@pasko70/pibo 3.2.6 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-mpRGeo_R.js","assets/dist-CqM4On9D.js","assets/dist-S3zJGntM.js","assets/dist-DHvUPfrF.js","assets/dist-DLJCGrGQ.js","assets/dist-LCx98fA_.js","assets/dist-DpF08Yd7.js","assets/dist-CLxh9uSM.js","assets/dist-RKTRnzGb.js","assets/dist-fPhZsAUX.js","assets/dist-BUupvbV9.js","assets/dist-DXdSiTyu.js","assets/dist-DTeLDijr.js","assets/dist-eddbbGyw.js","assets/dist-BJ-TIk3N.js","assets/dist-DMiglryg.js","assets/dist-XVYGiB-c.js","assets/dist-CswnpKik.js","assets/dockerfile-DJkHQgkl.js","assets/simple-mode-DXiLM1-G.js","assets/factor-LKH5gN8L.js","assets/nsis-CfSuhXs5.js","assets/pug-Gsm0M45u.js","assets/javascript-DoL9Wb-Q.js","assets/dist-B9gnHZqL.js","assets/dist-CR75V9VE.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-mpRGeo_R.js","assets/dist-CqM4On9D.js","assets/dist-S3zJGntM.js","assets/dist-DHvUPfrF.js","assets/dist-DLJCGrGQ.js","assets/dist-LCx98fA_.js","assets/dist-DpF08Yd7.js","assets/dist-DG6T1maU.js","assets/dist-RKTRnzGb.js","assets/dist-fPhZsAUX.js","assets/dist-CGgUuVB6.js","assets/dist-ENXYFYda.js","assets/dist-DTeLDijr.js","assets/dist-eddbbGyw.js","assets/dist-BJ-TIk3N.js","assets/dist-DMiglryg.js","assets/dist-XVYGiB-c.js","assets/dist-CswnpKik.js","assets/dockerfile-DJkHQgkl.js","assets/simple-mode-DXiLM1-G.js","assets/factor-LKH5gN8L.js","assets/nsis-CfSuhXs5.js","assets/pug-Gsm0M45u.js","assets/javascript-DoL9Wb-Q.js","assets/dist-CFtZTGHa.js","assets/dist-BikaGikn.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,n as t,o as n,s as r,t as i}from"./dist-DLJCGrGQ.js";import{$ as a,A as o,At as s,B as c,Bt as l,C as u,Ct as d,D as f,Dt as p,E as m,Et as h,F as g,Ft as _,G as v,H as y,Ht as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,N as O,Nt as k,O as A,P as j,Pt as M,Q as N,R as P,Rt as F,S as ee,St as I,T as L,Tt as R,U as te,V as z,Vt as ne,W as re,X as ie,Y as B,Z as ae,_ as oe,a as se,at as ce,b as le,bt as ue,c as de,ct as fe,d as pe,dt as me,et as he,f as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,j as Se,jt as V,k as Ce,kt as we,l as H,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as Ue,vt as We,w as Ge,wt as Ke,x as qe,xt as Je,y as Ye,yt as Xe,z as Ze,zt as Qe}from"./dist-CqM4On9D.js";import{a as $e,c as et,i as tt,n as nt,o as rt,r as it,s as at,t as ot}from"./dist-S3zJGntM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var st=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ee=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},I={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=I,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ee)}catch(e){ee(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),ct=e(((e,t)=>{t.exports=st()})),lt=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ut=e(((e,t)=>{t.exports=lt()})),dt=e((e=>{var t=ct();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),ft=e(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=dt()})),pt=e((e=>{var t=ut(),n=ct(),r=ft();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},ee=[],I=-1;function L(e){return{current:e}}function R(e){0>I||(e.current=ee[I],ee[I]=null,I--)}function te(e,t){I++,ee[I]=e.current,e.current=t}var z=L(null),ne=L(null),re=L(null),ie=L(null);function B(e,t){switch(te(re,t),te(ne,e),te(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}R(z),te(z,e)}function ae(){R(z),R(ne),R(re)}function oe(e){e.memoizedState!==null&&te(ie,e);var t=z.current,n=Kd(t,e.type);t!==n&&(te(ne,e),te(z,n))}function se(e){ne.current===e&&(R(z),R(ne)),ie.current===e&&(R(ie),tp._currentValue=F)}var ce,le;function ue(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,le=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ce+e+le}var de=!1;function fe(e,t){if(!e||de)return``;de=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -172,7 +172,7 @@ Error generating stack: `+e.message+`
172
172
  \${}
173
173
  }`,{label:`interface`,detail:`definition`,type:`keyword`}),et("type ${name} = ${type}",{label:`type`,detail:`definition`,type:`keyword`}),et(`enum \${name} {
174
174
  \${}
175
- }`,{label:`enum`,detail:`definition`,type:`keyword`})]),xL=new te,SL=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function CL(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var Nye=[`FunctionDeclaration`],Pye={FunctionDeclaration:CL(`function`),ClassDeclaration:CL(`class`),ClassExpression:()=>!0,EnumDeclaration:CL(`constant`),TypeAliasDeclaration:CL(`type`),NamespaceDeclaration:CL(`namespace`),VariableDefinition(e,t){e.matchContext(Nye)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function wL(e,t){let n=xL.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(Ze.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=Pye[t.name];if(e&&e(t,a)||SL.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of wL(e,t.node))r.push(n);return!1}}),xL.set(t,r),r}var TL=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,EL=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function DL(e){let t=g(e.state).resolveInner(e.pos,-1);if(EL.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&TL.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)SL.has(n.name)&&(r=r.concat(wL(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:TL}}var OL=Le.define({name:`javascript`,parser:Mye.configure({props:[f.add({IfStatement:ye({except:/^\s*({|else\b)/}),TryStatement:ye({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ye,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Ue({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":ye({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),u.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":qe,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),kL={test:e=>/^JSX/.test(e.name),facet:oe({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},AL=OL.configure({dialect:`ts`},`typescript`),jL=OL.configure({dialect:`jsx`,props:[O.add(e=>e.isTop?[kL]:void 0)]}),ML=OL.configure({dialect:`jsx ts`,props:[O.add(e=>e.isTop?[kL]:void 0)]},`typescript`),NL=e=>({label:e,type:`keyword`}),PL=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(NL),Fye=PL.concat([`declare`,`implements`,`private`,`protected`,`public`].map(NL));function FL(e={}){let t=e.jsx?e.typescript?ML:jL:e.typescript?AL:OL,n=e.typescript?bL.concat(Fye):yL.concat(PL);return new Ve(t,[OL.data.of({autocomplete:at(EL,$e(n))}),OL.data.of({autocomplete:DL}),e.jsx?LL:[]])}function Iye(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function IL(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var Lye=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),LL=B.inputHandler.of((e,t,n,r,i)=>{if((Lye?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!OL.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=g(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=IL(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:R.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=Iye(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=IL(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),Rye=n({autoCloseTags:()=>lR,html:()=>sR,htmlCompletionSource:()=>tR,htmlCompletionSourceWith:()=>nR,htmlLanguage:()=>oR}),RL=[`_blank`,`_self`,`_top`,`_parent`],zL=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],BL=[`get`,`post`,`put`,`delete`],VL=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],HL=[`true`,`false`],UL={},zye={a:{attrs:{href:null,ping:null,type:null,media:null,target:RL,hreflang:null}},abbr:UL,address:UL,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:UL,aside:UL,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:UL,base:{attrs:{href:null,target:RL}},bdi:UL,bdo:UL,blockquote:{attrs:{cite:null}},body:UL,br:UL,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:VL,formmethod:BL,formnovalidate:[`novalidate`],formtarget:RL,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:UL,center:UL,cite:UL,code:UL,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:UL,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:UL,div:UL,dl:UL,dt:UL,em:UL,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:UL,figure:UL,footer:UL,form:{attrs:{action:null,name:null,"accept-charset":zL,autocomplete:[`on`,`off`],enctype:VL,method:BL,novalidate:[`novalidate`],target:RL}},h1:UL,h2:UL,h3:UL,h4:UL,h5:UL,h6:UL,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:UL,hgroup:UL,hr:UL,html:{attrs:{manifest:null}},i:UL,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:VL,formmethod:BL,formnovalidate:[`novalidate`],formtarget:RL,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:UL,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:UL,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:UL,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:zL,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:UL,noscript:UL,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:UL,param:{attrs:{name:null,value:null}},pre:UL,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:UL,rt:UL,ruby:UL,samp:UL,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:zL}},section:UL,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:UL,source:{attrs:{src:null,type:null,media:null}},span:UL,strong:UL,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:UL,summary:UL,sup:UL,table:UL,tbody:UL,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:UL,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:UL,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:UL,time:{attrs:{datetime:null}},title:UL,tr:UL,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:UL,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:UL},WL={accesskey:null,class:null,contenteditable:HL,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:HL,autocorrect:HL,autocapitalize:HL,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":HL,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":HL,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":HL,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":HL,"aria-hidden":HL,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":HL,"aria-multiselectable":HL,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":HL,"aria-relevant":null,"aria-required":HL,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},GL=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of GL)WL[e]=null;var KL=class{constructor(e,t){this.tags={...zye,...e},this.globalAttrs={...WL,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};KL.default=new KL;function qL(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function JL(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`){if(t)t=!1;else return e}return null}function YL(e,t,n){return n.tags[qL(e,JL(t))]?.children||n.allTags}function XL(e,t){let n=[];for(let r=JL(t);r&&!r.type.isTop;r=JL(r.parent)){let i=qL(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var ZL=/^[:\-\.\w\u00b7-\uffff]*$/;function QL(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=JL(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:YL(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(XL(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function $L(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:XL(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:ZL}}function Bye(e,t,n,r){let i=[],a=0;for(let r of YL(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of XL(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Vye(e,t,n,r,i){let a=JL(n),o=a?t.tags[qL(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:ZL}}function Hye(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=JL(n),i=r?t.tags[qL(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function eR(e,t){let{state:n,pos:r}=t,i=g(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?$L(n,i,i.from,r):QL(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?QL(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?$L(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?Vye(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?Hye(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?Bye(n,e,i,r):null}function tR(e){return eR(KL.default,e)}function nR(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new KL(t,n):KL.default;return e=>eR(r,e)}var Uye=OL.parser.configure({top:`SingleExpression`}),rR=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:AL.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:jL.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:ML.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:Uye},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:OL.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:t.parser}],iR=[{name:`style`,parser:t.parser.configure({top:`Styles`})}].concat(GL.map(e=>({name:e,parser:OL.parser}))),aR=Le.define({name:`html`,parser:tye.configure({props:[f.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),u.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),Ee.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),oR=aR.configure({wrap:fL(rR,iR)});function sR(e={}){let t=``,n;e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=fL((e.nestedLanguages||[]).concat(rR),(e.nestedAttributes||[]).concat(iR)));let r=n?aR.configure({wrap:n,dialect:t}):t?oR.configure({dialect:t}):oR;return new Ve(r,[oR.data.of({autocomplete:nR(e)}),e.autoCloseTags===!1?[]:lR,FL().support,i().support])}var cR=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function Wye(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||qL(e,r)!=n)return!0;t=r}}var lR=B.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!oR.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=g(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if((a=qL(o.doc,t.parent,n))&&!cR.has(a)&&!Wye(o.doc,t.parent,a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=qL(o.doc,e,n))&&!cR.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:R.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)});function Gye(e,t,n,r){let i=Hd(HS),a=Wd(AC),o=U.useRef(null),{lexicalNode:s}=CF(),c=U.useRef(!1),l=U.useRef(!1),u=U.useCallback(()=>{a({editorType:t,rootNode:s,editorRef:o.current})},[t,s,a]),d=U.useCallback(t=>{if(t.key===`ArrowDown`){let t=o.current?.getCodemirror()?.state;t&&t.doc.length===t.selection.ranges[0].to&&(c.current?(i?.update(()=>{var t;let n=t_(e);n.getNextSibling()?((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectNext()):n.insertAfter(Mg())}),c.current=!1):c.current=!0)}else if(t.key===`ArrowUp`){let t=o.current?.getCodemirror()?.state;t&&t.selection.ranges[0].from===0&&(l.current?(i?.update(()=>{var t;let n=t_(e);n.getPreviousSibling()&&((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectPrevious())}),l.current=!1):l.current=!0)}else t.key===`Enter`?t.stopPropagation():(t.key===`Backspace`||t.key===`Delete`)&&(o.current?.getCodemirror()?.state)?.doc.length===0&&i?.update(()=>{t_(e).remove()})},[i,e]);return U.useEffect(()=>{let e=o.current;return setTimeout(()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.addEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.addEventListener(`keydown`,d)},300),()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.removeEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.removeEventListener(`keydown`,d)}},[o,u,d,n]),U.useEffect(()=>{r.subscribe(()=>{var e;(e=o.current?.getCodemirror())==null||e.focus(),u()})},[r,o,e,u]),o}function Z(e){return new Ve(ge.define(e))}function uR(e){return X(()=>import(`./dist-mpRGeo_R.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Kye=[H.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return X(()=>import(`./dist-DHvUPfrF.js`).then(e=>e.cpp()),__vite__mapDeps([3,1]))}}),H.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return X(()=>import(`./dist-DHvUPfrF.js`).then(e=>e.cpp()),__vite__mapDeps([3,1]))}}),H.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return uR(`Cassandra`)}}),H.of({name:`CSS`,extensions:[`css`],load(){return X(()=>import(`./dist-DLJCGrGQ.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,1]))}}),H.of({name:`Go`,extensions:[`go`],load(){return X(()=>import(`./dist-LCx98fA_.js`).then(e=>e.go()),__vite__mapDeps([5,1,2]))}}),H.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return X(()=>Promise.resolve().then(()=>Rye).then(e=>e.html()),void 0)}}),H.of({name:`Java`,extensions:[`java`],load(){return X(()=>import(`./dist-DpF08Yd7.js`).then(e=>e.java()),__vite__mapDeps([6,1]))}}),H.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript()),void 0)}}),H.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return X(()=>import(`./dist-CLxh9uSM.js`).then(e=>e.jinja()),__vite__mapDeps([7,1]))}}),H.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return X(()=>import(`./dist-RKTRnzGb.js`).then(e=>e.json()),__vite__mapDeps([8,1]))}}),H.of({name:`JSX`,extensions:[`jsx`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({jsx:!0})),void 0)}}),H.of({name:`LESS`,extensions:[`less`],load(){return X(()=>import(`./dist-fPhZsAUX.js`).then(e=>e.less()),__vite__mapDeps([9,4,1]))}}),H.of({name:`Liquid`,extensions:[`liquid`],load(){return X(()=>import(`./dist-BUupvbV9.js`).then(e=>e.liquid()),__vite__mapDeps([10,1]))}}),H.of({name:`MariaDB SQL`,load(){return uR(`MariaSQL`)}}),H.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return X(()=>Promise.resolve().then(()=>ZSe).then(e=>e.markdown()),void 0)}}),H.of({name:`MS SQL`,load(){return uR(`MSSQL`)}}),H.of({name:`MySQL`,load(){return uR(`MySQL`)}}),H.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return X(()=>import(`./dist-DXdSiTyu.js`).then(e=>e.php()),__vite__mapDeps([11,1]))}}),H.of({name:`PLSQL`,extensions:[`pls`],load(){return uR(`PLSQL`)}}),H.of({name:`PostgreSQL`,load(){return uR(`PostgreSQL`)}}),H.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return X(()=>import(`./dist-DTeLDijr.js`).then(e=>e.python()),__vite__mapDeps([12,1,2]))}}),H.of({name:`Rust`,extensions:[`rs`],load(){return X(()=>import(`./dist-eddbbGyw.js`).then(e=>e.rust()),__vite__mapDeps([13,1]))}}),H.of({name:`Sass`,extensions:[`sass`],load(){return X(()=>import(`./dist-BJ-TIk3N.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([14,4,1]))}}),H.of({name:`SCSS`,extensions:[`scss`],load(){return X(()=>import(`./dist-BJ-TIk3N.js`).then(e=>e.sass()),__vite__mapDeps([14,4,1]))}}),H.of({name:`SQL`,extensions:[`sql`],load(){return uR(`StandardSQL`)}}),H.of({name:`SQLite`,load(){return uR(`SQLite`)}}),H.of({name:`TSX`,extensions:[`tsx`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({jsx:!0,typescript:!0})),void 0)}}),H.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({typescript:!0})),void 0)}}),H.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return X(()=>import(`./dist-DMiglryg.js`).then(e=>e.wast()),__vite__mapDeps([15,1]))}}),H.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return X(()=>import(`./dist-XVYGiB-c.js`).then(e=>e.xml()),__vite__mapDeps([16,1]))}}),H.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return X(()=>import(`./dist-CswnpKik.js`).then(e=>e.yaml()),__vite__mapDeps([17,1]))}}),H.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return X(()=>import(`./apl-gfMMiTNf.js`).then(e=>Z(e.apl)),[])}}),H.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return X(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>Z(e.asciiArmor)),[])}}),H.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return X(()=>import(`./asn1-DCl_8MCW.js`).then(e=>Z(e.asn1({}))),[])}}),H.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return X(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>Z(e.asterisk)),[])}}),H.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return X(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>Z(e.brainfuck)),[])}}),H.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return X(()=>import(`./cobol-DHLQUbN7.js`).then(e=>Z(e.cobol)),[])}}),H.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.csharp)),[])}}),H.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`ClojureScript`,extensions:[`cljs`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return X(()=>import(`./css-CnaYoQib.js`).then(e=>Z(e.gss)),[])}}),H.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return X(()=>import(`./cmake-84nbDH0I.js`).then(e=>Z(e.cmake)),[])}}),H.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return X(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>Z(e.coffeeScript)),[])}}),H.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return X(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>Z(e.commonLisp)),[])}}),H.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return X(()=>import(`./cypher-p9eYesGn.js`).then(e=>Z(e.cypher)),[])}}),H.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return X(()=>import(`./python-B_1Jd8HM.js`).then(e=>Z(e.cython)),[])}}),H.of({name:`Crystal`,extensions:[`cr`],load(){return X(()=>import(`./crystal-Bsdphhtm.js`).then(e=>Z(e.crystal)),[])}}),H.of({name:`D`,extensions:[`d`],load(){return X(()=>import(`./d-DWkQyNnU.js`).then(e=>Z(e.d)),[])}}),H.of({name:`Dart`,extensions:[`dart`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.dart)),[])}}),H.of({name:`diff`,extensions:[`diff`,`patch`],load(){return X(()=>import(`./diff-ChtP43wD.js`).then(e=>Z(e.diff)),[])}}),H.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return X(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>Z(e.dockerFile)),__vite__mapDeps([18,19]))}}),H.of({name:`DTD`,extensions:[`dtd`],load(){return X(()=>import(`./dtd-DTF72YNO.js`).then(e=>Z(e.dtd)),[])}}),H.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return X(()=>import(`./dylan-BCDoL_-p.js`).then(e=>Z(e.dylan)),[])}}),H.of({name:`EBNF`,load(){return X(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>Z(e.ebnf)),[])}}),H.of({name:`ECL`,extensions:[`ecl`],load(){return X(()=>import(`./ecl-BVIeWmwY.js`).then(e=>Z(e.ecl)),[])}}),H.of({name:`edn`,extensions:[`edn`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`Eiffel`,extensions:[`e`],load(){return X(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>Z(e.eiffel)),[])}}),H.of({name:`Elm`,extensions:[`elm`],load(){return X(()=>import(`./elm-Cshzl8qu.js`).then(e=>Z(e.elm)),[])}}),H.of({name:`Erlang`,extensions:[`erl`],load(){return X(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>Z(e.erlang)),[])}}),H.of({name:`Esper`,load(){return X(()=>import(`./sql-DuQMFDvy.js`).then(e=>Z(e.esper)),[])}}),H.of({name:`Factor`,extensions:[`factor`],load(){return X(()=>import(`./factor-LKH5gN8L.js`).then(e=>Z(e.factor)),__vite__mapDeps([20,19]))}}),H.of({name:`FCL`,load(){return X(()=>import(`./fcl-ClOhbFR7.js`).then(e=>Z(e.fcl)),[])}}),H.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return X(()=>import(`./forth-Cezjo90N.js`).then(e=>Z(e.forth)),[])}}),H.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return X(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>Z(e.fortran)),[])}}),H.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.fSharp)),[])}}),H.of({name:`Gas`,extensions:[`s`],load(){return X(()=>import(`./gas-BHEdbvp9.js`).then(e=>Z(e.gas)),[])}}),H.of({name:`Gherkin`,extensions:[`feature`],load(){return X(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>Z(e.gherkin)),[])}}),H.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return X(()=>import(`./groovy-CUpZ7dEl.js`).then(e=>Z(e.groovy)),[])}}),H.of({name:`Haskell`,extensions:[`hs`],load(){return X(()=>import(`./haskell-BRsoo5mP.js`).then(e=>Z(e.haskell)),[])}}),H.of({name:`Haxe`,extensions:[`hx`],load(){return X(()=>import(`./haxe-DjVOVvNP.js`).then(e=>Z(e.haxe)),[])}}),H.of({name:`HXML`,extensions:[`hxml`],load(){return X(()=>import(`./haxe-DjVOVvNP.js`).then(e=>Z(e.hxml)),[])}}),H.of({name:`HTTP`,load(){return X(()=>import(`./http-CLVgA2GD.js`).then(e=>Z(e.http)),[])}}),H.of({name:`IDL`,extensions:[`pro`],load(){return X(()=>import(`./idl-BUZw3wgd.js`).then(e=>Z(e.idl)),[])}}),H.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return X(()=>import(`./javascript-DoL9Wb-Q.js`).then(e=>Z(e.jsonld)),[])}}),H.of({name:`Julia`,extensions:[`jl`],load(){return X(()=>import(`./julia-CQfgDRfP.js`).then(e=>Z(e.julia)),[])}}),H.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.kotlin)),[])}}),H.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return X(()=>import(`./livescript-BXxG0Yva.js`).then(e=>Z(e.liveScript)),[])}}),H.of({name:`Lua`,extensions:[`lua`],load(){return X(()=>import(`./lua-CiA1ziua.js`).then(e=>Z(e.lua)),[])}}),H.of({name:`mIRC`,extensions:[`mrc`],load(){return X(()=>import(`./mirc-C9zpzAZU.js`).then(e=>Z(e.mirc)),[])}}),H.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return X(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>Z(e.mathematica)),[])}}),H.of({name:`Modelica`,extensions:[`mo`],load(){return X(()=>import(`./modelica-CqHI_q-D.js`).then(e=>Z(e.modelica)),[])}}),H.of({name:`MUMPS`,extensions:[`mps`],load(){return X(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>Z(e.mumps)),[])}}),H.of({name:`Mbox`,extensions:[`mbox`],load(){return X(()=>import(`./mbox-BEMVcqjs.js`).then(e=>Z(e.mbox)),[])}}),H.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return X(()=>import(`./nginx-BMaDbqW3.js`).then(e=>Z(e.nginx)),[])}}),H.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return X(()=>import(`./nsis-CfSuhXs5.js`).then(e=>Z(e.nsis)),__vite__mapDeps([21,19]))}}),H.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return X(()=>import(`./ntriples-B9h1VB_g.js`).then(e=>Z(e.ntriples)),[])}}),H.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.objectiveC)),[])}}),H.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.objectiveCpp)),[])}}),H.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.oCaml)),[])}}),H.of({name:`Octave`,extensions:[`m`],load(){return X(()=>import(`./octave-D2Q8cUp1.js`).then(e=>Z(e.octave)),[])}}),H.of({name:`Oz`,extensions:[`oz`],load(){return X(()=>import(`./oz-BwTct_5T.js`).then(e=>Z(e.oz)),[])}}),H.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return X(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>Z(e.pascal)),[])}}),H.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return X(()=>import(`./perl-BkSkiI9m.js`).then(e=>Z(e.perl)),[])}}),H.of({name:`Pig`,extensions:[`pig`],load(){return X(()=>import(`./pig-AF4Hwhju.js`).then(e=>Z(e.pig)),[])}}),H.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return X(()=>import(`./powershell-BcIto6Sf.js`).then(e=>Z(e.powerShell)),[])}}),H.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return X(()=>import(`./properties-C357ku5U.js`).then(e=>Z(e.properties)),[])}}),H.of({name:`ProtoBuf`,extensions:[`proto`],load(){return X(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>Z(e.protobuf)),[])}}),H.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return X(()=>import(`./pug-Gsm0M45u.js`).then(e=>Z(e.pug)),__vite__mapDeps([22,23]))}}),H.of({name:`Puppet`,extensions:[`pp`],load(){return X(()=>import(`./puppet-BZyAS7I4.js`).then(e=>Z(e.puppet)),[])}}),H.of({name:`Q`,extensions:[`q`],load(){return X(()=>import(`./q-B9NhS7L_.js`).then(e=>Z(e.q)),[])}}),H.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return X(()=>import(`./r-CxDmU1I4.js`).then(e=>Z(e.r)),[])}}),H.of({name:`RPM Changes`,load(){return X(()=>import(`./rpm-gpDK5sbt.js`).then(e=>Z(e.rpmChanges)),[])}}),H.of({name:`RPM Spec`,extensions:[`spec`],load(){return X(()=>import(`./rpm-gpDK5sbt.js`).then(e=>Z(e.rpmSpec)),[])}}),H.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return X(()=>import(`./ruby-BjXV7-Qa.js`).then(e=>Z(e.ruby)),[])}}),H.of({name:`SAS`,extensions:[`sas`],load(){return X(()=>import(`./sas-C2OyD2Y6.js`).then(e=>Z(e.sas)),[])}}),H.of({name:`Scala`,extensions:[`scala`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.scala)),[])}}),H.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return X(()=>import(`./scheme-D9qYN0V5.js`).then(e=>Z(e.scheme)),[])}}),H.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return X(()=>import(`./shell-DwuoZtxw.js`).then(e=>Z(e.shell)),[])}}),H.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return X(()=>import(`./sieve-BAxa3IjF.js`).then(e=>Z(e.sieve)),[])}}),H.of({name:`Smalltalk`,extensions:[`st`],load(){return X(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>Z(e.smalltalk)),[])}}),H.of({name:`Solr`,load(){return X(()=>import(`./solr-BBopId9w.js`).then(e=>Z(e.solr)),[])}}),H.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.sml)),[])}}),H.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return X(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>Z(e.sparql)),[])}}),H.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return X(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>Z(e.spreadsheet)),[])}}),H.of({name:`Squirrel`,extensions:[`nut`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.squirrel)),[])}}),H.of({name:`Stylus`,extensions:[`styl`],load(){return X(()=>import(`./stylus-BOVgKnng.js`).then(e=>Z(e.stylus)),[])}}),H.of({name:`Swift`,extensions:[`swift`],load(){return X(()=>import(`./swift-DKB6_1j6.js`).then(e=>Z(e.swift)),[])}}),H.of({name:`sTeX`,load(){return X(()=>import(`./stex-DNzd62Q_.js`).then(e=>Z(e.stex)),[])}}),H.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return X(()=>import(`./stex-DNzd62Q_.js`).then(e=>Z(e.stex)),[])}}),H.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return X(()=>import(`./verilog-7LoJAqYT.js`).then(e=>Z(e.verilog)),[])}}),H.of({name:`Tcl`,extensions:[`tcl`],load(){return X(()=>import(`./tcl-BGfruO1u.js`).then(e=>Z(e.tcl)),[])}}),H.of({name:`Textile`,extensions:[`textile`],load(){return X(()=>import(`./textile-C4jVoHG1.js`).then(e=>Z(e.textile)),[])}}),H.of({name:`TiddlyWiki`,load(){return X(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>Z(e.tiddlyWiki)),[])}}),H.of({name:`Tiki wiki`,load(){return X(()=>import(`./tiki-AK6FwT8q.js`).then(e=>Z(e.tiki)),[])}}),H.of({name:`TOML`,extensions:[`toml`],load(){return X(()=>import(`./toml-BPTmHmyx.js`).then(e=>Z(e.toml)),[])}}),H.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return X(()=>import(`./troff-C2dAgh7P.js`).then(e=>Z(e.troff)),[])}}),H.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return X(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>Z(e.ttcn)),[])}}),H.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return X(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>Z(e.ttcnCfg)),[])}}),H.of({name:`Turtle`,extensions:[`ttl`],load(){return X(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>Z(e.turtle)),[])}}),H.of({name:`Web IDL`,extensions:[`webidl`],load(){return X(()=>import(`./webidl-D5jiJvOU.js`).then(e=>Z(e.webIDL)),[])}}),H.of({name:`VB.NET`,extensions:[`vb`],load(){return X(()=>import(`./vb-BthdM_4N.js`).then(e=>Z(e.vb)),[])}}),H.of({name:`VBScript`,extensions:[`vbs`],load(){return X(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>Z(e.vbScript)),[])}}),H.of({name:`Velocity`,extensions:[`vtl`],load(){return X(()=>import(`./velocity-CqftRsjg.js`).then(e=>Z(e.velocity)),[])}}),H.of({name:`Verilog`,extensions:[`v`],load(){return X(()=>import(`./verilog-7LoJAqYT.js`).then(e=>Z(e.verilog)),[])}}),H.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return X(()=>import(`./vhdl-kS471soi.js`).then(e=>Z(e.vhdl)),[])}}),H.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return X(()=>import(`./xquery-BKJx4mf9.js`).then(e=>Z(e.xQuery)),[])}}),H.of({name:`Yacas`,extensions:[`ys`],load(){return X(()=>import(`./yacas-CXXgtw0p.js`).then(e=>Z(e.yacas)),[])}}),H.of({name:`Z80`,extensions:[`z80`],load(){return X(()=>import(`./z80-Co3PbHdE.js`).then(e=>Z(e.z80)),[])}}),H.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.mscgen)),[])}}),H.of({name:`Xù`,extensions:[`xu`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.xu)),[])}}),H.of({name:`MsGenny`,extensions:[`msgenny`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.msgenny)),[])}}),H.of({name:`Vue`,extensions:[`vue`],load(){return X(()=>import(`./dist-B9gnHZqL.js`).then(e=>e.vue()),__vite__mapDeps([24,1]))}}),H.of({name:`Angular Template`,load(){return X(()=>import(`./dist-CR75V9VE.js`).then(e=>e.angular()),__vite__mapDeps([25,1]))}})],dR=`#2e3440`,fR=`#3b4252`,pR=`#434c5e`,mR=`#4c566a`,hR=`#e5e9f0`,gR=`#eceff4`,_R=`#8fbcbb`,vR=`#88c0d0`,qye=`#81a1c1`,yR=`#5e81ac`,Jye=`#bf616a`,bR=`#d08770`,xR=`#ebcb8b`,SR=`#a3be8c`,Yye=`#b48ead`,CR=`#d30102`,wR=gR,TR=wR,Xye=`#ffffff`,ER=fR,Zye=wR,DR=fR,Qye=B.theme({"&":{color:dR,backgroundColor:Xye},".cm-content":{caretColor:DR},".cm-cursor, .cm-dropCursor":{borderLeftColor:DR},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Zye},".cm-panels":{backgroundColor:wR,color:mR},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid ${mR}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:hR},".cm-activeLine":{backgroundColor:TR},".cm-selectionMatch":{backgroundColor:hR},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${mR}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:gR},".cm-gutters":{backgroundColor:gR,color:dR,border:`none`},".cm-activeLineGutter":{backgroundColor:TR},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:ER},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ER,borderBottomColor:ER},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:TR,color:mR}}},{dark:!1}),$ye=se.define([{tag:P.keyword,color:yR},{tag:[P.name,P.deleted,P.character,P.propertyName,P.macroName],color:bR},{tag:[P.variableName],color:bR},{tag:[P.function(P.variableName)],color:yR},{tag:[P.labelName],color:qye},{tag:[P.color,P.constant(P.name),P.standard(P.name)],color:yR},{tag:[P.definition(P.name),P.separator],color:SR},{tag:[P.brace],color:_R},{tag:[P.annotation],color:CR},{tag:[P.number,P.changed,P.annotation,P.modifier,P.self,P.namespace],color:vR},{tag:[P.typeName,P.className],color:xR},{tag:[P.operator,P.operatorKeyword],color:SR},{tag:[P.tagName],color:Yye},{tag:[P.squareBracket],color:Jye},{tag:[P.angleBracket],color:bR},{tag:[P.attributeName],color:xR},{tag:[P.regexp],color:yR},{tag:[P.quote],color:fR},{tag:[P.string],color:bR},{tag:P.link,color:_R,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[P.url,P.escape,P.special(P.string)],color:bR},{tag:[P.meta],color:vR},{tag:[P.comment],color:pR,fontStyle:`italic`},{tag:P.strong,fontWeight:`bold`,color:yR},{tag:P.emphasis,fontStyle:`italic`,color:yR},{tag:P.strikethrough,textDecoration:`line-through`},{tag:P.heading,fontWeight:`bold`,color:yR},{tag:P.special(P.heading1),fontWeight:`bold`,color:yR},{tag:P.heading1,fontWeight:`bold`,color:yR},{tag:[P.heading2,P.heading3,P.heading4],fontWeight:`bold`,color:yR},{tag:[P.heading5,P.heading6],color:yR},{tag:[P.atom,P.bool,P.special(P.variableName)],color:bR},{tag:[P.processingInstruction,P.inserted],color:_R},{tag:[P.contentSeparator],color:xR},{tag:P.invalid,color:pR,borderBottom:`1px dotted ${CR}`}]),OR=[Qye,j($ye)],kR=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,AR=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(kR(e)):kR,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return E(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=b(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=F(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(AR.prototype[Symbol.iterator]=function(){return this});var jR={from:-1,to:-1,match:/.*/.exec(``),precise:!0},MR=`gm`+(/x/.unicode==null?``:`u`),NR=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=jR,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new IR(e,t,n,r,i);this.re=new RegExp(t,MR+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=LR(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=LR(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},PR=new WeakMap,FR=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=PR.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return PR.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),PR.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},IR=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=jR,this.matchPos=LR(e,r),this.re=new RegExp(t,MR+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=FR.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=LR(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FR.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(NR.prototype[Symbol.iterator]=IR.prototype[Symbol.iterator]=function(){return this});function ebe(e){try{return new RegExp(e,MR),!0}catch{return!1}}function LR(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var tbe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=be(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=R.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,B.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},nbe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},RR=p.define({combine(e){return Qe(e,nbe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function rbe(e){let t=[cbe,sbe];return e&&t.push(RR.of(e)),t}var ibe=Pe.mark({class:`cm-selectionMatch`}),abe=Pe.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function zR(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=d.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=d.Word)}function obe(e,t,n,r){return e(t.sliceDoc(n,n+1))==d.Word&&e(t.sliceDoc(r-1,r))==d.Word}var sbe=ae.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(RR),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Pe.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return Pe.none;let e=n.wordAt(i.head);if(!e)return Pe.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return Pe.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(zR(o,n,i.from,i.to)&&obe(o,n,i.from,i.to)))return Pe.none}else if(a=n.sliceDoc(i.from,i.to),!a)return Pe.none}let s=[];for(let r of e.visibleRanges){let e=new AR(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||zR(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(abe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ibe.range(r,a)),s.length>t.maxMatches))return Pe.none}}return Pe.set(s)}},{decorations:e=>e.decorations}),cbe=B.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),lbe=({state:e,dispatch:t})=>{let{selection:n}=e,r=R.create(n.ranges.map(t=>e.wordAt(t.head)||R.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function ube(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new AR(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new AR(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var dbe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return lbe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ube(e,r);return i?(t(e.update({selection:e.selection.addRange(R.range(i.from,i.to),!1),effects:B.scrollIntoView(i.to)})),!0):!1},BR=p.define({combine(e){return Qe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Tbe(e),scrollToMatch:e=>B.scrollIntoView(e)})}}),VR=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||ebe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
175
+ }`,{label:`enum`,detail:`definition`,type:`keyword`})]),xL=new te,SL=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function CL(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var Nye=[`FunctionDeclaration`],Pye={FunctionDeclaration:CL(`function`),ClassDeclaration:CL(`class`),ClassExpression:()=>!0,EnumDeclaration:CL(`constant`),TypeAliasDeclaration:CL(`type`),NamespaceDeclaration:CL(`namespace`),VariableDefinition(e,t){e.matchContext(Nye)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function wL(e,t){let n=xL.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(Ze.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=Pye[t.name];if(e&&e(t,a)||SL.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of wL(e,t.node))r.push(n);return!1}}),xL.set(t,r),r}var TL=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,EL=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function DL(e){let t=g(e.state).resolveInner(e.pos,-1);if(EL.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&TL.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)SL.has(n.name)&&(r=r.concat(wL(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:TL}}var OL=Le.define({name:`javascript`,parser:Mye.configure({props:[f.add({IfStatement:ye({except:/^\s*({|else\b)/}),TryStatement:ye({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ye,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Ue({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":ye({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),u.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":qe,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),kL={test:e=>/^JSX/.test(e.name),facet:oe({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},AL=OL.configure({dialect:`ts`},`typescript`),jL=OL.configure({dialect:`jsx`,props:[O.add(e=>e.isTop?[kL]:void 0)]}),ML=OL.configure({dialect:`jsx ts`,props:[O.add(e=>e.isTop?[kL]:void 0)]},`typescript`),NL=e=>({label:e,type:`keyword`}),PL=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(NL),Fye=PL.concat([`declare`,`implements`,`private`,`protected`,`public`].map(NL));function FL(e={}){let t=e.jsx?e.typescript?ML:jL:e.typescript?AL:OL,n=e.typescript?bL.concat(Fye):yL.concat(PL);return new Ve(t,[OL.data.of({autocomplete:at(EL,$e(n))}),OL.data.of({autocomplete:DL}),e.jsx?LL:[]])}function Iye(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function IL(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var Lye=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),LL=B.inputHandler.of((e,t,n,r,i)=>{if((Lye?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!OL.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=g(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=IL(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:R.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=Iye(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=IL(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),Rye=n({autoCloseTags:()=>lR,html:()=>sR,htmlCompletionSource:()=>tR,htmlCompletionSourceWith:()=>nR,htmlLanguage:()=>oR}),RL=[`_blank`,`_self`,`_top`,`_parent`],zL=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],BL=[`get`,`post`,`put`,`delete`],VL=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],HL=[`true`,`false`],UL={},zye={a:{attrs:{href:null,ping:null,type:null,media:null,target:RL,hreflang:null}},abbr:UL,address:UL,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:UL,aside:UL,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:UL,base:{attrs:{href:null,target:RL}},bdi:UL,bdo:UL,blockquote:{attrs:{cite:null}},body:UL,br:UL,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:VL,formmethod:BL,formnovalidate:[`novalidate`],formtarget:RL,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:UL,center:UL,cite:UL,code:UL,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:UL,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:UL,div:UL,dl:UL,dt:UL,em:UL,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:UL,figure:UL,footer:UL,form:{attrs:{action:null,name:null,"accept-charset":zL,autocomplete:[`on`,`off`],enctype:VL,method:BL,novalidate:[`novalidate`],target:RL}},h1:UL,h2:UL,h3:UL,h4:UL,h5:UL,h6:UL,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:UL,hgroup:UL,hr:UL,html:{attrs:{manifest:null}},i:UL,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:VL,formmethod:BL,formnovalidate:[`novalidate`],formtarget:RL,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:UL,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:UL,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:UL,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:zL,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:UL,noscript:UL,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:UL,param:{attrs:{name:null,value:null}},pre:UL,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:UL,rt:UL,ruby:UL,samp:UL,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:zL}},section:UL,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:UL,source:{attrs:{src:null,type:null,media:null}},span:UL,strong:UL,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:UL,summary:UL,sup:UL,table:UL,tbody:UL,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:UL,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:UL,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:UL,time:{attrs:{datetime:null}},title:UL,tr:UL,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:UL,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:UL},WL={accesskey:null,class:null,contenteditable:HL,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:HL,autocorrect:HL,autocapitalize:HL,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":HL,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":HL,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":HL,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":HL,"aria-hidden":HL,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":HL,"aria-multiselectable":HL,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":HL,"aria-relevant":null,"aria-required":HL,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},GL=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of GL)WL[e]=null;var KL=class{constructor(e,t){this.tags={...zye,...e},this.globalAttrs={...WL,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};KL.default=new KL;function qL(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function JL(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`){if(t)t=!1;else return e}return null}function YL(e,t,n){return n.tags[qL(e,JL(t))]?.children||n.allTags}function XL(e,t){let n=[];for(let r=JL(t);r&&!r.type.isTop;r=JL(r.parent)){let i=qL(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var ZL=/^[:\-\.\w\u00b7-\uffff]*$/;function QL(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=JL(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:YL(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(XL(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function $L(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:XL(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:ZL}}function Bye(e,t,n,r){let i=[],a=0;for(let r of YL(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of XL(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Vye(e,t,n,r,i){let a=JL(n),o=a?t.tags[qL(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:ZL}}function Hye(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=JL(n),i=r?t.tags[qL(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function eR(e,t){let{state:n,pos:r}=t,i=g(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?$L(n,i,i.from,r):QL(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?QL(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?$L(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?Vye(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?Hye(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?Bye(n,e,i,r):null}function tR(e){return eR(KL.default,e)}function nR(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new KL(t,n):KL.default;return e=>eR(r,e)}var Uye=OL.parser.configure({top:`SingleExpression`}),rR=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:AL.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:jL.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:ML.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:Uye},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:OL.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:t.parser}],iR=[{name:`style`,parser:t.parser.configure({top:`Styles`})}].concat(GL.map(e=>({name:e,parser:OL.parser}))),aR=Le.define({name:`html`,parser:tye.configure({props:[f.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),u.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),Ee.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),oR=aR.configure({wrap:fL(rR,iR)});function sR(e={}){let t=``,n;e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=fL((e.nestedLanguages||[]).concat(rR),(e.nestedAttributes||[]).concat(iR)));let r=n?aR.configure({wrap:n,dialect:t}):t?oR.configure({dialect:t}):oR;return new Ve(r,[oR.data.of({autocomplete:nR(e)}),e.autoCloseTags===!1?[]:lR,FL().support,i().support])}var cR=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function Wye(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||qL(e,r)!=n)return!0;t=r}}var lR=B.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!oR.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=g(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if((a=qL(o.doc,t.parent,n))&&!cR.has(a)&&!Wye(o.doc,t.parent,a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=qL(o.doc,e,n))&&!cR.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:R.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)});function Gye(e,t,n,r){let i=Hd(HS),a=Wd(AC),o=U.useRef(null),{lexicalNode:s}=CF(),c=U.useRef(!1),l=U.useRef(!1),u=U.useCallback(()=>{a({editorType:t,rootNode:s,editorRef:o.current})},[t,s,a]),d=U.useCallback(t=>{if(t.key===`ArrowDown`){let t=o.current?.getCodemirror()?.state;t&&t.doc.length===t.selection.ranges[0].to&&(c.current?(i?.update(()=>{var t;let n=t_(e);n.getNextSibling()?((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectNext()):n.insertAfter(Mg())}),c.current=!1):c.current=!0)}else if(t.key===`ArrowUp`){let t=o.current?.getCodemirror()?.state;t&&t.selection.ranges[0].from===0&&(l.current?(i?.update(()=>{var t;let n=t_(e);n.getPreviousSibling()&&((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectPrevious())}),l.current=!1):l.current=!0)}else t.key===`Enter`?t.stopPropagation():(t.key===`Backspace`||t.key===`Delete`)&&(o.current?.getCodemirror()?.state)?.doc.length===0&&i?.update(()=>{t_(e).remove()})},[i,e]);return U.useEffect(()=>{let e=o.current;return setTimeout(()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.addEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.addEventListener(`keydown`,d)},300),()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.removeEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.removeEventListener(`keydown`,d)}},[o,u,d,n]),U.useEffect(()=>{r.subscribe(()=>{var e;(e=o.current?.getCodemirror())==null||e.focus(),u()})},[r,o,e,u]),o}function Z(e){return new Ve(ge.define(e))}function uR(e){return X(()=>import(`./dist-mpRGeo_R.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Kye=[H.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return X(()=>import(`./dist-DHvUPfrF.js`).then(e=>e.cpp()),__vite__mapDeps([3,1]))}}),H.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return X(()=>import(`./dist-DHvUPfrF.js`).then(e=>e.cpp()),__vite__mapDeps([3,1]))}}),H.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return uR(`Cassandra`)}}),H.of({name:`CSS`,extensions:[`css`],load(){return X(()=>import(`./dist-DLJCGrGQ.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,1]))}}),H.of({name:`Go`,extensions:[`go`],load(){return X(()=>import(`./dist-LCx98fA_.js`).then(e=>e.go()),__vite__mapDeps([5,1,2]))}}),H.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return X(()=>Promise.resolve().then(()=>Rye).then(e=>e.html()),void 0)}}),H.of({name:`Java`,extensions:[`java`],load(){return X(()=>import(`./dist-DpF08Yd7.js`).then(e=>e.java()),__vite__mapDeps([6,1]))}}),H.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript()),void 0)}}),H.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return X(()=>import(`./dist-DG6T1maU.js`).then(e=>e.jinja()),__vite__mapDeps([7,1]))}}),H.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return X(()=>import(`./dist-RKTRnzGb.js`).then(e=>e.json()),__vite__mapDeps([8,1]))}}),H.of({name:`JSX`,extensions:[`jsx`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({jsx:!0})),void 0)}}),H.of({name:`LESS`,extensions:[`less`],load(){return X(()=>import(`./dist-fPhZsAUX.js`).then(e=>e.less()),__vite__mapDeps([9,4,1]))}}),H.of({name:`Liquid`,extensions:[`liquid`],load(){return X(()=>import(`./dist-CGgUuVB6.js`).then(e=>e.liquid()),__vite__mapDeps([10,1]))}}),H.of({name:`MariaDB SQL`,load(){return uR(`MariaSQL`)}}),H.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return X(()=>Promise.resolve().then(()=>ZSe).then(e=>e.markdown()),void 0)}}),H.of({name:`MS SQL`,load(){return uR(`MSSQL`)}}),H.of({name:`MySQL`,load(){return uR(`MySQL`)}}),H.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return X(()=>import(`./dist-ENXYFYda.js`).then(e=>e.php()),__vite__mapDeps([11,1]))}}),H.of({name:`PLSQL`,extensions:[`pls`],load(){return uR(`PLSQL`)}}),H.of({name:`PostgreSQL`,load(){return uR(`PostgreSQL`)}}),H.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return X(()=>import(`./dist-DTeLDijr.js`).then(e=>e.python()),__vite__mapDeps([12,1,2]))}}),H.of({name:`Rust`,extensions:[`rs`],load(){return X(()=>import(`./dist-eddbbGyw.js`).then(e=>e.rust()),__vite__mapDeps([13,1]))}}),H.of({name:`Sass`,extensions:[`sass`],load(){return X(()=>import(`./dist-BJ-TIk3N.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([14,4,1]))}}),H.of({name:`SCSS`,extensions:[`scss`],load(){return X(()=>import(`./dist-BJ-TIk3N.js`).then(e=>e.sass()),__vite__mapDeps([14,4,1]))}}),H.of({name:`SQL`,extensions:[`sql`],load(){return uR(`StandardSQL`)}}),H.of({name:`SQLite`,load(){return uR(`SQLite`)}}),H.of({name:`TSX`,extensions:[`tsx`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({jsx:!0,typescript:!0})),void 0)}}),H.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return X(()=>Promise.resolve().then(()=>vL).then(e=>e.javascript({typescript:!0})),void 0)}}),H.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return X(()=>import(`./dist-DMiglryg.js`).then(e=>e.wast()),__vite__mapDeps([15,1]))}}),H.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return X(()=>import(`./dist-XVYGiB-c.js`).then(e=>e.xml()),__vite__mapDeps([16,1]))}}),H.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return X(()=>import(`./dist-CswnpKik.js`).then(e=>e.yaml()),__vite__mapDeps([17,1]))}}),H.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return X(()=>import(`./apl-gfMMiTNf.js`).then(e=>Z(e.apl)),[])}}),H.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return X(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>Z(e.asciiArmor)),[])}}),H.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return X(()=>import(`./asn1-DCl_8MCW.js`).then(e=>Z(e.asn1({}))),[])}}),H.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return X(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>Z(e.asterisk)),[])}}),H.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return X(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>Z(e.brainfuck)),[])}}),H.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return X(()=>import(`./cobol-DHLQUbN7.js`).then(e=>Z(e.cobol)),[])}}),H.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.csharp)),[])}}),H.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`ClojureScript`,extensions:[`cljs`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return X(()=>import(`./css-CnaYoQib.js`).then(e=>Z(e.gss)),[])}}),H.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return X(()=>import(`./cmake-84nbDH0I.js`).then(e=>Z(e.cmake)),[])}}),H.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return X(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>Z(e.coffeeScript)),[])}}),H.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return X(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>Z(e.commonLisp)),[])}}),H.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return X(()=>import(`./cypher-p9eYesGn.js`).then(e=>Z(e.cypher)),[])}}),H.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return X(()=>import(`./python-B_1Jd8HM.js`).then(e=>Z(e.cython)),[])}}),H.of({name:`Crystal`,extensions:[`cr`],load(){return X(()=>import(`./crystal-Bsdphhtm.js`).then(e=>Z(e.crystal)),[])}}),H.of({name:`D`,extensions:[`d`],load(){return X(()=>import(`./d-DWkQyNnU.js`).then(e=>Z(e.d)),[])}}),H.of({name:`Dart`,extensions:[`dart`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.dart)),[])}}),H.of({name:`diff`,extensions:[`diff`,`patch`],load(){return X(()=>import(`./diff-ChtP43wD.js`).then(e=>Z(e.diff)),[])}}),H.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return X(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>Z(e.dockerFile)),__vite__mapDeps([18,19]))}}),H.of({name:`DTD`,extensions:[`dtd`],load(){return X(()=>import(`./dtd-DTF72YNO.js`).then(e=>Z(e.dtd)),[])}}),H.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return X(()=>import(`./dylan-BCDoL_-p.js`).then(e=>Z(e.dylan)),[])}}),H.of({name:`EBNF`,load(){return X(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>Z(e.ebnf)),[])}}),H.of({name:`ECL`,extensions:[`ecl`],load(){return X(()=>import(`./ecl-BVIeWmwY.js`).then(e=>Z(e.ecl)),[])}}),H.of({name:`edn`,extensions:[`edn`],load(){return X(()=>import(`./clojure-BflJGmDX.js`).then(e=>Z(e.clojure)),[])}}),H.of({name:`Eiffel`,extensions:[`e`],load(){return X(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>Z(e.eiffel)),[])}}),H.of({name:`Elm`,extensions:[`elm`],load(){return X(()=>import(`./elm-Cshzl8qu.js`).then(e=>Z(e.elm)),[])}}),H.of({name:`Erlang`,extensions:[`erl`],load(){return X(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>Z(e.erlang)),[])}}),H.of({name:`Esper`,load(){return X(()=>import(`./sql-DuQMFDvy.js`).then(e=>Z(e.esper)),[])}}),H.of({name:`Factor`,extensions:[`factor`],load(){return X(()=>import(`./factor-LKH5gN8L.js`).then(e=>Z(e.factor)),__vite__mapDeps([20,19]))}}),H.of({name:`FCL`,load(){return X(()=>import(`./fcl-ClOhbFR7.js`).then(e=>Z(e.fcl)),[])}}),H.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return X(()=>import(`./forth-Cezjo90N.js`).then(e=>Z(e.forth)),[])}}),H.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return X(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>Z(e.fortran)),[])}}),H.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.fSharp)),[])}}),H.of({name:`Gas`,extensions:[`s`],load(){return X(()=>import(`./gas-BHEdbvp9.js`).then(e=>Z(e.gas)),[])}}),H.of({name:`Gherkin`,extensions:[`feature`],load(){return X(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>Z(e.gherkin)),[])}}),H.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return X(()=>import(`./groovy-CUpZ7dEl.js`).then(e=>Z(e.groovy)),[])}}),H.of({name:`Haskell`,extensions:[`hs`],load(){return X(()=>import(`./haskell-BRsoo5mP.js`).then(e=>Z(e.haskell)),[])}}),H.of({name:`Haxe`,extensions:[`hx`],load(){return X(()=>import(`./haxe-DjVOVvNP.js`).then(e=>Z(e.haxe)),[])}}),H.of({name:`HXML`,extensions:[`hxml`],load(){return X(()=>import(`./haxe-DjVOVvNP.js`).then(e=>Z(e.hxml)),[])}}),H.of({name:`HTTP`,load(){return X(()=>import(`./http-CLVgA2GD.js`).then(e=>Z(e.http)),[])}}),H.of({name:`IDL`,extensions:[`pro`],load(){return X(()=>import(`./idl-BUZw3wgd.js`).then(e=>Z(e.idl)),[])}}),H.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return X(()=>import(`./javascript-DoL9Wb-Q.js`).then(e=>Z(e.jsonld)),[])}}),H.of({name:`Julia`,extensions:[`jl`],load(){return X(()=>import(`./julia-CQfgDRfP.js`).then(e=>Z(e.julia)),[])}}),H.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.kotlin)),[])}}),H.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return X(()=>import(`./livescript-BXxG0Yva.js`).then(e=>Z(e.liveScript)),[])}}),H.of({name:`Lua`,extensions:[`lua`],load(){return X(()=>import(`./lua-CiA1ziua.js`).then(e=>Z(e.lua)),[])}}),H.of({name:`mIRC`,extensions:[`mrc`],load(){return X(()=>import(`./mirc-C9zpzAZU.js`).then(e=>Z(e.mirc)),[])}}),H.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return X(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>Z(e.mathematica)),[])}}),H.of({name:`Modelica`,extensions:[`mo`],load(){return X(()=>import(`./modelica-CqHI_q-D.js`).then(e=>Z(e.modelica)),[])}}),H.of({name:`MUMPS`,extensions:[`mps`],load(){return X(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>Z(e.mumps)),[])}}),H.of({name:`Mbox`,extensions:[`mbox`],load(){return X(()=>import(`./mbox-BEMVcqjs.js`).then(e=>Z(e.mbox)),[])}}),H.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return X(()=>import(`./nginx-BMaDbqW3.js`).then(e=>Z(e.nginx)),[])}}),H.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return X(()=>import(`./nsis-CfSuhXs5.js`).then(e=>Z(e.nsis)),__vite__mapDeps([21,19]))}}),H.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return X(()=>import(`./ntriples-B9h1VB_g.js`).then(e=>Z(e.ntriples)),[])}}),H.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.objectiveC)),[])}}),H.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.objectiveCpp)),[])}}),H.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.oCaml)),[])}}),H.of({name:`Octave`,extensions:[`m`],load(){return X(()=>import(`./octave-D2Q8cUp1.js`).then(e=>Z(e.octave)),[])}}),H.of({name:`Oz`,extensions:[`oz`],load(){return X(()=>import(`./oz-BwTct_5T.js`).then(e=>Z(e.oz)),[])}}),H.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return X(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>Z(e.pascal)),[])}}),H.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return X(()=>import(`./perl-BkSkiI9m.js`).then(e=>Z(e.perl)),[])}}),H.of({name:`Pig`,extensions:[`pig`],load(){return X(()=>import(`./pig-AF4Hwhju.js`).then(e=>Z(e.pig)),[])}}),H.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return X(()=>import(`./powershell-BcIto6Sf.js`).then(e=>Z(e.powerShell)),[])}}),H.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return X(()=>import(`./properties-C357ku5U.js`).then(e=>Z(e.properties)),[])}}),H.of({name:`ProtoBuf`,extensions:[`proto`],load(){return X(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>Z(e.protobuf)),[])}}),H.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return X(()=>import(`./pug-Gsm0M45u.js`).then(e=>Z(e.pug)),__vite__mapDeps([22,23]))}}),H.of({name:`Puppet`,extensions:[`pp`],load(){return X(()=>import(`./puppet-BZyAS7I4.js`).then(e=>Z(e.puppet)),[])}}),H.of({name:`Q`,extensions:[`q`],load(){return X(()=>import(`./q-B9NhS7L_.js`).then(e=>Z(e.q)),[])}}),H.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return X(()=>import(`./r-CxDmU1I4.js`).then(e=>Z(e.r)),[])}}),H.of({name:`RPM Changes`,load(){return X(()=>import(`./rpm-gpDK5sbt.js`).then(e=>Z(e.rpmChanges)),[])}}),H.of({name:`RPM Spec`,extensions:[`spec`],load(){return X(()=>import(`./rpm-gpDK5sbt.js`).then(e=>Z(e.rpmSpec)),[])}}),H.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return X(()=>import(`./ruby-BjXV7-Qa.js`).then(e=>Z(e.ruby)),[])}}),H.of({name:`SAS`,extensions:[`sas`],load(){return X(()=>import(`./sas-C2OyD2Y6.js`).then(e=>Z(e.sas)),[])}}),H.of({name:`Scala`,extensions:[`scala`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.scala)),[])}}),H.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return X(()=>import(`./scheme-D9qYN0V5.js`).then(e=>Z(e.scheme)),[])}}),H.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return X(()=>import(`./shell-DwuoZtxw.js`).then(e=>Z(e.shell)),[])}}),H.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return X(()=>import(`./sieve-BAxa3IjF.js`).then(e=>Z(e.sieve)),[])}}),H.of({name:`Smalltalk`,extensions:[`st`],load(){return X(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>Z(e.smalltalk)),[])}}),H.of({name:`Solr`,load(){return X(()=>import(`./solr-BBopId9w.js`).then(e=>Z(e.solr)),[])}}),H.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return X(()=>import(`./mllike-B45xgp2S.js`).then(e=>Z(e.sml)),[])}}),H.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return X(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>Z(e.sparql)),[])}}),H.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return X(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>Z(e.spreadsheet)),[])}}),H.of({name:`Squirrel`,extensions:[`nut`],load(){return X(()=>import(`./clike-D_6L3tnO.js`).then(e=>Z(e.squirrel)),[])}}),H.of({name:`Stylus`,extensions:[`styl`],load(){return X(()=>import(`./stylus-BOVgKnng.js`).then(e=>Z(e.stylus)),[])}}),H.of({name:`Swift`,extensions:[`swift`],load(){return X(()=>import(`./swift-DKB6_1j6.js`).then(e=>Z(e.swift)),[])}}),H.of({name:`sTeX`,load(){return X(()=>import(`./stex-DNzd62Q_.js`).then(e=>Z(e.stex)),[])}}),H.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return X(()=>import(`./stex-DNzd62Q_.js`).then(e=>Z(e.stex)),[])}}),H.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return X(()=>import(`./verilog-7LoJAqYT.js`).then(e=>Z(e.verilog)),[])}}),H.of({name:`Tcl`,extensions:[`tcl`],load(){return X(()=>import(`./tcl-BGfruO1u.js`).then(e=>Z(e.tcl)),[])}}),H.of({name:`Textile`,extensions:[`textile`],load(){return X(()=>import(`./textile-C4jVoHG1.js`).then(e=>Z(e.textile)),[])}}),H.of({name:`TiddlyWiki`,load(){return X(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>Z(e.tiddlyWiki)),[])}}),H.of({name:`Tiki wiki`,load(){return X(()=>import(`./tiki-AK6FwT8q.js`).then(e=>Z(e.tiki)),[])}}),H.of({name:`TOML`,extensions:[`toml`],load(){return X(()=>import(`./toml-BPTmHmyx.js`).then(e=>Z(e.toml)),[])}}),H.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return X(()=>import(`./troff-C2dAgh7P.js`).then(e=>Z(e.troff)),[])}}),H.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return X(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>Z(e.ttcn)),[])}}),H.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return X(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>Z(e.ttcnCfg)),[])}}),H.of({name:`Turtle`,extensions:[`ttl`],load(){return X(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>Z(e.turtle)),[])}}),H.of({name:`Web IDL`,extensions:[`webidl`],load(){return X(()=>import(`./webidl-D5jiJvOU.js`).then(e=>Z(e.webIDL)),[])}}),H.of({name:`VB.NET`,extensions:[`vb`],load(){return X(()=>import(`./vb-BthdM_4N.js`).then(e=>Z(e.vb)),[])}}),H.of({name:`VBScript`,extensions:[`vbs`],load(){return X(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>Z(e.vbScript)),[])}}),H.of({name:`Velocity`,extensions:[`vtl`],load(){return X(()=>import(`./velocity-CqftRsjg.js`).then(e=>Z(e.velocity)),[])}}),H.of({name:`Verilog`,extensions:[`v`],load(){return X(()=>import(`./verilog-7LoJAqYT.js`).then(e=>Z(e.verilog)),[])}}),H.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return X(()=>import(`./vhdl-kS471soi.js`).then(e=>Z(e.vhdl)),[])}}),H.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return X(()=>import(`./xquery-BKJx4mf9.js`).then(e=>Z(e.xQuery)),[])}}),H.of({name:`Yacas`,extensions:[`ys`],load(){return X(()=>import(`./yacas-CXXgtw0p.js`).then(e=>Z(e.yacas)),[])}}),H.of({name:`Z80`,extensions:[`z80`],load(){return X(()=>import(`./z80-Co3PbHdE.js`).then(e=>Z(e.z80)),[])}}),H.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.mscgen)),[])}}),H.of({name:`Xù`,extensions:[`xu`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.xu)),[])}}),H.of({name:`MsGenny`,extensions:[`msgenny`],load(){return X(()=>import(`./mscgen-qgSLujhx.js`).then(e=>Z(e.msgenny)),[])}}),H.of({name:`Vue`,extensions:[`vue`],load(){return X(()=>import(`./dist-CFtZTGHa.js`).then(e=>e.vue()),__vite__mapDeps([24,1]))}}),H.of({name:`Angular Template`,load(){return X(()=>import(`./dist-BikaGikn.js`).then(e=>e.angular()),__vite__mapDeps([25,1]))}})],dR=`#2e3440`,fR=`#3b4252`,pR=`#434c5e`,mR=`#4c566a`,hR=`#e5e9f0`,gR=`#eceff4`,_R=`#8fbcbb`,vR=`#88c0d0`,qye=`#81a1c1`,yR=`#5e81ac`,Jye=`#bf616a`,bR=`#d08770`,xR=`#ebcb8b`,SR=`#a3be8c`,Yye=`#b48ead`,CR=`#d30102`,wR=gR,TR=wR,Xye=`#ffffff`,ER=fR,Zye=wR,DR=fR,Qye=B.theme({"&":{color:dR,backgroundColor:Xye},".cm-content":{caretColor:DR},".cm-cursor, .cm-dropCursor":{borderLeftColor:DR},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Zye},".cm-panels":{backgroundColor:wR,color:mR},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid ${mR}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:hR},".cm-activeLine":{backgroundColor:TR},".cm-selectionMatch":{backgroundColor:hR},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${mR}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:gR},".cm-gutters":{backgroundColor:gR,color:dR,border:`none`},".cm-activeLineGutter":{backgroundColor:TR},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:ER},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ER,borderBottomColor:ER},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:TR,color:mR}}},{dark:!1}),$ye=se.define([{tag:P.keyword,color:yR},{tag:[P.name,P.deleted,P.character,P.propertyName,P.macroName],color:bR},{tag:[P.variableName],color:bR},{tag:[P.function(P.variableName)],color:yR},{tag:[P.labelName],color:qye},{tag:[P.color,P.constant(P.name),P.standard(P.name)],color:yR},{tag:[P.definition(P.name),P.separator],color:SR},{tag:[P.brace],color:_R},{tag:[P.annotation],color:CR},{tag:[P.number,P.changed,P.annotation,P.modifier,P.self,P.namespace],color:vR},{tag:[P.typeName,P.className],color:xR},{tag:[P.operator,P.operatorKeyword],color:SR},{tag:[P.tagName],color:Yye},{tag:[P.squareBracket],color:Jye},{tag:[P.angleBracket],color:bR},{tag:[P.attributeName],color:xR},{tag:[P.regexp],color:yR},{tag:[P.quote],color:fR},{tag:[P.string],color:bR},{tag:P.link,color:_R,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[P.url,P.escape,P.special(P.string)],color:bR},{tag:[P.meta],color:vR},{tag:[P.comment],color:pR,fontStyle:`italic`},{tag:P.strong,fontWeight:`bold`,color:yR},{tag:P.emphasis,fontStyle:`italic`,color:yR},{tag:P.strikethrough,textDecoration:`line-through`},{tag:P.heading,fontWeight:`bold`,color:yR},{tag:P.special(P.heading1),fontWeight:`bold`,color:yR},{tag:P.heading1,fontWeight:`bold`,color:yR},{tag:[P.heading2,P.heading3,P.heading4],fontWeight:`bold`,color:yR},{tag:[P.heading5,P.heading6],color:yR},{tag:[P.atom,P.bool,P.special(P.variableName)],color:bR},{tag:[P.processingInstruction,P.inserted],color:_R},{tag:[P.contentSeparator],color:xR},{tag:P.invalid,color:pR,borderBottom:`1px dotted ${CR}`}]),OR=[Qye,j($ye)],kR=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,AR=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(kR(e)):kR,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return E(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=b(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=F(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(AR.prototype[Symbol.iterator]=function(){return this});var jR={from:-1,to:-1,match:/.*/.exec(``),precise:!0},MR=`gm`+(/x/.unicode==null?``:`u`),NR=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=jR,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new IR(e,t,n,r,i);this.re=new RegExp(t,MR+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=LR(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=LR(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},PR=new WeakMap,FR=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=PR.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return PR.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),PR.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},IR=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=jR,this.matchPos=LR(e,r),this.re=new RegExp(t,MR+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=FR.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=LR(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=FR.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(NR.prototype[Symbol.iterator]=IR.prototype[Symbol.iterator]=function(){return this});function ebe(e){try{return new RegExp(e,MR),!0}catch{return!1}}function LR(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var tbe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=be(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=R.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,B.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},nbe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},RR=p.define({combine(e){return Qe(e,nbe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function rbe(e){let t=[cbe,sbe];return e&&t.push(RR.of(e)),t}var ibe=Pe.mark({class:`cm-selectionMatch`}),abe=Pe.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function zR(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=d.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=d.Word)}function obe(e,t,n,r){return e(t.sliceDoc(n,n+1))==d.Word&&e(t.sliceDoc(r-1,r))==d.Word}var sbe=ae.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(RR),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Pe.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return Pe.none;let e=n.wordAt(i.head);if(!e)return Pe.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return Pe.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(zR(o,n,i.from,i.to)&&obe(o,n,i.from,i.to)))return Pe.none}else if(a=n.sliceDoc(i.from,i.to),!a)return Pe.none}let s=[];for(let r of e.visibleRanges){let e=new AR(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||zR(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(abe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ibe.range(r,a)),s.length>t.maxMatches))return Pe.none}}return Pe.set(s)}},{decorations:e=>e.decorations}),cbe=B.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),lbe=({state:e,dispatch:t})=>{let{selection:n}=e,r=R.create(n.ranges.map(t=>e.wordAt(t.head)||R.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function ube(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new AR(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new AR(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var dbe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return lbe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ube(e,r);return i?(t(e.update({selection:e.selection.addRange(R.range(i.from,i.to),!1),effects:B.scrollIntoView(i.to)})),!0):!1},BR=p.define({combine(e){return Qe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Tbe(e),scrollToMatch:e=>B.scrollIntoView(e)})}}),VR=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||ebe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
176
176
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new _be(this):new mbe(this)}getCursor(e,t=0,n){let r=e.doc?e:h.create({doc:e});return n??=r.doc.length,this.regexp?WR(this,r,t,n):UR(this,r,t,n)}},HR=class{constructor(e){this.spec=e}};function fbe(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function UR(e,t,n,r){let i;return e.wholeWord&&(i=pbe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=fbe(e.test,t,i)),new AR(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function pbe(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(GR(i,n-a))!=d.Word||t(KR(i,n-a))!=d.Word)&&(t(KR(i,r-a))!=d.Word||t(GR(i,r-a))!=d.Word))}var mbe=class extends HR{constructor(e){super(e)}nextMatch(e,t,n){let r=UR(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=UR(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=UR(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=UR(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=UR(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function hbe(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function WR(e,t,n,r){let i;return e.wholeWord&&(i=gbe(t.charCategorizer(t.selection.main.head))),e.test&&(i=hbe(e.test,t,i)),new NR(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function GR(e,t){return e.slice(ne(e,t,!1),t)}function KR(e,t){return e.slice(t,ne(e,t))}function gbe(e){return(t,n,r)=>!r[0].length||(e(GR(r.input,r.index))!=d.Word||e(KR(r.input,r.index))!=d.Word)&&(e(KR(r.input,r.index+r[0].length))!=d.Word||e(GR(r.input,r.index+r[0].length))!=d.Word)}var _be=class extends HR{nextMatch(e,t,n){let r=WR(this.spec,e,n,e.doc.length).next();return r.done&&(r=WR(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=WR(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=WR(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=WR(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},qR=k.define(),JR=k.define(),YR=M.define({create(e){return new XR(nz(e).create(),null)},update(e,t){for(let n of t.effects)n.is(qR)?e=new XR(n.value.create(),e.panel):n.is(JR)&&(e=new XR(e.query,n.value?tz:null));return e},provide:e=>ve.from(e,e=>e.panel)}),XR=class{constructor(e,t){this.query=e,this.panel=t}},vbe=Pe.mark({class:`cm-searchMatch`}),ybe=Pe.mark({class:`cm-searchMatch cm-searchMatch-selected`}),bbe=ae.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(YR))}update(e){let t=e.state.field(YR);(t!=e.startState.field(YR)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Pe.none;let{view:n}=this,r=new V;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?ybe:vbe)})}return r.finish()}},{decorations:e=>e.decorations});function ZR(e){return t=>{let n=t.state.field(YR,!1);return n&&n.query.spec.valid?e(t,n):az(t)}}var QR=ZR((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=R.single(r.from,r.to),a=e.state.facet(BR);return e.dispatch({selection:i,effects:[uz(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),iz(e),!0}),$R=ZR((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=R.single(i.from,i.to),o=e.state.facet(BR);return e.dispatch({selection:a,effects:[uz(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),iz(e),!0}),xbe=ZR((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:R.create(n.map(e=>R.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Sbe=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new AR(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(R.range(t.value.from,t.value.to))}return t(e.update({selection:R.create(a,o),userEvent:`select.search.matches`})),!0},ez=ZR((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(B.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=R.single(o.from,o.to).map(d),u.push(uz(e,o)),u.push(n.facet(BR).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Cbe=ZR((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:B.announce.of(r),userEvent:`input.replace.all`}),!0});function tz(e){return e.state.facet(BR).createPanel(e)}function nz(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(BR);return new VR({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function rz(e){let t=Ie(e,tz);return t&&t.dom.querySelector(`[main-field]`)}function iz(e){let t=rz(e);t&&t==e.root.activeElement&&t.select()}var az=e=>{let t=e.state.field(YR,!1);if(t&&t.panel){let n=rz(e);if(n&&n!=e.root.activeElement){let r=nz(e.state,t.query.spec);r.valid&&e.dispatch({effects:qR.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[JR.of(!0),t?qR.of(nz(e.state,t.query.spec)):k.appendConfig.of(Dbe)]});return!0},oz=e=>{let t=e.state.field(YR,!1);if(!t||!t.panel)return!1;let n=Ie(e,tz);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:JR.of(!1)}),!0},wbe=[{key:`Mod-f`,run:az,scope:`editor search-panel`},{key:`F3`,run:QR,shift:$R,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:QR,shift:$R,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:oz,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Sbe},{key:`Mod-Alt-g`,run:tbe},{key:`Mod-d`,run:dbe,preventDefault:!0}],Tbe=class{constructor(e){this.view=e;let t=this.query=e.state.field(YR).query.spec;this.commit=this.commit.bind(this),this.searchField=We(`input`,{value:t.search,placeholder:sz(e,`Find`),"aria-label":sz(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=We(`input`,{value:t.replace,placeholder:sz(e,`Replace`),"aria-label":sz(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=We(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=We(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=We(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return We(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=We(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>QR(e),[sz(e,`next`)]),n(`prev`,()=>$R(e),[sz(e,`previous`)]),n(`select`,()=>xbe(e),[sz(e,`all`)]),We(`label`,null,[this.caseField,sz(e,`match case`)]),We(`label`,null,[this.reField,sz(e,`regexp`)]),We(`label`,null,[this.wordField,sz(e,`by word`)]),...e.state.readOnly?[]:[We(`br`),this.replaceField,n(`replace`,()=>ez(e),[sz(e,`replace`)]),n(`replaceAll`,()=>Cbe(e),[sz(e,`replace all`)])],We(`button`,{name:`close`,onclick:()=>oz(e),"aria-label":sz(e,`close`),type:`button`},[`×`])])}commit(){let e=new VR({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:qR.of(e)}))}keydown(e){De(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?$R:QR)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ez(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(qR)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(BR).top}};function sz(e,t){return e.state.phrase(t)}var cz=30,lz=/[\s\.,:;?!]/;function uz(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-cz),o=Math.min(i,n+cz),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<cz;e++)if(!lz.test(s[e+1])&&lz.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-cz;e--)if(!lz.test(s[e-1])&&lz.test(s[e])){s=s.slice(0,e);break}}return B.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ebe=B.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Dbe=[YR,we.low(bbe),Ebe],dz=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},fz=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(yz).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new V,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=zbe(s);if(i)o.add(n,n,Pe.widget({widget:new Fbe(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,Pe.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,pz(f))}};function pz(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new dz(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new dz(r.from,n,r.diagnostic)}}),r}function Obe(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(yz).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(mz))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function kbe(e,t){return e.field(_z,!1)?t:t.concat(k.appendConfig.of(Bbe))}var mz=k.define(),hz=k.define(),gz=k.define(),_z=M.define({create(){return new fz(Pe.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=pz(n,e.selected.diagnostic,i)||pz(n,null,i)}!n.size&&i&&t.state.facet(yz).autoPanel&&(i=null),e=new fz(n,i,r)}for(let n of t.effects)if(n.is(mz)){let r=t.state.facet(yz).autoPanel?n.value.length?wz.open:null:e.panel;e=fz.init(n.value,r,t.state)}else n.is(hz)?e=new fz(e.diagnostics,n.value?wz.open:null,e.selected):n.is(gz)&&(e=new fz(e.diagnostics,e.panel,n.value));return e},provide:e=>[ve.from(e,e=>e.panel),B.decorations.from(e,e=>e.diagnostics)]}),Abe=Pe.mark({class:`cm-lintRange cm-lintRange-active`});function jbe(e,t,n){let{diagnostics:r}=e.state.field(_z),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(yz).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:!0,create(){return{dom:Mbe(e,i)}}}:null}function Mbe(e,t){return We(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Sz(e,t,!1)))}var Nbe=e=>{let t=e.state.field(_z,!1);(!t||!t.panel)&&e.dispatch({effects:kbe(e.state,[hz.of(!0)])});let n=Ie(e,wz.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},vz=e=>{let t=e.state.field(_z,!1);return!t||!t.panel?!1:(e.dispatch({effects:hz.of(!1)}),!0)},Pbe=[{key:`Mod-Shift-m`,run:Nbe,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(_z,!1);if(!t)return!1;let n=e.state.selection.main,r=pz(t.diagnostics,null,n.to+1);return!r&&(r=pz(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),a(e,r.from,1,{tooltip:Ez,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],yz=p.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Qe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:bz,tooltipFilter:bz,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function bz(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function xz(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Sz(e,t,n){let r=n?xz(t.actions):[];return We(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},We(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=pz(e.state.field(_z).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),We(`u`,s.slice(c,c+1)),s.slice(c+1)],u=n.markClass?` `+n.markClass:``;return We(`button`,{type:`button`,class:`cm-diagnosticAction`+u,onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&We(`div`,{class:`cm-diagnosticSource`},t.source))}var Fbe=class extends N{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return We(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Cz=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Sz(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},wz=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)vz(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=xz(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=pz(this.view.state.field(_z).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=We(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=We(`div`,{class:`cm-panel-lint`},this.list,We(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>vz(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(_z).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(_z),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Cz(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Cz(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=pz(this.view.state.field(_z).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:gz.of(t)})}static open(t){return new e(t)}};function Ibe(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Tz(e){return Ibe(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Lbe=B.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Tz(`#f11`)},".cm-lintRange-warning":{backgroundImage:Tz(`orange`)},".cm-lintRange-info":{backgroundImage:Tz(`#999`)},".cm-lintRange-hint":{backgroundImage:Tz(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Rbe(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function zbe(e){let t=`hint`,n=1;for(let r of e){let e=Rbe(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ez=Te(jbe,{hideOn:Obe}),Bbe=[_z,B.decorations.compute([_z],e=>{let{selected:t,panel:n}=e.field(_z);return!t||!n||t.from==t.to?Pe.none:Pe.set([Abe.range(t.from,t.to)])}),Ez,Lbe],Dz=[me(),Re(),fe(),m_e(),le(),Be(),ke(),h.allowMultipleSelections.of(!0),A(),j(_e,{fallback:!0}),Me(),it(),nt(),Ne(),he(),je(),rbe(),He.of([...tt,...gve,...wbe,...C_e,...ee,...rt,...Pbe])],Vbe=Object.defineProperty,Hbe=(e,t)=>Vbe(e,`name`,{value:t,configurable:!0});function Oz(e,[t,n]){return Math.min(n,Math.max(t,e))}Hbe(Oz,`clamp`);var Ube=Object.defineProperty,Wbe=(e,t)=>Ube(e,`name`,{value:t,configurable:!0});function kz(e){let t=U.useRef({value:e,previous:e});return U.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}Wbe(kz,`usePrevious`);var Gbe=Object.defineProperty,Kbe=(e,t)=>Gbe(e,`name`,{value:t,configurable:!0}),Az=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),qbe=U.forwardRef(Kbe(function(e,t){return(0,W.jsx)(iE.span,{...e,ref:t,style:{...Az,...e.style}})},`VisuallyHidden`)),Jbe=Object.defineProperty,jz=(e,t)=>Jbe(e,`name`,{value:t,configurable:!0}),Ybe=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Xbe=[` `,`Enter`],Mz=`Select`,[Nz,Pz,Zbe]=IO(Mz),[Fz,Qbe]=KT(Mz,[Zbe,JD]),Iz=JD(),[$be,Lz]=Fz(Mz),[exe,txe]=Fz(Mz);function Rz(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Iz(t),[_,v]=U.useState(null),[y,b]=U.useState(null),[x,S]=U.useState(!1),C=VO(l),[w,T]=aO({prop:r,defaultProp:i??!1,onChange:a,caller:Mz}),[E,D]=aO({prop:o,defaultProp:s,onChange:c,caller:Mz}),O=U.useRef(null),k=U.useRef(E);U.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=jz(()=>D(k.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let A=!_||!!m||!!_.closest(`form`),[j,M]=U.useState(new Set),N=zE(),P=Array.from(j).map(e=>e.props.value).join(`;`),F=U.useCallback(e=>{M(t=>new Set(t).add(e))},[]),ee=U.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),I={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:N,value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:j,nativeSelectKey:P,isFormControl:A};return(0,W.jsx)(XD,{...g,children:(0,W.jsx)($be,{scope:t,...I,children:(0,W.jsx)(Nz.Provider,{scope:t,children:(0,W.jsx)(exe,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:ee,children:qz(h)?h(I):n})})})})}jz(Rz,`SelectProvider`);var nxe=jz(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Rz,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(Dxe,{__scopeSelect:t}):null]})})},`Select`),rxe=`SelectTrigger`,ixe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Iz(n),o=Lz(rxe,n),s=o.disabled||r,c=WT(t,o.onTriggerChange),l=Pz(n),u=U.useRef(`touch`),[d,f,p]=Yz(e=>{let t=l().filter(e=>!e.disabled),n=Xz(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=jz(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(ZD,{asChild:!0,...a,children:(0,W.jsx)(iE.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Jz(o.value)?``:void 0,...i,ref:c,onClick:LT(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:LT(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:LT(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Ybe.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),axe=`SelectValue`,oxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Lz(axe,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=WT(t,c.onValueNodeChange);RE(()=>{l(u)},[l,u]);let f=Jz(c.value);return(0,W.jsx)(iE.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(U.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),sxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(iE.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[cxe,lxe]=Fz(`SelectPortal`,{forceMount:void 0}),uxe=jz(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(cxe,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)($D,{asChild:!0,...r})})},`SelectPortal`),zz=`SelectContent`,dxe=U.forwardRef(jz(function(e,t){let n=lxe(zz,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Lz(zz,e.__scopeSelect),[o,s]=U.useState();return RE(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(tO,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(mxe,{...i,ref:t}):(0,W.jsx)(fxe,{...i,fragment:o})})},`SelectContent`)),fxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Fl.createPortal((0,W.jsx)(Vz,{scope:n,children:(0,W.jsx)(Nz.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Bz=10,[Vz,Hz]=Fz(zz),pxe=YT(`SelectContent.RemoveScroll`),mxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Lz(zz,n),[y,b]=U.useState(null),[x,S]=U.useState(null),C=WT(t,b),[w,T]=U.useState(null),[E,D]=U.useState(null),O=Pz(n),[k,A]=U.useState(!1),j=U.useRef(!1);U.useEffect(()=>{if(y)return uO(y)},[y]),bE();let M=U.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=U.useCallback(()=>M([w,y]),[M,w,y]);U.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;U.useEffect(()=>{if(y){let e={x:0,y:0},t=jz(t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},`handlePointerMove`),n=jz(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null},`handlePointerUp`);return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),U.useEffect(()=>{let e=jz(()=>P(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[ee,I]=Yz(e=>{let t=O().filter(e=>!e.disabled),n=Xz(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),L=U.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),R=U.useCallback(()=>y?.focus(),[y]),te=U.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),z=r===`popper`?Uz:hxe,ne=z===Uz?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(Vz,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:L,selectedItem:w,onItemLeave:R,itemTextRefCallback:te,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:ee,children:(0,W.jsx)(wO,{as:pxe,allowPinchZoom:!0,children:(0,W.jsx)(EE,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:LT(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(dE,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ne,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:LT(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&I(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),hxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=Lz(zz,n),o=Hz(zz,n),[s,c]=U.useState(null),[l,u]=U.useState(null),d=WT(t,u),f=Pz(n),p=U.useRef(!1),m=U.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=U.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Bz,d=Oz(a,[Bz,Math.max(Bz,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Bz,d=Oz(a,[Bz,Math.max(Bz,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Bz*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Bz,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Bz}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);RE(()=>y(),[y]);let[b,x]=U.useState();RE(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);let S=U.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,W.jsx)(gxe,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(iE.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Uz=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Bz,...a}=e,o=Iz(n);return(0,W.jsx)(QD,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[gxe,_xe]=Fz(zz,{}),Wz=`SelectViewport`,vxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Hz(Wz,n),o=_xe(Wz,n),s=WT(t,a.onViewportChange),c=U.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(Nz.Slot,{scope:n,children:(0,W.jsx)(iE.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:LT(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Bz*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[yxe,bxe]=Fz(`SelectGroup`),Gz=`SelectItem`,[xxe,Sxe]=Fz(Gz),Cxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Lz(Gz,n),c=Hz(Gz,n),l=s.value===r,[u,d]=U.useState(a??``),[f,p]=U.useState(!1),m=WT(t,oE(e=>c.itemRefCallback?.(e,r,i))),h=zE(),g=U.useRef(`touch`),_=jz(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,W.jsx)(xxe,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:U.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(Nz.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(iE.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:LT(o.onFocus,()=>p(!0)),onBlur:LT(o.onBlur,()=>p(!1)),onClick:LT(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:LT(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:LT(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:LT(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:LT(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:LT(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(Xbe.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Kz=`SelectItemText`,wxe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=Lz(Kz,n),s=Hz(Kz,n),c=Sxe(Kz,n),l=txe(Kz,n),[u,d]=U.useState(null),f=oE(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=WT(t,d,c.onItemTextChange,f),m=u?.textContent,h=U.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return RE(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(iE.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Jz(o.value)?Fl.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),Txe=U.forwardRef(jz(function(e,t){let{__scopeSelect:n,...r}=e;return(0,W.jsx)(iE.div,{"aria-hidden":!0,...r,ref:t})},`SelectSeparator`)),Exe=`SelectBubbleInput`,Dxe=U.forwardRef(jz(function({__scopeSelect:e,...t},n){let r=Lz(Exe,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=U.useRef(null),m=WT(n,p),h=i??``,g=kz(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return U.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,W.jsxs)(iE.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...Az,...t.style},ref:m,defaultValue:h,children:[Jz(i)&&!_?(0,W.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function qz(e){return typeof e==`function`}jz(qz,`isFunction`);function Jz(e){return e===``||e===void 0}jz(Jz,`shouldShowPlaceholder`);function Yz(e){let t=oE(e),n=U.useRef(``),r=U.useRef(0),i=U.useCallback(e=>{let i=n.current+e;t(i),jz((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=U.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return U.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}jz(Yz,`useTypeaheadSearch`);function Xz(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Zz(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}jz(Xz,`findNextItem`);function Zz(e,t){return e.map((n,r)=>e[(t+r)%e.length])}jz(Zz,`wrapArray`);var Oxe=Object.defineProperty,Qz=(e,t)=>Oxe(e,`name`,{value:t,configurable:!0}),[$z,kxe]=KT(`Tooltip`,[JD]),eB=JD(),Axe=`TooltipProvider`,jxe=700,tB=`tooltip.open`,[Mxe,nB]=$z(Axe),Nxe=Qz(e=>{let{__scopeTooltip:t,delayDuration:n=jxe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=U.useRef(!0),s=U.useRef(!1),c=U.useRef(0);return U.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,W.jsx)(Mxe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:U.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:U.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:U.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),rB=`Tooltip`,[Pxe,iB]=$z(rB),Fxe=Qz(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=nB(rB,e.__scopeTooltip),l=eB(t),[u,d]=U.useState(null),[f,p]=U.useState(void 0),m=zE(),h=U.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=U.useRef(!1),[y,b]=aO({prop:r,defaultProp:i??!1,onChange:Qz(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(tB))):c.onClose(),a?.(e)},`onChange`),caller:rB}),x=U.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=U.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=U.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=U.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);U.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,W.jsx)(XD,{...l,children:(0,W.jsx)(Pxe,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:U.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:U.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),aB=`TooltipTrigger`,Ixe=U.forwardRef(Qz(function(e,t){let{__scopeTooltip:n,...r}=e,i=iB(aB,n),a=nB(aB,n),o=eB(n),s=WT(t,U.useRef(null),i.onTriggerChange),c=U.useRef(!1),l=U.useRef(!1),u=U.useCallback(()=>c.current=!1,[]);return U.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,W.jsx)(ZD,{asChild:!0,...o,children:(0,W.jsx)(iE.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:LT(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:LT(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:LT(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:LT(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:LT(e.onBlur,i.onClose),onClick:LT(e.onClick,i.onClose)})})},`TooltipTrigger`)),oB=`TooltipPortal`,[Lxe,Rxe]=$z(oB,{forceMount:void 0}),zxe=Qz(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=iB(oB,t);return(0,W.jsx)(Lxe,{scope:t,forceMount:n,children:(0,W.jsx)(tO,{present:n||a.open,children:(0,W.jsx)($D,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),sB=`TooltipContent`,Bxe=U.forwardRef(Qz(function(e,t){let n=Rxe(sB,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=iB(sB,e.__scopeTooltip);return(0,W.jsx)(tO,{present:r||o.open,children:o.disableHoverableContent?(0,W.jsx)(cB,{side:i,...a,ref:t}):(0,W.jsx)(Vxe,{side:i,...a,ref:t})})},`TooltipContent`)),Vxe=U.forwardRef(Qz(function(e,t){let n=iB(sB,e.__scopeTooltip),r=nB(sB,e.__scopeTooltip),i=U.useRef(null),a=WT(t,i),[o,s]=U.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=U.useCallback(()=>{s(null),d(!1)},[d]),p=U.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=uB(r,lB(r,n.getBoundingClientRect())),a=dB(t.getBoundingClientRect()),o=pB([...i,...a]);s(o),d(!0)},[d]);return U.useEffect(()=>()=>f(),[f]),U.useEffect(()=>{if(c&&u){let e=Qz(e=>p(e,u),`handleTriggerLeave`),t=Qz(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),U.useEffect(()=>{if(o){let e=Qz(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!fB(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,W.jsx)(cB,{...e,ref:a})},`TooltipContentHoverable`)),Hxe=ZT(`TooltipContent`),cB=U.forwardRef(Qz(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=iB(sB,n),u=eB(n),{onClose:d}=l;U.useEffect(()=>(document.addEventListener(tB,d),()=>document.removeEventListener(tB,d)),[d]),U.useEffect(()=>{if(l.trigger){let e=Qz(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return RE(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,W.jsx)(dE,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,W.jsxs)(QD,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,W.jsx)(Hxe,{children:r}),i?(0,W.jsx)(qbe,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),Uxe=U.forwardRef(Qz(function(e,t){let{__scopeTooltip:n,...r}=e,i=eB(n);return(0,W.jsx)(Mue,{...i,...r,ref:t})},`TooltipArrow`));function lB(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Qz(lB,`getExitSideFromRect`);function uB(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Qz(uB,`getPaddedExitPoints`);function dB(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Qz(dB,`getPointsFromRect`);function fB(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Qz(fB,`isPointInPolygon`);function pB(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),mB(t)}Qz(pB,`getHull`);function mB(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Qz(mB,`getHullPresorted`);var hB=Nxe,gB=Fxe,_B=Ixe,vB=zxe,yB=Bxe,Wxe=Uxe,bB=U.forwardRef(({title:e,children:t},n)=>{let r=Hd(gC);return U.createElement(hB,{delayDuration:100},U.createElement(gB,null,U.createElement(_B,{ref:n,asChild:!0},U.createElement(`span`,{className:Y.tooltipTrigger},t)),U.createElement(vB,{container:r?.current},U.createElement(yB,{className:(0,tT.default)(Y.tooltipContent),sideOffset:10},e))))}),Gxe=U.forwardRef(({children:e,className:t,...n},r)=>U.createElement(Cxe,{...n,ref:r,className:(0,tT.default)(t,Y.selectItem)},U.createElement(wxe,null,e))),Kxe=({title:e,placeholder:t,className:n})=>{let[r,i]=Ud(GS,MC);return U.createElement(bB,{title:e},U.createElement(ixe,{"aria-label":t,className:(0,tT.default)(Y.selectTrigger,n),"data-toolbar-item":!0,disabled:r},U.createElement(oxe,{placeholder:t}),U.createElement(sxe,{className:Y.selectDropdownArrow},i(`arrow_drop_down`))))},qxe=({children:e,className:t=Y.selectContainer})=>{let n=Hd(gC);return U.createElement(uxe,{container:n?.current},U.createElement(dxe,{className:(0,tT.default)(t,`mdxeditor-select-content`),onCloseAutoFocus:e=>{e.preventDefault()},position:`popper`},U.createElement(vxe,{"data-editor-dropdown":!0,style:{maxHeight:`var(--radix-select-content-available-height)`}},e)))},xB=e=>U.createElement(nxe,{value:e.value||``,onValueChange:e.onChange,disabled:e.disabled},U.createElement(Kxe,{title:e.triggerTitle,placeholder:e.placeholder}),U.createElement(qxe,null,e.items.map((e,t)=>e===`separator`?U.createElement(Txe,{key:t}):U.createElement(Gxe,{key:t,value:e.value},e.label)))),SB=({language:e,nodeKey:t,code:n,focusEmitter:r})=>{let i=nw(),{parentEditor:a,lexicalNode:o}=CF(),[s,c,l,u,d]=Ud(GS,DB,OB,MC,EB),f=Gye(t,`codeblock`,e,r),{setCode:p}=CF(),m=U.useRef(null),g=U.useRef(null),{value:_,items:v}=U.useMemo(()=>TB(d,e),[d,e]),y=U.useRef(p);return y.current=p,f.current={getCodemirror:()=>m.current},U.useEffect(()=>{let t=g.current;return(async()=>{let r=[...c,Dz,OR,me(),He.of([_ve]),B.lineWrapping,B.updateListener.of(({state:e})=>{y.current(e.doc.toString())}),B.domEventHandlers({focus:()=>{a.update(()=>{l_(null)})}})];if(s&&r.push(h.readOnly.of(!0)),e!==``){let t=d.keyMap[e]??e,n=d.supportMap[t];if(n)r.push(n.extension);else if(l){let t=Kye.find(t=>t.name===e||t.alias.includes(e)||t.extensions.includes(e));if(t)try{let e=await t.load();r.push(e.extension)}catch{console.warn(`failed to load language support for`,e)}}}t.innerHTML=``,m.current=new B({parent:t,state:h.create({doc:n,extensions:r})}),t.addEventListener(`keydown`,CB)})(),()=>{var e;(e=m.current)==null||e.destroy(),m.current=null,t.removeEventListener(`keydown`,CB)}},[s,e,...c]),U.createElement(`div`,{className:Y.codeMirrorWrapper},U.createElement(`div`,{className:Y.codeMirrorToolbar},U.createElement(xB,{disabled:s,value:_,onChange:e=>{a.update(()=>{o.setLanguage(e===`__EMPTY_VALUE__`?``:e),setTimeout(()=>{a.update(()=>{o.getLatest().select()})})})},triggerTitle:i(`codeBlock.selectLanguage`,`Select code block language`),placeholder:i(`codeBlock.inlineLanguage`,`Language`),items:v}),U.createElement(`button`,{className:Y.iconButton,type:`button`,disabled:s,title:i(`codeblock.delete`,`Delete code block`),onClick:e=>{e.preventDefault(),a.update(()=>{o.remove()})}},u(`delete_small`))),U.createElement(`div`,{ref:g}))};function CB(e){e.stopPropagation()}function wB(e){let t=[],n={},r={};if(Array.isArray(e))for(let i of e){let e=i.alias?.[0]??i.name.toLowerCase(),a=e||`__EMPTY_VALUE__`;if(t.push({value:a,label:i.name}),n[e]=a,i.alias)for(let e of i.alias)n[e]=a;if(i.extensions)for(let e of i.extensions)n[e]=a;n[i.name.toLowerCase()]=a,i.support&&(r[a]=i.support)}else{let r={};for(let[i,a]of Object.entries(e))a in r||(r[a]=i,t.push({value:i||`__EMPTY_VALUE__`,label:a})),n[i]=r[a]||`__EMPTY_VALUE__`}return{items:t,keyMap:n,supportMap:r}}function TB(e,t){let n=e.keyMap[t]??t;return!n||e.items.some(e=>e.value===n)?{value:n,items:e.items}:{value:n,items:[...e.items,{value:n,label:t}]}}var EB=Ld(wB({js:`JavaScript`,ts:`TypeScript`,tsx:`TypeScript (React)`,jsx:`JavaScript (React)`,css:`CSS`})),Jxe=Rd(e=>{e.link(e.pipe(Jxe,Gd(({language:e,code:t})=>({code:t,language:e,meta:``}))),DF)}),DB=Ld([]),OB=Ld(!0),Yxe=Qd({update(e,t){e.pubIn({[EB]:wB(t?.codeBlockLanguages??{}),[DB]:t?.codeMirrorExtensions??[],[OB]:t?.autoLoadLanguageSupport??!0})},init(e,t){let n=wB(t?.codeBlockLanguages??{});e.pubIn({[EB]:n,[DB]:t?.codeMirrorExtensions??[],[t_e]:Xxe(),[OB]:t?.autoLoadLanguageSupport??!0})}});function Xxe(e){return{match(e,t){return!t},priority:1,Editor:SB}}function Zxe({url:e,title:t,text:n,onSubmit:r,onCancel:i,linkAutocompleteSuggestions:a,showLinkTitleField:o,showAnchorTextField:s}){let{register:c,handleSubmit:l,control:u,setValue:d,reset:f}=uj({values:{url:e,title:t,text:n}}),p=nw();return U.createElement(`form`,{onSubmit:e=>{l(r)(e),e.stopPropagation(),e.preventDefault()},onReset:e=>{e.stopPropagation(),i()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i())},className:(0,tT.default)(Y.multiFieldForm,Y.linkDialogEditForm)},U.createElement(`div`,{className:Y.formField},U.createElement(`label`,{htmlFor:`link-url`},p(`createLink.url`,`URL`)),U.createElement(uN,{register:c,initialInputValue:e,inputName:`url`,suggestions:a,setValue:d,control:u,placeholder:p(`createLink.urlPlaceholder`,`Select or paste an URL`),autofocus:!0})),s?U.createElement(`div`,{className:Y.formField},U.createElement(`label`,{htmlFor:`link-text`,title:p(`createLink.textTooltip`,`The text to be displayed for the link`)},p(`createLink.text`,`Anchor text`)),U.createElement(`input`,{id:`link-text`,className:Y.textInput,size:40,...c(`text`)})):null,o?U.createElement(`div`,{className:Y.formField},U.createElement(`label`,{htmlFor:`link-title`,title:p(`createLink.titleTooltip`,`The link's title attribute, shown on hover`)},p(`createLink.title`,`Link title`)),U.createElement(`input`,{id:`link-title`,className:Y.textInput,size:40,...c(`title`)})):null,U.createElement(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:`var(--spacing-2)`}},U.createElement(`button`,{type:`submit`,title:p(`createLink.saveTooltip`,`Set URL`),"aria-label":p(`createLink.saveTooltip`,`Set URL`),className:(0,tT.default)(Y.primaryButton)},p(`dialogControls.save`,`Save`)),U.createElement(`button`,{type:`reset`,title:p(`createLink.cancelTooltip`,`Cancel change`),"aria-label":p(`createLink.cancelTooltip`,`Cancel change`),className:(0,tT.default)(Y.secondaryButton)},p(`dialogControls.cancel`,`Cancel`))))}var Qxe=()=>{let[e,t,n,r,i,a,o]=Ud(gC,HS,MC,MB,RB,zB,HB),s=Wd(jB),c=Wd(NB),l=Wd(PB),u=Wd(FB),d=Wd(IB);U.useEffect(()=>{let e=()=>{t?.getEditorState().read(()=>{s(!0)})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e)}},[t,s]);let[f,p]=U.useState(!1),m=nw();if(r.type===`inactive`)return null;let h=r.rectangle,g=r.type===`preview`&&r.url.startsWith(`http`);return U.createElement(MO,{open:!0},U.createElement(ffe,{"data-visible":r.type===`edit`,className:Y.linkDialogAnchor,style:{top:`${h.top}px`,left:`${h.left}px`,width:`${h.width}px`,height:`${h.height}px`}}),U.createElement(NO,{container:e?.current},U.createElement(pfe,{className:(0,tT.default)(Y.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:e=>{e.preventDefault()},key:r.linkNodeKey},r.type===`edit`&&U.createElement(Zxe,{url:r.url,title:r.title,text:r.text,onSubmit:c,onCancel:l.bind(null),linkAutocompleteSuggestions:i,showLinkTitleField:o,showAnchorTextField:r.withAnchorText}),r.type===`preview`&&U.createElement(U.Fragment,null,U.createElement(`a`,{className:Y.linkDialogPreviewAnchor,href:r.url,...g?{target:`_blank`,rel:`noreferrer`}:{},onClick:e=>{a!==null&&(e.preventDefault(),a(r.url))},title:g?m(`linkPreview.open`,`Open {{url}} in new window`,{url:r.url}):r.url},U.createElement(`span`,null,r.url),g&&n(`open_in_new`)),U.createElement(kB,{onClick:()=>{u()},title:m(`linkPreview.edit`,`Edit link URL`),"aria-label":m(`linkPreview.edit`,`Edit link URL`)},n(`edit`)),U.createElement(hB,null,U.createElement(gB,{open:f},U.createElement(_B,{asChild:!0},U.createElement(kB,{title:m(`linkPreview.copyToClipboard`,`Copy to clipboard`),"aria-label":m(`linkPreview.copyToClipboard`,`Copy to clipboard`),onClick:()=>{window.navigator.clipboard.writeText(r.url).then(()=>{p(!0),setTimeout(()=>{p(!1)},1e3)})}},n(f?`check`:`content_copy`))),U.createElement(vB,{container:e?.current},U.createElement(yB,{className:(0,tT.default)(Y.tooltipContent),sideOffset:5},m(`linkPreview.copied`,`Copied!`),U.createElement(Wxe,null))))),U.createElement(kB,{title:m(`linkPreview.remove`,`Remove link`),"aria-label":m(`linkPreview.remove`,`Remove link`),onClick:()=>{d()}},n(`link_off`))),U.createElement(PO,{className:Y.popoverArrow}))))},kB=U.forwardRef(({className:e,...t},n)=>U.createElement(`button`,{className:(0,tT.default)(Y.actionButton,e),ref:n,...t}));function AB(e){if(!e)return null;let t=Pse(e);if(t===null)return null;let n=t.getParent();return hw(n)?n:hw(t)?t:null}var jB=Rd(),MB=Ld({type:`inactive`},e=>{e.pub(IC,t=>t.registerCommand(mm,()=>e.getValue(MB).type===`preview`&&(e.pub(MB,{type:`inactive`}),!0),1)),e.sub(e.pipe(XC),t=>{t!==`rich-text`&&e.pub(MB,{type:`inactive`})}),e.pub(IC,t=>t.registerCommand(om,t=>t.key===`k`&&(iT?t.metaKey:t.ctrlKey)&&!e.getValue(GS)&&q(Bh())?(e.pub(LB),t.stopPropagation(),t.preventDefault(),!0):!1,3)),e.sub(e.pipe(FB,Kd(MB,HS)),([,t,n])=>{if(t.type===`preview`)setTimeout(()=>{n?.getEditorState().read(()=>{let n=t_(t.linkNodeKey),r=hw(n)?n.getTextContent().length>0&&n.getChildrenSize()<=1:!1,i=r&&n?n.getTextContent():``;e.pub(MB,{type:`edit`,initialUrl:t.url,url:t.url,title:t.title,text:i,withAnchorText:r,linkNodeKey:t.linkNodeKey,rectangle:t.rectangle})})});else throw Error(`Cannot switch to edit mode when not in preview mode`)}),e.sub(e.pipe(NB,Kd(HS,MB,$S)),([t,n,r,i])=>{let a=t.text?.trim()??``,o=t.url?.trim()??``,s=t.title?.trim()??``;if(o!==``){if(i?.isCollapsed()){let e=a||s||o;n?.update(()=>{let t=AB(i);if(!t){let t=mw(o,{title:s});t.append(hh(e)),qh([t]),t.select()}else if(vw(t)){let e=mw(o,{title:s});e.append(hh(a)),t.replace(e),e.select()}else t.setURL(o),t.setTitle(s),VB(t.getFirstChild(),a)},{discrete:!0})}else n?.update(()=>{VB(i?.anchor.getNode(),a)}),n?.dispatchCommand(yw,{url:o,title:s});e.pub(MB,{type:`preview`,linkNodeKey:r.linkNodeKey,rectangle:r.rectangle,title:s,url:o})}else r.type===`edit`&&r.initialUrl!==``&&n?.dispatchCommand(yw,null),e.pub(MB,{type:`inactive`})}),e.link(e.pipe(PB,Kd(MB,HS),Gd(([,e,t])=>{if(e.type===`edit`)return t?.focus(),e.initialUrl===``?{type:`inactive`}:{type:`preview`,url:e.initialUrl,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw Error(`Cannot cancel edit when not in edit mode`)})),MB),e.link(e.pipe(e.combine($S,jB),Kd(HS,MB,GS),Gd(([[e],t,n,r])=>{if(q(e)&&t&&!r){let n=AB(e);if(!e.isCollapsed())return{type:`inactive`};if(n){let e=eT(t);return e?{type:`preview`,url:n.getURL(),linkNodeKey:n.getKey(),title:n.getTitle(),rectangle:e}:{type:`inactive`}}return{type:`inactive`}}return{type:`inactive`}})),MB)}),NB=Rd(),PB=zd();zd();var FB=zd(),IB=zd(e=>{e.sub(e.pipe(IB,Kd(HS)),([,e])=>{e?.dispatchCommand(yw,null)})}),LB=zd(e=>{e.sub(e.pipe(LB,Kd($S,HS),Jd(([,e])=>q(e))),([,t,n])=>{n?.focus(()=>{setTimeout(()=>{n.getEditorState().read(()=>{let r=AB(t),i=eT(n),a=r?.getURL()??``,o=r?.getURL()??``,s=r?.getTitle()??``,c=r?.getKey()??``,l=r?r.getTextContent().length>0&&r.getChildrenSize()<=1:!!t?.isCollapsed(),u=l&&r?r.getTextContent():``;e.pub(MB,{type:`edit`,initialUrl:a,url:o,title:s,text:u,withAnchorText:l,linkNodeKey:c,rectangle:i})})})})})}),RB=Ld([]),zB=Ld(null),BB=Ld(null,e=>{e.pub(IC,t=>{function n(n){let[r,i]=e.getValues([GS,BB]);!r||i===null||t.update(()=>{let e=i_(n.target);if(e!==null){let t=cy(e,e=>e instanceof pw);t!==null&&i(n,t,t.getURL())}})}return t.registerRootListener((e,t)=>{e&&e.addEventListener(`click`,n),t&&t.removeEventListener(`click`,n)})})});function VB(e,t){gh(e)&&t&&(e.setTextContent(t),e.selectStart())}var HB=Ld(!0),$xe=Qd({init(e,t){e.pub(zC,t?.LinkDialog??Qxe),e.pub(zB,t?.onClickLinkCallback??null),e.pub(BB,t?.onReadOnlyClickLinkCallback??null),e.pub(HB,t?.showLinkTitleField??!0)},update(e,t={}){e.pub(RB,t.linkAutocompleteSuggestions??[])}});function UB(e,t){return U.forwardRef((n,r)=>{let i=(0,tT.default)(t.className,n.className);return U.createElement(e,{...t,...n,className:i,ref:r})})}function eSe(e){return({title:t,children:n,...r})=>U.createElement(e,{"aria-label":t,...r},U.createElement(bB,{title:t},n))}var tSe=({readOnly:e,children:t,className:n})=>U.createElement(ek,{className:(0,tT.default)(`mdxeditor-toolbar`,Y.toolbarRoot,{[Y.readOnlyToolbarRoot]:e},n),...e?{tabIndex:-1}:{}},t),WB=eSe(UB(tk,{className:Y.toolbarButton,"data-toolbar-item":!0})),GB=UB(rk,{className:Y.toolbarToggleItem,"data-toolbar-item":!0});UB(nk,{type:`single`,className:Y.toolbarToggleSingleGroup});var KB=U.forwardRef(({on:e,title:t,children:n,disabled:r,...i},a)=>U.createElement(nk,{type:`single`,className:Y.toolbarToggleSingleGroup,...i,value:e?`on`:`off`,ref:a},U.createElement(GB,{"aria-label":t,value:`on`,disabled:r},U.createElement(bB,{title:t},n)))),qB=({items:e})=>U.createElement(`div`,{className:Y.toolbarGroupOfGroups},e.map((e,t)=>U.createElement(KB,{key:t,title:e.title,on:e.active,onValueChange:t=>{e.onChange(t===`on`)},disabled:e.disabled},e.contents))),JB=({value:e,onChange:t,className:n,ggClassName:r,items:i,disabled:a})=>{let o=nw();return U.createElement(`div`,{className:(0,tT.default)(Y.toolbarGroupOfGroups,r)},U.createElement(nk,{"aria-label":o(`toolbar.toggleGroup`,`toggle group`),type:`single`,className:(0,tT.default)(Y.toolbarToggleSingleGroup,n),onValueChange:t,value:e||``,disabled:a,onFocus:e=>{e.preventDefault()}},i.map((e,t)=>U.createElement(GB,{key:t,"aria-label":e.title,value:e.value},U.createElement(bB,{title:e.title},e.contents)))))};function YB(e){return Object.hasOwn(e,`when`)}var nSe=({options:e})=>{let t=Hd(AC),n=U.useMemo(()=>{let n=e.find(e=>{if(YB(e)){if(e.when(t))return!0}else return!0});return n?YB(n)?n.contents():n.fallback():null},[e,t]);return U.createElement(`div`,{style:{display:`flex`}},n)},XB=Npe,ZB=Ld(()=>null),QB=Ld(``),$B=()=>"This is an empty toolbar. Pass `{toolbarContents: () => { return <>toolbar components</> }}` to the toolbarPlugin to customize it.",rSe=Qd({init(e,t){let n=t?.toolbarPosition===`bottom`?ese:$oe;e.pubIn({[ZB]:t?.toolbarContents??$B,[QB]:t?.toolbarClassName??``,[n]:()=>{let[e,t,n]=Ud(ZB,GS,QB);return U.createElement(tSe,{className:n,readOnly:t},e())}})},update(e,t){e.pub(ZB,t?.toolbarContents??$B),e.pub(QB,t?.toolbarClassName??``)}}),eV=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function tV(e,t,n,r,i,a){if(e==r)return[];let o=lV(e,t,n,r,i,a),s=uV(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new eV(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new eV(t,t+o,i,i),new eV(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new eV(t,t,i,i+o),new eV(n,n,i+o+c,a)]}if(c==1||l==1)return[new eV(t,n,i,a)];let u=fV(e,t,n,r,i,a);if(u){let[o,s,c]=u;return tV(e,t,o,r,i,s).concat(tV(e,o+c,n,r,s+c,a))}return iSe(e,t,n,r,i,a)}var nV=1e9,rV=0,iV=!1;function iSe(e,t,n,r,i,a){let o=n-t,s=a-i;if(nV<1e9&&Math.min(o,s)>nV*16||rV>0&&Date.now()>rV)return Math.min(o,s)>nV*64?[new eV(t,n,i,a)]:pV(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);oV.reset(c),sV.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:sV,f=d?null:oV;for(let p=0;p<c;p++){if(p>nV||rV>0&&!(p&63)&&Date.now()>rV)return pV(e,t,n,r,i,a);let m=oV.advance(p,o,s,c,d,!1,l)||sV.advance(p,o,s,c,f,!0,u);if(m)return aSe(e,t,n,t+m[0],r,i,a,i+m[1])}return[new eV(t,n,i,a)]}var aV=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1){if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}}return null}},oV=new aV,sV=new aV;function aSe(e,t,n,r,i,a,o,s){let c=!1;return!EV(e,r)&&++r==n&&(c=!0),!EV(i,s)&&++s==o&&(c=!0),c?[new eV(t,n,a,o)]:tV(e,t,r,i,a,s).concat(tV(e,r,n,i,s,o))}function cV(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function lV(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=cV(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!EV(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function uV(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=cV(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!EV(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function dV(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){EV(e,s)||s++;let u=s+o;if(EV(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=lV(e,u,n,r,i+f+d.length,a),c=uV(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function fV(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=fV(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:dV(e,t,n,r,i,a,Math.floor(o/4),-1)}function pV(e,t,n,r,i,a){iV=!0;let o=n-t,s=a-i,c;if(o<s){let s=dV(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=dV(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new eV(t,n,i,a)];let[l,u,d]=c;return tV(e,t,l,r,i,u).concat(tV(e,l+d,n,r,u+d,a))}function mV(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new eV(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function oSe(e,t,n){for(;;){mV(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=lV(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new eV(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=uV(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new eV(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new eV(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new eV(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function sSe(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=xV(t,a.fromA,l),f=bV(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new eV(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=bV(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new eV(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=xV(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new eV(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=CV(n,a.fromB,a.toB),r,o=t<0?-1:SV(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=CV(t,a.fromA,a.toA),r,o=n<0?-1:SV(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return mV(e,3),e}var hV;try{hV=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function gV(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function _V(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!gV(n):hV?!wV(n)||t==e.length-1?+!!hV.test(String.fromCharCode(n)):hV.test(e.slice(t,t+2))?2:0:0}function vV(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!gV(n):hV?!TV(n)||t==1?+!!hV.test(String.fromCharCode(n)):hV.test(e.slice(t-2,t))?2:0:0}var yV=8;function bV(e,t,n){if(t==e.length||!vV(e,t))return t;for(let r=t,i=t+n,a=0;a<yV;a++){let t=_V(e,r);if(!t||r+t>i)return r;r+=t}return t}function xV(e,t,n){if(!t||!_V(e,t))return t;for(let r=t,i=t-n,a=0;a<yV;a++){let t=vV(e,r);if(!t||r-t<i)return r;r-=t}return t}function SV(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function CV(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var wV=e=>e>=55296&&e<=56319,TV=e=>e>=56320&&e<=57343;function EV(e,t){return!t||t==e.length||!wV(e.charCodeAt(t-1))||!TV(e.charCodeAt(t))}function cSe(e,t,n){let r=n?.override;return r?r(e,t):(nV=(n?.scanLimit??1e9)>>1,rV=n?.timeout?Date.now()+n.timeout:0,iV=!1,oSe(e,t,tV(e,0,e.length,t,0,t.length)))}function DV(){return!iV}function OV(e,t,n){return sSe(cSe(e,t,n),e,t)}var kV=p.define({combine:e=>e[0]}),AV=k.define(),lSe=p.define(),jV=M.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(AV)&&(e=n.value);for(let n of t.state.facet(lSe))e=n(e,t);return e}}),MV=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return FV(OV(e.toString(),t.toString(),n),e,t,0,0,DV())}static updateA(e,t,n,r,i){return zV(RV(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return zV(RV(e,r,!1,t.length),e,t,n,i)}};function NV(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function PV(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function FV(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=NV(c.fromA+r,c.fromB+i,t,n),[d,f]=PV(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=NV(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=PV(a.toA+r,a.toB+i,t,n),s++}o.push(new MV(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var IV=1e3;function LV(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function RV(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>IV&&([l,d]=LV(e,a-IV,n,!0)),o<t.length-IV&&([u,f]=LV(e,o+IV,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function zV(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=OV(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of FV(h,n,r,d,f,DV()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var uSe={scanLimit:500},BV=ae.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=WV(e))}update(e){(e.docChanged||e.viewportChanged||dSe(e.startState,e.state)||fSe(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=WV(e.view))}},{decorations:e=>e.deco}),VV=we.low(ce({class:`cm-changeGutter`,markers:e=>e.plugin(BV)?.gutter||s.empty}));function dSe(e,t){return e.field(jV,!1)!=t.field(jV,!1)}function fSe(e,t){return e.facet(kV)!=t.facet(kV)}var HV=Pe.line({class:`cm-changedLine`}),pSe=Pe.mark({class:`cm-changedText`}),mSe=Pe.mark({tagName:`ins`,class:`cm-insertedLine`}),hSe=Pe.mark({tagName:`del`,class:`cm-deletedLine`}),UV=new class extends ie{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function gSe(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,HV),i.add(o,s,n?hSe:mSe),a&&a.add(o,o,UV);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,HV),a&&a.add(u,u,UV);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,pSe),s<t)c++;else break}u=t}}}function WV(e){let t=e.state.field(jV),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(kV),o=n==`a`,s=new V,c=i?new V:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&gSe(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var GV=class extends N{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},KV=k.define({map:(e,t)=>e.map(t)}),qV=M.define({create:()=>Pe.none,update:(e,t)=>{for(let e of t.effects)if(e.is(KV))return e.value;return e.map(t.changes)},provide:e=>B.decorations.from(e)}),JV=.01;function YV(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function _Se(e,t,n){let r=new V,i=new V,a=e.state.field(qV).iter(),o=t.state.field(qV).iter(),s=0,c=0,l=0,u=0,d=e.viewport,f=t.viewport;for(let p=0;;p++){let m=p<n.length?n[p]:null,h=m?m.fromA:e.state.doc.length,g=m?m.fromB:t.state.doc.length;if(s<h){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+u);n<-.01?(l-=n,r.add(s,s,Pe.widget({widget:new GV(-n),block:!0,side:-1}))):n>JV&&(u+=n,i.add(c,c,Pe.widget({widget:new GV(n),block:!0,side:-1})))}if(h>s+1e3&&s<d.from&&h>d.from&&c<f.from&&g>f.from){let e=Math.min(d.from-s,f.from-c);s+=e,c+=e,p--}else if(m)s=m.toA,c=m.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let p=e.contentHeight+l-(t.contentHeight+u);p<JV?r.add(e.state.doc.length,e.state.doc.length,Pe.widget({widget:new GV(-p),block:!0,side:1})):p>JV&&i.add(t.state.doc.length,t.state.doc.length,Pe.widget({widget:new GV(p),block:!0,side:1}));let m=r.finish(),h=i.finish();YV(m,e.state.field(qV))||e.dispatch({effects:KV.of(m)}),YV(h,t.state.field(qV))||t.dispatch({effects:KV.of(h)})}var XV=k.define({map:(e,t)=>t.mapPos(e)}),vSe=class extends N{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:XV.of(n)});let{side:r,sibling:i}=e.state.facet(kV);i&&i().dispatch({effects:XV.of(ySe(n,e.state.field(jV),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function ySe(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var bSe=M.define({create(e){return Pe.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(XV)&&(e=e.update({filter:e=>e!=n.value}));if(e.size&&t.state.field(jV)!=t.startState.field(jV,!1)){let n=t.state.facet(kV).side==`a`,r=[];for(let i of t.state.field(jV))e.between(n?i.fromA:i.fromB,n?i.toA:i.toB,e=>{r.push(e)});r.length&&(e=e.update({filter:e=>r.indexOf(e)<0}))}return e},provide:e=>B.decorations.from(e)});function ZV({margin:e=3,minSize:t=4}){return bSe.init(n=>xSe(n,e,t))}function xSe(e,t,n){let r=new V,i=e.facet(kV).side==`a`,a=e.field(jV),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,Pe.replace({widget:new vSe(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var SSe=B.styleModule.of(new Xe({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),CSe=B.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),QV=new Ke,$V=new Ke,wSe=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||uSe;let t=[we.low(BV),CSe,SSe,qV,B.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(KV)))&&this.measure()})],n=[kV.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(VV);let r=h.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],B.editorAttributes.of({class:`cm-merge-a`}),$V.of(n),t]}),i=[kV.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(VV);let a=h.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],B.editorAttributes.of({class:`cm-merge-b`}),$V.of(i),t]});this.chunks=MV.build(r.doc,a.doc,this.diffConf);let o=[jV.init(()=>this.chunks),QV.of(e.collapseUnchanged?ZV(e.collapseUnchanged):[])];r=r.update({effects:k.appendConfig.of(o)}).state,a=a.update({effects:k.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new B({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new B({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),I.empty(e[0].startState.doc.length));this.chunks=t==this.a?MV.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):MV.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:AV.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:AV.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(kV),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push($V.reconfigure([kV.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?VV:[]])),a.push($V.reconfigure([kV.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?VV:[]]))}if(r){let t=QV.reconfigure(e.collapseUnchanged?ZV(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){_Se(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=eH(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=eH(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function eH(e){let t=e.nextSibling;return e.remove(),t}var tH=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[c.contextHash,r]]}addChild(e,t){e.prop(c.contextHash)!=this.hash&&(e=new v(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new v(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new v(y.none,e,t,n,this.hashProp)})}},nH;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(nH||={});var TSe=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},ESe=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return oH(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function rH(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==nH.OrderedList?pH:fH)(n,t,!1);return r>0&&(e.type!=nH.BulletList||uH(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var iH={[nH.Blockquote](e,t,n){return n.next==62&&(n.markers.push(IH(nH.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(aH(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[nH.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[nH.OrderedList]:rH,[nH.BulletList]:rH,[nH.Document](){return!0}};function aH(e){return e==32||e==9||e==10||e==13}function oH(e,t=0){for(;t<e.length&&aH(e.charCodeAt(t));)t++;return t}function sH(e,t,n){for(;t>n&&aH(e.charCodeAt(t-1));)t--;return t}function cH(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function lH(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function uH(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!aH(n))return-1}return n&&e.next==45&&hH(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(TH.SetextHeading)>-1||r<3?-1:1}function dH(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function fH(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||aH(e.text.charCodeAt(e.pos+1)))&&(!n||dH(t,nH.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function pH(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!aH(e.text.charCodeAt(r+1))||n&&!dH(t,nH.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function mH(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function hH(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&aH(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var gH=/^[ \t]*$/,_H=/-->/,vH=/\?>/,yH=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,_H],[/^\s*<\?/,vH],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,gH],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,gH]];function bH(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=yH.length-+!!n;e<t;e++)if(yH[e][0].test(r))return e;return-1}function xH(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.skipSpace(t),i=e.countIndent(r,t,n);return i>=n+5||r==e.text.length?n+1:i}function SH(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==nH.CodeText?e[r].to=n:e.push(IH(nH.CodeText,t,n))}var CH={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(SH(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){SH(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==nH.CodeText?SH(o,e.from,e.to):o.push(e);s=[]}SH(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&SH(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=nH.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(nH.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=cH(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=sH(t.text,t.text.length,o),c=[IH(nH.CodeMark,r,r+a)];o<s&&c.push(IH(nH.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&SH(c,e.lineStart-1,e.lineStart),c.push(IH(nH.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}{o=!0,n||(SH(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(SH(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(nH.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=lH(t);return n<0?!1:(e.startContext(nH.Blockquote,t.pos),e.addNode(nH.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(uH(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(nH.HorizontalRule,n),!0},BulletList(e,t){let n=fH(t,e,!1);if(n<0)return!1;e.block.type!=nH.BulletList&&e.startContext(nH.BulletList,t.basePos,t.next);let r=xH(t,t.pos+1);return e.startContext(nH.ListItem,t.basePos,r-t.baseIndent),e.addNode(nH.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=pH(t,e,!1);if(n<0)return!1;e.block.type!=nH.OrderedList&&e.startContext(nH.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=xH(t,t.pos+n);return e.startContext(nH.ListItem,t.basePos,r-t.baseIndent),e.addNode(nH.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=mH(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=sH(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!aH(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(nH.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(nH.HeaderMark,o-r,a-r);let c=s.finish(nH.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=bH(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=yH[n][1],a=[],o=i!=gH;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==_H?nH.CommentBlock:i==vH?nH.ProcessingInstructionBlock:nH.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},DSe=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
177
177
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length&&this.complete(e,n,i)}finish(e,t){return(this.stage==2||this.stage==3)&&oH(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,n){return e.addLeafElement(t,IH(nH.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(KH(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(IH(nH.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(WH(e,oH(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=oH(e,this.pos),n=0;if(t>this.pos){let r=GH(e,t,this.start);if(r){let t=wH(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=wH(e,this.pos),n>0&&n<e.length?n:-1}else return wH(e,this.pos)}};function wH(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!aH(n))return-1}return t}var OSe=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:hH(t),i=t.next;if(r<0)return!1;let a=IH(nH.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,IH(i==61?nH.SetextHeading1:nH.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},TH={LinkReference(e,t){return t.content.charCodeAt(0)==91?new DSe(t):null},SetextHeading(){return new OSe}},kSe=[(e,t)=>mH(t)>=0,(e,t)=>cH(t)>=0,(e,t)=>lH(t)>=0,(e,t)=>fH(t,e,!0)>=0,(e,t)=>pH(t,e,!0)>=0,(e,t)=>uH(t,e,!0)>=0,(e,t)=>bH(t,e,!0)>=0],ASe={text:``,end:0},jSe=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new ESe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=tH.create(nH.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new FSe(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new TSe(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
178
178
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=YH(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=ASe;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+nH[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
@@ -225,4 +225,4 @@ Error generating stack: `+e.message+`
225
225
  to { stroke-dashoffset: -24; }
226
226
  }
227
227
  `})}function f9({icon:e,label:t,onSelect:n,disabled:r=!1,destructive:i=!1}){return(0,W.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,onClick:n,disabled:r,className:`flex w-full items-center gap-2 px-3 py-2 text-left transition disabled:cursor-not-allowed disabled:opacity-40 ${i?`text-red-300 hover:bg-red-500/10 hover:text-red-100`:`text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4]`}`,children:[(0,W.jsx)(`span`,{className:`shrink-0`,children:e}),(0,W.jsx)(`span`,{className:`truncate`,children:t})]})}function s2e({nodeId:e,node:t,lastRun:n,visualState:r}){let i=F7(t),a=n?.nodeAttempts.findLast(t=>t.nodeId===e),o=M7(t.input)?t.input:void 0,s=M7(t.output)?t.output:void 0;return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow node viewer`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Node viewer`}),(0,W.jsx)(`div`,{className:`mt-1 truncate text-sm font-bold text-slate-100`,children:I7(e,t)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-500`,children:e})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1 text-[10px]`,children:[(0,W.jsx)(l9,{label:i}),r===`running`?(0,W.jsx)(l9,{label:`running`}):null,r===`recent`?(0,W.jsx)(l9,{label:`last run`}):null]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2 text-[11px] leading-5 text-slate-300`,children:[(0,W.jsx)(p9,{label:`Input port`,value:l2e(o)}),(0,W.jsx)(p9,{label:`Output port`,value:l2e(s)}),i===`trigger`?(0,W.jsx)(p9,{label:`Trigger`,value:u2e(t.trigger)}):null,i===`agent`?(0,W.jsx)(p9,{label:`Agent profile`,value:d2e(t.profile)}):null,i===`agent`?(0,W.jsx)(p9,{label:`Prompt source`,value:typeof t.promptTemplate==`string`?`promptTemplate`:t.promptBuilder?`promptBuilder`:`input`}):null,i===`adapter`?(0,W.jsx)(p9,{label:`Adapter`,value:f2e(t.handler)}):null,i===`workflow`?(0,W.jsx)(p9,{label:`Nested workflow`,value:`${typeof t.workflowId==`string`?t.workflowId:`<missing>`}@${typeof t.workflowVersion==`string`?t.workflowVersion:`latest`}`}):null,i===`human`?(0,W.jsx)(p9,{label:`Human actions`,value:Array.isArray(t.actions)?`${t.actions.length} actions`:`none`}):null]}),a?(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-300`,"aria-label":`Last node run facts`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Last run facts`}),(0,W.jsx)(p9,{label:`Attempt`,value:`${a.id} · ${a.status}`}),a.piboSessionId?(0,W.jsx)(p9,{label:`Pibo Session`,value:a.piboSessionId}):null,(0,W.jsx)(c2e,{label:`Input`,value:a.input}),a.output===void 0?null:(0,W.jsx)(c2e,{label:`Output`,value:a.output})]}):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#151f24]/50 p-2 text-[11px] leading-5 text-slate-500`,children:`No run facts for this node yet.`})]})}function p9({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[110px_minmax(0,1fr)] gap-2`,children:[(0,W.jsx)(`div`,{className:`text-slate-500`,children:e}),(0,W.jsx)(`div`,{className:`min-w-0 break-words font-mono text-slate-200`,children:t})]})}function c2e({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`div`,{className:`text-slate-500`,children:e}),(0,W.jsx)(`pre`,{className:`max-h-28 overflow-auto rounded-sm border border-slate-800 bg-[#0c171c] p-2 whitespace-pre-wrap text-slate-200`,children:t})]})}function l2e(e){return e?`${typeof e.kind==`string`?e.kind:`unknown`}${typeof e.description==`string`&&e.description.trim()?` · ${e.description.trim()}`:``}`:`none`}function u2e(e){return M7(e)?`${typeof e.kind==`string`?e.kind:`unknown`} · ${typeof e.mode==`string`?e.mode:`default`}`:`<missing>`}function d2e(e){return M7(e)&&typeof e.id==`string`?e.id:`<missing>`}function f2e(e){return typeof e==`string`?e:M7(e)&&typeof e.id==`string`?e.id:`<missing>`}function p2e({color:e}){return(0,W.jsx)(`svg`,{className:`pointer-events-none absolute inset-0 z-10 h-full w-full`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:(0,W.jsx)(`rect`,{x:`1`,y:`1`,width:`98`,height:`98`,rx:`2`,fill:`none`,stroke:e,strokeWidth:`2`,strokeDasharray:`9 7`,vectorEffect:`non-scaling-stroke`,style:{animation:`workflow-node-outline-flow 0.8s linear infinite`}})})}function m2e({data:e,selected:t}){let n=e.kind===`trigger`,r=e.runVisualState===`running`||e.runVisualState===`recent`,i=e.runVisualState===`running`?`#facc15`:`#22c55e`;return(0,W.jsxs)(`div`,{className:`relative min-w-44 rounded-sm border px-3 py-2 shadow-lg shadow-black/20 ${n?`bg-emerald-950/30`:`bg-[#15242b]`} ${r?`border-transparent`:t?`border-[#38bdf8]`:n?`border-emerald-700/70`:`border-slate-700`}`,children:[r?(0,W.jsx)(p2e,{color:i}):null,n?null:(0,W.jsx)(T7,{type:`target`,position:y5.Left,className:`!h-2.5 !w-2.5 !border-[#0f172a] !bg-[#38bdf8]`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:`truncate text-xs font-bold text-slate-100`,children:e.label}),(0,W.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.12em] ${n?`border-emerald-500/50 text-emerald-200`:`border-slate-700 text-slate-400`}`,children:e.kind})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[10px] text-slate-500`,children:e.nodeId}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1 text-[10px]`,children:[e.isInitial?(0,W.jsx)(`span`,{className:`rounded-full border border-[#11a4d4]/40 bg-[#11a4d4]/10 px-2 py-0.5 text-[#8bdcf4]`,children:`initial`}):null,e.validationCount?(0,W.jsxs)(`span`,{className:`rounded-full border border-amber-600/60 bg-amber-950/30 px-2 py-0.5 text-amber-200`,children:[e.validationCount,` diagnostics`]}):null]}),n?(0,W.jsxs)(`button`,{type:`button`,className:`nodrag nopan mt-2 inline-flex w-full items-center justify-center gap-2 rounded-sm border border-emerald-600/70 bg-emerald-500/10 px-2 py-1.5 text-[11px] font-bold text-emerald-100 transition hover:border-emerald-300 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:t=>{t.preventDefault(),t.stopPropagation(),e.onManualTriggerRun?.(e.nodeId)},disabled:e.readOnly,title:`Run this manual trigger`,children:[(0,W.jsx)(il,{size:12}),`Play test`]}):null,(0,W.jsx)(T7,{type:`source`,position:y5.Right,className:`!h-2.5 !w-2.5 !border-[#0f172a] ${n?`!bg-emerald-400`:`!bg-[#38bdf8]`}`})]})}function h2e({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,markerEnd:s,markerStart:c,style:l,selected:u,data:d,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:_}){let{screenToFlowPosition:v}=b7(),[y,b]=(0,U.useState)(void 0),x=(0,U.useRef)(void 0);(0,U.useEffect)(()=>{b(void 0),x.current=void 0},[d?.route,t,n,r,i,a,o]);let S=v2e({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,route:{...d?.route??{},...y??{}}}),C=d?.recentTransition===!0,w={...l,stroke:u?`#facc15`:C?`#22c55e`:`#38bdf8`,strokeWidth:u?2.2:C?2.4:1.5,...C?{strokeDasharray:`8 7`,animation:`workflow-edge-flow 0.7s linear infinite`}:{}},T=(t,n)=>{if(d?.readOnly||n.button!==0)return;n.preventDefault(),n.stopPropagation();let r=n.clientX,i=n.clientY,a=!1;x.current={...d?.route??{},...x.current??y??{}};let o=e=>{if(!a&&Math.hypot(e.clientX-r,e.clientY-i)<3)return;a=!0;let n=v({x:e.clientX,y:e.clientY}),o=Math.round(t.axis===`x`?n.x:n.y),s={...x.current??{}};s[t.routeKey]=o,x.current=s,b(s)},s=()=>{document.removeEventListener(`pointermove`,o),document.removeEventListener(`pointerup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,a?d?.onRouteChange?.(e,x.current??{}):d?.onSelect?.(e)};document.body.style.cursor=t.cursor,document.body.style.userSelect=`none`,document.addEventListener(`pointermove`,o),document.addEventListener(`pointerup`,s)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(D7,{id:e,path:S.path,markerStart:c,markerEnd:s,style:w,interactionWidth:22,label:f,labelX:S.labelX,labelY:S.labelY,labelStyle:p,labelShowBg:m,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:_}),S.draggableSegments.map(t=>(0,W.jsx)(`path`,{d:t.path,fill:`none`,stroke:`transparent`,strokeWidth:22,className:`nopan ${t.cursorClass}`,onClick:e=>e.stopPropagation(),onPointerDown:e=>T(t,e),onContextMenu:t=>d?.onContextMenu?.(e,t),"aria-label":`Move edge route ${e}`,children:(0,W.jsx)(`title`,{children:t.title})},t.id))]})}var m9=20,g2e=5,_2e=8;function v2e(e){let t={x:e.sourceX,y:e.sourceY},n={x:e.targetX,y:e.targetY},r=y2e(e.sourcePosition),i=y2e(e.targetPosition),a={x:t.x+r.x*m9,y:t.y+r.y*m9},o={x:n.x+i.x*m9,y:n.y+i.y*m9},s,c;if(r.x!==0&&i.x!==0&&r.x*i.x===-1){let i=o.x>=a.x?1:-1;if(r.x===i){let r=h9(e.route.centerX,(a.x+o.x)/2);s=[t,{x:r,y:t.y},{x:r,y:n.y},n],c=[g9(`centerX`,s[1],s[2])]}else{let r=h9(e.route.sourceControlX,a.x),i=h9(e.route.targetControlX,o.x),l=h9(e.route.centerY,(t.y+n.y)/2);s=[t,{x:r,y:t.y},{x:r,y:l},{x:i,y:l},{x:i,y:n.y},n],c=[g9(`sourceControlX`,s[1],s[2]),g9(`centerY`,s[2],s[3]),g9(`targetControlX`,s[3],s[4])]}}else if(r.y!==0&&i.y!==0&&r.y*i.y===-1){let i=o.y>=a.y?1:-1;if(r.y===i){let r=h9(e.route.centerY,(a.y+o.y)/2);s=[t,{x:t.x,y:r},{x:n.x,y:r},n],c=[g9(`centerY`,s[1],s[2])]}else{let r=h9(e.route.sourceControlY,a.y),i=h9(e.route.targetControlY,o.y),l=h9(e.route.centerX,(t.x+n.x)/2);s=[t,{x:t.x,y:r},{x:l,y:r},{x:l,y:i},{x:n.x,y:i},n],c=[g9(`sourceControlY`,s[1],s[2]),g9(`centerX`,s[2],s[3]),g9(`targetControlY`,s[3],s[4])]}}else{let r=h9(e.route.centerX,(a.x+o.x)/2),i=h9(e.route.centerY,(a.y+o.y)/2);s=[t,a,{x:r,y:a.y},{x:r,y:i},{x:o.x,y:i},o,n],c=b2e(s).map((e,t)=>({...e,id:`fallback-${t}`,routeKey:e.axis===`x`?`centerX`:`centerY`}))}let l=c.filter(e=>C2e(e)>=_2e),u=w2e(l)??T2e(s);return{path:x2e(s),labelX:u?(u.start.x+u.end.x)/2:(t.x+n.x)/2,labelY:u?(u.start.y+u.end.y)/2:(t.y+n.y)/2,draggableSegments:l}}function y2e(e){return e===y5.Left?{x:-1,y:0}:e===y5.Right?{x:1,y:0}:e===y5.Top?{x:0,y:-1}:{x:0,y:1}}function h9(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function g9(e,t,n){let r=t.x===n.x;return{id:`${e}-${t.x}-${t.y}-${n.x}-${n.y}`,start:t,end:n,path:`M ${t.x},${t.y} L ${n.x},${n.y}`,axis:r?`x`:`y`,routeKey:e,cursor:r?`ew-resize`:`ns-resize`,cursorClass:r?`cursor-ew-resize`:`cursor-ns-resize`,title:r?`Drag vertical edge segment left or right`:`Drag horizontal edge segment up or down`}}function b2e(e){return e.slice(1,-2).flatMap((t,n)=>{let r=e[n+2];return!r||t.x!==r.x&&t.y!==r.y||t.x===r.x&&t.y===r.y?[]:[g9(t.x===r.x?`centerX`:`centerY`,t,r)]})}function x2e(e){if(!e.length)return``;let t=`M ${e[0].x},${e[0].y}`;for(let n=1;n<e.length-1;n+=1)t+=S2e(e[n-1],e[n],e[n+1]);return t+=` L ${e[e.length-1].x},${e[e.length-1].y}`,t}function S2e(e,t,n){let r=Math.min(_9(e,t)/2,_9(t,n)/2,g2e);if(e.x===t.x&&t.x===n.x||e.y===t.y&&t.y===n.y)return` L ${t.x},${t.y}`;if(e.y===t.y){let i=e.x<n.x?-1:1,a=e.y<n.y?1:-1;return` L ${t.x+r*i},${t.y} Q ${t.x},${t.y} ${t.x},${t.y+r*a}`}let i=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return` L ${t.x},${t.y+r*a} Q ${t.x},${t.y} ${t.x+r*i},${t.y}`}function _9(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function C2e(e){return _9(e.start,e.end)}function w2e(e){let t;for(let n of e){let e=C2e(n);(!t||e>t.length)&&(t={start:n.start,end:n.end,length:e})}return t}function T2e(e){let t;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1],a=_9(r,i);(!t||a>t.length)&&(t={start:r,end:i,length:a})}return t}var E2e={workflowNode:m2e},D2e={workflowEdge:h2e};function O2e(e){return e instanceof HTMLElement?e.isContentEditable?!0:!!e.closest(`input, textarea, select, [contenteditable='true']`):!1}function k2e(e,t){if(!t)return`Select a node or edge in the canvas to inspect or delete it.`;if(t.type===`node`){let n=N7(e)[t.id];return n?`Node ${t.id}: ${F7(n)} — ${I7(t.id,n)}`:`Node ${t.id}`}let n=P7(e)[t.id],r=n?W7(n.from):void 0,i=n?W7(n.to):void 0;return n&&r&&i?`Edge ${t.id}: ${r} → ${i}`:`Edge ${t.id}`}function A2e(e,t){let n=W7(t.from),r=W7(t.to),i=F2e(e,t),a=v9(e,t);return{...n?{sourceNodeId:n}:{},...r?{targetNodeId:r}:{},...i?{sourcePort:i}:{},...a?{targetPort:a}:{},directlyCompatible:!!(i&&a&&P2e(i,a))}}function j2e(e){let t=M7(e.adapter)?e.adapter:void 0;return R2e(t&&M7(t.transform)?t.transform:void 0)}function M2e(e,t,n){let r=P7(e),i=r[t];if(!i)return e;let a=v9(e,i)??y9();return{...e,edges:{...r,[t]:{...i,id:t,adapter:{kind:`edgeAdapter`,transform:L2e(n),output:b9(a)}}}}}function N2e(e,t,n){let r=P7(e),i=r[t];if(!i)return e;let a=W7(i.from),o=W7(i.to);if(!a||!o)return e;let s=N7(e),c=B7(e,`adapter`),l=F2e(e,i)??y9(),u=v9(e,i)??y9(),d=L7(e),f=z2e(d[a],d[o])??z7(K1e(e,[]).nodes),p={...r};delete p[t];let m=B2e(p,`${t}_to_${c}`),h=B2e({...p,[m]:{}},`${c}_to_${o}`),g={id:m,from:b9(M7(i.from)?i.from:{nodeId:a}),to:{nodeId:c},kind:typeof i.kind==`string`?i.kind:`data`};M7(i.guard)&&(g.guard=b9(i.guard));let _={id:h,from:{nodeId:c},to:b9(M7(i.to)?i.to:{nodeId:o}),kind:typeof i.kind==`string`?i.kind:`data`};return H7({...e,nodes:{...s,[c]:J0e(c,n,l,u)},edges:{...p,[m]:g,[h]:_}},{...d,[c]:f})}function P2e(e,t){return e.kind===`text`&&t.kind===`text`?!0:e.kind!==`json`||t.kind!==`json`?!1:JSON.stringify(e.schema??null)===JSON.stringify(t.schema??null)}function F2e(e,t){let n=I2e(e,t.from);return n&&M7(n.output)?n.output:void 0}function v9(e,t){let n=I2e(e,t.to);return n&&M7(n.input)?n.input:void 0}function I2e(e,t){let n=W7(t);return n?N7(e)[n]:void 0}function y9(){return{kind:`text`}}function L2e(e){return{kind:`adapter`,language:`typescript`,id:e}}function R2e(e){return M7(e)&&e.kind===`adapter`&&e.language===`typescript`&&typeof e.id==`string`?e.id:``}function z2e(e,t){return e&&t?{x:(e.x+t.x)/2,y:(e.y+t.y)/2}:void 0}function B2e(e,t){let n=t.replace(/[^a-zA-Z0-9_-]/g,`-`);if(!Object.hasOwn(e,n))return n;let r=2;for(;Object.hasOwn(e,`${n}_${r}`);)r+=1;return`${n}_${r}`}function b9(e){return JSON.parse(JSON.stringify(e))}function V2e(e){let t=M7(e.metadata)?e.metadata:{};return{title:typeof e.title==`string`?e.title:``,description:typeof e.description==`string`?e.description:``,inputKind:X7(e.input,`text`),inputDescription:Z7(e.input),inputSchemaText:Q7(e.input),outputKind:X7(e.output,`text`),outputDescription:Z7(e.output),outputSchemaText:Q7(e.output),globalStateFields:U2e(e),metadataTags:C9(t.tags),metadataUseWhen:C9(t.useWhen),metadataNotFor:C9(t.notFor),metadataExamples:C9(t.examples)}}function x9(e,t){let n=M7(e.metadata)?{...e.metadata}:{};w9(n,`tags`,t.metadataTags),w9(n,`useWhen`,t.metadataUseWhen),w9(n,`notFor`,t.metadataNotFor),w9(n,`examples`,t.metadataExamples);let r={...e,input:t9(t.inputKind,t.inputDescription,e.input,t.inputSchemaText),output:t9(t.outputKind,t.outputDescription,e.output,t.outputSchemaText)};return G2e(r,t.globalStateFields),o9(r,`title`,t.title),o9(r,`description`,t.description),Object.keys(n).length?r.metadata=n:delete r.metadata,r}function H2e(e){let t=new Set(e.map(e=>e.path.trim()).filter(Boolean)),n=`projectGoal`,r=2;for(;t.has(n);)n=`projectGoal${r}`,r+=1;return{path:n,description:``,schemaText:$7(G7),mergeKind:`none`}}function U2e(e){let t=M7(e.state)?e.state:void 0,n=t&&M7(t.global)?t.global:void 0;return n?Object.entries(n).flatMap(([e,t])=>M7(t)?[{path:e,description:typeof t.description==`string`?t.description:``,schemaText:$7(t.schema),mergeKind:W2e(t.merge)}]:[]):[]}function W2e(e){return!M7(e)||typeof e.kind!=`string`?`none`:[`replace`,`append`,`shallowMerge`].includes(e.kind)?e.kind:`none`}function G2e(e,t){let n=M7(e.state)?{...e.state}:{},r={};for(let e of t){let t=_0e(e.path);if(!t)continue;let n={schema:e9(e.schemaText)};o9(n,`description`,e.description);let i=K2e(e.mergeKind);i&&(n.merge=i),r[t]=n}Object.keys(r).length?n.global=r:delete n.global,Object.keys(n).length?e.state=n:delete e.state}function K2e(e){return e===`none`?void 0:{kind:e}}function q2e(e,t){return JSON.stringify(U2e(e))!==JSON.stringify(t.globalStateFields)}function S9(e){return typeof e==`string`?e.trim():M7(e)&&typeof e.id==`string`?e.id.trim():``}function J2e(e,t,n){let r=N7(e),i=r[t];if(!i)return e;let a={...i,promptBuilder:{kind:`promptBuilder`,language:`typescript`,id:n.id,revisionId:n.revisionId,contentHash:n.contentHash,source:n.source},metadata:Y2e(i.metadata,n)};return delete a.promptTemplate,{...e,metadata:Y2e(e.metadata,n),nodes:{...r,[t]:a}}}function Y2e(e,t){let n=M7(e)?{...e}:{},r=Array.isArray(n.promptAssetRefs)?n.promptAssetRefs.filter(e=>typeof e==`string`&&e.trim().length>0):[];return n.promptAssetRefs=[...new Set([...r,t.id])],n.promptAssetPins=[...Array.isArray(n.promptAssetPins)?n.promptAssetPins.filter(e=>M7(e)&&e.assetId!==t.id):[],{assetId:t.id,revisionId:t.revisionId,contentHash:t.contentHash,source:t.source}],n}function C9(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`
228
- `):``}function X2e(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function w9(e,t,n){let r=X2e(n);r.length?e[t]=r:delete e[t]}function T9({diagnostics:e}){return e.length?(0,W.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Inspector picker diagnostics`,children:e.map(e=>(0,W.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-2 text-[11px] leading-5 text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,W.jsx)(Dl,{size:12}),e.code]}),(0,W.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-amber-200/80`,children:e.path}),(0,W.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function E9({option:e,badge:t}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-semibold text-slate-200`,children:e.displayName}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.id})]}),(0,W.jsx)(l9,{label:t})]}),e.description?(0,W.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,e.paramsSchema?(0,W.jsx)(`div`,{className:`mt-3`,children:(0,W.jsx)(D9,{label:`paramsSchema`,schema:e.paramsSchema})}):null]})}function D9({label:e,schema:t}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,W.jsx)(`pre`,{className:`mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[11px] leading-5 text-slate-300`,children:Z2e(t)})]})}function Z2e(e){return e?JSON.stringify(e,null,2):`null`}function Q2e({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let a=(0,U.useRef)(null),[o,s]=(0,U.useState)(S9(n.promptBuilder)),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(),[f,p]=(0,U.useState)(`idle`),[m,h]=(0,U.useState)(`saved`),[g,_]=(0,U.useState)();(0,U.useEffect)(()=>{s(S9(n.promptBuilder))},[n,t]),(0,U.useEffect)(()=>{let e=!1;return Hze(o||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o]),(0,U.useEffect)(()=>{let e=!1;return _(void 0),o?(p(`loading`),Uze(o).then(t=>{e||(d(t.asset),p(`loaded`))}).catch(t=>{e||(d(void 0),p(`error`),_(t instanceof Error?t.message:`Failed to load prompt asset`))}),()=>{e=!0}):(d(void 0),p(`idle`),()=>{e=!0})},[o]);let v=c?.options.find(e=>e.id===o),y=typeof n.promptTemplate==`string`?n.promptTemplate:z0e,b=u?.markdown??y,x=`${e.draftId}:${t}`,S=!!S9(n.promptBuilder),C=o.startsWith(`ui.promptAssets.`),w=`${typeof n.label==`string`&&n.label.trim()?n.label.trim():t} prompt asset`,T=(0,U.useCallback)(async n=>{try{let r=await Wze({assetId:C?o:void 0,sourceRefId:o||void 0,displayName:w,description:`Managed prompt asset for ${t} in draft ${e.draftId}.`,markdown:n});await i(J2e(e.definition,t,r.asset),`Saved prompt asset revision ${r.asset.revisionId} and updated ${t}.`,{editTrigger:`prompt_edit`}),s(r.asset.id),d(r.asset),_(`Saved ${r.asset.displayName} as revision ${r.asset.revisionId}; draft now pins ${r.asset.contentHash}.`)}catch(e){throw _(e instanceof Error?e.message:`Failed to save prompt asset revision`),e}},[e.definition,e.draftId,t,i,w,o,C]),E=async e=>{try{await a.current?.flushSave(),s(e)}catch(e){_(e instanceof Error?e.message:`Failed to save the current prompt asset before switching`)}},D=async()=>{u&&(await i(J2e(e.definition,t,u),`Updated ${t} to use prompt asset ${u.id}.`,{editTrigger:`prompt_edit`}),_(`Draft node ${t} now uses ${u.displayName} at ${u.contentHash}.`))};return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Prompt asset Markdown editor`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Prompt asset Markdown editor`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Edit prompt assets with the same Markdown editor pattern as Context Files. Saving creates a managed UI asset revision, updates this draft node to a prompt asset ref, and pins the revision id plus content hash in the Pibo Workflow IR.`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Prompt asset ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o,onChange:e=>void E(e.target.value),disabled:r,children:[(0,W.jsx)(`option`,{value:``,children:`Create managed asset from direct prompt template`}),c?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:c?.diagnostics??[]}),v?(0,W.jsx)(E9,{option:v,badge:v.kind===`ui`?`managed prompt asset`:`registered prompt asset`}):null,f===`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-2 text-[11px] leading-5 text-red-200`,role:`alert`,children:g??`Failed to load prompt asset.`}):null,(0,W.jsx)(`div`,{className:`workflow-prompt-editor-frame min-w-0 rounded-sm bg-[#101d22]`,children:(0,W.jsx)(bW,{ref:a,documentKey:x,initialMarkdown:b,onPersist:T,onSaveStateChange:h,ariaLabel:`Prompt asset Markdown editor`})}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:S?`promptBuilder ref`:`direct promptTemplate source`}),(0,W.jsx)(l9,{label:`Markdown save: ${m}`}),u?(0,W.jsx)(l9,{label:`${u.source} · ${u.revisionId}`}):null]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void D(),disabled:r||!u,children:[(0,W.jsx)(fl,{size:13}),`Use selected asset on draft`]})}),g&&f!==`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-2 text-[11px] leading-5 text-emerald-200`,role:`status`,children:g}):null,(0,W.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Code/plugin prompt assets are not mutated. Editing a registered asset copies the Markdown into a managed UI prompt asset; later saves append revisions and only affect this draft or future workflow versions that reference the new revision.`})]})}function $2e({workflowId:e,workflowVersion:t}){let[n,r]=(0,U.useState)(),[i,a]=(0,U.useState)(`loading`),[o,s]=(0,U.useState)();(0,U.useEffect)(()=>{let n=!1;return a(`loading`),s(void 0),qze({selectedWorkflowId:e,selectedWorkflowVersion:t}).then(e=>{n||(r(e),a(`loaded`))}).catch(e=>{n||(s(e instanceof Error?e.message:`Failed to load workflow viewer`),a(`error`))}),()=>{n=!0}},[e,t]);let c=(0,U.useMemo)(()=>n?.options.find(e=>e.id===n.selectedWorkflowId&&e.version===n.selectedWorkflowVersion),[n]);return i===`loading`?(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-sm text-slate-300`,"aria-live":`polite`,children:[(0,W.jsx)(Rc,{size:16,className:`animate-spin text-[#11a4d4]`}),`Loading workflow viewer `,e,`@`,t,`…`]}):i===`error`?(0,W.jsxs)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-4 text-sm leading-6 text-red-200`,role:`alert`,children:[(0,W.jsx)(`div`,{className:`font-bold`,children:`Could not load workflow viewer`}),(0,W.jsx)(`div`,{className:`mt-1 text-xs`,children:o??`Failed to load workflow metadata.`})]}):(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,W.jsx)(pc,{size:13}),`Workflow version viewer`]}),(0,W.jsx)(`h3`,{className:`mt-1 text-lg font-bold text-slate-100`,children:c?.title??`${e}@${t}`}),(0,W.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:`This separate viewer is the nested workflow navigation target. Parent graphs do not inline-expand nested workflow internals in V2.`})]}),(0,W.jsx)(`a`,{className:`shrink-0 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,href:`/apps/chat/workflows`,children:`Back to Workflows`})]}),c?(0,W.jsx)(e4e,{option:c}):null,(0,W.jsx)(t4e,{diagnostics:n?.diagnostics??[],ariaLabel:`Workflow viewer diagnostics`}),(0,W.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Viewer mode shows registry metadata and navigation context only. To change a child workflow, open its own UI draft or duplicate/edit a published workflow from the Workflow Library.`})]})}function e4e({option:e}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,W.jsxs)(`div`,{className:`font-semibold text-slate-200`,children:[`Selected workflow: `,e.title]}),(0,W.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:[e.id,`@`,e.version]}),e.description?(0,W.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${e.source} source`}),(0,W.jsx)(l9,{label:e.status}),e.tags.map(e=>(0,W.jsx)(l9,{label:e},e))]})]})}function t4e({diagnostics:e,ariaLabel:t}){return e.length?(0,W.jsx)(`div`,{className:`grid gap-2`,"aria-label":t,children:e.map(e=>(0,W.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,W.jsx)(Dl,{size:13}),e.code]}),(0,W.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-amber-200/80`,children:e.path}),(0,W.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function n4e({draft:e,selectedElement:t,nodeIds:n,isSaving:r,onSaveDefinition:i,onDraftDefinitionChange:a}){let o=t?.type===`node`?N7(e.definition)[t.id]:void 0,s=t?.type===`edge`?P7(e.definition)[t.id]:void 0;return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow inspectors`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Workflow inspectors`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Inspector saves update the same Pibo Workflow IR draft as the graph canvas; XState remains projection-only.`})]}),(0,W.jsx)(a4e,{draft:e,isSaving:r,onSaveDefinition:i,onDraftDefinitionChange:a}),t?.type===`node`&&o?(0,W.jsx)(o4e,{draft:e,nodeId:t.id,node:o,isSaving:r,onSaveDefinition:i}):t?.type===`edge`&&s?(0,W.jsx)(u4e,{draft:e,edgeId:t.id,edge:s,nodeIds:n,isSaving:r,onSaveDefinition:i}):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Select a canvas node or edge to open the node or edge inspector. Workflow settings remain editable at all times.`})]})}function r4e(e,t){return e.filter(e=>e.nodeId===t||e.path?.startsWith(`$.nodes.${t}`))}function i4e(e,t){return e.filter(e=>e.edgeId===t||e.path?.startsWith(`$.edges.${t}`))}function a4e({draft:e,isSaving:t,onSaveDefinition:n,onDraftDefinitionChange:r}){let[i,a]=(0,U.useState)(()=>V2e(e.definition));(0,U.useEffect)(()=>{a(V2e(e.definition))},[e.definition]);let o=(t,n)=>{a(i=>{let a={...i,[t]:n};return r?.(x9(e.definition,a)),a})};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:`Workflow settings inspector`}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Workflow title`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:i.title,onChange:e=>o(`title`,e.target.value)})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Workflow description`}),(0,W.jsx)(`textarea`,{className:`min-h-20 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:i.description,onChange:e=>o(`description`,e.target.value)})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(f4e,{label:`Workflow input port`,kind:i.inputKind,description:i.inputDescription,schemaText:i.inputSchemaText,onKindChange:e=>o(`inputKind`,e),onDescriptionChange:e=>o(`inputDescription`,e),onSchemaChange:e=>o(`inputSchemaText`,e)}),(0,W.jsx)(f4e,{label:`Workflow output port`,kind:i.outputKind,description:i.outputDescription,schemaText:i.outputSchemaText,onKindChange:e=>o(`outputKind`,e),onDescriptionChange:e=>o(`outputDescription`,e),onSchemaChange:e=>o(`outputSchemaText`,e)})]}),(0,W.jsx)(m4e,{fields:i.globalStateFields,onAddField:()=>{a(t=>{let n={...t,globalStateFields:[...t.globalStateFields,H2e(t.globalStateFields)]};return r?.(x9(e.definition,n)),n})},onRemoveField:t=>{a(n=>{let i={...n,globalStateFields:n.globalStateFields.filter((e,n)=>n!==t)};return r?.(x9(e.definition,i)),i})},onUpdateField:(t,n,i)=>{a(a=>{let o={...a,globalStateFields:a.globalStateFields.map((e,r)=>r===t?{...e,[n]:i}:e)};return r?.(x9(e.definition,o)),o})}}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(k9,{label:`metadata.tags`,value:i.metadataTags,onChange:e=>o(`metadataTags`,e)}),(0,W.jsx)(k9,{label:`metadata.useWhen`,value:i.metadataUseWhen,onChange:e=>o(`metadataUseWhen`,e)}),(0,W.jsx)(k9,{label:`metadata.notFor`,value:i.metadataNotFor,onChange:e=>o(`metadataNotFor`,e)}),(0,W.jsx)(k9,{label:`metadata.examples`,value:i.metadataExamples,onChange:e=>o(`metadataExamples`,e)})]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{n(x9(e.definition,i),`Saved workflow settings inspector edits to the draft IR.`,{editTrigger:q2e(e.definition,i)?`state_edit`:`schema_edit`})},disabled:t,children:[t?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save workflow settings`]})]})]})}function o4e({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,U.useState)(()=>v0e(n)),[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(),[d,f]=(0,U.useState)(),[p,m]=(0,U.useState)(),[h,g]=(0,U.useState)(),_=F7(n),v=r4e(e.diagnostics,t),y=d?.options.find(e=>e.id===(d?.selectedRefId??a.adapterRef)),b=(0,U.useMemo)(()=>new Set(a.humanActionRefs.map(e=>e.id)),[a.humanActionRefs]);(0,U.useEffect)(()=>{o(v0e(n))},[n,t]),(0,U.useEffect)(()=>{if(_!==`agent`)return;let e=!1;return M3(a.profileId||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.profileId]),(0,U.useEffect)(()=>{if(_!==`code`)return;let e=!1;return Bze(a.handlerId||void 0).then(t=>{e||u(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.handlerId]),(0,U.useEffect)(()=>{if(_!==`adapter`)return;let e=!1;return N3(a.adapterRef||void 0).then(t=>{e||f(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.adapterRef]),(0,U.useEffect)(()=>{if(_!==`workflow`)return;let e=!1,t=Z0e(a.workflowVersionKey);return F3({selectedWorkflowId:t?.workflowId,selectedWorkflowVersion:t?.workflowVersion}).then(t=>{e||m(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.workflowVersionKey]),(0,U.useEffect)(()=>{if(_!==`human`)return;let e=!1;return P3().then(t=>{e||g(t)}).catch(()=>void 0),()=>{e=!0}},[_]);let x=(e,t)=>{o(n=>({...n,[e]:t}))},S=(e,t)=>{o(n=>({...n,humanActionRefs:A0e(n.humanActionRefs,e,t)}))};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Node inspector: `,t]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${_} node`}),(0,W.jsx)(l9,{label:`${v.length} diagnostics`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Node label`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.label,onChange:e=>x(`label`,e.target.value)})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Node description`}),(0,W.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.description,onChange:e=>x(`description`,e.target.value)})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(p4e,{label:`Node input port`,kind:a.inputKind,description:a.inputDescription,schemaText:a.inputSchemaText,onKindChange:e=>x(`inputKind`,e),onDescriptionChange:e=>x(`inputDescription`,e),onSchemaChange:e=>x(`inputSchemaText`,e)}),(0,W.jsx)(p4e,{label:`Node output port`,kind:a.outputKind,description:a.outputDescription,schemaText:a.outputSchemaText,onKindChange:e=>x(`outputKind`,e),onDescriptionChange:e=>x(`outputDescription`,e),onSchemaChange:e=>x(`outputSchemaText`,e)})]}),(0,W.jsx)(s4e,{label:`Node`,definition:e.definition,value:a.stateAccess,onChange:e=>x(`stateAccess`,e)}),_===`agent`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Agent node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Agent profile ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:s?.selectedProfileId??a.profileId,onChange:e=>x(`profileId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a non-archived profile`}),s?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:Q0e(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:s?.diagnostics??[]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Prompt template`}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-slate-100`,value:a.promptTemplate,onChange:e=>x(`promptTemplate`,e.target.value)}),(0,W.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Saving direct prompt text writes `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`promptTemplate`}),` on this Pibo Workflow IR node.`]})]}),(0,W.jsx)(Q2e,{draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i})]}):null,_===`code`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Code node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Registered code handler`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l?.selectedHandlerId??a.handlerId,onChange:e=>x(`handlerId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered handler ref`}),l?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:$0e(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:l?.diagnostics??[]})]}):null,_===`adapter`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Adapter node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Registered adapter ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:d?.selectedRefId??a.adapterRef,onChange:e=>x(`adapterRef`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),d?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:d?.diagnostics??[]}),y?.paramsSchema?(0,W.jsx)(A9,{label:`Adapter params JSON`,schema:y.paramsSchema,value:a.adapterParamsText,onChange:e=>x(`adapterParamsText`,e)}):null,(0,W.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-500`,children:`Adapter nodes store only a registered deterministic adapter ref. Inline transformation code and hidden LLM coercion are not exposed by the UI.`})]}):null,_===`workflow`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Nested workflow ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:p?.selectedWorkflowId&&p.selectedWorkflowVersion?X0e(p.selectedWorkflowId,p.selectedWorkflowVersion):a.workflowVersionKey,onChange:e=>x(`workflowVersionKey`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a published workflow version`}),p?.options.map(e=>(0,W.jsx)(`option`,{value:c9(e),children:t2e(e)},c9(e)))]})]}),(0,W.jsx)(t4e,{diagnostics:p?.diagnostics??[],ariaLabel:`Workflow node diagnostics`})]}):null,_===`human`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Human node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Human prompt`}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:a.humanPrompt,onChange:e=>x(`humanPrompt`,e.target.value)})]}),(0,W.jsx)(O9,{label:`Human node resume payload schema JSON`,value:a.humanSchemaText,onChange:e=>x(`humanSchemaText`,e)}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Human action choices`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered action choices`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Actions are selected from the Workflow Registry. The label, action kind, and payload requirements come from picker metadata.`})]}),h?.options.length?h.options.map(e=>(0,W.jsxs)(`label`,{className:`grid gap-1 rounded-sm border border-slate-800 bg-[#101d22] p-2 text-slate-300`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-semibold`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#11a4d4]`,checked:b.has(e.id),onChange:t=>S(e,t.target.checked)}),(0,W.jsx)(`span`,{children:e.displayName}),(0,W.jsx)(l9,{label:`kind: ${e.kind??`registered`}`})]}),(0,W.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:e.description??e.id}),(0,W.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Payload requirements: `,e.paramsSchema?JSON.stringify(e.paramsSchema):`none`]})]},e.id)):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No registered human actions are available from the picker.`}),(0,W.jsx)(T9,{diagnostics:h?.diagnostics??[]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,"aria-label":`Selected human action refs`,children:a.humanActionRefs.length?a.humanActionRefs.map(e=>(0,W.jsx)(l9,{label:`${e.id}${e.kind?` (${e.kind})`:``}`},`${e.id}:${e.kind??``}`)):(0,W.jsx)(`span`,{className:`text-slate-500`,children:`No human action refs selected.`})})]}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 md:grid-cols-[1fr_1fr]`,"aria-label":`Human node timeout`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Timeout kind`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.humanTimeoutKind,onChange:e=>x(`humanTimeoutKind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`No timeout`}),(0,W.jsx)(`option`,{value:`milliseconds`,children:`Milliseconds`}),(0,W.jsx)(`option`,{value:`seconds`,children:`Seconds`}),(0,W.jsx)(`option`,{value:`minutes`,children:`Minutes`}),(0,W.jsx)(`option`,{value:`iso8601`,children:`ISO-8601 duration`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Timeout value`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,type:a.humanTimeoutKind===`iso8601`?`text`:`number`,min:a.humanTimeoutKind===`iso8601`?void 0:1,placeholder:a.humanTimeoutKind===`iso8601`?`PT1H`:`60`,value:a.humanTimeoutValue,onChange:e=>x(`humanTimeoutValue`,e.target.value),disabled:a.humanTimeoutKind===`none`})]})]})]}):null,(0,W.jsx)(n2e,{diagnostics:v,emptyLabel:`No diagnostics for selected node.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{let r=y0e(e.definition,t,a),o=d0e(n,a)?`state_edit`:_===`agent`||_===`human`?`prompt_edit`:`schema_edit`;i(r,`Saved node inspector edits for ${t}.`,{editTrigger:o})},disabled:r,children:[r?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save node inspector`]})]})]})}function s4e({label:e,definition:t,value:n,onChange:r,allowEdgeWrites:i=!1}){let a=h0e(t,n.readScope,[...n.reads,...n.writes]),o=i?K7:u0e,s=h0e(t,n.writeScope,[...n.reads,...n.writes]),c=!!n.readPath.trim(),l=!!n.writePath.trim()&&(i||n.writeScope!==`edge`),u=(e,t)=>r({...n,[e]:t}),d=e=>{let t=e===`reads`?n.readScope:n.writeScope,i=(e===`reads`?n.readPath:n.writePath).trim();if(!i)return;let a=`${t}.${i}`,o=n[e];o.includes(a)||r({...n,[e]:[...o,a]})},f=(e,t)=>r({...n,[e]:n[e].filter(e=>e!==t)});return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,"aria-label":`${e} simple state mapping controls`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[e,` simple state mappings`]}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:[`Add simple scoped state reads and writes as Pibo Workflow IR `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.reads`}),` and `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.writes`}),` arrays. Complex state mapping DSLs remain raw Workflow IR only.`]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Read scope`}),(0,W.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.readScope,onChange:e=>u(`readScope`,e.target.value),children:K7.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(c4e,{label:`Read path`,value:n.readPath,options:a,onChange:e=>u(`readPath`,e)}),(0,W.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`reads`),disabled:!c,children:`Add read`})]}),(0,W.jsx)(l4e,{label:`Reads`,entries:n.reads,onRemove:e=>f(`reads`,e)}),(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Write scope`}),(0,W.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.writeScope,onChange:e=>u(`writeScope`,e.target.value),children:o.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(c4e,{label:`Write path`,value:n.writePath,options:s,onChange:e=>u(`writePath`,e)}),(0,W.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`writes`),disabled:!l,children:`Add write`})]}),(0,W.jsx)(l4e,{label:`Writes`,entries:n.writes,onRemove:e=>f(`writes`,e)}),n.writeScope===`global`&&!g0e(t).length?(0,W.jsx)(`div`,{className:`rounded-sm border border-amber-900/60 bg-amber-950/20 p-2 text-[11px] leading-5 text-amber-100`,children:`Declare global state fields in the workflow settings inspector before selecting global read/write paths.`}):null]})}function c4e({label:e,value:t,options:n,onChange:r}){let i=t&&!n.includes(t)?[t,...n]:n;return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>r(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select path`}),i.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]})}function l4e({label:e,entries:t,onRemove:n}){return(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-semibold text-slate-400`,children:e}),t.length?(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-[11px] text-slate-300 transition hover:border-red-500/60 hover:text-red-100`,onClick:()=>n(e),title:`Remove ${e}`,children:[e,` ×`]},e))}):(0,W.jsxs)(`div`,{className:`text-[11px] text-slate-500`,children:[`No `,e.toLowerCase(),` declared.`]})]})}function u4e({draft:e,edgeId:t,edge:n,nodeIds:r,isSaving:i,onSaveDefinition:a}){let[o,s]=(0,U.useState)(()=>b0e(n,r)),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(),[f,p]=(0,U.useState)(!1),m=i4e(e.diagnostics,t),h=A2e(e.definition,n),g=m.some(e=>e.code===`WorkflowGraphError.incompatibleEdgePorts`),_=c?.options.find(e=>e.id===(c?.selectedRefId??o.guardHandler)),v=u?.options.find(e=>e.id===(u?.selectedRefId??o.adapterRef));(0,U.useEffect)(()=>{s(b0e(n,r))},[n,t,r]),(0,U.useEffect)(()=>{p(!1)},[t]),(0,U.useEffect)(()=>{let e=!1;return Vze(o.guardHandler||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o.guardHandler]),(0,U.useEffect)(()=>{let e=!1;return N3(o.adapterRef||void 0).then(t=>{e||d(t)}).catch(()=>void 0),()=>{e=!0}},[o.adapterRef]);let y=(e,t)=>{s(n=>({...n,[e]:t}))},b=()=>{let r=x0e(e.definition,t,o),i=f0e(n.state,o.stateAccess)?`state_edit`:`edge_edit`;a(r,`Saved edge inspector edits for ${t}.`,{editTrigger:i})};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Edge inspector: `,t]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${o.kind} edge`}),(0,W.jsx)(l9,{label:`${m.length} diagnostics`})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Source node`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourceNodeId,onChange:e=>y(`sourceNodeId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select source`}),r.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Target node`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetNodeId,onChange:e=>y(`targetNodeId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select target`}),r.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Source port id`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourcePortId,onChange:e=>y(`sourcePortId`,e.target.value),placeholder:`default`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Target port id`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetPortId,onChange:e=>y(`targetPortId`,e.target.value),placeholder:`default`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Edge kind`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.kind,onChange:e=>y(`kind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`data`,children:`data`}),(0,W.jsx)(`option`,{value:`control`,children:`control`}),(0,W.jsx)(`option`,{value:`error`,children:`error`}),(0,W.jsx)(`option`,{value:`resume`,children:`resume`})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Guard ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:c?.selectedRefId??o.guardHandler,onChange:e=>y(`guardHandler`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`No guard`}),c?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Guard priority`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.guardPriority,onChange:e=>y(`guardPriority`,e.target.value),placeholder:`optional integer`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,W.jsx)(`span`,{children:`Edge adapter ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:u?.selectedRefId??o.adapterRef,onChange:e=>y(`adapterRef`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`No edge adapter`}),u?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]})]}),_?.paramsSchema?(0,W.jsx)(A9,{label:`Guard params JSON`,schema:_.paramsSchema,value:o.guardParamsText,onChange:e=>y(`guardParamsText`,e)}):null,v?.paramsSchema?(0,W.jsx)(A9,{label:`Edge adapter params JSON`,schema:v.paramsSchema,value:o.adapterParamsText,onChange:e=>y(`adapterParamsText`,e)}):null,(0,W.jsx)(s4e,{label:`Edge`,definition:e.definition,value:o.stateAccess,onChange:e=>y(`stateAccess`,e),allowEdgeWrites:!0}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border px-3 py-2 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${g?`border-amber-600/70 text-amber-100 hover:border-amber-400`:`border-slate-700 text-slate-300 hover:border-[#11a4d4]/60 hover:text-slate-100`}`,onClick:()=>p(!0),disabled:i||!h.sourcePort||!h.targetPort,children:[(0,W.jsx)(Pc,{size:13}),g?`Fix incompatible edge with adapter`:`Open compatible edge adapter dialog`]}),f?(0,W.jsx)(d4e,{draft:e,edgeId:t,edge:n,edgePortDetails:h,isSaving:i,onClose:()=>p(!1),onSaveDefinition:a}):null,(0,W.jsx)(T9,{diagnostics:[...c?.diagnostics??[],...u?.diagnostics??[]]}),(0,W.jsx)(n2e,{diagnostics:m,emptyLabel:`No diagnostics for selected edge.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:b,disabled:i||!o.sourceNodeId||!o.targetNodeId,children:[i?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save edge inspector`]})]})]})}function d4e({draft:e,edgeId:t,edge:n,edgePortDetails:r,isSaving:i,onClose:a,onSaveDefinition:o}){let[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(j2e(n)),[d,f]=(0,U.useState)(`loading`),[p,m]=(0,U.useState)();(0,U.useEffect)(()=>{let e=!1;return f(`loading`),m(void 0),N3(l||void 0).then(t=>{e||(c(t),u(e=>e||(t.options[0]?.id??``)),f(`loaded`))}).catch(t=>{e||(m(t instanceof Error?t.message:`Failed to load compatible adapters`),f(`error`))}),()=>{e=!0}},[l]);let h=s?.options.find(e=>e.id===l),g=!!(h&&r.sourcePort&&r.targetPort&&d===`loaded`&&!i),_=async()=>{l&&(await o(M2e(e.definition,t,l),`Applied ${l} as edge adapter for ${t}.`,{editTrigger:`edge_edit`}),a())},v=async()=>{l&&(await o(N2e(e.definition,t,l),`Inserted adapter node for ${t} using ${l}.`,{editTrigger:`graph_edit`}),a())};return(0,W.jsx)(rQ,{title:`Choose a registered adapter for ${t}`,description:`The dialog shows the source output and target input schemas from the Pibo Workflow IR.`,onClose:a,closeLabel:`Close compatible edge adapter dialog`,closeDisabled:i,maxWidthClassName:`max-w-3xl`,children:(0,W.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,W.jsx)(Pc,{size:13}),`Compatible edge adapter dialog`]}),(0,W.jsx)(`p`,{className:`max-w-2xl text-xs leading-5 text-slate-500`,children:`Use a registered adapter as an explicit edge adapter, or insert a visible adapter node between the endpoints.`}),(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsx)(D9,{label:`From schema${r.sourceNodeId?` (${r.sourceNodeId})`:``}`,schema:r.sourcePort??null}),(0,W.jsx)(D9,{label:`To schema${r.targetNodeId?` (${r.targetNodeId})`:``}`,schema:r.targetPort??null})]}),(0,W.jsx)(`div`,{className:`rounded-sm border p-3 text-xs leading-5 ${r.directlyCompatible?`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`:`border-amber-700/70 bg-amber-950/30 text-amber-100`}`,children:r.directlyCompatible?`These ports are directly compatible. An adapter is optional and remains explicit if selected.`:`These ports are not directly compatible. Select a registered adapter instead of hidden LLM coercion or inline transformation code.`}),(0,W.jsxs)(`div`,{className:`grid gap-3 text-xs`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Compatible registered adapter`}),(0,W.jsxs)(`select`,{"aria-label":`Compatible registered adapter`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l,onChange:e=>u(e.target.value),disabled:d===`loading`||d===`error`||i,children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),s?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),d===`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:p??`Failed to load compatible adapters.`}):null,(0,W.jsx)(T9,{diagnostics:s?.diagnostics??[]}),h?(0,W.jsx)(E9,{option:h,badge:`selected adapter`}):null,(0,W.jsxs)(`div`,{className:`grid gap-2`,"aria-label":`Compatible adapter candidates`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Compatible adapter candidates`}),s?.options.map(e=>(0,W.jsx)(E9,{option:e,badge:`compatible adapter`},e.id))]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void _(),disabled:!g,children:[(0,W.jsx)(Pc,{size:13}),`Use as edge adapter`]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void v(),disabled:!g,children:[(0,W.jsx)(al,{size:13}),`Insert adapter node`]})]}),(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Both actions persist Pibo Workflow IR only. Edge adapters store `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`adapter.transform.id`}),`; inserted adapter nodes store a visible deterministic adapter handler ref.`]})]})]})})}function f4e({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,W.jsx)(`option`,{value:`text`,children:`text`}),(0,W.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),placeholder:`Optional port description`})]}),t===`json`?(0,W.jsx)(O9,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function p4e({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`inherit/default`}),(0,W.jsx)(`option`,{value:`text`,children:`text`}),(0,W.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),disabled:t===`none`,placeholder:`Optional port description`})]}),t===`json`?(0,W.jsx)(O9,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function m4e({fields:e,onAddField:t,onRemoveField:n,onUpdateField:r}){return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow global state fields`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Workflow global state fields`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Declare simple global state paths for node and edge state mapping dropdowns. State schema changes run draft validation and may invalidate connected graph diagnostics without blocking draft save.`})]}),e.length?e.map((e,t)=>(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Global state path`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.path,onChange:e=>r(t,`path`,e.target.value),placeholder:`projectGoal`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Merge policy`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.mergeKind,onChange:e=>r(t,`mergeKind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`No merge policy`}),(0,W.jsx)(`option`,{value:`replace`,children:`replace`}),(0,W.jsx)(`option`,{value:`append`,children:`append`}),(0,W.jsx)(`option`,{value:`shallowMerge`,children:`shallowMerge`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.description,onChange:e=>r(t,`description`,e.target.value),placeholder:`Optional state description`})]}),(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(O9,{label:`Global state ${e.path||t+1} schema JSON`,value:e.schemaText,onChange:e=>r(t,`schemaText`,e)})}),(0,W.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-red-500/70 hover:text-red-100`,onClick:()=>n(t),children:`Remove state field`})]},`${t}:${e.path}`)):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No global state fields declared. Local and edge path dropdowns remain available for simple node-local state and edge payload access.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:t,children:[(0,W.jsx)(al,{size:13}),`Add global state field`]})]})}function O9({label:e,value:t,onChange:n}){return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`textarea`,{className:`min-h-36 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:JSON.stringify(G7,null,2),spellCheck:!1,"aria-label":e}),(0,W.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:`Raw JSON Schema subset only. Unsupported keywords return workflow diagnostics; no Zod, AJV, or form-builder schema layer is introduced.`})]})}function k9({label:e,value:t,onChange:n}){return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:`One value per line`})]})}function A9({label:e,schema:t,value:n,onChange:r}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,"aria-label":e,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,W.jsx)(D9,{label:`paramsSchema`,schema:t}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:n,onChange:e=>r(e.target.value),placeholder:`{}`,"aria-label":`${e} value`}),(0,W.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Params save as data on the selected registry ref. No inline code path is created.`})]})}function h4e({open:e,onClose:t,onCreate:n}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(),p=(0,U.useRef)(null);if((0,U.useEffect)(()=>{e&&(i(``),o(!1),c(!1),u(!1),f(void 0))},[e]),!e)return null;let m=a||s?g4e(r):void 0;return(0,W.jsx)(rQ,{title:`Create workflow`,description:`Create a new editable workflow draft.`,onClose:t,initialFocusRef:p,closeLabel:`Cancel workflow creation`,closeDisabled:l,children:(0,W.jsxs)(`form`,{className:`grid gap-4 p-4`,onSubmit:async e=>{if(e.preventDefault(),o(!0),f(void 0),g4e(r)){p.current?.focus();return}u(!0);try{await n(r.trim()),u(!1),t()}catch(e){f(x1(e)),u(!1)}},noValidate:!0,children:[(0,W.jsxs)(`label`,{className:`block text-xs font-semibold text-slate-300`,children:[(0,W.jsxs)(`span`,{children:[`Name `,(0,W.jsx)(`span`,{className:`ml-1 text-[#8bdcf4]`,children:`required`})]}),(0,W.jsx)(`input`,{ref:p,id:`create-workflow-name`,value:r,onChange:e=>{i(e.target.value),f(void 0)},onBlur:()=>c(!0),required:!0,maxLength:160,"aria-invalid":!!m,"aria-describedby":m?`create-workflow-name-help create-workflow-name-error`:`create-workflow-name-help`,className:`mt-1.5 h-9 w-full rounded-sm border border-slate-700 bg-[#0e1116] px-3 text-sm text-slate-100 outline-none focus:border-[#11a4d4] focus:ring-1 focus:ring-[#11a4d4]`}),(0,W.jsx)(`div`,{id:`create-workflow-name-help`,className:`mt-1 text-[11px] text-slate-500`,children:`Maximum 160 characters.`}),m?(0,W.jsx)(`div`,{id:`create-workflow-name-error`,className:`mt-1 text-[11px] text-red-300`,role:`alert`,children:m}):null]}),d?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/30 px-3 py-2 text-xs text-red-200`,role:`alert`,children:d}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-slate-800 pt-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,disabled:l,className:`h-8 rounded-sm border border-slate-700 px-3 text-xs text-slate-300 hover:border-slate-500 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`submit`,disabled:l,className:`inline-flex h-8 items-center gap-2 rounded-sm bg-[#11a4d4] px-3 text-xs font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50`,children:[l?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):null,`Create workflow`]})]})]})})}function g4e(e){let t=e.trim();if(!t)return`Enter a workflow name.`;if(t.length>160)return`Workflow name must be 160 characters or fewer.`}var _4e=`workflow-picker-results`,v4e=e=>`workflow-picker-option-${e}`;function y4e({draftId:e,onNavigateDraft:t}){let[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(`loading`),[v,y]=(0,U.useState)(`idle`),[b,x]=(0,U.useState)(),[S,C]=(0,U.useState)(),[w,T]=(0,U.useState)(),E=(0,U.useRef)(null),D=(0,U.useRef)(null),O=(0,U.useCallback)(async()=>{_(`loading`);try{let e=await Gze();r(e.workflows),_(`loaded`)}catch(e){T(e instanceof Error?e.message:`Failed to load workflows`),_(`error`)}},[]);(0,U.useEffect)(()=>{O()},[O]),(0,U.useEffect)(()=>{if(!e){a(void 0),y(`idle`);return}let t=!1;return s(void 0),y(`loading`),T(void 0),Xze(e).then(e=>{t||(a(e.draft),y(`loaded`))}).catch(e=>{t||(a(void 0),y(`error`),T(e instanceof Error?e.message:`Failed to load workflow draft`))}),()=>{t=!0}},[e]),(0,U.useEffect)(()=>{function e(e){E.current?.contains(e.target)||(d(!1),p(void 0))}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]);let k=(0,U.useMemo)(()=>n.map(S4e),[n]),A=i?.workflowId??o?.workflowId,j=A?k.find(e=>e.workflowId===A):void 0,M=(0,U.useMemo)(()=>{let e=c.trim().toLowerCase().split(/\s+/).filter(Boolean);return!e.length||j?.label===c?k:k.filter(t=>e.every(e=>t.searchText.includes(e)))},[k,c,j]),N=f!==void 0&&f<M.length?f:void 0;(0,U.useEffect)(()=>{j&&!u&&l(j.label)},[u,j]),(0,U.useEffect)(()=>{D.current?.scrollIntoView({block:`nearest`})},[N]);let P=async e=>{if(!e.latestPublishedVersion)throw Error(`This workflow has no draft or published version to open.`);let t=await Kze(e.workflowId,e.latestPublishedVersion),n=new Date().toISOString();a(void 0),s({workflowId:e.workflowId,workflowVersion:e.latestPublishedVersion,title:t.workflow.title||e.label,source:t.workflow.source,draft:{draftId:`readonly_${e.workflowId}_${e.latestPublishedVersion}`,workflowId:e.workflowId,source:`ui`,status:`draft`,versionIntent:`patch`,definition:t.definition,diagnostics:t.diagnostics,validationState:t.validation.validationState,validation:t.validation,revision:0,createdAt:n,updatedAt:n}})},F=async e=>{x(`select`),d(!1),p(void 0),C(void 0),T(void 0);try{if(e.activeDraftId){s(void 0),t(e.activeDraftId);return}await P(e),C(`Opened ${e.label} as read-only.`)}catch(e){T(e instanceof Error?e.message:`Failed to select workflow`)}finally{x(void 0)}},ee=async e=>{x(`new`),C(void 0),T(void 0);try{let n=await Yze({title:e});s(void 0),C(`Created workflow ${n.draft.workflowId}.`),await O(),t(n.draft.draftId)}finally{x(void 0)}},I=async()=>{if(o){x(`duplicate`),C(void 0),T(void 0);try{let e=await Qze(o.workflowId,{version:o.workflowVersion});s(void 0),C(`Duplicated ${o.title}.`),await O(),t(e.draft.draftId)}catch(e){T(e instanceof Error?e.message:`Failed to duplicate workflow`)}finally{x(void 0)}}},L=async()=>{if(i){x(`save`),C(void 0),T(void 0);try{let e=await I3(i.draftId,{definition:i.definition,editTrigger:`graph_edit`});a(e.draft),C(e.message??`Saved ${i.workflowId}.`),await O()}catch(e){T(e instanceof Error?e.message:`Failed to save workflow`)}finally{x(void 0)}}},R=e=>{if(e.key===`Escape`&&u){e.preventDefault(),d(!1),p(void 0);return}if(e.key===`Enter`&&u&&N!==void 0&&!b){e.preventDefault(),F(M[N]);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),d(!0),!M.length){p(void 0);return}p(t=>{let n=t!==void 0&&t<M.length?t:void 0;return n===void 0?e.key===`ArrowDown`?0:M.length-1:e.key===`ArrowDown`?(n+1)%M.length:(n-1+M.length)%M.length})}},te=(0,U.useCallback)(e=>{a(t=>t&&{...t,definition:e})},[]),z=(0,U.useCallback)(e=>{a(e),O()},[O]),ne=(0,U.useCallback)((e,t=`status`)=>{if(t===`error`){T(e);return}T(void 0),C(e)},[]),re=g===`loading`||v===`loading`,ie=j?.label??o?.title??(i?i.workflowId:`No workflow selected`),B=i??o?.draft,ae=w??(b?b4e(b):re?`Loading workflow surface…`:S??`Ready`),oe=w?`error`:b||re?`busy`:`status`;return(0,W.jsxs)(`main`,{className:`@container flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#101d22] text-slate-200`,"aria-label":`Workflows`,children:[(0,W.jsx)(h4e,{open:m,onClose:()=>h(!1),onCreate:ee}),(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 flex-wrap items-center gap-2 border-b border-slate-800 bg-[#151f24] px-3 py-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-sm border border-[#11a4d4]/60 text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>h(!0),disabled:!!b,title:`Create workflow`,"aria-label":`Create workflow`,children:b===`new`?(0,W.jsx)(Rc,{size:15,className:`animate-spin`}):(0,W.jsx)(al,{size:15})}),(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-64`,ref:E,children:[(0,W.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-2 rounded-sm border border-slate-700 bg-[#101d22] px-2 focus-within:border-[#11a4d4]`,children:[(0,W.jsx)(ml,{size:14,className:`shrink-0 text-slate-500`}),(0,W.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-sm text-slate-100 outline-none placeholder:text-slate-600`,value:c,onFocus:()=>{d(!0);let e=M.findIndex(e=>e.workflowId===A);p(e>=0?e:void 0)},onChange:e=>{l(e.target.value),d(!0),p(void 0)},onKeyDown:R,placeholder:`Search workflows by name, id, tag, status…`,"aria-label":`Search workflows`,role:`combobox`,"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-expanded":u,"aria-controls":_4e,"aria-activedescendant":u&&N!==void 0?v4e(N):void 0})]}),u?(0,W.jsxs)(`div`,{id:_4e,className:`absolute left-0 right-0 top-full z-40 mt-1 max-h-80 overflow-auto rounded-sm border border-slate-700 bg-[#151f24] p-1 shadow-2xl`,role:`listbox`,"aria-label":`Workflow results`,children:[g===`loading`?(0,W.jsx)(T4e,{children:`Loading workflows…`}):null,g===`loaded`&&M.length===0?(0,W.jsx)(T4e,{children:`No workflows match this search.`}):null,M.map((e,t)=>(0,W.jsxs)(`button`,{id:v4e(t),ref:t===N?D:null,type:`button`,className:`flex w-full items-start justify-between gap-3 rounded-sm px-3 py-2 text-left text-xs transition hover:bg-slate-800/80 ${t===N||N===void 0&&A===e.workflowId?`bg-[#11a4d4]/10 text-[#8bdcf4]`:`text-slate-300`}`,onClick:()=>void F(e),onFocus:()=>p(t),onPointerMove:()=>p(t),disabled:!!b,role:`option`,"aria-selected":N===void 0?A===e.workflowId:t===N,children:[(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate font-semibold`,children:e.label}),(0,W.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-slate-500`,children:e.description})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${e.activeDraftId?`border-emerald-700/60 text-emerald-300`:`border-amber-700/60 text-amber-300`}`,children:e.activeDraftId?`draft`:`read only`})]},e.workflowId))]}):null]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-sm border border-emerald-700/70 px-3 text-xs font-semibold uppercase tracking-wide text-emerald-200 transition hover:border-emerald-400 hover:text-emerald-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void L(),disabled:!i||!!b,children:[b===`save`?(0,W.jsx)(Rc,{size:14,className:`animate-spin`}):(0,W.jsx)(fl,{size:14}),`Save`]})]}),o?(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-amber-700/50 bg-amber-950/20 px-3 py-1.5 text-xs text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 truncate`,children:[(0,W.jsx)(`span`,{className:`mr-2 rounded-sm border border-amber-500/60 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-200`,children:`Read only`}),o.title,` · `,o.workflowId,`@`,o.workflowVersion]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-2 rounded-sm border border-amber-500/60 px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-amber-100 hover:border-amber-300 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void I(),disabled:!!b,children:[b===`duplicate`?(0,W.jsx)(Rc,{size:12,className:`animate-spin`}):(0,W.jsx)(cc,{size:12}),`Duplicate`]})]}):null,(0,W.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden p-3`,children:B?(0,W.jsx)(a2e,{draft:B,onDraftChange:o?()=>void 0:z,fullHeight:!0,compactHeader:!0,readOnly:!!o,onDraftDefinitionChange:o?void 0:te,onStatusMessage:o?void 0:ne,renderInspectors:e=>o?(0,W.jsx)(w4e,{...e}):(0,W.jsx)(n4e,{...e})}):(0,W.jsx)(`div`,{className:`grid h-full min-w-0 place-items-center rounded-sm border border-dashed border-slate-700 bg-[#151f24]/50 p-6 text-center`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-lg font-bold text-slate-100`,children:ie}),(0,W.jsx)(`p`,{className:`mt-2 max-w-xl text-sm leading-6 text-slate-500`,children:`Create a workflow with the plus button or search and select an existing workflow above. Published and built-in workflows open read-only and can be duplicated before editing.`})]})})}),(0,W.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 border-t px-3 text-[11px] ${x4e(oe)}`,role:w?`alert`:`status`,"aria-label":`Workflow editor status`,children:[(0,W.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${oe===`error`?`bg-red-400`:oe===`busy`?`animate-pulse bg-[#11a4d4]`:`bg-emerald-400`}`}),(0,W.jsx)(`span`,{className:`shrink-0 font-bold uppercase tracking-[0.16em]`,children:`Status`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px]`,children:ae})]})]})}function b4e(e){return e===`new`?`Creating workflow…`:e===`select`?`Opening workflow…`:e===`duplicate`?`Duplicating workflow…`:`Saving workflow…`}function x4e(e){return e===`error`?`border-red-900/70 bg-red-950/30 text-red-200`:e===`busy`?`border-slate-800 bg-[#0f1b20] text-[#8bdcf4]`:`border-slate-800 bg-[#0f1b20] text-slate-400`}function S4e(e){let t=C4e(e.versions),n=e.tags.join(`, `),r=[e.id,e.status,e.source,n].filter(Boolean),i=[e.id,e.title,e.description,e.status,e.source,n,t?.version].filter(e=>!!e);return{workflowId:e.id,label:e.title||e.id,description:r.join(` · `),...e.activeDraftId?{activeDraftId:e.activeDraftId}:{},...t?{latestPublishedVersion:t.version}:{},searchText:i.join(` `).toLowerCase()}}function C4e(e){return[...e].reverse().find(e=>e.status===`published`)}function w4e({draft:e,selectedElement:t}){let n=N7(e.definition),r=P7(e.definition),i=t?.type===`node`?n[t.id]:t?.type===`edge`?r[t.id]:e.definition,a=t?`${t.type} ${t.id}`:`Workflow definition`;return(0,W.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Read-only workflow details`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Read-only details`}),(0,W.jsx)(`div`,{className:`mt-2 truncate text-xs font-semibold text-slate-200`,children:a}),(0,W.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-sm border border-slate-800 bg-[#0c171c] p-2 text-[11px] leading-5 text-slate-300`,children:JSON.stringify(i??{},null,2)})]})}function T4e({children:e}){return(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-500`,children:e})}function E4e(e){return e.viewWorkflowId&&e.viewWorkflowVersion?{workflowId:e.viewWorkflowId,workflowVersion:e.viewWorkflowVersion}:void 0}function D4e({workflowId:e,workflowVersion:t,surface:n=`desktop`}){return(0,W.jsx)(`main`,{className:`h-full min-h-0 overflow-auto bg-[#101d22] p-6 max-[720px]:p-4`,"data-pibo-debug":`${n}-workflow-version-viewer`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-4xl`,children:(0,W.jsx)($2e,{workflowId:e,workflowVersion:t})})})}function O4e({route:e,surface:t,fallback:n}){let r=E4e(e);return r?(0,W.jsx)(D4e,{...r,surface:t}):n}var k4e=50,A4e=6e4,j4e=[`.vs`,`.vs-dark`,`.hc-black`,`.hc-light`];function M4e(e){return!!(e?.querySelector(`.monaco-workbench`)&&j4e.some(t=>e.querySelector(t)))}function N4e(e,t,n=`http://localhost/`){let r=new URL(e,n);if(r.origin!==new URL(n).origin)throw Error(`VS Code Web URL must use the Pibo Chat origin.`);return t?r.searchParams.set(`folder`,t):r.searchParams.delete(`folder`),`${r.pathname}${r.search}${r.hash}`}function P4e({integration:e}){let[t,n]=(0,U.useState)(`checking`),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(0),l=(0,U.useRef)(null),u=(0,U.useRef)(null),d=(0,U.useMemo)(()=>e?N4e(e.url,e.workspaceRoot||void 0,window.location.href):``,[e?.url,e?.workspaceRoot]);return(0,U.useEffect)(()=>{if(!d){n(`unavailable`),i(`VS Code Web is not configured for this Pibo gateway.`);return}let e=new URL(d,window.location.href),t=new AbortController;return n(`checking`),i(null),fetch(e.toString(),{method:`GET`,credentials:`same-origin`,cache:`no-store`,headers:{accept:`text/html`},signal:t.signal}).then(e=>{let t=e.headers.get(`content-type`)??``;if(!e.ok||!t.toLowerCase().includes(`text/html`))throw Error(`VS Code Web returned HTTP ${e.status}.`);n(`ready`)}).catch(e=>{t.signal.aborted||(n(`unavailable`),i(e instanceof Error?e.message:String(e)))}),()=>t.abort()},[d,s]),(0,U.useEffect)(()=>(o(!1),u.current!==null&&(window.clearTimeout(u.current),u.current=null),()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)}),[d]),e?(0,W.jsx)(`main`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#101d22]`,"aria-label":`VS Code Web`,children:(0,W.jsx)(`div`,{className:`relative min-h-0 flex-1 bg-[#101d22]`,children:t===`ready`?(0,W.jsxs)(W.Fragment,{children:[a?null:(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center bg-[#101d22]`,role:`status`,"aria-live":`polite`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-slate-300`,children:[(0,W.jsx)(cl,{size:16,className:`animate-spin text-[#11a4d4]`}),`Starting VS Code…`]})}),(0,W.jsx)(`iframe`,{ref:l,src:d,title:`VS Code Web`,allow:`clipboard-read; clipboard-write`,onLoad:()=>{u.current!==null&&window.clearTimeout(u.current),o(!1);let e=Date.now(),t=()=>{let r=!1;try{let e=l.current?.contentDocument;r=M4e(e)}catch{r=!1}if(r){u.current=window.setTimeout(()=>{o(!0),u.current=null},100);return}if(Date.now()-e>=A4e){u.current=null,n(`unavailable`),i(`VS Code Web did not finish starting.`);return}u.current=window.setTimeout(t,k4e)};t()},"aria-hidden":!a,tabIndex:a?0:-1,className:`h-full w-full border-0 bg-[#101d22] ${a?`visible`:`invisible`}`},d)]}):t===`checking`?(0,W.jsx)(`div`,{className:`grid h-full place-items-center bg-[#101d22] text-sm text-slate-400`,children:`Connecting to VS Code Web…`}):(0,W.jsx)(`div`,{className:`grid h-full place-items-center p-6`,children:(0,W.jsxs)(`div`,{className:`max-w-lg border border-orange-500/40 bg-orange-500/10 p-5 text-sm text-slate-300 rounded-sm`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold uppercase tracking-wider text-orange-300`,children:[(0,W.jsx)(gl,{size:16}),` VS Code Web is not reachable`]}),(0,W.jsx)(`p`,{className:`mt-3 break-words text-slate-400`,children:r??`The embedded IDE did not respond.`}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>e+1),className:`mt-4 inline-flex items-center gap-2 rounded-sm bg-[#11a4d4] px-3 py-2 text-xs font-bold uppercase tracking-wider text-white`,children:[(0,W.jsx)(cl,{size:14}),` Retry`]})]})})})}):(0,W.jsx)(`main`,{className:`grid min-h-0 place-items-center bg-[#101d22] p-6`,"aria-label":`VS Code Web`,children:(0,W.jsxs)(`div`,{className:`max-w-lg border border-slate-700 bg-[#1a262b] p-5 text-sm text-slate-300 rounded-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-slate-100 font-bold uppercase tracking-wider`,children:[(0,W.jsx)(gl,{size:16,className:`text-orange-400`}),` VS Code Web unavailable`]}),(0,W.jsxs)(`p`,{className:`mt-3 text-slate-400`,children:[`Configure `,(0,W.jsx)(`code`,{className:`text-slate-200`,children:`PIBO_VSCODE_WEB_URL`}),` on the gateway to enable the embedded IDE.`]})]})})}var j9=`Delete this session`;function F4e({session:e,confirmText:t,deleting:n,onConfirmTextChange:r,onCancel:i,onDelete:a}){let o=(0,U.useRef)(null);return(0,W.jsx)(rQ,{title:`Delete Session`,description:e.piboSessionId,onClose:i,initialFocusRef:o,closeLabel:`Cancel session deletion`,closeDisabled:n,children:(0,W.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,W.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived session, its child sessions, and their Chat events. This cannot be undone.`}),(0,W.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-red-200`,children:j9}),` to confirm.`]}),(0,W.jsx)(`input`,{ref:o,value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:j9}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==j9,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,W.jsx)(El,{size:14}),`Delete permanently`]})]})]})})}function I4e({room:e,confirmName:t,deleting:n,onConfirmNameChange:r,onCancel:i,onDelete:a}){let o=(0,U.useRef)(null);return(0,W.jsx)(rQ,{title:`Delete Room`,description:e.id,onClose:i,initialFocusRef:o,closeLabel:`Cancel room deletion`,closeDisabled:n,children:(0,W.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,W.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived room, child rooms, all contained sessions, subagent sessions, and their Chat events. This cannot be undone.`}),(0,W.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-red-200`,children:e.name}),` to confirm.`]}),(0,W.jsx)(`input`,{ref:o,value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:e.name}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==e.name,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,W.jsx)(El,{size:14}),`Delete permanently`]})]})]})})}function L4e(e,t){return P9(e,e=>Y4e(t.sessions[e]))}function R4e(e,t){return P9(e,e=>X4e(t.sessions[e]))}function M9(e,t){return!!e?.sessions[t]}function z4e(e,t){return M9(e,t)?e:null}function B4e(e,t,n){if(!M9(e,t))return!0;let r=e.sessions[t];return r.isTreeActive||r.latestTurn?.state===`running`||n===`running`}function V4e(e,t,n){return M9(t,n)?e?.rootPiboSessionId!==t.rootPiboSessionId||e.version<=t.version:!1}function H4e(e,t,n){if(!M9(e,n))return{snapshot:e,needsRefresh:!0};let r=Z4e(e,t);return{snapshot:r,needsRefresh:r===e}}function U4e(e,t){let n=new Map(t.sessionSnapshots.map(e=>[e.piboSessionId,Y4e(e)]));return P9(e,e=>n.get(e))}function W4e(e,t){let n=new Map(t.sessionStatuses.map(e=>[e.piboSessionId,X4e(e)]));return P9(e,e=>n.get(e))}function N9(e,t){if(!e)return!0;let n=Date.parse(e.generatedAt),r=Date.parse(t.generatedAt);return Number.isFinite(n)&&Number.isFinite(r)?n<=r:Object.entries(e.rootVersions).every(([e,n])=>(t.rootVersions[e]??-1)>=n)}function G4e(e,t){if(!e||(e.rootVersions[t.rootPiboSessionId]??0)!==t.fromVersion)return{snapshot:e,needsRefresh:!0};let n={...e.sessions};for(let e of t.sessionStatuses)n[e.piboSessionId]=e;return{snapshot:{...e,generatedAt:t.generatedAt,rootVersions:{...e.rootVersions,[t.rootPiboSessionId]:t.toVersion},sessions:n},needsRefresh:!1}}function P9(e,t){return{...e,sessions:e.sessions.map(e=>K4e(e,t))}}function K4e(e,t){let n=t(e.piboSessionId),r=J4e(n,q4e(e)),i=r&&r!==e.status?I9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):I9(e.lastActivityAt,n?.updatedAt);return{...e,status:r??e.status,lastActivityAt:i,children:e.children.map(e=>K4e(e,t)),derivedSessions:e.derivedSessions.map(e=>{let n=t(e.piboSessionId),r=J4e(n,0),i=!!(r&&r!==e.status);return{...e,status:r??e.status,lastActivityAt:i?I9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):I9(e.lastActivityAt,n?.updatedAt)}})}}function q4e(e){return(e.unreadCount??0)+e.children.reduce((e,t)=>e+q4e(t),0)}function J4e(e,t){return e?.isTreeActive?`running`:e?.status===`error`?t>0?`error`:`idle`:e?.status}function Y4e(e){let t=F9(e);if(!(!e&&!t))return{status:t,updatedAt:e?.updatedAt,isTreeActive:e?.isTreeActive}}function X4e(e){return e?{status:e.status,updatedAt:e.updatedAt,isTreeActive:e.isTreeActive}:void 0}function F9(e){return e?f3(e).status:void 0}function I9(...e){let t,n=-1/0;for(let r of e){if(!r)continue;let e=Date.parse(r);!Number.isFinite(e)||e<n||(t=r,n=e)}return t}function Z4e(e,t){if(!e||e.rootPiboSessionId!==t.rootPiboSessionId||e.version!==t.fromVersion)return e;let n={...e.nodes};for(let e of t.removes)delete n[e];for(let e of t.upserts)n[e.id]=e;let r={...e.sessions};for(let e of t.sessionSnapshots)r[e.piboSessionId]=e;return{...e,version:t.toVersion,generatedAt:t.generatedAt,nodes:n,sessions:r}}function Q4e(e,t,n={}){let r=n.readSessionId?e3e(e.sessions,n.readSessionId):new Set,i=new Map;L9(e.sessions,i);let a=[...r].reduce((e,t)=>e+(i.get(t)??0),0);return{...e,identity:t.identity,session:t.session,room:t.room,selectedRoomId:t.selectedRoomId,selectedPiboSessionId:t.selectedPiboSessionId,latestRoomStreamId:t.latestRoomStreamId,rooms:r3e(e.rooms,t.rooms,t.selectedRoomId,a),sessions:e.selectedRoomId===t.selectedRoomId?n3e(e.sessions,R9(t.sessions,r,i)):R9(t.sessions,r,i)}}function $4e(e,t,n=e.selectedRoomId){let r=e3e(e.sessions,t),i=new Map;L9(e.sessions,i);let a=[...r].reduce((e,t)=>e+(i.get(t)??0),0);return{...e,selectedRoomId:n,selectedPiboSessionId:t,rooms:r3e(e.rooms,e.rooms,n,a),sessions:R9(e.sessions,r,i)}}function L9(e,t){for(let n of e)t.set(n.piboSessionId,n.unreadCount??0),L9(n.children,t)}function e3e(e,t){let n=new Set,r=e=>e.piboSessionId===t?(t3e(e,n),!0):e.children.some(e=>r(e));for(let t of e)r(t);return n}function t3e(e,t){t.add(e.piboSessionId);for(let n of e.children)t3e(n,t)}function n3e(e,t){let n=e.filter(e=>e.piSessionId===`pending`);if(!n.length)return t;let r=new Set(t.map(e=>e.piboSessionId)),i=n.filter(e=>!r.has(e.piboSessionId));return i.length?[...i,...t]:t}function R9(e,t,n){return e.map(e=>{let r=n.get(e.piboSessionId),i=t.has(e.piboSessionId)?0:e.unreadCount??r??0;return{...e,...i>0?{unreadCount:i}:{unreadCount:void 0},children:R9(e.children,t,n)}})}function r3e(e,t,n,r){let i=new Map;return i3e(e,i),a3e(t,i,n,r).rooms}function i3e(e,t){for(let n of e)t.set(n.id,n.unreadCount??0),i3e(n.children??[],t)}function a3e(e,t,n,r){let i=!1;return{rooms:e.map(e=>{let a=a3e(e.children??[],t,n,r),o=e.id===n||a.selectedRoomFound;i||=o;let s=e.unreadCount??t.get(e.id)??0,c=o&&r>0?Math.max(0,s-r):s;return{...e,...c>0?{unreadCount:c}:{unreadCount:void 0},...e.children?{children:a.rooms}:{}}}),selectedRoomFound:i}}function o3e(e,t){if(!t.length)return e;let n=new Set(e.map(e=>e.piboSessionId)),r=t.filter(e=>!n.has(e.piboSessionId));return r.length?[...e,...r]:e}function s3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,mcpServers:e.agentCatalog.mcpServers.map(e=>e.name===t.name?t:e)}}:e}function c3e(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.piPackages.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,piPackages:f3e([...n,t])}}}function l3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,piPackages:e.agentCatalog.piPackages.filter(e=>e.id!==t)}}:e}function u3e(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.userSkills.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,userSkills:f3e([...n,t])}}}function d3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,userSkills:e.agentCatalog.userSkills.filter(e=>e.id!==t)}}:e}function f3e(e){return e.sort((e,t)=>e.name.localeCompare(t.name))}function p3e(e,t){let n=WUe(e);return{deletedSessionIds:n,selectedSessionDeleted:t?n.has(t):!1,restoreSelectedPiboSessionId:t}}function m3e(e,t,n){return t?e.includes(t):n}function h3e(e,t){return t?void 0:e??void 0}function g3e(e,t,n){let r=eWe(e);return{deletedRoomIds:r,selectedRoomDeleted:t?r.has(t):!1,restoreSelectedRoomId:t,restoreSelectedPiboSessionId:n}}function _3e(e,t){return t===e}function v3e({queryClient:e,bootstrap:t,selectedPiboSessionId:n,selectedRoomId:r,showArchivedRef:i,isSessionsArea:a,loadBootstrap:o,navigateToSelectedSession:s,updateBootstrapCache:c,restoreBootstrapSnapshot:l,setSelectedPiboSessionId:u,setSelectedRoomId:d,setError:f}){let[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(null),[x,S]=(0,U.useState)(``),[C,w]=(0,U.useState)(!1),T=e=>{b(e),S(``)},E=()=>{b(null),S(``)},D=async()=>{if(!y)return;w(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let d=L6(e,t),p=p3e(y,n);p.selectedSessionDeleted&&u(null),c(e=>UUe(e,p.deletedSessionIds));try{let e=m3e((await tu(y.piboSessionId,x)).deletedSessionIds,n,p.selectedSessionDeleted);e&&u(null);let t=await o(h3e(n,e),i.current,r??void 0,{force:!0});a&&s(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),E(),f(null)}catch(e){l(d),p.selectedSessionDeleted&&u(p.restoreSelectedPiboSessionId),f(e instanceof Error?e.message:String(e))}finally{w(!1)}},O=e=>{m(e),g(``)},k=()=>{m(null),g(``)};return{deleteRoomTarget:p,deleteRoomConfirmName:h,deletingRoom:_,setDeleteRoomConfirmName:g,requestRoomDelete:O,cancelRoomDelete:k,permanentlyDeleteRoom:async()=>{if(!p)return;v(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let m=L6(e,t),g=g3e(p,r,n);g.selectedRoomDeleted&&(d(null),u(null)),c(e=>XUe(e,g.deletedRoomIds));try{await $l(p.id,h);for(let e of g.deletedRoomIds)QX(e),lZ(e);_3e(p.id,r)&&(d(null),u(null));let e=await o(void 0,i.current,void 0,{force:!0});a&&s(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),k(),f(null)}catch(e){l(m),g.selectedRoomDeleted&&(d(g.restoreSelectedRoomId),u(g.restoreSelectedPiboSessionId)),f(e instanceof Error?e.message:String(e))}finally{v(!1)}},deleteSessionTarget:y,deleteSessionConfirmText:x,deletingSession:C,setDeleteSessionConfirmText:S,requestSessionDelete:T,cancelSessionDelete:E,permanentlyDeleteSession:D}}function y3e(e){if(e.area!==`sessions`||!e.activeRoomId||e.bootstrapSelectedRoomId!==e.activeRoomId||typeof e.latestRoomStreamId!=`number`||!Number.isFinite(e.latestRoomStreamId)||e.latestRoomStreamId<=0)return null;let t=new URLSearchParams({roomId:e.activeRoomId});return t.set(`mode`,`summary`),t.set(`since`,`${e.latestRoomStreamId}:999999`),`/api/chat/events?${t.toString()}`}var b3e=`pibo.chat.desktopTabs.v1`,x3e=3840;function z9(){return{version:1,tabs:[],activeTabId:null,width:520,collapsed:!1}}function B9(e){if(e.kind===`new-tab`)return`new-tab:${e.instanceId}`;if(e.kind===`session-tool`)return`tool:${e.tool}`;let t=e.route;return t.area===`projects`?t.projectId?`projects:${t.projectId}`:`projects`:t.area===`workflows`?t.draftId?`workflows:draft:${t.draftId}`:t.viewWorkflowId&&t.viewWorkflowVersion?`workflows:view:${t.viewWorkflowId}:${t.viewWorkflowVersion}`:`workflows`:`route:${t.area}`}function V9(e){if(e.kind===`new-tab`)return`New Tab`;if(e.kind===`session-tool`)return e.tool===`preview`?`Preview`:e.tool===`raw-events`?`Raw Events`:e.tool===`web-annotations`?`Annotations`:e.tool===`runtime-requests`?`Runtime Requests`:`Session Inspector`;let t=e.route;return t.area===`vscode`?`VS Code`:t.area===`cron`?`Cron`:t.area===`loops`?`Loops`:t.area===`agents`?`Agent Designer`:t.area===`context`?`Context`:t.area===`settings`?`Settings`:t.area===`projects`?t.projectId?`Project · ${t.projectId}`:`Projects`:t.draftId?`Workflow · ${t.draftId}`:t.viewWorkflowId?`Workflow · ${t.viewWorkflowId}`:`Workflows`}function S3e(e){return e.area===`sessions`?null:{kind:`route`,route:e}}function H9(e,t,n={}){let r=n.now??Date.now(),i=B9(t),a=e.tabs.findIndex(e=>B9(e.target)===i);if(a>=0){let n=e.tabs[a],i=e.tabs.slice();return i[a]={...n,target:t,title:V9(t),lastActivatedAt:r},{...e,tabs:i,activeTabId:n.id,collapsed:!1}}let o=n.id??K3e(),s={id:o,target:t,title:V9(t),createdAt:r,lastActivatedAt:r},c=e.tabs.length>=24?e.tabs.slice(-23):e.tabs;return{...e,tabs:[...c,s],activeTabId:o,collapsed:!1}}function C3e(e,t={}){let n=t.id??K3e();return H9(e,{kind:`new-tab`,instanceId:n},{...t,id:n})}function w3e(e,t,n,r=Date.now()){let i=e.tabs.findIndex(e=>e.id===t&&e.target.kind===`new-tab`);if(i<0)return H9(e,n,{now:r});let a=B9(n);if(e.tabs.find(e=>e.id!==t&&B9(e.target)===a))return H9(E3e(e,t),n,{now:r});let o=e.tabs.slice();return o[i]={...o[i],target:n,title:V9(n),lastActivatedAt:r},{...e,tabs:o,activeTabId:t,collapsed:!1}}function T3e(e,t,n=Date.now()){return e.activeTabId===t&&!e.collapsed||!e.tabs.some(e=>e.id===t)?e:{...e,activeTabId:t,collapsed:!1,tabs:e.tabs.map(e=>e.id===t?{...e,lastActivatedAt:n}:e)}}function E3e(e,t){let n=e.tabs.findIndex(e=>e.id===t);if(n<0)return e;let r=e.tabs.filter(e=>e.id!==t);if(e.activeTabId!==t)return{...e,tabs:r};let i=r[n]??r[n-1]??null;return{...e,tabs:r,activeTabId:i?.id??null,collapsed:r.length?e.collapsed:!1}}function D3e(e,t,n){let r=e.tabs.findIndex(e=>e.id===t);if(r<0||e.tabs.length<2)return e;let i=Math.max(0,Math.min(e.tabs.length-1,n));if(i===r)return e;let a=e.tabs.slice(),[o]=a.splice(r,1);return a.splice(i,0,o),{...e,tabs:a}}function O3e(e,t,n){let r=e.tabs.findIndex(e=>e.id===t);return r<0?e:D3e(e,t,r+n)}function k3e(e,t){return{...e,width:U9(t)}}function U9(e){return Number.isFinite(e)?Math.round(Math.max(360,Math.min(x3e,e))):520}function W9(e){return e.tabs.find(t=>t.id===e.activeTabId)??null}function A3e(e){return e.target.kind===`new-tab`?!1:e.target.kind===`session-tool`?e.target.tool===`preview`:e.target.route.area===`vscode`}function j3e(e,t){let n=W9(e);return n?.target.kind===`route`?n.target.route:t}function M3e(e,t){return e?.target.kind===`route`&&e.target.route.area===`agents`&&e.id!==t}async function N3e(e,t){if(!e||!t)return{allowed:!0};try{return await t(),{allowed:!0}}catch(e){return{allowed:!1,error:e}}}async function P3e({current:e,next:t,sessionsRoute:n,closingTab:r,autosave:i,onCommit:a,onNavigate:o}){let s=W9(e),c=await N3e(!!(r?.target.kind===`route`&&r.target.route.area===`agents`||M3e(s,t.activeTabId)),i);if(!c.allowed)return c;let l=j3e(e,n),u=j3e(t,n);return a(t),JSON.stringify(l)!==JSON.stringify(u)&&o(u),{allowed:!0}}function F3e(e,t,n={}){let r=S3e(t);return r?{...H9(e,r,n),collapsed:e.collapsed}:e}function I3e(e){return JSON.stringify({...e,width:U9(e.width),tabs:e.tabs.slice(0,24),activeTabId:e.tabs.some(t=>t.id===e.activeTabId)?e.activeTabId:null})}function L3e(e){if(!e)return z9();try{let t=JSON.parse(e);if(!G9(t)||t.version!==1||!Array.isArray(t.tabs))return z9();let n=t.tabs.slice(0,24).map(B3e).filter(e=>e!==null),r=[],i=new Set,a=new Map,o=new Map;for(let e of n){let t=B9(e.target),n=a.get(t);if(i.has(e.id)||n){o.set(e.id,n??e.id);continue}r.push(e),i.add(e.id),a.set(t,e.id),o.set(e.id,e.id)}let s=typeof t.activeTabId==`string`?o.get(t.activeTabId):void 0;return{version:1,tabs:r,activeTabId:s&&r.some(e=>e.id===s)?s:r[0]?.id??null,width:U9(typeof t.width==`number`?t.width:520),collapsed:t.collapsed===!0&&r.length>0}}catch{return z9()}}function R3e(e=G3e()){try{return L3e(e?.getItem(b3e))}catch{return z9()}}function z3e(e,t=G3e()){try{t?.setItem(b3e,I3e(e))}catch{}}function B3e(e){if(!G9(e)||typeof e.id!=`string`||!e.id||!V3e(e.target))return null;let t=W3e(e.createdAt)??Date.now();return{id:e.id,target:e.target,title:typeof e.title==`string`&&e.title.trim()?e.title:V9(e.target),createdAt:t,lastActivatedAt:W3e(e.lastActivatedAt)??t}}function V3e(e){return G9(e)?e.kind===`new-tab`?typeof e.instanceId==`string`&&!!e.instanceId:e.kind===`session-tool`?H3e(e.tool):e.kind===`route`&&G9(e.route)&&U3e(e.route):!1}function H3e(e){return e===`preview`||e===`raw-events`||e===`web-annotations`||e===`runtime-requests`||e===`session-inspector`}function U3e(e){return e.area===`vscode`||e.area===`agents`||e.area===`cron`||e.area===`loops`||e.area===`projects`||e.area===`workflows`||e.area===`context`||e.area===`settings`}function W3e(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function G9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function G3e(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function K3e(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`tab-${crypto.randomUUID()}`:`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function q3e(e,t,n,r){let i=e.filter(e=>e.id!==t),a=i.findIndex(e=>e.id===n);return a<0?Math.max(0,i.length):a+ +(r===`after`)}var J3e=[{id:`preview`,label:`Preview`,description:`Live session preview`,icon:Sl,target:{kind:`session-tool`,tool:`preview`}},{id:`raw-events`,label:`Raw Events`,description:`Raw trace and event payloads`,icon:Bs,target:{kind:`session-tool`,tool:`raw-events`}},{id:`web-annotations`,label:`Web Annotations`,description:`Annotations attached to this session`,icon:Wc,target:{kind:`session-tool`,tool:`web-annotations`}},{id:`runtime-requests`,label:`Runtime Requests`,description:`Approvals and runtime input`,icon:Cl,target:{kind:`session-tool`,tool:`runtime-requests`}},{id:`session-inspector`,label:`Session Inspector`,description:`Session, signal, and runtime metadata`,icon:Ic,target:{kind:`session-tool`,tool:`session-inspector`}}];function Y3e(e){return[{id:`sessions`,label:`Sessions`,description:`Focus the fixed Rooms and Sessions navigation`,icon:Mc,sessionsAction:!0},{id:`projects`,label:`Projects`,description:`Project workspaces and project sessions`,icon:bc,target:{kind:`route`,route:{area:`projects`}}},{id:`vscode`,label:`VS Code`,description:`Embedded workspace editor`,icon:sc,target:{kind:`route`,route:{area:`vscode`}}},{id:`workflows`,label:`Workflows`,description:`Workflow definitions and drafts`,icon:Ml,target:{kind:`route`,route:{area:`workflows`}}},{id:`cron`,label:`Cron`,description:`Scheduled jobs`,icon:oc,target:{kind:`route`,route:{area:`cron`}}},{id:`loops`,label:`Loops`,description:`Goal and legacy Ralph loops`,icon:wc,target:{kind:`route`,route:{area:`loops`}}},{id:`agents`,label:`Agent Designer`,description:`Agents, profiles, and capability selection`,icon:Sl,target:{kind:`route`,route:{area:`agents`}}},{id:`context`,label:`Context`,description:`Context files, prompts, and MCP tools`,icon:Bs,target:{kind:`route`,route:{area:`context`}}},{id:`settings`,label:`Settings`,description:`Chat and runtime settings`,icon:vl,target:{kind:`route`,route:{area:`settings`}}},...J3e]}function X3e(e,t){let[n,r]=(0,U.useState)(()=>R3e()),i=(0,U.useMemo)(()=>JSON.stringify(e),[e]);return(0,U.useEffect)(()=>{t&&r(t=>F3e(t,e))},[t,i]),(0,U.useEffect)(()=>{t&&z3e(n)},[t,n]),{state:n,setState:r}}function Z3e({state:e,vscodeEnabled:t,onStateChange:n,onActivate:r,onClose:i,onFocusSessions:a,renderPanel:o,reservedLeftWidth:s,hidden:c=!1,fullscreen:l=!1}){let u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null),p=(0,U.useRef)(new Map),m=(0,U.useRef)(null),[h,g]=(0,U.useState)(null),_=(0,U.useRef)(!1),v=W9(e),y=(0,U.useMemo)(()=>Y3e(t),[t]);(0,U.useLayoutEffect)(()=>{v?.target.kind===`new-tab`&&d.current?.querySelector(`button[data-catalog-entry]`)?.focus()},[v?.id]),(0,U.useEffect)(()=>{e.collapsed||!v||p.current.get(v.id)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[v?.id,e.collapsed]),(0,U.useLayoutEffect)(()=>{_.current&&(_.current=!1,e.activeTabId?p.current.get(e.activeTabId)?.focus():u.current?.focus())},[e.activeTabId,e.tabs.length]);let b=(0,U.useCallback)(async e=>{_.current=!0,await i(e)||(_.current=!1)},[i]),x=e=>{let t=[...d.current?.querySelectorAll(`button[data-catalog-entry]`)??[]],n=t.indexOf(document.activeElement),r=-1;e.key===`ArrowDown`&&(r=n<0?0:(n+1)%t.length),e.key===`ArrowUp`&&(r=n<0?t.length-1:(n-1+t.length)%t.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=t.length-1),r>=0&&(e.preventDefault(),t[r]?.focus())},S=t=>{if(!(!v||v.target.kind!==`new-tab`)){if(t.sessionsAction){a(v);return}t.target&&n(w3e(e,v.id,t.target))}},C=t=>{let n=e.tabs[Math.max(0,Math.min(e.tabs.length-1,t))];n&&p.current.get(n.id)?.focus()},w=(t,i,a)=>{if(t.altKey&&t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){t.preventDefault();let r=t.key===`ArrowLeft`?-1:1;n(O3e(e,i.id,r)),window.setTimeout(()=>p.current.get(i.id)?.focus(),0);return}if(t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`){t.preventDefault(),t.key===`Home`?C(0):t.key===`End`?C(e.tabs.length-1):C((a+(t.key===`ArrowLeft`?-1:1)+e.tabs.length)%e.tabs.length);return}if(t.key===`Delete`){t.preventDefault(),b(i);return}(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(i))},T=t=>{t.preventDefault();let r=t.clientX,i=t.currentTarget.parentElement?.getBoundingClientRect().width??e.width,a=t=>n(k3e(e,i+r-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},E={"--pibo-desktop-tabs-width":`${e.width}px`,width:l?`100%`:e.collapsed?`44px`:`min(${e.width}px, max(0px, calc(100vw - ${s+250}px)))`};return(0,W.jsxs)(`aside`,{"data-pibo-debug":`desktop-tab-sidebar`,"data-pibo-state":l?`preview-fullscreen`:e.collapsed?`collapsed`:`open`,"data-pibo-preview-fullscreen":l?`true`:`false`,"aria-label":`Open workspace tabs`,"aria-hidden":c||void 0,hidden:c,className:`relative min-h-0 shrink-0 bg-[#101d22] ${l?`border-l-0`:`border-l border-slate-700`}`,style:E,children:[(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize workspace tabs`,"aria-orientation":`vertical`,"aria-valuemin":360,"aria-valuemax":x3e,"aria-valuenow":e.width,tabIndex:e.collapsed||l?-1:0,onPointerDown:T,onKeyDown:t=>{(t.key===`ArrowLeft`||t.key===`ArrowRight`)&&(t.preventDefault(),n(k3e(e,(t.currentTarget.parentElement?.getBoundingClientRect().width??e.width)+(t.key===`ArrowLeft`?24:-24))))},className:`absolute inset-y-0 -left-1 z-20 w-2 touch-none cursor-col-resize outline-none hover:bg-[#11a4d4]/35 focus-visible:bg-[#11a4d4]/60 ${e.collapsed||l?`hidden`:``}`}),e.collapsed&&!l?(0,W.jsxs)(`div`,{className:`flex h-full flex-col items-center gap-2 border-l border-slate-800 bg-[#151f24] py-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n({...e,collapsed:!1}),className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#11a4d4]`,title:`Reopen workspace tabs`,"aria-label":`Reopen workspace tabs`,children:(0,W.jsx)(el,{size:15})}),(0,W.jsxs)(`span`,{className:`mt-1 font-mono text-[10px] text-slate-500 [writing-mode:vertical-rl]`,children:[e.tabs.length,` tabs`]})]}):(0,W.jsxs)(`div`,{className:`grid h-full min-h-0 ${l?`grid-rows-[0_minmax(0,1fr)]`:`grid-rows-[40px_minmax(0,1fr)]`}`,children:[(0,W.jsxs)(`div`,{hidden:l,className:`relative flex min-w-0 items-stretch border-b border-slate-800 bg-[#151f24]`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>f.current?.scrollBy({left:-220,behavior:`smooth`}),title:`Scroll tabs left`,"aria-label":`Scroll tabs left`,className:`w-7 shrink-0 border-r border-slate-800 text-slate-500 hover:text-[#11a4d4]`,children:(0,W.jsx)(qs,{size:13,className:`mx-auto`})}),(0,W.jsx)(`div`,{ref:f,role:`tablist`,"aria-label":`Workspace tabs`,onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(null)},className:`flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:e.tabs.map((t,i)=>{let a=t.id===e.activeTabId,o=h?.overTabId===t.id&&h.position===`before`,s=h?.overTabId===t.id&&h.position===`after`;return(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[o?(0,W.jsx)(Q3e,{index:h.toIndex}):null,(0,W.jsxs)(`div`,{draggable:!0,onDragStart:e=>{m.current=t.id,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id)},onDragOver:n=>{n.preventDefault(),n.dataTransfer.dropEffect=`move`;let r=m.current;if(!r||r===t.id)return;let i=n.currentTarget.getBoundingClientRect(),a=n.clientX>=i.left+i.width/2?`after`:`before`,o=q3e(e.tabs,r,t.id,a);g(e=>e?.draggedTabId===r&&e.overTabId===t.id&&e.position===a?e:{draggedTabId:r,overTabId:t.id,position:a,toIndex:o})},onDrop:t=>{t.preventDefault();let r=m.current;r&&h?.draggedTabId===r&&n(D3e(e,r,h.toIndex)),m.current=null,g(null)},onDragEnd:()=>{m.current=null,g(null)},className:`group flex h-10 min-w-[9.5rem] max-w-[13rem] items-center border-r border-slate-800 ${m.current===t.id?`opacity-60`:``} ${a?`bg-[#101d22] text-[#7ddfff]`:`bg-[#151f24] text-slate-400 hover:bg-slate-800/60`}`,children:[(0,W.jsx)(`button`,{ref:e=>{e?p.current.set(t.id,e):p.current.delete(t.id)},id:`desktop-tab-${t.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`desktop-tabpanel-${t.id}`,tabIndex:a?0:-1,onClick:()=>r(t),onKeyDown:e=>w(e,t,i),title:`${t.title}. Alt+Shift+Arrow reorders; Delete closes.`,className:`min-w-0 flex-1 truncate px-2 text-left text-[11px] font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:t.title}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void b(t),title:`Close ${t.title}`,"aria-label":`Close ${t.title}`,className:`mr-1 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-slate-500 opacity-70 hover:bg-slate-700 hover:text-slate-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)(Pl,{size:12})})]}),s?(0,W.jsx)(Q3e,{index:h.toIndex}):null]},t.id)})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>f.current?.scrollBy({left:220,behavior:`smooth`}),title:`Scroll tabs right`,"aria-label":`Scroll tabs right`,className:`w-7 shrink-0 border-l border-slate-800 text-slate-500 hover:text-[#11a4d4]`,children:(0,W.jsx)(Js,{size:13,className:`mx-auto`})}),(0,W.jsx)(`button`,{ref:u,type:`button`,onClick:()=>n(C3e(e)),title:`New Tab`,"aria-label":`New Tab`,className:`w-9 shrink-0 border-l border-slate-800 text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)(al,{size:15,className:`mx-auto`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>n({...e,collapsed:!0}),title:`Collapse workspace tabs`,"aria-label":`Collapse workspace tabs`,className:`w-9 shrink-0 border-l border-slate-800 text-slate-400 hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)($c,{size:15,className:`mx-auto`})})]}),(0,W.jsx)(`div`,{className:`relative min-h-0 overflow-hidden bg-[#101d22] ${l?`row-start-2`:``}`,children:e.tabs.length?e.tabs.map(t=>{let n=t.id===e.activeTabId;return(0,W.jsx)(`section`,{id:`desktop-tabpanel-${t.id}`,role:`tabpanel`,"aria-labelledby":`desktop-tab-${t.id}`,hidden:!n,className:`h-full min-h-0 overflow-hidden`,children:t.target.kind===`new-tab`?(0,W.jsx)($3e,{ref:n?d:void 0,entries:y,onKeyDown:x,onChoose:S}):n||A3e(t)?o(t,n):null},t.id)}):(0,W.jsx)(`div`,{className:`grid h-full place-items-center p-6 text-center`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Zs,{size:22,className:`mx-auto text-slate-600`}),(0,W.jsx)(`div`,{className:`mt-3 text-xs font-bold uppercase tracking-wider text-slate-300`,children:`No workspace tabs`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-slate-500`,children:`Use + to open a product area or a session tool.`})]})})})]})]})}function Q3e({index:e}){return(0,W.jsx)(`span`,{"aria-hidden":`true`,"data-pibo-debug":`desktop-tab-drop-gap`,"data-pibo-insertion-index":e,className:`desktop-tab-drop-gap h-6 w-2 shrink-0 rounded-sm bg-[#11a4d4]/75 motion-reduce:animate-none`})}var $3e=function({ref:e,entries:t,onKeyDown:n,onChoose:r}){return(0,W.jsx)(`div`,{"data-pibo-debug":`desktop-new-tab`,className:`grid h-full min-h-0 place-items-center overflow-auto p-6`,children:(0,W.jsxs)(`div`,{ref:e,role:`navigation`,"aria-label":`New Tab module catalog`,onKeyDown:n,className:`grid w-full max-w-2xl grid-cols-2 gap-1 border border-slate-700 bg-[#1a262b] p-3 max-[1180px]:grid-cols-1`,children:[(0,W.jsxs)(`div`,{className:`col-span-full px-2 pb-2 pt-0.5`,children:[(0,W.jsx)(`h2`,{className:`text-[11px] font-bold uppercase tracking-[0.14em] text-slate-400`,children:`New Tab`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-slate-500`,children:`Open a product area or session tool`})]}),t.map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{"data-catalog-entry":!0,type:`button`,onClick:()=>r(e),className:`flex min-w-0 items-start gap-2 rounded-sm border border-transparent px-2 py-2 text-left hover:border-slate-700 hover:bg-[#101d22] focus-visible:border-[#11a4d4] focus-visible:bg-[#101d22] focus-visible:outline-none`,children:[(0,W.jsx)(t,{size:15,className:`mt-0.5 shrink-0 text-[#11a4d4]`}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate text-xs font-semibold text-slate-200`,children:e.label}),(0,W.jsx)(`span`,{className:`block text-[10px] leading-4 text-slate-500`,children:e.description})]})]},e.id)})]})})};function e6e(e){return e?.target.kind===`session-tool`?e.target.tool:null}function t6e(e,t){return H9(e,t)}function n6e(e,t){return T3e(e,t)}var K9=750,r6e=5e3,i6e=3e4,q9=120,J9=60,a6e=new Set;function Y9(e){return e.trim().replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??`download`}function X9(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function o6e(e){return e.status===`starting`?`Preparing download…`:e.status===`failed`?e.error??`Download failed`:e.totalBytes&&e.totalBytes>0?`${Math.min(100,Math.floor(e.receivedBytes/e.totalBytes*100))}% · ${X9(e.receivedBytes)} of ${X9(e.totalBytes)}`:e.receivedBytes>0?`${X9(e.receivedBytes)} received`:`Waiting for bytes…`}function Z9(e){return e instanceof DOMException&&e.name===`AbortError`}function s6e(e){let t=Number(e.split(`:`,1)[0]);return Number.isFinite(t)?t:void 0}async function c6e(e,t){let n=jPe(t.piboSessionId,t.includeArchived,t.roomId);return await e.removeQueries({queryKey:n,exact:!0}),Ll(t.piboSessionId,t.includeArchived,t.roomId,!!t.markRead,{signal:t.signal})}async function l6e(e,t){return PPe(e,t,()=>Rl(t.piboSessionId,t.includeArchived,t.roomId,{signal:t.signal}))}function u6e({route:e}){let t=jo(),n=On(),r=KJ(),i=!r,a=X3e(e,i),o=NIe(),s=W9(a.state),c=e6e(s),l=s?.target.kind===`route`?s.target.route:void 0,u=i?`sessions`:e.area,d=e.area===`sessions`?e.roomId:void 0,f=e.area===`projects`?e.projectId:void 0,p=e.area===`sessions`||e.area===`projects`||e.area===`context`?e.piboSessionId:void 0,m=e.area===`sessions`||!i&&e.area===`projects`?e.sessionViewId:void 0,h=e.area===`workflows`?e.draftId:void 0,g=e.area===`settings`?e.panel??`general`:`general`,[_,v]=(0,U.useState)(null),y=(0,U.useRef)(null),b=(0,U.useRef)(null),[x,S]=(0,U.useState)(null),C=(0,U.useCallback)(e=>{if(typeof e==`function`){S(t=>{let n=e(t);return y.current=n,n});return}y.current=e,S(e)},[]),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)(null),M=(0,U.useRef)(new Set),[N,P]=(0,U.useState)(Zje),[F,ee]=(0,U.useState)(Qje),[I,L]=(0,U.useState)($je),[R,te]=(0,U.useState)(eMe),[z,ne]=(0,U.useState)(tMe),[re,ie]=(0,U.useState)(rMe),[B,ae]=(0,U.useState)(``),[oe,se]=(0,U.useState)(null),[ce,le]=(0,U.useState)(()=>m??nZ()),[ue,de]=(0,U.useState)(!1),[fe,pe]=(0,U.useState)(!1),[me,he]=(0,U.useState)(``),[ge,_e]=(0,U.useState)(0),[ve,ye]=(0,U.useState)(!1),be=(0,U.useRef)(!1),xe=(0,U.useRef)(null),Se=(0,U.useRef)(!1),[V,Ce]=(0,U.useState)(!1),[we,H]=(0,U.useState)(!1),[Te,Ee]=(0,U.useState)(q9),[De,Oe]=(0,U.useState)(J9),[ke,Ae]=(0,U.useState)(null),[je,Me]=(0,U.useState)(null),[Ne,Pe]=(0,U.useState)(null),[Fe,Ie]=(0,U.useState)(`build-context`),[Le,Re]=(0,U.useState)(null),[ze,Be]=(0,U.useState)(null),[Ve,He]=(0,U.useState)(!1),[Ue,We]=(0,U.useState)(!1),[Ge,Ke]=(0,U.useState)({}),qe=(0,U.useMemo)(()=>Object.fromEntries([`preview`,`raw-events`,`web-annotations`,`runtime-requests`,`session-inspector`].map(e=>[e,t=>{Ke(n=>n[e]===t?n:{...n,[e]:t})}])),[]);(0,U.useEffect)(()=>{(!i||c!==`preview`)&&pe(!1)},[c,i]);let Je=(0,U.useRef)(null),Ye=GJ({isMobileViewport:r,isOpen:Ue,onClose:(0,U.useCallback)(()=>We(!1),[]),triggerRef:Je}),[Xe,Ze]=(0,U.useState)(!1),[Qe,$e]=(0,U.useState)(null),[et,tt]=(0,U.useState)(null),nt=(0,U.useRef)(null),rt=(0,U.useRef)(null),[it,at]=(0,U.useState)(()=>Date.now()),ot=(0,U.useRef)(z),st=(0,U.useRef)(null),ct=(0,U.useRef)(null),lt=(0,U.useRef)(0),ut=(0,U.useRef)(new Map),dt=(0,U.useRef)(null),ft=(0,U.useRef)(0),pt=w??_?.selectedRoomId??null,mt=pt&&_?EY(_.rooms,pt)??_.room:void 0,ht=jAe(_?.rooms??[],pt,_?.room),gt=mt?kY(mt):!1,_t=!!(je&&je===w),vt=b1(x),yt=(0,U.useCallback)(e=>{let t=rt.current,n=t?R4e(e,t):e,r=nt.current;return e.selectedPiboSessionId&&M9(r,e.selectedPiboSessionId)?L4e(n,r):n},[]);(0,U.useEffect)(()=>{ot.current=z},[z]),(0,U.useEffect)(()=>{ct.current=_},[_]),(0,U.useEffect)(()=>{Ee(q9),Oe(J9)},[w,z]),(0,U.useEffect)(()=>{at(Date.now())},[_]);let bt=(0,U.useCallback)(e=>N9(rt.current,e)?(rt.current=e,v(t=>t&&R4e(t,e)),!0):!1,[]),xt=(0,U.useCallback)(e=>{let t=G4e(rt.current,e);return!t.needsRefresh&&(rt.current=t.snapshot,v(t=>t&&W4e(t,e)),!0)},[]);(0,U.useEffect)(()=>{if(u===`sessions`&&vt)return;let e=!0,t,n=new AbortController,r=i=>{e&&(t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,Pu({signal:n.signal}).then(t=>{e&&!n.signal.aborted&&bt(t)}).catch(()=>{n.signal.aborted||r(K9)})},i))},i={onSnapshot:n=>{!e||!N9(rt.current,n)||(t&&=(clearTimeout(t),void 0),bt(n))},onPatch:t=>{e&&!xt(t)&&r(0)},onError:()=>r(K9)},a=()=>void 0,o=()=>{e&&(a(),a=Fu(i))},s=()=>{document.visibilityState===`visible`&&o()};return a=Fu(i),window.addEventListener(`pageshow`,o),document.addEventListener(`visibilitychange`,s),()=>{e=!1,n.abort(),t&&clearTimeout(t),window.removeEventListener(`pageshow`,o),document.removeEventListener(`visibilitychange`,s),a()}},[u,xt,bt,vt]),(0,U.useEffect)(()=>{if(u!==`sessions`||!vt){nt.current=null,tt(null);return}let e=z4e(nt.current,vt);nt.current=e,tt(e);let t=!0,n,r,i=new AbortController,a=e=>{!t||i.signal.aborted||!V4e(nt.current,e,vt)||(nt.current=e,tt(e),v(t=>t&&L4e(t,e)))},o=e=>{t&&(n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,Nu(vt,{signal:i.signal}).then(a).catch(()=>{i.signal.aborted||o(K9)})},e))},s=e=>{t&&(r&&clearTimeout(r),r=setTimeout(()=>{r=void 0,Pu({signal:i.signal}).then(e=>{t&&!i.signal.aborted&&bt(e)}).catch(()=>{i.signal.aborted||s(K9)})},e))},c={onSnapshot:e=>{!t||!V4e(nt.current,e,vt)||(n&&=(clearTimeout(n),void 0),a(e))},onPatch:e=>{if(!t)return;let n=H4e(nt.current,e,vt);if(n.needsRefresh){o(0);return}nt.current=n.snapshot,tt(n.snapshot),v(t=>t&&U4e(t,e))},onStatusSnapshot:e=>{!t||!N9(rt.current,e)||(r&&=(clearTimeout(r),void 0),bt(e))},onStatusPatch:e=>{t&&!xt(e)&&s(0)},onError:()=>{o(K9),s(K9)}},l=()=>void 0,d=()=>{t&&(l(),l=Iu(vt,c),o(0))},f=()=>{document.visibilityState===`visible`&&d()},p=()=>{let e=ct.current?o1(ct.current.sessions,vt):void 0;return B4e(nt.current,vt,e?.status)};l=Iu(vt,c),window.addEventListener(`pageshow`,d),document.addEventListener(`visibilitychange`,f);let m=window.setInterval(()=>{document.visibilityState===`visible`&&p()&&o(0)},r6e);return o(0),()=>{t=!1,i.abort(),n&&clearTimeout(n),r&&clearTimeout(r),window.removeEventListener(`pageshow`,d),document.removeEventListener(`visibilitychange`,f),window.clearInterval(m),l()}},[u,xt,bt,vt]),(0,U.useEffect)(()=>{let e=_?kAe(_.sessions,it):void 0;if(e===void 0)return;let t=setTimeout(()=>at(Date.now()),Math.max(50,e));return()=>clearTimeout(t)},[_,it]),(0,U.useEffect)(()=>{let e=async()=>{try{let e=await fetch(`/health`,{signal:AbortSignal.timeout(3e3)});if(e.ok){let t=await e.json();$e(t.mode===`fallback`?`fallback`:`main`)}else $e(null)}catch{$e(null)}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,U.useEffect)(()=>{if(u!==`sessions`&&u!==`projects`)return;let e=m??nZ();le(t=>t===e?t:e)},[u,m]),(0,U.useEffect)(()=>{Xje(ce)},[ce]),(0,U.useEffect)(()=>{de(!1)},[u]),(0,U.useEffect)(()=>{u===`sessions`&&ce!==`terminal`&&de(!1)},[u,ce]);let St=(0,U.useCallback)(()=>{We(!1),Ze(!1),de(!0)},[]),Ct=(0,U.useCallback)((e,n=!1,r=ce,i={})=>{i.closeMobileSidebar!==!1&&Ye(),bu(t,e,n,r,i.preserveHash===!0,i.preserveSearch===!0)},[Ye,t,ce]),wt=(0,U.useCallback)(e=>{xe.current=e},[]),Tt=(0,U.useCallback)(async({current:e,next:t})=>{if(e.pathname===t.pathname)return!1;if(Se.current)return Se.current=!1,!1;let n=xe.current;if(!n)return!1;try{return await n(),!1}catch(e){return D(`Agent Designer changes were not saved: ${e instanceof Error?e.message:String(e)}`),!0}},[]);ys({disabled:i?s?.target.kind!==`route`||s.target.route.area!==`agents`:u!==`agents`,enableBeforeUnload:!1,shouldBlockFn:Tt});let Et=(0,U.useCallback)((e,t,n=!1,r={})=>{if(!t){Ct({area:`sessions`,...e?{roomId:e}:{}},n,ce,r);return}Ct({area:`sessions`,...e?{roomId:e}:{},piboSessionId:t},n,ce,r)},[Ct,ce]),Dt=(0,U.useCallback)((e,t,n=!1,r={})=>{if(!t){Ct({area:`projects`,...e?{projectId:e}:{}},n,ce,r);return}Ct({area:`projects`,...e?{projectId:e}:{},piboSessionId:t},n,ce,r)},[Ct,ce]),Ot=(0,U.useCallback)(e=>{Ie(`build-context`),Ct({area:`context`,piboSessionId:e})},[Ct]),kt=(0,U.useCallback)(e=>{Re(e),Ie(`context-files`),Ct({area:`context`})},[Ct]),At=(0,U.useCallback)(e=>{Be(e),Ie(`mcp-tools`),Ct({area:`context`})},[Ct]),jt=(0,U.useCallback)(e=>{v(t=>t&&s3e(t,e))},[]),Mt=(0,U.useCallback)(e=>{v(t=>t&&c3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&c3e(t,e))},[n]),Nt=(0,U.useCallback)(e=>{v(t=>t&&l3e(t,e.id)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&l3e(t,e.id))},[n]),Pt=(0,U.useCallback)(e=>{v(t=>t&&u3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&u3e(t,e))},[n]),Ft=(0,U.useCallback)(e=>{v(t=>t&&d3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&d3e(t,e))},[n]),It=(0,U.useCallback)(e=>{let t=JSON.stringify([e.piboSessionId??``,e.includeArchived===!0?`archived`:`active`,e.roomId??``,e.force===!0?`force`:`cached`,j$(n)]);if(e.signal)return l6e(n,e);let r=ut.current.get(t);if(r)return r;let i=l6e(n,e).finally(()=>{ut.current.get(t)===i&&ut.current.delete(t)});return ut.current.set(t,i),i},[n]),Lt=(0,U.useCallback)(async(e,t=ot.current,r,i={})=>{let a=ct.current;if(a&&i.selectSession!==!1&&!i.force){e&&Yl(e).catch(()=>void 0);let n=lt.current+1;lt.current=n;let o=Q4e(a,await It({piboSessionId:e,includeArchived:t,roomId:r,signal:i.signal}),{readSessionId:e});if(n!==lt.current)return o;let s=yt(o);return v(s),C(s.selectedPiboSessionId),T(s.selectedRoomId),s}let o=lt.current+1;lt.current=o;let s=await c6e(n,{piboSessionId:e,includeArchived:t,roomId:r,markRead:i.selectSession!==!1,force:i.force,signal:i.signal});if(o!==lt.current)return s;let c=yt(s);return v(c),i.selectSession!==!1&&C(c.selectedPiboSessionId),T(c.selectedRoomId),c},[yt,n]),Rt=(0,U.useCallback)(async(e,t=ot.current,n,r={})=>{let i=ct.current;if(!i)return Lt(e,t,n,{force:r.force,signal:r.signal});let a=lt.current+1;lt.current=a;let o=Q4e(i,await It({piboSessionId:e,includeArchived:t,roomId:n,force:r.force,signal:r.signal}),{readSessionId:r.readSessionId});if(a!==lt.current)return o;let s=yt(o);return v(s),C(s.selectedPiboSessionId),T(s.selectedRoomId),s},[It,Lt,yt]);(0,U.useEffect)(()=>{if(u!==`sessions`)return;let e=!1,t=!1,n=()=>{e||t||document.hidden||!ct.current||x&&!vt||(t=!0,Rt(vt??void 0,ot.current,pt??void 0,{force:!0}).catch(()=>void 0).finally(()=>{t=!1}))},r=window.setInterval(n,i6e),i=()=>{document.hidden||n()};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,i),()=>{e=!0,window.clearInterval(r),window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,i)}},[pt,u,Rt,vt,x]),(0,U.useEffect)(()=>{let{requestedRoomId:t,requestedPiboSessionId:n}=dWe(e,ZX()),r=(t,n=!0)=>{let r=pWe(e,t);r&&Et(r.selectedRoomId,r.selectedPiboSessionId,n,{preserveHash:!0,preserveSearch:!0})};if(fWe({bootstrap:_,creatingSession:be.current,route:e}))return;let i=_?Rt:Lt,a=()=>{k(null),D(null)},o=e=>{ct.current||k(_We(e)),D(x1(e))};i(n,ot.current,t).then(e=>{r(e),a()}).catch(s=>{if(e.area===`sessions`&&d&&!p&&n){QX(d),i(void 0,ot.current,d).then(e=>{r(e),a()}).catch(o);return}if(mWe(e)||!n&&!t){o(s);return}iMe(),i().then(e=>{r(e),a()}).catch(o)})},[_,Lt,Rt,Et,e.area,p,d]),(0,U.useEffect)(()=>{!w&&!x||Jje({roomId:w??void 0,piboSessionId:x??void 0})},[x,w]),(0,U.useEffect)(()=>{he(x?$X(x):``)},[x]);let zt=(0,U.useCallback)(e=>{he(t=>{let n=typeof e==`function`?e(t):e;return x&&eZ(x,n),n})},[x]),Bt=(0,U.useMemo)(()=>RUe(),[]),Vt=(0,U.useMemo)(()=>I6(ce),[ce]),Ht=(0,U.useMemo)(()=>I6(`terminal`),[]);(0,U.useEffect)(()=>{if(!_?.agents.length)return;let e=_.selectedRoomId;if(je||!e||e.startsWith(`optimistic-room-`))return;let t=i1(_),n=cZ(e),r=n?``:cZ(),i=Q9(_.agents,n||r||t)?.name??Q9(_.agents,t)?.name??_.agents[0].name;ae(i),se(e),n!==i&&uZ(i,e),r&&uZ(``)},[_,je]);let Ut=(0,U.useCallback)(e=>{ae(e);let t=w??ct.current?.selectedRoomId;t&&(se(t),uZ(e,t))},[w]),Wt=(0,U.useCallback)(async e=>{let t=MDe(e),r=!1;try{await Promise.all([n.invalidateQueries({queryKey:N$(e),refetchType:`none`}),n.invalidateQueries({queryKey:P$(e),refetchType:`none`})]),await Promise.all([n.refetchQueries({queryKey:N$(e),type:`active`}),n.refetchQueries({queryKey:P$(e),type:`active`})])}catch(e){throw r=!0,e}finally{NDe(e,t,r)}},[n]),Gt=(0,U.useCallback)(()=>x?Wt(x):Promise.resolve(),[Wt,x]),Kt=(0,U.useCallback)(()=>Rt(x??void 0,ot.current,w??void 0,{force:!0}),[Rt,x,w]),qt=(0,U.useCallback)(async()=>{D(null);let e=x??void 0;await Lt(e,ot.current,w??void 0,{force:!0,selectSession:!1}),e&&await Wt(e)},[Lt,Wt,x,w]),Jt=(0,U.useCallback)(e=>{v(t=>t&&e(t)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&e(t))},[n]),Yt=(0,U.useCallback)((e,t)=>{v(n=>n&&zUe(n,e,t)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},n=>n&&zUe(n,e,t))},[n]),Xt=(0,U.useCallback)(async()=>{lt.current+=1,ut.current.clear(),await Promise.all([n.cancelQueries({queryKey:[`chat`,`bootstrap`]}),NPe(n)])},[n]),Zt=_?.latestRoomStreamId;(0,U.useEffect)(()=>{let e=y3e({area:u,activeRoomId:pt,bootstrapSelectedRoomId:_?.selectedRoomId,latestRoomStreamId:Zt});if(!e||!pt||typeof Zt!=`number`)return;let t,n,r=()=>{x&&!vt||(n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,Rt(vt??void 0,ot.current,pt,{force:!0}).catch(e=>{Z9(e)||D(x1(e))})},900))},i=e=>{let t=Yu(e);if(!t||t.type===`ready`)return;let n=s6e(e.lastEventId),i=n!==void 0&&n<=Zt,a=t.piboSessionId,o=od(t);if(a&&o){let e=rt.current?.sessions[a]?.status??F9(nt.current?.sessions[a])??o,t=new Date().toISOString();Jt(n=>z6(n,a,n=>({...n,status:e,lastActivityAt:t})))}!i&&ed(t)&&r()},a=()=>{n&&clearTimeout(n),n=void 0,t?.close(),t=void 0},o=()=>{a(),t=new EventSource(e),t.addEventListener(`pibo`,i)};return o(),window.addEventListener(`pagehide`,a),window.addEventListener(`pageshow`,o),()=>{window.removeEventListener(`pagehide`,a),window.removeEventListener(`pageshow`,o),a()}},[pt,u,_?.selectedRoomId,Zt,Rt,vt,x,Jt]);let Qt=(0,U.useCallback)((e,t)=>{if(e){v(VUe(e.localBootstrap,t)??null);for(let[r,i]of e.queryData)n.setQueryData(r,VUe(i,t)??void 0)}},[n]),{deleteRoomTarget:$t,deleteRoomConfirmName:en,deletingRoom:tn,setDeleteRoomConfirmName:nn,requestRoomDelete:rn,cancelRoomDelete:an,permanentlyDeleteRoom:on,deleteSessionTarget:sn,deleteSessionConfirmText:cn,deletingSession:ln,setDeleteSessionConfirmText:un,requestSessionDelete:dn,cancelSessionDelete:fn,permanentlyDeleteSession:pn}=v3e({queryClient:n,bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,showArchivedRef:ot,isSessionsArea:u===`sessions`,loadBootstrap:Lt,navigateToSelectedSession:Et,updateBootstrapCache:Jt,restoreBootstrapSnapshot:Qt,setSelectedPiboSessionId:C,setSelectedRoomId:T,setError:D}),mn=Wn({mutationFn:({profile:e,roomId:t})=>ql(e||void 0,t),onMutate:async({profile:e,roomId:t})=>{b.current=null,await Xt();let n=t??_?.selectedRoomId??``,r=y.current,i=`optimistic-session-${c1()}`;return ct.current?.selectedRoomId===n&&C(i),Yt(n,t=>({...HUe(t,tWe(i,e||i1(t))),selectedPiboSessionId:i})),{tempId:i,previousSelectedPiboSessionId:r,originRoomId:n}},onError:(e,t,n)=>{let r=BUe({status:`failure`,currentSelectedPiboSessionId:y.current,tempId:n?.tempId,previousSelectedPiboSessionId:n?.previousSelectedPiboSessionId});b.current=r,n?.originRoomId&&n.tempId&&Yt(n.originRoomId,e=>KUe(e,n.tempId,n.previousSelectedPiboSessionId??null)),C(r.selectedPiboSessionId)},onSuccess:(e,t,n)=>{let r=BUe({status:`success`,currentSelectedPiboSessionId:y.current,tempId:n?.tempId,previousSelectedPiboSessionId:n?.previousSelectedPiboSessionId,createdPiboSessionId:e.session.id});b.current=r,n?.originRoomId&&Yt(n.originRoomId,t=>GUe(t,n.tempId,nWe(e.session))),C(r.selectedPiboSessionId)}}),hn=Wn({mutationFn:({piboSessionId:e,title:t})=>eu(e,{title:t}),onMutate:async({piboSessionId:e,title:t})=>{await Xt();let r=L6(n,_);return Jt(n=>z6(n,e,e=>({...e,title:t||`Untitled Session`}))),{snapshot:r}},onError:(e,t,n)=>Qt(n?.snapshot),onSuccess:({session:e})=>Jt(t=>qUe(t,e))}),gn=Wn({mutationFn:({piboSessionId:e,archived:t})=>eu(e,{archived:t}),onMutate:async({piboSessionId:e,archived:t})=>{await Xt();let r=L6(n,_);return Jt(n=>z6(n,e,e=>({...e,archived:t,unreadCount:t?0:e.unreadCount}))),{snapshot:r}},onError:(e,t,n)=>Qt(n?.snapshot),onSuccess:({session:e})=>Jt(t=>qUe(t,e))}),_n=Wn({mutationFn:({piboSessionId:e,text:t,clientTxnId:n,roomId:r,webAnnotationIds:i,fileAttachmentPaths:a,delivery:o})=>nu(e,t,n,r,i,a,o),onMutate:async({piboSessionId:e})=>{await n.cancelQueries({queryKey:P$(e)}),Jt(t=>z6(t,e,e=>({...e,status:`running`,lastActivityAt:new Date().toISOString()})))},onError:(e,t)=>{Jt(e=>z6(e,t.piboSessionId,e=>({...e,status:`error`})))}}),vn=(0,U.useCallback)(async e=>{if(!(!x||!_||e===i1(_)))try{await eu(x,{profile:e});let t=await Lt(x,ot.current,w??void 0);u===`sessions`&&Et(t.selectedRoomId,t.selectedPiboSessionId),await Wt(x),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},[u,_,Lt,Et,Wt,x,w]),yn=(0,U.useMemo)(()=>lWe(_?.capabilities.actions??[]),[_]),bn=(0,U.useMemo)(()=>uWe(_,x),[_,x]),xn=(0,U.useCallback)(async e=>{let t=w??_?.selectedRoomId;(0,Fl.flushSync)(()=>{C(e),Ae(e),Ye()}),Jt(n=>$4e(n,e,t??n.selectedRoomId)),Et(t,e,!1,{closeMobileSidebar:!1}),Yl(e).catch(()=>void 0),window.setTimeout(()=>{Ae(t=>t===e?null:t)},50),window.setTimeout(()=>{ct.current?.selectedPiboSessionId===e&&Rt(e,ot.current,t,{readSessionId:e}).then(t=>{ct.current?.selectedPiboSessionId===e&&Et(t.selectedRoomId,t.selectedPiboSessionId,!0,{closeMobileSidebar:!1})}).catch(t=>{!Z9(t)&&ct.current?.selectedPiboSessionId===e&&D(x1(t))})},750)},[_?.selectedRoomId,Ye,Rt,Et,w,Jt]),Sn=(0,U.useCallback)(async(e,t={})=>{let n={...t,closeMobileSidebar:!1},r=ZX().sessionsByRoom?.[e],i=ft.current+1;ft.current=i,dt.current?.abort();let a=new AbortController;dt.current=a,(0,Fl.flushSync)(()=>{T(e),C(r??null),se(null),Me(e),Ye()});try{let t=await Rt(r,ot.current,e,{signal:a.signal});if(ft.current!==i||a.signal.aborted)return;Et(t.selectedRoomId,t.selectedPiboSessionId,!1,n)}catch(t){if(Z9(t))return;if(!r)throw t;QX(e),C(null);let o=await Rt(void 0,ot.current,e,{signal:a.signal});if(ft.current!==i||a.signal.aborted)return;Et(o.selectedRoomId,o.selectedPiboSessionId,!1,n)}finally{ft.current===i&&(dt.current===a&&(dt.current=null),Me(t=>t===e?null:t))}},[Ye,Rt,Et]),Cn=(0,U.useCallback)(()=>{let e=!re;if(ie(e),sZ(e),e||!_)return;let t=MAe(_.rooms,pt);t&&Sn(t,{closeMobileSidebar:!1}).catch(e=>{D(e instanceof Error?e.message:String(e))})},[pt,_,Sn,re]),wn=async(e=B)=>{if(ve||gt)return;let t=w??_?.selectedRoomId??``;be.current=!0,ye(!0);try{let n=await mn.mutateAsync({profile:e,roomId:t||void 0}),r=b.current;if(r?.autoRenameCreatedSession&&Pe(n.session.id),r?.navigateToCreatedSession){Et(t||void 0,n.session.id,!1,{closeMobileSidebar:!1});let e=await Lt(n.session.id,ot.current,t||void 0,{force:!0});Et(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1})}D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{b.current=null,be.current=!1,ye(!1)}},Tn=async()=>{let e=!z;if(ne(e),nMe(e),!e){H(!1),D(null);return}H(!0);try{let e=await Rt(x??void 0,!0,w??void 0);u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{H(!1)}},En=async(e,t)=>{try{await hn.mutateAsync({piboSessionId:e,title:t});let n=await Lt(x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&await Wt(n.selectedPiboSessionId),u===`sessions`&&Et(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},Dn=async(e,t)=>{try{await gn.mutateAsync({piboSessionId:e,archived:t});let n=await Lt(t&&!z&&x===e?void 0:x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&Et(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},kn=async()=>{if(Ve)return;He(!0),await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let e=L6(n,_),t=`optimistic-room-${c1()}`,r=QUe(t,`New Chat`);T(t),C(null),se(null),Me(t),Jt(e=>JUe(e,r));try{let e=await Zl({name:`New Chat`});QX(t),lZ(t),Jt(n=>YUe(n,t,e.room)),await Sn(e.room.id,{closeMobileSidebar:!1}),D(null)}catch(n){QX(t),lZ(t),Qt(e),T(w),C(x),D(n instanceof Error?n.message:String(n))}finally{Me(e=>e===t?null:e),He(!1)}},An=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=L6(n,_);Jt(n=>B6(n,e,e=>({...e,...t.name===void 0?{}:{name:t.name},...t.topic===void 0?{}:{topic:t.topic??void 0},...t.workspace===void 0?{}:{workspace:t.workspace??void 0},updatedAt:new Date().toISOString()})));try{let{room:n}=await Ql(e,t);Jt(t=>B6(t,e,()=>n));let r=await Lt(x??void 0,ot.current,e,{force:!0});u===`sessions`&&Et(r.selectedRoomId,r.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){Qt(r),D(e instanceof Error?e.message:String(e))}},jn=async e=>{try{await Xl(e);let t=await Lt(x??void 0,ot.current,w??void 0,{force:!0,selectSession:!1});u===`sessions`&&Et(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},Mn=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=L6(n,_);t&&(ie(!0),sZ(!0)),Jt(n=>B6(n,e,e=>$Ue(e,t)));try{let{room:n}=await Ql(e,{archived:t});Jt(t=>B6(t,e,()=>n));let r=await Lt(x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&Et(r.selectedRoomId,r.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){Qt(r),D(e instanceof Error?e.message:String(e))}},Nn=(0,U.useCallback)(async e=>{if(!x||gt)return!1;let t=e.trim().split(/\s+/)[0],n=yn.find(e=>e.slash===t);if(!n)return!1;if(n.action===`thinking-show`){let e=!N;return P(e),rZ(e),!0}if(n.action===`download`){let n=aWe(e.slice(t.length));if(!n)return D(`Usage: /download <path>`),!0;let r=`${x}:${n}`;if(M.current.has(r))return j(e=>e?.key===r?{...e,duplicateAttempted:!0}:{key:r,path:n,filename:Y9(n),receivedBytes:0,status:`running`,duplicateAttempted:!0}),!0;M.current.add(r),j({key:r,path:n,filename:Y9(n),receivedBytes:0,status:`starting`});try{let e=await Eu(n,{piboSessionId:x,roomId:w??void 0,onStart:e=>j(t=>({...e,key:r,status:`running`,duplicateAttempted:t?.key===r&&t.duplicateAttempted})),onProgress:e=>j(t=>({...e,key:r,status:`running`,duplicateAttempted:t?.key===r&&t.duplicateAttempted}))});j(t=>({...e,key:r,status:`completed`,duplicateAttempted:t?.key===r&&t.duplicateAttempted})),D(null)}catch(e){let t=e instanceof Error?e.message:String(e);j(e=>({key:r,path:n,filename:e?.key===r?e.filename:Y9(n),receivedBytes:e?.key===r?e.receivedBytes:0,totalBytes:e?.key===r?e.totalBytes:void 0,status:`failed`,error:t})),D(t)}finally{M.current.delete(r)}return!0}let r=oWe(n.action,e.slice(t.length).trim()),i=cWe(await iu(x,n.action,r));if((n.action===`session.clone`||n.action===`session.fork`)&&i)await xn(i);else{let e=await Lt(x,ot.current,w??void 0);u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId),await Wt(x)}return!0},[u,Lt,Et,Wt,xn,x,gt,w,N,yn]),Pn=(0,U.useCallback)(async e=>{if(!x||gt)return;let t=sWe(await iu(x,`session.fork`,{entryId:e}));if(t?.result.cancelled)return;if(!t)throw Error(`Unexpected fork action response`);let n=typeof t.result.selectedText==`string`?t.result.selectedText:void 0;n!==void 0&&t.result.piboSessionId&&eZ(t.result.piboSessionId,n),t.result.piboSessionId&&await xn(t.result.piboSessionId),n!==void 0&&(he(n),_e(e=>e+1))},[xn,x,gt]),Fn=(0,U.useCallback)(e=>void xn(e),[xn]),In=(0,U.useCallback)(e=>{if(le(e),u===`projects`){Ct({area:`projects`,...f?{projectId:f}:{},...p?{piboSessionId:p}:{}},!1,e);return}u===`sessions`&&Ct({area:`sessions`,...w?{roomId:w}:{},...x?{piboSessionId:x}:{}},!1,e)},[u,Ct,p,f,x,w]),Ln=(0,U.useMemo)(()=>_?wY(_.sessions,z):{active:[],archived:[]},[_?.sessions,z]),Rn=(0,U.useMemo)(()=>AAe(Ln.active,Te,x),[Ln.active,x,Te]),zn=(0,U.useMemo)(()=>z?Ln.archived.slice(0,De):[],[Ln.archived,z,De]),Bn=Ln.active.length>Rn.length,Vn=z&&Ln.archived.length>zn.length,Hn=(0,U.useMemo)(()=>x?new Set(s1(_?.sessions??[],x).map(e=>e.piboSessionId)):a6e,[_?.sessions,x]),Un=(0,U.useCallback)(async e=>{if(!pt)return;let t=(e?zn:Rn).at(-1)?.piboSessionId;e?H(!0):Ce(!0);try{let r=e?J9:q9,i=await n.fetchQuery({queryKey:IPe(pt,e,t,r),queryFn:()=>Kl({roomId:pt,piboSessionId:x??void 0,archived:e,cursor:t,limit:r}),staleTime:3e4,gcTime:18e5});v(e=>e&&yt({...e,sessions:o3e(e.sessions,i.sessions)})),e?Oe(e=>e+r):Ee(e=>e+r)}finally{e?H(!1):Ce(!1)}},[pt,yt,n,x,Rn,zn]);if(O&&!_)return O.kind===`authentication-required`?(0,W.jsx)(TIe,{message:O.message}):(0,W.jsx)(EIe,{message:O.message,onRetry:()=>window.location.reload()});if(!_)return(0,W.jsx)(`div`,{className:`min-h-screen bg-[#101d22] text-slate-300 grid place-items-center`,children:`Loading Pibo Chat...`});let Gn=x?o1(_.sessions,x):void 0,Kn=x?et?.sessions[x]:void 0,qn=et?.rootPiboSessionId?et.sessions[et.rootPiboSessionId]:void 0,Jn=a1(_,Gn??{profile:i1(_),parentId:_.session?.parentId}),Yn=NAe(_.rooms),Xn=[...new Set([..._.agents.map(e=>e.name),..._.customAgents.map(e=>e.profileName)])],Zn=uFe(_),Qn=ue&&(u===`sessions`||u===`projects`)&&(u===`projects`||ce===`terminal`),$n=i&&fe&&c===`preview`,er=Qn||$n,tr=Qn?`h-full overflow-hidden grid grid-cols-[minmax(0,1fr)]`:u===`vscode`||u===`workflows`||u===`cron`||u===`loops`||u===`agents`||u===`projects`?`h-full overflow-hidden`:`grid ${u===`sessions`&&I?`grid-cols-[300px_minmax(0,1fr)_320px] max-[980px]:grid-cols-1`:`grid-cols-[300px_minmax(0,1fr)] max-[980px]:grid-cols-1`}`,nr=e=>{if(Ze(!1),e===`sessions`){Et(w??_.selectedRoomId,x??_.selectedPiboSessionId);return}if(e===`projects`){Ct({area:`projects`});return}Ct({area:e})},rr={area:`sessions`,...w??_.selectedRoomId?{roomId:w??_.selectedRoomId}:{},...x??_.selectedPiboSessionId?{piboSessionId:x??_.selectedPiboSessionId}:{}},ir=async(e,t={})=>{let n=W9(a.state),r=t.saveClosingTab?.target.kind===`route`&&t.saveClosingTab.target.route.area===`agents`||n?.target.kind===`route`&&n.target.route.area===`agents`&&n.id!==e.activeTabId,i=await P3e({current:a.state,next:e,sessionsRoute:rr,closingTab:t.saveClosingTab,autosave:xe.current,onCommit:a.setState,onNavigate:e=>{r&&(Se.current=!0),Ct(e),r&&window.setTimeout(()=>{Se.current=!1},0)}});return i.allowed?!0:(D(`Agent Designer changes were not saved: ${i.error instanceof Error?i.error.message:String(i.error)}`),!1)},ar=e=>{ir(e)},or=async e=>{let t=t6e(a.state,e);await ir(t)},sr=async e=>{await ir(n6e(a.state,e.id))},cr=async e=>ir(E3e(a.state,e.id),{saveClosingTab:e}),lr=e=>{let t=a.state.tabs.find(t=>t.target.kind===`session-tool`&&t.target.tool===e);t&&cr(t)},ur=async e=>{e&&!await cr(e)||(Et(w??_.selectedRoomId,x??_.selectedPiboSessionId),window.setTimeout(()=>document.querySelector(`[data-pibo-debug="desktop-session-sidebar"] button`)?.focus(),0))},dr=(e,t)=>{if(e.target.kind===`new-tab`)return null;if(e.target.kind===`session-tool`)return(0,W.jsx)(`div`,{ref:qe[e.target.tool],className:`h-full min-h-0 overflow-hidden ${e.target.tool===`preview`?`flex flex-col`:``}`,"data-pibo-debug":`desktop-session-tool-${e.target.tool}`});let n=e.target.route;if(n.area===`vscode`)return(0,W.jsx)(P4e,{integration:_.integrations?.vscode});if(n.area===`cron`)return(0,W.jsx)(YJ,{bootstrap:_,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`loops`)return(0,W.jsx)(MY,{bootstrap:_,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`agents`)return(0,W.jsx)(IX,{agents:_.agents,initialCustomAgents:_.customAgents,initialAgentFolders:_.agentFolders,initialCatalog:_.agentCatalog,modelCatalog:_.modelCatalog,onCreateSession:e=>void wn(e),onEditContextFile:kt,onEditMcpServer:At,onAgentsChanged:()=>void Lt(x??void 0,ot.current,w??void 0,{selectSession:!1}),onAutosaveHandlerChange:wt,creatingSession:ve||gt,mobileSidebarOpen:!1,isMobileSidebarViewport:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`workflows`)return(0,W.jsx)(O4e,{route:n,surface:`desktop`,fallback:(0,W.jsx)(y4e,{draftId:n.draftId,onNavigateDraft:e=>{t&&Ct({area:`workflows`,draftId:e})}})});if(n.area===`projects`)return(0,W.jsx)(oGe,{baseBootstrap:_,routeProjectId:n.projectId,routePiboSessionId:n.piboSessionId,sessionViews:Bt,showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,terminalFullscreen:!1,onEnterTerminalFullscreen:()=>void 0,onExitTerminalFullscreen:()=>void 0,onNavigate:t?Dt:()=>void 0,onViewContext:Ot,onSelectSessionView:e=>Ct({...n,sessionViewId:e},!1,e),onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onThinkingLevelChange:e=>void iu(n.piboSessionId??``,`thinking`,{level:e}),onError:D,surface:`tab`});if(n.area===`context`)return(0,W.jsx)(JJ,{label:`Context`,sidebar:(0,W.jsx)(BJ,{activePanel:Fe,onSelect:Ie,toolCount:_.agentCatalog?.piboTools.length??0,mcpServerCount:_.agentCatalog?.mcpServers.length??0}),contentOverflow:`hidden`,children:Fe===`pibo-tools`?(0,W.jsx)(LK,{tools:_.agentCatalog?.piboTools??[]}):Fe===`mcp-tools`?(0,W.jsx)(BK,{servers:_.agentCatalog?.mcpServers??[],selectedServerName:ze,onServerSaved:jt}):Fe===`build-context`?(0,W.jsx)(MJ,{piboSessionId:n.piboSessionId??x}):Fe===`base-prompt`?(0,W.jsx)(kW,{}):Fe===`compaction-prompt`?(0,W.jsx)(AW,{}):(0,W.jsx)(xW,{agentProfiles:Xn,selectedFileKey:Le})});let r=n.panel??`general`;return(0,W.jsx)(JJ,{label:`Settings`,sidebar:(0,W.jsx)(vWe,{activePanel:r,onSelect:e=>Ct({area:`settings`,panel:e}),piPackageCount:_.agentCatalog?.piPackages.length??0,userSkillCount:_.agentCatalog?.userSkills.length??0}),children:(0,W.jsx)(EWe,{activePanel:r,showThinking:N,setShowThinking:P,expandThinking:F,setExpandThinking:ee,modelDefaults:_.modelDefaults,modelCatalog:_.modelCatalog,onModelDefaultsChanged:e=>v(t=>t&&{...t,modelDefaults:e}),piPackages:_.agentCatalog?.piPackages,onPiPackageChanged:Mt,onPiPackageRemoved:Nt,userSkills:_.agentCatalog?.userSkills,onUserSkillChanged:Pt,onUserSkillRemoved:Ft,piboSessionId:x,onProviderAuthChanged:qt})})};return(0,W.jsxs)(W.Fragment,{children:[Qe===`fallback`&&!er?(0,W.jsx)(SIe,{}):null,(0,W.jsxs)(`div`,{"data-pibo-debug":`chat-app`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??_.selectedPiboSessionId??void 0,"data-pibo-terminal-fullscreen":Qn?`true`:`false`,"data-pibo-preview-fullscreen":$n?`true`:`false`,className:`h-dvh overflow-hidden bg-[#101d22] text-slate-200 grid ${er?`grid-rows-[1fr]`:i?`grid-rows-[auto_1fr]`:`grid-rows-[auto_auto_1fr]`}`,children:[er||i?null:(0,W.jsx)(CIe,{area:u,identity:Zn,mobileAreaMenuOpen:Xe,mobileSidebarTriggerRef:Je,totalRoomUnreadCount:Yn,vscodeEnabled:!!_.integrations?.vscode,showMobileSidebarTrigger:u!==`vscode`,onOpenMobileSidebar:()=>We(!0),onSelectMainNavArea:nr,onToggleMobileAreaMenu:()=>Ze(e=>!e),onCloseMobileAreaMenu:()=>Ze(!1)}),er?null:(0,W.jsxs)(`div`,{children:[E?(0,W.jsx)(wIe,{message:E,onDismiss:()=>D(null)}):null,A?(0,W.jsx)(d6e,{status:A,onDismiss:()=>j(null)}):null]}),i?(0,W.jsxs)(`div`,{"data-pibo-debug":`desktop-route-shell`,"data-pibo-area":l?.area??`sessions`,className:`min-h-0 flex overflow-hidden`,children:[(0,W.jsx)(PIe,{state:o.state,onStateChange:o.setState,identity:Zn,onRefresh:()=>void Lt(x??void 0,ot.current,w??void 0,{force:!0}).then(e=>{x&&Wt(x),Et(e.selectedRoomId,e.selectedPiboSessionId)}),hidden:er,children:(0,W.jsx)(N1,{bootstrap:_,selectedRoomId:w,selectedPiboSessionId:x,showArchivedRooms:re,onToggleArchivedRooms:Cn,creatingRoom:Ve,onCreateRoom:()=>kn(),onSelectRoom:Sn,loadingRoomId:je,roomSessionsLoading:_t,onUpdateRoom:An,onArchiveRoom:Mn,onReadAllRoom:jn,onDeleteRoom:rn,newSessionProfile:B,newSessionProfileReady:oe===(w??_.selectedRoomId),onNewSessionProfileChange:Ut,selectedRoomArchived:gt,creatingSession:ve,onCreateSession:()=>wn(),showArchived:z,onToggleArchivedSessions:Tn,loadingArchivedSessions:we,visibleActiveSessions:Rn,visibleArchivedSessions:zn,totalActiveSessionCount:Ln.active.length,totalArchivedSessionCount:Ln.archived.length,hasMoreActiveSessions:Bn,hasMoreArchivedSessions:Vn,loadingActiveSessions:V,sessionListScrollRef:st,onLoadMoreSessions:Un,signalNow:it,selectedSessionPathIds:Hn,onSelectSession:xn,onRenameSession:En,onArchiveSession:Dn,onDeleteSession:dn,onViewContext:Ot,loadingPiboSessionId:ke,autoRenameSessionId:Ne,onAutoRenameConsumed:()=>Pe(null)})}),(0,W.jsx)(`main`,{"data-pibo-debug":`desktop-session-center`,hidden:$n,"aria-hidden":$n||void 0,className:`min-h-0 min-w-[250px] flex-1 overflow-hidden`,children:(0,W.jsx)(A1,{bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,contextLabel:ht,selectedRoomArchived:gt,roomNavigationPending:_t,sessionNavigationPending:!!(ke&&ke===x),selectedSessionProfile:Gn?.profile??i1(_),selectedSessionActiveModel:Jn,selectedSessionStatus:F9(Kn??qn)??Gn?.status,selectedSessionSignal:Kn,signals:et??void 0,sessionViewId:`terminal`,sessionViews:Bt,currentSessionView:Ht,desktopTerminalOnly:!0,containerResponsive:!0,creatingSession:ve,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,composerText:me,composerFocusSignal:ge,onComposerTextChange:zt,onToggleRawEvents:()=>or({kind:`session-tool`,tool:`raw-events`}),onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onSessionAgentProfileChange:e=>void vn(e),onFork:Pn,onOpenSession:Fn,onSelectSessionView:In,onCommand:Nn,onThinkingLevelChange:e=>void Nn(`/thinking ${e}`),onRefreshTrace:Gt,onRefreshBootstrap:Kt,desktopActiveTool:c,desktopToolHosts:Ge,onOpenDesktopTool:e=>void or({kind:`session-tool`,tool:e}),onCloseDesktopTool:lr,desktopPreviewFullscreen:$n,onEnterDesktopPreviewFullscreen:()=>pe(!0),onExitDesktopPreviewFullscreen:()=>pe(!1),onSend:async(e,t,n,r,i)=>{if(!(l1(x,gt)||!x))try{await _n.mutateAsync({piboSessionId:x,text:e,clientTxnId:r??c1(),roomId:w??void 0,webAnnotationIds:t,fileAttachmentPaths:n,delivery:i}),await Lt(x,ot.current,w??void 0,{force:!0}),D(null)}catch(e){throw D(e instanceof Error?e.message:String(e)),e}},onError:D})}),(0,W.jsx)(Z3e,{state:a.state,vscodeEnabled:!!_.integrations?.vscode,onStateChange:ar,onActivate:e=>void sr(e),onClose:cr,onFocusSessions:e=>void ur(e),renderPanel:(e,t)=>dr(e,t),reservedLeftWidth:o.state.collapsed?44:o.state.width,hidden:Qn,fullscreen:$n}),$t?(0,W.jsx)(I4e,{room:$t,confirmName:en,deleting:tn,onConfirmNameChange:nn,onCancel:an,onDelete:()=>void on()}):null,sn?(0,W.jsx)(F4e,{session:sn,confirmText:cn,deleting:ln,onConfirmTextChange:un,onCancel:fn,onDelete:()=>void pn()}):null]}):(0,W.jsx)(`div`,{"data-pibo-debug":`route-shell`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??void 0,className:`min-h-0 ${tr}`,children:u===`vscode`?(0,W.jsx)(P4e,{integration:_.integrations?.vscode}):u===`cron`?(0,W.jsx)(YJ,{bootstrap:_,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye}):u===`loops`?(0,W.jsx)(MY,{bootstrap:_,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye}):u===`agents`?(0,W.jsx)(IX,{agents:_.agents,initialCustomAgents:_.customAgents,initialAgentFolders:_.agentFolders,initialCatalog:_.agentCatalog,modelCatalog:_.modelCatalog,onCreateSession:e=>void wn(e),onEditContextFile:kt,onEditMcpServer:At,onAgentsChanged:()=>void Lt(x??void 0,ot.current,w??void 0,{selectSession:!1}),onAutosaveHandlerChange:wt,creatingSession:ve||gt,mobileSidebarOpen:Ue,isMobileSidebarViewport:r,onCloseMobileSidebar:Ye}):u===`workflows`?(0,W.jsx)(O4e,{route:e.area===`workflows`?e:{area:`workflows`,draftId:h},surface:`mobile`,fallback:(0,W.jsx)(y4e,{draftId:h,onNavigateDraft:e=>Ct({area:`workflows`,draftId:e})})}):u===`projects`?(0,W.jsx)(oGe,{baseBootstrap:_,routeProjectId:f,routePiboSessionId:p,sessionViews:Bt,showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),onNavigate:Dt,onViewContext:Ot,onSelectSessionView:In,onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onThinkingLevelChange:e=>void iu(p??``,`thinking`,{level:e}),onError:D}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{"data-pibo-mobile-sidebar-backdrop":!0,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/60 min-[981px]:hidden transition-opacity duration-200 ${Qn?`hidden`:Ue?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,onClick:Ye}),(0,W.jsxs)(`aside`,{"data-pibo-mobile-sidebar":!0,...UJ(r,Ue,`Chat sidebar`),"data-pibo-debug":`sidebar-shell`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??void 0,"data-pibo-state":Ue?`open`:`closed`,className:`min-h-0 overflow-hidden flex flex-col bg-[#1a262b] border-r border-slate-800 max-[980px]:fixed max-[980px]:left-0 max-[980px]:top-0 max-[980px]:bottom-0 max-[980px]:z-40 max-[980px]:w-[280px] max-[980px]:transition-transform max-[980px]:duration-200 ${Qn?`hidden`:Ue?`max-[980px]:translate-x-0`:`max-[980px]:-translate-x-full`}`,children:[(0,W.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider max-[980px]:h-auto max-[980px]:py-2 max-[980px]:flex-wrap`,children:[(0,W.jsx)(`span`,{children:u}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u===`sessions`?(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Lt(x??void 0,ot.current,w??void 0,{force:!0}).then(e=>{x&&Wt(x),u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId)}),title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,W.jsx)(cl,{size:13})}):null,(0,W.jsx)(`button`,{type:`button`,onClick:Ye,className:`min-[981px]:hidden p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Close sidebar`,"aria-label":`Close sidebar`,children:(0,W.jsx)(Pl,{size:13})})]})]}),u===`sessions`?(0,W.jsx)(N1,{bootstrap:_,selectedRoomId:w,selectedPiboSessionId:x,showArchivedRooms:re,onToggleArchivedRooms:Cn,creatingRoom:Ve,onCreateRoom:()=>kn(),onSelectRoom:Sn,loadingRoomId:je,roomSessionsLoading:_t,onUpdateRoom:An,onArchiveRoom:Mn,onReadAllRoom:jn,onDeleteRoom:rn,newSessionProfile:B,newSessionProfileReady:oe===(w??_.selectedRoomId),onNewSessionProfileChange:Ut,selectedRoomArchived:gt,creatingSession:ve,onCreateSession:()=>wn(),showArchived:z,onToggleArchivedSessions:Tn,loadingArchivedSessions:we,visibleActiveSessions:Rn,visibleArchivedSessions:zn,totalActiveSessionCount:Ln.active.length,totalArchivedSessionCount:Ln.archived.length,hasMoreActiveSessions:Bn,hasMoreArchivedSessions:Vn,loadingActiveSessions:V,sessionListScrollRef:st,onLoadMoreSessions:Un,signalNow:it,selectedSessionPathIds:Hn,onSelectSession:xn,onRenameSession:En,onArchiveSession:Dn,onDeleteSession:dn,onViewContext:Ot,loadingPiboSessionId:ke,autoRenameSessionId:Ne,onAutoRenameConsumed:()=>Pe(null)}):u===`context`?(0,W.jsx)(BJ,{activePanel:Fe,onSelect:Ie,toolCount:_.agentCatalog?.piboTools.length??0,mcpServerCount:_.agentCatalog?.mcpServers.length??0}):(0,W.jsx)(vWe,{activePanel:g,onSelect:e=>Ct({area:`settings`,panel:e}),piPackageCount:_.agentCatalog?.piPackages.length??0,userSkillCount:_.agentCatalog?.userSkills.length??0})]}),u===`sessions`?(0,W.jsx)(A1,{bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,contextLabel:ht,selectedRoomArchived:gt,roomNavigationPending:_t,sessionNavigationPending:!!(ke&&ke===x),selectedSessionProfile:Gn?.profile??i1(_),selectedSessionActiveModel:Jn,selectedSessionStatus:F9(Kn??qn)??Gn?.status,selectedSessionSignal:Kn,signals:et??void 0,sessionViewId:ce,sessionViews:Bt,currentSessionView:Vt,creatingSession:ve,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,composerText:me,composerFocusSignal:ge,onComposerTextChange:zt,onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onSessionAgentProfileChange:e=>void vn(e),onFork:Pn,onOpenSession:Fn,onSelectSessionView:In,onCommand:Nn,onThinkingLevelChange:e=>void Nn(`/thinking ${e}`),onRefreshTrace:Gt,onRefreshBootstrap:Kt,onSend:async(e,t,n,r,i)=>{if(!(l1(x,gt)||!x))try{await _n.mutateAsync({piboSessionId:x,text:e,clientTxnId:r??c1(),roomId:w??void 0,webAnnotationIds:t,fileAttachmentPaths:n,delivery:i}),await Lt(x,ot.current,w??void 0,{force:!0}),D(null)}catch(e){throw D(e instanceof Error?e.message:String(e)),e}},onError:D}):(0,W.jsx)(`main`,{className:`min-h-0 flex flex-col`,children:u===`context`?Fe===`pibo-tools`?(0,W.jsx)(LK,{tools:_.agentCatalog?.piboTools??[]}):Fe===`mcp-tools`?(0,W.jsx)(BK,{servers:_.agentCatalog?.mcpServers??[],selectedServerName:ze,onServerSaved:jt}):Fe===`build-context`?(0,W.jsx)(MJ,{piboSessionId:p??null}):Fe===`base-prompt`?(0,W.jsx)(kW,{}):Fe===`compaction-prompt`?(0,W.jsx)(AW,{}):(0,W.jsx)(xW,{agentProfiles:Xn,selectedFileKey:Le}):(0,W.jsx)(EWe,{activePanel:g,showThinking:N,setShowThinking:P,expandThinking:F,setExpandThinking:ee,modelDefaults:_.modelDefaults,modelCatalog:_.modelCatalog,onModelDefaultsChanged:e=>{v(t=>t&&{...t,modelDefaults:e})},piPackages:_.agentCatalog?.piPackages,onPiPackageChanged:Mt,onPiPackageRemoved:Nt,userSkills:_.agentCatalog?.userSkills,onUserSkillChanged:Pt,onUserSkillRemoved:Ft,piboSessionId:x,onProviderAuthChanged:qt})}),$t?(0,W.jsx)(I4e,{room:$t,confirmName:en,deleting:tn,onConfirmNameChange:nn,onCancel:an,onDelete:()=>void on()}):null,sn?(0,W.jsx)(F4e,{session:sn,confirmText:cn,deleting:ln,onConfirmTextChange:un,onCancel:fn,onDelete:()=>void pn()}):null]})})]})]})}function d6e({status:e,onDismiss:t}){let n=e.status===`starting`||e.status===`running`,r=e.totalBytes&&e.totalBytes>0?Math.min(100,Math.max(0,e.receivedBytes/e.totalBytes*100)):void 0,i=e.status===`failed`?`border-red-500/40 bg-red-500/10 text-red-100`:e.status===`completed`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-100`:`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-slate-100`,a=e.status===`completed`?`Download ready`:e.status===`failed`?`Download failed`:`Download in progress`;return(0,W.jsx)(`div`,{className:`border-b px-4 py-2 text-sm ${i}`,role:`status`,"aria-live":`polite`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider opacity-80`,children:a}),(0,W.jsx)(`div`,{className:`min-w-0 truncate font-medium`,title:e.path,children:e.filename}),(0,W.jsxs)(`div`,{className:`mt-1 text-xs text-slate-300`,children:[o6e(e),e.duplicateAttempted&&n?(0,W.jsx)(`span`,{className:`ml-2 text-amber-200`,children:`Already downloading this file. Please wait.`}):null]}),r!==void 0&&n?(0,W.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-sm bg-[#0e1116]`,"aria-label":`Download progress ${Math.floor(r)}%`,children:(0,W.jsx)(`div`,{className:`h-full bg-[#11a4d4] transition-[width]`,style:{width:`${r}%`}})}):null,r===void 0&&n?(0,W.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-sm bg-[#0e1116]`,children:(0,W.jsx)(`div`,{className:`h-full w-1/3 animate-pulse bg-[#11a4d4]`})}):null]}),n?null:(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-sm border border-slate-600 px-2 py-1 text-[11px] uppercase tracking-wider text-slate-200 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:`Dismiss`})]})})}function Q9(e,t){return e.find(e=>e.name===t||e.aliases.includes(t))}var f6e=new wn({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});function p6e(){let e=bs({select:e=>({pathname:e.location.pathname,search:e.location.search})});return(0,W.jsx)(u6e,{route:gu(e.pathname,e.search)})}var $9=Zo({component:p6e}),m6e=Yo({getParentRoute:()=>$9,path:`/`}),h6e=Yo({getParentRoute:()=>$9,path:`sessions/$piboSessionId`}),g6e=Yo({getParentRoute:()=>$9,path:`rooms/$roomId`}),_6e=Yo({getParentRoute:()=>$9,path:`rooms/$roomId/sessions/$piboSessionId`}),v6e=Yo({getParentRoute:()=>$9,path:`projects`}),y6e=Yo({getParentRoute:()=>$9,path:`projects/$projectId`}),b6e=Yo({getParentRoute:()=>$9,path:`projects/$projectId/sessions/$piboSessionId`}),x6e=Yo({getParentRoute:()=>$9,path:`vscode`}),S6e=Yo({getParentRoute:()=>$9,path:`workflows`}),C6e=Yo({getParentRoute:()=>$9,path:`workflows/drafts/$draftId`}),w6e=Yo({getParentRoute:()=>$9,path:`workflows/view/$workflowId/$workflowVersion`}),T6e=Yo({getParentRoute:()=>$9,path:`agents`}),E6e=Yo({getParentRoute:()=>$9,path:`cron`}),D6e=Yo({getParentRoute:()=>$9,path:`loops`}),O6e=Yo({getParentRoute:()=>$9,path:`ralph`}),k6e=Yo({getParentRoute:()=>$9,path:`context`}),A6e=Yo({getParentRoute:()=>$9,path:`settings`}),j6e=Yo({getParentRoute:()=>$9,path:`settings/concurrency`}),M6e=Yo({getParentRoute:()=>$9,path:`settings/previews`}),N6e=Yo({getParentRoute:()=>$9,path:`settings/transcription`}),P6e=Yo({getParentRoute:()=>$9,path:`settings/speech`}),F6e=Yo({getParentRoute:()=>$9,path:`settings/shortcuts`}),I6e=Yo({getParentRoute:()=>$9,path:`settings/maintenance`}),L6e=Yo({getParentRoute:()=>$9,path:`settings/pi-packages`}),R6e=Yo({getParentRoute:()=>$9,path:`settings/skills`}),z6e=Yo({getParentRoute:()=>$9,path:`settings/providers`}),B6e=ms({routeTree:$9.addChildren([m6e,h6e,g6e,_6e,v6e,y6e,b6e,x6e,S6e,C6e,w6e,T6e,E6e,D6e,O6e,k6e,A6e,j6e,M6e,N6e,P6e,F6e,I6e,L6e,R6e,z6e]),basepath:`/apps/chat`,stringifySearch:yu});`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=!1;navigator.serviceWorker.addEventListener(`controllerchange`,()=>{e||(e=!0,window.location.reload())}),navigator.serviceWorker.register(`/apps/chat/sw.js`).then(e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&navigator.serviceWorker.controller&&t.postMessage({type:`PIBO_CHAT_SKIP_WAITING`})})}),window.setInterval(()=>{e.update()},3e5)}).catch(()=>{})}),(0,Il.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(U.StrictMode,{children:(0,W.jsx)(kn,{client:f6e,children:(0,W.jsx)(_s,{router:B6e})})}));export{OL as n,sR as t};
228
+ `):``}function X2e(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function w9(e,t,n){let r=X2e(n);r.length?e[t]=r:delete e[t]}function T9({diagnostics:e}){return e.length?(0,W.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Inspector picker diagnostics`,children:e.map(e=>(0,W.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-2 text-[11px] leading-5 text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,W.jsx)(Dl,{size:12}),e.code]}),(0,W.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-amber-200/80`,children:e.path}),(0,W.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function E9({option:e,badge:t}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-semibold text-slate-200`,children:e.displayName}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.id})]}),(0,W.jsx)(l9,{label:t})]}),e.description?(0,W.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,e.paramsSchema?(0,W.jsx)(`div`,{className:`mt-3`,children:(0,W.jsx)(D9,{label:`paramsSchema`,schema:e.paramsSchema})}):null]})}function D9({label:e,schema:t}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,W.jsx)(`pre`,{className:`mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[11px] leading-5 text-slate-300`,children:Z2e(t)})]})}function Z2e(e){return e?JSON.stringify(e,null,2):`null`}function Q2e({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let a=(0,U.useRef)(null),[o,s]=(0,U.useState)(S9(n.promptBuilder)),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(),[f,p]=(0,U.useState)(`idle`),[m,h]=(0,U.useState)(`saved`),[g,_]=(0,U.useState)();(0,U.useEffect)(()=>{s(S9(n.promptBuilder))},[n,t]),(0,U.useEffect)(()=>{let e=!1;return Hze(o||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o]),(0,U.useEffect)(()=>{let e=!1;return _(void 0),o?(p(`loading`),Uze(o).then(t=>{e||(d(t.asset),p(`loaded`))}).catch(t=>{e||(d(void 0),p(`error`),_(t instanceof Error?t.message:`Failed to load prompt asset`))}),()=>{e=!0}):(d(void 0),p(`idle`),()=>{e=!0})},[o]);let v=c?.options.find(e=>e.id===o),y=typeof n.promptTemplate==`string`?n.promptTemplate:z0e,b=u?.markdown??y,x=`${e.draftId}:${t}`,S=!!S9(n.promptBuilder),C=o.startsWith(`ui.promptAssets.`),w=`${typeof n.label==`string`&&n.label.trim()?n.label.trim():t} prompt asset`,T=(0,U.useCallback)(async n=>{try{let r=await Wze({assetId:C?o:void 0,sourceRefId:o||void 0,displayName:w,description:`Managed prompt asset for ${t} in draft ${e.draftId}.`,markdown:n});await i(J2e(e.definition,t,r.asset),`Saved prompt asset revision ${r.asset.revisionId} and updated ${t}.`,{editTrigger:`prompt_edit`}),s(r.asset.id),d(r.asset),_(`Saved ${r.asset.displayName} as revision ${r.asset.revisionId}; draft now pins ${r.asset.contentHash}.`)}catch(e){throw _(e instanceof Error?e.message:`Failed to save prompt asset revision`),e}},[e.definition,e.draftId,t,i,w,o,C]),E=async e=>{try{await a.current?.flushSave(),s(e)}catch(e){_(e instanceof Error?e.message:`Failed to save the current prompt asset before switching`)}},D=async()=>{u&&(await i(J2e(e.definition,t,u),`Updated ${t} to use prompt asset ${u.id}.`,{editTrigger:`prompt_edit`}),_(`Draft node ${t} now uses ${u.displayName} at ${u.contentHash}.`))};return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Prompt asset Markdown editor`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Prompt asset Markdown editor`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Edit prompt assets with the same Markdown editor pattern as Context Files. Saving creates a managed UI asset revision, updates this draft node to a prompt asset ref, and pins the revision id plus content hash in the Pibo Workflow IR.`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Prompt asset ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o,onChange:e=>void E(e.target.value),disabled:r,children:[(0,W.jsx)(`option`,{value:``,children:`Create managed asset from direct prompt template`}),c?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:c?.diagnostics??[]}),v?(0,W.jsx)(E9,{option:v,badge:v.kind===`ui`?`managed prompt asset`:`registered prompt asset`}):null,f===`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-2 text-[11px] leading-5 text-red-200`,role:`alert`,children:g??`Failed to load prompt asset.`}):null,(0,W.jsx)(`div`,{className:`workflow-prompt-editor-frame min-w-0 rounded-sm bg-[#101d22]`,children:(0,W.jsx)(bW,{ref:a,documentKey:x,initialMarkdown:b,onPersist:T,onSaveStateChange:h,ariaLabel:`Prompt asset Markdown editor`})}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:S?`promptBuilder ref`:`direct promptTemplate source`}),(0,W.jsx)(l9,{label:`Markdown save: ${m}`}),u?(0,W.jsx)(l9,{label:`${u.source} · ${u.revisionId}`}):null]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void D(),disabled:r||!u,children:[(0,W.jsx)(fl,{size:13}),`Use selected asset on draft`]})}),g&&f!==`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-2 text-[11px] leading-5 text-emerald-200`,role:`status`,children:g}):null,(0,W.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Code/plugin prompt assets are not mutated. Editing a registered asset copies the Markdown into a managed UI prompt asset; later saves append revisions and only affect this draft or future workflow versions that reference the new revision.`})]})}function $2e({workflowId:e,workflowVersion:t}){let[n,r]=(0,U.useState)(),[i,a]=(0,U.useState)(`loading`),[o,s]=(0,U.useState)();(0,U.useEffect)(()=>{let n=!1;return a(`loading`),s(void 0),qze({selectedWorkflowId:e,selectedWorkflowVersion:t}).then(e=>{n||(r(e),a(`loaded`))}).catch(e=>{n||(s(e instanceof Error?e.message:`Failed to load workflow viewer`),a(`error`))}),()=>{n=!0}},[e,t]);let c=(0,U.useMemo)(()=>n?.options.find(e=>e.id===n.selectedWorkflowId&&e.version===n.selectedWorkflowVersion),[n]);return i===`loading`?(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-sm text-slate-300`,"aria-live":`polite`,children:[(0,W.jsx)(Rc,{size:16,className:`animate-spin text-[#11a4d4]`}),`Loading workflow viewer `,e,`@`,t,`…`]}):i===`error`?(0,W.jsxs)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-4 text-sm leading-6 text-red-200`,role:`alert`,children:[(0,W.jsx)(`div`,{className:`font-bold`,children:`Could not load workflow viewer`}),(0,W.jsx)(`div`,{className:`mt-1 text-xs`,children:o??`Failed to load workflow metadata.`})]}):(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,W.jsx)(pc,{size:13}),`Workflow version viewer`]}),(0,W.jsx)(`h3`,{className:`mt-1 text-lg font-bold text-slate-100`,children:c?.title??`${e}@${t}`}),(0,W.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:`This separate viewer is the nested workflow navigation target. Parent graphs do not inline-expand nested workflow internals in V2.`})]}),(0,W.jsx)(`a`,{className:`shrink-0 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,href:`/apps/chat/workflows`,children:`Back to Workflows`})]}),c?(0,W.jsx)(e4e,{option:c}):null,(0,W.jsx)(t4e,{diagnostics:n?.diagnostics??[],ariaLabel:`Workflow viewer diagnostics`}),(0,W.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Viewer mode shows registry metadata and navigation context only. To change a child workflow, open its own UI draft or duplicate/edit a published workflow from the Workflow Library.`})]})}function e4e({option:e}){return(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,W.jsxs)(`div`,{className:`font-semibold text-slate-200`,children:[`Selected workflow: `,e.title]}),(0,W.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:[e.id,`@`,e.version]}),e.description?(0,W.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${e.source} source`}),(0,W.jsx)(l9,{label:e.status}),e.tags.map(e=>(0,W.jsx)(l9,{label:e},e))]})]})}function t4e({diagnostics:e,ariaLabel:t}){return e.length?(0,W.jsx)(`div`,{className:`grid gap-2`,"aria-label":t,children:e.map(e=>(0,W.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,W.jsx)(Dl,{size:13}),e.code]}),(0,W.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-amber-200/80`,children:e.path}),(0,W.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function n4e({draft:e,selectedElement:t,nodeIds:n,isSaving:r,onSaveDefinition:i,onDraftDefinitionChange:a}){let o=t?.type===`node`?N7(e.definition)[t.id]:void 0,s=t?.type===`edge`?P7(e.definition)[t.id]:void 0;return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow inspectors`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Workflow inspectors`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Inspector saves update the same Pibo Workflow IR draft as the graph canvas; XState remains projection-only.`})]}),(0,W.jsx)(a4e,{draft:e,isSaving:r,onSaveDefinition:i,onDraftDefinitionChange:a}),t?.type===`node`&&o?(0,W.jsx)(o4e,{draft:e,nodeId:t.id,node:o,isSaving:r,onSaveDefinition:i}):t?.type===`edge`&&s?(0,W.jsx)(u4e,{draft:e,edgeId:t.id,edge:s,nodeIds:n,isSaving:r,onSaveDefinition:i}):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Select a canvas node or edge to open the node or edge inspector. Workflow settings remain editable at all times.`})]})}function r4e(e,t){return e.filter(e=>e.nodeId===t||e.path?.startsWith(`$.nodes.${t}`))}function i4e(e,t){return e.filter(e=>e.edgeId===t||e.path?.startsWith(`$.edges.${t}`))}function a4e({draft:e,isSaving:t,onSaveDefinition:n,onDraftDefinitionChange:r}){let[i,a]=(0,U.useState)(()=>V2e(e.definition));(0,U.useEffect)(()=>{a(V2e(e.definition))},[e.definition]);let o=(t,n)=>{a(i=>{let a={...i,[t]:n};return r?.(x9(e.definition,a)),a})};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:`Workflow settings inspector`}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Workflow title`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:i.title,onChange:e=>o(`title`,e.target.value)})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Workflow description`}),(0,W.jsx)(`textarea`,{className:`min-h-20 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:i.description,onChange:e=>o(`description`,e.target.value)})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(f4e,{label:`Workflow input port`,kind:i.inputKind,description:i.inputDescription,schemaText:i.inputSchemaText,onKindChange:e=>o(`inputKind`,e),onDescriptionChange:e=>o(`inputDescription`,e),onSchemaChange:e=>o(`inputSchemaText`,e)}),(0,W.jsx)(f4e,{label:`Workflow output port`,kind:i.outputKind,description:i.outputDescription,schemaText:i.outputSchemaText,onKindChange:e=>o(`outputKind`,e),onDescriptionChange:e=>o(`outputDescription`,e),onSchemaChange:e=>o(`outputSchemaText`,e)})]}),(0,W.jsx)(m4e,{fields:i.globalStateFields,onAddField:()=>{a(t=>{let n={...t,globalStateFields:[...t.globalStateFields,H2e(t.globalStateFields)]};return r?.(x9(e.definition,n)),n})},onRemoveField:t=>{a(n=>{let i={...n,globalStateFields:n.globalStateFields.filter((e,n)=>n!==t)};return r?.(x9(e.definition,i)),i})},onUpdateField:(t,n,i)=>{a(a=>{let o={...a,globalStateFields:a.globalStateFields.map((e,r)=>r===t?{...e,[n]:i}:e)};return r?.(x9(e.definition,o)),o})}}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(k9,{label:`metadata.tags`,value:i.metadataTags,onChange:e=>o(`metadataTags`,e)}),(0,W.jsx)(k9,{label:`metadata.useWhen`,value:i.metadataUseWhen,onChange:e=>o(`metadataUseWhen`,e)}),(0,W.jsx)(k9,{label:`metadata.notFor`,value:i.metadataNotFor,onChange:e=>o(`metadataNotFor`,e)}),(0,W.jsx)(k9,{label:`metadata.examples`,value:i.metadataExamples,onChange:e=>o(`metadataExamples`,e)})]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{n(x9(e.definition,i),`Saved workflow settings inspector edits to the draft IR.`,{editTrigger:q2e(e.definition,i)?`state_edit`:`schema_edit`})},disabled:t,children:[t?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save workflow settings`]})]})]})}function o4e({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,U.useState)(()=>v0e(n)),[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(),[d,f]=(0,U.useState)(),[p,m]=(0,U.useState)(),[h,g]=(0,U.useState)(),_=F7(n),v=r4e(e.diagnostics,t),y=d?.options.find(e=>e.id===(d?.selectedRefId??a.adapterRef)),b=(0,U.useMemo)(()=>new Set(a.humanActionRefs.map(e=>e.id)),[a.humanActionRefs]);(0,U.useEffect)(()=>{o(v0e(n))},[n,t]),(0,U.useEffect)(()=>{if(_!==`agent`)return;let e=!1;return M3(a.profileId||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.profileId]),(0,U.useEffect)(()=>{if(_!==`code`)return;let e=!1;return Bze(a.handlerId||void 0).then(t=>{e||u(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.handlerId]),(0,U.useEffect)(()=>{if(_!==`adapter`)return;let e=!1;return N3(a.adapterRef||void 0).then(t=>{e||f(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.adapterRef]),(0,U.useEffect)(()=>{if(_!==`workflow`)return;let e=!1,t=Z0e(a.workflowVersionKey);return F3({selectedWorkflowId:t?.workflowId,selectedWorkflowVersion:t?.workflowVersion}).then(t=>{e||m(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.workflowVersionKey]),(0,U.useEffect)(()=>{if(_!==`human`)return;let e=!1;return P3().then(t=>{e||g(t)}).catch(()=>void 0),()=>{e=!0}},[_]);let x=(e,t)=>{o(n=>({...n,[e]:t}))},S=(e,t)=>{o(n=>({...n,humanActionRefs:A0e(n.humanActionRefs,e,t)}))};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Node inspector: `,t]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${_} node`}),(0,W.jsx)(l9,{label:`${v.length} diagnostics`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Node label`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.label,onChange:e=>x(`label`,e.target.value)})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Node description`}),(0,W.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.description,onChange:e=>x(`description`,e.target.value)})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(p4e,{label:`Node input port`,kind:a.inputKind,description:a.inputDescription,schemaText:a.inputSchemaText,onKindChange:e=>x(`inputKind`,e),onDescriptionChange:e=>x(`inputDescription`,e),onSchemaChange:e=>x(`inputSchemaText`,e)}),(0,W.jsx)(p4e,{label:`Node output port`,kind:a.outputKind,description:a.outputDescription,schemaText:a.outputSchemaText,onKindChange:e=>x(`outputKind`,e),onDescriptionChange:e=>x(`outputDescription`,e),onSchemaChange:e=>x(`outputSchemaText`,e)})]}),(0,W.jsx)(s4e,{label:`Node`,definition:e.definition,value:a.stateAccess,onChange:e=>x(`stateAccess`,e)}),_===`agent`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Agent node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Agent profile ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:s?.selectedProfileId??a.profileId,onChange:e=>x(`profileId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a non-archived profile`}),s?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:Q0e(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:s?.diagnostics??[]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Prompt template`}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-slate-100`,value:a.promptTemplate,onChange:e=>x(`promptTemplate`,e.target.value)}),(0,W.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Saving direct prompt text writes `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`promptTemplate`}),` on this Pibo Workflow IR node.`]})]}),(0,W.jsx)(Q2e,{draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i})]}):null,_===`code`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Code node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Registered code handler`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l?.selectedHandlerId??a.handlerId,onChange:e=>x(`handlerId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered handler ref`}),l?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:$0e(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:l?.diagnostics??[]})]}):null,_===`adapter`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Adapter node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Registered adapter ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:d?.selectedRefId??a.adapterRef,onChange:e=>x(`adapterRef`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),d?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsx)(T9,{diagnostics:d?.diagnostics??[]}),y?.paramsSchema?(0,W.jsx)(A9,{label:`Adapter params JSON`,schema:y.paramsSchema,value:a.adapterParamsText,onChange:e=>x(`adapterParamsText`,e)}):null,(0,W.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-500`,children:`Adapter nodes store only a registered deterministic adapter ref. Inline transformation code and hidden LLM coercion are not exposed by the UI.`})]}):null,_===`workflow`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Nested workflow ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:p?.selectedWorkflowId&&p.selectedWorkflowVersion?X0e(p.selectedWorkflowId,p.selectedWorkflowVersion):a.workflowVersionKey,onChange:e=>x(`workflowVersionKey`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select a published workflow version`}),p?.options.map(e=>(0,W.jsx)(`option`,{value:c9(e),children:t2e(e)},c9(e)))]})]}),(0,W.jsx)(t4e,{diagnostics:p?.diagnostics??[],ariaLabel:`Workflow node diagnostics`})]}):null,_===`human`?(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Human node fields`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Human prompt`}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:a.humanPrompt,onChange:e=>x(`humanPrompt`,e.target.value)})]}),(0,W.jsx)(O9,{label:`Human node resume payload schema JSON`,value:a.humanSchemaText,onChange:e=>x(`humanSchemaText`,e)}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Human action choices`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered action choices`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Actions are selected from the Workflow Registry. The label, action kind, and payload requirements come from picker metadata.`})]}),h?.options.length?h.options.map(e=>(0,W.jsxs)(`label`,{className:`grid gap-1 rounded-sm border border-slate-800 bg-[#101d22] p-2 text-slate-300`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-semibold`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#11a4d4]`,checked:b.has(e.id),onChange:t=>S(e,t.target.checked)}),(0,W.jsx)(`span`,{children:e.displayName}),(0,W.jsx)(l9,{label:`kind: ${e.kind??`registered`}`})]}),(0,W.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:e.description??e.id}),(0,W.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Payload requirements: `,e.paramsSchema?JSON.stringify(e.paramsSchema):`none`]})]},e.id)):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No registered human actions are available from the picker.`}),(0,W.jsx)(T9,{diagnostics:h?.diagnostics??[]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,"aria-label":`Selected human action refs`,children:a.humanActionRefs.length?a.humanActionRefs.map(e=>(0,W.jsx)(l9,{label:`${e.id}${e.kind?` (${e.kind})`:``}`},`${e.id}:${e.kind??``}`)):(0,W.jsx)(`span`,{className:`text-slate-500`,children:`No human action refs selected.`})})]}),(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 md:grid-cols-[1fr_1fr]`,"aria-label":`Human node timeout`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Timeout kind`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.humanTimeoutKind,onChange:e=>x(`humanTimeoutKind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`No timeout`}),(0,W.jsx)(`option`,{value:`milliseconds`,children:`Milliseconds`}),(0,W.jsx)(`option`,{value:`seconds`,children:`Seconds`}),(0,W.jsx)(`option`,{value:`minutes`,children:`Minutes`}),(0,W.jsx)(`option`,{value:`iso8601`,children:`ISO-8601 duration`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Timeout value`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,type:a.humanTimeoutKind===`iso8601`?`text`:`number`,min:a.humanTimeoutKind===`iso8601`?void 0:1,placeholder:a.humanTimeoutKind===`iso8601`?`PT1H`:`60`,value:a.humanTimeoutValue,onChange:e=>x(`humanTimeoutValue`,e.target.value),disabled:a.humanTimeoutKind===`none`})]})]})]}):null,(0,W.jsx)(n2e,{diagnostics:v,emptyLabel:`No diagnostics for selected node.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{let r=y0e(e.definition,t,a),o=d0e(n,a)?`state_edit`:_===`agent`||_===`human`?`prompt_edit`:`schema_edit`;i(r,`Saved node inspector edits for ${t}.`,{editTrigger:o})},disabled:r,children:[r?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save node inspector`]})]})]})}function s4e({label:e,definition:t,value:n,onChange:r,allowEdgeWrites:i=!1}){let a=h0e(t,n.readScope,[...n.reads,...n.writes]),o=i?K7:u0e,s=h0e(t,n.writeScope,[...n.reads,...n.writes]),c=!!n.readPath.trim(),l=!!n.writePath.trim()&&(i||n.writeScope!==`edge`),u=(e,t)=>r({...n,[e]:t}),d=e=>{let t=e===`reads`?n.readScope:n.writeScope,i=(e===`reads`?n.readPath:n.writePath).trim();if(!i)return;let a=`${t}.${i}`,o=n[e];o.includes(a)||r({...n,[e]:[...o,a]})},f=(e,t)=>r({...n,[e]:n[e].filter(e=>e!==t)});return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,"aria-label":`${e} simple state mapping controls`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[e,` simple state mappings`]}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:[`Add simple scoped state reads and writes as Pibo Workflow IR `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.reads`}),` and `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.writes`}),` arrays. Complex state mapping DSLs remain raw Workflow IR only.`]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Read scope`}),(0,W.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.readScope,onChange:e=>u(`readScope`,e.target.value),children:K7.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(c4e,{label:`Read path`,value:n.readPath,options:a,onChange:e=>u(`readPath`,e)}),(0,W.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`reads`),disabled:!c,children:`Add read`})]}),(0,W.jsx)(l4e,{label:`Reads`,entries:n.reads,onRemove:e=>f(`reads`,e)}),(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Write scope`}),(0,W.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.writeScope,onChange:e=>u(`writeScope`,e.target.value),children:o.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(c4e,{label:`Write path`,value:n.writePath,options:s,onChange:e=>u(`writePath`,e)}),(0,W.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`writes`),disabled:!l,children:`Add write`})]}),(0,W.jsx)(l4e,{label:`Writes`,entries:n.writes,onRemove:e=>f(`writes`,e)}),n.writeScope===`global`&&!g0e(t).length?(0,W.jsx)(`div`,{className:`rounded-sm border border-amber-900/60 bg-amber-950/20 p-2 text-[11px] leading-5 text-amber-100`,children:`Declare global state fields in the workflow settings inspector before selecting global read/write paths.`}):null]})}function c4e({label:e,value:t,options:n,onChange:r}){let i=t&&!n.includes(t)?[t,...n]:n;return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>r(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select path`}),i.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]})}function l4e({label:e,entries:t,onRemove:n}){return(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-semibold text-slate-400`,children:e}),t.length?(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-[11px] text-slate-300 transition hover:border-red-500/60 hover:text-red-100`,onClick:()=>n(e),title:`Remove ${e}`,children:[e,` ×`]},e))}):(0,W.jsxs)(`div`,{className:`text-[11px] text-slate-500`,children:[`No `,e.toLowerCase(),` declared.`]})]})}function u4e({draft:e,edgeId:t,edge:n,nodeIds:r,isSaving:i,onSaveDefinition:a}){let[o,s]=(0,U.useState)(()=>b0e(n,r)),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(),[f,p]=(0,U.useState)(!1),m=i4e(e.diagnostics,t),h=A2e(e.definition,n),g=m.some(e=>e.code===`WorkflowGraphError.incompatibleEdgePorts`),_=c?.options.find(e=>e.id===(c?.selectedRefId??o.guardHandler)),v=u?.options.find(e=>e.id===(u?.selectedRefId??o.adapterRef));(0,U.useEffect)(()=>{s(b0e(n,r))},[n,t,r]),(0,U.useEffect)(()=>{p(!1)},[t]),(0,U.useEffect)(()=>{let e=!1;return Vze(o.guardHandler||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o.guardHandler]),(0,U.useEffect)(()=>{let e=!1;return N3(o.adapterRef||void 0).then(t=>{e||d(t)}).catch(()=>void 0),()=>{e=!0}},[o.adapterRef]);let y=(e,t)=>{s(n=>({...n,[e]:t}))},b=()=>{let r=x0e(e.definition,t,o),i=f0e(n.state,o.stateAccess)?`state_edit`:`edge_edit`;a(r,`Saved edge inspector edits for ${t}.`,{editTrigger:i})};return(0,W.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,W.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Edge inspector: `,t]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,W.jsx)(l9,{label:`${o.kind} edge`}),(0,W.jsx)(l9,{label:`${m.length} diagnostics`})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Source node`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourceNodeId,onChange:e=>y(`sourceNodeId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select source`}),r.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Target node`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetNodeId,onChange:e=>y(`targetNodeId`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`Select target`}),r.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Source port id`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourcePortId,onChange:e=>y(`sourcePortId`,e.target.value),placeholder:`default`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Target port id`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetPortId,onChange:e=>y(`targetPortId`,e.target.value),placeholder:`default`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Edge kind`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.kind,onChange:e=>y(`kind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`data`,children:`data`}),(0,W.jsx)(`option`,{value:`control`,children:`control`}),(0,W.jsx)(`option`,{value:`error`,children:`error`}),(0,W.jsx)(`option`,{value:`resume`,children:`resume`})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Guard ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:c?.selectedRefId??o.guardHandler,onChange:e=>y(`guardHandler`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`No guard`}),c?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Guard priority`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.guardPriority,onChange:e=>y(`guardPriority`,e.target.value),placeholder:`optional integer`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,W.jsx)(`span`,{children:`Edge adapter ref`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:u?.selectedRefId??o.adapterRef,onChange:e=>y(`adapterRef`,e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`No edge adapter`}),u?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]})]}),_?.paramsSchema?(0,W.jsx)(A9,{label:`Guard params JSON`,schema:_.paramsSchema,value:o.guardParamsText,onChange:e=>y(`guardParamsText`,e)}):null,v?.paramsSchema?(0,W.jsx)(A9,{label:`Edge adapter params JSON`,schema:v.paramsSchema,value:o.adapterParamsText,onChange:e=>y(`adapterParamsText`,e)}):null,(0,W.jsx)(s4e,{label:`Edge`,definition:e.definition,value:o.stateAccess,onChange:e=>y(`stateAccess`,e),allowEdgeWrites:!0}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border px-3 py-2 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${g?`border-amber-600/70 text-amber-100 hover:border-amber-400`:`border-slate-700 text-slate-300 hover:border-[#11a4d4]/60 hover:text-slate-100`}`,onClick:()=>p(!0),disabled:i||!h.sourcePort||!h.targetPort,children:[(0,W.jsx)(Pc,{size:13}),g?`Fix incompatible edge with adapter`:`Open compatible edge adapter dialog`]}),f?(0,W.jsx)(d4e,{draft:e,edgeId:t,edge:n,edgePortDetails:h,isSaving:i,onClose:()=>p(!1),onSaveDefinition:a}):null,(0,W.jsx)(T9,{diagnostics:[...c?.diagnostics??[],...u?.diagnostics??[]]}),(0,W.jsx)(n2e,{diagnostics:m,emptyLabel:`No diagnostics for selected edge.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:b,disabled:i||!o.sourceNodeId||!o.targetNodeId,children:[i?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):(0,W.jsx)(fl,{size:13}),`Save edge inspector`]})]})]})}function d4e({draft:e,edgeId:t,edge:n,edgePortDetails:r,isSaving:i,onClose:a,onSaveDefinition:o}){let[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(j2e(n)),[d,f]=(0,U.useState)(`loading`),[p,m]=(0,U.useState)();(0,U.useEffect)(()=>{let e=!1;return f(`loading`),m(void 0),N3(l||void 0).then(t=>{e||(c(t),u(e=>e||(t.options[0]?.id??``)),f(`loaded`))}).catch(t=>{e||(m(t instanceof Error?t.message:`Failed to load compatible adapters`),f(`error`))}),()=>{e=!0}},[l]);let h=s?.options.find(e=>e.id===l),g=!!(h&&r.sourcePort&&r.targetPort&&d===`loaded`&&!i),_=async()=>{l&&(await o(M2e(e.definition,t,l),`Applied ${l} as edge adapter for ${t}.`,{editTrigger:`edge_edit`}),a())},v=async()=>{l&&(await o(N2e(e.definition,t,l),`Inserted adapter node for ${t} using ${l}.`,{editTrigger:`graph_edit`}),a())};return(0,W.jsx)(rQ,{title:`Choose a registered adapter for ${t}`,description:`The dialog shows the source output and target input schemas from the Pibo Workflow IR.`,onClose:a,closeLabel:`Close compatible edge adapter dialog`,closeDisabled:i,maxWidthClassName:`max-w-3xl`,children:(0,W.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,W.jsx)(Pc,{size:13}),`Compatible edge adapter dialog`]}),(0,W.jsx)(`p`,{className:`max-w-2xl text-xs leading-5 text-slate-500`,children:`Use a registered adapter as an explicit edge adapter, or insert a visible adapter node between the endpoints.`}),(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsx)(D9,{label:`From schema${r.sourceNodeId?` (${r.sourceNodeId})`:``}`,schema:r.sourcePort??null}),(0,W.jsx)(D9,{label:`To schema${r.targetNodeId?` (${r.targetNodeId})`:``}`,schema:r.targetPort??null})]}),(0,W.jsx)(`div`,{className:`rounded-sm border p-3 text-xs leading-5 ${r.directlyCompatible?`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`:`border-amber-700/70 bg-amber-950/30 text-amber-100`}`,children:r.directlyCompatible?`These ports are directly compatible. An adapter is optional and remains explicit if selected.`:`These ports are not directly compatible. Select a registered adapter instead of hidden LLM coercion or inline transformation code.`}),(0,W.jsxs)(`div`,{className:`grid gap-3 text-xs`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Compatible registered adapter`}),(0,W.jsxs)(`select`,{"aria-label":`Compatible registered adapter`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l,onChange:e=>u(e.target.value),disabled:d===`loading`||d===`error`||i,children:[(0,W.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),s?.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:s9(e)},e.id))]})]}),d===`error`?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:p??`Failed to load compatible adapters.`}):null,(0,W.jsx)(T9,{diagnostics:s?.diagnostics??[]}),h?(0,W.jsx)(E9,{option:h,badge:`selected adapter`}):null,(0,W.jsxs)(`div`,{className:`grid gap-2`,"aria-label":`Compatible adapter candidates`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Compatible adapter candidates`}),s?.options.map(e=>(0,W.jsx)(E9,{option:e,badge:`compatible adapter`},e.id))]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void _(),disabled:!g,children:[(0,W.jsx)(Pc,{size:13}),`Use as edge adapter`]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void v(),disabled:!g,children:[(0,W.jsx)(al,{size:13}),`Insert adapter node`]})]}),(0,W.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Both actions persist Pibo Workflow IR only. Edge adapters store `,(0,W.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`adapter.transform.id`}),`; inserted adapter nodes store a visible deterministic adapter handler ref.`]})]})]})})}function f4e({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,W.jsx)(`option`,{value:`text`,children:`text`}),(0,W.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),placeholder:`Optional port description`})]}),t===`json`?(0,W.jsx)(O9,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function p4e({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`inherit/default`}),(0,W.jsx)(`option`,{value:`text`,children:`text`}),(0,W.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),disabled:t===`none`,placeholder:`Optional port description`})]}),t===`json`?(0,W.jsx)(O9,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function m4e({fields:e,onAddField:t,onRemoveField:n,onUpdateField:r}){return(0,W.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow global state fields`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Workflow global state fields`}),(0,W.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Declare simple global state paths for node and edge state mapping dropdowns. State schema changes run draft validation and may invalidate connected graph diagnostics without blocking draft save.`})]}),e.length?e.map((e,t)=>(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-2`,children:[(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Global state path`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.path,onChange:e=>r(t,`path`,e.target.value),placeholder:`projectGoal`})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:`Merge policy`}),(0,W.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.mergeKind,onChange:e=>r(t,`mergeKind`,e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`No merge policy`}),(0,W.jsx)(`option`,{value:`replace`,children:`replace`}),(0,W.jsx)(`option`,{value:`append`,children:`append`}),(0,W.jsx)(`option`,{value:`shallowMerge`,children:`shallowMerge`})]})]}),(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,W.jsx)(`span`,{children:`Description`}),(0,W.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.description,onChange:e=>r(t,`description`,e.target.value),placeholder:`Optional state description`})]}),(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(O9,{label:`Global state ${e.path||t+1} schema JSON`,value:e.schemaText,onChange:e=>r(t,`schemaText`,e)})}),(0,W.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-red-500/70 hover:text-red-100`,onClick:()=>n(t),children:`Remove state field`})]},`${t}:${e.path}`)):(0,W.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No global state fields declared. Local and edge path dropdowns remain available for simple node-local state and edge payload access.`}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:t,children:[(0,W.jsx)(al,{size:13}),`Add global state field`]})]})}function O9({label:e,value:t,onChange:n}){return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`textarea`,{className:`min-h-36 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:JSON.stringify(G7,null,2),spellCheck:!1,"aria-label":e}),(0,W.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:`Raw JSON Schema subset only. Unsupported keywords return workflow diagnostics; no Zod, AJV, or form-builder schema layer is introduced.`})]})}function k9({label:e,value:t,onChange:n}){return(0,W.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:`One value per line`})]})}function A9({label:e,schema:t,value:n,onChange:r}){return(0,W.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,"aria-label":e,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,W.jsx)(D9,{label:`paramsSchema`,schema:t}),(0,W.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:n,onChange:e=>r(e.target.value),placeholder:`{}`,"aria-label":`${e} value`}),(0,W.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Params save as data on the selected registry ref. No inline code path is created.`})]})}function h4e({open:e,onClose:t,onCreate:n}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(),p=(0,U.useRef)(null);if((0,U.useEffect)(()=>{e&&(i(``),o(!1),c(!1),u(!1),f(void 0))},[e]),!e)return null;let m=a||s?g4e(r):void 0;return(0,W.jsx)(rQ,{title:`Create workflow`,description:`Create a new editable workflow draft.`,onClose:t,initialFocusRef:p,closeLabel:`Cancel workflow creation`,closeDisabled:l,children:(0,W.jsxs)(`form`,{className:`grid gap-4 p-4`,onSubmit:async e=>{if(e.preventDefault(),o(!0),f(void 0),g4e(r)){p.current?.focus();return}u(!0);try{await n(r.trim()),u(!1),t()}catch(e){f(x1(e)),u(!1)}},noValidate:!0,children:[(0,W.jsxs)(`label`,{className:`block text-xs font-semibold text-slate-300`,children:[(0,W.jsxs)(`span`,{children:[`Name `,(0,W.jsx)(`span`,{className:`ml-1 text-[#8bdcf4]`,children:`required`})]}),(0,W.jsx)(`input`,{ref:p,id:`create-workflow-name`,value:r,onChange:e=>{i(e.target.value),f(void 0)},onBlur:()=>c(!0),required:!0,maxLength:160,"aria-invalid":!!m,"aria-describedby":m?`create-workflow-name-help create-workflow-name-error`:`create-workflow-name-help`,className:`mt-1.5 h-9 w-full rounded-sm border border-slate-700 bg-[#0e1116] px-3 text-sm text-slate-100 outline-none focus:border-[#11a4d4] focus:ring-1 focus:ring-[#11a4d4]`}),(0,W.jsx)(`div`,{id:`create-workflow-name-help`,className:`mt-1 text-[11px] text-slate-500`,children:`Maximum 160 characters.`}),m?(0,W.jsx)(`div`,{id:`create-workflow-name-error`,className:`mt-1 text-[11px] text-red-300`,role:`alert`,children:m}):null]}),d?(0,W.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/30 px-3 py-2 text-xs text-red-200`,role:`alert`,children:d}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-slate-800 pt-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,disabled:l,className:`h-8 rounded-sm border border-slate-700 px-3 text-xs text-slate-300 hover:border-slate-500 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`submit`,disabled:l,className:`inline-flex h-8 items-center gap-2 rounded-sm bg-[#11a4d4] px-3 text-xs font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50`,children:[l?(0,W.jsx)(Rc,{size:13,className:`animate-spin`}):null,`Create workflow`]})]})]})})}function g4e(e){let t=e.trim();if(!t)return`Enter a workflow name.`;if(t.length>160)return`Workflow name must be 160 characters or fewer.`}var _4e=`workflow-picker-results`,v4e=e=>`workflow-picker-option-${e}`;function y4e({draftId:e,onNavigateDraft:t}){let[n,r]=(0,U.useState)([]),[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(`loading`),[v,y]=(0,U.useState)(`idle`),[b,x]=(0,U.useState)(),[S,C]=(0,U.useState)(),[w,T]=(0,U.useState)(),E=(0,U.useRef)(null),D=(0,U.useRef)(null),O=(0,U.useCallback)(async()=>{_(`loading`);try{let e=await Gze();r(e.workflows),_(`loaded`)}catch(e){T(e instanceof Error?e.message:`Failed to load workflows`),_(`error`)}},[]);(0,U.useEffect)(()=>{O()},[O]),(0,U.useEffect)(()=>{if(!e){a(void 0),y(`idle`);return}let t=!1;return s(void 0),y(`loading`),T(void 0),Xze(e).then(e=>{t||(a(e.draft),y(`loaded`))}).catch(e=>{t||(a(void 0),y(`error`),T(e instanceof Error?e.message:`Failed to load workflow draft`))}),()=>{t=!0}},[e]),(0,U.useEffect)(()=>{function e(e){E.current?.contains(e.target)||(d(!1),p(void 0))}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]);let k=(0,U.useMemo)(()=>n.map(S4e),[n]),A=i?.workflowId??o?.workflowId,j=A?k.find(e=>e.workflowId===A):void 0,M=(0,U.useMemo)(()=>{let e=c.trim().toLowerCase().split(/\s+/).filter(Boolean);return!e.length||j?.label===c?k:k.filter(t=>e.every(e=>t.searchText.includes(e)))},[k,c,j]),N=f!==void 0&&f<M.length?f:void 0;(0,U.useEffect)(()=>{j&&!u&&l(j.label)},[u,j]),(0,U.useEffect)(()=>{D.current?.scrollIntoView({block:`nearest`})},[N]);let P=async e=>{if(!e.latestPublishedVersion)throw Error(`This workflow has no draft or published version to open.`);let t=await Kze(e.workflowId,e.latestPublishedVersion),n=new Date().toISOString();a(void 0),s({workflowId:e.workflowId,workflowVersion:e.latestPublishedVersion,title:t.workflow.title||e.label,source:t.workflow.source,draft:{draftId:`readonly_${e.workflowId}_${e.latestPublishedVersion}`,workflowId:e.workflowId,source:`ui`,status:`draft`,versionIntent:`patch`,definition:t.definition,diagnostics:t.diagnostics,validationState:t.validation.validationState,validation:t.validation,revision:0,createdAt:n,updatedAt:n}})},F=async e=>{x(`select`),d(!1),p(void 0),C(void 0),T(void 0);try{if(e.activeDraftId){s(void 0),t(e.activeDraftId);return}await P(e),C(`Opened ${e.label} as read-only.`)}catch(e){T(e instanceof Error?e.message:`Failed to select workflow`)}finally{x(void 0)}},ee=async e=>{x(`new`),C(void 0),T(void 0);try{let n=await Yze({title:e});s(void 0),C(`Created workflow ${n.draft.workflowId}.`),await O(),t(n.draft.draftId)}finally{x(void 0)}},I=async()=>{if(o){x(`duplicate`),C(void 0),T(void 0);try{let e=await Qze(o.workflowId,{version:o.workflowVersion});s(void 0),C(`Duplicated ${o.title}.`),await O(),t(e.draft.draftId)}catch(e){T(e instanceof Error?e.message:`Failed to duplicate workflow`)}finally{x(void 0)}}},L=async()=>{if(i){x(`save`),C(void 0),T(void 0);try{let e=await I3(i.draftId,{definition:i.definition,editTrigger:`graph_edit`});a(e.draft),C(e.message??`Saved ${i.workflowId}.`),await O()}catch(e){T(e instanceof Error?e.message:`Failed to save workflow`)}finally{x(void 0)}}},R=e=>{if(e.key===`Escape`&&u){e.preventDefault(),d(!1),p(void 0);return}if(e.key===`Enter`&&u&&N!==void 0&&!b){e.preventDefault(),F(M[N]);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),d(!0),!M.length){p(void 0);return}p(t=>{let n=t!==void 0&&t<M.length?t:void 0;return n===void 0?e.key===`ArrowDown`?0:M.length-1:e.key===`ArrowDown`?(n+1)%M.length:(n-1+M.length)%M.length})}},te=(0,U.useCallback)(e=>{a(t=>t&&{...t,definition:e})},[]),z=(0,U.useCallback)(e=>{a(e),O()},[O]),ne=(0,U.useCallback)((e,t=`status`)=>{if(t===`error`){T(e);return}T(void 0),C(e)},[]),re=g===`loading`||v===`loading`,ie=j?.label??o?.title??(i?i.workflowId:`No workflow selected`),B=i??o?.draft,ae=w??(b?b4e(b):re?`Loading workflow surface…`:S??`Ready`),oe=w?`error`:b||re?`busy`:`status`;return(0,W.jsxs)(`main`,{className:`@container flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#101d22] text-slate-200`,"aria-label":`Workflows`,children:[(0,W.jsx)(h4e,{open:m,onClose:()=>h(!1),onCreate:ee}),(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 flex-wrap items-center gap-2 border-b border-slate-800 bg-[#151f24] px-3 py-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-sm border border-[#11a4d4]/60 text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>h(!0),disabled:!!b,title:`Create workflow`,"aria-label":`Create workflow`,children:b===`new`?(0,W.jsx)(Rc,{size:15,className:`animate-spin`}):(0,W.jsx)(al,{size:15})}),(0,W.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-64`,ref:E,children:[(0,W.jsxs)(`div`,{className:`flex h-9 min-w-0 items-center gap-2 rounded-sm border border-slate-700 bg-[#101d22] px-2 focus-within:border-[#11a4d4]`,children:[(0,W.jsx)(ml,{size:14,className:`shrink-0 text-slate-500`}),(0,W.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-sm text-slate-100 outline-none placeholder:text-slate-600`,value:c,onFocus:()=>{d(!0);let e=M.findIndex(e=>e.workflowId===A);p(e>=0?e:void 0)},onChange:e=>{l(e.target.value),d(!0),p(void 0)},onKeyDown:R,placeholder:`Search workflows by name, id, tag, status…`,"aria-label":`Search workflows`,role:`combobox`,"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-expanded":u,"aria-controls":_4e,"aria-activedescendant":u&&N!==void 0?v4e(N):void 0})]}),u?(0,W.jsxs)(`div`,{id:_4e,className:`absolute left-0 right-0 top-full z-40 mt-1 max-h-80 overflow-auto rounded-sm border border-slate-700 bg-[#151f24] p-1 shadow-2xl`,role:`listbox`,"aria-label":`Workflow results`,children:[g===`loading`?(0,W.jsx)(T4e,{children:`Loading workflows…`}):null,g===`loaded`&&M.length===0?(0,W.jsx)(T4e,{children:`No workflows match this search.`}):null,M.map((e,t)=>(0,W.jsxs)(`button`,{id:v4e(t),ref:t===N?D:null,type:`button`,className:`flex w-full items-start justify-between gap-3 rounded-sm px-3 py-2 text-left text-xs transition hover:bg-slate-800/80 ${t===N||N===void 0&&A===e.workflowId?`bg-[#11a4d4]/10 text-[#8bdcf4]`:`text-slate-300`}`,onClick:()=>void F(e),onFocus:()=>p(t),onPointerMove:()=>p(t),disabled:!!b,role:`option`,"aria-selected":N===void 0?A===e.workflowId:t===N,children:[(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate font-semibold`,children:e.label}),(0,W.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-slate-500`,children:e.description})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${e.activeDraftId?`border-emerald-700/60 text-emerald-300`:`border-amber-700/60 text-amber-300`}`,children:e.activeDraftId?`draft`:`read only`})]},e.workflowId))]}):null]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 shrink-0 items-center justify-center gap-2 rounded-sm border border-emerald-700/70 px-3 text-xs font-semibold uppercase tracking-wide text-emerald-200 transition hover:border-emerald-400 hover:text-emerald-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void L(),disabled:!i||!!b,children:[b===`save`?(0,W.jsx)(Rc,{size:14,className:`animate-spin`}):(0,W.jsx)(fl,{size:14}),`Save`]})]}),o?(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-amber-700/50 bg-amber-950/20 px-3 py-1.5 text-xs text-amber-100`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 truncate`,children:[(0,W.jsx)(`span`,{className:`mr-2 rounded-sm border border-amber-500/60 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wide text-amber-200`,children:`Read only`}),o.title,` · `,o.workflowId,`@`,o.workflowVersion]}),(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-2 rounded-sm border border-amber-500/60 px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-amber-100 hover:border-amber-300 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void I(),disabled:!!b,children:[b===`duplicate`?(0,W.jsx)(Rc,{size:12,className:`animate-spin`}):(0,W.jsx)(cc,{size:12}),`Duplicate`]})]}):null,(0,W.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden p-3`,children:B?(0,W.jsx)(a2e,{draft:B,onDraftChange:o?()=>void 0:z,fullHeight:!0,compactHeader:!0,readOnly:!!o,onDraftDefinitionChange:o?void 0:te,onStatusMessage:o?void 0:ne,renderInspectors:e=>o?(0,W.jsx)(w4e,{...e}):(0,W.jsx)(n4e,{...e})}):(0,W.jsx)(`div`,{className:`grid h-full min-w-0 place-items-center rounded-sm border border-dashed border-slate-700 bg-[#151f24]/50 p-6 text-center`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-lg font-bold text-slate-100`,children:ie}),(0,W.jsx)(`p`,{className:`mt-2 max-w-xl text-sm leading-6 text-slate-500`,children:`Create a workflow with the plus button or search and select an existing workflow above. Published and built-in workflows open read-only and can be duplicated before editing.`})]})})}),(0,W.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 border-t px-3 text-[11px] ${x4e(oe)}`,role:w?`alert`:`status`,"aria-label":`Workflow editor status`,children:[(0,W.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${oe===`error`?`bg-red-400`:oe===`busy`?`animate-pulse bg-[#11a4d4]`:`bg-emerald-400`}`}),(0,W.jsx)(`span`,{className:`shrink-0 font-bold uppercase tracking-[0.16em]`,children:`Status`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px]`,children:ae})]})]})}function b4e(e){return e===`new`?`Creating workflow…`:e===`select`?`Opening workflow…`:e===`duplicate`?`Duplicating workflow…`:`Saving workflow…`}function x4e(e){return e===`error`?`border-red-900/70 bg-red-950/30 text-red-200`:e===`busy`?`border-slate-800 bg-[#0f1b20] text-[#8bdcf4]`:`border-slate-800 bg-[#0f1b20] text-slate-400`}function S4e(e){let t=C4e(e.versions),n=e.tags.join(`, `),r=[e.id,e.status,e.source,n].filter(Boolean),i=[e.id,e.title,e.description,e.status,e.source,n,t?.version].filter(e=>!!e);return{workflowId:e.id,label:e.title||e.id,description:r.join(` · `),...e.activeDraftId?{activeDraftId:e.activeDraftId}:{},...t?{latestPublishedVersion:t.version}:{},searchText:i.join(` `).toLowerCase()}}function C4e(e){return[...e].reverse().find(e=>e.status===`published`)}function w4e({draft:e,selectedElement:t}){let n=N7(e.definition),r=P7(e.definition),i=t?.type===`node`?n[t.id]:t?.type===`edge`?r[t.id]:e.definition,a=t?`${t.type} ${t.id}`:`Workflow definition`;return(0,W.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Read-only workflow details`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Read-only details`}),(0,W.jsx)(`div`,{className:`mt-2 truncate text-xs font-semibold text-slate-200`,children:a}),(0,W.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-sm border border-slate-800 bg-[#0c171c] p-2 text-[11px] leading-5 text-slate-300`,children:JSON.stringify(i??{},null,2)})]})}function T4e({children:e}){return(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-500`,children:e})}function E4e(e){return e.viewWorkflowId&&e.viewWorkflowVersion?{workflowId:e.viewWorkflowId,workflowVersion:e.viewWorkflowVersion}:void 0}function D4e({workflowId:e,workflowVersion:t,surface:n=`desktop`}){return(0,W.jsx)(`main`,{className:`h-full min-h-0 overflow-auto bg-[#101d22] p-6 max-[720px]:p-4`,"data-pibo-debug":`${n}-workflow-version-viewer`,children:(0,W.jsx)(`div`,{className:`mx-auto w-full max-w-4xl`,children:(0,W.jsx)($2e,{workflowId:e,workflowVersion:t})})})}function O4e({route:e,surface:t,fallback:n}){let r=E4e(e);return r?(0,W.jsx)(D4e,{...r,surface:t}):n}var k4e=50,A4e=6e4,j4e=[`.vs`,`.vs-dark`,`.hc-black`,`.hc-light`];function M4e(e){return!!(e?.querySelector(`.monaco-workbench`)&&j4e.some(t=>e.querySelector(t)))}function N4e(e,t,n=`http://localhost/`){let r=new URL(e,n);if(r.origin!==new URL(n).origin)throw Error(`VS Code Web URL must use the Pibo Chat origin.`);return t?r.searchParams.set(`folder`,t):r.searchParams.delete(`folder`),`${r.pathname}${r.search}${r.hash}`}function P4e({integration:e}){let[t,n]=(0,U.useState)(`checking`),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(0),l=(0,U.useRef)(null),u=(0,U.useRef)(null),d=(0,U.useMemo)(()=>e?N4e(e.url,e.workspaceRoot||void 0,window.location.href):``,[e?.url,e?.workspaceRoot]);return(0,U.useEffect)(()=>{if(!d){n(`unavailable`),i(`VS Code Web is not configured for this Pibo gateway.`);return}let e=new URL(d,window.location.href),t=new AbortController;return n(`checking`),i(null),fetch(e.toString(),{method:`GET`,credentials:`same-origin`,cache:`no-store`,headers:{accept:`text/html`},signal:t.signal}).then(e=>{let t=e.headers.get(`content-type`)??``;if(!e.ok||!t.toLowerCase().includes(`text/html`))throw Error(`VS Code Web returned HTTP ${e.status}.`);n(`ready`)}).catch(e=>{t.signal.aborted||(n(`unavailable`),i(e instanceof Error?e.message:String(e)))}),()=>t.abort()},[d,s]),(0,U.useEffect)(()=>(o(!1),u.current!==null&&(window.clearTimeout(u.current),u.current=null),()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)}),[d]),e?(0,W.jsx)(`main`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#101d22]`,"aria-label":`VS Code Web`,children:(0,W.jsx)(`div`,{className:`relative min-h-0 flex-1 bg-[#101d22]`,children:t===`ready`?(0,W.jsxs)(W.Fragment,{children:[a?null:(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center bg-[#101d22]`,role:`status`,"aria-live":`polite`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-slate-300`,children:[(0,W.jsx)(cl,{size:16,className:`animate-spin text-[#11a4d4]`}),`Starting VS Code…`]})}),(0,W.jsx)(`iframe`,{ref:l,src:d,title:`VS Code Web`,allow:`clipboard-read; clipboard-write`,onLoad:()=>{u.current!==null&&window.clearTimeout(u.current),o(!1);let e=Date.now(),t=()=>{let r=!1;try{let e=l.current?.contentDocument;r=M4e(e)}catch{r=!1}if(r){u.current=window.setTimeout(()=>{o(!0),u.current=null},100);return}if(Date.now()-e>=A4e){u.current=null,n(`unavailable`),i(`VS Code Web did not finish starting.`);return}u.current=window.setTimeout(t,k4e)};t()},"aria-hidden":!a,tabIndex:a?0:-1,className:`h-full w-full border-0 bg-[#101d22] ${a?`visible`:`invisible`}`},d)]}):t===`checking`?(0,W.jsx)(`div`,{className:`grid h-full place-items-center bg-[#101d22] text-sm text-slate-400`,children:`Connecting to VS Code Web…`}):(0,W.jsx)(`div`,{className:`grid h-full place-items-center p-6`,children:(0,W.jsxs)(`div`,{className:`max-w-lg border border-orange-500/40 bg-orange-500/10 p-5 text-sm text-slate-300 rounded-sm`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-bold uppercase tracking-wider text-orange-300`,children:[(0,W.jsx)(gl,{size:16}),` VS Code Web is not reachable`]}),(0,W.jsx)(`p`,{className:`mt-3 break-words text-slate-400`,children:r??`The embedded IDE did not respond.`}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>e+1),className:`mt-4 inline-flex items-center gap-2 rounded-sm bg-[#11a4d4] px-3 py-2 text-xs font-bold uppercase tracking-wider text-white`,children:[(0,W.jsx)(cl,{size:14}),` Retry`]})]})})})}):(0,W.jsx)(`main`,{className:`grid min-h-0 place-items-center bg-[#101d22] p-6`,"aria-label":`VS Code Web`,children:(0,W.jsxs)(`div`,{className:`max-w-lg border border-slate-700 bg-[#1a262b] p-5 text-sm text-slate-300 rounded-sm`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-slate-100 font-bold uppercase tracking-wider`,children:[(0,W.jsx)(gl,{size:16,className:`text-orange-400`}),` VS Code Web unavailable`]}),(0,W.jsxs)(`p`,{className:`mt-3 text-slate-400`,children:[`Configure `,(0,W.jsx)(`code`,{className:`text-slate-200`,children:`PIBO_VSCODE_WEB_URL`}),` on the gateway to enable the embedded IDE.`]})]})})}var j9=`Delete this session`;function F4e({session:e,confirmText:t,deleting:n,onConfirmTextChange:r,onCancel:i,onDelete:a}){let o=(0,U.useRef)(null);return(0,W.jsx)(rQ,{title:`Delete Session`,description:e.piboSessionId,onClose:i,initialFocusRef:o,closeLabel:`Cancel session deletion`,closeDisabled:n,children:(0,W.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,W.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived session, its child sessions, and their Chat events. This cannot be undone.`}),(0,W.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-red-200`,children:j9}),` to confirm.`]}),(0,W.jsx)(`input`,{ref:o,value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:j9}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==j9,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,W.jsx)(El,{size:14}),`Delete permanently`]})]})]})})}function I4e({room:e,confirmName:t,deleting:n,onConfirmNameChange:r,onCancel:i,onDelete:a}){let o=(0,U.useRef)(null);return(0,W.jsx)(rQ,{title:`Delete Room`,description:e.id,onClose:i,initialFocusRef:o,closeLabel:`Cancel room deletion`,closeDisabled:n,children:(0,W.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,W.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived room, child rooms, all contained sessions, subagent sessions, and their Chat events. This cannot be undone.`}),(0,W.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,W.jsx)(`span`,{className:`font-mono text-red-200`,children:e.name}),` to confirm.`]}),(0,W.jsx)(`input`,{ref:o,value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:e.name}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,W.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==e.name,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,W.jsx)(El,{size:14}),`Delete permanently`]})]})]})})}function L4e(e,t){return P9(e,e=>Y4e(t.sessions[e]))}function R4e(e,t){return P9(e,e=>X4e(t.sessions[e]))}function M9(e,t){return!!e?.sessions[t]}function z4e(e,t){return M9(e,t)?e:null}function B4e(e,t,n){if(!M9(e,t))return!0;let r=e.sessions[t];return r.isTreeActive||r.latestTurn?.state===`running`||n===`running`}function V4e(e,t,n){return M9(t,n)?e?.rootPiboSessionId!==t.rootPiboSessionId||e.version<=t.version:!1}function H4e(e,t,n){if(!M9(e,n))return{snapshot:e,needsRefresh:!0};let r=Z4e(e,t);return{snapshot:r,needsRefresh:r===e}}function U4e(e,t){let n=new Map(t.sessionSnapshots.map(e=>[e.piboSessionId,Y4e(e)]));return P9(e,e=>n.get(e))}function W4e(e,t){let n=new Map(t.sessionStatuses.map(e=>[e.piboSessionId,X4e(e)]));return P9(e,e=>n.get(e))}function N9(e,t){if(!e)return!0;let n=Date.parse(e.generatedAt),r=Date.parse(t.generatedAt);return Number.isFinite(n)&&Number.isFinite(r)?n<=r:Object.entries(e.rootVersions).every(([e,n])=>(t.rootVersions[e]??-1)>=n)}function G4e(e,t){if(!e||(e.rootVersions[t.rootPiboSessionId]??0)!==t.fromVersion)return{snapshot:e,needsRefresh:!0};let n={...e.sessions};for(let e of t.sessionStatuses)n[e.piboSessionId]=e;return{snapshot:{...e,generatedAt:t.generatedAt,rootVersions:{...e.rootVersions,[t.rootPiboSessionId]:t.toVersion},sessions:n},needsRefresh:!1}}function P9(e,t){return{...e,sessions:e.sessions.map(e=>K4e(e,t))}}function K4e(e,t){let n=t(e.piboSessionId),r=J4e(n,q4e(e)),i=r&&r!==e.status?I9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):I9(e.lastActivityAt,n?.updatedAt);return{...e,status:r??e.status,lastActivityAt:i,children:e.children.map(e=>K4e(e,t)),derivedSessions:e.derivedSessions.map(e=>{let n=t(e.piboSessionId),r=J4e(n,0),i=!!(r&&r!==e.status);return{...e,status:r??e.status,lastActivityAt:i?I9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):I9(e.lastActivityAt,n?.updatedAt)}})}}function q4e(e){return(e.unreadCount??0)+e.children.reduce((e,t)=>e+q4e(t),0)}function J4e(e,t){return e?.isTreeActive?`running`:e?.status===`error`?t>0?`error`:`idle`:e?.status}function Y4e(e){let t=F9(e);if(!(!e&&!t))return{status:t,updatedAt:e?.updatedAt,isTreeActive:e?.isTreeActive}}function X4e(e){return e?{status:e.status,updatedAt:e.updatedAt,isTreeActive:e.isTreeActive}:void 0}function F9(e){return e?f3(e).status:void 0}function I9(...e){let t,n=-1/0;for(let r of e){if(!r)continue;let e=Date.parse(r);!Number.isFinite(e)||e<n||(t=r,n=e)}return t}function Z4e(e,t){if(!e||e.rootPiboSessionId!==t.rootPiboSessionId||e.version!==t.fromVersion)return e;let n={...e.nodes};for(let e of t.removes)delete n[e];for(let e of t.upserts)n[e.id]=e;let r={...e.sessions};for(let e of t.sessionSnapshots)r[e.piboSessionId]=e;return{...e,version:t.toVersion,generatedAt:t.generatedAt,nodes:n,sessions:r}}function Q4e(e,t,n={}){let r=n.readSessionId?e3e(e.sessions,n.readSessionId):new Set,i=new Map;L9(e.sessions,i);let a=[...r].reduce((e,t)=>e+(i.get(t)??0),0);return{...e,identity:t.identity,session:t.session,room:t.room,selectedRoomId:t.selectedRoomId,selectedPiboSessionId:t.selectedPiboSessionId,latestRoomStreamId:t.latestRoomStreamId,rooms:r3e(e.rooms,t.rooms,t.selectedRoomId,a),sessions:e.selectedRoomId===t.selectedRoomId?n3e(e.sessions,R9(t.sessions,r,i)):R9(t.sessions,r,i)}}function $4e(e,t,n=e.selectedRoomId){let r=e3e(e.sessions,t),i=new Map;L9(e.sessions,i);let a=[...r].reduce((e,t)=>e+(i.get(t)??0),0);return{...e,selectedRoomId:n,selectedPiboSessionId:t,rooms:r3e(e.rooms,e.rooms,n,a),sessions:R9(e.sessions,r,i)}}function L9(e,t){for(let n of e)t.set(n.piboSessionId,n.unreadCount??0),L9(n.children,t)}function e3e(e,t){let n=new Set,r=e=>e.piboSessionId===t?(t3e(e,n),!0):e.children.some(e=>r(e));for(let t of e)r(t);return n}function t3e(e,t){t.add(e.piboSessionId);for(let n of e.children)t3e(n,t)}function n3e(e,t){let n=e.filter(e=>e.piSessionId===`pending`);if(!n.length)return t;let r=new Set(t.map(e=>e.piboSessionId)),i=n.filter(e=>!r.has(e.piboSessionId));return i.length?[...i,...t]:t}function R9(e,t,n){return e.map(e=>{let r=n.get(e.piboSessionId),i=t.has(e.piboSessionId)?0:e.unreadCount??r??0;return{...e,...i>0?{unreadCount:i}:{unreadCount:void 0},children:R9(e.children,t,n)}})}function r3e(e,t,n,r){let i=new Map;return i3e(e,i),a3e(t,i,n,r).rooms}function i3e(e,t){for(let n of e)t.set(n.id,n.unreadCount??0),i3e(n.children??[],t)}function a3e(e,t,n,r){let i=!1;return{rooms:e.map(e=>{let a=a3e(e.children??[],t,n,r),o=e.id===n||a.selectedRoomFound;i||=o;let s=e.unreadCount??t.get(e.id)??0,c=o&&r>0?Math.max(0,s-r):s;return{...e,...c>0?{unreadCount:c}:{unreadCount:void 0},...e.children?{children:a.rooms}:{}}}),selectedRoomFound:i}}function o3e(e,t){if(!t.length)return e;let n=new Set(e.map(e=>e.piboSessionId)),r=t.filter(e=>!n.has(e.piboSessionId));return r.length?[...e,...r]:e}function s3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,mcpServers:e.agentCatalog.mcpServers.map(e=>e.name===t.name?t:e)}}:e}function c3e(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.piPackages.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,piPackages:f3e([...n,t])}}}function l3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,piPackages:e.agentCatalog.piPackages.filter(e=>e.id!==t)}}:e}function u3e(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.userSkills.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,userSkills:f3e([...n,t])}}}function d3e(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,userSkills:e.agentCatalog.userSkills.filter(e=>e.id!==t)}}:e}function f3e(e){return e.sort((e,t)=>e.name.localeCompare(t.name))}function p3e(e,t){let n=WUe(e);return{deletedSessionIds:n,selectedSessionDeleted:t?n.has(t):!1,restoreSelectedPiboSessionId:t}}function m3e(e,t,n){return t?e.includes(t):n}function h3e(e,t){return t?void 0:e??void 0}function g3e(e,t,n){let r=eWe(e);return{deletedRoomIds:r,selectedRoomDeleted:t?r.has(t):!1,restoreSelectedRoomId:t,restoreSelectedPiboSessionId:n}}function _3e(e,t){return t===e}function v3e({queryClient:e,bootstrap:t,selectedPiboSessionId:n,selectedRoomId:r,showArchivedRef:i,isSessionsArea:a,loadBootstrap:o,navigateToSelectedSession:s,updateBootstrapCache:c,restoreBootstrapSnapshot:l,setSelectedPiboSessionId:u,setSelectedRoomId:d,setError:f}){let[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(null),[x,S]=(0,U.useState)(``),[C,w]=(0,U.useState)(!1),T=e=>{b(e),S(``)},E=()=>{b(null),S(``)},D=async()=>{if(!y)return;w(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let d=L6(e,t),p=p3e(y,n);p.selectedSessionDeleted&&u(null),c(e=>UUe(e,p.deletedSessionIds));try{let e=m3e((await tu(y.piboSessionId,x)).deletedSessionIds,n,p.selectedSessionDeleted);e&&u(null);let t=await o(h3e(n,e),i.current,r??void 0,{force:!0});a&&s(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),E(),f(null)}catch(e){l(d),p.selectedSessionDeleted&&u(p.restoreSelectedPiboSessionId),f(e instanceof Error?e.message:String(e))}finally{w(!1)}},O=e=>{m(e),g(``)},k=()=>{m(null),g(``)};return{deleteRoomTarget:p,deleteRoomConfirmName:h,deletingRoom:_,setDeleteRoomConfirmName:g,requestRoomDelete:O,cancelRoomDelete:k,permanentlyDeleteRoom:async()=>{if(!p)return;v(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let m=L6(e,t),g=g3e(p,r,n);g.selectedRoomDeleted&&(d(null),u(null)),c(e=>XUe(e,g.deletedRoomIds));try{await $l(p.id,h);for(let e of g.deletedRoomIds)QX(e),lZ(e);_3e(p.id,r)&&(d(null),u(null));let e=await o(void 0,i.current,void 0,{force:!0});a&&s(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),k(),f(null)}catch(e){l(m),g.selectedRoomDeleted&&(d(g.restoreSelectedRoomId),u(g.restoreSelectedPiboSessionId)),f(e instanceof Error?e.message:String(e))}finally{v(!1)}},deleteSessionTarget:y,deleteSessionConfirmText:x,deletingSession:C,setDeleteSessionConfirmText:S,requestSessionDelete:T,cancelSessionDelete:E,permanentlyDeleteSession:D}}function y3e(e){return!e.replayFrame&&e.eventRefreshesNavigation&&(!e.selectedBackendPiboSessionId||e.targetPiboSessionId!==e.selectedBackendPiboSessionId)}function b3e(e){if(e.area!==`sessions`||!e.activeRoomId||e.bootstrapSelectedRoomId!==e.activeRoomId||typeof e.latestRoomStreamId!=`number`||!Number.isFinite(e.latestRoomStreamId)||e.latestRoomStreamId<=0)return null;let t=new URLSearchParams({roomId:e.activeRoomId});return t.set(`mode`,`summary`),t.set(`since`,`${e.latestRoomStreamId}:999999`),`/api/chat/events?${t.toString()}`}var x3e=`pibo.chat.desktopTabs.v1`,S3e=3840;function z9(){return{version:1,tabs:[],activeTabId:null,width:520,collapsed:!1}}function B9(e){if(e.kind===`new-tab`)return`new-tab:${e.instanceId}`;if(e.kind===`session-tool`)return`tool:${e.tool}`;let t=e.route;return t.area===`projects`?t.projectId?`projects:${t.projectId}`:`projects`:t.area===`workflows`?t.draftId?`workflows:draft:${t.draftId}`:t.viewWorkflowId&&t.viewWorkflowVersion?`workflows:view:${t.viewWorkflowId}:${t.viewWorkflowVersion}`:`workflows`:`route:${t.area}`}function V9(e){if(e.kind===`new-tab`)return`New Tab`;if(e.kind===`session-tool`)return e.tool===`preview`?`Preview`:e.tool===`raw-events`?`Raw Events`:e.tool===`web-annotations`?`Annotations`:e.tool===`runtime-requests`?`Runtime Requests`:`Session Inspector`;let t=e.route;return t.area===`vscode`?`VS Code`:t.area===`cron`?`Cron`:t.area===`loops`?`Loops`:t.area===`agents`?`Agent Designer`:t.area===`context`?`Context`:t.area===`settings`?`Settings`:t.area===`projects`?t.projectId?`Project · ${t.projectId}`:`Projects`:t.draftId?`Workflow · ${t.draftId}`:t.viewWorkflowId?`Workflow · ${t.viewWorkflowId}`:`Workflows`}function C3e(e){return e.area===`sessions`?null:{kind:`route`,route:e}}function H9(e,t,n={}){let r=n.now??Date.now(),i=B9(t),a=e.tabs.findIndex(e=>B9(e.target)===i);if(a>=0){let n=e.tabs[a],i=e.tabs.slice();return i[a]={...n,target:t,title:V9(t),lastActivatedAt:r},{...e,tabs:i,activeTabId:n.id,collapsed:!1}}let o=n.id??q3e(),s={id:o,target:t,title:V9(t),createdAt:r,lastActivatedAt:r},c=e.tabs.length>=24?e.tabs.slice(-23):e.tabs;return{...e,tabs:[...c,s],activeTabId:o,collapsed:!1}}function w3e(e,t={}){let n=t.id??q3e();return H9(e,{kind:`new-tab`,instanceId:n},{...t,id:n})}function T3e(e,t,n,r=Date.now()){let i=e.tabs.findIndex(e=>e.id===t&&e.target.kind===`new-tab`);if(i<0)return H9(e,n,{now:r});let a=B9(n);if(e.tabs.find(e=>e.id!==t&&B9(e.target)===a))return H9(D3e(e,t),n,{now:r});let o=e.tabs.slice();return o[i]={...o[i],target:n,title:V9(n),lastActivatedAt:r},{...e,tabs:o,activeTabId:t,collapsed:!1}}function E3e(e,t,n=Date.now()){return e.activeTabId===t&&!e.collapsed||!e.tabs.some(e=>e.id===t)?e:{...e,activeTabId:t,collapsed:!1,tabs:e.tabs.map(e=>e.id===t?{...e,lastActivatedAt:n}:e)}}function D3e(e,t){let n=e.tabs.findIndex(e=>e.id===t);if(n<0)return e;let r=e.tabs.filter(e=>e.id!==t);if(e.activeTabId!==t)return{...e,tabs:r};let i=r[n]??r[n-1]??null;return{...e,tabs:r,activeTabId:i?.id??null,collapsed:r.length?e.collapsed:!1}}function O3e(e,t,n){let r=e.tabs.findIndex(e=>e.id===t);if(r<0||e.tabs.length<2)return e;let i=Math.max(0,Math.min(e.tabs.length-1,n));if(i===r)return e;let a=e.tabs.slice(),[o]=a.splice(r,1);return a.splice(i,0,o),{...e,tabs:a}}function k3e(e,t,n){let r=e.tabs.findIndex(e=>e.id===t);return r<0?e:O3e(e,t,r+n)}function A3e(e,t){return{...e,width:U9(t)}}function U9(e){return Number.isFinite(e)?Math.round(Math.max(360,Math.min(S3e,e))):520}function W9(e){return e.tabs.find(t=>t.id===e.activeTabId)??null}function j3e(e){return e.target.kind===`new-tab`?!1:e.target.kind===`session-tool`?e.target.tool===`preview`:e.target.route.area===`vscode`}function M3e(e,t){let n=W9(e);return n?.target.kind===`route`?n.target.route:t}function N3e(e,t){return e?.target.kind===`route`&&e.target.route.area===`agents`&&e.id!==t}async function P3e(e,t){if(!e||!t)return{allowed:!0};try{return await t(),{allowed:!0}}catch(e){return{allowed:!1,error:e}}}async function F3e({current:e,next:t,sessionsRoute:n,closingTab:r,autosave:i,onCommit:a,onNavigate:o}){let s=W9(e),c=await P3e(!!(r?.target.kind===`route`&&r.target.route.area===`agents`||N3e(s,t.activeTabId)),i);if(!c.allowed)return c;let l=M3e(e,n),u=M3e(t,n);return a(t),JSON.stringify(l)!==JSON.stringify(u)&&o(u),{allowed:!0}}function I3e(e,t,n={}){let r=C3e(t);return r?{...H9(e,r,n),collapsed:e.collapsed}:e}function L3e(e){return JSON.stringify({...e,width:U9(e.width),tabs:e.tabs.slice(0,24),activeTabId:e.tabs.some(t=>t.id===e.activeTabId)?e.activeTabId:null})}function R3e(e){if(!e)return z9();try{let t=JSON.parse(e);if(!G9(t)||t.version!==1||!Array.isArray(t.tabs))return z9();let n=t.tabs.slice(0,24).map(V3e).filter(e=>e!==null),r=[],i=new Set,a=new Map,o=new Map;for(let e of n){let t=B9(e.target),n=a.get(t);if(i.has(e.id)||n){o.set(e.id,n??e.id);continue}r.push(e),i.add(e.id),a.set(t,e.id),o.set(e.id,e.id)}let s=typeof t.activeTabId==`string`?o.get(t.activeTabId):void 0;return{version:1,tabs:r,activeTabId:s&&r.some(e=>e.id===s)?s:r[0]?.id??null,width:U9(typeof t.width==`number`?t.width:520),collapsed:t.collapsed===!0&&r.length>0}}catch{return z9()}}function z3e(e=K3e()){try{return R3e(e?.getItem(x3e))}catch{return z9()}}function B3e(e,t=K3e()){try{t?.setItem(x3e,L3e(e))}catch{}}function V3e(e){if(!G9(e)||typeof e.id!=`string`||!e.id||!H3e(e.target))return null;let t=G3e(e.createdAt)??Date.now();return{id:e.id,target:e.target,title:typeof e.title==`string`&&e.title.trim()?e.title:V9(e.target),createdAt:t,lastActivatedAt:G3e(e.lastActivatedAt)??t}}function H3e(e){return G9(e)?e.kind===`new-tab`?typeof e.instanceId==`string`&&!!e.instanceId:e.kind===`session-tool`?U3e(e.tool):e.kind===`route`&&G9(e.route)&&W3e(e.route):!1}function U3e(e){return e===`preview`||e===`raw-events`||e===`web-annotations`||e===`runtime-requests`||e===`session-inspector`}function W3e(e){return e.area===`vscode`||e.area===`agents`||e.area===`cron`||e.area===`loops`||e.area===`projects`||e.area===`workflows`||e.area===`context`||e.area===`settings`}function G3e(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function G9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function K3e(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function q3e(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`tab-${crypto.randomUUID()}`:`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function J3e(e,t,n,r){let i=e.filter(e=>e.id!==t),a=i.findIndex(e=>e.id===n);return a<0?Math.max(0,i.length):a+ +(r===`after`)}var Y3e=[{id:`preview`,label:`Preview`,description:`Live session preview`,icon:Sl,target:{kind:`session-tool`,tool:`preview`}},{id:`raw-events`,label:`Raw Events`,description:`Raw trace and event payloads`,icon:Bs,target:{kind:`session-tool`,tool:`raw-events`}},{id:`web-annotations`,label:`Web Annotations`,description:`Annotations attached to this session`,icon:Wc,target:{kind:`session-tool`,tool:`web-annotations`}},{id:`runtime-requests`,label:`Runtime Requests`,description:`Approvals and runtime input`,icon:Cl,target:{kind:`session-tool`,tool:`runtime-requests`}},{id:`session-inspector`,label:`Session Inspector`,description:`Session, signal, and runtime metadata`,icon:Ic,target:{kind:`session-tool`,tool:`session-inspector`}}];function X3e(e){return[{id:`sessions`,label:`Sessions`,description:`Focus the fixed Rooms and Sessions navigation`,icon:Mc,sessionsAction:!0},{id:`projects`,label:`Projects`,description:`Project workspaces and project sessions`,icon:bc,target:{kind:`route`,route:{area:`projects`}}},{id:`vscode`,label:`VS Code`,description:`Embedded workspace editor`,icon:sc,target:{kind:`route`,route:{area:`vscode`}}},{id:`workflows`,label:`Workflows`,description:`Workflow definitions and drafts`,icon:Ml,target:{kind:`route`,route:{area:`workflows`}}},{id:`cron`,label:`Cron`,description:`Scheduled jobs`,icon:oc,target:{kind:`route`,route:{area:`cron`}}},{id:`loops`,label:`Loops`,description:`Goal and legacy Ralph loops`,icon:wc,target:{kind:`route`,route:{area:`loops`}}},{id:`agents`,label:`Agent Designer`,description:`Agents, profiles, and capability selection`,icon:Sl,target:{kind:`route`,route:{area:`agents`}}},{id:`context`,label:`Context`,description:`Context files, prompts, and MCP tools`,icon:Bs,target:{kind:`route`,route:{area:`context`}}},{id:`settings`,label:`Settings`,description:`Chat and runtime settings`,icon:vl,target:{kind:`route`,route:{area:`settings`}}},...Y3e]}function Z3e(e,t){let[n,r]=(0,U.useState)(()=>z3e()),i=(0,U.useMemo)(()=>JSON.stringify(e),[e]);return(0,U.useEffect)(()=>{t&&r(t=>I3e(t,e))},[t,i]),(0,U.useEffect)(()=>{t&&B3e(n)},[t,n]),{state:n,setState:r}}function Q3e({state:e,vscodeEnabled:t,onStateChange:n,onActivate:r,onClose:i,onFocusSessions:a,renderPanel:o,reservedLeftWidth:s,hidden:c=!1,fullscreen:l=!1}){let u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null),p=(0,U.useRef)(new Map),m=(0,U.useRef)(null),[h,g]=(0,U.useState)(null),_=(0,U.useRef)(!1),v=W9(e),y=(0,U.useMemo)(()=>X3e(t),[t]);(0,U.useLayoutEffect)(()=>{v?.target.kind===`new-tab`&&d.current?.querySelector(`button[data-catalog-entry]`)?.focus()},[v?.id]),(0,U.useEffect)(()=>{e.collapsed||!v||p.current.get(v.id)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[v?.id,e.collapsed]),(0,U.useLayoutEffect)(()=>{_.current&&(_.current=!1,e.activeTabId?p.current.get(e.activeTabId)?.focus():u.current?.focus())},[e.activeTabId,e.tabs.length]);let b=(0,U.useCallback)(async e=>{_.current=!0,await i(e)||(_.current=!1)},[i]),x=e=>{let t=[...d.current?.querySelectorAll(`button[data-catalog-entry]`)??[]],n=t.indexOf(document.activeElement),r=-1;e.key===`ArrowDown`&&(r=n<0?0:(n+1)%t.length),e.key===`ArrowUp`&&(r=n<0?t.length-1:(n-1+t.length)%t.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=t.length-1),r>=0&&(e.preventDefault(),t[r]?.focus())},S=t=>{if(!(!v||v.target.kind!==`new-tab`)){if(t.sessionsAction){a(v);return}t.target&&n(T3e(e,v.id,t.target))}},C=t=>{let n=e.tabs[Math.max(0,Math.min(e.tabs.length-1,t))];n&&p.current.get(n.id)?.focus()},w=(t,i,a)=>{if(t.altKey&&t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){t.preventDefault();let r=t.key===`ArrowLeft`?-1:1;n(k3e(e,i.id,r)),window.setTimeout(()=>p.current.get(i.id)?.focus(),0);return}if(t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`){t.preventDefault(),t.key===`Home`?C(0):t.key===`End`?C(e.tabs.length-1):C((a+(t.key===`ArrowLeft`?-1:1)+e.tabs.length)%e.tabs.length);return}if(t.key===`Delete`){t.preventDefault(),b(i);return}(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(i))},T=t=>{t.preventDefault();let r=t.clientX,i=t.currentTarget.parentElement?.getBoundingClientRect().width??e.width,a=t=>n(A3e(e,i+r-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},E={"--pibo-desktop-tabs-width":`${e.width}px`,width:l?`100%`:e.collapsed?`44px`:`min(${e.width}px, max(0px, calc(100vw - ${s+250}px)))`};return(0,W.jsxs)(`aside`,{"data-pibo-debug":`desktop-tab-sidebar`,"data-pibo-state":l?`preview-fullscreen`:e.collapsed?`collapsed`:`open`,"data-pibo-preview-fullscreen":l?`true`:`false`,"aria-label":`Open workspace tabs`,"aria-hidden":c||void 0,hidden:c,className:`relative min-h-0 shrink-0 bg-[#101d22] ${l?`border-l-0`:`border-l border-slate-700`}`,style:E,children:[(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize workspace tabs`,"aria-orientation":`vertical`,"aria-valuemin":360,"aria-valuemax":S3e,"aria-valuenow":e.width,tabIndex:e.collapsed||l?-1:0,onPointerDown:T,onKeyDown:t=>{(t.key===`ArrowLeft`||t.key===`ArrowRight`)&&(t.preventDefault(),n(A3e(e,(t.currentTarget.parentElement?.getBoundingClientRect().width??e.width)+(t.key===`ArrowLeft`?24:-24))))},className:`absolute inset-y-0 -left-1 z-20 w-2 touch-none cursor-col-resize outline-none hover:bg-[#11a4d4]/35 focus-visible:bg-[#11a4d4]/60 ${e.collapsed||l?`hidden`:``}`}),e.collapsed&&!l?(0,W.jsxs)(`div`,{className:`flex h-full flex-col items-center gap-2 border-l border-slate-800 bg-[#151f24] py-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n({...e,collapsed:!1}),className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#11a4d4]`,title:`Reopen workspace tabs`,"aria-label":`Reopen workspace tabs`,children:(0,W.jsx)(el,{size:15})}),(0,W.jsxs)(`span`,{className:`mt-1 font-mono text-[10px] text-slate-500 [writing-mode:vertical-rl]`,children:[e.tabs.length,` tabs`]})]}):(0,W.jsxs)(`div`,{className:`grid h-full min-h-0 ${l?`grid-rows-[0_minmax(0,1fr)]`:`grid-rows-[40px_minmax(0,1fr)]`}`,children:[(0,W.jsxs)(`div`,{hidden:l,className:`relative flex min-w-0 items-stretch border-b border-slate-800 bg-[#151f24]`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>f.current?.scrollBy({left:-220,behavior:`smooth`}),title:`Scroll tabs left`,"aria-label":`Scroll tabs left`,className:`w-7 shrink-0 border-r border-slate-800 text-slate-500 hover:text-[#11a4d4]`,children:(0,W.jsx)(qs,{size:13,className:`mx-auto`})}),(0,W.jsx)(`div`,{ref:f,role:`tablist`,"aria-label":`Workspace tabs`,onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(null)},className:`flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:e.tabs.map((t,i)=>{let a=t.id===e.activeTabId,o=h?.overTabId===t.id&&h.position===`before`,s=h?.overTabId===t.id&&h.position===`after`;return(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[o?(0,W.jsx)($3e,{index:h.toIndex}):null,(0,W.jsxs)(`div`,{draggable:!0,onDragStart:e=>{m.current=t.id,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.id)},onDragOver:n=>{n.preventDefault(),n.dataTransfer.dropEffect=`move`;let r=m.current;if(!r||r===t.id)return;let i=n.currentTarget.getBoundingClientRect(),a=n.clientX>=i.left+i.width/2?`after`:`before`,o=J3e(e.tabs,r,t.id,a);g(e=>e?.draggedTabId===r&&e.overTabId===t.id&&e.position===a?e:{draggedTabId:r,overTabId:t.id,position:a,toIndex:o})},onDrop:t=>{t.preventDefault();let r=m.current;r&&h?.draggedTabId===r&&n(O3e(e,r,h.toIndex)),m.current=null,g(null)},onDragEnd:()=>{m.current=null,g(null)},className:`group flex h-10 min-w-[9.5rem] max-w-[13rem] items-center border-r border-slate-800 ${m.current===t.id?`opacity-60`:``} ${a?`bg-[#101d22] text-[#7ddfff]`:`bg-[#151f24] text-slate-400 hover:bg-slate-800/60`}`,children:[(0,W.jsx)(`button`,{ref:e=>{e?p.current.set(t.id,e):p.current.delete(t.id)},id:`desktop-tab-${t.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`desktop-tabpanel-${t.id}`,tabIndex:a?0:-1,onClick:()=>r(t),onKeyDown:e=>w(e,t,i),title:`${t.title}. Alt+Shift+Arrow reorders; Delete closes.`,className:`min-w-0 flex-1 truncate px-2 text-left text-[11px] font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:t.title}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void b(t),title:`Close ${t.title}`,"aria-label":`Close ${t.title}`,className:`mr-1 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-slate-500 opacity-70 hover:bg-slate-700 hover:text-slate-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)(Pl,{size:12})})]}),s?(0,W.jsx)($3e,{index:h.toIndex}):null]},t.id)})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>f.current?.scrollBy({left:220,behavior:`smooth`}),title:`Scroll tabs right`,"aria-label":`Scroll tabs right`,className:`w-7 shrink-0 border-l border-slate-800 text-slate-500 hover:text-[#11a4d4]`,children:(0,W.jsx)(Js,{size:13,className:`mx-auto`})}),(0,W.jsx)(`button`,{ref:u,type:`button`,onClick:()=>n(w3e(e)),title:`New Tab`,"aria-label":`New Tab`,className:`w-9 shrink-0 border-l border-slate-800 text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)(al,{size:15,className:`mx-auto`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>n({...e,collapsed:!0}),title:`Collapse workspace tabs`,"aria-label":`Collapse workspace tabs`,className:`w-9 shrink-0 border-l border-slate-800 text-slate-400 hover:text-[#11a4d4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#11a4d4]`,children:(0,W.jsx)($c,{size:15,className:`mx-auto`})})]}),(0,W.jsx)(`div`,{className:`relative min-h-0 overflow-hidden bg-[#101d22] ${l?`row-start-2`:``}`,children:e.tabs.length?e.tabs.map(t=>{let n=t.id===e.activeTabId;return(0,W.jsx)(`section`,{id:`desktop-tabpanel-${t.id}`,role:`tabpanel`,"aria-labelledby":`desktop-tab-${t.id}`,hidden:!n,className:`h-full min-h-0 overflow-hidden`,children:t.target.kind===`new-tab`?(0,W.jsx)(e6e,{ref:n?d:void 0,entries:y,onKeyDown:x,onChoose:S}):n||j3e(t)?o(t,n):null},t.id)}):(0,W.jsx)(`div`,{className:`grid h-full place-items-center p-6 text-center`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Zs,{size:22,className:`mx-auto text-slate-600`}),(0,W.jsx)(`div`,{className:`mt-3 text-xs font-bold uppercase tracking-wider text-slate-300`,children:`No workspace tabs`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-slate-500`,children:`Use + to open a product area or a session tool.`})]})})})]})]})}function $3e({index:e}){return(0,W.jsx)(`span`,{"aria-hidden":`true`,"data-pibo-debug":`desktop-tab-drop-gap`,"data-pibo-insertion-index":e,className:`desktop-tab-drop-gap h-6 w-2 shrink-0 rounded-sm bg-[#11a4d4]/75 motion-reduce:animate-none`})}var e6e=function({ref:e,entries:t,onKeyDown:n,onChoose:r}){return(0,W.jsx)(`div`,{"data-pibo-debug":`desktop-new-tab`,className:`grid h-full min-h-0 place-items-center overflow-auto p-6`,children:(0,W.jsxs)(`div`,{ref:e,role:`navigation`,"aria-label":`New Tab module catalog`,onKeyDown:n,className:`grid w-full max-w-2xl grid-cols-2 gap-1 border border-slate-700 bg-[#1a262b] p-3 max-[1180px]:grid-cols-1`,children:[(0,W.jsxs)(`div`,{className:`col-span-full px-2 pb-2 pt-0.5`,children:[(0,W.jsx)(`h2`,{className:`text-[11px] font-bold uppercase tracking-[0.14em] text-slate-400`,children:`New Tab`}),(0,W.jsx)(`p`,{className:`mt-1 text-[10px] text-slate-500`,children:`Open a product area or session tool`})]}),t.map(e=>{let t=e.icon;return(0,W.jsxs)(`button`,{"data-catalog-entry":!0,type:`button`,onClick:()=>r(e),className:`flex min-w-0 items-start gap-2 rounded-sm border border-transparent px-2 py-2 text-left hover:border-slate-700 hover:bg-[#101d22] focus-visible:border-[#11a4d4] focus-visible:bg-[#101d22] focus-visible:outline-none`,children:[(0,W.jsx)(t,{size:15,className:`mt-0.5 shrink-0 text-[#11a4d4]`}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block truncate text-xs font-semibold text-slate-200`,children:e.label}),(0,W.jsx)(`span`,{className:`block text-[10px] leading-4 text-slate-500`,children:e.description})]})]},e.id)})]})})};function t6e(e){return e?.target.kind===`session-tool`?e.target.tool:null}function n6e(e,t){return H9(e,t)}function r6e(e,t){return E3e(e,t)}var K9=750,i6e=5e3,a6e=3e4,o6e=3e4,q9=120,J9=60,s6e=new Set;function Y9(e){return e.trim().replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()??`download`}function X9(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function c6e(e){return e.status===`starting`?`Preparing download…`:e.status===`failed`?e.error??`Download failed`:e.totalBytes&&e.totalBytes>0?`${Math.min(100,Math.floor(e.receivedBytes/e.totalBytes*100))}% · ${X9(e.receivedBytes)} of ${X9(e.totalBytes)}`:e.receivedBytes>0?`${X9(e.receivedBytes)} received`:`Waiting for bytes…`}function Z9(e){return e instanceof DOMException&&e.name===`AbortError`}function l6e(e){let t=Number(e.split(`:`,1)[0]);return Number.isFinite(t)?t:void 0}async function u6e(e,t){let n=jPe(t.piboSessionId,t.includeArchived,t.roomId);return await e.removeQueries({queryKey:n,exact:!0}),Ll(t.piboSessionId,t.includeArchived,t.roomId,!!t.markRead,{signal:t.signal})}async function d6e(e,t){return PPe(e,t,()=>Rl(t.piboSessionId,t.includeArchived,t.roomId,{signal:t.signal}))}function f6e({route:e}){let t=jo(),n=On(),r=KJ(),i=!r,a=Z3e(e,i),o=NIe(),s=W9(a.state),c=t6e(s),l=s?.target.kind===`route`?s.target.route:void 0,u=i?`sessions`:e.area,d=e.area===`sessions`?e.roomId:void 0,f=e.area===`projects`?e.projectId:void 0,p=e.area===`sessions`||e.area===`projects`||e.area===`context`?e.piboSessionId:void 0,m=e.area===`sessions`||!i&&e.area===`projects`?e.sessionViewId:void 0,h=e.area===`workflows`?e.draftId:void 0,g=e.area===`settings`?e.panel??`general`:`general`,[_,v]=(0,U.useState)(null),y=(0,U.useRef)(null),b=(0,U.useRef)(null),[x,S]=(0,U.useState)(null),C=(0,U.useCallback)(e=>{if(typeof e==`function`){S(t=>{let n=e(t);return y.current=n,n});return}y.current=e,S(e)},[]),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)(null),M=(0,U.useRef)(new Set),[N,P]=(0,U.useState)(Zje),[F,ee]=(0,U.useState)(Qje),[I,L]=(0,U.useState)($je),[R,te]=(0,U.useState)(eMe),[z,ne]=(0,U.useState)(tMe),[re,ie]=(0,U.useState)(rMe),[B,ae]=(0,U.useState)(``),[oe,se]=(0,U.useState)(null),[ce,le]=(0,U.useState)(()=>m??nZ()),[ue,de]=(0,U.useState)(!1),[fe,pe]=(0,U.useState)(!1),[me,he]=(0,U.useState)(``),[ge,_e]=(0,U.useState)(0),[ve,ye]=(0,U.useState)(!1),be=(0,U.useRef)(!1),xe=(0,U.useRef)(null),Se=(0,U.useRef)(!1),[V,Ce]=(0,U.useState)(!1),[we,H]=(0,U.useState)(!1),[Te,Ee]=(0,U.useState)(q9),[De,Oe]=(0,U.useState)(J9),[ke,Ae]=(0,U.useState)(null),[je,Me]=(0,U.useState)(null),[Ne,Pe]=(0,U.useState)(null),[Fe,Ie]=(0,U.useState)(`build-context`),[Le,Re]=(0,U.useState)(null),[ze,Be]=(0,U.useState)(null),[Ve,He]=(0,U.useState)(!1),[Ue,We]=(0,U.useState)(!1),[Ge,Ke]=(0,U.useState)({}),qe=(0,U.useMemo)(()=>Object.fromEntries([`preview`,`raw-events`,`web-annotations`,`runtime-requests`,`session-inspector`].map(e=>[e,t=>{Ke(n=>n[e]===t?n:{...n,[e]:t})}])),[]);(0,U.useEffect)(()=>{(!i||c!==`preview`)&&pe(!1)},[c,i]);let Je=(0,U.useRef)(null),Ye=GJ({isMobileViewport:r,isOpen:Ue,onClose:(0,U.useCallback)(()=>We(!1),[]),triggerRef:Je}),[Xe,Ze]=(0,U.useState)(!1),[Qe,$e]=(0,U.useState)(null),[et,tt]=(0,U.useState)(null),nt=(0,U.useRef)(null),rt=(0,U.useRef)(null),[it,at]=(0,U.useState)(()=>Date.now()),ot=(0,U.useRef)(z),st=(0,U.useRef)(null),ct=(0,U.useRef)(null),lt=(0,U.useRef)(0),ut=(0,U.useRef)(new Map),dt=(0,U.useRef)(null),ft=(0,U.useRef)(0),pt=w??_?.selectedRoomId??null,mt=pt&&_?EY(_.rooms,pt)??_.room:void 0,ht=jAe(_?.rooms??[],pt,_?.room),gt=mt?kY(mt):!1,_t=!!(je&&je===w),vt=b1(x),yt=(0,U.useCallback)(e=>{let t=rt.current,n=t?R4e(e,t):e,r=nt.current;return e.selectedPiboSessionId&&M9(r,e.selectedPiboSessionId)?L4e(n,r):n},[]);(0,U.useEffect)(()=>{ot.current=z},[z]),(0,U.useEffect)(()=>{ct.current=_},[_]),(0,U.useEffect)(()=>{Ee(q9),Oe(J9)},[w,z]),(0,U.useEffect)(()=>{at(Date.now())},[_]);let bt=(0,U.useCallback)(e=>N9(rt.current,e)?(rt.current=e,v(t=>t&&R4e(t,e)),!0):!1,[]),xt=(0,U.useCallback)(e=>{let t=G4e(rt.current,e);return!t.needsRefresh&&(rt.current=t.snapshot,v(t=>t&&W4e(t,e)),!0)},[]);(0,U.useEffect)(()=>{if(u===`sessions`&&vt)return;let e=!0,t,n=new AbortController,r=i=>{e&&(t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,Pu({signal:n.signal}).then(t=>{e&&!n.signal.aborted&&bt(t)}).catch(()=>{n.signal.aborted||r(K9)})},i))},i={onSnapshot:n=>{!e||!N9(rt.current,n)||(t&&=(clearTimeout(t),void 0),bt(n))},onPatch:t=>{e&&!xt(t)&&r(0)},onError:()=>r(K9)},a=()=>void 0,o=()=>{e&&(a(),a=Fu(i))},s=()=>{document.visibilityState===`visible`&&o()};return a=Fu(i),window.addEventListener(`pageshow`,o),document.addEventListener(`visibilitychange`,s),()=>{e=!1,n.abort(),t&&clearTimeout(t),window.removeEventListener(`pageshow`,o),document.removeEventListener(`visibilitychange`,s),a()}},[u,xt,bt,vt]),(0,U.useEffect)(()=>{if(u!==`sessions`||!vt){nt.current=null,tt(null);return}let e=z4e(nt.current,vt);nt.current=e,tt(e);let t=!0,n,r,i=new AbortController,a=e=>{!t||i.signal.aborted||!V4e(nt.current,e,vt)||(nt.current=e,tt(e),v(t=>t&&L4e(t,e)))},o=e=>{t&&(n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,Nu(vt,{signal:i.signal}).then(a).catch(()=>{i.signal.aborted||o(K9)})},e))},s=e=>{t&&(r&&clearTimeout(r),r=setTimeout(()=>{r=void 0,Pu({signal:i.signal}).then(e=>{t&&!i.signal.aborted&&bt(e)}).catch(()=>{i.signal.aborted||s(K9)})},e))},c={onSnapshot:e=>{!t||!V4e(nt.current,e,vt)||(n&&=(clearTimeout(n),void 0),a(e))},onPatch:e=>{if(!t)return;let n=H4e(nt.current,e,vt);if(n.needsRefresh){o(0);return}nt.current=n.snapshot,tt(n.snapshot),v(t=>t&&U4e(t,e))},onStatusSnapshot:e=>{!t||!N9(rt.current,e)||(r&&=(clearTimeout(r),void 0),bt(e))},onStatusPatch:e=>{t&&!xt(e)&&s(0)},onError:()=>{o(K9),s(K9)}},l=()=>void 0,d=()=>{t&&(l(),l=Iu(vt,c),o(i6e))},f=()=>{document.visibilityState===`visible`&&d()},p=()=>{let e=ct.current?o1(ct.current.sessions,vt):void 0;return B4e(nt.current,vt,e?.status)};l=Iu(vt,c),window.addEventListener(`pageshow`,d),document.addEventListener(`visibilitychange`,f);let m=window.setInterval(()=>{document.visibilityState===`visible`&&p()&&o(0)},a6e);return o(i6e),()=>{t=!1,i.abort(),n&&clearTimeout(n),r&&clearTimeout(r),window.removeEventListener(`pageshow`,d),document.removeEventListener(`visibilitychange`,f),window.clearInterval(m),l()}},[u,xt,bt,vt]),(0,U.useEffect)(()=>{let e=_?kAe(_.sessions,it):void 0;if(e===void 0)return;let t=setTimeout(()=>at(Date.now()),Math.max(50,e));return()=>clearTimeout(t)},[_,it]),(0,U.useEffect)(()=>{let e=async()=>{try{let e=await fetch(`/health`,{signal:AbortSignal.timeout(3e3)});if(e.ok){let t=await e.json();$e(t.mode===`fallback`?`fallback`:`main`)}else $e(null)}catch{$e(null)}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,U.useEffect)(()=>{if(u!==`sessions`&&u!==`projects`)return;let e=m??nZ();le(t=>t===e?t:e)},[u,m]),(0,U.useEffect)(()=>{Xje(ce)},[ce]),(0,U.useEffect)(()=>{de(!1)},[u]),(0,U.useEffect)(()=>{u===`sessions`&&ce!==`terminal`&&de(!1)},[u,ce]);let St=(0,U.useCallback)(()=>{We(!1),Ze(!1),de(!0)},[]),Ct=(0,U.useCallback)((e,n=!1,r=ce,i={})=>{i.closeMobileSidebar!==!1&&Ye(),bu(t,e,n,r,i.preserveHash===!0,i.preserveSearch===!0)},[Ye,t,ce]),wt=(0,U.useCallback)(e=>{xe.current=e},[]),Tt=(0,U.useCallback)(async({current:e,next:t})=>{if(e.pathname===t.pathname)return!1;if(Se.current)return Se.current=!1,!1;let n=xe.current;if(!n)return!1;try{return await n(),!1}catch(e){return D(`Agent Designer changes were not saved: ${e instanceof Error?e.message:String(e)}`),!0}},[]);ys({disabled:i?s?.target.kind!==`route`||s.target.route.area!==`agents`:u!==`agents`,enableBeforeUnload:!1,shouldBlockFn:Tt});let Et=(0,U.useCallback)((e,t,n=!1,r={})=>{if(!t){Ct({area:`sessions`,...e?{roomId:e}:{}},n,ce,r);return}Ct({area:`sessions`,...e?{roomId:e}:{},piboSessionId:t},n,ce,r)},[Ct,ce]),Dt=(0,U.useCallback)((e,t,n=!1,r={})=>{if(!t){Ct({area:`projects`,...e?{projectId:e}:{}},n,ce,r);return}Ct({area:`projects`,...e?{projectId:e}:{},piboSessionId:t},n,ce,r)},[Ct,ce]),Ot=(0,U.useCallback)(e=>{Ie(`build-context`),Ct({area:`context`,piboSessionId:e})},[Ct]),kt=(0,U.useCallback)(e=>{Re(e),Ie(`context-files`),Ct({area:`context`})},[Ct]),At=(0,U.useCallback)(e=>{Be(e),Ie(`mcp-tools`),Ct({area:`context`})},[Ct]),jt=(0,U.useCallback)(e=>{v(t=>t&&s3e(t,e))},[]),Mt=(0,U.useCallback)(e=>{v(t=>t&&c3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&c3e(t,e))},[n]),Nt=(0,U.useCallback)(e=>{v(t=>t&&l3e(t,e.id)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&l3e(t,e.id))},[n]),Pt=(0,U.useCallback)(e=>{v(t=>t&&u3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&u3e(t,e))},[n]),Ft=(0,U.useCallback)(e=>{v(t=>t&&d3e(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&d3e(t,e))},[n]),It=(0,U.useCallback)(e=>{let t=JSON.stringify([e.piboSessionId??``,e.includeArchived===!0?`archived`:`active`,e.roomId??``,e.force===!0?`force`:`cached`,j$(n)]);if(e.signal)return d6e(n,e);let r=ut.current.get(t);if(r)return r;let i=d6e(n,e).finally(()=>{ut.current.get(t)===i&&ut.current.delete(t)});return ut.current.set(t,i),i},[n]),Lt=(0,U.useCallback)(async(e,t=ot.current,r,i={})=>{let a=ct.current;if(a&&i.selectSession!==!1&&!i.force){e&&Yl(e).catch(()=>void 0);let n=lt.current+1;lt.current=n;let o=Q4e(a,await It({piboSessionId:e,includeArchived:t,roomId:r,signal:i.signal}),{readSessionId:e});if(n!==lt.current)return o;let s=yt(o);return v(s),C(s.selectedPiboSessionId),T(s.selectedRoomId),s}let o=lt.current+1;lt.current=o;let s=await u6e(n,{piboSessionId:e,includeArchived:t,roomId:r,markRead:i.selectSession!==!1,force:i.force,signal:i.signal});if(o!==lt.current)return s;let c=yt(s);return v(c),i.selectSession!==!1&&C(c.selectedPiboSessionId),T(c.selectedRoomId),c},[yt,n]),Rt=(0,U.useCallback)(async(e,t=ot.current,n,r={})=>{let i=ct.current;if(!i)return Lt(e,t,n,{force:r.force,signal:r.signal});let a=lt.current+1;lt.current=a;let o=Q4e(i,await It({piboSessionId:e,includeArchived:t,roomId:n,force:r.force,signal:r.signal}),{readSessionId:r.readSessionId});if(a!==lt.current)return o;let s=yt(o);return v(s),C(s.selectedPiboSessionId),T(s.selectedRoomId),s},[It,Lt,yt]);(0,U.useEffect)(()=>{if(u!==`sessions`)return;let e=!1,t=!1,n=()=>{e||t||document.hidden||!ct.current||x&&!vt||(t=!0,Rt(vt??void 0,ot.current,pt??void 0,{force:!0}).catch(()=>void 0).finally(()=>{t=!1}))},r=window.setInterval(n,o6e),i=()=>{document.hidden||n()};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,i),()=>{e=!0,window.clearInterval(r),window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,i)}},[pt,u,Rt,vt,x]),(0,U.useEffect)(()=>{let{requestedRoomId:t,requestedPiboSessionId:n}=dWe(e,ZX()),r=(t,n=!0)=>{let r=pWe(e,t);r&&Et(r.selectedRoomId,r.selectedPiboSessionId,n,{preserveHash:!0,preserveSearch:!0})};if(fWe({bootstrap:_,creatingSession:be.current,route:e}))return;let i=_?Rt:Lt,a=()=>{k(null),D(null)},o=e=>{ct.current||k(_We(e)),D(x1(e))};i(n,ot.current,t).then(e=>{r(e),a()}).catch(s=>{if(e.area===`sessions`&&d&&!p&&n){QX(d),i(void 0,ot.current,d).then(e=>{r(e),a()}).catch(o);return}if(mWe(e)||!n&&!t){o(s);return}iMe(),i().then(e=>{r(e),a()}).catch(o)})},[_,Lt,Rt,Et,e.area,p,d]),(0,U.useEffect)(()=>{!w&&!x||Jje({roomId:w??void 0,piboSessionId:x??void 0})},[x,w]),(0,U.useEffect)(()=>{he(x?$X(x):``)},[x]);let zt=(0,U.useCallback)(e=>{he(t=>{let n=typeof e==`function`?e(t):e;return x&&eZ(x,n),n})},[x]),Bt=(0,U.useMemo)(()=>RUe(),[]),Vt=(0,U.useMemo)(()=>I6(ce),[ce]),Ht=(0,U.useMemo)(()=>I6(`terminal`),[]);(0,U.useEffect)(()=>{if(!_?.agents.length)return;let e=_.selectedRoomId;if(je||!e||e.startsWith(`optimistic-room-`))return;let t=i1(_),n=cZ(e),r=n?``:cZ(),i=Q9(_.agents,n||r||t)?.name??Q9(_.agents,t)?.name??_.agents[0].name;ae(i),se(e),n!==i&&uZ(i,e),r&&uZ(``)},[_,je]);let Ut=(0,U.useCallback)(e=>{ae(e);let t=w??ct.current?.selectedRoomId;t&&(se(t),uZ(e,t))},[w]),Wt=(0,U.useCallback)(async e=>{let t=MDe(e),r=!1;try{await Promise.all([n.invalidateQueries({queryKey:N$(e),refetchType:`none`}),n.invalidateQueries({queryKey:P$(e),refetchType:`none`})]),await Promise.all([n.refetchQueries({queryKey:N$(e),type:`active`}),n.refetchQueries({queryKey:P$(e),type:`active`})])}catch(e){throw r=!0,e}finally{NDe(e,t,r)}},[n]),Gt=(0,U.useCallback)(()=>x?Wt(x):Promise.resolve(),[Wt,x]),Kt=(0,U.useCallback)(()=>Rt(x??void 0,ot.current,w??void 0,{force:!0}),[Rt,x,w]),qt=(0,U.useCallback)(async()=>{D(null);let e=x??void 0;await Lt(e,ot.current,w??void 0,{force:!0,selectSession:!1}),e&&await Wt(e)},[Lt,Wt,x,w]),Jt=(0,U.useCallback)(e=>{v(t=>t&&e(t)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&e(t))},[n]),Yt=(0,U.useCallback)((e,t)=>{v(n=>n&&zUe(n,e,t)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},n=>n&&zUe(n,e,t))},[n]),Xt=(0,U.useCallback)(async()=>{lt.current+=1,ut.current.clear(),await Promise.all([n.cancelQueries({queryKey:[`chat`,`bootstrap`]}),NPe(n)])},[n]),Zt=_?.latestRoomStreamId;(0,U.useEffect)(()=>{let e=b3e({area:u,activeRoomId:pt,bootstrapSelectedRoomId:_?.selectedRoomId,latestRoomStreamId:Zt});if(!e||!pt||typeof Zt!=`number`)return;let t,n,r=()=>{x&&!vt||(n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,Rt(vt??void 0,ot.current,pt,{force:!0}).catch(e=>{Z9(e)||D(x1(e))})},900))},i=e=>{let t=Yu(e);if(!t||t.type===`ready`)return;let n=l6e(e.lastEventId),i=n!==void 0&&n<=Zt,a=t.piboSessionId,o=od(t);if(a&&o){let e=rt.current?.sessions[a]?.status??F9(nt.current?.sessions[a])??o,t=new Date().toISOString();Jt(n=>z6(n,a,n=>({...n,status:e,lastActivityAt:t})))}y3e({replayFrame:i,eventRefreshesNavigation:ed(t),targetPiboSessionId:a,selectedBackendPiboSessionId:vt??void 0})&&r()},a=()=>{n&&clearTimeout(n),n=void 0,t?.close(),t=void 0},o=()=>{a(),t=new EventSource(e),t.addEventListener(`pibo`,i)};return o(),window.addEventListener(`pagehide`,a),window.addEventListener(`pageshow`,o),()=>{window.removeEventListener(`pagehide`,a),window.removeEventListener(`pageshow`,o),a()}},[pt,u,_?.selectedRoomId,Zt,Rt,vt,x,Jt]);let Qt=(0,U.useCallback)((e,t)=>{if(e){v(VUe(e.localBootstrap,t)??null);for(let[r,i]of e.queryData)n.setQueryData(r,VUe(i,t)??void 0)}},[n]),{deleteRoomTarget:$t,deleteRoomConfirmName:en,deletingRoom:tn,setDeleteRoomConfirmName:nn,requestRoomDelete:rn,cancelRoomDelete:an,permanentlyDeleteRoom:on,deleteSessionTarget:sn,deleteSessionConfirmText:cn,deletingSession:ln,setDeleteSessionConfirmText:un,requestSessionDelete:dn,cancelSessionDelete:fn,permanentlyDeleteSession:pn}=v3e({queryClient:n,bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,showArchivedRef:ot,isSessionsArea:u===`sessions`,loadBootstrap:Lt,navigateToSelectedSession:Et,updateBootstrapCache:Jt,restoreBootstrapSnapshot:Qt,setSelectedPiboSessionId:C,setSelectedRoomId:T,setError:D}),mn=Wn({mutationFn:({profile:e,roomId:t})=>ql(e||void 0,t),onMutate:async({profile:e,roomId:t})=>{b.current=null,await Xt();let n=t??_?.selectedRoomId??``,r=y.current,i=`optimistic-session-${c1()}`;return ct.current?.selectedRoomId===n&&C(i),Yt(n,t=>({...HUe(t,tWe(i,e||i1(t))),selectedPiboSessionId:i})),{tempId:i,previousSelectedPiboSessionId:r,originRoomId:n}},onError:(e,t,n)=>{let r=BUe({status:`failure`,currentSelectedPiboSessionId:y.current,tempId:n?.tempId,previousSelectedPiboSessionId:n?.previousSelectedPiboSessionId});b.current=r,n?.originRoomId&&n.tempId&&Yt(n.originRoomId,e=>KUe(e,n.tempId,n.previousSelectedPiboSessionId??null)),C(r.selectedPiboSessionId)},onSuccess:(e,t,n)=>{let r=BUe({status:`success`,currentSelectedPiboSessionId:y.current,tempId:n?.tempId,previousSelectedPiboSessionId:n?.previousSelectedPiboSessionId,createdPiboSessionId:e.session.id});b.current=r,n?.originRoomId&&Yt(n.originRoomId,t=>GUe(t,n.tempId,nWe(e.session))),C(r.selectedPiboSessionId)}}),hn=Wn({mutationFn:({piboSessionId:e,title:t})=>eu(e,{title:t}),onMutate:async({piboSessionId:e,title:t})=>{await Xt();let r=L6(n,_);return Jt(n=>z6(n,e,e=>({...e,title:t||`Untitled Session`}))),{snapshot:r}},onError:(e,t,n)=>Qt(n?.snapshot),onSuccess:({session:e})=>Jt(t=>qUe(t,e))}),gn=Wn({mutationFn:({piboSessionId:e,archived:t})=>eu(e,{archived:t}),onMutate:async({piboSessionId:e,archived:t})=>{await Xt();let r=L6(n,_);return Jt(n=>z6(n,e,e=>({...e,archived:t,unreadCount:t?0:e.unreadCount}))),{snapshot:r}},onError:(e,t,n)=>Qt(n?.snapshot),onSuccess:({session:e})=>Jt(t=>qUe(t,e))}),_n=Wn({mutationFn:({piboSessionId:e,text:t,clientTxnId:n,roomId:r,webAnnotationIds:i,fileAttachmentPaths:a,delivery:o})=>nu(e,t,n,r,i,a,o),onMutate:async({piboSessionId:e})=>{await n.cancelQueries({queryKey:P$(e)}),Jt(t=>z6(t,e,e=>({...e,status:`running`,lastActivityAt:new Date().toISOString()})))},onError:(e,t)=>{Jt(e=>z6(e,t.piboSessionId,e=>({...e,status:`error`})))}}),vn=(0,U.useCallback)(async e=>{if(!(!x||!_||e===i1(_)))try{await eu(x,{profile:e});let t=await Lt(x,ot.current,w??void 0);u===`sessions`&&Et(t.selectedRoomId,t.selectedPiboSessionId),await Wt(x),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},[u,_,Lt,Et,Wt,x,w]),yn=(0,U.useMemo)(()=>lWe(_?.capabilities.actions??[]),[_]),bn=(0,U.useMemo)(()=>uWe(_,x),[_,x]),xn=(0,U.useCallback)(async e=>{let t=w??_?.selectedRoomId;(0,Fl.flushSync)(()=>{C(e),Ae(e),Ye()}),Jt(n=>$4e(n,e,t??n.selectedRoomId)),Et(t,e,!1,{closeMobileSidebar:!1}),Yl(e).catch(()=>void 0),window.setTimeout(()=>{Ae(t=>t===e?null:t)},50),window.setTimeout(()=>{ct.current?.selectedPiboSessionId===e&&Rt(e,ot.current,t,{readSessionId:e}).then(t=>{ct.current?.selectedPiboSessionId===e&&Et(t.selectedRoomId,t.selectedPiboSessionId,!0,{closeMobileSidebar:!1})}).catch(t=>{!Z9(t)&&ct.current?.selectedPiboSessionId===e&&D(x1(t))})},750)},[_?.selectedRoomId,Ye,Rt,Et,w,Jt]),Sn=(0,U.useCallback)(async(e,t={})=>{let n={...t,closeMobileSidebar:!1},r=ZX().sessionsByRoom?.[e],i=ft.current+1;ft.current=i,dt.current?.abort();let a=new AbortController;dt.current=a,(0,Fl.flushSync)(()=>{T(e),C(r??null),se(null),Me(e),Ye()});try{let t=await Rt(r,ot.current,e,{signal:a.signal});if(ft.current!==i||a.signal.aborted)return;Et(t.selectedRoomId,t.selectedPiboSessionId,!1,n)}catch(t){if(Z9(t))return;if(!r)throw t;QX(e),C(null);let o=await Rt(void 0,ot.current,e,{signal:a.signal});if(ft.current!==i||a.signal.aborted)return;Et(o.selectedRoomId,o.selectedPiboSessionId,!1,n)}finally{ft.current===i&&(dt.current===a&&(dt.current=null),Me(t=>t===e?null:t))}},[Ye,Rt,Et]),Cn=(0,U.useCallback)(()=>{let e=!re;if(ie(e),sZ(e),e||!_)return;let t=MAe(_.rooms,pt);t&&Sn(t,{closeMobileSidebar:!1}).catch(e=>{D(e instanceof Error?e.message:String(e))})},[pt,_,Sn,re]),wn=async(e=B)=>{if(ve||gt)return;let t=w??_?.selectedRoomId??``;be.current=!0,ye(!0);try{let n=await mn.mutateAsync({profile:e,roomId:t||void 0}),r=b.current;if(r?.autoRenameCreatedSession&&Pe(n.session.id),r?.navigateToCreatedSession){Et(t||void 0,n.session.id,!1,{closeMobileSidebar:!1});let e=await Lt(n.session.id,ot.current,t||void 0,{force:!0});Et(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1})}D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{b.current=null,be.current=!1,ye(!1)}},Tn=async()=>{let e=!z;if(ne(e),nMe(e),!e){H(!1),D(null);return}H(!0);try{let e=await Rt(x??void 0,!0,w??void 0);u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}finally{H(!1)}},En=async(e,t)=>{try{await hn.mutateAsync({piboSessionId:e,title:t});let n=await Lt(x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&await Wt(n.selectedPiboSessionId),u===`sessions`&&Et(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},Dn=async(e,t)=>{try{await gn.mutateAsync({piboSessionId:e,archived:t});let n=await Lt(t&&!z&&x===e?void 0:x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&Et(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},kn=async()=>{if(Ve)return;He(!0),await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let e=L6(n,_),t=`optimistic-room-${c1()}`,r=QUe(t,`New Chat`);T(t),C(null),se(null),Me(t),Jt(e=>JUe(e,r));try{let e=await Zl({name:`New Chat`});QX(t),lZ(t),Jt(n=>YUe(n,t,e.room)),await Sn(e.room.id,{closeMobileSidebar:!1}),D(null)}catch(n){QX(t),lZ(t),Qt(e),T(w),C(x),D(n instanceof Error?n.message:String(n))}finally{Me(e=>e===t?null:e),He(!1)}},An=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=L6(n,_);Jt(n=>B6(n,e,e=>({...e,...t.name===void 0?{}:{name:t.name},...t.topic===void 0?{}:{topic:t.topic??void 0},...t.workspace===void 0?{}:{workspace:t.workspace??void 0},updatedAt:new Date().toISOString()})));try{let{room:n}=await Ql(e,t);Jt(t=>B6(t,e,()=>n));let r=await Lt(x??void 0,ot.current,e,{force:!0});u===`sessions`&&Et(r.selectedRoomId,r.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){Qt(r),D(e instanceof Error?e.message:String(e))}},jn=async e=>{try{await Xl(e);let t=await Lt(x??void 0,ot.current,w??void 0,{force:!0,selectSession:!1});u===`sessions`&&Et(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){D(e instanceof Error?e.message:String(e))}},Mn=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=L6(n,_);t&&(ie(!0),sZ(!0)),Jt(n=>B6(n,e,e=>$Ue(e,t)));try{let{room:n}=await Ql(e,{archived:t});Jt(t=>B6(t,e,()=>n));let r=await Lt(x??void 0,ot.current,w??void 0,{force:!0});u===`sessions`&&Et(r.selectedRoomId,r.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),D(null)}catch(e){Qt(r),D(e instanceof Error?e.message:String(e))}},Nn=(0,U.useCallback)(async e=>{if(!x||gt)return!1;let t=e.trim().split(/\s+/)[0],n=yn.find(e=>e.slash===t);if(!n)return!1;if(n.action===`thinking-show`){let e=!N;return P(e),rZ(e),!0}if(n.action===`download`){let n=aWe(e.slice(t.length));if(!n)return D(`Usage: /download <path>`),!0;let r=`${x}:${n}`;if(M.current.has(r))return j(e=>e?.key===r?{...e,duplicateAttempted:!0}:{key:r,path:n,filename:Y9(n),receivedBytes:0,status:`running`,duplicateAttempted:!0}),!0;M.current.add(r),j({key:r,path:n,filename:Y9(n),receivedBytes:0,status:`starting`});try{let e=await Eu(n,{piboSessionId:x,roomId:w??void 0,onStart:e=>j(t=>({...e,key:r,status:`running`,duplicateAttempted:t?.key===r&&t.duplicateAttempted})),onProgress:e=>j(t=>({...e,key:r,status:`running`,duplicateAttempted:t?.key===r&&t.duplicateAttempted}))});j(t=>({...e,key:r,status:`completed`,duplicateAttempted:t?.key===r&&t.duplicateAttempted})),D(null)}catch(e){let t=e instanceof Error?e.message:String(e);j(e=>({key:r,path:n,filename:e?.key===r?e.filename:Y9(n),receivedBytes:e?.key===r?e.receivedBytes:0,totalBytes:e?.key===r?e.totalBytes:void 0,status:`failed`,error:t})),D(t)}finally{M.current.delete(r)}return!0}let r=oWe(n.action,e.slice(t.length).trim()),i=cWe(await iu(x,n.action,r));if((n.action===`session.clone`||n.action===`session.fork`)&&i)await xn(i);else{let e=await Lt(x,ot.current,w??void 0);u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId),await Wt(x)}return!0},[u,Lt,Et,Wt,xn,x,gt,w,N,yn]),Pn=(0,U.useCallback)(async e=>{if(!x||gt)return;let t=sWe(await iu(x,`session.fork`,{entryId:e}));if(t?.result.cancelled)return;if(!t)throw Error(`Unexpected fork action response`);let n=typeof t.result.selectedText==`string`?t.result.selectedText:void 0;n!==void 0&&t.result.piboSessionId&&eZ(t.result.piboSessionId,n),t.result.piboSessionId&&await xn(t.result.piboSessionId),n!==void 0&&(he(n),_e(e=>e+1))},[xn,x,gt]),Fn=(0,U.useCallback)(e=>void xn(e),[xn]),In=(0,U.useCallback)(e=>{if(le(e),u===`projects`){Ct({area:`projects`,...f?{projectId:f}:{},...p?{piboSessionId:p}:{}},!1,e);return}u===`sessions`&&Ct({area:`sessions`,...w?{roomId:w}:{},...x?{piboSessionId:x}:{}},!1,e)},[u,Ct,p,f,x,w]),Ln=(0,U.useMemo)(()=>_?wY(_.sessions,z):{active:[],archived:[]},[_?.sessions,z]),Rn=(0,U.useMemo)(()=>AAe(Ln.active,Te,x),[Ln.active,x,Te]),zn=(0,U.useMemo)(()=>z?Ln.archived.slice(0,De):[],[Ln.archived,z,De]),Bn=Ln.active.length>Rn.length,Vn=z&&Ln.archived.length>zn.length,Hn=(0,U.useMemo)(()=>x?new Set(s1(_?.sessions??[],x).map(e=>e.piboSessionId)):s6e,[_?.sessions,x]),Un=(0,U.useCallback)(async e=>{if(!pt)return;let t=(e?zn:Rn).at(-1)?.piboSessionId;e?H(!0):Ce(!0);try{let r=e?J9:q9,i=await n.fetchQuery({queryKey:IPe(pt,e,t,r),queryFn:()=>Kl({roomId:pt,piboSessionId:x??void 0,archived:e,cursor:t,limit:r}),staleTime:3e4,gcTime:18e5});v(e=>e&&yt({...e,sessions:o3e(e.sessions,i.sessions)})),e?Oe(e=>e+r):Ee(e=>e+r)}finally{e?H(!1):Ce(!1)}},[pt,yt,n,x,Rn,zn]);if(O&&!_)return O.kind===`authentication-required`?(0,W.jsx)(TIe,{message:O.message}):(0,W.jsx)(EIe,{message:O.message,onRetry:()=>window.location.reload()});if(!_)return(0,W.jsx)(`div`,{className:`min-h-screen bg-[#101d22] text-slate-300 grid place-items-center`,children:`Loading Pibo Chat...`});let Gn=x?o1(_.sessions,x):void 0,Kn=x?et?.sessions[x]:void 0,qn=et?.rootPiboSessionId?et.sessions[et.rootPiboSessionId]:void 0,Jn=a1(_,Gn??{profile:i1(_),parentId:_.session?.parentId}),Yn=NAe(_.rooms),Xn=[...new Set([..._.agents.map(e=>e.name),..._.customAgents.map(e=>e.profileName)])],Zn=uFe(_),Qn=ue&&(u===`sessions`||u===`projects`)&&(u===`projects`||ce===`terminal`),$n=i&&fe&&c===`preview`,er=Qn||$n,tr=Qn?`h-full overflow-hidden grid grid-cols-[minmax(0,1fr)]`:u===`vscode`||u===`workflows`||u===`cron`||u===`loops`||u===`agents`||u===`projects`?`h-full overflow-hidden`:`grid ${u===`sessions`&&I?`grid-cols-[300px_minmax(0,1fr)_320px] max-[980px]:grid-cols-1`:`grid-cols-[300px_minmax(0,1fr)] max-[980px]:grid-cols-1`}`,nr=e=>{if(Ze(!1),e===`sessions`){Et(w??_.selectedRoomId,x??_.selectedPiboSessionId);return}if(e===`projects`){Ct({area:`projects`});return}Ct({area:e})},rr={area:`sessions`,...w??_.selectedRoomId?{roomId:w??_.selectedRoomId}:{},...x??_.selectedPiboSessionId?{piboSessionId:x??_.selectedPiboSessionId}:{}},ir=async(e,t={})=>{let n=W9(a.state),r=t.saveClosingTab?.target.kind===`route`&&t.saveClosingTab.target.route.area===`agents`||n?.target.kind===`route`&&n.target.route.area===`agents`&&n.id!==e.activeTabId,i=await F3e({current:a.state,next:e,sessionsRoute:rr,closingTab:t.saveClosingTab,autosave:xe.current,onCommit:a.setState,onNavigate:e=>{r&&(Se.current=!0),Ct(e),r&&window.setTimeout(()=>{Se.current=!1},0)}});return i.allowed?!0:(D(`Agent Designer changes were not saved: ${i.error instanceof Error?i.error.message:String(i.error)}`),!1)},ar=e=>{ir(e)},or=async e=>{let t=n6e(a.state,e);await ir(t)},sr=async e=>{await ir(r6e(a.state,e.id))},cr=async e=>ir(D3e(a.state,e.id),{saveClosingTab:e}),lr=e=>{let t=a.state.tabs.find(t=>t.target.kind===`session-tool`&&t.target.tool===e);t&&cr(t)},ur=async e=>{e&&!await cr(e)||(Et(w??_.selectedRoomId,x??_.selectedPiboSessionId),window.setTimeout(()=>document.querySelector(`[data-pibo-debug="desktop-session-sidebar"] button`)?.focus(),0))},dr=(e,t)=>{if(e.target.kind===`new-tab`)return null;if(e.target.kind===`session-tool`)return(0,W.jsx)(`div`,{ref:qe[e.target.tool],className:`h-full min-h-0 overflow-hidden ${e.target.tool===`preview`?`flex flex-col`:``}`,"data-pibo-debug":`desktop-session-tool-${e.target.tool}`});let n=e.target.route;if(n.area===`vscode`)return(0,W.jsx)(P4e,{integration:_.integrations?.vscode});if(n.area===`cron`)return(0,W.jsx)(YJ,{bootstrap:_,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`loops`)return(0,W.jsx)(MY,{bootstrap:_,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`agents`)return(0,W.jsx)(IX,{agents:_.agents,initialCustomAgents:_.customAgents,initialAgentFolders:_.agentFolders,initialCatalog:_.agentCatalog,modelCatalog:_.modelCatalog,onCreateSession:e=>void wn(e),onEditContextFile:kt,onEditMcpServer:At,onAgentsChanged:()=>void Lt(x??void 0,ot.current,w??void 0,{selectSession:!1}),onAutosaveHandlerChange:wt,creatingSession:ve||gt,mobileSidebarOpen:!1,isMobileSidebarViewport:!1,onCloseMobileSidebar:()=>void 0,surface:`tab`});if(n.area===`workflows`)return(0,W.jsx)(O4e,{route:n,surface:`desktop`,fallback:(0,W.jsx)(y4e,{draftId:n.draftId,onNavigateDraft:e=>{t&&Ct({area:`workflows`,draftId:e})}})});if(n.area===`projects`)return(0,W.jsx)(oGe,{baseBootstrap:_,routeProjectId:n.projectId,routePiboSessionId:n.piboSessionId,sessionViews:Bt,showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,mobileSidebarOpen:!1,onCloseMobileSidebar:()=>void 0,terminalFullscreen:!1,onEnterTerminalFullscreen:()=>void 0,onExitTerminalFullscreen:()=>void 0,onNavigate:t?Dt:()=>void 0,onViewContext:Ot,onSelectSessionView:e=>Ct({...n,sessionViewId:e},!1,e),onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onThinkingLevelChange:e=>void iu(n.piboSessionId??``,`thinking`,{level:e}),onError:D,surface:`tab`});if(n.area===`context`)return(0,W.jsx)(JJ,{label:`Context`,sidebar:(0,W.jsx)(BJ,{activePanel:Fe,onSelect:Ie,toolCount:_.agentCatalog?.piboTools.length??0,mcpServerCount:_.agentCatalog?.mcpServers.length??0}),contentOverflow:`hidden`,children:Fe===`pibo-tools`?(0,W.jsx)(LK,{tools:_.agentCatalog?.piboTools??[]}):Fe===`mcp-tools`?(0,W.jsx)(BK,{servers:_.agentCatalog?.mcpServers??[],selectedServerName:ze,onServerSaved:jt}):Fe===`build-context`?(0,W.jsx)(MJ,{piboSessionId:n.piboSessionId??x}):Fe===`base-prompt`?(0,W.jsx)(kW,{}):Fe===`compaction-prompt`?(0,W.jsx)(AW,{}):(0,W.jsx)(xW,{agentProfiles:Xn,selectedFileKey:Le})});let r=n.panel??`general`;return(0,W.jsx)(JJ,{label:`Settings`,sidebar:(0,W.jsx)(vWe,{activePanel:r,onSelect:e=>Ct({area:`settings`,panel:e}),piPackageCount:_.agentCatalog?.piPackages.length??0,userSkillCount:_.agentCatalog?.userSkills.length??0}),children:(0,W.jsx)(EWe,{activePanel:r,showThinking:N,setShowThinking:P,expandThinking:F,setExpandThinking:ee,modelDefaults:_.modelDefaults,modelCatalog:_.modelCatalog,onModelDefaultsChanged:e=>v(t=>t&&{...t,modelDefaults:e}),piPackages:_.agentCatalog?.piPackages,onPiPackageChanged:Mt,onPiPackageRemoved:Nt,userSkills:_.agentCatalog?.userSkills,onUserSkillChanged:Pt,onUserSkillRemoved:Ft,piboSessionId:x,onProviderAuthChanged:qt})})};return(0,W.jsxs)(W.Fragment,{children:[Qe===`fallback`&&!er?(0,W.jsx)(SIe,{}):null,(0,W.jsxs)(`div`,{"data-pibo-debug":`chat-app`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??_.selectedPiboSessionId??void 0,"data-pibo-terminal-fullscreen":Qn?`true`:`false`,"data-pibo-preview-fullscreen":$n?`true`:`false`,className:`h-dvh overflow-hidden bg-[#101d22] text-slate-200 grid ${er?`grid-rows-[1fr]`:i?`grid-rows-[auto_1fr]`:`grid-rows-[auto_auto_1fr]`}`,children:[er||i?null:(0,W.jsx)(CIe,{area:u,identity:Zn,mobileAreaMenuOpen:Xe,mobileSidebarTriggerRef:Je,totalRoomUnreadCount:Yn,vscodeEnabled:!!_.integrations?.vscode,showMobileSidebarTrigger:u!==`vscode`,onOpenMobileSidebar:()=>We(!0),onSelectMainNavArea:nr,onToggleMobileAreaMenu:()=>Ze(e=>!e),onCloseMobileAreaMenu:()=>Ze(!1)}),er?null:(0,W.jsxs)(`div`,{children:[E?(0,W.jsx)(wIe,{message:E,onDismiss:()=>D(null)}):null,A?(0,W.jsx)(p6e,{status:A,onDismiss:()=>j(null)}):null]}),i?(0,W.jsxs)(`div`,{"data-pibo-debug":`desktop-route-shell`,"data-pibo-area":l?.area??`sessions`,className:`min-h-0 flex overflow-hidden`,children:[(0,W.jsx)(PIe,{state:o.state,onStateChange:o.setState,identity:Zn,onRefresh:()=>void Lt(x??void 0,ot.current,w??void 0,{force:!0}).then(e=>{x&&Wt(x),Et(e.selectedRoomId,e.selectedPiboSessionId)}),hidden:er,children:(0,W.jsx)(N1,{bootstrap:_,selectedRoomId:w,selectedPiboSessionId:x,showArchivedRooms:re,onToggleArchivedRooms:Cn,creatingRoom:Ve,onCreateRoom:()=>kn(),onSelectRoom:Sn,loadingRoomId:je,roomSessionsLoading:_t,onUpdateRoom:An,onArchiveRoom:Mn,onReadAllRoom:jn,onDeleteRoom:rn,newSessionProfile:B,newSessionProfileReady:oe===(w??_.selectedRoomId),onNewSessionProfileChange:Ut,selectedRoomArchived:gt,creatingSession:ve,onCreateSession:()=>wn(),showArchived:z,onToggleArchivedSessions:Tn,loadingArchivedSessions:we,visibleActiveSessions:Rn,visibleArchivedSessions:zn,totalActiveSessionCount:Ln.active.length,totalArchivedSessionCount:Ln.archived.length,hasMoreActiveSessions:Bn,hasMoreArchivedSessions:Vn,loadingActiveSessions:V,sessionListScrollRef:st,onLoadMoreSessions:Un,signalNow:it,selectedSessionPathIds:Hn,onSelectSession:xn,onRenameSession:En,onArchiveSession:Dn,onDeleteSession:dn,onViewContext:Ot,loadingPiboSessionId:ke,autoRenameSessionId:Ne,onAutoRenameConsumed:()=>Pe(null)})}),(0,W.jsx)(`main`,{"data-pibo-debug":`desktop-session-center`,hidden:$n,"aria-hidden":$n||void 0,className:`min-h-0 min-w-[250px] flex-1 overflow-hidden`,children:(0,W.jsx)(A1,{bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,contextLabel:ht,selectedRoomArchived:gt,roomNavigationPending:_t,sessionNavigationPending:!!(ke&&ke===x),selectedSessionProfile:Gn?.profile??i1(_),selectedSessionActiveModel:Jn,selectedSessionStatus:F9(Kn??qn)??Gn?.status,selectedSessionSignal:Kn,signals:et??void 0,sessionViewId:`terminal`,sessionViews:Bt,currentSessionView:Ht,desktopTerminalOnly:!0,containerResponsive:!0,creatingSession:ve,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,composerText:me,composerFocusSignal:ge,onComposerTextChange:zt,onToggleRawEvents:()=>or({kind:`session-tool`,tool:`raw-events`}),onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onSessionAgentProfileChange:e=>void vn(e),onFork:Pn,onOpenSession:Fn,onSelectSessionView:In,onCommand:Nn,onThinkingLevelChange:e=>void Nn(`/thinking ${e}`),onRefreshTrace:Gt,onRefreshBootstrap:Kt,desktopActiveTool:c,desktopToolHosts:Ge,onOpenDesktopTool:e=>void or({kind:`session-tool`,tool:e}),onCloseDesktopTool:lr,desktopPreviewFullscreen:$n,onEnterDesktopPreviewFullscreen:()=>pe(!0),onExitDesktopPreviewFullscreen:()=>pe(!1),onSend:async(e,t,n,r,i)=>{if(!(l1(x,gt)||!x))try{await _n.mutateAsync({piboSessionId:x,text:e,clientTxnId:r??c1(),roomId:w??void 0,webAnnotationIds:t,fileAttachmentPaths:n,delivery:i}),await Lt(x,ot.current,w??void 0,{force:!0}),D(null)}catch(e){throw D(e instanceof Error?e.message:String(e)),e}},onError:D})}),(0,W.jsx)(Q3e,{state:a.state,vscodeEnabled:!!_.integrations?.vscode,onStateChange:ar,onActivate:e=>void sr(e),onClose:cr,onFocusSessions:e=>void ur(e),renderPanel:(e,t)=>dr(e,t),reservedLeftWidth:o.state.collapsed?44:o.state.width,hidden:Qn,fullscreen:$n}),$t?(0,W.jsx)(I4e,{room:$t,confirmName:en,deleting:tn,onConfirmNameChange:nn,onCancel:an,onDelete:()=>void on()}):null,sn?(0,W.jsx)(F4e,{session:sn,confirmText:cn,deleting:ln,onConfirmTextChange:un,onCancel:fn,onDelete:()=>void pn()}):null]}):(0,W.jsx)(`div`,{"data-pibo-debug":`route-shell`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??void 0,className:`min-h-0 ${tr}`,children:u===`vscode`?(0,W.jsx)(P4e,{integration:_.integrations?.vscode}):u===`cron`?(0,W.jsx)(YJ,{bootstrap:_,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye}):u===`loops`?(0,W.jsx)(MY,{bootstrap:_,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye}):u===`agents`?(0,W.jsx)(IX,{agents:_.agents,initialCustomAgents:_.customAgents,initialAgentFolders:_.agentFolders,initialCatalog:_.agentCatalog,modelCatalog:_.modelCatalog,onCreateSession:e=>void wn(e),onEditContextFile:kt,onEditMcpServer:At,onAgentsChanged:()=>void Lt(x??void 0,ot.current,w??void 0,{selectSession:!1}),onAutosaveHandlerChange:wt,creatingSession:ve||gt,mobileSidebarOpen:Ue,isMobileSidebarViewport:r,onCloseMobileSidebar:Ye}):u===`workflows`?(0,W.jsx)(O4e,{route:e.area===`workflows`?e:{area:`workflows`,draftId:h},surface:`mobile`,fallback:(0,W.jsx)(y4e,{draftId:h,onNavigateDraft:e=>Ct({area:`workflows`,draftId:e})})}):u===`projects`?(0,W.jsx)(oGe,{baseBootstrap:_,routeProjectId:f,routePiboSessionId:p,sessionViews:Bt,showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,mobileSidebarOpen:Ue,onCloseMobileSidebar:Ye,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),onNavigate:Dt,onViewContext:Ot,onSelectSessionView:In,onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onThinkingLevelChange:e=>void iu(p??``,`thinking`,{level:e}),onError:D}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{"data-pibo-mobile-sidebar-backdrop":!0,"aria-hidden":`true`,className:`fixed inset-0 z-30 bg-black/60 min-[981px]:hidden transition-opacity duration-200 ${Qn?`hidden`:Ue?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,onClick:Ye}),(0,W.jsxs)(`aside`,{"data-pibo-mobile-sidebar":!0,...UJ(r,Ue,`Chat sidebar`),"data-pibo-debug":`sidebar-shell`,"data-pibo-area":u,"data-pibo-room-id":w??_.selectedRoomId??void 0,"data-pibo-selected-session-id":x??void 0,"data-pibo-state":Ue?`open`:`closed`,className:`min-h-0 overflow-hidden flex flex-col bg-[#1a262b] border-r border-slate-800 max-[980px]:fixed max-[980px]:left-0 max-[980px]:top-0 max-[980px]:bottom-0 max-[980px]:z-40 max-[980px]:w-[280px] max-[980px]:transition-transform max-[980px]:duration-200 ${Qn?`hidden`:Ue?`max-[980px]:translate-x-0`:`max-[980px]:-translate-x-full`}`,children:[(0,W.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider max-[980px]:h-auto max-[980px]:py-2 max-[980px]:flex-wrap`,children:[(0,W.jsx)(`span`,{children:u}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u===`sessions`?(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Lt(x??void 0,ot.current,w??void 0,{force:!0}).then(e=>{x&&Wt(x),u===`sessions`&&Et(e.selectedRoomId,e.selectedPiboSessionId)}),title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,W.jsx)(cl,{size:13})}):null,(0,W.jsx)(`button`,{type:`button`,onClick:Ye,className:`min-[981px]:hidden p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Close sidebar`,"aria-label":`Close sidebar`,children:(0,W.jsx)(Pl,{size:13})})]})]}),u===`sessions`?(0,W.jsx)(N1,{bootstrap:_,selectedRoomId:w,selectedPiboSessionId:x,showArchivedRooms:re,onToggleArchivedRooms:Cn,creatingRoom:Ve,onCreateRoom:()=>kn(),onSelectRoom:Sn,loadingRoomId:je,roomSessionsLoading:_t,onUpdateRoom:An,onArchiveRoom:Mn,onReadAllRoom:jn,onDeleteRoom:rn,newSessionProfile:B,newSessionProfileReady:oe===(w??_.selectedRoomId),onNewSessionProfileChange:Ut,selectedRoomArchived:gt,creatingSession:ve,onCreateSession:()=>wn(),showArchived:z,onToggleArchivedSessions:Tn,loadingArchivedSessions:we,visibleActiveSessions:Rn,visibleArchivedSessions:zn,totalActiveSessionCount:Ln.active.length,totalArchivedSessionCount:Ln.archived.length,hasMoreActiveSessions:Bn,hasMoreArchivedSessions:Vn,loadingActiveSessions:V,sessionListScrollRef:st,onLoadMoreSessions:Un,signalNow:it,selectedSessionPathIds:Hn,onSelectSession:xn,onRenameSession:En,onArchiveSession:Dn,onDeleteSession:dn,onViewContext:Ot,loadingPiboSessionId:ke,autoRenameSessionId:Ne,onAutoRenameConsumed:()=>Pe(null)}):u===`context`?(0,W.jsx)(BJ,{activePanel:Fe,onSelect:Ie,toolCount:_.agentCatalog?.piboTools.length??0,mcpServerCount:_.agentCatalog?.mcpServers.length??0}):(0,W.jsx)(vWe,{activePanel:g,onSelect:e=>Ct({area:`settings`,panel:e}),piPackageCount:_.agentCatalog?.piPackages.length??0,userSkillCount:_.agentCatalog?.userSkills.length??0})]}),u===`sessions`?(0,W.jsx)(A1,{bootstrap:_,selectedPiboSessionId:x,selectedRoomId:w,contextLabel:ht,selectedRoomArchived:gt,roomNavigationPending:_t,sessionNavigationPending:!!(ke&&ke===x),selectedSessionProfile:Gn?.profile??i1(_),selectedSessionActiveModel:Jn,selectedSessionStatus:F9(Kn??qn)??Gn?.status,selectedSessionSignal:Kn,signals:et??void 0,sessionViewId:ce,sessionViews:Bt,currentSessionView:Vt,creatingSession:ve,terminalFullscreen:Qn,onEnterTerminalFullscreen:St,onExitTerminalFullscreen:()=>de(!1),showRawEvents:I,showThinking:N,expandThinking:F,toolDisplayMode:R,commands:yn,skills:bn,composerText:me,composerFocusSignal:ge,onComposerTextChange:zt,onToggleRawEvents:()=>{let e=!I;L(e),oZ(e)},onToggleThinking:()=>{let e=!N;P(e),rZ(e)},onToggleExpandThinking:()=>{let e=!F;ee(e),iZ(e)},onToolDisplayModeChange:e=>{te(e),aZ(e)},onSessionAgentProfileChange:e=>void vn(e),onFork:Pn,onOpenSession:Fn,onSelectSessionView:In,onCommand:Nn,onThinkingLevelChange:e=>void Nn(`/thinking ${e}`),onRefreshTrace:Gt,onRefreshBootstrap:Kt,onSend:async(e,t,n,r,i)=>{if(!(l1(x,gt)||!x))try{await _n.mutateAsync({piboSessionId:x,text:e,clientTxnId:r??c1(),roomId:w??void 0,webAnnotationIds:t,fileAttachmentPaths:n,delivery:i}),await Lt(x,ot.current,w??void 0,{force:!0}),D(null)}catch(e){throw D(e instanceof Error?e.message:String(e)),e}},onError:D}):(0,W.jsx)(`main`,{className:`min-h-0 flex flex-col`,children:u===`context`?Fe===`pibo-tools`?(0,W.jsx)(LK,{tools:_.agentCatalog?.piboTools??[]}):Fe===`mcp-tools`?(0,W.jsx)(BK,{servers:_.agentCatalog?.mcpServers??[],selectedServerName:ze,onServerSaved:jt}):Fe===`build-context`?(0,W.jsx)(MJ,{piboSessionId:p??null}):Fe===`base-prompt`?(0,W.jsx)(kW,{}):Fe===`compaction-prompt`?(0,W.jsx)(AW,{}):(0,W.jsx)(xW,{agentProfiles:Xn,selectedFileKey:Le}):(0,W.jsx)(EWe,{activePanel:g,showThinking:N,setShowThinking:P,expandThinking:F,setExpandThinking:ee,modelDefaults:_.modelDefaults,modelCatalog:_.modelCatalog,onModelDefaultsChanged:e=>{v(t=>t&&{...t,modelDefaults:e})},piPackages:_.agentCatalog?.piPackages,onPiPackageChanged:Mt,onPiPackageRemoved:Nt,userSkills:_.agentCatalog?.userSkills,onUserSkillChanged:Pt,onUserSkillRemoved:Ft,piboSessionId:x,onProviderAuthChanged:qt})}),$t?(0,W.jsx)(I4e,{room:$t,confirmName:en,deleting:tn,onConfirmNameChange:nn,onCancel:an,onDelete:()=>void on()}):null,sn?(0,W.jsx)(F4e,{session:sn,confirmText:cn,deleting:ln,onConfirmTextChange:un,onCancel:fn,onDelete:()=>void pn()}):null]})})]})]})}function p6e({status:e,onDismiss:t}){let n=e.status===`starting`||e.status===`running`,r=e.totalBytes&&e.totalBytes>0?Math.min(100,Math.max(0,e.receivedBytes/e.totalBytes*100)):void 0,i=e.status===`failed`?`border-red-500/40 bg-red-500/10 text-red-100`:e.status===`completed`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-100`:`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-slate-100`,a=e.status===`completed`?`Download ready`:e.status===`failed`?`Download failed`:`Download in progress`;return(0,W.jsx)(`div`,{className:`border-b px-4 py-2 text-sm ${i}`,role:`status`,"aria-live":`polite`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider opacity-80`,children:a}),(0,W.jsx)(`div`,{className:`min-w-0 truncate font-medium`,title:e.path,children:e.filename}),(0,W.jsxs)(`div`,{className:`mt-1 text-xs text-slate-300`,children:[c6e(e),e.duplicateAttempted&&n?(0,W.jsx)(`span`,{className:`ml-2 text-amber-200`,children:`Already downloading this file. Please wait.`}):null]}),r!==void 0&&n?(0,W.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-sm bg-[#0e1116]`,"aria-label":`Download progress ${Math.floor(r)}%`,children:(0,W.jsx)(`div`,{className:`h-full bg-[#11a4d4] transition-[width]`,style:{width:`${r}%`}})}):null,r===void 0&&n?(0,W.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-sm bg-[#0e1116]`,children:(0,W.jsx)(`div`,{className:`h-full w-1/3 animate-pulse bg-[#11a4d4]`})}):null]}),n?null:(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-sm border border-slate-600 px-2 py-1 text-[11px] uppercase tracking-wider text-slate-200 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:`Dismiss`})]})})}function Q9(e,t){return e.find(e=>e.name===t||e.aliases.includes(t))}var m6e=new wn({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});function h6e(){let e=bs({select:e=>({pathname:e.location.pathname,search:e.location.search})});return(0,W.jsx)(f6e,{route:gu(e.pathname,e.search)})}var $9=Zo({component:h6e}),g6e=Yo({getParentRoute:()=>$9,path:`/`}),_6e=Yo({getParentRoute:()=>$9,path:`sessions/$piboSessionId`}),v6e=Yo({getParentRoute:()=>$9,path:`rooms/$roomId`}),y6e=Yo({getParentRoute:()=>$9,path:`rooms/$roomId/sessions/$piboSessionId`}),b6e=Yo({getParentRoute:()=>$9,path:`projects`}),x6e=Yo({getParentRoute:()=>$9,path:`projects/$projectId`}),S6e=Yo({getParentRoute:()=>$9,path:`projects/$projectId/sessions/$piboSessionId`}),C6e=Yo({getParentRoute:()=>$9,path:`vscode`}),w6e=Yo({getParentRoute:()=>$9,path:`workflows`}),T6e=Yo({getParentRoute:()=>$9,path:`workflows/drafts/$draftId`}),E6e=Yo({getParentRoute:()=>$9,path:`workflows/view/$workflowId/$workflowVersion`}),D6e=Yo({getParentRoute:()=>$9,path:`agents`}),O6e=Yo({getParentRoute:()=>$9,path:`cron`}),k6e=Yo({getParentRoute:()=>$9,path:`loops`}),A6e=Yo({getParentRoute:()=>$9,path:`ralph`}),j6e=Yo({getParentRoute:()=>$9,path:`context`}),M6e=Yo({getParentRoute:()=>$9,path:`settings`}),N6e=Yo({getParentRoute:()=>$9,path:`settings/concurrency`}),P6e=Yo({getParentRoute:()=>$9,path:`settings/previews`}),F6e=Yo({getParentRoute:()=>$9,path:`settings/transcription`}),I6e=Yo({getParentRoute:()=>$9,path:`settings/speech`}),L6e=Yo({getParentRoute:()=>$9,path:`settings/shortcuts`}),R6e=Yo({getParentRoute:()=>$9,path:`settings/maintenance`}),z6e=Yo({getParentRoute:()=>$9,path:`settings/pi-packages`}),B6e=Yo({getParentRoute:()=>$9,path:`settings/skills`}),V6e=Yo({getParentRoute:()=>$9,path:`settings/providers`}),H6e=ms({routeTree:$9.addChildren([g6e,_6e,v6e,y6e,b6e,x6e,S6e,C6e,w6e,T6e,E6e,D6e,O6e,k6e,A6e,j6e,M6e,N6e,P6e,F6e,I6e,L6e,R6e,z6e,B6e,V6e]),basepath:`/apps/chat`,stringifySearch:yu});`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=!1;navigator.serviceWorker.addEventListener(`controllerchange`,()=>{e||(e=!0,window.location.reload())}),navigator.serviceWorker.register(`/apps/chat/sw.js`).then(e=>{e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&navigator.serviceWorker.controller&&t.postMessage({type:`PIBO_CHAT_SKIP_WAITING`})})}),window.setInterval(()=>{e.update()},3e5)}).catch(()=>{})}),(0,Il.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(U.StrictMode,{children:(0,W.jsx)(kn,{client:m6e,children:(0,W.jsx)(_s,{router:H6e})})}));export{OL as n,sR as t};