@netnodeag/kraftwerk 0.86.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +35 -8
  2. package/dist/cli/kraftwerk.js +1 -1
  3. package/dist/cli/routines.d.ts +4 -2
  4. package/dist/cli/routines.js +30 -13
  5. package/dist/client/routes.d.ts +5 -0
  6. package/dist/client/routes.js +5 -0
  7. package/dist/core/agent-status.js +4 -3
  8. package/dist/core/attention.js +8 -4
  9. package/dist/core/boards.d.ts +10 -0
  10. package/dist/core/boards.js +13 -0
  11. package/dist/core/chat/context.js +12 -11
  12. package/dist/core/chat/sessions.js +2 -2
  13. package/dist/core/chat/state.d.ts +1 -1
  14. package/dist/core/chat/state.js +4 -4
  15. package/dist/core/chat/types.d.ts +6 -2
  16. package/dist/core/diagnose.js +13 -5
  17. package/dist/core/routines.d.ts +37 -11
  18. package/dist/core/routines.js +79 -27
  19. package/dist/core/skills.d.ts +2 -0
  20. package/dist/core/skills.js +2 -0
  21. package/dist/server/api/agents.d.ts +1 -0
  22. package/dist/server/api/agents.js +9 -7
  23. package/dist/server/api/boards.d.ts +3 -1
  24. package/dist/server/api/boards.js +4 -1
  25. package/dist/server/api/index.d.ts +23 -11
  26. package/dist/server/api/runs.d.ts +19 -10
  27. package/dist/server/api/runs.js +45 -2
  28. package/package.json +1 -1
  29. package/web/dist/assets/{dist-DaClI4_P.js → dist-B0kpimQd.js} +1 -1
  30. package/web/dist/assets/dist-B4JfCAqZ.js +1 -0
  31. package/web/dist/assets/{dist-ciCcv6TG.js → dist-B6J2XiOw.js} +1 -1
  32. package/web/dist/assets/{dist-1mbdSunG.js → dist-BJ7cArEV.js} +1 -1
  33. package/web/dist/assets/{dist-CPeXTjYj.js → dist-BbJD-deH.js} +1 -1
  34. package/web/dist/assets/{dist-D4JsX0B8.js → dist-BebxUYjL.js} +1 -1
  35. package/web/dist/assets/{dist-60Qxhb1I.js → dist-BmEO2riK.js} +1 -1
  36. package/web/dist/assets/{dist-CYuFWOhW.js → dist-CTlewW8J.js} +1 -1
  37. package/web/dist/assets/{dist-CVzVQqDH.js → dist-Ce7w7gso.js} +1 -1
  38. package/web/dist/assets/{dist-BRwu-xz3.js → dist-DNqCNe5Z.js} +1 -1
  39. package/web/dist/assets/{dist-BmpFCYFq.js → dist-DuNyZ7cE.js} +1 -1
  40. package/web/dist/assets/{editor-CXOAhwnW.js → editor-D7Y97r7h.js} +3 -3
  41. package/web/dist/assets/{index-BpESoZpK.js → index-BGKyxvvZ.js} +15 -15
  42. package/web/dist/assets/index-DBkbrkOH.css +2 -0
  43. package/web/dist/index.html +2 -2
  44. package/web/dist/assets/dist-B89nfy4o.js +0 -1
  45. package/web/dist/assets/index-DEO_Q944.css +0 -2
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CXOAhwnW.js","assets/dist-BUzdcj0Z.js","assets/dist-BxtR6jpW.js","assets/dist-D4JsX0B8.js","assets/dist-CYuFWOhW.js","assets/dist-BmpFCYFq.js","assets/editor-C0_Snnzk.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-D7Y97r7h.js","assets/dist-BUzdcj0Z.js","assets/dist-BxtR6jpW.js","assets/dist-BebxUYjL.js","assets/dist-CTlewW8J.js","assets/dist-DuNyZ7cE.js","assets/editor-C0_Snnzk.css"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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 u=o((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.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.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`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ee=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+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(w,w):(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,C(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ee,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(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=h(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,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var te=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)};function I(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,te)}catch(e){te(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function R(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else I(R.bind(null,e))}var z={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(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=z,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=R,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=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.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 D(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)E.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 D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,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=I,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),d=o(((e,t)=>{t.exports=u()})),f=o((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&&ee(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&&ee(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 ee(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,ee(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}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();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`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(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.browser=function(e){return{$$typeof:o,_reason:e}},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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.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=u(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=u(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,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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=u(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=u(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,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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 l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),h=o(((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=m()})),g=o((e=>{var t=p(),n=d(),r=h();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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function 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 f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),ee=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),N=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),F=Symbol.for(`react.forward_ref`),te=Symbol.for(`react.suspense`),I=Symbol.for(`react.suspense_list`),R=Symbol.for(`react.memo`),z=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.legacy_hidden`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.for(`react.view_transition`),oe=Symbol.for(`react.recoverable`),se=Symbol.iterator;function ce(e){return typeof e!=`object`||!e?null:(e=se&&e[se]||e[`@@iterator`],typeof e==`function`?e:null)}var le=Symbol.for(`react.client.reference`);function ue(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===le?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case ee:return`Fragment`;case M:return`Profiler`;case j:return`StrictMode`;case te:return`Suspense`;case I:return`SuspenseList`;case ne:return`Activity`;case ae:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case N:return(e._context.displayName||`Context`)+`.Consumer`;case F:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case R:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case z:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}var de=Array.isArray,B=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},H=[],pe=-1;function me(e){return{current:e}}function he(e){0>pe||(e.current=H[pe],H[pe]=null,pe--)}function U(e,t){pe++,H[pe]=e.current,e.current=t}var ge=me(null),_e=me(null),ve=me(null),ye=me(null);function be(e,t){switch(U(ve,t),U(_e,e),U(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=dp(t),e=fp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}he(ge),U(ge,e)}function xe(){he(ge),he(_e),he(ve)}function Se(e){var t=e.memoizedState;t!==null&&(ch._currentValue=t.memoizedState,U(ye,e)),t=ge.current;var n=fp(t,e.type);t!==n&&(U(_e,e),U(ge,n))}function Ce(e){_e.current===e&&(he(ge),he(_e)),ye.current===e&&(he(ye),ch._currentValue=fe)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+we+e+Te}var De=!1;function Oe(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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -7,7 +7,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
7
7
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{De=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ee(n):``}function ke(e,t){switch(e.tag){case 26:case 27:case 5:return Ee(e.type);case 16:return Ee(`Lazy`);case 13:return e.child!==t&&t!==null?Ee(`Suspense Fallback`):Ee(`Suspense`);case 19:return Ee(`SuspenseList`);case 0:case 15:return Oe(e.type,!1);case 11:return Oe(e.type.render,!1);case 1:return Oe(e.type,!0);case 31:return Ee(`Activity`);case 30:return Ee(`ViewTransition`);default:return``}}function Ae(e){try{var t=``,n=null;do t+=ke(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
8
  Error generating stack: `+e.message+`
9
9
  `+e.stack}}var je=Object.prototype.hasOwnProperty,Me=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,Pe=t.unstable_shouldYield,Fe=t.unstable_requestPaint,Ie=t.unstable_now,Le=t.unstable_getCurrentPriorityLevel,Re=t.unstable_ImmediatePriority,ze=t.unstable_UserBlockingPriority,Be=t.unstable_NormalPriority,Ve=t.unstable_LowPriority,He=t.unstable_IdlePriority,Ue=t.log,We=t.unstable_setDisableYieldValue,Ge=null,W=null;function Ke(e){if(typeof Ue==`function`&&We(e),W&&typeof W.setStrictMode==`function`)try{W.setStrictMode(Ge,e)}catch{}}var qe=Math.clz32?Math.clz32:Xe,Je=Math.log,Ye=Math.LN2;function Xe(e){return e>>>=0,e===0?32:31-(Je(e)/Ye|0)|0}var Ze=256,G=262144,K=4194304;function Qe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function $e(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Qe(n))):i=Qe(o):i=Qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Qe(n))):i=Qe(o)):i=Qe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function q(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function et(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-qe(n),i=1<<r;t|=e[r],n&=~i}return t}function J(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Y(){var e=K;return K<<=1,!(K&62914560)&&(K=4194304),e}function tt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function nt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function rt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-qe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&X(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function X(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-qe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function it(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-qe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function at(e,t){var n=t&-t;return n=n&42?1:ot(n),(n&(e.suspendedLanes|t))===0?n:0}function ot(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function st(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ct(){var e=V.p;return e===0?(e=window.event,e===void 0?32:wh(e.type)):e}function lt(e,t){var n=V.p;try{return V.p=e,t()}finally{V.p=n}}var ut=Math.random().toString(36).slice(2),dt=`__reactFiber$`+ut,ft=`__reactProps$`+ut,pt=`__reactContainer$`+ut,mt=`__reactEvents$`+ut,ht=`__reactListeners$`+ut,gt=`__reactHandles$`+ut,_t=`__reactResources$`+ut,vt=`__reactMarker$`+ut,Z=`__reactLoad$`+ut;function yt(e){delete e[dt],delete e[ft],delete e[ht],delete e[gt]}function bt(e){var t;if(t=e[dt])return t;for(var n=e.parentNode;n;){if(t=n[pt]||n[dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pm(e);e!==null;){if(n=e[dt])return n;e=pm(e)}return t}e=n,n=e.parentNode}return null}function Q(e){if(e=e[dt]||e[pt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function xt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function St(e){var t=e[_t];return t||=e[_t]={hoistableStyles:new Map,hoistableScripts:new Map},t}function $(e){e[vt]=!0}function Ct(e){e[Z]=void 0}var wt=new Set,Tt={};function Et(e,t){Dt(e,t),Dt(e+`Capture`,t)}function Dt(e,t){for(Tt[e]=t,e=0;e<t.length;e++)wt.add(t[e])}var Ot=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),kt={},At={};function jt(e){return je.call(At,e)?!0:je.call(kt,e)?!1:Ot.test(e)?At[e]=!0:(kt[e]=!0,!1)}var Mt=!1;function Nt(){var e=Mt;return Mt=!1,e}function Pt(e,t,n){if(jt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Ft(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function It(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Lt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Rt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function zt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Bt(e){if(!e._valueTracker){var t=Rt(e)?`checked`:`value`;e._valueTracker=zt(e,t,``+e[t])}}function Vt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Rt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var Ht=/[\n"\\]/g;function Ut(e){return e.replace(Ht,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Wt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Lt(t)):e.value!==``+Lt(t)&&(e.value=``+Lt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Kt(e,Lt(n)):o===`number`&&e.value==t?Kt(e,Lt(e.value)):Kt(e,Lt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Lt(s):e.removeAttribute(`name`)}function Gt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Bt(e);return}n=n==null?``:``+Lt(n),t=t==null?n:``+Lt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Bt(e)}function Kt(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function qt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Lt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Jt(e,t,n){t!=null&&(t=``+Lt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Lt(n)}function Yt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(de(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Lt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Bt(e)}function Xt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Zt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Qt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Zt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function $t(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Mt=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(Qt(e,a,r),Mt=!0)}else for(var o in t)t.hasOwnProperty(o)&&Qt(e,o,t[o])}function en(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var tn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),nn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rn(e){return nn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function an(){}var on=null;function sn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var cn=null,ln=null;function un(e){var t=Q(e);if(t&&(e=t.stateNode)){var n=e[ft]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Wt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Ut(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ft]||null;if(!a)throw Error(i(90));Wt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Vt(r)}break a;case`textarea`:Jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&qt(e,!!n.multiple,t,!1)}}}var dn=!1;function fn(e,t,n){if(dn)return e(t,n);dn=!0;try{return e(t)}finally{if(dn=!1,(cn!==null||ln!==null)&&(Ld(),cn&&(t=cn,e=ln,ln=cn=null,un(t),e)))for(t=0;t<e.length;t++)un(e[t])}}function pn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ft]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var mn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,hn=!1;if(mn)try{var gn={};Object.defineProperty(gn,"passive",{get:function(){hn=!0}}),window.addEventListener(`test`,gn,gn),window.removeEventListener(`test`,gn,gn)}catch{hn=!1}var _n=null,vn=null,yn=null;function bn(){if(yn)return yn;var e,t=vn,n=t.length,r,i=`value`in _n?_n.value:_n.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return yn=i.slice(e,1<r?1-r:void 0)}function xn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Sn(){return!0}function Cn(){return!1}function wn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Sn:Cn,this.isPropagationStopped=Cn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Sn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Sn)},persist:function(){},isPersistent:Sn}),t}var Tn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},En=wn(Tn),Dn=D({},Tn,{view:0,detail:0}),On=wn(Dn),kn,An,jn,Mn=D({},Dn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Un,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==jn&&(jn&&e.type===`mousemove`?(kn=e.screenX-jn.screenX,An=e.screenY-jn.screenY):An=kn=0,jn=e),kn)},movementY:function(e){return`movementY`in e?e.movementY:An}}),Nn=wn(Mn),Pn=wn(D({},Mn,{dataTransfer:0})),Fn=wn(D({},Dn,{relatedTarget:0})),In=wn(D({},Tn,{animationName:0,elapsedTime:0,pseudoElement:0})),Ln=wn(D({},Tn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Rn=wn(D({},Tn,{data:0})),zn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Bn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Vn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Hn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Vn[e])?!!t[e]:!1}function Un(){return Hn}var Wn=wn(D({},Dn,{key:function(e){if(e.key){var t=zn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=xn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Bn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Un,charCode:function(e){return e.type===`keypress`?xn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?xn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Gn=wn(D({},Mn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Kn=wn(D({},Tn,{submitter:0})),qn=wn(D({},Dn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Un})),Jn=wn(D({},Tn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Yn=wn(D({},Mn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Xn=wn(D({},Tn,{newState:0,oldState:0,source:0})),Zn=[9,13,27,32],Qn=mn&&`CompositionEvent`in window,$n=null;mn&&`documentMode`in document&&($n=document.documentMode);var er=mn&&`TextEvent`in window&&!$n,tr=mn&&(!Qn||$n&&8<$n&&11>=$n),nr=` `,rr=!1;function ir(e,t){switch(e){case`keyup`:return Zn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function ar(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var or=!1;function sr(e,t){switch(e){case`compositionend`:return ar(t);case`keypress`:return t.which===32?(rr=!0,nr):null;case`textInput`:return e=t.data,e===nr&&rr?null:e;default:return null}}function cr(e,t){if(or)return e===`compositionend`||!Qn&&ir(e,t)?(e=bn(),yn=vn=_n=null,or=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return tr&&t.locale!==`ko`?null:t.data;default:return null}}var lr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ur(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!lr[e.type]:t===`textarea`}function dr(e,t,n,r){cn?ln?ln.push(r):ln=[r]:cn=r,t=Jf(t,`onChange`),0<t.length&&(n=new En(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var fr=null,pr=null;function mr(e){Bf(e,0)}function hr(e){if(Vt(xt(e)))return e}function gr(e,t){if(e===`change`)return t}var _r=!1;if(mn){var vr;if(mn){var yr=`oninput`in document;if(!yr){var br=document.createElement(`div`);br.setAttribute(`oninput`,`return;`),yr=typeof br.oninput==`function`}vr=yr}else vr=!1;_r=vr&&(!document.documentMode||9<document.documentMode)}function xr(){fr&&(fr.detachEvent(`onpropertychange`,Sr),pr=fr=null)}function Sr(e){if(e.propertyName===`value`&&hr(pr)){var t=[];dr(t,pr,e,sn(e)),fn(mr,t)}}function Cr(e,t,n){e===`focusin`?(xr(),fr=t,pr=n,fr.attachEvent(`onpropertychange`,Sr)):e===`focusout`&&xr()}function wr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return hr(pr)}function Tr(e,t){if(e===`click`)return hr(t)}function Er(e,t){if(e===`input`||e===`change`)return hr(t)}function Dr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Or=typeof Object.is==`function`?Object.is:Dr;function kr(e,t){if(Or(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!je.call(t,i)||!Or(e[i],t[i]))return!1}return!0}function Ar(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function jr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Mr(e,t){var n=jr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=jr(n)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ar(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ar(e.document)}return t}function Fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ir=mn&&`documentMode`in document&&11>=document.documentMode,Lr=null,Rr=null,zr=null,Br=!1;function Vr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Br||Lr==null||Lr!==Ar(r)||(r=Lr,`selectionStart`in r&&Fr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),zr&&kr(zr,r)||(zr=r,r=Jf(Rr,`onSelect`),0<r.length&&(t=new En(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Lr)))}function Hr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ur={animationend:Hr(`Animation`,`AnimationEnd`),animationiteration:Hr(`Animation`,`AnimationIteration`),animationstart:Hr(`Animation`,`AnimationStart`),transitionrun:Hr(`Transition`,`TransitionRun`),transitionstart:Hr(`Transition`,`TransitionStart`),transitioncancel:Hr(`Transition`,`TransitionCancel`),transitionend:Hr(`Transition`,`TransitionEnd`)},Wr={},Gr={};mn&&(Gr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ur.animationend.animation,delete Ur.animationiteration.animation,delete Ur.animationstart.animation),`TransitionEvent`in window||delete Ur.transitionend.transition);function Kr(e){if(Wr[e])return Wr[e];if(!Ur[e])return e;var t=Ur[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gr)return Wr[e]=t[n];return e}var qr=Kr(`animationend`),Jr=Kr(`animationiteration`),Yr=Kr(`animationstart`),Xr=Kr(`transitionrun`),Zr=Kr(`transitionstart`),Qr=Kr(`transitioncancel`),$r=Kr(`transitionend`),ei=new Map,ti=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);ti.push(`scrollEnd`);function ni(e,t){ei.set(e,t),Et(t,[e])}var ri=0;function ii(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=vd.identifierPrefix;var n=ri++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function ai(e){if(e==null||typeof e==`string`)return e;var t=null,n=Ed;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function oi(e,t){return e=ai(e),t=ai(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var si=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)},ci=[],li=0,ui=0;function di(){for(var e=li,t=ui=li=0;t<e;){var n=ci[t];ci[t++]=null;var r=ci[t];ci[t++]=null;var i=ci[t];ci[t++]=null;var a=ci[t];if(ci[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&hi(n,i,a)}}function fi(e,t,n,r){ci[li++]=e,ci[li++]=t,ci[li++]=n,ci[li++]=r,ui|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function pi(e,t,n,r){return fi(e,t,n,r),gi(e)}function mi(e,t){return fi(e,null,null,t),gi(e)}function hi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-qe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function gi(e){if(50<Dd)throw Dd=0,Od=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var _i={};function vi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function yi(e,t,n,r){return new vi(e,t,n,r)}function bi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function xi(e,t){var n=e.alternate;return n===null?(n=yi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Si(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ci(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)bi(r)&&(s=1);else if(typeof r==`string`)s=Jm(e,n,ge.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ne:return e=yi(31,n,t,a),e.elementType=ne,e.lanes=o,e;case ee:return wi(n.children,a,o,t);case j:s=8,a|=24;break;case M:return e=yi(12,n,t,a|2),e.elementType=M,e.lanes=o,e;case te:return e=yi(13,n,t,a),e.elementType=te,e.lanes=o,e;case I:return e=yi(19,n,t,a),e.elementType=I,e.lanes=o,e;case re:case ae:return e=a|32,e=yi(30,n,t,e),e.elementType=ae,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case P:s=10;break a;case N:s=9;break a;case F:s=11;break a;case R:s=14;break a;case z:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=yi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function wi(e,t,n,r){return e=yi(7,e,r,t),e.lanes=n,e}function Ti(e,t,n){return e=yi(6,e,null,t),e.lanes=n,e}function Ei(e){var t=yi(18,null,null,0);return t.stateNode=e,t}function Di(e,t,n){return t=yi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Oi=new WeakMap;function ki(e,t){if(typeof e==`object`&&e){var n=Oi.get(e);return n===void 0?(t={value:e,source:t,stack:Ae(t)},Oi.set(e,t),t):n}return{value:e,source:t,stack:Ae(t)}}var Ai=[],ji=0,Mi=null,Ni=0,Pi=[],Fi=0,Ii=null,Li=1,Ri=``;function zi(e,t){Ai[ji++]=Ni,Ai[ji++]=Mi,Mi=e,Ni=t}function Bi(e,t,n){Pi[Fi++]=Li,Pi[Fi++]=Ri,Pi[Fi++]=Ii,Ii=e;var r=Li;e=Ri;var i=32-qe(r)-1;r&=~(1<<i),n+=1;var a=32-qe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Li=1<<32-qe(t)+i|n<<i|r,Ri=a+e}else Li=1<<a|n<<i|r,Ri=e}function Vi(e){e.return!==null&&(zi(e,1),Bi(e,1,0))}function Hi(e){for(;e===Mi;)Mi=Ai[--ji],Ai[ji]=null,Ni=Ai[--ji],Ai[ji]=null;for(;e===Ii;)Ii=Pi[--Fi],Pi[Fi]=null,Ri=Pi[--Fi],Pi[Fi]=null,Li=Pi[--Fi],Pi[Fi]=null}function Ui(e,t){Pi[Fi++]=Li,Pi[Fi++]=Ri,Pi[Fi++]=Ii,Li=t.id,Ri=t.overflow,Ii=e}var Wi=null,Gi=null,Ki=!1,qi=null,Ji=!1,Yi=Error(i(519));function Xi(e){throw na(ki(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Yi}function Zi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[dt]=e,t[ft]=r,n){case`dialog`:Vf(`cancel`,t),Vf(`close`,t);break;case`iframe`:case`object`:case`embed`:Vf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Rf.length;n++)Vf(Rf[n],t);break;case`source`:Vf(`error`,t);break;case`img`:case`image`:case`link`:Vf(`error`,t),Vf(`load`,t);break;case`details`:Vf(`toggle`,t);break;case`input`:Vf(`invalid`,t),Gt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Vf(`invalid`,t);break;case`textarea`:Vf(`invalid`,t),Yt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||ep(t.textContent,n)?(r.popover!=null&&(Vf(`beforetoggle`,t),Vf(`toggle`,t)),r.onScroll!=null&&Vf(`scroll`,t),r.onScrollEnd!=null&&Vf(`scrollend`,t),r.onClick!=null&&(t.onclick=an),t=!0):t=!1,t||Xi(e,!0)}function Qi(e){for(Wi=e.return;Wi;)switch(Wi.tag){case 5:case 31:case 13:Ji=!1;return;case 27:case 3:Ji=!0;return;default:Wi=Wi.return}}function $i(e){if(e!==Wi)return!1;if(!Ki)return Qi(e),Ki=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||mp(e.type,e.memoizedProps)),n=!n),n&&Gi&&Xi(e),Qi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Gi=fm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Gi=fm(e)}else t===27?(t=Gi,Cp(e.type)?(e=dm,dm=null,Gi=e):Gi=t):Gi=Wi?um(e.stateNode.nextSibling):null;return!0}function ea(){Gi=Wi=null,Ki=!1}function ta(){var e=qi;return e!==null&&(ud===null?ud=e:ud.push.apply(ud,e),qi=null),e}function na(e){qi===null?qi=[e]:qi.push(e)}var ra=me(null),ia=null,aa=null;function oa(e,t,n){U(ra,t._currentValue),t._currentValue=n}function sa(e){e._currentValue=ra.current,he(ra)}function ca(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function la(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ca(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ca(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),ca(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function ua(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Or(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ye.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[ch]:e.push(ch))}a=a.return}return e!==null&&la(t,e,n,r),t.flags|=262144,e!==null}function da(e){for(e=e.firstContext;e!==null;){if(!Or(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function fa(e){ia=e,aa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function pa(e){return ha(ia,e)}function ma(e,t){return ia===null&&fa(e),ha(e,t)}function ha(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},aa===null){if(e===null)throw Error(i(308));aa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else aa=aa.next=t;return n}var ga=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},_a=t.unstable_scheduleCallback,va=t.unstable_NormalPriority,ya={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ba(){return{controller:new ga,data:new Map,refCount:0}}function xa(e){e.refCount--,e.refCount===0&&_a(va,function(){e.controller.abort()})}function Sa(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Ca=null;function wa(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ta=null,Ea=0,Da=0,Oa=null;function ka(e,t){if(Ta===null){var n=Ta=[];Ea=0,Da=Nf(),Oa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ea++,t.then(Aa,Aa),t}function Aa(){if(--Ea===0&&(Ca=null,Ta!==null)){Oa!==null&&(Oa.status=`fulfilled`);var e=Ta;Ta=null,Da=0,Oa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ja(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ma=B.S;B.S=function(e,t){if(pd=Ie(),typeof t==`object`&&t&&typeof t.then==`function`&&ka(e,t),Ca!==null)for(var n=yf;n!==null;)Sa(n,Ca),n=n.next;if(n=e.types,n!==null){for(var r=yf;r!==null;)Sa(r,n),r=r.next;if(Da!==0){r=Ca,r===null&&(r=Ca=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ma!==null&&Ma(e,t)};var Na=me(null);function Pa(){var e=Na.current;return e===null?Ju.pooledCache:e}function Fa(e,t){t===null?U(Na,Na.current):U(Na,t.pool)}function Ia(){var e=Pa();return e===null?null:{parent:ya._currentValue,pool:e}}var La=Error(i(460)),Ra=Error(i(474)),za=Error(i(542)),Ba={then:function(){}};function Va(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ha(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(an,an),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ka(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(an,an);else{if(e=Ju,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ka(e),e}throw Wa=t,La}}function Ua(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Wa=e,La):e}}var Wa=null;function Ga(){if(Wa===null)throw Error(i(459));var e=Wa;return Wa=null,e}function Ka(e){if(e===La||e===za)throw Error(i(483))}var qa=null,Ja=0;function Ya(e){var t=Ja;return Ja+=1,qa===null&&(qa=[]),Ha(qa,e,t)}function Xa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Za(e,t){throw t.$$typeof===O?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Qa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=xi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ti(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===ee?(e=d(e,t,n.props.children,r,n.key),Xa(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===z&&Ua(i)===t.type)?(t=a(t,n.props),Xa(t,n),t.return=e,t):(t=Ci(n.type,n.key,n.props,null,e.mode,r),Xa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Di(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=wi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ti(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Ci(t.type,t.key,t.props,null,e.mode,n),Xa(n,t),n.return=e,n;case A:return t=Di(t,e.mode,n),t.return=e,t;case z:return t=Ua(t),f(e,t,n)}if(de(t)||ce(t))return t=wi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ya(t),n);if(t.$$typeof===P)return f(e,ma(e,t),n);Za(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case z:return n=Ua(n),p(e,t,n,r)}if(de(n)||ce(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ya(n),r);if(n.$$typeof===P)return p(e,t,ma(e,n),r);Za(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case z:return r=Ua(r),m(e,t,n,r,i)}if(de(r)||ce(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ya(r),i);if(r.$$typeof===P)return m(e,t,n,ma(t,r),i);Za(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ki&&zi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ki&&zi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ki&&zi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ki&&zi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ki&&zi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ki&&zi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ee&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case k:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ee){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),Xa(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===z&&Ua(l)===r.type){n(e,r.sibling),c=a(r,o.props),Xa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ee?(c=wi(o.props.children,e.mode,c,o.key),Xa(c,o),c.return=e,e=c):(c=Ci(o.type,o.key,o.props,null,e.mode,c),Xa(c,o),c.return=e,e=c)}return s(e);case A:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Di(o,e.mode,c),c.return=e,e=c}return s(e);case z:return o=Ua(o),_(e,r,o,c)}if(de(o))return h(e,r,o,c);if(ce(o)){if(l=ce(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,Ya(o),c);if(o.$$typeof===P)return _(e,r,ma(e,o),c);Za(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ti(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ja=0;var i=_(e,t,n,r);return qa=null,i}catch(t){if(t===La||t===za)throw t;var a=yi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var $a=Qa(!0),eo=Qa(!1),to=!1;function no(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ro(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function io(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ao(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,qu&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=gi(e),hi(e,null,n),t}return fi(e,r,t,n),gi(e)}function oo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}function so(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var co=!1;function lo(){if(co){var e=Oa;if(e!==null)throw e}}function uo(e,t,n,r){co=!1;var i=e.updateQueue;to=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Xu&f)===f:(r&f)===f){f!==0&&f===Da&&(co=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:to=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),id|=o,e.lanes=o,e.memoizedState=d}}function fo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function po(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)fo(n[e],t)}var mo=me(null),ho=me(0);function go(e,t){e=nd,U(ho,e),U(mo,t),nd=e|t.baseLanes}function _o(){U(ho,nd),U(mo,mo.current)}function vo(){nd=ho.current,he(mo),he(ho)}var yo=me(null),bo=null;function xo(e){var t=e.alternate;U(Eo,Eo.current&1),U(yo,e),bo===null&&(t===null||mo.current!==null||t.memoizedState!==null)&&(bo=e)}function So(e){U(Eo,Eo.current),U(yo,e),bo===null&&(bo=e)}function Co(e){e.tag===22?(U(Eo,Eo.current),U(yo,e),bo===null&&(bo=e)):wo()}function wo(){U(Eo,Eo.current),U(yo,yo.current)}function To(e){he(yo),bo===e&&(bo=null),he(Eo)}var Eo=me(0);function Do(e,t){U(yo,yo.current),U(Eo,t)}function Oo(e){he(Eo),he(yo),bo===e&&(bo=null)}function ko(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||sm(n)||cm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ao=0,jo=null,Mo=null,No=null,Po=!1,Fo=!1,Io=!1,Lo=0,Ro=0,zo=null,Bo=0;function Vo(){throw Error(i(321))}function Ho(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Or(e[n],t[n]))return!1;return!0}function Uo(e,t,n,r,i,a){return Ao=a,jo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,B.H=e===null||e.memoizedState===null?oc:sc,Io=!1,a=n(r,i),Io=!1,Fo&&(a=Go(t,n,r,i)),Wo(e),a}function Wo(e){B.H=ac;var t=Mo!==null&&Mo.next!==null;if(Ao=0,No=Mo=jo=null,Po=!1,Ro=0,zo=null,t)throw Error(i(300));e===null||wc||(e=e.dependencies,e!==null&&da(e)&&(wc=!0))}function Go(e,t,n,r){jo=e;var a=0;do{if(Fo&&(zo=null),Ro=0,Fo=!1,25<=a)throw Error(i(301));if(a+=1,No=Mo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}B.H=cc,o=t(n,r)}while(Fo);return o}function Ko(){var e=B.H,t=e.useState()[0];return t=typeof t.then==`function`?$o(t):t,e=e.useState()[0],(Mo===null?null:Mo.memoizedState)!==e&&(jo.flags|=1024),t}function qo(){var e=Lo!==0;return Lo=0,e}function Jo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Yo(e){if(Po){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Po=!1}Ao=0,No=Mo=jo=null,Fo=!1,Ro=Lo=0,zo=null}function Xo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return No===null?jo.memoizedState=No=e:No=No.next=e,No}function Zo(){if(Mo===null){var e=jo.alternate;e=e===null?null:e.memoizedState}else e=Mo.next;var t=No===null?jo.memoizedState:No.next;if(t!==null)No=t,Mo=e;else{if(e===null)throw jo.alternate===null?Error(i(467)):Error(i(310));Mo=e,e={memoizedState:Mo.memoizedState,baseState:Mo.baseState,baseQueue:Mo.baseQueue,queue:Mo.queue,next:null},No===null?jo.memoizedState=No=e:No=No.next=e}return No}function Qo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function $o(e){var t=Ro;return Ro+=1,zo===null&&(zo=[]),e=Ha(zo,e,t),t=jo,(No===null?t.memoizedState:No.next)===null&&(t=t.alternate,B.H=t===null||t.memoizedState===null?oc:sc),e}function es(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return $o(e);if(e.$$typeof===oe)return;if(e.$$typeof===P)return pa(e)}throw Error(i(438,String(e)))}function ts(e){var t=null,n=jo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=jo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Qo(),jo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ie;return t.index++,n}function ns(e,t){return typeof t==`function`?t(e):t}function rs(e){return is(Zo(),Mo,e)}function is(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Ao&f)===f:(Xu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Da&&(d=!0);else if((Ao&p)===p){u=u.next,p===Da&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,jo.lanes|=p,id|=p;f=u.action,Io&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,jo.lanes|=f,id|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Or(o,e.memoizedState)&&(wc=!0,d&&(n=Oa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function as(e){var t=Zo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Or(o,t.memoizedState)||(wc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function os(e,t,n){var r=jo,a=Zo(),o=Ki;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Or((Mo||a).memoizedState,n);if(s&&(a.memoizedState=n,wc=!0),a=a.queue,js(ls.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||No!==null&&!!(No.memoizedState.tag&1),Es(e?9:8,{destroy:void 0},cs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,Ju===null)throw Error(i(349));o||Ao&127||ss(r,t,n)}return n}function ss(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=jo.updateQueue,t===null?(t=Qo(),jo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function cs(e,t,n,r){t.value=n,t.getSnapshot=r,us(t)&&ds(e)}function ls(e,t,n){return n(function(){us(t)&&ds(e)})}function us(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Or(e,n)}catch{return!0}}function ds(e){var t=mi(e,2);t!==null&&Md(t,e,2)}function fs(e){var t=Xo();if(typeof e==`function`){var n=e;if(e=n(),Io){Ke(!0);try{n()}finally{Ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:e},t}function ps(e,t,n,r){return e.baseState=n,is(e,Mo,typeof r==`function`?r:ns)}function ms(e,t,n,r,a){if(nc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};B.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,hs(t,o)):(o.next=n.next,t.pending=n.next=o)}}function hs(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=B.T,o={};o.types=a===null?null:a.types,B.T=o;try{var s=n(i,r),c=B.S;c!==null&&c(o,s),gs(e,t,s)}catch(n){vs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),B.T=a}}else try{a=n(i,r),gs(e,t,a)}catch(n){vs(e,t,n)}}function gs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){_s(e,t,n)},function(n){return vs(e,t,n)}):_s(e,t,n)}function _s(e,t,n){t.status=`fulfilled`,t.value=n,ys(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,hs(e,n)))}function vs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ys(t),t=t.next;while(t!==r)}e.action=null}function ys(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function bs(e,t){return t}function xs(e,t){if(Ki){var n=Ju.formState;if(n!==null){a:{var r=jo;if(Ki){if(Gi){b:{for(var i=Gi,a=Ji;i.nodeType!==8;)if(!a||(i=um(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Gi=um(i.nextSibling),r=i.data===`F!`;break a}}Xi(r)}r=!1}r&&(t=n[0])}}return n=Xo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bs,lastRenderedState:t},n.queue=r,n=$s.bind(null,jo,r),r.dispatch=n,r=fs(!1),a=tc.bind(null,jo,!1,r.queue),r=Xo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ms.bind(null,jo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ss(e){return Cs(Zo(),Mo,e)}function Cs(e,t,n){if(t=is(e,t,bs)[0],e=rs(ns)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=$o(t)}catch(e){throw e===La?za:e}else r=t;t=Zo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(jo.flags|=2048,Es(9,{destroy:void 0},ws.bind(null,i,n),null)),[r,a,e]}function ws(e,t){e.action=t}function Ts(e){var t=Zo(),n=Mo;if(n!==null)return Cs(t,n,e);Zo(),t=t.memoizedState,n=Zo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Es(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=jo.updateQueue,t===null&&(t=Qo(),jo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ds(){return Zo().memoizedState}function Os(e,t,n,r){var i=Xo();jo.flags|=e,i.memoizedState=Es(1|t,{destroy:void 0},n,r===void 0?null:r)}function ks(e,t,n,r){var i=Zo();r=r===void 0?null:r;var a=i.memoizedState.inst;Mo!==null&&r!==null&&Ho(r,Mo.memoizedState.deps)?i.memoizedState=Es(t,a,n,r):(jo.flags|=e,i.memoizedState=Es(1|t,a,n,r))}function As(e,t){Os(8390656,8,e,t)}function js(e,t){ks(2048,8,e,t)}function Ms(e){jo.flags|=4;var t=jo.updateQueue;if(t===null)t=Qo(),jo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ns(e){var t=Zo().memoizedState;return Ms({ref:t,nextImpl:e}),function(){if(qu&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ps(e,t){return ks(4,2,e,t)}function Fs(e,t){return ks(4,4,e,t)}function Is(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ls(e,t,n){n=n==null?null:n.concat([e]),ks(4,4,Is.bind(null,t,e),n)}function Rs(){}function zs(e,t){var n=Zo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Ho(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Bs(e,t){var n=Zo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Ho(t,r[1]))return r[0];if(r=e(),Io){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r}function Vs(e,t,n){return n===void 0||Ao&1073741824&&!(Xu&261930)?e.memoizedState=t:(e.memoizedState=n,e=Ad(),jo.lanes|=e,id|=e,n)}function Hs(e,t,n,r){return Or(n,t)?n:mo.current===null?!(Ao&106)||Ao&1073741824&&!(Xu&261930)?(wc=!0,e.memoizedState=n):(e=Ad(),jo.lanes|=e,id|=e,t):(e=Vs(e,n,r),Or(e,t)||(wc=!0),e)}function Us(e,t,n,r,i){var a=V.p;V.p=a!==0&&8>a?a:8;var o=B.T,s={};s.types=o===null?null:o.types,B.T=s,tc(e,!1,t,n);try{var c=i(),l=B.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ec(e,t,ja(c,r),kd(e)):ec(e,t,r,kd(e))}catch(n){ec(e,t,{then:function(){},status:`rejected`,reason:n},kd())}finally{V.p=a,o!==null&&s.types!==null&&(o.types=s.types),B.T=o}}function Ws(){}function Gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ks(e).queue;Us(e,a,t,fe,n===null?Ws:function(){return qs(e),n(r)})}function Ks(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:fe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function qs(e){var t=Ks(e);t.next===null&&(t=e.alternate.memoizedState),ec(e,t.next.queue,{},kd())}function Js(){return pa(ch)}function Ys(){return Zo().memoizedState}function Xs(){return Zo().memoizedState}function Zs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=kd();e=io(n);var r=ao(t,e,n);r!==null&&(Md(r,t,n),oo(r,t,n)),t={cache:ba()},e.payload=t;return}t=t.return}}function Qs(e,t,n){var r=kd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},nc(e)?rc(t,n):(n=pi(e,t,n,r),n!==null&&(Md(n,e,r),ic(n,t,r)))}function $s(e,t,n){ec(e,t,n,kd())}function ec(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(nc(e))rc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Or(s,o))return fi(e,t,i,0),Ju===null&&di(),!1}catch{}if(n=pi(e,t,i,r),n!==null)return Md(n,e,r),ic(n,t,r),!0}return!1}function tc(e,t,n,r){if(r={lane:2,revertLane:Nf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},nc(e)){if(t)throw Error(i(479))}else t=pi(e,n,r,2),t!==null&&Md(t,e,2)}function nc(e){var t=e.alternate;return e===jo||t!==null&&t===jo}function rc(e,t){Fo=Po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ic(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}var ac={readContext:pa,use:es,useCallback:Vo,useContext:Vo,useEffect:Vo,useImperativeHandle:Vo,useLayoutEffect:Vo,useInsertionEffect:Vo,useMemo:Vo,useReducer:Vo,useRef:Vo,useState:Vo,useDebugValue:Vo,useDeferredValue:Vo,useTransition:Vo,useSyncExternalStore:Vo,useId:Vo,useHostTransitionStatus:Vo,useFormState:Vo,useActionState:Vo,useOptimistic:Vo,useMemoCache:Vo,useCacheRefresh:Vo,useEffectEvent:Vo},oc={readContext:pa,use:es,useCallback:function(e,t){return Xo().memoizedState=[e,t===void 0?null:t],e},useContext:pa,useEffect:As,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Os(4194308,4,Is.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Os(4194308,4,e,t)},useInsertionEffect:function(e,t){Os(4,2,e,t)},useMemo:function(e,t){var n=Xo();t=t===void 0?null:t;var r=e();if(Io){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Xo();if(n!==void 0){var i=n(t);if(Io){Ke(!0);try{n(t)}finally{Ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Qs.bind(null,jo,e),[r.memoizedState,e]},useRef:function(e){var t=Xo();return e={current:e},t.memoizedState=e},useState:function(e){e=fs(e);var t=e.queue,n=$s.bind(null,jo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Rs,useDeferredValue:function(e,t){return Vs(Xo(),e,t)},useTransition:function(){var e=fs(!1);return e=Us.bind(null,jo,e.queue,!0,!1),Xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=jo,a=Xo();if(Ki){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ju===null)throw Error(i(349));Xu&127||ss(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,As(ls.bind(null,r,o,e),[e]),r.flags|=2048,Es(9,{destroy:void 0},cs.bind(null,r,o,n,t),null),n},useId:function(){var e=Xo(),t=Ju.identifierPrefix;if(Ki){var n=Ri,r=Li;n=(r&~(1<<32-qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Lo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Bo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Js,useFormState:xs,useActionState:xs,useOptimistic:function(e){var t=Xo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=tc.bind(null,jo,!0,n),n.dispatch=t,[e,t]},useMemoCache:ts,useCacheRefresh:function(){return Xo().memoizedState=Zs.bind(null,jo)},useEffectEvent:function(e){var t=Xo(),n={impl:e};return t.memoizedState=n,function(){if(qu&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},sc={readContext:pa,use:es,useCallback:zs,useContext:pa,useEffect:js,useImperativeHandle:Ls,useInsertionEffect:Ps,useLayoutEffect:Fs,useMemo:Bs,useReducer:rs,useRef:Ds,useState:function(){return rs(ns)},useDebugValue:Rs,useDeferredValue:function(e,t){return Hs(Zo(),Mo.memoizedState,e,t)},useTransition:function(){var e=rs(ns)[0],t=Zo().memoizedState;return[typeof e==`boolean`?e:$o(e),t]},useSyncExternalStore:os,useId:Ys,useHostTransitionStatus:Js,useFormState:Ss,useActionState:Ss,useOptimistic:function(e,t){return ps(Zo(),Mo,e,t)},useMemoCache:ts,useCacheRefresh:Xs,useEffectEvent:Ns},cc={readContext:pa,use:es,useCallback:zs,useContext:pa,useEffect:js,useImperativeHandle:Ls,useInsertionEffect:Ps,useLayoutEffect:Fs,useMemo:Bs,useReducer:as,useRef:Ds,useState:function(){return as(ns)},useDebugValue:Rs,useDeferredValue:function(e,t){var n=Zo();return Mo===null?Vs(n,e,t):Hs(n,Mo.memoizedState,e,t)},useTransition:function(){var e=as(ns)[0],t=Zo().memoizedState;return[typeof e==`boolean`?e:$o(e),t]},useSyncExternalStore:os,useId:Ys,useHostTransitionStatus:Js,useFormState:Ts,useActionState:Ts,useOptimistic:function(e,t){var n=Zo();return Mo===null?(n.baseState=e,[e,n.queue.dispatch]):ps(n,Mo,e,t)},useMemoCache:ts,useCacheRefresh:Xs,useEffectEvent:Ns};function lc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var uc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=kd(),i=io(r);i.payload=t,n!=null&&(i.callback=n),t=ao(e,i,r),t!==null&&(Md(t,e,r),oo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=kd(),i=io(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ao(e,i,r),t!==null&&(Md(t,e,r),oo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=kd(),r=io(n);r.tag=2,t!=null&&(r.callback=t),t=ao(e,r,n),t!==null&&(Md(t,e,n),oo(t,e,n))}};function dc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!kr(n,r)||!kr(i,a):!0}function fc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&uc.enqueueReplaceState(t,t.state,null)}function pc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function mc(e){si(e)}function hc(e){console.error(e)}function gc(e){si(e)}function _c(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function vc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function yc(e,t,n){return n=io(n),n.tag=3,n.payload={element:null},n.callback=function(){_c(e,t)},n}function bc(e){return e=io(e),e.tag=3,e}function xc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){vc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){vc(t,n,r),typeof i!=`function`&&(gd===null?gd=new Set([this]):gd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Sc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ua(t,n,a,!0),n=yo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return bo===null?Wd():n.alternate===null&&rd===0&&(rd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ba?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),pf(e,r,a)),!1;case 22:return n.flags|=65536,r===Ba?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),pf(e,r,a)),!1}throw Error(i(435,n.tag))}return pf(e,r,a),Wd(),!1}if(Ki)return t=yo.current,t===null?(r!==Yi&&(t=Error(i(423),{cause:r}),na(ki(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ki(r,n),a=yc(e.stateNode,r,a),so(e,a),rd!==4&&(rd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Yi&&(e=Error(i(422),{cause:r}),na(ki(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ki(o,n),ld===null?ld=[o]:ld.push(o),rd!==4&&(rd=2),t===null)return!0;r=ki(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=yc(n.stateNode,r,e),so(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(gd===null||!gd.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=bc(a),xc(a,e,n,r),so(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Cc=Error(i(461)),wc=!1;function Tc(e,t,n,r){t.child=e===null?eo(t,null,n,r):$a(t,e.child,n,r)}function Ec(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return fa(t),r=Uo(e,t,n,o,a,i),s=qo(),e!==null&&!wc?(Jo(e,t,i),el(e,t,i)):(Ki&&s&&Vi(t),t.flags|=1,Tc(e,t,r,i),t.child)}function Dc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!bi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Oc(e,t,a,r,i)):(e=Ci(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!tl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?kr:n,n(o,r)&&e.ref===t.ref)return el(e,t,i)}return t.flags|=1,e=xi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Oc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(kr(a,r)&&e.ref===t.ref){if(wc=!1,t.pendingProps=r=a,tl(e,i))e.flags&131072&&(wc=!0);else return t.lanes=e.lanes,el(e,t,i)}}return Ic(e,t,n,r,i)}function kc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return jc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Fa(t,a===null?null:a.cachePool),a===null?_o():go(t,a),Co(t);else return r=t.lanes=536870912,jc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Fa(t,null),_o(),wo()):(Fa(t,a.cachePool),go(t,a),wo(),t.memoizedState=null);return Tc(e,t,i,n),t.child}function Ac(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function jc(e,t,n,r,i){var a=Pa();return a=a===null?null:{parent:ya._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Fa(t,null),_o(),Co(t),e!==null&&ua(e,t,r,!0),t.childLanes=i,null}function Mc(e,t){return t=Gc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Nc(e,t,n){return $a(t,e.child,null,n),e=Mc(t,t.pendingProps),e.flags|=2,To(t),t.memoizedState=null,e}function Pc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(Ki){if(r.mode===`hidden`)return e=Mc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Ac(null,e);if(So(t),(e=Gi)?(e=om(e,Ji),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ii===null?null:{id:Li,overflow:Ri},retryLane:536870912,hydrationErrors:null},n=Ei(e),n.return=t,t.child=n,Wi=t,Gi=null)):e=null,e===null)throw Xi(t);return t.lanes=536870912,null}return Mc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(So(t),a){if(t.flags&256)t.flags&=-257,t=Nc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(wc||ua(e,t,n,!1),a=(n&e.childLanes)!==0,wc||a){if(mo.current===null){if(r=Ju,r!==null&&(s=at(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,mi(e,s),Md(r,e,s),Cc;Wd()}t=Nc(e,t,n)}else e=o.treeContext,Gi=um(s.nextSibling),Wi=t,Ki=!0,qi=null,Ji=!1,e!==null&&Ui(t,e),t=Mc(t,r),t.flags|=134221824;return t}return e=xi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Fc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Ic(e,t,n,r,i){return fa(t),n=Uo(e,t,n,r,void 0,i),r=qo(),e!==null&&!wc?(Jo(e,t,i),el(e,t,i)):(Ki&&r&&Vi(t),t.flags|=1,Tc(e,t,n,i),t.child)}function Lc(e,t,n,r,i,a){return fa(t),t.updateQueue=null,n=Go(t,r,n,i),Wo(e),r=qo(),e!==null&&!wc?(Jo(e,t,a),el(e,t,a)):(Ki&&r&&Vi(t),t.flags|=1,Tc(e,t,n,a),t.child)}function Rc(e,t,n,r,i){if(fa(t),t.stateNode===null){var a=_i,o=n.contextType;typeof o==`object`&&o&&(a=pa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=uc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},no(t),o=n.contextType,a.context=typeof o==`object`&&o?pa(o):_i,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(lc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&uc.enqueueReplaceState(a,a.state,null),uo(t,r,a,i),lo(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=pc(n,s);a.props=c;var l=a.context,u=n.contextType;o=_i,typeof u==`object`&&u&&(o=pa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&fc(t,a,r,o),to=!1;var f=t.memoizedState;a.state=f,uo(t,r,a,i),lo(),l=t.memoizedState,s||f!==l||to?(typeof d==`function`&&(lc(t,n,d,r),l=t.memoizedState),(c=to||dc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ro(e,t),o=t.memoizedProps,u=pc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=_i,typeof l==`object`&&l&&(c=pa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&fc(t,a,r,c),to=!1,f=t.memoizedState,a.state=f,uo(t,r,a,i),lo();var p=t.memoizedState;o!==d||f!==p||to||e!==null&&e.dependencies!==null&&da(e.dependencies)?(typeof s==`function`&&(lc(t,n,s,r),p=t.memoizedState),(u=to||dc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&da(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Fc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=$a(t,e.child,null,i),t.child=$a(t,null,n,i)):Tc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=el(e,t,i),e}function zc(e,t,n,r){return ea(),t.flags|=256,Tc(e,t,n,r),t.child}var Bc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vc(e){return{baseLanes:e,cachePool:Ia()}}function Hc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=sd),e}function Uc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Eo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(Ki){if(i?xo(t):wo(),(e=Gi)?(e=om(e,Ji),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ii===null?null:{id:Li,overflow:Ri},retryLane:536870912,hydrationErrors:null},n=Ei(e),n.return=t,t.child=n,Wi=t,Gi=null)):e=null,e===null)throw Xi(t);return t.lanes=cm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(wo(),i=t.mode,a=Gc({mode:`hidden`,children:a},i),r=wi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Vc(n),r.childLanes=Hc(e,o,n),t.memoizedState=Bc,Ac(null,r)):(xo(t),Wc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return qc(e,t,a,o,r,c,s,n)}return i?(wo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=xi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=wi(i,a,n,null),i.flags|=2):i=xi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Ac(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Vc(n):(a=i.cachePool,a===null?a=Ia():(s=ya._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Hc(e,o,n),t.memoizedState=Bc,Ac(e.child,r)):(xo(t),n=e.child,e=n.sibling,n=xi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Wc(e,t){return t=Gc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Gc(e,t){return e=yi(22,e,null,t),e.lanes=0,e}function Kc(e,t,n){return $a(t,e.child,null,n),e=Wc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function qc(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(xo(t),t.flags&=-257,Kc(e,t,c)):t.memoizedState===null?(wo(),o=a.fallback,s=t.mode,a=Gc({mode:`visible`,children:a.children},s),o=wi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,$a(t,e.child,null,c),a=t.child,a.memoizedState=Vc(c),a.childLanes=Hc(e,r,c),t.memoizedState=Bc,Ac(null,a)):(wo(),t.child=e.child,t.flags|=128,null);if(xo(t),cm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,na({value:a,source:null,stack:null})),Kc(e,t,c)}if(wc||ua(e,t,c,!1),r=(c&e.childLanes)!==0,wc||r){if(mo.current!==null)return Kc(e,t,c);if(r=Ju,r!==null&&(a=at(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,mi(e,a),Md(r,e,a),Cc;return sm(o)||Wd(),Kc(e,t,c)}return sm(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,Gi=um(o.nextSibling),Wi=t,Ki=!0,qi=null,Ji=!1,e!==null&&Ui(t,e),t=Wc(t,a.children),t.flags|=134221824,t)}function Jc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ca(e.return,t,n)}function Yc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&ko(n)===null&&(t=e),e=e.sibling}return t}function Xc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Zc(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function Qc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Eo.current;if(t.flags&128)return Do(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Do(t,o),i===`backwards`&&e!==null?(Zc(e),Tc(e,t,r,n),Zc(e)):Tc(e,t,r,n),r=Ki?Ni:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Jc(e,n,t);else if(e.tag===19)Jc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Yc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,Zc(t)),Xc(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ko(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Xc(t,!0,n,null,a,r);break;case`together`:Xc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Yc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Xc(t,!1,i,n,a,r)}return t.child}function $c(e,t,n){var r=t.pendingProps;return oa(t,t.type,r.value),Tc(e,t,r.children,n),t.child}function el(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),id|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ua(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=xi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=xi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function tl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&da(e)))}function nl(e,t,n){switch(t.tag){case 3:be(t,t.stateNode.containerInfo),oa(t,ya,e.memoizedState.cache),ea();break;case 27:case 5:Se(t);break;case 4:be(t,t.stateNode.containerInfo);break;case 10:oa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,So(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return xo(t),t.flags|=128,null;r=ua(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Uc(e,t,n):(xo(t),e=el(e,t,n),e===null?null:e.sibling)}xo(t);break;case 19:if(t.flags&128)return Qc(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(ua(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Qc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Do(t,Eo.current),r)break;return null;case 22:return t.lanes=0,kc(e,t,n,t.pendingProps);case 24:oa(t,ya,e.memoizedState.cache)}return el(e,t,n)}function rl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)wc=!0;else{if(!tl(e,n)&&!(t.flags&128))return wc=!1,nl(e,t,n);wc=!!(e.flags&131072)}}else wc=!1,Ki&&t.flags&1048576&&Bi(t,Ni,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ua(t.elementType),t.type=e,typeof e==`function`)bi(e)?(r=pc(e,r),t.tag=1,t=Rc(null,t,e,r,n)):(t.tag=0,t=Ic(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===F){t.tag=11,t=Ec(null,t,e,r,n);break a}if(a===R){t.tag=14,t=Dc(null,t,e,r,n);break a}if(a===P){t.tag=10,t.type=e,t=$c(null,t,n);break a}}throw t=ue(e)||e,Error(i(306,t,``))}}return t;case 0:return Ic(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=pc(r,t.pendingProps),Rc(e,t,r,a,n);case 3:a:{if(be(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ro(e,t),uo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,oa(t,ya,r),r!==o.cache&&la(t,[ya],n,!0),lo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=zc(e,t,r,n);break a}if(r!==a){a=ki(Error(i(424)),t),na(a),t=zc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Gi=um(e.firstChild),Wi=t,Ki=!0,qi=null,Ji=!0,n=eo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ea(),r===a){t=el(e,t,n);break a}Tc(e,t,r,n)}t=t.child}return t;case 26:return Fc(e,t),e===null?(n=Pm(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ki||(t.stateNode=pp(t.type,t.pendingProps,ve.current,t)):t.memoizedState=Pm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Se(t),e===null&&Ki&&(r=t.stateNode=gm(t.type,t.pendingProps,ve.current),Wi=t,Ji=!0,a=Gi,Cp(t.type)?(dm=a,Gi=um(r.firstChild)):Gi=a),Tc(e,t,t.pendingProps.children,n),Fc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ki&&((a=r=Gi)&&(r=im(r,t.type,t.pendingProps,Ji),r===null?a=!1:(t.stateNode=r,Wi=t,Gi=um(r.firstChild),Ji=!1,a=!0)),a||Xi(t)),Se(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,mp(a,o)?r=null:s!==null&&mp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Uo(e,t,Ko,null,null,n),ch._currentValue=a),Fc(e,t),Tc(e,t,r,n),t.child;case 6:return e===null&&Ki&&((e=n=Gi)&&(n=am(n,t.pendingProps,Ji),n===null?e=!1:(t.stateNode=n,Wi=t,Gi=null,e=!0)),e||Xi(t)),null;case 13:return Uc(e,t,n);case 4:return be(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$a(t,null,r,n):Tc(e,t,r,n),t.child;case 11:return Ec(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Fc(e,t),Tc(e,t,r,n),t.child;case 8:return Tc(e,t,t.pendingProps.children,n),t.child;case 12:return Tc(e,t,t.pendingProps.children,n),t.child;case 10:return $c(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,fa(t),a=pa(a),r=r(a),t.flags|=1,Tc(e,t,r,n),t.child;case 14:return Dc(e,t,t.type,t.pendingProps,n);case 15:return Oc(e,t,t.type,t.pendingProps,n);case 19:return Qc(e,t,n);case 31:return Pc(e,t,n);case 22:return kc(e,t,n,t.pendingProps);case 24:return fa(t),r=pa(ya),e===null?(a=Pa(),a===null&&(a=Ju,o=ba(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},no(t),oa(t,ya,a)):((e.lanes&n)!==0&&(ro(e,t),uo(t,null,null,n),lo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,oa(t,ya,r),r!==a.cache&&la(t,[ya],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),oa(t,ya,r))),Tc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:Ki&&Vi(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Fc(e,t),Tc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function il(e){e.flags|=4}function al(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Ym(t,r):Ym(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Vd())e.flags|=8192;else throw Wa=Ba,Ra}}else e.flags&=-16777217}function ol(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Xm(t)){if(Vd())e.flags|=8192;else throw Wa=Ba,Ra}}function sl(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Y(),e.lanes|=t,cd|=t)}function cl(e,t){if(!Ki)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function ll(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function ul(e,t,n){var r=t.pendingProps;switch(Hi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ll(t),null;case 1:return ll(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),sa(ya),xe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&($i(t)?il(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ta())),ll(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(il(t),o===null?(ll(t),al(t,a,null,r,n)):(ll(t),ol(t,o))):o?o===e.memoizedState?(ll(t),t.flags&=-16777217):(il(t),ll(t),ol(t,o)):(e=e.memoizedProps,e!==r&&il(t),ll(t),al(t,a,e,r,n)),null;case 27:if(Ce(t),n=ve.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&il(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return ll(t),t.subtreeFlags&=-33554433,null}e=ge.current,$i(t)?Zi(t,e):(e=gm(a,r,n),t.stateNode=e,il(t))}return ll(t),t.subtreeFlags&=-33554433,null;case 5:if(Ce(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&il(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return ll(t),t.subtreeFlags&=-33554433,null}if(o=ge.current,$i(t))Zi(t,o);else{var s=up(ve.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[dt]=t,o[ft]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(rp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&il(t)}}return ll(t),t.subtreeFlags&=-33554433,al(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&il(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ve.current,$i(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Wi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||Xi(t,!0)}else e=up(e).createTextNode(r),e[dt]=t,t.stateNode=e}return ll(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=$i(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[dt]=t}else ea(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),e=!1}else n=ta(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(To(t),t):(To(t),null);if(t.flags&128)throw Error(i(558))}return ll(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=$i(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[dt]=t}else ea(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),a=!1}else a=ta(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(To(t),t):(To(t),null)}return To(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),sl(t,t.updateQueue),ll(t),null);case 4:return xe(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,ll(t),null;case 10:return sa(t.type),ll(t),null;case 19:if(Oo(t),r=t.memoizedState,r===null)return ll(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)cl(r,!1);else{if(rd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ko(e),o!==null){for(t.flags|=128,cl(r,!1),e=o.updateQueue,t.updateQueue=e,sl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Si(n,e),n=n.sibling;return Do(t,Eo.current&1|2),Ki&&zi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ie()>md&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=ko(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,sl(t,e),cl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!Ki)return ll(t),null}else 2*Ie()-r.renderingStartTime>md&&n!==536870912&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ie(),e.sibling=null,o=Eo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||Ki?Do(t,o):(n=o,U(yo,t),U(Eo,n),bo===null&&(bo=t)),Ki&&zi(t,r.treeForkCount),e}return ll(t),null;case 22:case 23:return To(t),vo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(ll(t),t.subtreeFlags&6&&(t.flags|=8192)):ll(t),n=t.updateQueue,n!==null&&sl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&he(Na),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),sa(ya),ll(t),null;case 25:return null;case 30:return t.flags|=33554432,ll(t),null}throw Error(i(156,t.tag))}function dl(e,t){switch(Hi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return sa(ya),xe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ce(t),null;case 31:if(t.memoizedState!==null){if(To(t),t.alternate===null)throw Error(i(340));ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(To(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Oo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return xe(),null;case 10:return sa(t.type),null;case 22:case 23:return To(t),vo(),e!==null&&he(Na),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return sa(ya),null;case 25:return null;default:return null}}function fl(e,t){switch(Hi(t),t.tag){case 3:sa(ya),xe();break;case 26:case 27:case 5:Ce(t);break;case 4:xe();break;case 31:t.memoizedState!==null&&To(t);break;case 13:To(t);break;case 19:Oo(t);break;case 10:sa(t.type);break;case 22:case 23:To(t),vo(),e!==null&&he(Na);break;case 24:sa(ya)}}function pl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){ff(t,t.return,e)}}function ml(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){ff(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ff(t,t.return,e)}}function hl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{po(t,n)}catch(t){ff(e,e.return,t)}}}function gl(e,t,n){n.props=pc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ff(e,t,n)}}function _l(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=ii(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Fp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Ip(e);m(e.child,!1,$p,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){ff(e,t,n)}}function vl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){ff(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){ff(e,t,n)}else n.current=null}}function yl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)tm(e.stateNode,t[n])}function bl(e){for(var t=e.return;t!==null&&(Cl(t)&&tm(e.stateNode,t.stateNode),!Sl(t));)t=t.return}function xl(e){for(var t=e.return;t!==null&&(Cl(t)&&nm(e.stateNode,t.stateNode),!Sl(t));)t=t.return}function Sl(e){return e.tag===5||e.tag===3||e.tag===27}function Cl(e){return e&&e.tag===7&&e.stateNode!==null}function wl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){ff(e,e.return,t)}}function Tl(e,t,n){try{var r=e.stateNode;ap(r,e.type,n,t),r[ft]=t}catch(t){ff(e,e.return,t)}}function El(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Cp(e.type)||e.tag===4}function Dl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||El(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Cp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ol(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=an)),yl(e,r),Mt=!0;else if(i!==4&&(i===27&&(yl(e,r),r=null,Cp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Ol(e,t,n,r),e=e.sibling;e!==null;)Ol(e,t,n,r),e=e.sibling}function kl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),yl(e,r),Mt=!0;else if(i!==4&&(i===27&&(yl(e,r),r=null,Cp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(kl(e,t,n,r),e=e.sibling;e!==null;)kl(e,t,n,r),e=e.sibling}function Al(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);rp(t,r,n),t[dt]=e,t[ft]=n}catch(t){ff(e,e.return,t)}}var jl=!1,Ml=null;function Nl(e){(e.tag===30||e.subtreeFlags&33554432)&&(jl=!0)}var Pl=null;function Fl(){var e=Pl;return Pl=null,e}var Il=0;function Ll(e,t,n,r,i){return Il=0,Rl(e.child,t,n,r,i)}function Rl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=kp(o);r.push(s),s.view&&(a=!0)}else a||kp(o).view&&(a=!0);jl=!0,Ep(o,Il===0?t:t+`_`+Il,n),Il++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Rl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function zl(e,t){for(;e!==null;)e.tag===5?Dp(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||zl(e.child,t),e=e.sibling}function Bl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Bl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=oi(t.default,t.share),t!==`none`&&(Ll(e,n,t,null,!1)||zl(e.child,!1))}e=e.sibling}}function Vl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=ii(r,n),a=oi(r.default,n.paired?r.share:r.enter);a===`none`?Bl(e):Ll(e,i,a,null,!1)?(Bl(e),n.paired||t||jd(e,r.onEnter)):zl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Vl(e,t),e=e.sibling;else Bl(e)}function Hl(e){if(Ml!==null&&Ml.size!==0){var t=Ml;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=oi(n.default,n.share);if(a!==`none`&&(Ll(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,jd(e,n.onShare)):zl(e.child,!1)),t.delete(r),t.size===0)break}}}Hl(e)}e=e.sibling}}}function Ul(e){if(e.tag===30){var t=e.memoizedProps,n=ii(t,e.stateNode),r=Ml===null?void 0:Ml.get(n),i=oi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Ll(e,n,i,null,!1)?r===void 0?jd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Ml.delete(n),jd(e,t.onShare)):zl(e.child,!1)),Ml!==null&&Hl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Ul(e),e=e.sibling;else Ml!==null&&Hl(e)}function Wl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=ii(t,e.stateNode);t=oi(t.default,t.update),e.flags&=-5,t!==`none`&&Ll(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Wl(e);e=e.sibling}}function Gl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,zl(e.child,!1))}Gl(e)}e=e.sibling}}function Kl(e){if(e.tag===30)e.stateNode.paired=null,zl(e.child,!1),Gl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Kl(e),e=e.sibling;else Gl(e)}function ql(e){for(e=e.child;e!==null;)e.tag===30?zl(e.child,!1):e.subtreeFlags&33554432&&ql(e),e=e.sibling}function Jl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Il<a.length){var l=a[Il],u=kp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Ep(c,Il===0?n:n+`_`+Il,i),s&&e.flags&4||(Pl===null&&(Pl=[]),Pl.push(c,Il===0?r:r+`_`+Il,t.memoizedProps)),Il++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Jl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Yl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=ii(n,r),a=oi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Ap)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Il=0,i=Jl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||jd(e,n.onUpdate))}else e.subtreeFlags&33554432&&Yl(e,t);e=e.sibling}}var Xl=!1,Zl=!1,Ql=!1,$l=!1,eu=typeof WeakSet==`function`?WeakSet:Set,tu=null,nu=!1,ru=!1,iu=!1,au=!1;function ou(e,t,n){if(e=e.containerInfo,cp=_h,e=Pr(e),Fr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(lp={focusedElem:e,selectionRange:r},_h=!1,n=(n&335544064)===n,tu=t,t=n?9270:1024;tu!==null;){if(e=tu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Ul(r[a]);if(e.alternate===null&&e.flags&2)n&&Nl(e),su(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Ul(r),su(n);continue}if(r!==null&&r.memoizedState!==null){n&&Nl(e),su(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,tu=r):(n&&Wl(e),su(n))}}Ml=null}function su(e){for(;tu!==null;){var t=tu,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=pc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){ff(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)rm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:rm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=ii(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=oi(a.default,a.update),a!==`none`&&Ll(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,tu=r;break}tu=t.return}}function cu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ou(e,n),r&4&&pl(5,n);break;case 1:if(Ou(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){ff(n,n.return,e)}else{var i=pc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){ff(n,n.return,e)}}}r&64&&hl(n),r&512&&_l(n,n.return);break;case 3:if(Ou(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{po(e,t)}catch(e){ff(n,n.return,e)}}break;case 27:t===null&&r&4&&Al(n);case 26:case 5:Ou(e,n),t===null&&r&4&&wl(n),r&512&&_l(n,n.return);break;case 12:Ou(e,n);break;case 31:Ou(e,n),r&4&&_u(e,n);break;case 13:Ou(e,n),r&4&&vu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=gf.bind(null,n),lm(e,n))));break;case 22:if(r=n.memoizedState!==null||Xl,!r){var a=t!==null&&t.memoizedState!==null||Zl;t=Xl,i=Zl,Xl=r,(Zl=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Au(e,n,r)):Ou(e,n),Xl=t,Zl=i}break;case 30:Ou(e,n),r&512&&_l(n,n.return);break;case 7:r&512&&_l(n,n.return);default:Ou(e,n)}}function lu(e,t){for(e=e.child;e!==null;)uu(e,t),e=e.sibling}function uu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){ff(e,e.return,t)}du(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Mt=!0}catch(t){ff(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Tp(s,!0):Tp(e.stateNode,!1)}catch(t){ff(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&lu(e,t);break;default:lu(e,t)}}function du(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:uu(n,r);break a;case 22:n.memoizedState===null&&du(n,r);break a;default:du(n,r)}}e=e.sibling}}function fu(e){var t=e.alternate;t!==null&&(e.alternate=null,fu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&yt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var pu=null,mu=!1;function hu(e,t,n){for(n=n.child;n!==null;)gu(e,t,n),n=n.sibling}function gu(e,t,n){if(W&&typeof W.onCommitFiberUnmount==`function`)try{W.onCommitFiberUnmount(Ge,n)}catch{}switch(n.tag){case 26:Zl||vl(n,t),hu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Zl&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Zl||vl(n,t),xl(n);var r=pu,i=mu;Cp(n.type)&&(pu=n.stateNode,mu=!1),hu(e,t,n),_m(n.stateNode,n.type,n.memoizedProps),pu=r,mu=i;break;case 5:Zl||vl(n,t),xl(n);case 6:if(n.tag===6&&xl(n),r=pu,i=mu,pu=null,hu(e,t,n),pu=r,mu=i,pu!==null){if(mu)try{(pu.nodeType===9?pu.body:pu.nodeName===`HTML`?pu.ownerDocument.body:pu).removeChild(n.stateNode),Mt=!0}catch(e){ff(n,t,e)}else try{pu.removeChild(n.stateNode),Mt=!0}catch(e){ff(n,t,e)}}break;case 18:pu!==null&&(mu?(e=pu,wp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Uh(e)):wp(pu,n.stateNode));break;case 4:r=pu,i=mu,pu=n.stateNode.containerInfo,mu=!0,hu(e,t,n),pu=r,mu=i;break;case 0:case 11:case 14:case 15:ml(2,n,t),Zl||ml(4,n,t),hu(e,t,n);break;case 1:Zl||(vl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&gl(n,t,r)),hu(e,t,n);break;case 21:hu(e,t,n);break;case 22:Zl=(r=Zl)||n.memoizedState!==null,hu(e,t,n),Zl=r;break;case 30:vl(n,t),hu(e,t,n);break;case 7:Zl||vl(n,t),hu(e,t,n);break;default:hu(e,t,n)}}function _u(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Uh(e)}catch(e){ff(t,t.return,e)}}}function vu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Uh(e)}catch(e){ff(t,t.return,e)}}function yu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new eu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new eu),t;default:throw Error(i(435,e.tag))}}function bu(e,t){var n=yu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=_f.bind(null,e,t);t.then(r,r)}})}function xu(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Cp(l.type)){pu=l.stateNode,mu=!1;break a}break;case 5:pu=l.stateNode,mu=!1;break a;case 3:case 4:pu=l.stateNode.containerInfo,mu=!0;break a}l=l.return}if(pu===null)throw Error(i(160));gu(s,c,o),pu=null,mu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Cu(t,e,n),t=t.sibling}var Su=null;function Cu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}xu(t,e,n),wu(e),a&4&&(ml(3,e,e.return),pl(3,e),ml(5,e,e.return));break;case 1:xu(t,e,n),wu(e),a&512&&(Zl||r===null||vl(r,r.return)),a&64&&Xl&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Su,xu(t,e,n),wu(e),a&512&&(Zl||r===null||vl(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(Xl)e.stateNode=pp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[vt]||r[dt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),rp(r,t,n),r[dt]=e,$(r),t=r;break a;case`link`:if(o=Km(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),rp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=Km(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),rp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[dt]=e,$(r),t=r}e.stateNode=t}}else Xl||qm(o,e.type,e.stateNode)}else e.stateNode=Vm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Tl(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||Zl||t.parentNode.removeChild(t)):a.count--,n===null?Xl||qm(o,e.type,e.stateNode):Vm(o,n,e.memoizedProps))}break;case 27:xu(t,e,n),wu(e),a&512&&(Zl||r===null||vl(r,r.return)),r!==null&&a&4&&Tl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=Ql,Ql=!1,xu(t,e,n),Ql=o,wu(e),a&512&&(Zl||r===null||vl(r,r.return)),e.flags&32){t=e.stateNode;try{Xt(t,``),Mt=!0}catch(t){ff(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Tl(e,t,r===null?t:r.memoizedProps)),a&1024&&($l=!0);break;case 6:if(xu(t,e,n),wu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Mt=!0}catch(t){ff(e,e.return,t)}}break;case 3:if(Mt=!1,Gm=null,o=Su,Su=xm(t.containerInfo),xu(t,e,n),Su=o,wu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Uh(t.containerInfo)}catch(t){ff(e,e.return,t)}$l&&($l=!1,Tu(e)),Mt=!1;break;case 4:a=Ql,Ql=Xl,r=Nt(),o=Su,Su=xm(e.stateNode.containerInfo),xu(t,e,n),wu(e),Su=o,Mt&&ru&&(iu=!0),Mt=r,Ql=a;break;case 12:xu(t,e,n),wu(e);break;case 31:xu(t,e,n),wu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,bu(e,t)));break;case 13:xu(t,e,n),wu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(fd=Ie()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,bu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Xl,l=Zl,u=Ql;Xl=c||o,Ql=u||o,Zl=l||s,xu(t,e,n),Zl=l,Ql=u,Xl=c,wu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||Xl||Zl||(t=s||Zl,n=Xl,r=Zl,Xl=o||Xl,Zl=t,ku(e,2),Xl=n,Zl=r),!o&&Ql||lu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,bu(e,n))));break;case 19:xu(t,e,n),wu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,bu(e,t)));break;case 30:a&512&&(Zl||r===null||vl(r,r.return)),a=Nt(),o=ru,s=(n&335544064)===n,c=e.memoizedProps,ru=s&&oi(c.default,c.update)!==`none`,xu(t,e,n),wu(e),s&&r!==null&&Mt&&(e.flags|=4),ru=o,Mt=a;break;case 21:break;case 7:a&512&&(Zl||r===null||vl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:xu(t,e,n),wu(e)}}function wu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(El(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Cl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Sl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;kl(e,Dl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(Xt(l,``),n.flags&=-33),kl(e,Dl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Ol(e,Dl(e),u,s);break;default:throw Error(i(161))}}catch(t){ff(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Tu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Tu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,_h=!0,t.reset(),_h=!1),e=e.sibling}}function Eu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Du(t,e),t=t.sibling;else Yl(t,!1)}function Du(e,t){var n=e.alternate;if(n===null)Vl(e,!1);else switch(e.tag){case 3:if(au=nu=!1,Fl(),Eu(t,e),!nu&&!iu){if(e=Pl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Dp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),au=!0}Pl=null;break;case 5:Eu(t,e);break;case 4:r=nu,nu=!1,Eu(t,e),nu&&(iu=!0),nu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Eu(t,e):Vl(e,!1));break;case 30:r=nu,i=Fl(),nu=!1,Eu(t,e),nu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=ii(a,o),o=ii(n.memoizedProps,o);var s=oi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Il=0,t=Jl(e,n,t,o,s,a,!0),Il!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(jd(e,e.memoizedProps.onUpdate),Pl=i):i!==null&&(i.push.apply(i,Pl),Pl=i),nu=e.flags&32?!0:r;break;default:Eu(t,e)}}function Ou(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)cu(e,t.alternate,t),t=t.sibling}function ku(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:ml(4,n,n.return),ku(n,r);break;case 1:vl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&gl(n,n.return,i),ku(n,r);break;case 27:r&2&&_m(n.stateNode,n.type,n.memoizedProps);case 5:vl(n,n.return),n.tag!==5&&n.tag!==27||xl(n),ku(n,r);break;case 6:xl(n);break;case 26:vl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Zl||i.parentNode.removeChild(i),ku(n,r);break;case 22:n.memoizedState===null&&ku(n,r);break;case 30:vl(n,n.return),ku(n,r);break;case 7:vl(n,n.return);default:ku(n,r)}e=e.sibling}}function Au(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Au(i,a,n),pl(4,a);break;case 1:if(Au(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){ff(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)fo(l[i],c)}catch(e){ff(r,r.return,e)}}s&&o&64&&hl(a),_l(a,a.return);break;case 27:n&2&&Al(a);case 5:a.tag!==5&&a.tag!==27||bl(a),Au(i,a,n),s&&r===null&&o&4&&wl(a),_l(a,a.return);break;case 6:bl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Xl||qm(xm(c.ownerDocument),a.type,c),Au(i,a,n),s&&r===null&&o&4&&wl(a),_l(a,a.return);break;case 12:Au(i,a,n);break;case 31:Au(i,a,n),s&&o&4&&_u(i,a);break;case 13:Au(i,a,n),s&&o&4&&vu(i,a);break;case 22:a.memoizedState===null&&Au(i,a,n),_l(a,a.return);break;case 30:Au(i,a,n),_l(a,a.return);break;case 7:_l(a,a.return);default:Au(i,a,n)}t=t.sibling}}function ju(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&xa(n))}function Mu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&xa(e))}function Nu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Pu(e,t,n,r),t=t.sibling;else i&&ql(t)}function Pu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Kl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Nu(e,t,n,r),a&2048&&pl(9,t);break;case 1:Nu(e,t,n,r);break;case 3:Nu(e,t,n,r),i&&au&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&xa(a)));break;case 12:if(a&2048){Nu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){ff(t,t.return,e)}}else Nu(e,t,n,r);break;case 31:Nu(e,t,n,r);break;case 13:Nu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Kl(t),o._visibility&2?Nu(e,t,n,r):(o._visibility|=2,Fu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Kl(s),o._visibility&2?Nu(e,t,n,r):Iu(e,t)),a&2048&&ju(s,t);break;case 24:Nu(e,t,n,r),a&2048&&Mu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(zl(a.child,!0),zl(t.child,!0))),Nu(e,t,n,r);break;default:Nu(e,t,n,r)}}function Fu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Fu(a,o,s,c,i),pl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Fu(a,o,s,c,i)):u._visibility&2?Fu(a,o,s,c,i):Iu(a,o),i&&l&2048&&ju(o.alternate,o);break;case 24:Fu(a,o,s,c,i),i&&l&2048&&Mu(o.alternate,o);break;default:Fu(a,o,s,c,i)}t=t.sibling}}function Iu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Iu(n,r),i&2048&&ju(r.alternate,r);break;case 24:Iu(n,r),i&2048&&Mu(r.alternate,r);break;default:Iu(n,r)}t=t.sibling}}var Lu=8192;function Ru(e,t,n){if(e.subtreeFlags&Lu)for(e=e.child;e!==null;)zu(e,t,n),e=e.sibling}function zu(e,t,n){switch(e.tag){case 26:Ru(e,t,n),e.flags&Lu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Qm(n,e)):$m(n,Su,e.memoizedState,e.memoizedProps));break;case 5:Ru(e,t,n),e.flags&Lu&&(e=e.stateNode,(t&335544128)===t&&Qm(n,e));break;case 3:case 4:var r=Su;Su=xm(e.stateNode.containerInfo),Ru(e,t,n),Su=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Lu,Lu=16777216,Ru(e,t,n),Lu=r):Ru(e,t,n));break;case 30:if((e.flags&Lu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Ml===null&&(Ml=new Map),Ml.set(r,i)}Ru(e,t,n);break;default:Ru(e,t,n)}}function Bu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Vu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];tu=r,Wu(r,e)}Bu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Hu(e),e=e.sibling}function Hu(e){switch(e.tag){case 0:case 11:case 15:Vu(e),e.flags&2048&&ml(9,e,e.return);break;case 3:Vu(e);break;case 12:Vu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Uu(e)):Vu(e);break;default:Vu(e)}}function Uu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];tu=r,Wu(r,e)}Bu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ml(8,t,t.return),Uu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Uu(t));break;default:Uu(t)}e=e.sibling}}function Wu(e,t){for(;tu!==null;){var n=tu;switch(n.tag){case 0:case 11:case 15:ml(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:xa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,tu=r;else a:for(n=e;tu!==null;){r=tu;var i=r.sibling,a=r.return;if(fu(r),r===n){tu=null;break a}if(i!==null){i.return=a,tu=i;break a}tu=a}}}var Gu={getCacheForType:function(e){var t=pa(ya),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return pa(ya).controller.signal}},Ku=typeof WeakMap==`function`?WeakMap:Map,qu=0,Ju=null,Yu=null,Xu=0,Zu=0,Qu=null,$u=!1,ed=!1,td=!1,nd=0,rd=0,id=0,ad=0,od=0,sd=0,cd=0,ld=null,ud=null,dd=!1,fd=0,pd=0,md=1/0,hd=null,gd=null,_d=0,vd=null,yd=null,bd=0,xd=0,Sd=null,Cd=null,wd=null,Td=null,Ed=null,Dd=0,Od=null;function kd(){return qu&2&&Xu!==0?Xu&-Xu:B.T===null?ct():Nf()}function Ad(){if(sd===0){if(!(Xu&536870912)||Ki){var e=G;G<<=1,!(G&3932160)&&(G=262144),sd=e}else sd=536870912}return e=yo.current,e!==null&&(e.flags|=32),sd}function jd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Fp(ii(e.memoizedProps,n))),Td===null&&(Td=[]),Td.push(t.bind(null,r))}}function Md(e,t,n){(e===Ju&&(Zu===2||Zu===9)||e.cancelPendingCommit!==null)&&(zd(e,0),Id(e,Xu,sd,!1)),nt(e,n),qu&2&&e===Ju||(e===Ju&&(!(qu&2)&&(ad|=n),rd===4&&Id(e,Xu,sd,!1)),Tf(e))}function Nd(e,t,n){if(qu&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||q(e,t),a=r?qd(e,t):Gd(e,t,!0),o=r;do{if(a===0){ed&&!r&&Id(e,t,0,!1);break}if(n=e.current.alternate,o&&!Fd(n))a=Gd(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ld;var l=c.current.memoizedState.isDehydrated;if(l&&(zd(c,s).flags|=256),s=Gd(c,s,!1),s!==2&&s!==6){if(td&&!l){c.errorRecoveryDisabledLanes|=o,ad|=o,a=4;break a}o=ud,ud=a,o!==null&&(ud===null?ud=o:ud.push.apply(ud,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){zd(e,0),Id(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Id(r,t,sd,!$u);break a;case 2:ud=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=fd+300-Ie(),10<a)){if(Id(r,t,sd,!$u),$e(r,0,!0)!==0)break a;bd=t,r.timeoutHandle=_p(Pd.bind(null,r,n,ud,hd,dd,t,sd,ad,cd,$u,o,`Throttled`,-0,0),a);break a}Pd(r,n,ud,hd,dd,t,sd,ad,cd,$u,o,null,-0,0)}break}}while(1);Tf(e)}function Pd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:an},Ml=null,zu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=rh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?fd-Ie():(a&4194048)===a?pd-Ie():0,m=th(d,m),m!==null)?(bd=a,e.cancelPendingCommit=m(ef.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Id(e,a,o,!l)):ef(e,t,a,n,r,i,o,s,c,l,u,d)}function Fd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Or(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Id(e,t,n,r){t=et(e,t),t&=~od,t&=~ad,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-qe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&X(e,n,t)}function Ld(){return qu&6?!0:(Ef(0,!1),!1)}function Rd(){if(Yu!==null){if(Zu===0)var e=Yu.return;else e=Yu,aa=ia=null,Yo(e),qa=null,Ja=0,e=Yu;for(;e!==null;)fl(e.alternate,e),e=e.return;Yu=null}}function zd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,vp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),bd=0,Rd(),Ju=e,Yu=n=xi(e.current,null),Xu=t,Zu=0,Qu=null,$u=!1,ed=q(e,t),td=!1,cd=sd=od=ad=id=rd=0,ud=ld=null,dd=!1,nd=et(e,t),di(),n}function Bd(e,t){jo=null,B.H=ac,t===La||t===za?(t=Ga(),Zu=3):t===Ra?(t=Ga(),Zu=4):Zu=t===Cc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Qu=t,Yu===null&&(rd=1,_c(e,ki(t,e.current)))}function Vd(){var e=yo.current;return e===null?!0:(Xu&4194048)===Xu?bo===null:(Xu&62914560)===Xu||Xu&536870912?e===bo:!1}function Hd(){var e=B.H;return B.H=ac,e===null?ac:e}function Ud(){var e=B.A;return B.A=Gu,e}function Wd(){rd=4,$u||(Xu&4194048)!==Xu&&yo.current!==null||(ed=!0),!(id&134217727)&&!(ad&134217727)||Ju===null||Id(Ju,Xu,sd,!1)}function Gd(e,t,n){var r=qu;qu|=2;var i=Hd(),a=Ud();(Ju!==e||Xu!==t)&&(hd=null,zd(e,t)),t=!1;var o=rd;a:do try{if(Zu!==0&&Yu!==null){var s=Yu,c=Qu;switch(Zu){case 8:Rd(),o=6;break a;case 3:case 2:case 9:case 6:yo.current===null&&(t=!0);var l=Zu;if(Zu=0,Qu=null,Zd(e,s,c,l),n&&ed){o=0;break a}break;default:l=Zu,Zu=0,Qu=null,Zd(e,s,c,l)}}Kd(),o=rd;break}catch(t){Bd(e,t)}while(1);return t&&e.shellSuspendCounter++,aa=ia=null,qu=r,B.H=i,B.A=a,Yu===null&&(Ju=null,Xu=0,di()),o}function Kd(){for(;Yu!==null;)Yd(Yu)}function qd(e,t){var n=qu;qu|=2;var r=Hd(),a=Ud();Ju!==e||Xu!==t?(hd=null,md=Ie()+500,zd(e,t)):ed=q(e,t);a:do try{if(Zu!==0&&Yu!==null){t=Yu;var o=Qu;b:switch(Zu){case 1:Zu=0,Qu=null,Zd(e,t,o,1);break;case 2:case 9:if(Va(o)){Zu=0,Qu=null,Xd(t);break}t=function(){Zu!==2&&Zu!==9||Ju!==e||(Zu=7),Tf(e)},o.then(t,t);break a;case 3:Zu=7;break a;case 4:Zu=5;break a;case 7:Va(o)?(Zu=0,Qu=null,Xd(t)):(Zu=0,Qu=null,Zd(e,t,o,7));break;case 5:var s=null;switch(Yu.tag){case 26:s=Yu.memoizedState;case 5:case 27:var c=Yu;if(s?Xm(s):c.stateNode.complete){Zu=0,Qu=null;var l=c.sibling;if(l!==null)Yu=l;else{var u=c.return;u===null?Yu=null:(Yu=u,Qd(u))}break b}}Zu=0,Qu=null,Zd(e,t,o,5);break;case 6:Zu=0,Qu=null,Zd(e,t,o,6);break;case 8:Rd(),rd=6;break a;default:throw Error(i(462))}}Jd();break}catch(t){Bd(e,t)}while(1);return aa=ia=null,B.H=r,B.A=a,qu=n,Yu===null?(Ju=null,Xu=0,di(),rd):0}function Jd(){for(;Yu!==null&&!Pe();)Yd(Yu)}function Yd(e){var t=rl(e.alternate,e,nd);e.memoizedProps=e.pendingProps,t===null?Qd(e):Yu=t}function Xd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Lc(n,t,t.pendingProps,t.type,void 0,Xu);break;case 11:t=Lc(n,t,t.pendingProps,t.type.render,t.ref,Xu);break;case 5:Yo(t);var r=t;r===Wi&&(Ki?(Qi(r),r.tag===5&&r.stateNode!=null&&(Gi=r.stateNode)):(Qi(r),Ki=!0));default:fl(n,t),t=Yu=Si(t,nd),t=rl(n,t,nd)}e.memoizedProps=e.pendingProps,t===null?Qd(e):Yu=t}function Zd(e,t,n,r){aa=ia=null,Yo(t),qa=null,Ja=0;var i=t.return;try{if(Sc(e,i,t,n,Xu)){rd=1,_c(e,ki(n,e.current)),Yu=null;return}}catch(t){if(i!==null)throw Yu=i,t;rd=1,_c(e,ki(n,e.current)),Yu=null;return}t.flags&32768?(Ki||r===1?e=!0:ed||Xu&536870912?e=!1:($u=e=!0,(r===2||r===9||r===3||r===6)&&(r=yo.current,r!==null&&r.tag===13&&(r.flags|=16384))),$d(t,e)):Qd(t)}function Qd(e){var t=e;do{if(t.flags&32768){$d(t,$u);return}e=t.return;var n=ul(t.alternate,t,nd);if(n!==null){Yu=n;return}if(t=t.sibling,t!==null){Yu=t;return}Yu=t=e}while(t!==null);rd===0&&(rd=5)}function $d(e,t){do{var n=dl(e.alternate,e);if(n!==null){n.flags&=32767,Yu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Yu=e;return}Yu=e=n}while(e!==null);rd=6,Yu=null}function ef(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do lf();while(_d!==0);if(qu&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===Ju&&(Yu=Ju=null,Xu=0),yd=t,vd=e,bd=n,Sd=a,Cd=r,tf(e,t,n,s,c,l,f)}}function tf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(xd=s,s|=ui,rt(e,n,s,r,i,a),Td=null,(n&335544064)===n?(Ed=wa(e),r=10262):(Ed=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,vf(Be,function(){return uf(),null})):(e.callbackNode=null,e.callbackPriority=0),jl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=B.T,B.T=null,i=V.p,V.p=2,a=qu,qu|=4;try{ou(e,t,n)}finally{qu=a,V.p=i,B.T=r}}_d=1,jl?wd=Np(o,e.containerInfo,Ed,af,of,rf,sf,uf,nf,null,null):(af(),of(),sf())}function nf(e){if(_d!==0){var t=vd.onRecoverableError;t(e,{componentStack:null})}}function rf(){_d===3&&(_d=0,Du(yd,vd),_d=4)}function af(){if(_d===1){_d=0;var e=vd,t=yd,n=bd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=B.T,B.T=null;var i=V.p;V.p=2;var a=qu;qu|=4;try{ru=iu=!1,Cu(t,e,n),n=lp;var o=Pr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Nr(s.ownerDocument.documentElement,s)){if(c!==null&&Fr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Mr(s,h),v=Mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}_h=!!cp,lp=cp=null}finally{qu=a,V.p=i,B.T=r}}e.current=t,_d=2}}function of(){if(_d===2){_d=0;var e=vd,t=yd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=B.T,B.T=null;var r=V.p;V.p=2;var i=qu;qu|=4;try{cu(e,t.alternate,t)}finally{qu=i,V.p=r,B.T=n}}_d=3}}function sf(){if(_d===4||_d===3){_d=0;var e=wd;wd=null,Fe();var t=vd,n=yd,r=bd,i=Cd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?_d=5:(_d=0,yd=vd=null,cf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(gd=null),st(r),n=n.stateNode,W&&typeof W.onCommitFiberRoot==`function`)try{W.onCommitFiberRoot(Ge,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=B.T,a=V.p,V.p=2,B.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{B.T=n,V.p=a}}if(i=Td,o=Ed,Ed=null,i!==null&&(Td=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);bd&3&&lf(),Tf(t),a=t.pendingLanes,r&261930&&a&42?t===Od?Dd++:(Dd=0,Od=t):(Dd=0,Od=null),Ef(0,!1)}}function cf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,xa(t)))}function lf(){return wd!==null&&(wd.skipTransition(),wd=null),af(),of(),sf(),uf()}function uf(){if(_d!==5)return!1;var e=vd,t=xd;xd=0;var n=st(bd),r=B.T,a=V.p;try{V.p=32>n?32:n,B.T=null,n=Sd,Sd=null;var o=vd,s=bd;if(_d=0,yd=vd=null,bd=0,qu&6)throw Error(i(331));var c=qu;if(qu|=4,Hu(o.current),Pu(o,o.current,s,n),qu=c,Ef(0,!1),W&&typeof W.onPostCommitFiberRoot==`function`)try{W.onPostCommitFiberRoot(Ge,o)}catch{}return!0}finally{V.p=a,B.T=r,cf(e,t)}}function df(e,t,n){t=ki(n,t),t=yc(e.stateNode,t,2),e=ao(e,t,2),e!==null&&(nt(e,2),Tf(e))}function ff(e,t,n){if(e.tag===3)df(e,e,n);else for(;t!==null;){if(t.tag===3){df(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(gd===null||!gd.has(r))){e=ki(n,e),n=bc(2),r=ao(t,n,2),r!==null&&(xc(n,r,t,e),nt(r,2),Tf(r));break}}t=t.return}}function pf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ku;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(td=!0,i.add(n),e=mf.bind(null,e,t,n),t.then(e,e))}function mf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ju===e&&(Xu&n)===n&&(rd===4||rd===3&&(Xu&62914560)===Xu&&300>Ie()-fd?qu&2?od|=n:zd(e,0):od|=n,cd===Xu&&(cd=0)),Tf(e)}function hf(e,t){t===0&&(t=Y()),e=mi(e,t),e!==null&&(nt(e,t),Tf(e))}function gf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),hf(e,n)}function _f(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),hf(e,n)}function vf(e,t){return Me(e,t)}var yf=null,bf=null,xf=!1,Sf=!1,Cf=!1,wf=0;function Tf(e){e!==bf&&e.next===null&&(bf===null?yf=bf=e:bf=bf.next=e),Sf=!0,xf||(xf=!0,Mf())}function Ef(e,t){if(!Cf&&Sf){Cf=!0;do for(var n=!1,r=yf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-qe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,jf(r,a))}else a=Xu,a=$e(r,r===Ju?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||q(r,a)||(n=!0,jf(r,a))}r=r.next}while(n);Cf=!1}}function Df(){Of()}function Of(){Sf=xf=!1;var e=0;wf!==0&&gp()&&(e=wf);for(var t=Ie(),n=null,r=yf;r!==null;){var i=r.next,a=kf(r,t);a===0?(r.next=null,n===null?yf=i:n.next=i,i===null&&(bf=n)):(n=r,(e!==0||a&3)&&(Sf=!0)),r=i}_d!==0&&_d!==5||Ef(e,!1),wf!==0&&(wf=0)}function kf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-qe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=J(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ju,n=Xu,n=$e(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Zu===2||Zu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Ne(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||q(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ne(r),st(n)){case 2:case 8:n=ze;break;case 32:n=Be;break;case 268435456:n=He;break;default:n=Be}return r=Af.bind(null,e),n=Me(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ne(r),e.callbackPriority=2,e.callbackNode=null,2}function Af(e,t){if(_d!==0&&_d!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(lf()&&e.callbackNode!==n)return null;var r=Xu;return r=$e(e,e===Ju?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Nd(e,r,t),kf(e,Ie()),e.callbackNode!=null&&e.callbackNode===n?Af.bind(null,e):null)}function jf(e,t){if(lf())return null;Nd(e,t,!0)}function Mf(){xp(function(){qu&6?Me(Re,Df):Of()})}function Nf(){if(wf===0){var e=Da;e===0&&(e=Ze,Ze<<=1,!(Ze&261888)&&(Ze=256)),wf=e}return wf}function Pf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:rn(e)}function Ff(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Pf((i[ft]||null).action),o=r.submitter;o&&(t=(t=o[ft]||null)?Pf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new En(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(wf!==0){var e=new FormData(i,o);Gs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Gs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var If=0;If<ti.length;If++){var Lf=ti[If];ni(Lf.toLowerCase(),`on`+(Lf[0].toUpperCase()+Lf.slice(1)))}ni(qr,`onAnimationEnd`),ni(Jr,`onAnimationIteration`),ni(Yr,`onAnimationStart`),ni(`dblclick`,`onDoubleClick`),ni(`focusin`,`onFocus`),ni(`focusout`,`onBlur`),ni(Xr,`onTransitionRun`),ni(Zr,`onTransitionStart`),ni(Qr,`onTransitionCancel`),ni($r,`onTransitionEnd`),Dt(`onMouseEnter`,[`mouseout`,`mouseover`]),Dt(`onMouseLeave`,[`mouseout`,`mouseover`]),Dt(`onPointerEnter`,[`pointerout`,`pointerover`]),Dt(`onPointerLeave`,[`pointerout`,`pointerover`]),Et(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Et(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Et(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Et(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Et(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Et(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Rf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),zf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Rf));function Bf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){si(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){si(e)}i.currentTarget=null,a=c}}}}function Vf(e,t){var n=t[mt];n===void 0&&(n=t[mt]=new Set);var r=e+`__bubble`;n.has(r)||(Gf(t,e,2,!1),n.add(r))}function Hf(e,t,n){var r=0;t&&(r|=4),Gf(n,e,r,t)}var Uf=`_reactListening`+Math.random().toString(36).slice(2);function Wf(e){if(!e[Uf]){e[Uf]=!0,wt.forEach(function(t){t!==`selectionchange`&&(zf.has(t)||Hf(t,!1,e),Hf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Uf]||(t[Uf]=!0,Hf(`selectionchange`,!1,t))}}function Gf(e,t,n,r){switch(wh(t)){case 2:var i=vh;break;case 8:i=yh;break;default:i=bh}n=i.bind(null,t,n,e),i=void 0,!hn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Kf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=bt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}fn(function(){var r=a,i=sn(n),s=[];a:{var c=ei.get(e);if(c!==void 0){var l=En,u=e;switch(e){case`keypress`:if(xn(n)===0)break a;case`keydown`:case`keyup`:l=Wn;break;case`focusin`:u=`focus`,l=Fn;break;case`focusout`:u=`blur`,l=Fn;break;case`beforeblur`:case`afterblur`:l=Fn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Nn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Pn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=qn;break;case qr:case Jr:case Yr:l=In;break;case $r:l=Jn;break;case`scroll`:case`scrollend`:l=On;break;case`wheel`:l=Yn;break;case`copy`:case`cut`:case`paste`:l=Ln;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Gn;break;case`submit`:l=Kn;break;case`toggle`:case`beforetoggle`:l=Xn}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=pn(m,p),g!=null&&d.push(qf(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==on&&(u=n.relatedTarget||n.fromElement)&&(bt(u)||u[pt]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?bt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Nn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Gn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:xt(c),h=l==null?u:xt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,bt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?E(c,l,Yf):null,c!==null&&Xf(s,u,c,d,!1),l!==null&&f!==null&&Xf(s,f,l,d,!0)))}a:{if(c=r?xt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=gr;else if(ur(c)){if(_r)_=Er;else{_=wr;var v=Cr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&en(r.elementType)&&(_=gr):_=Tr;if(_&&=_(e,r)){dr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?xt(r):window,e){case`focusin`:(ur(v)||v.contentEditable===`true`)&&(Lr=v,Rr=r,zr=null);break;case`focusout`:zr=Rr=Lr=null;break;case`mousedown`:Br=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Br=!1,Vr(s,n,i);break;case`selectionchange`:if(Ir)break;case`keydown`:case`keyup`:Vr(s,n,i)}var y;if(Qn)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else or?ir(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(tr&&n.locale!==`ko`&&(or||b!==`onCompositionStart`?b===`onCompositionEnd`&&or&&(y=bn()):(_n=i,vn=`value`in _n?_n.value:_n.textContent,or=!0)),v=Jf(r,b),0<v.length&&(b=new Rn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=ar(n),y!==null&&(b.data=y)))),(y=er?sr(e,n):cr(e,n))&&(b=Jf(r,`onBeforeInput`),0<b.length&&(v=new Rn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Ff(s,e,r,n,i)}Bf(s,t)})}function qf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Jf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=pn(e,n),i!=null&&r.unshift(qf(e,i,a)),i=pn(e,t),i!=null&&r.push(qf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Yf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Xf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=pn(n,a),l!=null&&o.unshift(qf(n,l,c))):i||(l=pn(n,a),l!=null&&o.push(qf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Zf=/\r\n?/g,Qf=/\u0000|\uFFFD/g;function $f(e){return(typeof e==`string`?e:``+e).replace(Zf,`
10
- `).replace(Qf,``)}function ep(e,t){return t=$f(t),$f(e)===t}function tp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||Xt(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&Xt(e,``+r);else return;break;case`className`:Ft(e,`class`,r);break;case`tabIndex`:Ft(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ft(e,n,r);break;case`style`:$t(e,r,o);return;case`data`:if(t!==`object`){Ft(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&tp(e,t,`name`,a.name,a,null),tp(e,t,`formEncType`,a.formEncType,a,null),tp(e,t,`formMethod`,a.formMethod,a,null),tp(e,t,`formTarget`,a.formTarget,a,null)):(tp(e,t,`encType`,a.encType,a,null),tp(e,t,`method`,a.method,a,null),tp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=an);return;case`onScroll`:r!=null&&Vf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Vf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=rn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Vf(`beforetoggle`,e),Vf(`toggle`,e),Pt(e,`popover`,r);break;case`xlinkActuate`:It(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:It(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:It(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:It(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Pt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=tn.get(n)||n,Pt(e,n,r);else return}Mt=!0}function np(e,t,n,r,a,o){switch(n){case`style`:$t(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)Xt(e,r);else if(typeof r==`number`||typeof r==`bigint`)Xt(e,``+r);else return;break;case`onScroll`:r!=null&&Vf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Vf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=an);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Tt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[ft]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Mt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Pt(e,n,r)}return}Mt=!0}function rp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Vf(`error`,e),Vf(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:tp(e,t,o,s,n,null)}}a&&tp(e,t,`srcSet`,n.srcSet,n,null),r&&tp(e,t,`src`,n.src,n,null);return;case`input`:Vf(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:tp(e,t,r,d,n,null)}}Gt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Vf(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:tp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&qt(e,!!r,n,!0):qt(e,!!r,t,!1);return;case`textarea`:for(s in Vf(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:tp(e,t,s,c,n,null)}Yt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:tp(e,t,l,r,n,null)}return;case`dialog`:Vf(`beforetoggle`,e),Vf(`toggle`,e),Vf(`cancel`,e),Vf(`close`,e);break;case`iframe`:case`object`:Vf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)Vf(Rf[r],e);break;case`image`:Vf(`error`,e),Vf(`load`,e);break;case`details`:Vf(`toggle`,e);break;case`embed`:case`source`:case`link`:Vf(`error`,e),Vf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:tp(e,t,u,r,n,null)}return;default:if(en(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&np(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&tp(e,t,c,r,n,null))}var ip={};function ap(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||tp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Mt=!0),o=m;break;case`name`:m!==f&&(Mt=!0),a=m;break;case`checked`:m!==f&&(Mt=!0),u=m;break;case`defaultChecked`:m!==f&&(Mt=!0),d=m;break;case`value`:m!==f&&(Mt=!0),s=m;break;case`defaultValue`:m!==f&&(Mt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&tp(e,t,p,m,r,f)}}Wt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||tp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Mt=!0),p=o;break;case`defaultValue`:o!==l&&(Mt=!0),c=o;break;case`multiple`:o!==l&&(Mt=!0),s=o;default:o!==l&&tp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?qt(e,!!n,n?[]:``,!1):qt(e,!!n,t,!0)):qt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:tp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Mt=!0),p=a;break;case`defaultValue`:a!==o&&(Mt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&tp(e,t,s,a,r,o)}Jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:tp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Mt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:tp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&tp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:tp(e,t,u,p,r,m)}return;default:if(en(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&np(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||np(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&tp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||tp(e,t,f,p,r,m)}function op(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function sp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&op(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&op(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var cp=null,lp=null;function up(e){return e.nodeType===9?e:e.ownerDocument}function dp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function fp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function pp(e,t,n,r){return n=up(n).createElement(e),n[dt]=r,n[ft]=t,rp(n,e,t),$(n),n}function mp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hp=null;function gp(){var e=window.event;return e&&e.type===`popstate`?e!==hp&&(hp=e,!0):(hp=null,!1)}var _p=typeof setTimeout==`function`?setTimeout:void 0,vp=typeof clearTimeout==`function`?clearTimeout:void 0,yp=typeof Promise==`function`?Promise:void 0,bp=typeof requestAnimationFrame==`function`?requestAnimationFrame:_p,xp=typeof queueMicrotask==`function`?queueMicrotask:yp===void 0?_p:function(e){return yp.resolve(null).then(e).catch(Sp)};function Sp(e){setTimeout(function(){throw e})}function Cp(e){return e===`head`}function wp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Uh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)vm(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,vm(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&vm(e.ownerDocument.body)}n=i}while(n);Uh(t)}function Tp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Ep(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Dp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Op(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function kp(e){return Op(e.getBoundingClientRect(),getComputedStyle(e),e)}function Ap(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Op(t,n,e)}function jp(e){return e.documentElement.clientHeight}function Mp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Np(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(jp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Zm(f),u>eh){s.length=o;break}f=new Promise(Mp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Pp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Pp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Pp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Pp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Fp(e){return{name:e,group:new Pp(`group`,e),imagePair:new Pp(`image-pair`,e),old:new Pp(`old`,e),new:new Pp(`new`,e)}}function Ip(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Ip.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Vp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=zp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),m(this._fragmentFiber.child,!1,Lp,e,s,r)}this._eventListeners=a}};function Lp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Ip.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Vp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=zp(i.optionsOrUseCapture),m(this._fragmentFiber.child,!1,Rp,e,n,i),r.splice(t,1),a!==null&&a()}};function Rp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function zp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Bp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Vp(e,t,n,r){if(e.length===0)return-1;r=Bp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Bp(a.optionsOrUseCapture)===r)return i}return-1}Ip.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,zp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,zp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Ip.prototype.focus=function(e){m(this._fragmentFiber.child,!0,Hp,e,void 0,void 0)};function Hp(e,t){return e.tag!==6&&(e=b(e),mm(e,t))}Ip.prototype.focusLast=function(e){var t=[];m(this._fragmentFiber.child,!0,Up,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Hp(t[n],e);n--);};function Up(e,t){return t.push(e),!1}Ip.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=up(e).activeElement,e!==null&&m(this._fragmentFiber.child,!1,Wp,e,void 0,void 0))};function Wp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Ip.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),m(this._fragmentFiber.child,!1,Gp,e,void 0,void 0)};function Gp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Ip.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),m(this._fragmentFiber.child,!1,Kp,e,void 0,void 0);for(var n=t=0;n<qp.length;n++){var r=qp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):qp[t++]=r}qp.length=t}};function Kp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var qp=[],Jp=!1;function Yp(e,t,n){qp.push({fragmentInstance:e,observer:t,instance:n}),Jp||(Jp=!0,hm(function(){Jp=!1;var e=qp;qp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Ip.prototype.getClientRects=function(){var e=[];return m(this._fragmentFiber.child,!1,Xp,e,void 0,void 0),e};function Xp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Ip.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Ip.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];m(this._fragmentFiber.child,!1,Up,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Zp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Zp(e,t,n,r,i){var a=bt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(m(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(m(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function Qp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Ip.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];m(this._fragmentFiber.child,!1,Up,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),Qp(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=b(a),Qp(a,n)):b(a).scrollIntoView(e),r+=n?-1:1}};function $p(e,t){return e=b(e),em(e,t),!1}function em(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,zp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<qp.length;i++){var a=qp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(qp[r++]=a)}qp.length=r,n.observe(e)}),em(e,t))}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,zp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Yp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function rm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:rm(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function im(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=um(e.nextSibling),e===null)break}return null}function am(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=um(e.nextSibling),e===null))return null;return e}function om(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=um(e.nextSibling),e===null))return null;return e}function sm(e){return e.data===`$?`||e.data===`$~`}function cm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function um(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var dm=null;function fm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return um(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function hm(e){bp(function(){bp(function(t){return e(t)})})}function gm(e,t,n){switch(t=up(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _m(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&tp(e,t,r,null,ip,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===an&&(e.onclick=null),yt(e)}function vm(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var ym=new Map,bm=new Set;function xm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Sm=V.d;V.d={f:Cm,r:wm,D:Dm,C:Om,L:km,m:Am,X:Mm,S:jm,M:Nm};function Cm(){var e=Sm.f(),t=Ld();return e||t}function wm(e){var t=Q(e);t!==null&&t.tag===5&&t.type===`form`?qs(t):Sm.r(e)}var Tm=typeof document>`u`?null:document;function Em(e,t,n){var r=Tm;if(r&&typeof t==`string`&&t){var i=Ut(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),bm.has(i)||(bm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),rp(t,`link`,e),$(t),r.head.appendChild(t)))}}function Dm(e){Sm.D(e),Em(`dns-prefetch`,e,null)}function Om(e,t){Sm.C(e,t),Em(`preconnect`,e,t)}function km(e,t,n){Sm.L(e,t,n);var r=Tm;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ut(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ut(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ut(n.imageSizes)+`"]`)):i+=`[href="`+Ut(e)+`"]`;var a=i;switch(t){case`style`:a=Fm(e);break;case`script`:a=zm(e)}if(!(ym.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),ym.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Im(a))||t===`script`&&r.querySelector(Bm(a))))){var o=r.createElement(`link`);rp(o,`link`,e),t===`style`&&(o[Z]=!0,o.onload=o.onerror=function(){Ct(o)}),$(o),r.head.appendChild(o)}}}function Am(e,t){Sm.m(e,t);var n=Tm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ut(r)+`"][href="`+Ut(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=zm(e)}if(!ym.has(a)&&(e=D({rel:`modulepreload`,href:e},t),ym.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Bm(a)))return}r=n.createElement(`link`),rp(r,`link`,e),$(r),n.head.appendChild(r)}}}function jm(e,t,n){Sm.S(e,t,n);var r=Tm;if(r&&e){var i=St(r).hoistableStyles,a=Fm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Im(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=ym.get(a))&&Um(e,n);var c=o=r.createElement(`link`);$(c),rp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Hm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Mm(e,t){Sm.X(e,t);var n=Tm;if(n&&e){var r=St(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),$(a),rp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t){Sm.M(e,t);var n=Tm;if(n&&e){var r=St(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),$(a),rp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t,n,r){var a=(a=ve.current)?xm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Fm(n.href),t=St(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Fm(n.href);var o=St(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Im(e)))?o._p||(s.instance=o,s.state.loading=5):(o=ym.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},ym.set(e,o)),Rm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=zm(n),t=St(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Fm(e){return`href="`+Ut(e)+`"`}function Im(e){return`link[rel="stylesheet"][`+e+`]`}function Lm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Rm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Z]){r.loading=1;return}}else t=e.createElement(`link`),t[Z]=!0,t.onload=t.onerror=Ct.bind(null,t),rp(t,`link`,n),$(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function zm(e){return`[src="`+Ut(e)+`"]`}function Bm(e){return`script[async]`+e}function Vm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ut(n.href)+`"]`);if(r)return t.instance=r,$(r),r;var a=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),$(r),rp(r,`style`,a),Hm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Fm(n.href);var o=e.querySelector(Im(a));if(o)return t.state.loading|=4,t.instance=o,$(o),o;r=Lm(n),(a=ym.get(a))&&Um(r,a),o=(e.ownerDocument||e).createElement(`link`),$(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),rp(o,`link`,r),t.state.loading|=4,Hm(o,n.precedence,e),t.instance=o;case`script`:return o=zm(n.src),(a=e.querySelector(Bm(o)))?(t.instance=a,$(a),a):(r=n,(a=ym.get(o))&&(r=D({},n),Wm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),$(a),rp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Hm(r,n.precedence,e));return t.instance}function Hm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Gm=null;function Km(e,t,n){if(Gm===null){var r=new Map,i=Gm=new Map;i.set(n,r)}else i=Gm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function qm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Jm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Ym(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Xm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Zm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Qm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Zm(t),e.suspenseyImages.push(t)),e=ih.bind(e),t.decode().then(e,e))}function $m(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Fm(r.href),a=t.querySelector(Im(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,$(a);return}a=t.ownerDocument||t,r=Lm(r),(i=ym.get(i))&&Um(r,i),a=a.createElement(`link`),$(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),rp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var eh=0;function th(e,t){return e.stylesheets&&e.count===0&&oh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&eh===0&&(eh=62500*sp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>eh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function nh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)oh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function rh(){this.count--,nh(this)}function ih(){this.imgCount--,nh(this)}var ah=null;function oh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ah=new Map,t.forEach(sh,e),ah=null,rh.call(e))}function sh(e,t){if(!(t.state.loading&4)){var n=ah.get(e);if(n)var r=n.get(null);else{n=new Map,ah.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ch={$$typeof:P,Provider:null,Consumer:null,_currentValue:fe,_currentValue2:fe,_threadCount:0};function lh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=tt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tt(0),this.hiddenUpdates=tt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function uh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new lh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=yi(3,null,null,t),e.current=a,a.stateNode=e,t=ba(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},no(a),e}function dh(e){return e?(e=_i,e):_i}function fh(e,t,n,r,i,a){i=dh(i),r.context===null?r.context=i:r.pendingContext=i,r=io(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=ao(e,r,t),n!==null&&(Md(n,e,t),oo(n,e,t))}function ph(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mh(e,t){ph(e,t),(e=e.alternate)&&ph(e,t)}function hh(e){if(e.tag===13||e.tag===31){var t=mi(e,67108864);t!==null&&Md(t,e,67108864),mh(e,67108864)}}function gh(e){if(e.tag===13||e.tag===31){var t=kd();t=ot(t);var n=mi(e,t);n!==null&&Md(n,e,t),mh(e,t)}}var _h=!0;function vh(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=2,bh(e,t,n,r)}finally{V.p=a,B.T=i}}function yh(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=8,bh(e,t,n,r)}finally{V.p=a,B.T=i}}function bh(e,t,n,r){if(_h){var i=xh(r);if(i===null)Kf(e,t,r,Sh,n),Nh(e,r);else if(Fh(i,e,t,n,r))r.stopPropagation();else if(Nh(e,r),t&4&&-1<Mh.indexOf(e)){for(;i!==null;){var a=Q(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Qe(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-qe(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(qu&6)&&(md=Ie()+500,Ef(0,!1))}}break;case 31:case 13:s=mi(a,2),s!==null&&Md(s,a,2),Ld(),mh(a,2)}if(a=xh(r),a===null&&Kf(e,t,r,Sh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Kf(e,t,r,null,n)}}function xh(e){return e=sn(e),Ch(e)}var Sh=null;function Ch(e){if(Sh=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Sh=e,null}function wh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Le()){case Re:return 2;case ze:return 8;case Be:case Ve:return 32;case He:return 268435456;default:return 32}default:return 32}}var Th=!1,Eh=null,Dh=null,Oh=null,kh=new Map,Ah=new Map,jh=[],Mh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Nh(e,t){switch(e){case`focusin`:case`focusout`:Eh=null;break;case`dragenter`:case`dragleave`:Dh=null;break;case`mouseover`:case`mouseout`:Oh=null;break;case`pointerover`:case`pointerout`:kh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Ah.delete(t.pointerId)}}function Ph(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Q(t),t!==null&&hh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Fh(e,t,n,r,i){switch(t){case`focusin`:return Eh=Ph(Eh,e,t,n,r,i),!0;case`dragenter`:return Dh=Ph(Dh,e,t,n,r,i),!0;case`mouseover`:return Oh=Ph(Oh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return kh.set(a,Ph(kh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Ah.set(a,Ph(Ah.get(a)||null,e,t,n,r,i)),!0}return!1}function Ih(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){gh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){gh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);on=r,n.target.dispatchEvent(r),on=null}else return t=Q(n),t!==null&&hh(t),e.blockedOn=n,!1;t.shift()}return!0}function Rh(e,t,n){Lh(e)&&n.delete(t)}function zh(){Th=!1,Eh!==null&&Lh(Eh)&&(Eh=null),Dh!==null&&Lh(Dh)&&(Dh=null),Oh!==null&&Lh(Oh)&&(Oh=null),kh.forEach(Rh),Ah.forEach(Rh)}function Bh(e,n){e.blockedOn===n&&(e.blockedOn=null,Th||(Th=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zh)))}var Vh=null;function Hh(e){Vh!==e&&(Vh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Vh===e&&(Vh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Ch(r||n)===null)continue;break}var a=Q(n);a!==null&&(e.splice(t,3),t-=3,Gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Uh(e){function t(t){return Bh(t,e)}Eh!==null&&Bh(Eh,e),Dh!==null&&Bh(Dh,e),Oh!==null&&Bh(Oh,e),kh.forEach(t),Ah.forEach(t);for(var n=0;n<jh.length;n++){var r=jh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<jh.length&&(n=jh[0],n.blockedOn===null);)Ih(n),n.blockedOn===null&&jh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Hh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(Ch(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Hh(n)}}}function Wh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Gh(e){this._internalRoot=e}Kh.prototype.render=Gh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;fh(n,kd(),e,t,null,null)},Kh.prototype.unmount=Gh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fh(e.current,2,null,e,null,null),Ld(),t[pt]=null}};function Kh(e){this._internalRoot=e}Kh.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jh.length&&t!==0&&t<jh[n].priority;n++);jh.splice(n,0,e),n===0&&Ih(e)}};var qh=n.version;if(qh!==`19.3.1`)throw Error(i(527,qh,`19.3.1`));V.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Jh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:B,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Yh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yh.isDisabled&&Yh.supportsFiber)try{Ge=Yh.inject(Jh),W=Yh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=mc,s=hc,c=gc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=uh(e,1,!1,null,null,n,r,null,o,s,c,Wh),e[pt]=t.current,Wf(e),new Gh(t)}})),_=o(((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=g()})),v=l(d(),1),y=_(),b={"agents.addJournal":[`POST`,`/api/agents/:slug/journal`],"agents.adoptRoutine":[`POST`,`/api/agents/:slug/routines/:id/adopt`],"agents.archive":[`POST`,`/api/agents/:slug/archive`],"agents.create":[`POST`,`/api/agents`],"agents.delete":[`DELETE`,`/api/agents/:slug`],"agents.deleteRoutine":[`DELETE`,`/api/agents/:slug/routines/:id`],"agents.deleteSkill":[`DELETE`,`/api/agents/:slug/skills/:name`],"agents.get":[`GET`,`/api/agents/:slug`],"agents.journal":[`GET`,`/api/agents/:slug/journal`],"agents.list":[`GET`,`/api/agents`],"agents.routines":[`GET`,`/api/agents/:slug/routines`],"agents.runRoutine":[`POST`,`/api/agents/:slug/routines/:id/run`],"agents.save":[`PUT`,`/api/agents/:slug`],"agents.saveRoutine":[`POST`,`/api/agents/:slug/routines`],"agents.saveSkill":[`POST`,`/api/agents/:slug/skills`],"agents.sessions":[`GET`,`/api/agent-sessions`],"agents.skill":[`GET`,`/api/agents/:slug/skills/:name`],"agents.skills":[`GET`,`/api/agents/:slug/skills`],"agents.status":[`GET`,`/api/agent-status`],"attention.list":[`GET`,`/api/attention`],"boards.create":[`POST`,`/api/boards`],"boards.delete":[`DELETE`,`/api/boards/:board`],"boards.ensure":[`POST`,`/api/boards/default`],"boards.get":[`GET`,`/api/boards/:board`],"boards.list":[`GET`,`/api/boards`],"boards.save":[`PUT`,`/api/boards/:board`],"channels.create":[`POST`,`/api/channels`],"channels.delete":[`DELETE`,`/api/channels/:slug`],"channels.fromChat":[`POST`,`/api/channels/from-chat`],"channels.get":[`GET`,`/api/channels/:slug`],"channels.list":[`GET`,`/api/channels`],"channels.save":[`PUT`,`/api/channels/:slug`],"chats.attach":[`POST`,`/api/chats/:id/attachments`,`upload`],"chats.attachment":[`GET`,`/api/chats/:id/attachments/:name`,`raw`],"chats.cancel":[`POST`,`/api/chats/:id/cancel`],"chats.config":[`POST`,`/api/chats/:id/config`],"chats.create":[`POST`,`/api/chats`],"chats.delete":[`DELETE`,`/api/chats/:id`],"chats.elicitation":[`POST`,`/api/chats/:id/elicitation`],"chats.events":[`GET`,`/api/chats/:id/events`,`raw`],"chats.fork":[`POST`,`/api/chats/:id/fork`],"chats.get":[`GET`,`/api/chats/:id`],"chats.list":[`GET`,`/api/chats`],"chats.message":[`POST`,`/api/chats/:id/message`],"chats.permission":[`POST`,`/api/chats/:id/permission`],"chats.rename":[`PATCH`,`/api/chats/:id`],"chats.resetSession":[`POST`,`/api/chats/:id/reset-session`],"chats.setProject":[`POST`,`/api/chats/:id/project`],"chats.setVibeable":[`POST`,`/api/chats/:id/vibeable`],"chats.steer":[`POST`,`/api/chats/:id/steer`],"chats.stopTask":[`POST`,`/api/chats/:id/task-stop`],"cloud.invite":[`POST`,`/api/cloud/invite`],"cloud.set":[`POST`,`/api/cloud`],"cloud.status":[`GET`,`/api/cloud`],"cloud.sync":[`POST`,`/api/cloud/sync`],"cloud.unlink":[`POST`,`/api/cloud/unlink`],"contacts.create":[`POST`,`/api/contacts`],"contacts.delete":[`DELETE`,`/api/contacts/:slug`],"contacts.get":[`GET`,`/api/contacts/:slug`],"contacts.list":[`GET`,`/api/contacts`],"contacts.save":[`PUT`,`/api/contacts/:slug`],"devices.code":[`POST`,`/api/devices/code`],"devices.dropPush":[`DELETE`,`/api/devices/push`],"devices.list":[`GET`,`/api/devices`],"devices.pair":[`POST`,`/api/pair`],"devices.relay":[`GET`,`/api/devices/relay`],"devices.revoke":[`DELETE`,`/api/devices/:id`],"devices.self":[`GET`,`/api/devices/self`],"devices.setPush":[`POST`,`/api/devices/push`],"devices.setRelay":[`POST`,`/api/devices/relay`],"events.create":[`POST`,`/api/events`],"events.delete":[`DELETE`,`/api/events/:slug`],"events.get":[`GET`,`/api/events/:slug`],"events.list":[`GET`,`/api/events`],"events.save":[`PUT`,`/api/events/:slug`],"files.delete":[`DELETE`,`/api/files`],"files.list":[`GET`,`/api/files/list`],"files.mkdir":[`POST`,`/api/files/folder`],"files.move":[`POST`,`/api/files/move`],"files.raw":[`GET`,`/api/files/raw`,`raw`],"files.recent":[`GET`,`/api/files/recent`],"files.scopes":[`GET`,`/api/files`],"files.upload":[`POST`,`/api/files/upload`,`upload`],"git.commit":[`POST`,`/api/git/commit`],"git.diff":[`GET`,`/api/git/diff`],"git.fetch":[`POST`,`/api/git/fetch`],"git.pull":[`POST`,`/api/git/pull`],"git.push":[`POST`,`/api/git/push`],"git.status":[`GET`,`/api/git`],"hub.close":[`POST`,`/api/hub/close`],"hub.list":[`GET`,`/api/hub`],"hub.open":[`POST`,`/api/hub/open`],"identity.get":[`GET`,`/api/identity`],"knowledge.concept":[`GET`,`/api/knowledge/:bundle/concept`],"knowledge.create":[`POST`,`/api/knowledge`],"knowledge.delete":[`DELETE`,`/api/knowledge/:bundle`],"knowledge.get":[`GET`,`/api/knowledge/:bundle`],"knowledge.list":[`GET`,`/api/knowledge`],"knowledge.putConcept":[`POST`,`/api/knowledge/:bundle/concept`],"knowledge.verify":[`POST`,`/api/knowledge/:bundle/verify`],"meta.get":[`GET`,`/api/meta`],"notifications.clear":[`DELETE`,`/api/notifications`],"notifications.diagnose":[`POST`,`/api/notifications/:id/diagnose`],"notifications.list":[`GET`,`/api/notifications`],"notifications.read":[`POST`,`/api/notifications/read`],"places.create":[`POST`,`/api/places`],"places.delete":[`DELETE`,`/api/places/:slug`],"places.get":[`GET`,`/api/places/:slug`],"places.list":[`GET`,`/api/places`],"places.save":[`PUT`,`/api/places/:slug`],"presentations.comment":[`POST`,`/api/presentations/:name/comments`],"presentations.commentDelete":[`DELETE`,`/api/presentations/:name/comments/:id`],"presentations.commentSave":[`PUT`,`/api/presentations/:name/comments/:id`],"presentations.create":[`POST`,`/api/presentations`],"presentations.delete":[`DELETE`,`/api/presentations/:name`],"presentations.export":[`GET`,`/api/presentations/:name/export`,`raw`],"presentations.file":[`GET`,`/api/presentations/:name/file`,`raw`],"presentations.get":[`GET`,`/api/presentations/:name`],"presentations.history":[`GET`,`/api/presentations/:name/history`],"presentations.links":[`GET`,`/api/presentations/:name/links`],"presentations.list":[`GET`,`/api/presentations`],"presentations.presence":[`POST`,`/api/presentations/:name/presence`],"presentations.save":[`PUT`,`/api/presentations/:name`],"presentations.slide":[`GET`,`/api/presentations/:name/slides/:n`,`raw`],"presentations.templateFile":[`GET`,`/api/presentations/templates/:slug/file`,`raw`],"presentations.templates":[`GET`,`/api/presentations/templates`],"presentations.upload":[`POST`,`/api/presentations/:name/assets`,`upload`],"presentations.version":[`GET`,`/api/presentations/:name/history/:id`],"projects.create":[`POST`,`/api/projects`],"projects.delete":[`DELETE`,`/api/projects/:slug`],"projects.get":[`GET`,`/api/projects/:slug`],"projects.link":[`POST`,`/api/projects/:slug/links`],"projects.list":[`GET`,`/api/projects`],"projects.log":[`POST`,`/api/projects/:slug/log`],"projects.save":[`PUT`,`/api/projects/:slug`],"projects.saveLayout":[`PUT`,`/api/projects`],"protocol.get":[`GET`,`/api/protocol`],"refs.resolve":[`POST`,`/api/refs/resolve`],"repos.add":[`POST`,`/api/repos`],"repos.commit":[`GET`,`/api/repos/:slug/commits/:hash`],"repos.diff":[`GET`,`/api/repos/:slug/diff`],"repos.get":[`GET`,`/api/repos/:slug`],"repos.list":[`GET`,`/api/repos`],"repos.remove":[`DELETE`,`/api/repos/:slug`],"repos.update":[`POST`,`/api/repos/:slug/update`],"routines.adopt":[`POST`,`/api/routines/adopt`],"routines.list":[`GET`,`/api/routines`],"runs.decide":[`POST`,`/api/runs/:id/decision`],"runs.delete":[`DELETE`,`/api/runs/:id`],"runs.file":[`GET`,`/api/runs/:id/file`,`raw`],"runs.fileText":[`GET`,`/api/runs/:id/text`],"runs.get":[`GET`,`/api/runs/:id`],"runs.list":[`GET`,`/api/runs`],"runs.stop":[`POST`,`/api/runs/:id/stop`],"search.agents":[`GET`,`/api/search/agents`],"server.restart":[`POST`,`/api/restart`],"settings.get":[`GET`,`/api/settings`],"settings.save":[`PUT`,`/api/settings`],"skills.get":[`GET`,`/api/skills/:name`],"skills.list":[`GET`,`/api/skills`],"tasks.assign":[`POST`,`/api/boards/:board/tasks/:task/assign`],"tasks.create":[`POST`,`/api/boards/:board/tasks`],"tasks.delete":[`DELETE`,`/api/boards/:board/tasks/:task`],"tasks.get":[`GET`,`/api/boards/:board/tasks/:task`],"tasks.log":[`POST`,`/api/boards/:board/tasks/:task/log`],"tasks.move":[`POST`,`/api/boards/:board/tasks/:task/move`],"tasks.pick":[`POST`,`/api/boards/:board/pick`],"tasks.save":[`PUT`,`/api/boards/:board/tasks/:task`],"temp.clean":[`DELETE`,`/api/temp`],"temp.list":[`GET`,`/api/temp`],"trash.empty":[`DELETE`,`/api/trash`],"trash.list":[`GET`,`/api/trash`],"trash.purge":[`POST`,`/api/trash/purge`],"trash.restore":[`POST`,`/api/trash/restore`],"update.check":[`GET`,`/api/update-check`],"update.start":[`POST`,`/api/update`],"update.status":[`GET`,`/api/update`],"vibeables.create":[`POST`,`/api/vibeables`],"vibeables.delete":[`DELETE`,`/api/vibeables/:slug`],"vibeables.devStart":[`POST`,`/api/vibeables/:slug/dev/start`],"vibeables.devStop":[`POST`,`/api/vibeables/:slug/dev/stop`],"vibeables.events":[`GET`,`/api/vibeables/:slug/events`,`raw`],"vibeables.get":[`GET`,`/api/vibeables/:slug`],"vibeables.list":[`GET`,`/api/vibeables`],"workflows.delete":[`DELETE`,`/api/workflows/:slug`],"workflows.get":[`GET`,`/api/workflows/:slug`],"workflows.list":[`GET`,`/api/workflows`],"workflows.run":[`POST`,`/api/workflows/:slug/run`],"workflows.runner":[`GET`,`/api/workflows/:slug/run`],"workspaces.forget":[`POST`,`/api/workspaces/forget`],"workspaces.list":[`GET`,`/api/workspaces`],"workspaces.start":[`POST`,`/api/workspaces/start`],"workspaces.stop":[`POST`,`/api/workspaces/stop`]},x=1e4;function S(e){let t=e.WebSocket??(typeof WebSocket>`u`?void 0:WebSocket),n=e.EventSource??(typeof EventSource>`u`?void 0:EventSource),{client:r}=e,i=new Map,a=new Map,o=null,s=!1,c=!1,l=500,u,d=0,f=()=>`${(/^https?:/.test(r.baseUrl)?r.baseUrl:(typeof location>`u`?``:location.origin)+r.baseUrl).replace(/^http/,`ws`).replace(/\/+$/,``)}/api/ws${r.token?`?token=${encodeURIComponent(r.token)}`:``}`,p=e=>{s&&o?.send(JSON.stringify(e))},m=e=>{let t=i.get(e);t&&!s&&(clearTimeout(t.timer),r.request(t.name,t.input).then(n=>n.ok&&i.get(e)===t&&!s&&t.onData(n.data)).catch(()=>{}).finally(()=>{i.get(e)===t&&!s&&(t.timer=setTimeout(()=>m(e),t.interval))}))},h=e=>{let t=a.get(e);if(!t||s||t.source||!n)return;let[i,...o]=t.topic.split(`.`),c=o.join(`.`),l=i===`chat`?r.url(`chats.events`,{id:c,query:{after:t.after}}):i===`vibeable`?r.url(`vibeables.events`,{slug:c}):``;l&&(t.source=new n(l),t.source.onmessage=t=>g(e,JSON.parse(t.data)))},g=(e,t)=>{let n=a.get(e);if(!n)return;let r=t?.seq;if(typeof r==`number`){if(r<=n.after)return;n.after=r}n.onEvent(t)},_=r.onChange(()=>{if(!s)for(let e of i.keys())m(e)}),v=()=>{for(let[e,t]of i)clearTimeout(t.timer),p({watch:e,name:t.name,input:t.input,interval:t.interval});for(let[e,t]of a)t.source?.close(),t.source=void 0,p({sub:e,topic:t.topic,after:t.after})},y=()=>{for(let e of i.keys())m(e);for(let e of a.keys())h(e)},b=()=>{if(c||o||!t)return;let e;try{e=new t(f())}catch{return y()}o=e,e.onopen=()=>{s=!0,l=500,v()},e.onmessage=e=>{let t;try{t=JSON.parse(String(e.data))}catch{return}t.watch&&`data`in t?i.get(t.watch)?.onData(t.data):t.event&&g(t.event,t.data)},e.onclose=()=>{o=null,s=!1,c||(y(),u=setTimeout(b,l),l=Math.min(x,l*2))}};return{get connected(){return s},watch(e,t,n,r){let a=`w${++d}`;return i.set(a,{name:e,input:t??{},interval:n.interval??6e3,onData:r}),s?p({watch:a,name:e,input:t??{},interval:n.interval??6e3}):(m(a),b()),()=>{clearTimeout(i.get(a)?.timer),i.delete(a),p({unwatch:a})}},subscribe(e,t,n){let r=`s${++d}`;return a.set(r,{topic:e,after:t.after??0,onEvent:n}),s?p({sub:r,topic:e,after:t.after??0}):(h(r),b()),()=>{a.get(r)?.source?.close(),a.delete(r),p({unsub:r})}},close(){c=!0,_(),clearTimeout(u),o?.close();for(let e of i.values())clearTimeout(e.timer);for(let e of a.values())e.source?.close();i.clear(),a.clear()}}}var C=class extends Error{status;body;route;constructor(e,t,n){super(w(t)??`${n}: HTTP ${e}`),this.status=e,this.body=t,this.route=n}};function w(e){let t=e&&typeof e==`object`&&`error`in e?e.error:void 0;return typeof t==`string`&&t?t:void 0}function T(e={}){let t=(e.baseUrl??``).replace(/\/+$/,``)+(e.workspace?`/w/${encodeURIComponent(e.workspace)}`:``),n=e.fetch??((...e)=>fetch(...e)),r=new Set,i=(e,n={})=>{let[,r]=b[e],i=r.replace(/:([A-Za-z]+)/g,(t,r)=>{let i=n[r];if(i==null||i===``)throw Error(`${e}: missing path parameter ${r}`);return encodeURIComponent(String(i))}),a=new URLSearchParams;for(let[e,t]of Object.entries(n.query??{}))t!=null&&t!==!1&&a.set(e,t===!0?`1`:String(t));let o=a.toString();return`${t}${i}${o?`?${o}`:``}`},a=async(t,a={})=>{let[o]=b[t],{body:s,headers:c={},signal:l,keepalive:u}=a,d=s instanceof Blob||s instanceof ArrayBuffer||ArrayBuffer.isView(s),f=await n(i(t,a),{method:o,cache:`no-store`,signal:l,keepalive:u,headers:{...s!==void 0&&!d?{"content-type":`application/json`}:{},...e.token?{authorization:`Bearer ${e.token}`}:{},...c},body:s===void 0?void 0:d?s:JSON.stringify(s)}),p=await f.text(),m=p;try{m=p?JSON.parse(p):void 0}catch{}if(f.ok&&o!==`GET`)for(let e of r)e();return f.status===401&&m?.pair===!0&&e.onUnauthorized?.(),f.ok?{ok:!0,status:f.status,data:m}:{ok:!1,status:f.status,data:m,error:w(m)}};return{token:e.token,baseUrl:t,onChange(e){return r.add(e),()=>r.delete(e)},url:((e,t)=>i(e,t)),request:((e,t)=>a(e,t)),call:(async(e,t)=>{let n=await a(e,t);if(!n.ok)throw new C(n.status,n.data,e);return n.data})}}var E=!1,D=new Set;function O(){return(0,v.useSyncExternalStore)(e=>(D.add(e),()=>D.delete(e)),()=>E)}var k=/^\/w\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\//.exec(location.pathname)?.[1],A=T({workspace:k,onUnauthorized:()=>{if(!E){E=!0;for(let e of D)e()}}}),ee=e=>e.startsWith(`/`)?A.baseUrl+e:e,j=S({client:A});function M(e){return e.ok?``:e.error??`HTTP ${e.status}`}function N(e,t,n={}){let[r,i]=(0,v.useState)(null),a=t===null?``:`${e} ${JSON.stringify(t)}`,o=(0,v.useRef)(t);o.current=t;let{fast:s=!1,interval:c=6e3,refresh:l}=n;return(0,v.useEffect)(()=>{if(a)return j.watch(e,o.current??void 0,{interval:s?1500:c},i)},[a,s,c,l]),r}function P(...e){return e.filter(Boolean).join(` `)}var F=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),te=o(((e,t)=>{t.exports=F()})),I=te();function R({name:e,fill:t,className:n}){return(0,I.jsx)(`span`,{className:`ms material-symbols-rounded${t?` ms-fill`:``}${e===`progress_activity`?` ms-spin`:``}${n?` ${n}`:``}`,"aria-hidden":!0,children:e})}function z(){let[e,t]=(0,v.useState)(()=>window.location.hash.slice(1)||`/`);return(0,v.useEffect)(()=>{let e=()=>t(window.location.hash.slice(1)||`/`);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}var ne=`kraftwerk inspector`,re=``,ie=0;function ae(){let e=re?`${re} — ${ne}`:ne;document.title=ie>0?`(${ie}) ${e}`:e}function oe(e){e!==ie&&(ie=e,ae())}function se(e){ne=e,ae()}function ce(e){re=e,ae()}var le=new Set([`agents`,`team`,`chats`,`projects`,`channels`]),ue=e=>{let t=e.split(`?`)[0].split(`/`).filter(Boolean);return t[0]===`projects`&&t[2]===`boards`},de=e=>{let t=e.split(`?`)[0].split(`/`).filter(Boolean);return t[0]===`projects`&&t[2]===`presentations`},B=e=>le.has(e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``)&&!ue(e)&&!de(e)?`chat`:`side`,V=`kw-column-path`;function fe(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return!n||n===`chats`?!1:n===`new`?[`projects`,`agents`,`team`,`channels`].includes(t[0])&&!t[2]:t[0]===`projects`?t[2]===`info`:t[0]===`agents`||t[0]===`team`?t[2]===`info`||t[2]===`edit`:t[0]===`channels`&&t[2]===`edit`}function H(e,t){let n=window.location.hash.slice(1)||`/`;t?.replace&&(B(e)!==B(n)||fe(n)&&!fe(e)&&B(e)===`chat`)?window.dispatchEvent(new CustomEvent(V,{detail:e})):t?.replace?window.location.replace(`#${e}`):window.location.hash=e}function pe(e){if(!e.here||!e.slug)return e.url;let{protocol:t,hostname:n,port:r}=window.location;return k?`/w/${e.slug}/`:n.endsWith(`.localhost`)?`${t}//${e.slug}.localhost${r?`:${r}`:``}/`:n===`localhost`||n===`127.0.0.1`||n===`[::1]`?e.url:`/w/${e.slug}/`}async function me(e){let t=await A.request(`workspaces.start`,{body:{root:e}});if(!t.ok)throw Error(M(t));let n=t.data;if(n.live&&n.url)return pe({url:n.url,slug:n.slug,here:n.here});for(let t=0;t<12;t++){await new Promise(e=>setTimeout(e,1e3));try{let t=(await A.call(`meta.get`)).switcher.find(t=>t.root===e&&t.live);if(t)return pe(t)}catch{}}throw Error(`started, but the UI did not answer yet — see ~/.kraftwerk/logs`)}var he=(0,v.createContext)(null);function U({href:e,onClick:t,...n}){let r=(0,v.useContext)(he);return(0,I.jsx)(`a`,{href:`#${e}`,onClick:n=>{t?.(n),!n.defaultPrevented&&r&&(n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||r(e)&&n.preventDefault())},...n})}var ge=`kw-expert`,_e=(()=>{try{return localStorage.getItem(ge)!==`off`}catch{return!0}})(),ve=new Set;document.documentElement.dataset.expert=_e?`on`:`off`;function ye(e){_e=e,document.documentElement.dataset.expert=e?`on`:`off`;try{localStorage.setItem(ge,e?`on`:`off`)}catch{}ve.forEach(e=>e())}function be(){return(0,v.useSyncExternalStore)(e=>(ve.add(e),()=>ve.delete(e)),()=>_e)}var xe=[`git`,`repos`,`vibeables`,`projects`,`contacts`,`places`,`events`,`boards`,`presentations`],Se={git:!1,repos:!1,vibeables:!1,projects:!1,contacts:!1,places:!1,events:!1,boards:!1,presentations:!1},Ce=new Set;function we(e){xe.every(t=>e[t]===Se[t])||(Se=e,Ce.forEach(e=>e()))}function Te(){return(0,v.useSyncExternalStore)(e=>(Ce.add(e),()=>Ce.delete(e)),()=>Se)}function Ee(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)%360}function De(e,t){return e||`hsl(${Ee(t)} 58% 46%)`}function Oe(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(t){let e=t[1].length===3?t[1].split(``).map(e=>e+e).join(``):t[1];return[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}let n=/^hsl\(\s*([\d.]+)[ ,]+([\d.]+)%[ ,]+([\d.]+)%/i.exec(e.trim());if(!n)return null;let r=n[1]/360,i=n[2]/100,a=n[3]/100,o=a<.5?a*(1+i):a+i-a*i,s=2*a-o,c=e=>(e=(e+1)%1,e<1/6?s+(o-s)*6*e:e<1/2?o:e<2/3?s+(o-s)*(2/3-e)*6:s);return[c(r+1/3),c(r),c(r-1/3)].map(e=>Math.round(e*255))}var ke=(e,t,n)=>e.map((e,r)=>Math.round(e+(t[r]-e)*n)),Ae=e=>`#`+e.map(e=>e.toString(16).padStart(2,`0`)).join(``);function je([e,t,n]){let r=e=>(e/=255)<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Me(e,t){let n=je(e),r=je(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Ne(e,t,n,r){let i=e;for(let a=0;a<=1&&Me(i,t)<n;a+=.04)i=ke(e,r,a);return i}var Pe=[255,255,255],Fe=[0,0,0],Ie=[38,37,35];function Le(e){let t=Oe(e);if(!t)return null;let n=Ne(t,Pe,4.5,Fe),r=ke(t,Pe,.84),i=ke(t,Pe,.88),a=Ne(ke(t,Pe,.4),Ie,4.5,Pe),o=ke(t,Fe,.42),s=ke(t,Fe,.6);return{"--wsp-l-primary":Ae(n),"--wsp-l-on-primary":Ae(Pe),"--wsp-l-primary-container":Ae(r),"--wsp-l-on-primary-container":Ae(Ne(ke(t,Fe,.6),r,4.5,Fe)),"--wsp-l-secondary-container":Ae(i),"--wsp-l-on-secondary-container":Ae(Ne(ke(t,Fe,.65),i,4.5,Fe)),"--wsp-d-primary":Ae(a),"--wsp-d-on-primary":Ae(Ne(ke(t,Fe,.7),a,4.5,Fe)),"--wsp-d-primary-container":Ae(o),"--wsp-d-on-primary-container":Ae(Ne(ke(t,Pe,.8),o,4.5,Pe)),"--wsp-d-secondary-container":Ae(s),"--wsp-d-on-secondary-container":Ae(Ne(ke(t,Pe,.85),s,4.5,Pe))}}function Re(e){let t=e.split(/[^\p{L}\p{N}]+/u).filter(Boolean);return t.length===0?`?`:(t.length>=2?t[0][0]+t[1][0]:t[0].slice(0,2)).toUpperCase()}function ze({icon:e,name:t,color:n,seed:r,ambiguous:i,size:a=`md`,className:o}){let s={"--ws-c":De(n,r)};return(0,I.jsxs)(`span`,{className:P(`relative grid flex-none place-items-center rounded-full leading-none`,`bg-[color-mix(in_srgb,var(--ws-c,var(--text))_22%,var(--surface-2))]`,a===`sm`?`size-8`:`size-10`,e?a===`sm`?`text-[18px]`:`text-[22px]`:P(`font-sans font-medium tracking-[0.15px] text-[var(--ws-c,var(--text))]`,a===`sm`?`text-[13px]`:`text-base`),o),style:s,"aria-hidden":!0,children:[e||Re(t),e&&i&&(0,I.jsx)(`span`,{className:`absolute -right-[3px] -bottom-[3px] grid h-[18px] min-w-[18px] place-items-center rounded-full bg-[var(--ws-c,var(--text))] px-1 font-sans text-[10px] font-medium leading-none tracking-[0.4px] text-white shadow-[0_0_0_2px_var(--surface-1)]`,children:Re(t)})]})}var Be={emoji:`🧭`,name:`Assistant`};function Ve(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m${String(t%60).padStart(2,`0`)}s`}function He(e){return e==null?`—`:`$${e.toFixed(2)}`}function Ue(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function We(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} K`:`${(e/1024/1024).toFixed(1)} M`}function Ge(e){if(!e)return`—`;let t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),i=t.toTimeString().slice(0,5);return r?i:`${t.toISOString().slice(5,10)} ${i}`}function W(e){if(!e)return`—`;let t=Date.now()-Date.parse(e);if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toISOString().slice(5,10)}function Ke({since:e}){let[,t]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),e?(0,I.jsx)(`span`,{className:`tabular-nums`,children:Ve(Date.now()-Date.parse(e))}):null}var qe=[``,`low`,`medium`,`high`,`xhigh`,`max`],Je=`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-control font-medium transition-colors disabled:cursor-default disabled:opacity-45 focus-visible:outline-2 focus-visible:outline-live cursor-pointer no-underline`,Ye={primary:`bg-accent text-on-accent hover:bg-accent-hover`,secondary:`border border-line bg-transparent text-fg hover:bg-surface-2`,quiet:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`,danger:`bg-transparent text-bad hover:bg-bad-soft`},Xe={sm:`h-7 px-2.5 text-sm`,md:`h-9 px-3.5 text-base`};function Ze(e=`secondary`,t=`md`,n){return P(Je,Ye[e],Xe[t],n)}function G({variant:e=`secondary`,size:t=`md`,icon:n,busy:r,children:i,className:a,href:o,...s}){let c=(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(R,{name:r?`progress_activity`:n,className:`ms-sm`}),i]}),l=Ze(e,t,a);return o?(0,I.jsx)(U,{href:o,className:l,title:s.title,"aria-label":s[`aria-label`],onClick:s.onClick,children:c}):(0,I.jsx)(`button`,{type:`button`,className:l,...s,disabled:r||s.disabled,children:c})}function K({icon:e,label:t,variant:n=`quiet`,size:r=`md`,className:i,href:a,...o}){let s=P(`inline-grid shrink-0 place-items-center rounded-control transition-colors cursor-pointer disabled:opacity-45 disabled:cursor-default no-underline`,n===`danger`?`text-bad hover:bg-bad-soft`:`text-fg-2 hover:bg-surface-2 hover:text-fg`,r===`sm`?`size-7`:`size-8`,i);return a?(0,I.jsx)(U,{href:a,className:s,title:t,"aria-label":t,children:(0,I.jsx)(R,{name:e,className:`ms-sm`})}):(0,I.jsx)(`button`,{type:`button`,className:s,title:t,"aria-label":t,...o,children:(0,I.jsx)(R,{name:e,className:`ms-sm`})})}function Qe({n:e,tone:t=`bad`,title:n}){return e?(0,I.jsx)(`span`,{"data-ui":`badge`,className:P(`inline-grid h-[18px] min-w-[18px] shrink-0 place-items-center rounded-full px-1.5 text-2xs font-bold tabular-nums`,t===`bad`?`bg-bad text-on-bad`:`bg-surface-2 text-fg-2`),title:n,"aria-label":n??`${e}`,children:e}):null}function $e({tone:e,title:t}){return(0,I.jsx)(`span`,{"data-ui":`dot`,"data-tone":e,title:t,className:P(`inline-block size-2 shrink-0 rounded-full`,e===`ok`&&`bg-ok`,e===`bad`&&`bg-bad`,e===`ask`&&`bg-ask`,e===`live`&&`bg-live`,e===`working`&&`animate-pulse bg-accent`,e===`idle`&&`border-[1.5px] border-line`)})}function q({children:e,tone:t=`neutral`,title:n,href:r,className:i}){let a=P(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-2xs font-semibold no-underline`,t===`neutral`&&`bg-surface-2 text-fg-2`,t===`ok`&&`bg-ok-soft text-ok`,t===`bad`&&`bg-bad-soft text-on-bad-soft`,t===`ask`&&`bg-ask-soft text-on-ask-soft`,t===`accent`&&`bg-accent-soft text-on-accent-soft`,r&&`transition-opacity hover:opacity-80`,i);return r?(0,I.jsx)(U,{href:r,title:n,className:a,children:e}):(0,I.jsx)(`span`,{title:n,className:a,children:e})}function et({children:e,className:t,...n}){return(0,I.jsx)(`kbd`,{className:P(`rounded-[5px] border border-line px-[5px] py-[3px] font-mono text-[10.5px] leading-none text-fg-2`,t),...n,children:e})}function J({children:e,className:t}){return(0,I.jsx)(`p`,{className:P(`m-0 text-xs text-fg-2 [&_code]:text-2xs`,t),children:e})}function Y({icon:e,children:t,action:n,className:r}){return(0,I.jsxs)(`div`,{className:P(`flex flex-col items-center gap-2 px-4 py-10 text-center text-sm text-fg-2`,r),children:[e&&(0,I.jsx)(R,{name:e,className:`text-[32px] opacity-70`}),(0,I.jsx)(`div`,{children:t}),n]})}function tt({tone:e=`neutral`,children:t}){return(0,I.jsxs)(`div`,{className:P(`flex items-center gap-1.5 px-1.5 py-1 text-sm`,e===`bad`?`text-bad`:`text-fg-2`),children:[e===`bad`&&(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),t]})}function nt({children:e,className:t}){return(0,I.jsx)(`span`,{className:P(`text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2`,t),children:e})}function rt({title:e,count:t,action:n,size:r=`sm`,children:i,className:a}){return r===`lg`?(0,I.jsxs)(`section`,{className:P(`mt-4 border-t border-line pt-4 first:mt-0 first:border-t-0 first:pt-0`,a),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-1.5`,children:[(0,I.jsx)(`h3`,{className:`m-0 text-[17px] leading-tight font-[750] tracking-[-0.01em] text-fg first-letter:uppercase`,children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`rounded-full bg-surface-2 px-2 py-px text-xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),i]}):(0,I.jsxs)(`section`,{className:P(`mt-3 first:mt-0`,a),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-1 pt-1`,children:[(0,I.jsx)(nt,{children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),i]})}function X({title:e,count:t,actions:n,children:r,className:i}){return(0,I.jsxs)(`section`,{className:P(`overflow-hidden rounded-card border border-line bg-surface`,i),children:[(e||n)&&(0,I.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center gap-2 border-b border-line px-[18px] py-2`,children:[e&&(0,I.jsx)(nt,{className:`whitespace-nowrap text-fg`,children:e}),t!==void 0&&t>0&&(0,I.jsx)(`span`,{className:`text-xs font-bold tabular-nums text-bad`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),r]})}function it({children:e,size:t=`md`,className:n}){return(0,I.jsx)(`h1`,{className:P(`m-0 font-semibold tracking-[-0.01em] text-fg`,t===`lg`?`text-2xl`:`text-xl`,n),children:e})}function at({title:e,sub:t,actions:n,icon:r}){return(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[typeof r==`string`?(0,I.jsx)(R,{name:r,className:`text-[26px] text-fg-2`}):r,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(it,{children:e}),t&&(0,I.jsx)(`div`,{className:`text-sm text-fg-2`,children:t})]}),(0,I.jsx)(`span`,{className:`flex-1`}),n]})}function ot({children:e,width:t=`wide`,className:n}){return(0,I.jsx)(`div`,{className:P(`mx-auto flex w-full animate-rise flex-col gap-4`,t===`narrow`?`new-chat max-w-[640px]`:`max-w-[960px]`,n),children:e})}function st({children:e}){return(0,I.jsx)(`span`,{className:`grid size-14 flex-none place-items-center rounded-full bg-accent-soft text-[28px] leading-none`,children:e})}function ct({name:e}){return(0,I.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-full bg-accent-soft text-on-accent-soft`,children:(0,I.jsx)(R,{name:e,className:`text-[17px]`})})}function lt({icon:e,title:t,children:n,action:r,className:i,...a}){return(0,I.jsxs)(`div`,{className:P(`flex items-center gap-3.5 px-[18px] py-3`,i),...a,children:[(0,I.jsx)(ct,{name:e}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,I.jsx)(`span`,{className:`flex items-center gap-2 text-[13.5px] font-medium text-fg`,children:t}),n]}),r]})}function ut({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col divide-y divide-line py-1`,t),children:e})}var dt=(0,v.createContext)(!1);function ft({compact:e=!1,children:t}){return(0,I.jsx)(dt.Provider,{value:e,children:(0,I.jsx)(`div`,{className:`py-1 [&>*+*]:border-t [&>*+*]:border-line`,children:t})})}function pt({label:e,dim:t,mono:n,children:r}){let i=(0,v.useContext)(dt);return(0,I.jsxs)(`div`,{className:P(`flex`,i?`items-baseline gap-3 px-3.5 py-1.5`:`flex-col gap-[3px] px-[18px] py-2.5`),children:[(0,I.jsx)(nt,{className:P(i&&`w-[84px] flex-none`),children:e}),(0,I.jsx)(`span`,{className:P(`flex min-w-0 flex-wrap items-center gap-2 break-words`,i?`text-xs`:`text-[12.5px]`,t?`text-fg-2`:`text-fg`,n&&`font-mono break-all`),children:r})]})}function mt({leading:e,title:t,sub:n,subTone:r=`plain`,meta:i,actions:a,href:o,onClick:s,active:c,dim:l,size:u=`md`,className:d,titleExtra:f,label:p,over:m,actionsAlways:h,innerProps:g,titleLines:_=1}){let v=(0,I.jsxs)(I.Fragment,{children:[e!==void 0&&(0,I.jsx)(`span`,{className:`grid w-6 shrink-0 place-items-center text-[15px] text-fg-2`,children:e}),(0,I.jsxs)(`span`,{className:`grid min-w-0 flex-1`,children:[m&&(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-fg-2`,children:m}),(0,I.jsxs)(`span`,{className:P(`flex min-w-0 items-center gap-1.5 text-fg`,m?`font-normal`:`font-semibold`,u===`sm`?`text-sm`:`text-base`),children:[(0,I.jsx)(`span`,{className:P(`min-w-0`,_===2?`line-clamp-2 leading-snug [overflow-wrap:anywhere]`:`truncate`),children:t}),f]}),n&&(0,I.jsx)(`span`,{className:P(`truncate text-xs`,r===`bad`?`text-bad`:r===`accent`?`text-accent`:`text-fg-2`),children:n})]}),i!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:i})]}),y=P(`flex min-w-0 flex-1 items-center gap-2.5 rounded-control text-left no-underline text-inherit`,u===`sm`?`px-2.5 py-1.5`:`px-2.5 py-2`,(o||s)&&`cursor-pointer`,l&&`opacity-55`),b=o?(0,I.jsx)(U,{href:o,onClick:s,className:y,"aria-label":p,"aria-current":c?`page`:void 0,...g,children:v}):s?(0,I.jsx)(`button`,{type:`button`,onClick:s,className:P(y,`border-0 bg-transparent font-[inherit]`),"aria-label":p,...g,children:v}):(0,I.jsx)(`div`,{className:y,children:v});return(0,I.jsxs)(`div`,{className:P(`group/row relative flex items-center rounded-control transition-colors`,c?`bg-surface shadow-[inset_0_0_0_1px_var(--line)]`:(o||s)&&`hover:bg-surface-2`,d),children:[b,a&&(0,I.jsx)(`span`,{className:P(`flex shrink-0 items-center gap-0.5 pr-1.5`,!h&&`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 pointer-coarse:opacity-100`),children:a})]})}function ht({items:e,value:t,onChange:n,className:r,label:i,bare:a}){return(0,I.jsx)(`div`,{role:`tablist`,"aria-label":i,className:P(`flex flex-wrap gap-x-4 max-[800px]:flex-nowrap max-[800px]:overflow-x-auto max-[800px]:overflow-y-hidden max-[800px]:[scrollbar-width:none] max-[800px]:[&>*]:flex-none`,!a&&`border-b border-line px-4`,r),children:e.map(e=>{let r=e.id===t,i=P(`-mb-px inline-flex cursor-pointer items-center gap-1.5 border-0 border-b-2 bg-transparent px-0 pt-2 pb-[7px] text-sm font-semibold no-underline transition-colors`,r?`border-accent text-accent`:`border-transparent text-fg-2 hover:text-fg`),a=(0,I.jsxs)(I.Fragment,{children:[e.label,e.count!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums opacity-70`,children:e.count})]});return e.href?(0,I.jsx)(U,{href:e.href,role:`tab`,"aria-selected":r,className:i,children:a},e.id):(0,I.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n?.(e.id),className:i,children:a},e.id)})})}var gt=`rounded-control border border-line bg-surface text-fg placeholder:text-fg-2 focus:border-accent focus:outline-none disabled:opacity-60`,_t=[[/^font-(sans|mono|reading|serif)$/,/^font-(sans|mono|reading|serif)$/],[/^text-(2xs|xs|sm|base|md|lg|xl)$/,/^text-(2xs|xs|sm|base|md|lg|xl|2xl|\[\d)/],[/^w-/,/^w-/],[/^h-/,/^h-/],[/^px-/,/^px-/],[/^pr-/,/^(pr|px)-/],[/^py-/,/^py-/],[/^leading-/,/^leading-/]];function vt(e,t){let n=(t??``).split(/\s+/).filter(Boolean);return P(gt,...e.split(` `).filter(e=>{let t=_t.find(([t])=>t.test(e));return!t||!n.some(e=>t[1].test(e))}),t)}var Z=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`input`,{ref:n,className:vt(`w-full h-9 px-3 font-sans text-base`,e),...t})}),yt=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`textarea`,{ref:n,className:vt(`w-full px-3 py-2 font-sans text-base leading-normal`,e),...t})});function bt({className:e,children:t,...n}){return(0,I.jsx)(`select`,{className:vt(`w-full h-9 cursor-pointer px-3 pr-8 font-sans text-base`,e),...n,children:t})}function Q({label:e,hint:t,children:n,className:r}){return(0,I.jsxs)(`label`,{className:P(`flex flex-col gap-1.5`,r),children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),n,t&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:t})]})}function xt({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col gap-3.5 p-[18px]`,t),children:e})}function St({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-wrap items-end gap-2.5 max-[900px]:flex-col max-[900px]:items-stretch`,t),children:e})}function $({checked:e,onChange:t,children:n,hint:r,mono:i,disabled:a,className:o}){return(0,I.jsxs)(`label`,{className:P(`flex cursor-pointer items-center gap-2 text-sm text-fg`,a&&`cursor-default opacity-60`,o),children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`size-[15px] flex-none accent-accent`,checked:e,disabled:a,onChange:e=>t(e.target.checked)}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[i?(0,I.jsx)(`b`,{className:`font-mono text-xs font-semibold`,children:n}):n,r&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[` — `,r]})]})]})}function Ct({checked:e}){return(0,I.jsx)(`span`,{"aria-hidden":!0,className:P(`relative inline-block h-6 w-11 flex-none rounded-full border-2 transition-colors`,e?`border-accent bg-accent`:`border-line bg-surface-2`),children:(0,I.jsx)(`span`,{className:P(`absolute top-1/2 size-4 -translate-y-1/2 rounded-full transition-[left,background-color]`,e?`left-[22px] bg-on-accent`:`left-1 bg-fg-2`)})})}function wt({checked:e,onChange:t,label:n,disabled:r}){return(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,title:n,disabled:r,onClick:()=>t(!e),className:`inline-flex flex-none cursor-pointer border-0 bg-transparent p-0 disabled:cursor-default disabled:opacity-50`,children:(0,I.jsx)(Ct,{checked:e})})}function Tt({label:e,hint:t,checked:n,onChange:r}){return(0,I.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-4 rounded-control border-0 bg-transparent py-2 pr-3 pl-2 text-left transition-colors hover:bg-surface-2`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`text-base text-fg`,children:e}),t&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:t})]}),(0,I.jsx)(Ct,{checked:n})]})}function Et({title:e,count:t,back:n,action:r,divided:i}){return(0,I.jsxs)(`div`,{className:P(`flex min-h-11 items-center gap-2 pt-3 pb-1`,i?`mt-2.5 border-t border-line px-2`:`px-3.5`),children:[n&&(0,I.jsx)(K,{icon:`arrow_back`,label:n.label,size:`sm`,href:n.href,className:`-ml-1.5`}),(0,I.jsx)(nt,{children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),r]})}function Dt({icon:e=`search`,...t}){return(0,I.jsxs)(`label`,{className:`relative mx-2 mt-1 mb-1 block`,children:[(0,I.jsx)(R,{name:e,className:`ms-sm pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-fg-2`}),(0,I.jsx)(Z,{type:`search`,className:`h-8 rounded-full pl-8 text-sm`,...t})]})}function Ot({children:e,label:t,className:n}){let r=P(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,n);return t?(0,I.jsx)(`nav`,{className:r,"aria-label":t,children:e}):(0,I.jsx)(`div`,{className:r,children:e})}function kt({children:e,className:t}){return(0,I.jsx)(`p`,{className:P(`m-0 px-3 py-2.5 text-xs text-fg-2`,t),children:e})}function At({trigger:e,children:t,align:n=`start`,className:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`span`,{ref:o,className:`relative inline-flex`,children:[e({open:i,toggle:()=>a(e=>!e)}),i&&(0,I.jsx)(`div`,{role:`menu`,className:P(`absolute top-[calc(100%+6px)] z-50 min-w-[260px] overflow-hidden rounded-card border border-line bg-surface p-1.5 shadow-pop`,n===`end`?`right-0`:`left-0`,r),children:t(()=>a(!1))})]})}var jt=null,Mt=new Set,Nt;async function Pt(){try{let e=await A.request(`attention.list`);if(e.ok){jt=e.data.items;for(let e of Mt)e()}}catch{}Nt=setTimeout(()=>void Pt(),3e3)}function Ft(e){return Mt.add(e),Mt.size===1&&Pt(),()=>{Mt.delete(e),Mt.size===0&&Nt&&clearTimeout(Nt)}}function It(){Nt&&clearTimeout(Nt),Pt()}function Lt(){return(0,v.useSyncExternalStore)(Ft,()=>jt)}var Rt={agent:(e,t)=>e.filter(e=>e.owner.agent?.slug===t),project:(e,t,n=[])=>e.filter(e=>e.owner.project?.slug===t||!!e.owner.agent&&n.includes(e.owner.agent.slug)),channel:(e,t)=>e.filter(e=>e.owner.channel===t),general:e=>e.filter(e=>e.owner.general)},zt=e=>e===`approval`?`front_hand`:e===`question`?`help`:e===`runner`?`event_busy`:e===`review`?`rate_review`:`error`,Bt=e=>e===`approval`?`needs approval`:e===`question`?`asks you`:e===`runner`?`no runner`:e===`review`?`for review`:`failed`;function Vt(e){let t=e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:``;return[e.project?`📁 ${e.project.title}`:e.channel?`#${e.channel}`:e.general?`Ralv`:e.workflow?`${e.workflow} run`:``,t].filter(Boolean).join(` · `)||`workspace`}var Ht=e=>new URLSearchParams(e.split(`?`)[1]??``).get(`focus`),Ut=e=>e.split(`?`)[0];function Wt(e,t){if(e.length!==0)return e[(e.findIndex(e=>e.href===t||Ht(t)===null&&Ut(e.href)===t)+1)%e.length]}function Gt(e){e.notificationId&&A.request(`notifications.read`,{body:{ids:[e.notificationId]}}).then(()=>It()).catch(()=>{}),(window.location.hash.slice(1)||`/`)===e.href?window.dispatchEvent(new Event(Kt)):H(e.href)}var Kt=`kw-refocus`;function qt(){let e=Lt()??[],t=Wt(e,z());return(0,v.useEffect)(()=>{let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.code!==`KeyN`)return;let t=Wt(jt??[],window.location.hash.slice(1)||`/`);t&&(e.preventDefault(),Gt(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),t?(0,I.jsxs)(`button`,{type:`button`,className:`next-btn inline-flex h-8 cursor-pointer items-center gap-2 rounded-control border-0 bg-bad/12 px-1.5 font-[inherit] text-sm text-fg hover:bg-bad/18`,onClick:()=>Gt(t),title:`next: ${Vt(t.owner)} — ${t.title} (⌥N)`,children:[(0,I.jsx)(`span`,{className:`next-n inline-grid h-5 min-w-5 place-items-center rounded-full bg-bad px-1.5 text-2xs font-bold tabular-nums text-on-bad`,children:e.length}),(0,I.jsx)(`span`,{className:`text-fg-2 max-[640px]:hidden`,children:`waiting`}),(0,I.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-0.5 rounded-md bg-bad pl-2.5 pr-2 font-semibold text-on-bad`,children:[`next `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),(0,I.jsx)(et,{className:`mr-1 max-[800px]:hidden`,"aria-hidden":!0,children:`⌥N`})]}):null}function Jt(){let e=z(),t=Ht(e),[n,r]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>r(e=>e+1);return window.addEventListener(Kt,e),()=>window.removeEventListener(Kt,e)},[]),(0,v.useEffect)(()=>{if(!t)return;let e=0,n=setInterval(()=>{let r=document.querySelector(`[data-request="${CSS.escape(t)}"]`);r?(clearInterval(n),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.classList.remove(`focus-flash`),r.offsetWidth,r.classList.add(`focus-flash`)):++e>40&&clearInterval(n)},150);return()=>clearInterval(n)},[t,e,n])}function Yt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xt=Yt();function Zt(e){Xt=e}var Qt={exec:()=>null};function $t(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function en(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(nn.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var tn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),nn={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:$t(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:$t(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:$t(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:$t(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:$t(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:$t(e=>RegExp(`^ {0,${e}}(?:</?(?:${vn})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:$t(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},rn=/^(?:[ \t]*(?:\n|$))+/,an=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,on=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,sn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,cn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ln=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,un=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,dn=en(un).replace(/bull/g,ln).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),fn=en(un).replace(/bull/g,ln).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,mn=/^[^\n]+/,hn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,gn=en(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,hn).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),_n=en(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ln).getRegex(),vn=`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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,yn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bn=en(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,yn).replace(`tag`,vn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xn=e=>en(pn).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex(),Sn=xn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Cn=xn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),wn={blockquote:en(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Cn).getRegex(),code:an,def:gn,fences:on,heading:cn,hr:sn,html:bn,lheading:dn,list:_n,newline:rn,paragraph:Sn,table:Qt,text:mn},Tn=en(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex(),En={...wn,lheading:fn,table:Tn,paragraph:en(pn).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Tn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex()},Dn={...wn,html:en(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,yn).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Qt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:en(pn).replace(`hr`,sn).replace(`heading`,` *#{1,6} *[^
10
+ `).replace(Qf,``)}function ep(e,t){return t=$f(t),$f(e)===t}function tp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||Xt(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&Xt(e,``+r);else return;break;case`className`:Ft(e,`class`,r);break;case`tabIndex`:Ft(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ft(e,n,r);break;case`style`:$t(e,r,o);return;case`data`:if(t!==`object`){Ft(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&tp(e,t,`name`,a.name,a,null),tp(e,t,`formEncType`,a.formEncType,a,null),tp(e,t,`formMethod`,a.formMethod,a,null),tp(e,t,`formTarget`,a.formTarget,a,null)):(tp(e,t,`encType`,a.encType,a,null),tp(e,t,`method`,a.method,a,null),tp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=rn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=an);return;case`onScroll`:r!=null&&Vf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Vf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=rn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Vf(`beforetoggle`,e),Vf(`toggle`,e),Pt(e,`popover`,r);break;case`xlinkActuate`:It(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:It(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:It(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:It(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Pt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=tn.get(n)||n,Pt(e,n,r);else return}Mt=!0}function np(e,t,n,r,a,o){switch(n){case`style`:$t(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)Xt(e,r);else if(typeof r==`number`||typeof r==`bigint`)Xt(e,``+r);else return;break;case`onScroll`:r!=null&&Vf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Vf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=an);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Tt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[ft]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Mt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Pt(e,n,r)}return}Mt=!0}function rp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Vf(`error`,e),Vf(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:tp(e,t,o,s,n,null)}}a&&tp(e,t,`srcSet`,n.srcSet,n,null),r&&tp(e,t,`src`,n.src,n,null);return;case`input`:Vf(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:tp(e,t,r,d,n,null)}}Gt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Vf(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:tp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&qt(e,!!r,n,!0):qt(e,!!r,t,!1);return;case`textarea`:for(s in Vf(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:tp(e,t,s,c,n,null)}Yt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:tp(e,t,l,r,n,null)}return;case`dialog`:Vf(`beforetoggle`,e),Vf(`toggle`,e),Vf(`cancel`,e),Vf(`close`,e);break;case`iframe`:case`object`:Vf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)Vf(Rf[r],e);break;case`image`:Vf(`error`,e),Vf(`load`,e);break;case`details`:Vf(`toggle`,e);break;case`embed`:case`source`:case`link`:Vf(`error`,e),Vf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:tp(e,t,u,r,n,null)}return;default:if(en(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&np(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&tp(e,t,c,r,n,null))}var ip={};function ap(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||tp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Mt=!0),o=m;break;case`name`:m!==f&&(Mt=!0),a=m;break;case`checked`:m!==f&&(Mt=!0),u=m;break;case`defaultChecked`:m!==f&&(Mt=!0),d=m;break;case`value`:m!==f&&(Mt=!0),s=m;break;case`defaultValue`:m!==f&&(Mt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&tp(e,t,p,m,r,f)}}Wt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||tp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Mt=!0),p=o;break;case`defaultValue`:o!==l&&(Mt=!0),c=o;break;case`multiple`:o!==l&&(Mt=!0),s=o;default:o!==l&&tp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?qt(e,!!n,n?[]:``,!1):qt(e,!!n,t,!0)):qt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:tp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Mt=!0),p=a;break;case`defaultValue`:a!==o&&(Mt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&tp(e,t,s,a,r,o)}Jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:tp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Mt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:tp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&tp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:tp(e,t,u,p,r,m)}return;default:if(en(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&np(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||np(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&tp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||tp(e,t,f,p,r,m)}function op(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function sp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&op(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&op(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var cp=null,lp=null;function up(e){return e.nodeType===9?e:e.ownerDocument}function dp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function fp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function pp(e,t,n,r){return n=up(n).createElement(e),n[dt]=r,n[ft]=t,rp(n,e,t),$(n),n}function mp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hp=null;function gp(){var e=window.event;return e&&e.type===`popstate`?e!==hp&&(hp=e,!0):(hp=null,!1)}var _p=typeof setTimeout==`function`?setTimeout:void 0,vp=typeof clearTimeout==`function`?clearTimeout:void 0,yp=typeof Promise==`function`?Promise:void 0,bp=typeof requestAnimationFrame==`function`?requestAnimationFrame:_p,xp=typeof queueMicrotask==`function`?queueMicrotask:yp===void 0?_p:function(e){return yp.resolve(null).then(e).catch(Sp)};function Sp(e){setTimeout(function(){throw e})}function Cp(e){return e===`head`}function wp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Uh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)vm(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,vm(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&vm(e.ownerDocument.body)}n=i}while(n);Uh(t)}function Tp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Ep(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Dp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Op(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function kp(e){return Op(e.getBoundingClientRect(),getComputedStyle(e),e)}function Ap(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Op(t,n,e)}function jp(e){return e.documentElement.clientHeight}function Mp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Np(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(jp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Zm(f),u>eh){s.length=o;break}f=new Promise(Mp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Pp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Pp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Pp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Pp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Fp(e){return{name:e,group:new Pp(`group`,e),imagePair:new Pp(`image-pair`,e),old:new Pp(`old`,e),new:new Pp(`new`,e)}}function Ip(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Ip.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Vp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=zp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),m(this._fragmentFiber.child,!1,Lp,e,s,r)}this._eventListeners=a}};function Lp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Ip.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Vp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=zp(i.optionsOrUseCapture),m(this._fragmentFiber.child,!1,Rp,e,n,i),r.splice(t,1),a!==null&&a()}};function Rp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function zp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Bp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Vp(e,t,n,r){if(e.length===0)return-1;r=Bp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Bp(a.optionsOrUseCapture)===r)return i}return-1}Ip.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,zp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,zp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Ip.prototype.focus=function(e){m(this._fragmentFiber.child,!0,Hp,e,void 0,void 0)};function Hp(e,t){return e.tag!==6&&(e=b(e),mm(e,t))}Ip.prototype.focusLast=function(e){var t=[];m(this._fragmentFiber.child,!0,Up,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Hp(t[n],e);n--);};function Up(e,t){return t.push(e),!1}Ip.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=up(e).activeElement,e!==null&&m(this._fragmentFiber.child,!1,Wp,e,void 0,void 0))};function Wp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Ip.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),m(this._fragmentFiber.child,!1,Gp,e,void 0,void 0)};function Gp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Ip.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),m(this._fragmentFiber.child,!1,Kp,e,void 0,void 0);for(var n=t=0;n<qp.length;n++){var r=qp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):qp[t++]=r}qp.length=t}};function Kp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var qp=[],Jp=!1;function Yp(e,t,n){qp.push({fragmentInstance:e,observer:t,instance:n}),Jp||(Jp=!0,hm(function(){Jp=!1;var e=qp;qp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Ip.prototype.getClientRects=function(){var e=[];return m(this._fragmentFiber.child,!1,Xp,e,void 0,void 0),e};function Xp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Ip.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Ip.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];m(this._fragmentFiber.child,!1,Up,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Zp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Zp(e,t,n,r,i){var a=bt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(m(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(m(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function Qp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Ip.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];m(this._fragmentFiber.child,!1,Up,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),Qp(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=b(a),Qp(a,n)):b(a).scrollIntoView(e),r+=n?-1:1}};function $p(e,t){return e=b(e),em(e,t),!1}function em(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,zp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<qp.length;i++){var a=qp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(qp[r++]=a)}qp.length=r,n.observe(e)}),em(e,t))}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,zp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Yp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function rm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:rm(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function im(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=um(e.nextSibling),e===null)break}return null}function am(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=um(e.nextSibling),e===null))return null;return e}function om(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=um(e.nextSibling),e===null))return null;return e}function sm(e){return e.data===`$?`||e.data===`$~`}function cm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function um(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var dm=null;function fm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return um(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function mm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function hm(e){bp(function(){bp(function(t){return e(t)})})}function gm(e,t,n){switch(t=up(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _m(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&tp(e,t,r,null,ip,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===an&&(e.onclick=null),yt(e)}function vm(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var ym=new Map,bm=new Set;function xm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Sm=V.d;V.d={f:Cm,r:wm,D:Dm,C:Om,L:km,m:Am,X:Mm,S:jm,M:Nm};function Cm(){var e=Sm.f(),t=Ld();return e||t}function wm(e){var t=Q(e);t!==null&&t.tag===5&&t.type===`form`?qs(t):Sm.r(e)}var Tm=typeof document>`u`?null:document;function Em(e,t,n){var r=Tm;if(r&&typeof t==`string`&&t){var i=Ut(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),bm.has(i)||(bm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),rp(t,`link`,e),$(t),r.head.appendChild(t)))}}function Dm(e){Sm.D(e),Em(`dns-prefetch`,e,null)}function Om(e,t){Sm.C(e,t),Em(`preconnect`,e,t)}function km(e,t,n){Sm.L(e,t,n);var r=Tm;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ut(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ut(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ut(n.imageSizes)+`"]`)):i+=`[href="`+Ut(e)+`"]`;var a=i;switch(t){case`style`:a=Fm(e);break;case`script`:a=zm(e)}if(!(ym.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),ym.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Im(a))||t===`script`&&r.querySelector(Bm(a))))){var o=r.createElement(`link`);rp(o,`link`,e),t===`style`&&(o[Z]=!0,o.onload=o.onerror=function(){Ct(o)}),$(o),r.head.appendChild(o)}}}function Am(e,t){Sm.m(e,t);var n=Tm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ut(r)+`"][href="`+Ut(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=zm(e)}if(!ym.has(a)&&(e=D({rel:`modulepreload`,href:e},t),ym.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Bm(a)))return}r=n.createElement(`link`),rp(r,`link`,e),$(r),n.head.appendChild(r)}}}function jm(e,t,n){Sm.S(e,t,n);var r=Tm;if(r&&e){var i=St(r).hoistableStyles,a=Fm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Im(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=ym.get(a))&&Um(e,n);var c=o=r.createElement(`link`);$(c),rp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Hm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Mm(e,t){Sm.X(e,t);var n=Tm;if(n&&e){var r=St(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),$(a),rp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t){Sm.M(e,t);var n=Tm;if(n&&e){var r=St(n).hoistableScripts,i=zm(e),a=r.get(i);a||(a=n.querySelector(Bm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=ym.get(i))&&Wm(e,t),a=n.createElement(`script`),$(a),rp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t,n,r){var a=(a=ve.current)?xm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Fm(n.href),t=St(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Fm(n.href);var o=St(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Im(e)))?o._p||(s.instance=o,s.state.loading=5):(o=ym.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},ym.set(e,o)),Rm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=zm(n),t=St(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Fm(e){return`href="`+Ut(e)+`"`}function Im(e){return`link[rel="stylesheet"][`+e+`]`}function Lm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Rm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Z]){r.loading=1;return}}else t=e.createElement(`link`),t[Z]=!0,t.onload=t.onerror=Ct.bind(null,t),rp(t,`link`,n),$(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function zm(e){return`[src="`+Ut(e)+`"]`}function Bm(e){return`script[async]`+e}function Vm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ut(n.href)+`"]`);if(r)return t.instance=r,$(r),r;var a=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),$(r),rp(r,`style`,a),Hm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Fm(n.href);var o=e.querySelector(Im(a));if(o)return t.state.loading|=4,t.instance=o,$(o),o;r=Lm(n),(a=ym.get(a))&&Um(r,a),o=(e.ownerDocument||e).createElement(`link`),$(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),rp(o,`link`,r),t.state.loading|=4,Hm(o,n.precedence,e),t.instance=o;case`script`:return o=zm(n.src),(a=e.querySelector(Bm(o)))?(t.instance=a,$(a),a):(r=n,(a=ym.get(o))&&(r=D({},n),Wm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),$(a),rp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Hm(r,n.precedence,e));return t.instance}function Hm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Gm=null;function Km(e,t,n){if(Gm===null){var r=new Map,i=Gm=new Map;i.set(n,r)}else i=Gm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function qm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Jm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Ym(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Xm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Zm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Qm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Zm(t),e.suspenseyImages.push(t)),e=ih.bind(e),t.decode().then(e,e))}function $m(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Fm(r.href),a=t.querySelector(Im(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,$(a);return}a=t.ownerDocument||t,r=Lm(r),(i=ym.get(i))&&Um(r,i),a=a.createElement(`link`),$(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),rp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var eh=0;function th(e,t){return e.stylesheets&&e.count===0&&oh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&eh===0&&(eh=62500*sp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>eh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function nh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)oh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function rh(){this.count--,nh(this)}function ih(){this.imgCount--,nh(this)}var ah=null;function oh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ah=new Map,t.forEach(sh,e),ah=null,rh.call(e))}function sh(e,t){if(!(t.state.loading&4)){var n=ah.get(e);if(n)var r=n.get(null);else{n=new Map,ah.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var ch={$$typeof:P,Provider:null,Consumer:null,_currentValue:fe,_currentValue2:fe,_threadCount:0};function lh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=tt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tt(0),this.hiddenUpdates=tt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function uh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new lh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=yi(3,null,null,t),e.current=a,a.stateNode=e,t=ba(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},no(a),e}function dh(e){return e?(e=_i,e):_i}function fh(e,t,n,r,i,a){i=dh(i),r.context===null?r.context=i:r.pendingContext=i,r=io(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=ao(e,r,t),n!==null&&(Md(n,e,t),oo(n,e,t))}function ph(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mh(e,t){ph(e,t),(e=e.alternate)&&ph(e,t)}function hh(e){if(e.tag===13||e.tag===31){var t=mi(e,67108864);t!==null&&Md(t,e,67108864),mh(e,67108864)}}function gh(e){if(e.tag===13||e.tag===31){var t=kd();t=ot(t);var n=mi(e,t);n!==null&&Md(n,e,t),mh(e,t)}}var _h=!0;function vh(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=2,bh(e,t,n,r)}finally{V.p=a,B.T=i}}function yh(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=8,bh(e,t,n,r)}finally{V.p=a,B.T=i}}function bh(e,t,n,r){if(_h){var i=xh(r);if(i===null)Kf(e,t,r,Sh,n),Nh(e,r);else if(Fh(i,e,t,n,r))r.stopPropagation();else if(Nh(e,r),t&4&&-1<Mh.indexOf(e)){for(;i!==null;){var a=Q(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Qe(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-qe(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(qu&6)&&(md=Ie()+500,Ef(0,!1))}}break;case 31:case 13:s=mi(a,2),s!==null&&Md(s,a,2),Ld(),mh(a,2)}if(a=xh(r),a===null&&Kf(e,t,r,Sh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Kf(e,t,r,null,n)}}function xh(e){return e=sn(e),Ch(e)}var Sh=null;function Ch(e){if(Sh=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Sh=e,null}function wh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Le()){case Re:return 2;case ze:return 8;case Be:case Ve:return 32;case He:return 268435456;default:return 32}default:return 32}}var Th=!1,Eh=null,Dh=null,Oh=null,kh=new Map,Ah=new Map,jh=[],Mh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Nh(e,t){switch(e){case`focusin`:case`focusout`:Eh=null;break;case`dragenter`:case`dragleave`:Dh=null;break;case`mouseover`:case`mouseout`:Oh=null;break;case`pointerover`:case`pointerout`:kh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Ah.delete(t.pointerId)}}function Ph(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Q(t),t!==null&&hh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Fh(e,t,n,r,i){switch(t){case`focusin`:return Eh=Ph(Eh,e,t,n,r,i),!0;case`dragenter`:return Dh=Ph(Dh,e,t,n,r,i),!0;case`mouseover`:return Oh=Ph(Oh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return kh.set(a,Ph(kh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Ah.set(a,Ph(Ah.get(a)||null,e,t,n,r,i)),!0}return!1}function Ih(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){gh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){gh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);on=r,n.target.dispatchEvent(r),on=null}else return t=Q(n),t!==null&&hh(t),e.blockedOn=n,!1;t.shift()}return!0}function Rh(e,t,n){Lh(e)&&n.delete(t)}function zh(){Th=!1,Eh!==null&&Lh(Eh)&&(Eh=null),Dh!==null&&Lh(Dh)&&(Dh=null),Oh!==null&&Lh(Oh)&&(Oh=null),kh.forEach(Rh),Ah.forEach(Rh)}function Bh(e,n){e.blockedOn===n&&(e.blockedOn=null,Th||(Th=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zh)))}var Vh=null;function Hh(e){Vh!==e&&(Vh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Vh===e&&(Vh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Ch(r||n)===null)continue;break}var a=Q(n);a!==null&&(e.splice(t,3),t-=3,Gs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Uh(e){function t(t){return Bh(t,e)}Eh!==null&&Bh(Eh,e),Dh!==null&&Bh(Dh,e),Oh!==null&&Bh(Oh,e),kh.forEach(t),Ah.forEach(t);for(var n=0;n<jh.length;n++){var r=jh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<jh.length&&(n=jh[0],n.blockedOn===null);)Ih(n),n.blockedOn===null&&jh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Hh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(Ch(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Hh(n)}}}function Wh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Gh(e){this._internalRoot=e}Kh.prototype.render=Gh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;fh(n,kd(),e,t,null,null)},Kh.prototype.unmount=Gh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fh(e.current,2,null,e,null,null),Ld(),t[pt]=null}};function Kh(e){this._internalRoot=e}Kh.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jh.length&&t!==0&&t<jh[n].priority;n++);jh.splice(n,0,e),n===0&&Ih(e)}};var qh=n.version;if(qh!==`19.3.1`)throw Error(i(527,qh,`19.3.1`));V.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Jh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:B,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Yh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yh.isDisabled&&Yh.supportsFiber)try{Ge=Yh.inject(Jh),W=Yh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=mc,s=hc,c=gc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=uh(e,1,!1,null,null,n,r,null,o,s,c,Wh),e[pt]=t.current,Wf(e),new Gh(t)}})),_=o(((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=g()})),v=l(d(),1),y=_(),b={"agents.addJournal":[`POST`,`/api/agents/:slug/journal`],"agents.adoptRoutine":[`POST`,`/api/agents/:slug/routines/:id/adopt`],"agents.archive":[`POST`,`/api/agents/:slug/archive`],"agents.create":[`POST`,`/api/agents`],"agents.delete":[`DELETE`,`/api/agents/:slug`],"agents.deleteRoutine":[`DELETE`,`/api/agents/:slug/routines/:id`],"agents.deleteSkill":[`DELETE`,`/api/agents/:slug/skills/:name`],"agents.get":[`GET`,`/api/agents/:slug`],"agents.journal":[`GET`,`/api/agents/:slug/journal`],"agents.list":[`GET`,`/api/agents`],"agents.routines":[`GET`,`/api/agents/:slug/routines`],"agents.runRoutine":[`POST`,`/api/agents/:slug/routines/:id/run`],"agents.save":[`PUT`,`/api/agents/:slug`],"agents.saveRoutine":[`POST`,`/api/agents/:slug/routines`],"agents.saveSkill":[`POST`,`/api/agents/:slug/skills`],"agents.sessions":[`GET`,`/api/agent-sessions`],"agents.skill":[`GET`,`/api/agents/:slug/skills/:name`],"agents.skills":[`GET`,`/api/agents/:slug/skills`],"agents.status":[`GET`,`/api/agent-status`],"attention.list":[`GET`,`/api/attention`],"boards.create":[`POST`,`/api/boards`],"boards.delete":[`DELETE`,`/api/boards/:board`],"boards.ensure":[`POST`,`/api/boards/default`],"boards.get":[`GET`,`/api/boards/:board`],"boards.list":[`GET`,`/api/boards`],"boards.save":[`PUT`,`/api/boards/:board`],"channels.create":[`POST`,`/api/channels`],"channels.delete":[`DELETE`,`/api/channels/:slug`],"channels.fromChat":[`POST`,`/api/channels/from-chat`],"channels.get":[`GET`,`/api/channels/:slug`],"channels.list":[`GET`,`/api/channels`],"channels.save":[`PUT`,`/api/channels/:slug`],"chats.attach":[`POST`,`/api/chats/:id/attachments`,`upload`],"chats.attachment":[`GET`,`/api/chats/:id/attachments/:name`,`raw`],"chats.cancel":[`POST`,`/api/chats/:id/cancel`],"chats.config":[`POST`,`/api/chats/:id/config`],"chats.create":[`POST`,`/api/chats`],"chats.delete":[`DELETE`,`/api/chats/:id`],"chats.elicitation":[`POST`,`/api/chats/:id/elicitation`],"chats.events":[`GET`,`/api/chats/:id/events`,`raw`],"chats.fork":[`POST`,`/api/chats/:id/fork`],"chats.get":[`GET`,`/api/chats/:id`],"chats.list":[`GET`,`/api/chats`],"chats.message":[`POST`,`/api/chats/:id/message`],"chats.permission":[`POST`,`/api/chats/:id/permission`],"chats.rename":[`PATCH`,`/api/chats/:id`],"chats.resetSession":[`POST`,`/api/chats/:id/reset-session`],"chats.setProject":[`POST`,`/api/chats/:id/project`],"chats.setVibeable":[`POST`,`/api/chats/:id/vibeable`],"chats.steer":[`POST`,`/api/chats/:id/steer`],"chats.stopTask":[`POST`,`/api/chats/:id/task-stop`],"cloud.invite":[`POST`,`/api/cloud/invite`],"cloud.set":[`POST`,`/api/cloud`],"cloud.status":[`GET`,`/api/cloud`],"cloud.sync":[`POST`,`/api/cloud/sync`],"cloud.unlink":[`POST`,`/api/cloud/unlink`],"contacts.create":[`POST`,`/api/contacts`],"contacts.delete":[`DELETE`,`/api/contacts/:slug`],"contacts.get":[`GET`,`/api/contacts/:slug`],"contacts.list":[`GET`,`/api/contacts`],"contacts.save":[`PUT`,`/api/contacts/:slug`],"devices.code":[`POST`,`/api/devices/code`],"devices.dropPush":[`DELETE`,`/api/devices/push`],"devices.list":[`GET`,`/api/devices`],"devices.pair":[`POST`,`/api/pair`],"devices.relay":[`GET`,`/api/devices/relay`],"devices.revoke":[`DELETE`,`/api/devices/:id`],"devices.self":[`GET`,`/api/devices/self`],"devices.setPush":[`POST`,`/api/devices/push`],"devices.setRelay":[`POST`,`/api/devices/relay`],"events.create":[`POST`,`/api/events`],"events.delete":[`DELETE`,`/api/events/:slug`],"events.get":[`GET`,`/api/events/:slug`],"events.list":[`GET`,`/api/events`],"events.save":[`PUT`,`/api/events/:slug`],"files.delete":[`DELETE`,`/api/files`],"files.list":[`GET`,`/api/files/list`],"files.mkdir":[`POST`,`/api/files/folder`],"files.move":[`POST`,`/api/files/move`],"files.raw":[`GET`,`/api/files/raw`,`raw`],"files.recent":[`GET`,`/api/files/recent`],"files.scopes":[`GET`,`/api/files`],"files.upload":[`POST`,`/api/files/upload`,`upload`],"git.commit":[`POST`,`/api/git/commit`],"git.diff":[`GET`,`/api/git/diff`],"git.fetch":[`POST`,`/api/git/fetch`],"git.pull":[`POST`,`/api/git/pull`],"git.push":[`POST`,`/api/git/push`],"git.status":[`GET`,`/api/git`],"hub.close":[`POST`,`/api/hub/close`],"hub.list":[`GET`,`/api/hub`],"hub.open":[`POST`,`/api/hub/open`],"identity.get":[`GET`,`/api/identity`],"knowledge.concept":[`GET`,`/api/knowledge/:bundle/concept`],"knowledge.create":[`POST`,`/api/knowledge`],"knowledge.delete":[`DELETE`,`/api/knowledge/:bundle`],"knowledge.get":[`GET`,`/api/knowledge/:bundle`],"knowledge.list":[`GET`,`/api/knowledge`],"knowledge.putConcept":[`POST`,`/api/knowledge/:bundle/concept`],"knowledge.verify":[`POST`,`/api/knowledge/:bundle/verify`],"meta.get":[`GET`,`/api/meta`],"notifications.clear":[`DELETE`,`/api/notifications`],"notifications.diagnose":[`POST`,`/api/notifications/:id/diagnose`],"notifications.list":[`GET`,`/api/notifications`],"notifications.read":[`POST`,`/api/notifications/read`],"places.create":[`POST`,`/api/places`],"places.delete":[`DELETE`,`/api/places/:slug`],"places.get":[`GET`,`/api/places/:slug`],"places.list":[`GET`,`/api/places`],"places.save":[`PUT`,`/api/places/:slug`],"presentations.comment":[`POST`,`/api/presentations/:name/comments`],"presentations.commentDelete":[`DELETE`,`/api/presentations/:name/comments/:id`],"presentations.commentSave":[`PUT`,`/api/presentations/:name/comments/:id`],"presentations.create":[`POST`,`/api/presentations`],"presentations.delete":[`DELETE`,`/api/presentations/:name`],"presentations.export":[`GET`,`/api/presentations/:name/export`,`raw`],"presentations.file":[`GET`,`/api/presentations/:name/file`,`raw`],"presentations.get":[`GET`,`/api/presentations/:name`],"presentations.history":[`GET`,`/api/presentations/:name/history`],"presentations.links":[`GET`,`/api/presentations/:name/links`],"presentations.list":[`GET`,`/api/presentations`],"presentations.presence":[`POST`,`/api/presentations/:name/presence`],"presentations.save":[`PUT`,`/api/presentations/:name`],"presentations.slide":[`GET`,`/api/presentations/:name/slides/:n`,`raw`],"presentations.templateFile":[`GET`,`/api/presentations/templates/:slug/file`,`raw`],"presentations.templates":[`GET`,`/api/presentations/templates`],"presentations.upload":[`POST`,`/api/presentations/:name/assets`,`upload`],"presentations.version":[`GET`,`/api/presentations/:name/history/:id`],"projects.create":[`POST`,`/api/projects`],"projects.delete":[`DELETE`,`/api/projects/:slug`],"projects.get":[`GET`,`/api/projects/:slug`],"projects.link":[`POST`,`/api/projects/:slug/links`],"projects.list":[`GET`,`/api/projects`],"projects.log":[`POST`,`/api/projects/:slug/log`],"projects.save":[`PUT`,`/api/projects/:slug`],"projects.saveLayout":[`PUT`,`/api/projects`],"protocol.get":[`GET`,`/api/protocol`],"refs.resolve":[`POST`,`/api/refs/resolve`],"repos.add":[`POST`,`/api/repos`],"repos.commit":[`GET`,`/api/repos/:slug/commits/:hash`],"repos.diff":[`GET`,`/api/repos/:slug/diff`],"repos.get":[`GET`,`/api/repos/:slug`],"repos.list":[`GET`,`/api/repos`],"repos.remove":[`DELETE`,`/api/repos/:slug`],"repos.update":[`POST`,`/api/repos/:slug/update`],"routines.adopt":[`POST`,`/api/routines/adopt`],"routines.adoptOne":[`POST`,`/api/routines/:id/adopt`],"routines.delete":[`DELETE`,`/api/routines/:id`],"routines.list":[`GET`,`/api/routines`],"routines.run":[`POST`,`/api/routines/:id/run`],"routines.save":[`POST`,`/api/routines`],"runs.decide":[`POST`,`/api/runs/:id/decision`],"runs.delete":[`DELETE`,`/api/runs/:id`],"runs.file":[`GET`,`/api/runs/:id/file`,`raw`],"runs.fileText":[`GET`,`/api/runs/:id/text`],"runs.get":[`GET`,`/api/runs/:id`],"runs.list":[`GET`,`/api/runs`],"runs.stop":[`POST`,`/api/runs/:id/stop`],"search.agents":[`GET`,`/api/search/agents`],"server.restart":[`POST`,`/api/restart`],"settings.get":[`GET`,`/api/settings`],"settings.save":[`PUT`,`/api/settings`],"skills.get":[`GET`,`/api/skills/:name`],"skills.list":[`GET`,`/api/skills`],"tasks.assign":[`POST`,`/api/boards/:board/tasks/:task/assign`],"tasks.create":[`POST`,`/api/boards/:board/tasks`],"tasks.delete":[`DELETE`,`/api/boards/:board/tasks/:task`],"tasks.get":[`GET`,`/api/boards/:board/tasks/:task`],"tasks.list":[`GET`,`/api/tasks`],"tasks.log":[`POST`,`/api/boards/:board/tasks/:task/log`],"tasks.move":[`POST`,`/api/boards/:board/tasks/:task/move`],"tasks.pick":[`POST`,`/api/boards/:board/pick`],"tasks.save":[`PUT`,`/api/boards/:board/tasks/:task`],"temp.clean":[`DELETE`,`/api/temp`],"temp.list":[`GET`,`/api/temp`],"trash.empty":[`DELETE`,`/api/trash`],"trash.list":[`GET`,`/api/trash`],"trash.purge":[`POST`,`/api/trash/purge`],"trash.restore":[`POST`,`/api/trash/restore`],"update.check":[`GET`,`/api/update-check`],"update.start":[`POST`,`/api/update`],"update.status":[`GET`,`/api/update`],"vibeables.create":[`POST`,`/api/vibeables`],"vibeables.delete":[`DELETE`,`/api/vibeables/:slug`],"vibeables.devStart":[`POST`,`/api/vibeables/:slug/dev/start`],"vibeables.devStop":[`POST`,`/api/vibeables/:slug/dev/stop`],"vibeables.events":[`GET`,`/api/vibeables/:slug/events`,`raw`],"vibeables.get":[`GET`,`/api/vibeables/:slug`],"vibeables.list":[`GET`,`/api/vibeables`],"workflows.delete":[`DELETE`,`/api/workflows/:slug`],"workflows.get":[`GET`,`/api/workflows/:slug`],"workflows.list":[`GET`,`/api/workflows`],"workflows.run":[`POST`,`/api/workflows/:slug/run`],"workflows.runner":[`GET`,`/api/workflows/:slug/run`],"workspaces.forget":[`POST`,`/api/workspaces/forget`],"workspaces.list":[`GET`,`/api/workspaces`],"workspaces.start":[`POST`,`/api/workspaces/start`],"workspaces.stop":[`POST`,`/api/workspaces/stop`]},x=1e4;function S(e){let t=e.WebSocket??(typeof WebSocket>`u`?void 0:WebSocket),n=e.EventSource??(typeof EventSource>`u`?void 0:EventSource),{client:r}=e,i=new Map,a=new Map,o=null,s=!1,c=!1,l=500,u,d=0,f=()=>`${(/^https?:/.test(r.baseUrl)?r.baseUrl:(typeof location>`u`?``:location.origin)+r.baseUrl).replace(/^http/,`ws`).replace(/\/+$/,``)}/api/ws${r.token?`?token=${encodeURIComponent(r.token)}`:``}`,p=e=>{s&&o?.send(JSON.stringify(e))},m=e=>{let t=i.get(e);t&&!s&&(clearTimeout(t.timer),r.request(t.name,t.input).then(n=>n.ok&&i.get(e)===t&&!s&&t.onData(n.data)).catch(()=>{}).finally(()=>{i.get(e)===t&&!s&&(t.timer=setTimeout(()=>m(e),t.interval))}))},h=e=>{let t=a.get(e);if(!t||s||t.source||!n)return;let[i,...o]=t.topic.split(`.`),c=o.join(`.`),l=i===`chat`?r.url(`chats.events`,{id:c,query:{after:t.after}}):i===`vibeable`?r.url(`vibeables.events`,{slug:c}):``;l&&(t.source=new n(l),t.source.onmessage=t=>g(e,JSON.parse(t.data)))},g=(e,t)=>{let n=a.get(e);if(!n)return;let r=t?.seq;if(typeof r==`number`){if(r<=n.after)return;n.after=r}n.onEvent(t)},_=r.onChange(()=>{if(!s)for(let e of i.keys())m(e)}),v=()=>{for(let[e,t]of i)clearTimeout(t.timer),p({watch:e,name:t.name,input:t.input,interval:t.interval});for(let[e,t]of a)t.source?.close(),t.source=void 0,p({sub:e,topic:t.topic,after:t.after})},y=()=>{for(let e of i.keys())m(e);for(let e of a.keys())h(e)},b=()=>{if(c||o||!t)return;let e;try{e=new t(f())}catch{return y()}o=e,e.onopen=()=>{s=!0,l=500,v()},e.onmessage=e=>{let t;try{t=JSON.parse(String(e.data))}catch{return}t.watch&&`data`in t?i.get(t.watch)?.onData(t.data):t.event&&g(t.event,t.data)},e.onclose=()=>{o=null,s=!1,c||(y(),u=setTimeout(b,l),l=Math.min(x,l*2))}};return{get connected(){return s},watch(e,t,n,r){let a=`w${++d}`;return i.set(a,{name:e,input:t??{},interval:n.interval??6e3,onData:r}),s?p({watch:a,name:e,input:t??{},interval:n.interval??6e3}):(m(a),b()),()=>{clearTimeout(i.get(a)?.timer),i.delete(a),p({unwatch:a})}},subscribe(e,t,n){let r=`s${++d}`;return a.set(r,{topic:e,after:t.after??0,onEvent:n}),s?p({sub:r,topic:e,after:t.after??0}):(h(r),b()),()=>{a.get(r)?.source?.close(),a.delete(r),p({unsub:r})}},close(){c=!0,_(),clearTimeout(u),o?.close();for(let e of i.values())clearTimeout(e.timer);for(let e of a.values())e.source?.close();i.clear(),a.clear()}}}var C=class extends Error{status;body;route;constructor(e,t,n){super(w(t)??`${n}: HTTP ${e}`),this.status=e,this.body=t,this.route=n}};function w(e){let t=e&&typeof e==`object`&&`error`in e?e.error:void 0;return typeof t==`string`&&t?t:void 0}function T(e={}){let t=(e.baseUrl??``).replace(/\/+$/,``)+(e.workspace?`/w/${encodeURIComponent(e.workspace)}`:``),n=e.fetch??((...e)=>fetch(...e)),r=new Set,i=(e,n={})=>{let[,r]=b[e],i=r.replace(/:([A-Za-z]+)/g,(t,r)=>{let i=n[r];if(i==null||i===``)throw Error(`${e}: missing path parameter ${r}`);return encodeURIComponent(String(i))}),a=new URLSearchParams;for(let[e,t]of Object.entries(n.query??{}))t!=null&&t!==!1&&a.set(e,t===!0?`1`:String(t));let o=a.toString();return`${t}${i}${o?`?${o}`:``}`},a=async(t,a={})=>{let[o]=b[t],{body:s,headers:c={},signal:l,keepalive:u}=a,d=s instanceof Blob||s instanceof ArrayBuffer||ArrayBuffer.isView(s),f=await n(i(t,a),{method:o,cache:`no-store`,signal:l,keepalive:u,headers:{...s!==void 0&&!d?{"content-type":`application/json`}:{},...e.token?{authorization:`Bearer ${e.token}`}:{},...c},body:s===void 0?void 0:d?s:JSON.stringify(s)}),p=await f.text(),m=p;try{m=p?JSON.parse(p):void 0}catch{}if(f.ok&&o!==`GET`)for(let e of r)e();return f.status===401&&m?.pair===!0&&e.onUnauthorized?.(),f.ok?{ok:!0,status:f.status,data:m}:{ok:!1,status:f.status,data:m,error:w(m)}};return{token:e.token,baseUrl:t,onChange(e){return r.add(e),()=>r.delete(e)},url:((e,t)=>i(e,t)),request:((e,t)=>a(e,t)),call:(async(e,t)=>{let n=await a(e,t);if(!n.ok)throw new C(n.status,n.data,e);return n.data})}}var E=!1,D=new Set;function O(){return(0,v.useSyncExternalStore)(e=>(D.add(e),()=>D.delete(e)),()=>E)}var k=/^\/w\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\//.exec(location.pathname)?.[1],A=T({workspace:k,onUnauthorized:()=>{if(!E){E=!0;for(let e of D)e()}}}),ee=e=>e.startsWith(`/`)?A.baseUrl+e:e,j=S({client:A});function M(e){return e.ok?``:e.error??`HTTP ${e.status}`}function N(e,t,n={}){let[r,i]=(0,v.useState)(null),a=t===null?``:`${e} ${JSON.stringify(t)}`,o=(0,v.useRef)(t);o.current=t;let{fast:s=!1,interval:c=6e3,refresh:l}=n;return(0,v.useEffect)(()=>{if(a)return j.watch(e,o.current??void 0,{interval:s?1500:c},i)},[a,s,c,l]),r}function P(...e){return e.filter(Boolean).join(` `)}var F=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),te=o(((e,t)=>{t.exports=F()})),I=te();function R({name:e,fill:t,className:n}){return(0,I.jsx)(`span`,{className:`ms material-symbols-rounded${t?` ms-fill`:``}${e===`progress_activity`?` ms-spin`:``}${n?` ${n}`:``}`,"aria-hidden":!0,children:e})}function z(){let[e,t]=(0,v.useState)(()=>window.location.hash.slice(1)||`/`);return(0,v.useEffect)(()=>{let e=()=>t(window.location.hash.slice(1)||`/`);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),e}var ne=`kraftwerk inspector`,re=``,ie=0;function ae(){let e=re?`${re} — ${ne}`:ne;document.title=ie>0?`(${ie}) ${e}`:e}function oe(e){e!==ie&&(ie=e,ae())}function se(e){ne=e,ae()}function ce(e){re=e,ae()}var le=new Set([`agents`,`team`,`chats`,`projects`,`channels`]),ue=e=>{let t=e.split(`?`)[0].split(`/`).filter(Boolean);return t[0]===`projects`&&t[2]===`boards`},de=e=>{let t=e.split(`?`)[0].split(`/`).filter(Boolean);return t[0]===`projects`&&t[2]===`presentations`},B=e=>le.has(e.split(`?`)[0].split(`/`).filter(Boolean)[0]??``)&&!ue(e)&&!de(e)?`chat`:`side`,V=`kw-column-path`;function fe(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return!n||n===`chats`?!1:n===`new`?[`projects`,`agents`,`team`,`channels`].includes(t[0])&&!t[2]:t[0]===`projects`?t[2]===`info`:t[0]===`agents`||t[0]===`team`?t[2]===`info`||t[2]===`edit`:t[0]===`channels`&&t[2]===`edit`}function H(e,t){let n=window.location.hash.slice(1)||`/`;t?.replace&&(B(e)!==B(n)||fe(n)&&!fe(e)&&B(e)===`chat`)?window.dispatchEvent(new CustomEvent(V,{detail:e})):t?.replace?window.location.replace(`#${e}`):window.location.hash=e}function pe(e){if(!e.here||!e.slug)return e.url;let{protocol:t,hostname:n,port:r}=window.location;return k?`/w/${e.slug}/`:n.endsWith(`.localhost`)?`${t}//${e.slug}.localhost${r?`:${r}`:``}/`:n===`localhost`||n===`127.0.0.1`||n===`[::1]`?e.url:`/w/${e.slug}/`}async function me(e){let t=await A.request(`workspaces.start`,{body:{root:e}});if(!t.ok)throw Error(M(t));let n=t.data;if(n.live&&n.url)return pe({url:n.url,slug:n.slug,here:n.here});for(let t=0;t<12;t++){await new Promise(e=>setTimeout(e,1e3));try{let t=(await A.call(`meta.get`)).switcher.find(t=>t.root===e&&t.live);if(t)return pe(t)}catch{}}throw Error(`started, but the UI did not answer yet — see ~/.kraftwerk/logs`)}var he=(0,v.createContext)(null);function U({href:e,onClick:t,...n}){let r=(0,v.useContext)(he);return(0,I.jsx)(`a`,{href:`#${e}`,onClick:n=>{t?.(n),!n.defaultPrevented&&r&&(n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||r(e)&&n.preventDefault())},...n})}var ge=`kw-expert`,_e=(()=>{try{return localStorage.getItem(ge)!==`off`}catch{return!0}})(),ve=new Set;document.documentElement.dataset.expert=_e?`on`:`off`;function ye(e){_e=e,document.documentElement.dataset.expert=e?`on`:`off`;try{localStorage.setItem(ge,e?`on`:`off`)}catch{}ve.forEach(e=>e())}function be(){return(0,v.useSyncExternalStore)(e=>(ve.add(e),()=>ve.delete(e)),()=>_e)}var xe=[`git`,`repos`,`vibeables`,`projects`,`contacts`,`places`,`events`,`boards`,`presentations`],Se={git:!1,repos:!1,vibeables:!1,projects:!1,contacts:!1,places:!1,events:!1,boards:!1,presentations:!1},Ce=new Set;function we(e){xe.every(t=>e[t]===Se[t])||(Se=e,Ce.forEach(e=>e()))}function Te(){return(0,v.useSyncExternalStore)(e=>(Ce.add(e),()=>Ce.delete(e)),()=>Se)}function Ee(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)%360}function De(e,t){return e||`hsl(${Ee(t)} 58% 46%)`}function Oe(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(t){let e=t[1].length===3?t[1].split(``).map(e=>e+e).join(``):t[1];return[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}let n=/^hsl\(\s*([\d.]+)[ ,]+([\d.]+)%[ ,]+([\d.]+)%/i.exec(e.trim());if(!n)return null;let r=n[1]/360,i=n[2]/100,a=n[3]/100,o=a<.5?a*(1+i):a+i-a*i,s=2*a-o,c=e=>(e=(e+1)%1,e<1/6?s+(o-s)*6*e:e<1/2?o:e<2/3?s+(o-s)*(2/3-e)*6:s);return[c(r+1/3),c(r),c(r-1/3)].map(e=>Math.round(e*255))}var ke=(e,t,n)=>e.map((e,r)=>Math.round(e+(t[r]-e)*n)),Ae=e=>`#`+e.map(e=>e.toString(16).padStart(2,`0`)).join(``);function je([e,t,n]){let r=e=>(e/=255)<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Me(e,t){let n=je(e),r=je(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Ne(e,t,n,r){let i=e;for(let a=0;a<=1&&Me(i,t)<n;a+=.04)i=ke(e,r,a);return i}var Pe=[255,255,255],Fe=[0,0,0],Ie=[38,37,35];function Le(e){let t=Oe(e);if(!t)return null;let n=Ne(t,Pe,4.5,Fe),r=ke(t,Pe,.84),i=ke(t,Pe,.88),a=Ne(ke(t,Pe,.4),Ie,4.5,Pe),o=ke(t,Fe,.42),s=ke(t,Fe,.6);return{"--wsp-l-primary":Ae(n),"--wsp-l-on-primary":Ae(Pe),"--wsp-l-primary-container":Ae(r),"--wsp-l-on-primary-container":Ae(Ne(ke(t,Fe,.6),r,4.5,Fe)),"--wsp-l-secondary-container":Ae(i),"--wsp-l-on-secondary-container":Ae(Ne(ke(t,Fe,.65),i,4.5,Fe)),"--wsp-d-primary":Ae(a),"--wsp-d-on-primary":Ae(Ne(ke(t,Fe,.7),a,4.5,Fe)),"--wsp-d-primary-container":Ae(o),"--wsp-d-on-primary-container":Ae(Ne(ke(t,Pe,.8),o,4.5,Pe)),"--wsp-d-secondary-container":Ae(s),"--wsp-d-on-secondary-container":Ae(Ne(ke(t,Pe,.85),s,4.5,Pe))}}function Re(e){let t=e.split(/[^\p{L}\p{N}]+/u).filter(Boolean);return t.length===0?`?`:(t.length>=2?t[0][0]+t[1][0]:t[0].slice(0,2)).toUpperCase()}function ze({icon:e,name:t,color:n,seed:r,ambiguous:i,size:a=`md`,className:o}){let s={"--ws-c":De(n,r)};return(0,I.jsxs)(`span`,{className:P(`relative grid flex-none place-items-center rounded-full leading-none`,`bg-[color-mix(in_srgb,var(--ws-c,var(--text))_22%,var(--surface-2))]`,a===`sm`?`size-8`:`size-10`,e?a===`sm`?`text-[18px]`:`text-[22px]`:P(`font-sans font-medium tracking-[0.15px] text-[var(--ws-c,var(--text))]`,a===`sm`?`text-[13px]`:`text-base`),o),style:s,"aria-hidden":!0,children:[e||Re(t),e&&i&&(0,I.jsx)(`span`,{className:`absolute -right-[3px] -bottom-[3px] grid h-[18px] min-w-[18px] place-items-center rounded-full bg-[var(--ws-c,var(--text))] px-1 font-sans text-[10px] font-medium leading-none tracking-[0.4px] text-white shadow-[0_0_0_2px_var(--surface-1)]`,children:Re(t)})]})}var Be={emoji:`🧭`,name:`Assistant`};function Ve(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m${String(t%60).padStart(2,`0`)}s`}function He(e){return e==null?`—`:`$${e.toFixed(2)}`}function Ue(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function We(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} K`:`${(e/1024/1024).toFixed(1)} M`}function Ge(e){if(!e)return`—`;let t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),i=t.toTimeString().slice(0,5);return r?i:`${t.toISOString().slice(5,10)} ${i}`}function W(e){if(!e)return`—`;let t=Date.now()-Date.parse(e);if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toISOString().slice(5,10)}function Ke({since:e}){let[,t]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),e?(0,I.jsx)(`span`,{className:`tabular-nums`,children:Ve(Date.now()-Date.parse(e))}):null}var qe=[``,`low`,`medium`,`high`,`xhigh`,`max`],Je=`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-control font-medium transition-colors disabled:cursor-default disabled:opacity-45 focus-visible:outline-2 focus-visible:outline-live cursor-pointer no-underline`,Ye={primary:`bg-accent text-on-accent hover:bg-accent-hover`,secondary:`border border-line bg-transparent text-fg hover:bg-surface-2`,quiet:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`,danger:`bg-transparent text-bad hover:bg-bad-soft`},Xe={sm:`h-7 px-2.5 text-sm`,md:`h-9 px-3.5 text-base`};function Ze(e=`secondary`,t=`md`,n){return P(Je,Ye[e],Xe[t],n)}function G({variant:e=`secondary`,size:t=`md`,icon:n,busy:r,children:i,className:a,href:o,...s}){let c=(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(R,{name:r?`progress_activity`:n,className:`ms-sm`}),i]}),l=Ze(e,t,a);return o?(0,I.jsx)(U,{href:o,className:l,title:s.title,"aria-label":s[`aria-label`],onClick:s.onClick,children:c}):(0,I.jsx)(`button`,{type:`button`,className:l,...s,disabled:r||s.disabled,children:c})}function K({icon:e,label:t,variant:n=`quiet`,size:r=`md`,className:i,href:a,...o}){let s=P(`inline-grid shrink-0 place-items-center rounded-control transition-colors cursor-pointer disabled:opacity-45 disabled:cursor-default no-underline`,n===`danger`?`text-bad hover:bg-bad-soft`:`text-fg-2 hover:bg-surface-2 hover:text-fg`,r===`sm`?`size-7`:`size-8`,i);return a?(0,I.jsx)(U,{href:a,className:s,title:t,"aria-label":t,children:(0,I.jsx)(R,{name:e,className:`ms-sm`})}):(0,I.jsx)(`button`,{type:`button`,className:s,title:t,"aria-label":t,...o,children:(0,I.jsx)(R,{name:e,className:`ms-sm`})})}function Qe({n:e,tone:t=`bad`,title:n}){return e?(0,I.jsx)(`span`,{"data-ui":`badge`,className:P(`inline-grid h-[18px] min-w-[18px] shrink-0 place-items-center rounded-full px-1.5 text-2xs font-bold tabular-nums`,t===`bad`?`bg-bad text-on-bad`:`bg-surface-2 text-fg-2`),title:n,"aria-label":n??`${e}`,children:e}):null}function $e({tone:e,title:t}){return(0,I.jsx)(`span`,{"data-ui":`dot`,"data-tone":e,title:t,className:P(`inline-block size-2 shrink-0 rounded-full`,e===`ok`&&`bg-ok`,e===`bad`&&`bg-bad`,e===`ask`&&`bg-ask`,e===`live`&&`bg-live`,e===`working`&&`animate-pulse bg-accent`,e===`idle`&&`border-[1.5px] border-line`)})}function q({children:e,tone:t=`neutral`,title:n,href:r,className:i}){let a=P(`inline-flex h-5 shrink-0 items-center rounded-full px-2 text-2xs font-semibold no-underline`,t===`neutral`&&`bg-surface-2 text-fg-2`,t===`ok`&&`bg-ok-soft text-ok`,t===`bad`&&`bg-bad-soft text-on-bad-soft`,t===`ask`&&`bg-ask-soft text-on-ask-soft`,t===`accent`&&`bg-accent-soft text-on-accent-soft`,r&&`transition-opacity hover:opacity-80`,i);return r?(0,I.jsx)(U,{href:r,title:n,className:a,children:e}):(0,I.jsx)(`span`,{title:n,className:a,children:e})}function et({children:e,className:t,...n}){return(0,I.jsx)(`kbd`,{className:P(`rounded-[5px] border border-line px-[5px] py-[3px] font-mono text-[10.5px] leading-none text-fg-2`,t),...n,children:e})}function J({children:e,className:t}){return(0,I.jsx)(`p`,{className:P(`m-0 text-xs text-fg-2 [&_code]:text-2xs`,t),children:e})}function Y({icon:e,children:t,action:n,className:r}){return(0,I.jsxs)(`div`,{className:P(`flex flex-col items-center gap-2 px-4 py-10 text-center text-sm text-fg-2`,r),children:[e&&(0,I.jsx)(R,{name:e,className:`text-[32px] opacity-70`}),(0,I.jsx)(`div`,{children:t}),n]})}function tt({tone:e=`neutral`,children:t}){return(0,I.jsxs)(`div`,{className:P(`flex items-center gap-1.5 px-1.5 py-1 text-sm`,e===`bad`?`text-bad`:`text-fg-2`),children:[e===`bad`&&(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),t]})}function nt({children:e,className:t}){return(0,I.jsx)(`span`,{className:P(`text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2`,t),children:e})}function rt({title:e,count:t,action:n,size:r=`sm`,children:i,className:a}){return r===`lg`?(0,I.jsxs)(`section`,{className:P(`mt-4 border-t border-line pt-4 first:mt-0 first:border-t-0 first:pt-0`,a),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-1.5`,children:[(0,I.jsx)(`h3`,{className:`m-0 text-[17px] leading-tight font-[750] tracking-[-0.01em] text-fg first-letter:uppercase`,children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`rounded-full bg-surface-2 px-2 py-px text-xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),i]}):(0,I.jsxs)(`section`,{className:P(`mt-3 first:mt-0`,a),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-1 pt-1`,children:[(0,I.jsx)(nt,{children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),i]})}function X({title:e,count:t,actions:n,children:r,className:i}){return(0,I.jsxs)(`section`,{className:P(`overflow-hidden rounded-card border border-line bg-surface`,i),children:[(e||n)&&(0,I.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center gap-2 border-b border-line px-[18px] py-2`,children:[e&&(0,I.jsx)(nt,{className:`whitespace-nowrap text-fg`,children:e}),t!==void 0&&t>0&&(0,I.jsx)(`span`,{className:`text-xs font-bold tabular-nums text-bad`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),n]}),r]})}function it({children:e,size:t=`md`,className:n}){return(0,I.jsx)(`h1`,{className:P(`m-0 font-semibold tracking-[-0.01em] text-fg`,t===`lg`?`text-2xl`:`text-xl`,n),children:e})}function at({title:e,sub:t,actions:n,icon:r}){return(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[typeof r==`string`?(0,I.jsx)(R,{name:r,className:`text-[26px] text-fg-2`}):r,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(it,{children:e}),t&&(0,I.jsx)(`div`,{className:`text-sm text-fg-2`,children:t})]}),(0,I.jsx)(`span`,{className:`flex-1`}),n]})}function ot({children:e,width:t=`wide`,className:n}){return(0,I.jsx)(`div`,{className:P(`mx-auto flex w-full animate-rise flex-col gap-4`,t===`narrow`?`new-chat max-w-[640px]`:`max-w-[960px]`,n),children:e})}function st({children:e}){return(0,I.jsx)(`span`,{className:`grid size-14 flex-none place-items-center rounded-full bg-accent-soft text-[28px] leading-none`,children:e})}function ct({name:e}){return(0,I.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-full bg-accent-soft text-on-accent-soft`,children:(0,I.jsx)(R,{name:e,className:`text-[17px]`})})}function lt({icon:e,title:t,children:n,action:r,className:i,...a}){return(0,I.jsxs)(`div`,{className:P(`flex items-center gap-3.5 px-[18px] py-3`,i),...a,children:[(0,I.jsx)(ct,{name:e}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,I.jsx)(`span`,{className:`flex items-center gap-2 text-[13.5px] font-medium text-fg`,children:t}),n]}),r]})}function ut({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col divide-y divide-line py-1`,t),children:e})}var dt=(0,v.createContext)(!1);function ft({compact:e=!1,children:t}){return(0,I.jsx)(dt.Provider,{value:e,children:(0,I.jsx)(`div`,{className:`py-1 [&>*+*]:border-t [&>*+*]:border-line`,children:t})})}function pt({label:e,dim:t,mono:n,children:r}){let i=(0,v.useContext)(dt);return(0,I.jsxs)(`div`,{className:P(`flex`,i?`items-baseline gap-3 px-3.5 py-1.5`:`flex-col gap-[3px] px-[18px] py-2.5`),children:[(0,I.jsx)(nt,{className:P(i&&`w-[84px] flex-none`),children:e}),(0,I.jsx)(`span`,{className:P(`flex min-w-0 flex-wrap items-center gap-2 break-words`,i?`text-xs`:`text-[12.5px]`,t?`text-fg-2`:`text-fg`,n&&`font-mono break-all`),children:r})]})}function mt({leading:e,title:t,sub:n,subTone:r=`plain`,meta:i,actions:a,href:o,onClick:s,active:c,dim:l,size:u=`md`,className:d,titleExtra:f,label:p,over:m,actionsAlways:h,innerProps:g,titleLines:_=1}){let v=(0,I.jsxs)(I.Fragment,{children:[e!==void 0&&(0,I.jsx)(`span`,{className:`grid w-6 shrink-0 place-items-center text-[15px] text-fg-2`,children:e}),(0,I.jsxs)(`span`,{className:`grid min-w-0 flex-1`,children:[m&&(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-fg-2`,children:m}),(0,I.jsxs)(`span`,{className:P(`flex min-w-0 items-center gap-1.5 text-fg`,m?`font-normal`:`font-semibold`,u===`sm`?`text-sm`:`text-base`),children:[(0,I.jsx)(`span`,{className:P(`min-w-0`,_===2?`line-clamp-2 leading-snug [overflow-wrap:anywhere]`:`truncate`),children:t}),f]}),n&&(0,I.jsx)(`span`,{className:P(`truncate text-xs`,r===`bad`?`text-bad`:r===`accent`?`text-accent`:`text-fg-2`),children:n})]}),i!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:i})]}),y=P(`flex min-w-0 flex-1 items-center gap-2.5 rounded-control text-left no-underline text-inherit`,u===`sm`?`px-2.5 py-1.5`:`px-2.5 py-2`,(o||s)&&`cursor-pointer`,l&&`opacity-55`),b=o?(0,I.jsx)(U,{href:o,onClick:s,className:y,"aria-label":p,"aria-current":c?`page`:void 0,...g,children:v}):s?(0,I.jsx)(`button`,{type:`button`,onClick:s,className:P(y,`border-0 bg-transparent font-[inherit]`),"aria-label":p,...g,children:v}):(0,I.jsx)(`div`,{className:y,children:v});return(0,I.jsxs)(`div`,{className:P(`group/row relative flex items-center rounded-control transition-colors`,c?`bg-surface shadow-[inset_0_0_0_1px_var(--line)]`:(o||s)&&`hover:bg-surface-2`,d),children:[b,a&&(0,I.jsx)(`span`,{className:P(`flex shrink-0 items-center gap-0.5 pr-1.5`,!h&&`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 pointer-coarse:opacity-100`),children:a})]})}function ht({items:e,value:t,onChange:n,className:r,label:i,bare:a}){return(0,I.jsx)(`div`,{role:`tablist`,"aria-label":i,className:P(`flex flex-wrap gap-x-4 max-[800px]:flex-nowrap max-[800px]:overflow-x-auto max-[800px]:overflow-y-hidden max-[800px]:[scrollbar-width:none] max-[800px]:[&>*]:flex-none`,!a&&`border-b border-line px-4`,r),children:e.map(e=>{let r=e.id===t,i=P(`-mb-px inline-flex cursor-pointer items-center gap-1.5 border-0 border-b-2 bg-transparent px-0 pt-2 pb-[7px] text-sm font-semibold no-underline transition-colors`,r?`border-accent text-accent`:`border-transparent text-fg-2 hover:text-fg`),a=(0,I.jsxs)(I.Fragment,{children:[e.label,e.count!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums opacity-70`,children:e.count})]});return e.href?(0,I.jsx)(U,{href:e.href,role:`tab`,"aria-selected":r,className:i,children:a},e.id):(0,I.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n?.(e.id),className:i,children:a},e.id)})})}var gt=`rounded-control border border-line bg-surface text-fg placeholder:text-fg-2 focus:border-accent focus:outline-none disabled:opacity-60`,_t=[[/^font-(sans|mono|reading|serif)$/,/^font-(sans|mono|reading|serif)$/],[/^text-(2xs|xs|sm|base|md|lg|xl)$/,/^text-(2xs|xs|sm|base|md|lg|xl|2xl|\[\d)/],[/^w-/,/^w-/],[/^h-/,/^h-/],[/^px-/,/^px-/],[/^pr-/,/^(pr|px)-/],[/^py-/,/^py-/],[/^leading-/,/^leading-/]];function vt(e,t){let n=(t??``).split(/\s+/).filter(Boolean);return P(gt,...e.split(` `).filter(e=>{let t=_t.find(([t])=>t.test(e));return!t||!n.some(e=>t[1].test(e))}),t)}var Z=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`input`,{ref:n,className:vt(`w-full h-9 px-3 font-sans text-base`,e),...t})}),yt=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`textarea`,{ref:n,className:vt(`w-full px-3 py-2 font-sans text-base leading-normal`,e),...t})});function bt({className:e,children:t,...n}){return(0,I.jsx)(`select`,{className:vt(`w-full h-9 cursor-pointer px-3 pr-8 font-sans text-base`,e),...n,children:t})}function Q({label:e,hint:t,children:n,className:r}){return(0,I.jsxs)(`label`,{className:P(`flex flex-col gap-1.5`,r),children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),n,t&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:t})]})}function xt({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col gap-3.5 p-[18px]`,t),children:e})}function St({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-wrap items-end gap-2.5 max-[900px]:flex-col max-[900px]:items-stretch`,t),children:e})}function $({checked:e,onChange:t,children:n,hint:r,mono:i,disabled:a,className:o}){return(0,I.jsxs)(`label`,{className:P(`flex cursor-pointer items-center gap-2 text-sm text-fg`,a&&`cursor-default opacity-60`,o),children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`size-[15px] flex-none accent-accent`,checked:e,disabled:a,onChange:e=>t(e.target.checked)}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[i?(0,I.jsx)(`b`,{className:`font-mono text-xs font-semibold`,children:n}):n,r&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[` — `,r]})]})]})}function Ct({checked:e}){return(0,I.jsx)(`span`,{"aria-hidden":!0,className:P(`relative inline-block h-6 w-11 flex-none rounded-full border-2 transition-colors`,e?`border-accent bg-accent`:`border-line bg-surface-2`),children:(0,I.jsx)(`span`,{className:P(`absolute top-1/2 size-4 -translate-y-1/2 rounded-full transition-[left,background-color]`,e?`left-[22px] bg-on-accent`:`left-1 bg-fg-2`)})})}function wt({checked:e,onChange:t,label:n,disabled:r}){return(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,title:n,disabled:r,onClick:()=>t(!e),className:`inline-flex flex-none cursor-pointer border-0 bg-transparent p-0 disabled:cursor-default disabled:opacity-50`,children:(0,I.jsx)(Ct,{checked:e})})}function Tt({label:e,hint:t,checked:n,onChange:r}){return(0,I.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-4 rounded-control border-0 bg-transparent py-2 pr-3 pl-2 text-left transition-colors hover:bg-surface-2`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`text-base text-fg`,children:e}),t&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:t})]}),(0,I.jsx)(Ct,{checked:n})]})}function Et({title:e,count:t,back:n,action:r,divided:i}){return(0,I.jsxs)(`div`,{className:P(`flex min-h-11 items-center gap-2 pt-3 pb-1`,i?`mt-2.5 border-t border-line px-2`:`px-3.5`),children:[n&&(0,I.jsx)(K,{icon:`arrow_back`,label:n.label,size:`sm`,href:n.href,className:`-ml-1.5`}),(0,I.jsx)(nt,{children:e}),t!==void 0&&(0,I.jsx)(`span`,{className:`text-2xs font-semibold tabular-nums text-fg-2`,children:t}),(0,I.jsx)(`span`,{className:`flex-1`}),r]})}function Dt({icon:e=`search`,...t}){return(0,I.jsxs)(`label`,{className:`relative mx-2 mt-1 mb-1 block`,children:[(0,I.jsx)(R,{name:e,className:`ms-sm pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-fg-2`}),(0,I.jsx)(Z,{type:`search`,className:`h-8 rounded-full pl-8 text-sm`,...t})]})}function Ot({children:e,label:t,className:n}){let r=P(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,n);return t?(0,I.jsx)(`nav`,{className:r,"aria-label":t,children:e}):(0,I.jsx)(`div`,{className:r,children:e})}function kt({children:e,className:t}){return(0,I.jsx)(`p`,{className:P(`m-0 px-3 py-2.5 text-xs text-fg-2`,t),children:e})}function At({trigger:e,children:t,align:n=`start`,className:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`span`,{ref:o,className:`relative inline-flex`,children:[e({open:i,toggle:()=>a(e=>!e)}),i&&(0,I.jsx)(`div`,{role:`menu`,className:P(`absolute top-[calc(100%+6px)] z-50 min-w-[260px] overflow-hidden rounded-card border border-line bg-surface p-1.5 shadow-pop`,n===`end`?`right-0`:`left-0`,r),children:t(()=>a(!1))})]})}var jt=null,Mt=new Set,Nt;async function Pt(){try{let e=await A.request(`attention.list`);if(e.ok){jt=e.data.items;for(let e of Mt)e()}}catch{}Nt=setTimeout(()=>void Pt(),3e3)}function Ft(e){return Mt.add(e),Mt.size===1&&Pt(),()=>{Mt.delete(e),Mt.size===0&&Nt&&clearTimeout(Nt)}}function It(){Nt&&clearTimeout(Nt),Pt()}function Lt(){return(0,v.useSyncExternalStore)(Ft,()=>jt)}var Rt={agent:(e,t)=>e.filter(e=>e.owner.agent?.slug===t),project:(e,t,n=[])=>e.filter(e=>e.owner.project?.slug===t||!!e.owner.agent&&n.includes(e.owner.agent.slug)),channel:(e,t)=>e.filter(e=>e.owner.channel===t),general:e=>e.filter(e=>e.owner.general)},zt=e=>e===`approval`?`front_hand`:e===`question`?`help`:e===`runner`?`event_busy`:e===`review`?`rate_review`:`error`,Bt=e=>e===`approval`?`needs approval`:e===`question`?`asks you`:e===`runner`?`no runner`:e===`review`?`for review`:`failed`;function Vt(e){let t=e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:``;return[e.project?`📁 ${e.project.title}`:e.channel?`#${e.channel}`:e.general?`Ralv`:e.workflow?`${e.workflow} run`:``,t].filter(Boolean).join(` · `)||`workspace`}var Ht=e=>new URLSearchParams(e.split(`?`)[1]??``).get(`focus`),Ut=e=>e.split(`?`)[0];function Wt(e,t){if(e.length!==0)return e[(e.findIndex(e=>e.href===t||Ht(t)===null&&Ut(e.href)===t)+1)%e.length]}function Gt(e){e.notificationId&&A.request(`notifications.read`,{body:{ids:[e.notificationId]}}).then(()=>It()).catch(()=>{}),(window.location.hash.slice(1)||`/`)===e.href?window.dispatchEvent(new Event(Kt)):H(e.href)}var Kt=`kw-refocus`;function qt(){let e=Lt()??[],t=Wt(e,z());return(0,v.useEffect)(()=>{let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.code!==`KeyN`)return;let t=Wt(jt??[],window.location.hash.slice(1)||`/`);t&&(e.preventDefault(),Gt(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),t?(0,I.jsxs)(`button`,{type:`button`,className:`next-btn inline-flex h-8 cursor-pointer items-center gap-2 rounded-control border-0 bg-bad/12 px-1.5 font-[inherit] text-sm text-fg hover:bg-bad/18`,onClick:()=>Gt(t),title:`next: ${Vt(t.owner)} — ${t.title} (⌥N)`,children:[(0,I.jsx)(`span`,{className:`next-n inline-grid h-5 min-w-5 place-items-center rounded-full bg-bad px-1.5 text-2xs font-bold tabular-nums text-on-bad`,children:e.length}),(0,I.jsx)(`span`,{className:`text-fg-2 max-[640px]:hidden`,children:`waiting`}),(0,I.jsxs)(`span`,{className:`inline-flex h-6 items-center gap-0.5 rounded-md bg-bad pl-2.5 pr-2 font-semibold text-on-bad`,children:[`next `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),(0,I.jsx)(et,{className:`mr-1 max-[800px]:hidden`,"aria-hidden":!0,children:`⌥N`})]}):null}function Jt(){let e=z(),t=Ht(e),[n,r]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>r(e=>e+1);return window.addEventListener(Kt,e),()=>window.removeEventListener(Kt,e)},[]),(0,v.useEffect)(()=>{if(!t)return;let e=0,n=setInterval(()=>{let r=document.querySelector(`[data-request="${CSS.escape(t)}"]`);r?(clearInterval(n),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.classList.remove(`focus-flash`),r.offsetWidth,r.classList.add(`focus-flash`)):++e>40&&clearInterval(n)},150);return()=>clearInterval(n)},[t,e,n])}function Yt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xt=Yt();function Zt(e){Xt=e}var Qt={exec:()=>null};function $t(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function en(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(nn.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var tn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),nn={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:$t(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:$t(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:$t(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:$t(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:$t(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:$t(e=>RegExp(`^ {0,${e}}(?:</?(?:${vn})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:$t(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},rn=/^(?:[ \t]*(?:\n|$))+/,an=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,on=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,sn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,cn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ln=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,un=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,dn=en(un).replace(/bull/g,ln).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),fn=en(un).replace(/bull/g,ln).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,mn=/^[^\n]+/,hn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,gn=en(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,hn).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),_n=en(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ln).getRegex(),vn=`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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,yn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bn=en(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,yn).replace(`tag`,vn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xn=e=>en(pn).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex(),Sn=xn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Cn=xn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),wn={blockquote:en(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Cn).getRegex(),code:an,def:gn,fences:on,heading:cn,hr:sn,html:bn,lheading:dn,list:_n,newline:rn,paragraph:Sn,table:Qt,text:mn},Tn=en(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex(),En={...wn,lheading:fn,table:Tn,paragraph:en(pn).replace(`hr`,sn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Tn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,vn).getRegex()},Dn={...wn,html:en(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,yn).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Qt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:en(pn).replace(`hr`,sn).replace(`heading`,` *#{1,6} *[^
11
11
  ]`).replace(`lheading`,dn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},On=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,kn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,An=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,jn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Mn=/[\p{P}\p{S}]/u,Nn=/[\s\p{P}\p{S}]/u,Pn=/[^\s\p{P}\p{S}]/u,Fn=en(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Nn).getRegex(),In=/[\p{Pi}\p{Ps}"']/u,Ln=/(?!~)[\p{P}\p{S}]/u,Rn=/(?!~)[\s\p{P}\p{S}]/u,zn=/(?:[^\s\p{P}\p{S}]|~)/u,Bn=en(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,tn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Vn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Hn=en(Vn,`u`).replace(/punct/g,Mn).getRegex(),Un=en(Vn,`u`).replace(/punct/g,Ln).getRegex(),Wn=en(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,In).replace(/punct/g,Mn).getRegex(),Gn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Kn=en(Gn,`gu`).replace(/notPunctSpace/g,Pn).replace(/punctSpace/g,Nn).replace(/punct/g,Mn).getRegex(),qn=en(Gn,`gu`).replace(/notPunctSpace/g,zn).replace(/punctSpace/g,Rn).replace(/punct/g,Ln).getRegex(),Jn=en(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Pn).replace(/punctSpace/g,Nn).replace(/punct/g,Mn).getRegex(),Yn=en(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Pn).replace(/punctSpace/g,Nn).replace(/punct/g,Mn).getRegex(),Xn=en(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Pn).replace(/punctSpace/g,Nn).replace(/punct/g,Mn).getRegex(),Zn=en(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Mn).getRegex(),Qn=en(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Pn).replace(/punctSpace/g,Nn).replace(/punct/g,Mn).getRegex(),$n=en(/\\(punct)/,`gu`).replace(/punct/g,Mn).getRegex(),er=en(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,Mn).getRegex(),tr=en(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),nr=en(yn).replace(`(?:-->|$)`,`-->`).getRegex(),rr=en(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,nr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ir=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,ar=en(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,ir).getRegex(),or=en(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,ar).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),sr=en(/^!?\[(label)\]\[(ref)\]/).replace(`label`,ar).replace(`ref`,hn).getRegex(),cr=en(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,hn).getRegex(),lr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,ur=en(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,ir).getRegex(),dr=en(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,en(/^!?\[(label)\]\[(ref)\]/).replace(`label`,ur).replace(`ref`,lr).getRegex()).replace(`nolink`,en(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,lr).getRegex()).getRegex(),fr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,pr=en(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),mr={_backpedal:Qt,anyPunctuation:$n,anyPunctuationOutsideCode:er,autolink:tr,blockSkip:Bn,br:An,code:kn,del:Qt,delLDelim:Qt,delRDelim:Qt,emStrongLDelim:Hn,emStrongRDelimAst:Kn,emStrongRDelimUnd:Yn,escape:On,link:or,nolink:cr,punctuation:Fn,reflink:sr,reflinkSearch:dr,tag:rr,text:jn,url:Qt},hr={...mr,emStrongLDelim:Wn,emStrongRDelimAst:Jn,emStrongRDelimUnd:Xn,link:en(/^!?\[(label)\]\((.*?)\)/).replace(`label`,ar).getRegex(),reflink:en(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,ar).getRegex()},gr={...mr,emStrongRDelimAst:qn,emStrongLDelim:Un,delLDelim:Zn,delRDelim:Qn,url:en(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,pr).replace(`protocol`,fr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:en(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,fr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,tn?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},_r={...gr,br:en(An).replace(`{2,}`,`*`).getRegex(),text:en(gr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},vr={normal:wn,gfm:En,pedantic:Dn},yr={normal:mr,gfm:gr,breaks:_r,pedantic:hr},br={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},xr=e=>br[e];function Sr(e,t){if(t){if(nn.escapeTest.test(e))return e.replace(nn.escapeReplace,xr)}else if(nn.escapeTestNoEncode.test(e))return e.replace(nn.escapeReplaceNoEncode,xr);return e}function Cr(e){return nn.numericCharacterReference.test(e)?e.replace(nn.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&amp;`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&amp;`:String.fromCodePoint(r)}):e}function wr(e){try{e=encodeURI(e).replace(nn.percentDecode,`%`)}catch{return null}return e}function Tr(e,t){let n=e.replace(nn.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(nn.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(nn.slashPipe,`|`);return n}function Er(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Dr(e){let t=e.split(`
12
12
  `),n=t.length-1;for(;n>=0&&nn.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
13
13
  `)}function Or(e){return e.trim().replace(nn.multipleSpaceGlobal,` `).toLowerCase().toUpperCase().toLowerCase()}function kr(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}var Ar=new WeakMap;function jr(e){let t={"*":-1,_:-1},n=-1,r=e.length;for(let i=0;i<r;i++){let a=e[i];if(a!==`*`&&a!==`_`&&a!==`~`)continue;let o=i===0?`
@@ -83,7 +83,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
83
83
  `+f),xe&&(f=$(f)),D&&Ae?M(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};nt(e),we=!0,Te=V,Ee=H},t.clearConfig=function(){J=null,we=!1,Te=null,Ee=null,D=k,O=``},t.isValidAttribute=function(e,t,n){J||nt({});let r=et(e),i=et(t);return typeof n==`string`&&(Bt(t,n)||!be&&Li(va,n))?!1:Ft(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Fi(re,e)&&vi(re[e],t)},t.removeHook=function(e,t){if(Fi(re,e)){if(t!==void 0){let n=gi(re[e],t);return n===-1?void 0:bi(re[e],n,1)[0]}return _i(re[e])}},t.removeHooks=function(e){Fi(re,e)&&(re[e]=[])},t.removeAllHooks=function(){re=Ca()},t}var Da=Ea(),Oa=l(h(),1),ka=`kw-vibeable`,Aa=`kw-vibe-slot`;function ja(e){window.dispatchEvent(new CustomEvent(ka,{detail:e}))}async function Ma(e,t){let n=await A.request(`chats.setVibeable`,{id:e,body:{slug:t}});if(!n.ok)throw Error(M(n));return n.data}function Na({chatId:e,slug:t,agentBusy:n,onClosed:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),g=(0,v.useRef)(null),_=(0,v.useCallback)(async()=>{try{let e=await A.request(`vibeables.get`,{slug:t});if(!e.ok)throw Error(M(e));a(e.data),d(``)}catch(e){d(e.message)}},[t]);(0,v.useEffect)(()=>{_();let e,n=j.subscribe(`vibeable.${t}`,{},t=>{let n=t;if(n.type===`change`)s(e=>e+1),l(n.files.slice(0,3).join(`, `)+(n.files.length>3?` +${n.files.length-3}`:``)),clearTimeout(e),e=setTimeout(()=>l(``),2500);else if(n.type===`dev`&&n.dev){let e=n.dev;a(t=>t&&{...t,dev:e,mode:e.running?`dev`:`static`})}else n.type===`error`&&d(n.message)});return()=>{n(),clearTimeout(e)}},[t,_]);let y=!!i?.dev?.running;(0,v.useEffect)(()=>{if(!y||!m)return;let e=setInterval(()=>void _(),2e3);return()=>clearInterval(e)},[y,m,_]);let b=i?`${ee(i.url)}?v=${o}`:``,x=()=>s(e=>e+1),S=async e=>{p(e),d(``);try{let n=await A.request(e===`start`?`vibeables.devStart`:`vibeables.devStop`,{slug:t});if(!n.ok)throw Error(M(n));a(n.data),e===`start`&&h(!0)}catch(e){d(e.message)}finally{p(``)}},C=async()=>{if(e&&r){p(`close`),d(``);try{r(await Ma(e,null))}catch(e){d(e.message),p(``)}}},w=i?.dev,T=w?.running?w.ready?{tone:`ok`,text:`dev :${w.port}`}:{tone:`working`,text:`starting…`}:w&&w.exitCode!==void 0?{tone:`bad`,text:`dev exited${w.exitCode==null?``:` (${w.exitCode})`}`}:{tone:`ok`,text:`static`};return(0,I.jsxs)(`aside`,{className:Fa,"data-vibe":t,children:[(0,I.jsxs)(`div`,{className:Ia,children:[(0,I.jsx)(R,{name:`web`,className:`text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate text-base font-medium`,title:i?.path,children:t}),(0,I.jsx)(Ra,{tone:T.tone,title:w?.command?`dev: ${w.command}`:i?.dir,children:T.text}),c&&(0,I.jsxs)(`span`,{className:`inline-flex animate-vibe-flash items-center gap-1 text-2xs whitespace-nowrap text-accent`,title:c,children:[(0,I.jsx)(R,{name:`bolt`,className:`ms-sm`}),` reloaded`]}),(0,I.jsx)(`span`,{className:`flex-1`}),i?.config.dev&&(w?.running?(0,I.jsx)(K,{icon:f===`stop`?`progress_activity`:`stop`,label:`stop dev server`,title:`Stop the dev server (${i.config.dev})`,onClick:()=>void S(`stop`),disabled:!!f}):(0,I.jsx)(K,{icon:f===`start`?`progress_activity`:`play_arrow`,label:`start dev server`,title:`Start the dev server: ${i.config.dev}`,className:`text-accent`,onClick:()=>void S(`start`),disabled:!!f})),w&&(0,I.jsx)(K,{icon:`terminal`,label:`dev server output`,title:`Dev server output`,className:m?`bg-accent-soft text-on-accent-soft`:void 0,"aria-pressed":m,onClick:()=>h(e=>!e)}),(0,I.jsx)(K,{icon:`refresh`,label:`reload preview`,title:`Reload the preview`,onClick:x}),(0,I.jsx)(K,{icon:`open_in_new`,label:`open in new tab`,title:`Open in a new tab`,onClick:()=>window.open(i?ee(i.url):``,`_blank`,`noopener`),disabled:!i}),e&&r&&(0,I.jsx)(K,{icon:f===`close`?`progress_activity`:`close`,label:`close preview`,title:n?`The agent is working — close the preview when the turn is done`:`Close the preview (the agent returns to the project root)`,onClick:()=>void C(),disabled:!!f||n})]}),(u||i?.configError)&&(0,I.jsxs)(`div`,{className:La,children:[(0,I.jsx)(`span`,{className:`flex-1`,children:u||i?.configError}),u&&(0,I.jsx)(K,{icon:`close`,label:`dismiss`,size:`sm`,className:`rounded-full text-inherit hover:bg-transparent hover:text-inherit`,onClick:()=>d(``)})]}),i?.config.dev&&!w?.running&&!u&&(0,I.jsxs)(J,{className:`flex-none border-b border-line px-3.5 py-1.5`,children:[`This app has a dev command (`,(0,I.jsx)(`code`,{children:i.config.dev}),`). Showing the static folder until you start it.`]}),b&&(0,I.jsx)(`iframe`,{ref:g,className:`vibeable-frame block min-h-0 w-full flex-1 border-0 bg-white`,src:b,title:`vibeable ${t}`,sandbox:`allow-scripts allow-forms allow-popups allow-modals allow-downloads`,allow:`clipboard-write`}),!b&&!u&&(0,I.jsx)(Y,{className:`m-auto`,children:`loading…`}),m&&w&&(0,I.jsx)(`pre`,{className:`m-0 max-h-[180px] flex-none overflow-auto border-t border-line bg-surface-2 px-3.5 py-2 font-mono text-[11.5px] leading-[1.5] break-words whitespace-pre-wrap text-fg-2`,"aria-label":`dev server log`,children:w.log.length?w.log.join(`
84
84
  `):`(no output yet)`})]})}var Pa=`vibeable-pane flex flex-col overflow-hidden rounded-2xl bg-surface-2`,Fa=`${Pa} min-h-0 min-w-0 flex-1`,Ia=`flex min-h-11 flex-none items-center gap-2 border-b border-line py-1.5 pr-2 pl-3.5`,La=`flex flex-none items-center gap-2.5 bg-bad-soft py-1.5 pr-2 pl-3.5 text-[12.5px] text-on-bad-soft`;function Ra({tone:e,title:t,children:n}){return(0,I.jsxs)(`span`,{className:P(`vibeable-mode inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-2xs font-medium tracking-[0.02em] whitespace-nowrap`,e===`bad`?`bg-bad-soft text-on-bad-soft`:`bg-surface text-fg-2`),title:t,children:[(0,I.jsx)($e,{tone:e}),n]})}function za({chatId:e,slug:t,onClosed:n}){let[r,i]=(0,v.useState)(``);return(0,I.jsxs)(`aside`,{className:P(Pa,`max-w-[420px] min-w-[320px] flex-none self-start`),"data-vibe":t,children:[(0,I.jsxs)(`div`,{className:Ia,children:[(0,I.jsx)(R,{name:`web`,className:`text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate text-base font-medium`,children:t}),(0,I.jsx)(Ra,{tone:`bad`,children:`vibeables are off`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:`close`,label:`close preview`,title:`Detach the app from this chat`,onClick:()=>Ma(e,null).then(n).catch(e=>i(e.message))})]}),(0,I.jsxs)(J,{className:`flex-none border-b border-line px-3.5 py-1.5`,children:[`This chat has `,(0,I.jsx)(`b`,{children:t}),` open, but vibeables were switched off in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),`. Turn them back on to see the preview, or detach the app.`]}),r&&(0,I.jsx)(`div`,{className:La,children:(0,I.jsx)(`span`,{className:`flex-1`,children:r})})]})}var Ba=`kw-vibeable-agent`;async function Va(e,t){let n=await A.request(`chats.create`,{body:{agent:t,scope:{kind:`general`}}});if(!n.ok)throw Error(M(n));let r=n.data;if(!r.id)throw Error(`HTTP ${n.status}`);await Ma(r.id,e),H(`/agents/chats/${r.id}`)}function Ha({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)({}),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(()=>{try{let e=localStorage.getItem(Ba);return e===`codex`||e===`pi`?e:`claude`}catch{return`claude`}}),_=be(),y=(0,v.useCallback)(async()=>{try{let e=await A.request(`vibeables.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);n(e.data),i(``)}catch(e){i(e.message||`could not load the apps`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await y(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[y]);let b=[...t?.vibeables??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``)),x=s.trim().toLowerCase(),S=x?b.filter(e=>e.slug.toLowerCase().includes(x)):b,C=e===`new`,w=e&&!C?b.find(t=>t.slug===e):void 0;(0,v.useEffect)(()=>{y()},[e,y]);let T=b[0]?.slug;(0,v.useEffect)(()=>{!e&&T&&H(`/vibeables/${encodeURIComponent(T)}`,{replace:!0})},[e,T]);let E=(e,t)=>u(n=>({...n,[e]:t})),D=e=>u(t=>{let n={...t};return delete n[e],n}),O=(e,t)=>f(n=>({...n,[e]:t.message})),k=async e=>{e.preventDefault();let t=a.trim();if(t&&!l.__new){E(`__new`,`create`),f(e=>({...e,__new:``}));try{let e=await A.request(`vibeables.create`,{body:{name:t}});if(!e.ok)throw Error(M(e));let n=e.data;o(``),await y(),H(`/vibeables/${encodeURIComponent(n.slug??t)}`)}catch(e){O(`__new`,e)}finally{D(`__new`)}}},ee=async e=>{E(e,`open`);try{await Va(e,h)}catch(t){O(e,t),D(e)}},j=async e=>{E(e,`remove`),m(!1);try{let t=await A.request(`vibeables.delete`,{slug:e});if(!t.ok)throw Error(t.error||`failed`);await y(),H(`/vibeables`,{replace:!0})}catch(t){O(e,t),y()}finally{D(e)}},N=e=>{g(e);try{localStorage.setItem(Ba,e)}catch{}},P=e=>e.configError?{label:`config error`,tone:`bad`}:e.hasIndex?{label:e.dev?`dev`:`static`,tone:`ok`}:{label:`no index.html yet`,tone:`idle`},F;if(t&&!t.enabled)F=(0,I.jsx)(Y,{children:t.error&&!/are off/.test(t.error)?(0,I.jsx)(tt,{tone:`bad`,children:t.error}):(0,I.jsxs)(I.Fragment,{children:[`Apps are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`vibeables:`}),` block to kraftwerk.yml.`]})});else if(!t)F=(0,I.jsx)(Y,{children:`loading…`});else if(C||b.length===0)F=(0,I.jsxs)(`form`,{className:`mx-auto flex w-full max-w-[560px] flex-col gap-2.5 px-4 py-10`,onSubmit:e=>void k(e),children:[(0,I.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,I.jsx)(Z,{className:`flex-1 font-mono text-sm`,value:a,placeholder:`e.g. team-dashboard`,"aria-label":`new app name`,onChange:e=>o(e.target.value),autoFocus:!0}),(0,I.jsx)(G,{type:`submit`,variant:`primary`,icon:`add`,busy:!!l.__new,disabled:!a.trim(),children:l.__new?`creating…`:`new app`})]}),d.__new&&(0,I.jsx)(tt,{tone:`bad`,children:d.__new}),(0,I.jsxs)(`p`,{className:`m-0 text-xs text-fg-2`,children:[`A small app built live with an agent. One folder each under `,(0,I.jsx)(`code`,{title:t.root,children:t.root}),`; part of the workspace, commit it from the git screen.`]})]});else if(e&&!w)F=(0,I.jsxs)(Y,{children:[`no vibeable named `,e]});else if(w){let e=w,t=P(e),n=l[e.slug];F=(0,I.jsxs)(`div`,{className:`chat-main gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,I.jsx)($e,{tone:t.tone}),(0,I.jsx)(it,{children:e.slug}),(0,I.jsx)(q,{tone:t.tone===`bad`?`bad`:t.tone===`ok`?`ok`:`neutral`,children:t.label}),e.updatedAt&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,W(e.updatedAt)]}),_&&(0,I.jsx)(`span`,{className:`max-w-[40ch] truncate font-mono text-xs text-fg-2`,title:e.path,children:e.path}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(bt,{className:`h-8 w-auto text-sm`,value:h,onChange:e=>N(e.target.value),"aria-label":`agent for new chats`,children:[(0,I.jsx)(`option`,{value:`claude`,children:`claude`}),(0,I.jsx)(`option`,{value:`codex`,children:`codex`}),(0,I.jsx)(`option`,{value:`pi`,children:`pi`})]}),(0,I.jsx)(G,{variant:`primary`,icon:`chat`,busy:n===`open`,disabled:!!n,onClick:()=>void ee(e.slug),title:`Start a ${h} chat with this app in the preview pane`,children:`open in chat`}),p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,icon:`delete`,onClick:()=>void j(e.slug),children:`confirm remove`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>m(!1),children:`cancel`})]}):(0,I.jsx)(G,{variant:`danger`,icon:`delete`,disabled:!!n,onClick:()=>m(!0),title:`Move the folder to the trash`,children:`remove`})]}),(e.configError||d[e.slug])&&(0,I.jsx)(tt,{tone:`bad`,children:e.configError||d[e.slug]}),(0,I.jsx)(Na,{slug:e.slug},e.slug)]})}else F=(0,I.jsx)(Y,{children:`loading…`});return(0,I.jsxs)(`div`,{className:`runs-screen vibeables-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`apps`,count:t?.enabled?b.length:void 0,action:t?.enabled&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/vibeables/new`,children:`new`})}),(0,I.jsx)(Dt,{icon:`filter_list`,value:s,placeholder:`search apps`,"aria-label":`search apps`,onChange:e=>c(e.target.value)}),(0,I.jsxs)(Ot,{children:[S.map(t=>{let n=P(t);return(0,I.jsx)(`div`,{className:`vibeable-row`,"data-vibeable":t.slug,children:(0,I.jsx)(mt,{href:`/vibeables/${encodeURIComponent(t.slug)}`,active:t.slug===e,size:`sm`,leading:(0,I.jsx)($e,{tone:n.tone}),title:t.slug,sub:`${n.label}${t.dev?` · ${t.dev}`:``}`,meta:t.updatedAt&&(0,I.jsx)(`span`,{title:t.updatedAt,children:W(t.updatedAt)})})},t.slug)}),t&&b.length===0&&(0,I.jsx)(kt,{children:`nothing built yet`}),t&&b.length>0&&S.length===0&&(0,I.jsx)(kt,{children:`no vibeable matches`}),r&&(0,I.jsx)(tt,{tone:`bad`,children:r})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:F})]})}function Ua({slug:e}){let t=N(`channels.list`,{},{interval:4e3}),n=N(`agents.list`,{},{interval:15e3}),r=e?t?.channels.find(t=>t.slug===e):void 0;return e?t?r?(0,I.jsx)(qa,{channel:r,agents:n?.agents??[]},r.slug):(0,I.jsx)(Y,{icon:`forum`,children:`channel not found`}):(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(qa,{agents:n?.agents??[]})}function Wa({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:t&&e[1]===`edit`?`edit`:t?`channel`:`home`,r=N(`channels.list`,{},{interval:4e3}),i=N(`agents.list`,{},{interval:15e3}),a=r?.channels??[],o=t?a.find(e=>e.slug===t):void 0,s=a.reduce((e,t)=>!e||t.updatedAt>e.updatedAt?t:e,void 0);(0,v.useEffect)(()=>{n===`home`&&s&&H(`/channels/${encodeURIComponent(s.slug)}`,{replace:!0})},[n,s?.slug]);let c;return c=n===`new`?(0,I.jsx)(qa,{agents:i?.agents??[]}):n===`edit`&&o?(0,I.jsx)(qa,{channel:o,agents:i?.agents??[]},o.slug):n===`channel`&&o?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Ko,{id:o.chatId,channel:o,agents:i?.agents??[]},o.chatId)}):n===`channel`&&r?(0,I.jsx)(Y,{icon:`forum`,children:`channel not found`}):n===`channel`||!r||s?(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(Ga,{}),(0,I.jsxs)(`div`,{className:`runs-screen channels-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`channels`,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/channels/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[a.map(e=>(0,I.jsx)(mt,{href:`/channels/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,leading:(0,I.jsx)($e,{tone:e.awaitingApproval?`bad`:e.busy?`working`:`idle`,title:e.awaitingApproval?`waiting for your approval`:e.busy?`an agent is working`:void 0}),title:`#${e.slug}`,sub:`${e.name}${e.project?` · 📁 ${e.project}`:``}${e.members.length?` · ${e.members.map(e=>`@${e}`).join(` `)}`:``}`,meta:Ge(e.updatedAt)},e.slug)),r&&a.length===0&&(0,I.jsx)(kt,{children:`no channels yet — create one, or add a coworker to an agent session or a project chat`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:c})]})}function Ga(){return(0,I.jsx)(Y,{className:`m-auto`,action:(0,I.jsx)(G,{variant:`primary`,icon:`add`,href:`/channels/new`,children:`new channel`}),children:null})}function Ka({agents:e,checked:t,onToggle:n,none:r}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-control border border-line p-1`,children:[e.map(e=>(0,I.jsx)($,{checked:t.includes(e.slug),onChange:t=>n(e.slug,t),hint:`@${e.slug}${e.description?` · ${e.description}`:``}`,className:P(`rounded-control px-2.5 py-1.5 transition-colors hover:bg-surface-2`,t.includes(e.slug)&&`bg-surface-2`),children:(0,I.jsxs)(`b`,{className:`font-semibold`,children:[e.emoji,` `,e.name]})},e.slug)),e.length===0&&(0,I.jsx)(Y,{className:`py-4`,children:r})]})}function qa({channel:e,agents:t}){let[n,r]=(0,v.useState)(e?.name??``),[i,a]=(0,v.useState)(e?.purpose??``),[o,s]=(0,v.useState)(e?.members??[]),[c,l]=(0,v.useState)(e?.responder??``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),m=t.filter(e=>!e.archived);function h(e,t){s(n=>t?[...n.filter(t=>t!==e),e]:n.filter(t=>t!==e)),!t&&c===e&&l(``)}async function g(){d(!0),p(``);try{let t={name:n,purpose:i,members:o,responder:c||null},r=e?await A.request(`channels.save`,{slug:e.slug,body:t}):await A.request(`channels.create`,{body:t});if(!r.ok)throw Error(M(r));H(`/channels/${encodeURIComponent(r.data.slug)}`)}catch(e){p(e.message)}d(!1)}async function _(){e&&window.confirm(`Move #${e.slug} and its transcript to the trash?`)&&(await A.request(`channels.delete`,{slug:e.slug}).catch(()=>{}),H(`/channels`))}return(0,I.jsx)(ot,{width:`narrow`,children:(0,I.jsx)(X,{title:e?`edit #${e.slug}`:`new channel`,actions:e&&(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void _(),children:`delete`}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 p-[18px]`,children:[(0,I.jsx)(Q,{label:`name`,children:(0,I.jsx)(Z,{value:n,placeholder:`e.g. Website relaunch`,onChange:e=>r(e.target.value),autoFocus:!0})}),(0,I.jsx)(Q,{label:`purpose — one line the agents read`,children:(0,I.jsx)(Z,{value:i,placeholder:`what this channel is for`,onChange:e=>a(e.target.value)})}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`members — agents in this channel`}),(0,I.jsx)(Ka,{agents:m,checked:o,onToggle:h,none:`no agents yet — create one on the agents screen first`})]}),(0,I.jsx)(Q,{label:`responder — answers when a message mentions nobody`,children:(0,I.jsxs)(bt,{value:c,onChange:e=>l(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`nobody (agents only answer when @mentioned)`}),o.map(e=>(0,I.jsxs)(`option`,{value:e,children:[`@`,e]},e))]})}),f&&(0,I.jsx)(tt,{tone:`bad`,children:f}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(G,{variant:`primary`,busy:u,disabled:!n.trim()||o.length===0,onClick:()=>void g(),children:u?`saving…`:e?`save`:`create channel`}),(0,I.jsx)(G,{variant:`quiet`,href:e?`/channels/${encodeURIComponent(e.slug)}`:`/channels`,children:`cancel`})]})]})})})}function Ja({chatId:e,agentSlug:t,project:n,title:r,onClose:i,onCreated:a}){let[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(r||``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``);(0,v.useEffect)(()=>{A.call(`agents.list`).then(e=>s(e.agents.filter(e=>!e.archived&&e.slug!==t))).catch(()=>{})},[t]);async function g(){p(!0),h(``);try{let n=await A.request(`channels.fromChat`,{body:{chatId:e,name:c,members:t?[t,...u]:u,responder:t??u[0]}});if(!n.ok)throw Error(M(n));let r=n.data;if(!r.slug)throw Error(`HTTP ${n.status}`);i(),a?a(r.slug):H(`/channels/${encodeURIComponent(r.slug)}`)}catch(e){h(e.message)}p(!1)}return(0,I.jsx)(`div`,{className:`fixed inset-0 z-40 grid animate-fade place-items-center bg-[color-mix(in_srgb,var(--text)_32%,transparent)] p-6`,onMouseDown:e=>e.target===e.currentTarget&&i(),children:(0,I.jsxs)(`div`,{className:`max-h-[calc(100dvh-48px)] w-[min(560px,100%)] animate-rise overflow-y-auto rounded-card border border-line bg-surface shadow-modal`,role:`dialog`,"aria-label":`Add a coworker`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 border-b border-line px-[18px] py-2`,children:[(0,I.jsx)(nt,{className:`text-fg`,children:`add a coworker`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:`close`,label:`close`,size:`sm`,onClick:i})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-4 p-[18px]`,children:[(0,I.jsx)(`p`,{className:`m-0 text-sm text-fg-2`,children:t?(0,I.jsxs)(I.Fragment,{children:[`This session becomes a channel: @`,t,` stays and keeps its memory, the agents you pick join, and everyone reads the same transcript. @`,t,` answers when nobody is mentioned.`]}):(0,I.jsxs)(I.Fragment,{children:[`This chat becomes a channel session of the project `,(0,I.jsx)(`b`,{className:`text-fg`,children:n}),` and stays here: the agents you pick join with everything said so far and the project's brief, state, records and links. The first one you pick answers when nobody is mentioned.`]})}),(0,I.jsx)(Q,{label:`channel name`,children:(0,I.jsx)(Z,{value:c,placeholder:`e.g. Website relaunch`,onChange:e=>l(e.target.value),autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`invite`}),(0,I.jsx)(Ka,{agents:o,checked:u,onToggle:(e,t)=>d(n=>t?[...n,e]:n.filter(t=>t!==e)),none:`no other agents to invite yet`})]}),m&&(0,I.jsx)(tt,{tone:`bad`,children:m}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(G,{variant:`primary`,busy:f,disabled:!c.trim()||u.length===0,onClick:()=>void g(),children:f?`creating…`:`create channel`}),(0,I.jsx)(G,{variant:`quiet`,onClick:i,children:`cancel`})]})]})]})})}var Ya=`kw-strip-end`;function Xa({children:e}){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=document.getElementById(Ya);e!==t&&n(e)}),t?(0,Oa.createPortal)(e,t):null}function Za({name:e,className:t,onDone:n}){let[r,i]=(0,v.useState)(e),a=r.replace(/\s+/g,` `).trim().slice(0,80);return(0,I.jsx)(`input`,{autoFocus:!0,value:r,"aria-label":`chat name`,maxLength:80,className:P(`min-w-0 rounded-control border border-accent bg-surface px-2 py-1 font-[inherit] text-fg outline-none`,t),onFocus:e=>e.currentTarget.select(),onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`&&n(a&&a!==e?a:void 0),t.key===`Escape`&&n()},onBlur:()=>n(a&&a!==e?a:void 0)})}function Qa({icon:e,label:t,danger:n,onClick:r}){return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:P(`flex w-full cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm hover:bg-surface-2`,n?`text-bad`:`text-fg`),onClick:r,children:[(0,I.jsx)(R,{name:e,className:`ms-sm`}),t]})}var $a=(e,t)=>e.scope.kind===`channel`?e.title||`#${e.scope.slug}`:e.title||t;function eo({id:e,fallbackTitle:t,backHref:n}){let r=N(`chats.list`,{},{refresh:e})?.chats.find(t=>t.id===e),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=r?$a(r,t):``;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`flex-none text-lg text-line-strong`,"aria-hidden":!0,children:`/`}),i&&r?(0,I.jsx)(Za,{name:c,className:`w-[280px] text-base font-semibold`,onDone:t=>{a(!1),t&&A.request(`chats.rename`,{id:e,body:{title:t}}).catch(()=>null)}}):(0,I.jsx)(At,{trigger:({open:e,toggle:t})=>(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":e,"aria-label":`session menu`,className:`session-crumb inline-flex min-w-0 cursor-pointer items-center gap-1 rounded-control px-1.5 py-0.5 text-[17px] font-semibold text-fg transition-colors hover:bg-surface-2`,title:c,onClick:()=>{s(!1),t()},children:[r&&(r.busy||r.awaitingApproval)&&(0,I.jsx)($e,{tone:r.awaitingApproval?`bad`:`working`,title:r.awaitingApproval?`waiting for your approval`:`working`}),r?.scope.kind===`channel`&&(0,I.jsx)(R,{name:`forum`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate`,children:c||`…`}),(0,I.jsx)(R,{name:`expand_more`,className:`ms-sm flex-none text-fg-2`})]}),children:t=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qa,{icon:`edit`,label:`rename`,onClick:()=>{t(),a(!0)}}),(0,I.jsx)(Qa,{icon:`delete`,label:o?`confirm delete`:`delete`,danger:!0,onClick:async()=>{if(!o)return s(!0);t(),await A.request(`chats.delete`,{id:e}).catch(()=>null),H(n)}})]})}),(0,I.jsx)(`span`,{id:Ya,className:`flex flex-none items-center gap-0.5`})]})}var to=`kw-me`;function no(){try{return localStorage.getItem(to)||``}catch{return``}}function ro(e){try{localStorage.setItem(to,e)}catch{}}function io(e,t){A.request(`chats.cancel`,{id:e,body:t?{agent:t}:{}}).catch(()=>{})}var ao=(e,t=90)=>{let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n};function oo(e,t){let n=RegExp(`(^|[^a-z0-9-])@${t.replace(/[.*+?^${}()|[\\]\\]/g,`\\$&`)}(?![a-z0-9-])`,`i`),r,i,a=!1,o=``;for(let s of e)if(s.from?.kind!==`agent`||s.from.slug!==t)(s.type===`user_message`||s.type===`text`)&&n.test(s.text)&&(r=ao(s.text));else switch(s.type){case`turn_start`:a=!0,i=void 0,o=``;break;case`turn_end`:case`error`:a=!1;break;case`tool_call`:a&&(i=ao(`${s.kind&&s.kind!==`other`?`${s.kind}: `:``}${s.title}`));break;case`text`:a&&(o+=s.text,(!i||i.startsWith(`says: `))&&(i=ao(`says: ${o}`)))}return{task:r,now:i}}function so(e,t){let n=e=>!t&&!e||t?.kind===`agent`&&e?.kind===`agent`&&e.slug===t.slug,r=null,i,a=[],o=[],s;for(let t of e)n(t.from)&&(t.type===`plan`?r=t.entries:t.type===`usage`?i={used:t.used,size:t.size,costUsd:t.costUsd}:t.type===`commands`?a=t.commands:t.type===`config`?o=t.options:t.type===`auth`&&(s=t));return{plan:r,usage:i,commands:a,config:o,auth:s}}var co=(0,v.createContext)(()=>`The agent`),lo=()=>(0,v.useContext)(co);function uo(e){let t=new Map;for(let n of e)(n.type===`permission_request`||n.type===`elicitation_request`)&&t.set(n.requestId,n.from??null),(n.type===`permission_resolved`||n.type===`elicitation_resolved`)&&t.delete(n.requestId);return t.size?[...t.values()][0]:void 0}function fo(e,t,n){if(e.kind===`agent`){let r=t.find(t=>t.slug===e.slug);return r?`${r.emoji?`${r.emoji} `:``}${r.name}`:n??e.slug}return e.kind===`general`||e.kind===`kraftwerk`?`🎩 Ralv`:e.kind===`project`?`${Be.emoji} ${Be.name}`:`The assistant`}var po=`kw-browse`;function mo(e){window.dispatchEvent(new CustomEvent(po,{detail:e}))}function ho(e){if(!/<a\s/i.test(e))return e;let t=document.createElement(`template`);t.innerHTML=e;for(let e of t.content.querySelectorAll(`a[href^="http://"], a[href^="https://"]`)){if(e.classList.contains(`md-browse`))continue;let t=document.createElement(`a`);t.className=`md-browse ml-0.5 inline-grid size-[18px] place-items-center rounded-[5px] align-[-3px] text-fg-2 no-underline opacity-55 transition hover:bg-surface-2 hover:text-accent hover:opacity-100 [&_.ms]:align-[0] [&_.ms]:text-[14px]`,t.href=e.getAttribute(`href`)??``,t.title=`Open beside the conversation`,t.setAttribute(`aria-label`,`Open beside the conversation`),t.innerHTML=`<span class="ms material-symbols-rounded ms-sm" aria-hidden="true">open_in_new</span>`,e.after(t)}return t.innerHTML}function go(e){let t=e.target.closest?.(`a.md-browse`);t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button!==0||(e.preventDefault(),mo(t.href)))}var _o=`kw-browser-tabs`;function vo(e){try{return new URL(e).host.replace(/^www\./,``)}catch{return e}}function yo(e){let t=e.trim();return t?/^[a-z]+:\/\//i.test(t)?t:`https://${t}`:``}function bo({storeKey:e,onTabs:t}){let n=`${_o}:${e}`,[r,i]=(0,v.useState)(()=>{try{let e=JSON.parse(sessionStorage.getItem(n)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e.url==`string`&&typeof e.id==`number`):[]}catch{return[]}}),[a,o]=(0,v.useState)(()=>r[0]?.id??null),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),d=(0,v.useRef)(Math.max(0,...r.map(e=>e.id))+1);(0,v.useEffect)(()=>{try{sessionStorage.setItem(n,JSON.stringify(r))}catch{}t?.(r.length)},[r,t,n]);let f=e=>{i(t=>{let n=t.find(t=>t.url===e);if(n)return o(n.id),t;let r={id:d.current++,url:e};return o(r.id),[...t,r]})};(0,v.useEffect)(()=>{let e=e=>f(e.detail);return window.addEventListener(po,e),()=>window.removeEventListener(po,e)},[]);let p=r.find(e=>e.id===a)??null;(0,v.useEffect)(()=>c(p?.url??``),[p?.url]);let m=e=>{i(t=>{let n=t.findIndex(t=>t.id===e),r=t.filter(t=>t.id!==e);return a===e&&o(r[Math.min(n,r.length-1)]?.id??null),r})},h=()=>{let e=yo(s);e&&(p?i(t=>t.map(t=>t.id===p.id?{...t,url:e}:t)):f(e))},g=`grid size-[30px] flex-none place-items-center rounded-full text-fg-2 no-underline transition-colors hover:bg-surface hover:text-fg`;return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-card border border-line bg-surface`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-0.5 overflow-x-auto px-1.5 pt-1.5 [scrollbar-width:none]`,role:`tablist`,"aria-label":`Browser tabs`,children:[r.map(e=>(0,I.jsxs)(`div`,{className:P(`flex max-w-[180px] items-center rounded-t-lg`,e.id===a?`bg-surface-2 text-fg`:`text-fg-2`),children:[(0,I.jsx)(`button`,{role:`tab`,"aria-selected":e.id===a,className:`min-w-0 cursor-pointer truncate border-0 bg-transparent py-1.5 pr-1 pl-2.5 text-[12.5px] font-semibold text-inherit`,title:e.url,onClick:()=>o(e.id),children:vo(e.url)}),(0,I.jsx)(K,{icon:`close`,label:`Close ${vo(e.url)}`,className:`size-6 text-inherit`,onClick:()=>m(e.id)})]},e.id)),(0,I.jsx)(K,{icon:`add`,label:`New tab`,className:`ml-1 size-6`,onClick:()=>{o(null),c(``)}})]}),(0,I.jsxs)(`form`,{className:`flex flex-none items-center gap-1 border-y border-line bg-surface-2 px-2 py-1.5`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,I.jsx)(`button`,{type:`button`,className:P(g,`cursor-pointer border-0 bg-transparent disabled:pointer-events-none disabled:opacity-40`),title:`Reload`,"aria-label":`Reload`,disabled:!p,onClick:()=>p&&u(e=>({...e,[p.id]:(e[p.id]??0)+1})),children:(0,I.jsx)(R,{name:`refresh`})}),(0,I.jsx)(`input`,{className:`h-[30px] min-w-0 flex-1 rounded-full border border-line bg-surface px-3 font-sans text-[13px] text-fg focus:border-fg focus:outline-none`,value:s,placeholder:`https://…`,"aria-label":`Address`,spellCheck:!1,onChange:e=>c(e.target.value)}),(0,I.jsx)(`button`,{type:`submit`,className:P(g,`cursor-pointer border-0 bg-transparent`),title:`Go`,"aria-label":`Go`,children:(0,I.jsx)(R,{name:`arrow_forward`})}),(0,I.jsx)(`a`,{className:P(g,!p&&`pointer-events-none opacity-40`),href:p?.url,target:`_blank`,rel:`noopener noreferrer`,title:`Open in a window`,"aria-label":`Open in a window`,children:(0,I.jsx)(R,{name:`open_in_new`})})]}),(0,I.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-white`,children:[r.map(e=>(0,I.jsx)(`iframe`,{className:`block size-full border-0 bg-white [&[hidden]]:hidden`,src:e.url,title:vo(e.url),hidden:e.id!==a,sandbox:`allow-scripts allow-forms allow-popups allow-same-origin allow-downloads`,referrerPolicy:`no-referrer-when-downgrade`},`${e.id}:${l[e.id]??0}`)),!p&&(0,I.jsxs)(`div`,{className:`absolute inset-0 grid place-content-center justify-items-center gap-2 bg-surface p-6 text-center text-fg-2`,children:[(0,I.jsx)(R,{name:`public`,className:`text-[32px]`}),(0,I.jsxs)(`p`,{className:`m-0 max-w-[36ch] text-[13.5px]`,children:[`Read a page beside the conversation: type an address, or click the `,(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm align-[-3px]`}),` next to a link in the chat.`]})]})]})]})}var xo={knowledge:`knowledge`,vibeable:`vibeables`,repo:`repos`,workflow:`workflows`,agent:`agents`,project:`projects`,contact:`contacts`,place:`places`,event:`events`,presentation:`presentations`},So=RegExp(`(?<![\\w/:.@-])(${Object.keys(xo).join(`|`)}):([a-z0-9][a-z0-9-]{0,48})(?![\\w-])`,`g`),Co=e=>{let[t,n]=e.split(`:`);return`#/${xo[t]}/${encodeURIComponent(n)}`},wo=`md-ref rounded-[5px] bg-surface-2 px-1 py-px font-mono text-[0.9em] text-accent no-underline hover:underline`;function To(e){if(!So.test(e))return e;So.lastIndex=0;let t=document.createElement(`template`);t.innerHTML=e;let n=document.createTreeWalker(t.content,NodeFilter.SHOW_TEXT),r=[];for(let e=n.nextNode();e;e=n.nextNode())r.push(e);for(let e of r){if(e.parentElement?.closest(`a, code, pre`))continue;let t=e.data;if(So.lastIndex=0,!So.test(t))continue;let n=document.createDocumentFragment(),r=0;So.lastIndex=0;for(let e of t.matchAll(So)){n.append(t.slice(r,e.index));let i=document.createElement(`a`);i.className=wo,i.href=Co(e[0]),i.textContent=e[0],n.append(i),r=e.index+e[0].length}n.append(t.slice(r)),e.replaceWith(n)}return t.innerHTML}var Eo=(e,t)=>!e&&!t||!!e&&!!t&&e.kind===t.kind&&(e.kind===`human`?e.name===t.name:e.slug===t.slug);function Do(e){let t=[],n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c,l;for(let u of e){let e=`subagent`in u&&u.subagent?r.get(u.subagent):void 0,d=e?e.children:t,f=d[d.length-1];switch(u.type){case`user_message`:c=u.text,d.push({kind:`user`,text:u.text,steered:u.steered,attachments:u.attachments,key:`e${u.seq}`,from:u.from,by:u.by});break;case`text`:f?.kind===`agent`&&Eo(f.from,u.from)?f.text+=u.text:d.push({kind:`agent`,text:u.text,key:`e${u.seq}`,from:u.from});break;case`thought`:f?.kind===`thought`&&Eo(f.from,u.from)?f.text+=u.text:d.push({kind:`thought`,text:u.text,key:`e${u.seq}`,from:u.from});break;case`tool_call`:{let e={kind:`tool`,callId:u.callId,title:u.title,toolKind:u.kind,status:u.status,compaction:u.compaction,key:`e${u.seq}`,from:u.from};n.set(u.callId,e),d.push(e);break}case`tool_update`:{let e=n.get(u.callId);e&&(u.title&&(e.title=u.title),u.status&&(e.status=u.status),u.compaction&&(e.compaction={...e.compaction,...u.compaction}));break}case`subagent`:{let e={kind:`subagent`,sessionId:u.sessionId,name:u.name,task:u.task,children:[],key:`e${u.seq}`,from:u.from};r.set(u.sessionId,e),t.push(e);break}case`subagent_state`:{let e=r.get(u.sessionId);e&&(e.state=u.state);break}case`task`:{let e={kind:`task`,taskId:u.taskId,name:u.name,taskType:u.taskType,description:u.description,canStop:u.canStop,state:`running`,key:`e${u.seq}`,from:u.from};i.set(u.taskId,e),d.push(e);break}case`task_update`:{let e=i.get(u.taskId);e&&(u.description&&(e.description=u.description),u.summary&&(e.summary=u.summary),u.state&&(e.state=u.state));break}case`permission_request`:s.set(u.requestId,d.length),d.push({kind:`permission`,requestId:u.requestId,title:u.title,options:u.options,resolved:void 0,key:`e${u.seq}`,from:u.from});break;case`permission_resolved`:{let e=s.get(u.requestId);e!=null&&(d[e].resolved=u.optionId);break}case`error`:d.push({kind:`error`,text:u.message,key:`e${u.seq}`,from:u.from});break;case`failure`:{let{type:e,seq:n,ts:r,from:i,...o}=u,s=a.get(o.id);if(s&&o.revision>=s.failure.revision)s.failure=o,s.resolved=!1,s.retryText=c;else if(!s){let e={kind:`failure`,failure:o,resolved:!1,retryText:c,key:`e${u.seq}`,from:i};a.set(o.id,e),t.push(e)}break}case`turn_end`:for(let e of a.values())e.resolved=!0;break;case`plan`:u.entries===null?l&&(l.removed=!0):l&&!l.removed?l.entries=u.entries:(l={kind:`plan`,entries:u.entries,removed:!1,key:`e${u.seq}`,from:u.from},t.push(l));break;case`files_changed`:(u.paths.length>0||u.uncertainty)&&t.push({kind:`files`,paths:u.paths,complete:u.complete,...u.uncertainty?{note:u.uncertainty}:{},key:`e${u.seq}`,from:u.from});break;case`elicitation_request`:{let e={kind:`question`,requestId:u.requestId,message:u.message,fields:u.fields,key:`e${u.seq}`,from:u.from};o.set(u.requestId,e),t.push(e);break}case`elicitation_resolved`:{let e=o.get(u.requestId);e&&(e.resolved={action:u.action,...u.action===`accept`?{content:u.content}:{}});break}}}return t}function Oo({b:e,chatId:t}){let[n,r]=(0,v.useState)({}),[i,a]=(0,v.useState)(!1),o=lo(),[s,c]=(0,v.useState)(null),l=e.resolved===void 0&&!s;async function u(r){a(!0);try{let i=await A.request(`chats.elicitation`,{id:t,body:{requestId:e.requestId,action:r,...r===`accept`?{content:n}:{}}});i.ok||c(i.error??`request failed (${i.status})`)}catch{}a(!1)}let d=(e,t)=>r(n=>({...n,[e]:t})),f=e.fields.some(e=>e.required&&(n[e.key]===void 0||n[e.key]===``));return(0,I.jsx)(ko,{className:P(`question-card`,l&&`pending`),requestId:e.requestId,who:`${o(e.from)} asks`,what:e.message,children:l?(0,I.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2.5`,children:[e.fields.map(e=>(0,I.jsxs)(`label`,{className:P(`flex flex-col gap-1.5 text-sm`,e.custom&&`-mt-1`),children:[(e.title||e.description)&&!e.custom&&(0,I.jsxs)(`span`,{children:[e.title&&(0,I.jsx)(`b`,{children:e.title}),e.description&&(0,I.jsxs)(`span`,{className:`opacity-85`,children:[` `,e.description]})]}),e.kind===`select`&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.options?.map(t=>(0,I.jsx)(G,{size:`sm`,variant:n[e.key]===t.value?`primary`:`secondary`,title:t.description,onClick:()=>d(e.key,t.value),children:t.label},t.value))}),e.kind===`multiselect`&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.options?.map(t=>{let r=n[e.key]??[],i=r.includes(t.value);return(0,I.jsx)(G,{size:`sm`,variant:i?`primary`:`secondary`,title:t.description,onClick:()=>d(e.key,i?r.filter(e=>e!==t.value):[...r,t.value]),children:t.label},t.value)})}),e.kind===`text`&&(0,I.jsx)(Z,{className:`max-w-[60ch]`,placeholder:e.custom?`or type your own answer`:e.title??e.key,value:n[e.key]??``,onChange:t=>d(e.key,t.target.value)}),e.kind===`number`&&(0,I.jsx)(Z,{type:`number`,className:`max-w-[60ch]`,value:n[e.key]??``,onChange:t=>d(e.key,t.target.value===``?``:Number(t.target.value))}),e.kind===`boolean`&&(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:n[e.key]===!0,onChange:t=>d(e.key,t.target.checked)}),` `,e.title??e.key]})]},e.key)),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(G,{variant:`primary`,disabled:i||f,onClick:()=>u(`accept`),children:`answer`}),(0,I.jsx)(G,{disabled:i,onClick:()=>u(`decline`),children:`skip`})]})]}):(0,I.jsx)(Ao,{children:s?`→ ${s}`:e.resolved?.action===`accept`?`→ ${Object.values(e.resolved.content??{}).filter(e=>e!==``&&e!==void 0&&!(Array.isArray(e)&&e.length===0)).map(e=>Array.isArray(e)?e.join(`, `):String(e)).join(` · `)||`answered`}`:e.resolved?.action===`decline`?`→ skipped`:`→ dismissed`})})}function ko({className:e,requestId:t,who:n,what:r,children:i}){return(0,I.jsxs)(`div`,{className:P(`perm-card max-w-[76ch] self-start rounded-2xl bg-ask-soft px-4 py-3 text-on-ask-soft`,e),"data-request":t,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-[3px]`,children:[(0,I.jsx)(`span`,{className:`perm-who text-[12.5px] font-semibold text-fg-2`,children:n}),(0,I.jsx)(`span`,{className:`text-base font-semibold [overflow-wrap:anywhere] text-fg`,children:r})]}),i]})}function Ao({children:e}){return(0,I.jsx)(`div`,{className:`mt-1.5 font-mono text-xs text-fg-2`,children:e})}function jo({b:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=lo(),[a,o]=(0,v.useState)(null),s=e.resolved===void 0&&!a;async function c(n){r(!0);try{let r=await A.request(`chats.permission`,{id:t,body:{requestId:e.requestId,optionId:n}});r.ok||o(r.error??`request failed (${r.status})`)}catch{}r(!1)}return(0,I.jsx)(ko,{className:P(s&&`pending`),requestId:e.requestId,who:`${i(e.from)} asks for your OK`,what:e.title,children:s?(0,I.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.options.map(e=>(0,I.jsx)(G,{variant:e.kind?.startsWith(`allow`)?`primary`:`secondary`,disabled:n,title:e.name,onClick:()=>c(e.optionId),children:Mo(e)},e.optionId))}):(0,I.jsx)(Ao,{children:e.resolved?`→ ${(()=>{let t=e.options.find(t=>t.optionId===e.resolved);return t?Mo(t):e.resolved})()}`:a?`→ ${a}`:`→ dismissed`})})}function Mo(e){return e.kind===`allow_once`?`Allow`:e.kind===`allow_always`?`Always allow`:e.kind===`reject_once`?`Don't allow`:e.kind===`reject_always`?`Never allow`:e.name}var No=new Set([`tool`,`thought`,`subagent`,`task`,`files`]);function Po({id:e,events:t,busy:n,channel:r,agentMap:i,working:a,focus:o}){let s=be(),c=(0,v.useMemo)(()=>{let e=Do(o?t.filter(e=>e.from?.kind===`human`||e.from?.kind===`agent`&&e.from.slug===o):t);return s||o?e:e.filter(e=>!No.has(e.kind))},[t,s,o]),l=lo(),u=(0,v.useMemo)(()=>uo(t),[t]),d=(0,v.useRef)(null),f=(0,v.useRef)(!0);return(0,v.useEffect)(()=>{let e=d.current;e&&f.current&&(e.scrollTop=e.scrollHeight)},[c,n]),(0,I.jsxs)(`div`,{className:`-mx-5 flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto px-[22px] pt-3.5 pb-5 [&>:nth-last-child(-n+3)]:animate-rise`,ref:d,onClick:go,onScroll:e=>{let t=e.currentTarget;f.current=t.scrollHeight-t.scrollTop-t.clientHeight<60},children:[c.length===0&&(0,I.jsx)(Y,{className:`m-auto`,children:r?`say something — @mention an agent to wake it${r.responder?`, or just write: @${r.responder} answers`:``}`:`say something — the agent starts on your first message`}),c.map((t,n)=>{let a=c[n-1],o=r&&t.kind!==`error`&&(!a||!Eo(a.from,t.from)||a.kind===`error`)?t.from:void 0;return(0,I.jsxs)(`div`,{className:`contents`,children:[o&&(0,I.jsx)(Fo,{from:o,agentMap:i}),(0,I.jsx)(zo,{b:t,chatId:e})]},t.key)}),n&&u!==void 0&&(0,I.jsxs)(`div`,{className:`chat-working waiting flex animate-breathe items-center gap-2 text-xs font-semibold text-bad`,children:[(0,I.jsx)($e,{tone:`bad`}),` `,l(u??void 0),` is waiting for you`]}),n&&u===void 0&&(0,I.jsxs)(`div`,{className:`chat-working flex animate-breathe items-center gap-2 text-xs text-fg-2`,children:[(0,I.jsx)($e,{tone:`working`}),` `,r&&a?.length?a.map(e=>`${i?.get(e)?.emoji??``} @${e}`).join(`, `)+(a.length===1?` is working…`:` are working…`):`${l()} is working…`]})]})}function Fo({from:e,agentMap:t}){let n=`mt-2.5 -mb-0.5 inline-flex items-center gap-2 text-sm text-fg-2 no-underline`,r=`grid size-[22px] place-items-center rounded-full text-xs font-semibold`;if(e.kind===`human`)return(0,I.jsxs)(`div`,{className:P(`byline human self-end`,n),children:[(0,I.jsx)(`span`,{className:P(r,`bg-accent text-on-accent`),children:e.name.slice(0,1).toUpperCase()}),(0,I.jsx)(`span`,{className:`byline-name font-semibold text-fg`,children:e.name})]});let i=t?.get(e.slug);return(0,I.jsxs)(U,{href:`/agents/${encodeURIComponent(e.slug)}/info`,className:P(`byline agent self-start`,n),children:[(0,I.jsx)(`span`,{className:P(r,`bg-accent-soft text-on-accent-soft`),children:i?.emoji??`🤖`}),(0,I.jsx)(`span`,{className:`byline-name font-semibold text-fg`,children:i?.name??e.slug}),(0,I.jsxs)(`span`,{className:`font-mono text-2xs`,children:[`@`,e.slug]})]})}function Io({text:e,small:t}){let n=(0,v.useMemo)(()=>ho(To(Da.sanitize(Jr.parse(e,{async:!1})))),[e]);return(0,I.jsx)(`div`,{className:P(`md-body h-auto self-stretch overflow-visible p-0 break-words text-fg`,t?`font-sans text-[12.5px] leading-[1.6]`:`font-reading text-[17px] leading-[1.62]`,`[&_img]:my-1 [&_img]:block [&_img]:rounded-xl [&_pre]:max-w-full`),dangerouslySetInnerHTML:{__html:n}})}function Lo({tone:e,kind:t,kindTone:n,children:r,extra:i}){return(0,I.jsxs)(`div`,{className:`flex max-w-[min(90ch,100%)] items-start gap-2 self-start px-0.5 font-mono text-2xs text-fg-2 max-[800px]:flex-wrap max-[800px]:gap-y-0.5`,children:[(0,I.jsx)(`span`,{className:`mt-[3px] grid`,children:(0,I.jsx)($e,{tone:e})}),(0,I.jsx)(`span`,{className:P(`min-w-16 shrink-0 text-[10px] tracking-[0.5px] uppercase`,n===`ask`&&`text-ask`),children:t}),(0,I.jsx)(`span`,{className:`min-w-0 leading-[1.5] [overflow-wrap:anywhere] whitespace-pre-wrap max-[800px]:basis-full max-[800px]:ps-4`,children:r}),i]})}var Ro=(e,t=`working`)=>e===`completed`?`ok`:e===`failed`?`bad`:e===`running`||e===void 0?t:`idle`;function zo({b:e,chatId:t,nested:n}){switch(e.kind){case`user`:return(0,I.jsxs)(`div`,{className:P(`msg user -mx-[22px] my-1.5 self-stretch bg-[color-mix(in_srgb,var(--accent)_14%,var(--surface-1))] px-[22px] py-4 text-md leading-[1.55] break-words whitespace-pre-wrap text-fg`,e.steered&&`border-l-[3px] border-ask`),children:[e.steered&&(0,I.jsx)(nt,{className:`mb-0.5 block text-[10px] opacity-70`,children:`steered in`}),e.by?.email&&(0,I.jsx)(nt,{className:`mb-0.5 block text-[10px] normal-case opacity-70`,children:(0,I.jsxs)(`span`,{title:e.by.email,children:[`@`,e.by.handle]})}),e.text,e.attachments&&e.attachments.length>0&&(0,I.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.attachments.map(e=>{let n=A.url(`chats.attachment`,{id:t,name:e.name});return e.mimeType.startsWith(`image/`)?(0,I.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,title:e.name,children:(0,I.jsx)(`img`,{src:n,alt:e.name,className:`block max-h-60 max-w-full rounded-lg`})},e.name):(0,I.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs text-inherit underline`,href:n,target:`_blank`,rel:`noreferrer`,children:[(0,I.jsx)(R,{name:`attach_file`,className:`ms-sm`}),` `,e.name]},e.name)})})]});case`agent`:return(0,I.jsx)(Io,{text:e.text,small:n});case`thought`:return(0,I.jsxs)(`details`,{className:`self-stretch`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none`,children:`thinking`}),(0,I.jsx)(`div`,{className:`mt-1 border-l-2 border-line px-3 py-2 text-xs break-words whitespace-pre-wrap text-fg-2`,children:e.text})]});case`tool`:return(0,I.jsx)(Lo,{tone:e.status===`completed`?`ok`:e.status===`failed`?`bad`:`working`,kind:e.compaction?`compact`:e.toolKind,kindTone:e.compaction?`ask`:void 0,children:e.compaction?Ho(e.compaction,e.status):e.title});case`subagent`:return(0,I.jsxs)(`details`,{className:`max-w-[90ch] self-stretch`,open:!e.state,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden`,children:(0,I.jsxs)(Lo,{tone:Ro(e.state),kind:`subagent`,children:[(0,I.jsx)(`b`,{children:e.name}),` — `,e.task,e.state&&e.state!==`completed`&&(0,I.jsxs)(`span`,{className:`opacity-70`,children:[` · `,e.state]})]})}),(0,I.jsxs)(`div`,{className:`mt-1.5 mb-1 ml-[3px] flex flex-col gap-2.5 border-l-2 border-line py-1.5 pl-3.5`,children:[e.children.length===0&&(0,I.jsx)(`div`,{className:`font-mono text-2xs text-fg-2 opacity-70`,children:`working…`}),e.children.map(e=>(0,I.jsx)(zo,{b:e,chatId:t,nested:!0},e.key))]})]});case`task`:return(0,I.jsxs)(Lo,{tone:Ro(e.state,`working`),kind:e.taskType,kindTone:`ask`,extra:e.canStop&&(e.state===`running`||e.state===`paused`)&&(0,I.jsx)(`button`,{type:`button`,className:`ml-2 cursor-pointer rounded-lg border border-line bg-transparent px-1.5 py-px font-[inherit] text-[10px] tracking-[0.5px] text-inherit uppercase hover:border-bad hover:text-bad`,title:`stop this background task (the turn goes on)`,onClick:()=>A.request(`chats.stopTask`,{id:t,body:{taskId:e.taskId}}).catch(()=>{}),children:`stop`}),children:[(0,I.jsx)(`b`,{children:e.name}),` — `,e.summary??e.description,e.state&&e.state!==`running`&&e.state!==`completed`&&(0,I.jsxs)(`span`,{className:`opacity-70`,children:[` · `,e.state]})]});case`plan`:return(0,I.jsxs)(`div`,{className:P(`max-w-[76ch] self-start rounded-xl bg-surface-2 px-3.5 py-2.5 text-[12.5px] text-fg-2`,e.removed&&`opacity-55`),children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,I.jsx)(nt,{children:`plan`}),(0,I.jsxs)(`span`,{className:`font-mono text-2xs`,children:[e.entries.filter(e=>e.status===`completed`).length,`/`,e.entries.length]})]}),(0,I.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-[3px] p-0`,children:e.entries.map((e,t)=>(0,I.jsxs)(`li`,{className:P(`flex items-start gap-1.5 leading-[1.45]`,e.status===`completed`&&`line-through opacity-60`,e.status===`in_progress`&&`font-semibold text-fg`),children:[(0,I.jsx)(R,{name:e.status===`completed`?`check_circle`:e.status===`in_progress`?`play_circle`:`radio_button_unchecked`,className:P(`ms-sm mt-0.5 shrink-0`,e.status===`in_progress`&&`text-accent`)}),(0,I.jsx)(`span`,{children:e.content})]},t))})]});case`files`:return(0,I.jsxs)(Lo,{tone:`ok`,kind:`changed`,children:[e.paths.join(`
85
85
  `),(!e.complete||e.note)&&(0,I.jsxs)(`span`,{className:`opacity-70`,children:[` · `,e.note??`list may be incomplete`]})]});case`question`:return(0,I.jsx)(Oo,{b:e,chatId:t});case`permission`:return(0,I.jsx)(jo,{b:e,chatId:t});case`error`:return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 self-start text-[12.5px] text-bad`,children:[(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),` `,e.text]});case`failure`:return(0,I.jsx)(Vo,{b:e,chatId:t})}}var Bo={retry:`try again`,login:`sign in again`,new_session:`start a fresh session`};function Vo({b:e,chatId:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=e.failure,s=!e.resolved&&!i;async function c(n){if(n===`login`)a(`Sign in again in a terminal (claude login, or codex login), then send your message again.`);else{r(!0);try{if(n===`retry`){if(!e.retryText)return a(`nothing to retry — send a message`);await A.request(`chats.message`,{id:t,body:{text:e.retryText}})}else{let e=await A.request(`chats.resetSession`,{id:t});e.ok||a(e.error??`reset failed (${e.status})`)}}catch{}finally{r(!1)}}}return(0,I.jsxs)(`div`,{className:P(`max-w-[76ch] self-start rounded-2xl px-4 py-3`,o.severity===`warning`?`bg-ask-soft text-on-ask-soft`:`bg-bad-soft text-on-bad-soft`,!s&&`opacity-70`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[13.5px]`,children:[(0,I.jsx)(R,{name:o.severity===`warning`?`warning`:`error`,className:`ms-sm`}),(0,I.jsx)(nt,{className:`mr-1 font-bold text-inherit`,children:o.category}),` `,o.title]}),o.details&&(0,I.jsx)(`div`,{className:`mt-1.5 text-xs break-words whitespace-pre-wrap`,children:o.details}),i&&(0,I.jsx)(`div`,{className:`mt-1.5 text-xs break-words whitespace-pre-wrap`,children:i}),s&&o.actions.length>0&&(0,I.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:o.actions.map(e=>(0,I.jsx)(G,{size:`sm`,disabled:n,className:`border-current text-inherit`,onClick:()=>c(e),children:Bo[e]},e))})]})}function Ho(e,t){let n=e=>e>=1e4?`${Math.round(e/1e3)}k`:String(e),r=[t===`completed`?`context compacted`:t===`failed`?`compaction failed`:`compacting context`];return e.preTokens!=null&&e.postTokens!=null?r.push(`${n(e.preTokens)} → ${n(e.postTokens)} tokens`):e.preTokens!=null&&r.push(`${n(e.preTokens)} tokens`),e.trigger&&r.push(e.trigger),e.error&&r.push(e.error),r.join(` · `)}function Uo({id:e,busy:t,scope:n,channel:r,agentMap:i,commands:a=[],canSteer:o,account:s}){let[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(null),f=lo()().replace(/^\S+\s(?=\S)/u,e=>/\p{Extended_Pictographic}/u.test(e)?``:e).replace(/^The /,`the `),[p,m]=(0,v.useState)([]),[h,g]=(0,v.useState)(0),[_,y]=(0,v.useState)(!1);async function b(t){for(let n of Array.from(t)){g(e=>e+1);try{let t=await A.request(`chats.attach`,{id:e,headers:{"content-type":n.type||`application/octet-stream`,"x-file-name":encodeURIComponent(n.name||`pasted.png`)},body:n});if(typeof t.data!=`object`||!t.data)throw Error(`not json`);t.ok?m(e=>[...e,{...t.data,...n.type.startsWith(`image/`)?{preview:URL.createObjectURL(n)}:{}}]):d(t.error??`upload failed (${t.status})`)}catch{d(`upload failed`)}finally{g(e=>e-1)}}}let[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(0),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(no),[k,ee]=(0,v.useState)(!1),j=(0,v.useRef)(null),M=(0,v.useRef)(null),F=t&&!r&&!!o,te=t&&!r&&!o;(0,v.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await A.request(`skills.list`),r=(t.ok?t.data.skills:void 0)??[];if(n?.kind===`agent`){let[e,t]=await Promise.all([A.call(`agents.get`,{slug:n.slug}).catch(()=>null),A.call(`agents.skills`,{slug:n.slug}).catch(()=>null)]);if(e&&Array.isArray(e.skills)){let t=new Set(e.skills.map(e=>e.toLowerCase()));r=r.filter(e=>t.has(e.name.toLowerCase()))}let i=t?.skills??[],a=new Set(i.map(e=>e.name.toLowerCase()));r=[...i,...r.filter(e=>!a.has(e.name.toLowerCase()))]}e&&S(r)}catch{}})(),()=>{e=!1}},[e]);let z=/^\/([\w-]*)$/.exec(c)?.[1],ne=z!==void 0&&!T?x.filter(e=>e.name.toLowerCase().startsWith(z.toLowerCase())):[],re=new Set(x.map(e=>e.name.toLowerCase())),ie=z!==void 0&&!T?a.filter(e=>e.name.toLowerCase().startsWith(z.toLowerCase())&&!re.has(e.name.toLowerCase())):[],ae=j.current?.selectionStart??c.length,oe=r&&!T?/(^|\s)@([a-z0-9-]*)$/i.exec(c.slice(0,ae)):null,se=oe&&r?r.members.filter(e=>e.startsWith(oe[2].toLowerCase())||(i?.get(e)?.name??``).toLowerCase().startsWith(oe[2].toLowerCase())):[],ce=Te(),le=!T&&ce.presentations?/(^|\s)presentation:([a-z0-9-]*)$/.exec(c.slice(0,ae)):null,ue=N(`presentations.list`,le?{query:{all:`1`}}:null,{interval:6e4}),de=le?(ue?.presentations??[]).filter(e=>e.name.startsWith(le[2])||e.title.toLowerCase().includes(le[2])):[],B=[...ne.map(e=>({id:`/${e.name}`,label:`/${e.name}`,hint:e.description,src:e.source,pick:()=>{l(`/${e.name} `),w(0)}})),...ie.map(e=>({id:`/${e.name}`,label:`/${e.name}${e.hint?` ${e.hint}`:``}`,hint:e.description,src:`agent`,pick:()=>{l(`/${e.name} `),w(0)}})),...se.map(e=>({id:`@${e}`,label:`${i?.get(e)?.emoji??`🤖`} @${e}`,hint:i?.get(e)?.name,pick:()=>{let t=c.slice(0,ae).replace(/@[a-z0-9-]*$/i,`@${e} `);l(t+c.slice(ae)),w(0),requestAnimationFrame(()=>{let e=j.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}})),...de.map(e=>({id:`presentation:${e.project??``}/${e.name}`,label:`▶ presentation:${e.name}`,hint:`${e.title}${e.project?` · ${e.project}`:``} · ${e.slides} slides`,pick:()=>{let t=c.slice(0,ae).replace(/presentation:[a-z0-9-]*$/,`presentation:${e.name} `);l(t+c.slice(ae)),w(0),requestAnimationFrame(()=>{let e=j.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}))].slice(0,15),V=B.length>0,fe=Math.min(C,B.length-1);async function H(){let t=c.trim();if(!t&&p.length===0||te||h>0)return;let n=p.map(({preview:e,...t})=>t);l(``),m([]),d(null);let i={text:t,...n.length?{attachments:n}:{},...r?{from:D||`you`}:{}},a=await(F?A.request(`chats.steer`,{id:e,body:i}):A.request(`chats.message`,{id:e,body:i})).catch(()=>null);a&&!a.ok&&(d(a.error??`not sent (${a.status})`),l(t),m(p))}return(0,I.jsxs)(`div`,{className:`composer relative flex flex-none flex-wrap items-end border-t border-line pt-2.5 pb-1`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),y(!0))},onDragLeave:()=>y(!1),onDrop:e=>{e.dataTransfer.files.length&&(e.preventDefault(),y(!1),b(e.dataTransfer.files))},children:[p.length>0&&(0,I.jsxs)(`div`,{className:`flex basis-full flex-wrap gap-1.5 px-1 pb-1.5`,children:[p.map(e=>(0,I.jsxs)(`span`,{className:Wo,title:`${e.name} · ${Math.round(e.size/1024)} KB`,children:[e.preview?(0,I.jsx)(`img`,{src:e.preview,alt:e.name,className:`h-7 rounded`}):(0,I.jsx)(R,{name:`attach_file`,className:`ms-sm`}),e.name.replace(/^\d{8}-\d{6}-/,``),(0,I.jsx)(`button`,{type:`button`,className:`inline-flex cursor-pointer border-0 bg-transparent p-0 text-inherit hover:text-fg`,title:`remove`,"aria-label":`remove ${e.name}`,onClick:()=>m(t=>t.filter(t=>t.name!==e.name)),children:(0,I.jsx)(R,{name:`close`,className:`ms-sm`})})]},e.name)),h>0&&(0,I.jsx)(`span`,{className:Wo,children:`uploading…`})]}),r&&(0,I.jsxs)(`div`,{className:`composer-me flex basis-full items-center gap-1.5 px-1 pb-1 text-xs text-fg-2`,children:[`posting as`,` `,k?(0,I.jsx)(Z,{autoFocus:!0,className:`h-7 w-48 text-xs`,value:D,placeholder:`your name`,"aria-label":`your name`,onChange:e=>O(e.target.value),onBlur:()=>{ro(D.trim()),ee(!1)},onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&e.target.blur()}}):(0,I.jsxs)(`button`,{type:`button`,className:`me-name inline-flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 font-[inherit] font-semibold text-fg`,onClick:()=>ee(!0),title:`change your name`,children:[D||`you`,` `,(0,I.jsx)(R,{name:`edit`,className:`ms-sm`})]})]}),V&&(0,I.jsx)(`div`,{className:`skill-menu absolute inset-x-0 bottom-full z-5 mb-1.5 flex max-h-[46vh] flex-col overflow-y-auto rounded-card border border-line bg-surface py-1 shadow-pop`,children:B.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,className:P(`flex cursor-pointer items-center gap-1.5 border-0 px-3.5 py-2 text-left text-sm whitespace-nowrap text-fg`,t===fe?`bg-surface-2`:`bg-transparent hover:bg-surface-2`),onMouseDown:t=>{t.preventDefault(),e.pick()},children:[(0,I.jsx)(`b`,{className:`max-w-[42%] flex-none truncate font-mono text-[12.5px] font-medium`,children:e.label}),e.hint&&(0,I.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-2`,children:[`— `,e.hint]}),e.src&&(0,I.jsx)(`span`,{className:`ml-auto flex-none text-[10.5px] tracking-[0.04em] text-fg-2 uppercase`,children:e.src})]},e.id))}),u&&(0,I.jsx)(`div`,{className:`basis-full`,children:(0,I.jsx)(tt,{tone:`bad`,children:u})}),(0,I.jsxs)(`div`,{className:P(`flex min-w-0 flex-1 items-end gap-0.5 rounded-[24px] border bg-surface py-[5px] pr-[5px] pl-3.5 transition-[border-color,box-shadow]`,`focus-within:border-accent focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--accent)_16%,transparent)]`,_?`border-dashed border-accent`:`border-line`),children:[(0,I.jsx)(`textarea`,{ref:j,value:c,className:`max-h-[40vh] min-w-0 flex-1 resize-none overflow-y-auto rounded-none border-0 bg-transparent px-1.5 py-2 font-sans text-md leading-[1.5] text-fg shadow-none outline-none [field-sizing:content] placeholder:text-fg-2`,placeholder:r?te?`the agents are working…`:`Message the channel…`:te?`${f} is working…`:F?`Add to what ${f} is doing…`:`Message ${f}…`,title:`${r?`Enter to send · Shift+Enter for a newline · @ mentions an agent · / for skills · drop or paste files`:`Enter to send · Shift+Enter for a newline · / for skills · drop or paste files`}${s?`\nruns as ${s}`:``}`,rows:Math.min(6,Math.max(1,c.split(`
86
- `).length)),onChange:e=>{l(e.target.value),w(0),E(!1)},onPaste:e=>{let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),b(t))},onKeyDown:e=>{if(V){if(e.key===`ArrowDown`)return e.preventDefault(),w((fe+1)%B.length);if(e.key===`ArrowUp`)return e.preventDefault(),w((fe-1+B.length)%B.length);if(e.key===`Tab`||e.key===`Enter`)return e.preventDefault(),B[fe].pick();if(e.key===`Escape`)return e.preventDefault(),E(!0)}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}}),t&&(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,className:`mr-1 self-center`,onClick:()=>A.request(`chats.cancel`,{id:e}).catch(()=>{}),children:`stop`}),!te&&(0,I.jsx)(K,{icon:`attach_file`,label:`attach files (or drop / paste them)`,className:`size-9 rounded-full [&_.ms]:text-[20px]`,onClick:()=>M.current?.click()}),(0,I.jsx)(`input`,{ref:M,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&b(e.target.files),e.target.value=``}}),!te&&(0,I.jsx)(`button`,{type:`button`,className:`inline-grid size-9 flex-none cursor-pointer place-items-center rounded-full border-0 bg-accent p-0 text-on-accent transition-[filter,opacity] hover:enabled:brightness-110 active:enabled:scale-95 disabled:cursor-default disabled:opacity-30`,disabled:!c.trim()&&p.length===0||h>0,onClick:H,"aria-label":F?`steer`:`send`,title:F?`steer: hand this into the running turn (Enter)`:`send (Enter)`,children:(0,I.jsx)(R,{name:F?`alt_route`:`send`,className:`text-[19px]`})})]})]})}var Wo=`inline-flex items-center gap-1.5 rounded-full border border-line bg-surface-2 px-2 py-0.5 text-2xs text-fg-2`;function Go({id:e,live:t}){let n=be(),[r,i]=(0,v.useState)(null),a=t.config.filter(e=>e.category===`model`||e.category===`thought_level`);async function o(t,n){i(t.id);let r=await A.request(`chats.config`,{id:e,body:{configId:t.id,value:n}}).catch(()=>null);i(null),r&&!r.ok&&alert(r.error??`setting refused (${r.status})`)}return(0,I.jsxs)(I.Fragment,{children:[t.auth?.kind===`none`&&(0,I.jsx)(`span`,{title:[t.auth.detail,t.auth.email,t.auth.organization,t.auth.plan].filter(Boolean).join(` · `),children:(0,I.jsxs)(q,{tone:t.auth.kind===`none`?`bad`:`neutral`,children:[(0,I.jsx)(R,{name:t.auth.kind===`none`?`person_off`:`person`,className:`ms-sm mr-1`}),` `,t.auth.email??t.auth.label]})}),n&&t.usage&&t.usage.size>0&&(0,I.jsx)(`span`,{className:`font-mono`,title:`${t.usage.used.toLocaleString()} of ${t.usage.size.toLocaleString()} context tokens${t.usage.costUsd==null?``:` · $${t.usage.costUsd.toFixed(2)} so far`}`,children:(0,I.jsxs)(q,{children:[Math.round(100*t.usage.used/t.usage.size),`% ctx`,t.usage.costUsd!=null&&` · $${t.usage.costUsd.toFixed(2)}`]})}),n&&a.map(e=>e.type===`select`?(0,I.jsx)(bt,{className:`h-7 w-auto max-w-[22ch] px-2 pr-6 text-xs text-fg-2`,value:e.value,disabled:r===e.id,title:e.description??e.name,"aria-label":e.name,onChange:t=>o(e,t.target.value),children:e.choices.map(e=>(0,I.jsxs)(`option`,{value:e.value,title:e.description,children:[e.group?`${e.group} · `:``,e.name]},e.value))},e.id):(0,I.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-fg-2`,title:e.description??e.name,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:e.value,disabled:r===e.id,onChange:t=>o(e,t.target.checked)}),` `,e.name]},e.id))]})}function Ko({id:e,agentName:t,agentDescription:n,channel:r,agents:i,onConverted:a}){let[o,s]=(0,v.useState)(null),c=N(`chats.list`,{})?.chats.find(t=>t.id===e)?.title;(0,v.useEffect)(()=>{c!==void 0&&s(e=>e&&e.title!==c?{...e,title:c}:e)},[c]);let[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),S=Te(),C=be(),w=N(`agents.list`,r?null:{},{interval:3e4})?.agents??[],T=o?.vibeable&&S.vibeables?o.vibeable:null,[E,D]=(0,v.useState)(null);(0,v.useEffect)(()=>T?(ja({chatId:e,slug:T}),D(document.getElementById(Aa)),()=>ja(null)):D(null),[e,T]);let O=(0,v.useMemo)(()=>so(l),[l]);(0,v.useEffect)(()=>{let t=!0,n;return A.call(`chats.get`,{id:e}).then(r=>{if(!t)return;s(r.meta),u(r.events);let i=r.events[r.events.length-1]?.seq??0;n=j.subscribe(`chat.${e}`,{after:i},e=>{let t=e;u(e=>e.some(e=>e.seq===t.seq)?e:[...e,t])})}).catch(()=>t&&f(!0)),()=>{t=!1,n?.()}},[e]);let k=(0,v.useMemo)(()=>{if(!r)return[];let e=new Set;for(let t of l)t.from?.kind===`agent`&&(t.type===`turn_start`&&e.add(t.from.slug),(t.type===`turn_end`||t.type===`error`)&&e.delete(t.from.slug));return[...e]},[l,r]),ee=(0,v.useMemo)(()=>{if(r)return k.length>0;for(let e=l.length-1;e>=0;e--){let t=l[e].type;if(t===`user_message`)return!0;if(t===`turn_end`||t===`error`)return!1}return!1},[l,r,k]),M=(0,v.useMemo)(()=>{if(o?.title)return o.title;let e=l.find(e=>e.type===`user_message`);return e&&e.type===`user_message`?e.text.replace(/\s+/g,` `).trim().slice(0,80):``},[o,l]);if((0,v.useEffect)(()=>o?r?(ce(`#${r.slug} · ${r.name}`),()=>ce(``)):(ce([t??(o.scope.kind===`agent`?o.scope.slug:o.agent),n,M||`new chat`].filter(Boolean).join(` · `)),()=>ce(``)):void 0,[o,M,t,n,r]),d)return(0,I.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!o)return(0,I.jsx)(Y,{children:`loading…`});let F=new Map((i??[]).map(e=>[e.slug,e]));if(r)return(0,I.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[(0,I.jsxs)(`div`,{className:`channel-head flex flex-none flex-wrap items-center gap-x-3 gap-y-2 pb-1.5`,children:[(0,I.jsx)($e,{tone:ee?`working`:`ok`}),(0,I.jsxs)(it,{children:[`#`,r.slug]}),(0,I.jsx)(`span`,{className:`text-md text-fg-2`,children:r.name}),(0,I.jsx)(`span`,{className:`flex-1`}),k.length>0&&(0,I.jsxs)(G,{size:`sm`,variant:`danger`,icon:`stop`,title:`interrupt every agent working in this channel`,onClick:()=>io(e),children:[`stop all (`,k.length,`)`]}),(0,I.jsx)(G,{size:`sm`,icon:`tune`,href:`/channels/${encodeURIComponent(r.slug)}/edit`,title:`members, purpose, responder`,children:`members`})]}),(0,I.jsxs)(`div`,{className:`channel-members flex flex-none flex-wrap items-center gap-x-2.5 gap-y-2 pb-3`,children:[r.purpose&&(0,I.jsx)(`span`,{className:`channel-purpose w-full text-sm text-fg-2`,children:r.purpose}),r.members.map(t=>{let n=F.get(t),i=k.includes(t),a=oo(l,t);return(0,I.jsxs)(`div`,{className:P(`member-chip inline-flex items-center gap-1 rounded-full py-[3px] pr-1.5 pl-[3px] text-sm transition-colors`,i?`bg-accent-soft`:`bg-surface-2`,b===t&&`outline-2 outline-accent`),title:n?.description,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 cursor-pointer items-center gap-2 border-0 bg-transparent p-0 text-left font-[inherit] text-inherit`,onClick:()=>x(b===t?null:t),title:b===t?`back to the channel`:`look at @${t}'s session`,children:[(0,I.jsxs)(`span`,{className:`relative grid size-7 flex-none place-items-center rounded-full bg-surface text-[15px]`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:n?.emoji??`🤖`}),(0,I.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 grid rounded-full bg-surface p-px`,children:(0,I.jsx)($e,{tone:i?`working`:`idle`})})]}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`font-medium text-fg`,children:n?.name??t}),(0,I.jsxs)(`span`,{className:`member-handle font-mono text-2xs text-fg-2`,children:[`@`,t]}),r.responder===t&&(0,I.jsx)(q,{children:`responder`})]}),(a.task||a.now)&&(0,I.jsx)(`span`,{className:`max-w-[44ch] truncate text-2xs text-fg-2`,children:i?a.now?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(nt,{className:`mr-1`,children:`now`}),` `,a.now]}):(0,I.jsxs)(I.Fragment,{children:[`working on: `,a.task]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(nt,{className:`mr-1`,children:`last`}),` `,a.task]})})]})]}),i&&(0,I.jsx)(K,{icon:`stop`,label:`interrupt @${t}`,variant:`danger`,size:`sm`,className:`size-6`,onClick:()=>io(e,t)}),(0,I.jsx)(K,{icon:`info`,label:`agent definition`,size:`sm`,className:`size-6`,href:`/agents/${encodeURIComponent(t)}/info`})]},t)})]}),b&&(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line py-1.5 text-sm`,children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_back`,onClick:()=>x(null),children:`channel`}),(0,I.jsxs)(`span`,{className:`min-w-0 truncate text-fg-2`,children:[F.get(b)?.emoji??`🤖`,` @`,b,`'s session — everything this agent did, tools included`]}),(0,I.jsx)(`span`,{className:`flex-1`}),k.includes(b)&&(0,I.jsxs)(G,{size:`sm`,variant:`danger`,icon:`stop`,onClick:()=>io(e,b),children:[`stop @`,b]})]}),(0,I.jsxs)(co.Provider,{value:e=>{let t=e?.kind===`agent`?F.get(e.slug):void 0;return e?.kind===`agent`?`${t?.emoji??`🤖`} ${t?.name??e.slug}`:`The agent`},children:[(0,I.jsx)(Po,{id:e,events:l,busy:ee,channel:r,agentMap:F,working:k,focus:b??void 0}),(0,I.jsx)(Uo,{id:e,busy:ee,scope:o.scope,channel:r,agentMap:F})]})]});let te=o.scope.kind===`agent`&&!o.scope.routine||o.scope.kind===`project`,R=O.auth?.kind===`none`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[o.scope.kind===`agent`&&!o.scope.routine&&(0,I.jsx)(Xa,{children:(0,I.jsx)(Jo,{id:e,project:o.project,onFiled:e=>s(t=>t&&{...t,project:e})})}),te&&(0,I.jsx)(Xa,{children:(0,I.jsx)(K,{size:`sm`,icon:`group_add`,label:`add coworker`,title:o.scope.kind===`project`?`add coworker: turn this chat into a channel of the project and invite agents`:`add coworker: turn this chat into a channel and invite more agents`,onClick:()=>m(!0),disabled:ee})}),(C||R)&&(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-2.5 gap-y-1.5 pb-1.5`,children:[C&&o.agent!==`pi`&&o.sessions?.main&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`call_split`,busy:h,className:o.agent===`codex`?`opacity-50`:void 0,disabled:ee,"aria-disabled":o.agent===`codex`,title:o.agent===`codex`?`not supported: codex has no session fork`:`Branch this conversation: a new chat with the same history, the original stays as it is`,onClick:async()=>{if(o.agent===`codex`)return y(`fork is not supported by codex`);g(!0);let t=await A.request(`chats.fork`,{id:e});if(g(!1),!t.ok||!t.data?.id)return alert(t.error??`fork failed (${t.status})`);let n=t.data;H(n.scope?.kind===`agent`?`/agents/${encodeURIComponent(n.scope.slug)}/chat/${n.id}`:`/agents/chats/${n.id}`)},children:h?`forking…`:`fork`}),C&&_&&(0,I.jsx)(`span`,{className:`text-2xs text-fg-2`,children:_}),C&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsx)(q,{children:o.agent})}),(0,I.jsx)(Go,{id:e,live:O}),C&&o.scope.kind===`run`&&(0,I.jsx)(qo,{href:`/runs/${o.scope.runId}`,children:o.scope.runId}),C&&o.scope.kind===`kraftwerk`&&(0,I.jsx)(q,{children:`kraftwerk-aware`}),C&&o.scope.kind===`knowledge`&&(0,I.jsxs)(qo,{href:o.scope.bundle?`/knowledge/${encodeURIComponent(o.scope.bundle)}`:`/knowledge`,children:[`knowledge`,o.scope.bundle?`:${o.scope.bundle}`:``]}),C&&o.scope.kind===`agent`&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsxs)(qo,{href:`/agents/${encodeURIComponent(o.scope.slug)}/info`,children:[`agent:`,o.scope.slug]})}),C&&(0,I.jsx)(`span`,{className:`rid max-w-[34ch] min-w-0 truncate font-mono text-xs text-fg-2 max-[800px]:hidden`,title:o.cwd,children:o.cwd})]}),o.vibeable&&!S.vibeables&&(0,I.jsx)(za,{chatId:e,slug:o.vibeable,onClosed:s}),(0,I.jsxs)(co.Provider,{value:()=>fo(o.scope,w,t),children:[(0,I.jsx)(Po,{id:e,events:l,busy:ee}),(0,I.jsx)(Uo,{id:e,busy:ee,scope:o.scope,commands:O.commands,canSteer:o.agent!==`pi`,account:O.auth&&O.auth.kind!==`none`?O.auth.email??O.auth.label:void 0})]})]}),T&&E&&(0,Oa.createPortal)((0,I.jsx)(Na,{chatId:e,slug:T,agentBusy:ee,onClosed:s},T),E),p&&o.scope.kind===`agent`&&(0,I.jsx)(Ja,{chatId:e,agentSlug:o.scope.slug,title:M,onClose:()=>m(!1)}),p&&o.scope.kind===`project`&&(0,I.jsx)(Ja,{chatId:e,project:o.scope.slug,title:M||t||``,onClose:()=>m(!1),onCreated:a})]})}function qo({href:e,children:t}){return(0,I.jsx)(U,{href:e,className:`no-underline hover:opacity-80`,children:(0,I.jsx)(q,{children:t})})}function Jo({id:e,project:t,onFiled:n}){let r=N(`projects.list`,{},{interval:6e4}),[i,a]=(0,v.useState)(!1),o=r?.enabled===!1?[]:r?.projects??[];return!o.length&&!t?null:(0,I.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-fg-2`,title:`file this chat under a project: the agent works in its context`,children:[(0,I.jsx)(R,{name:`folder`,className:`ms-sm`}),(0,I.jsxs)(bt,{"aria-label":`project`,className:`h-7 w-auto max-w-[180px] py-0 pl-2 text-sm`,value:t??``,disabled:i,onChange:async t=>{let r=t.target.value||null;a(!0);let i=await A.request(`chats.setProject`,{id:e,body:{project:r}}).catch(()=>null);a(!1),i?.ok&&n(r??void 0)},children:[(0,I.jsx)(`option`,{value:``,children:`no project`}),o.map(e=>(0,I.jsx)(`option`,{value:e.slug,children:e.title},e.slug))]})]})}async function Yo(e,t,n,r){let i=await A.request(`chats.create`,{body:{agent:e,scope:t,...n?{resume:n}:{},...r?{project:r}:{}}}),a=i.ok?i.data:null;a?.id&&H(a.project?`/projects/${encodeURIComponent(a.project)}/chat/${a.id}`:a.scope?.kind===`agent`?`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:a.scope?.kind===`project`?`/projects/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:`/agents/chats/${a.id}`)}function Xo({placeholder:e,byDefault:t,firstGroup:n,agentHint:r,exclude:i,placeOf:a,sessions:o,hrefOf:s,create:c,children:l}){let u=N(`agents.list`,{},{interval:3e4}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=(0,v.useRef)(null);(0,v.useEffect)(()=>{document.querySelector(`[role=dialog]`)||b.current?.focus()},[]);let x=(u?.agents??[]).filter(e=>!e.archived),S=x.filter(e=>e.slug!==i),C=n?S.filter(e=>n.slugs.has(e.slug)):[],w=n?S.filter(e=>!n.slugs.has(e.slug)):S,T=d?S.find(e=>e.slug===d):void 0,E=e=>{let t=x.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},D=async()=>{if(h)return;g(!0),y(``);let e=await c(d||void 0);if(`error`in e)return g(!1),y(e.error);let t=p.trim();if(t){let n=await A.request(`chats.message`,{id:e.id,body:{text:t}});if(!n.ok)return g(!1),y(M(n))}H(e.href)},O=T?`${T.emoji||`🤖`} ${T.name}`:`${t.emoji} ${t.name}`,k=(e,t)=>(0,I.jsx)($o,{emoji:e.emoji||`🤖`,name:e.name,sub:e.description,on:d===e.slug,onClick:()=>{f(e.slug),t()}},e.slug);return(0,I.jsxs)(`div`,{className:`session-home mx-auto flex w-full max-w-[760px] animate-rise flex-col gap-7 px-6 pt-8 pb-12 max-[800px]:px-3 max-[800px]:pt-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`rounded-[18px] border border-line bg-surface shadow-[0_1px_2px_rgb(0_0_0/0.04),0_4px_16px_rgb(0_0_0/0.04)] focus-within:border-line-strong`,children:[(0,I.jsx)(`textarea`,{ref:b,rows:2,value:p,"aria-label":`new session`,placeholder:e,className:`block max-h-[40vh] min-h-[64px] w-full resize-none rounded-t-[18px] border-0 bg-transparent px-4 pt-3.5 pb-1 font-[inherit] text-base text-fg shadow-none outline-none focus:shadow-none focus:outline-none focus-visible:outline-none placeholder:text-fg-2 [field-sizing:content]`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),D())}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-2.5`,children:[(0,I.jsx)(At,{className:`max-h-[50vh] overflow-y-auto`,trigger:({open:e,toggle:t})=>(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":e,"aria-label":`session with`,className:`inline-flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:t,children:[O,(0,I.jsx)(R,{name:`expand_more`,className:`ms-sm text-fg-2`})]}),children:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)($o,{emoji:t.emoji,name:`${t.name} (default)`,sub:t.sub,on:!d,onClick:()=>{f(``),e()}}),C.length>0&&n&&(0,I.jsx)(Qo,{children:n.label}),C.map(t=>k(t,e)),w.length>0&&(0,I.jsx)(Qo,{children:C.length>0?`other agents`:`agents`}),w.map(t=>k(t,e))]})}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2 max-[800px]:hidden`,children:T?r??``:t.hint??``}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`start session`,title:`start session (Enter)`,className:`inline-grid size-8 flex-none cursor-pointer place-items-center rounded-full bg-accent text-on-accent transition-[filter] hover:enabled:brightness-110 disabled:cursor-default disabled:opacity-60`,disabled:h,onClick:()=>void D(),children:(0,I.jsx)(R,{name:h?`progress_activity`:`arrow_upward`,className:`ms-sm`})})]})]}),_&&(0,I.jsx)(tt,{tone:`bad`,children:_})]}),l,(0,I.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`recent sessions`,children:[(0,I.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Recents`}),o&&o.length===0&&(0,I.jsx)(`p`,{className:`m-0 px-3 text-sm text-fg-2`,children:`No sessions yet — start one above.`}),(o??[]).map(e=>(0,I.jsx)(es,{chat:e,href:s(e),place:a?.(e),who:e.scope.kind===`channel`?`👥 coworkers · #${e.scope.slug}`:e.scope.kind===`agent`?E(e.scope.slug):e.scope.kind===`project`?`${Be.emoji} ${Be.name}`:`${t.emoji} ${t.name}`},e.id))]})]})}async function Zo(e,t){let n=await A.request(`chats.create`,{body:e});return n.ok?{id:n.data.id,href:t(n.data.id)}:{error:M(n)}}function Qo({children:e}){return(0,I.jsx)(`div`,{className:`mt-1.5 border-t border-line px-2 pt-2 pb-1 text-2xs font-semibold tracking-[0.06em] text-fg-2 uppercase`,children:e})}function $o({emoji:e,name:t,sub:n,on:r,onClick:i}){return(0,I.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,className:`flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,onClick:i,children:[(0,I.jsx)(`span`,{className:`w-5 flex-none text-center text-base leading-5`,children:e}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm text-fg`,children:t}),n&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:n})]}),r&&(0,I.jsx)(R,{name:`check`,className:`ms-sm mt-0.5 text-accent`})]})}function es({chat:e,href:t,who:n,place:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=$a(e,`new session`);return i?(0,I.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,I.jsx)(Za,{name:c,className:`w-full text-base`,onDone:t=>{a(!1),t&&A.request(`chats.rename`,{id:e.id,body:{title:t}}).catch(()=>null)}})}):(0,I.jsxs)(`div`,{className:`recent-session group/recent relative flex items-center rounded-card transition-colors hover:bg-surface-2 has-[[aria-expanded=true]]:bg-surface-2`,"data-chat":e.id,children:[(0,I.jsxs)(U,{href:t,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-2.5 text-[15px] text-fg no-underline`,children:[(e.busy||e.awaitingApproval)&&(0,I.jsx)($e,{tone:e.awaitingApproval?`bad`:`working`,title:e.awaitingApproval?`waiting for your approval`:`working`}),e.scope.kind===`channel`&&(0,I.jsx)(R,{name:`forum`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,I.jsx)(`span`,{className:`recent-place flex-none truncate text-xs text-fg-2`,children:r})]}),(0,I.jsx)(`span`,{className:`recent-agent flex-none truncate rounded-full bg-surface-2 px-2 py-0.5 text-xs text-fg-2 max-w-[40%]`,title:`session with ${n}`,children:n}),(0,I.jsx)(`span`,{className:`flex-none px-3 text-sm text-fg-2 tabular-nums group-hover/recent:hidden group-has-[[aria-expanded=true]]/recent:hidden`,title:e.updatedAt,children:W(e.updatedAt)}),(0,I.jsx)(`span`,{className:`hidden flex-none pr-1.5 group-hover/recent:inline-flex group-has-[[aria-expanded=true]]/recent:inline-flex pointer-coarse:inline-flex`,children:(0,I.jsx)(At,{align:`end`,trigger:({open:e,toggle:t})=>(0,I.jsx)(K,{icon:`more_horiz`,size:`sm`,label:`more for ${c}`,"aria-haspopup":`menu`,"aria-expanded":e,onClick:()=>{s(!1),t()}}),children:t=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qa,{icon:`edit`,label:`rename`,onClick:()=>{t(),a(!0)}}),(0,I.jsx)(Qa,{icon:`delete`,label:o?`confirm delete`:`delete`,danger:!0,onClick:()=>{if(!o)return s(!0);t(),A.request(`chats.delete`,{id:e.id}).catch(()=>null)}})]})})})]})}var ts=[`active`,`paused`,`done`,`archived`],ns={active:`working`,paused:`idle`,done:`ok`,archived:`idle`},rs={active:`accent`,paused:`neutral`,done:`ok`,archived:`neutral`},is={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,crm:`CRM`,newsletter:`Newsletter tool`,calendar:`Calendar`,"google-maps":`Google Maps`,url:`Link`},as=e=>is[e]??e,os=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`}],ss=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),cs=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),ls=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function us(e,t){let n=await A.request(`projects.save`,{slug:e,body:t});if(!n.ok)throw Error(M(n));return n.data}function ds({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=be(),l=(0,v.useCallback)(async()=>{try{let e=await A.request(`projects.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);a(e.data),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await l(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[l]),(0,v.useEffect)(()=>{l()},[t,n,l]);let u=i?.projects??[],d=t?u.find(e=>e.slug===t):void 0,f=[...u].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&f&&H(`/projects/${encodeURIComponent(f)}`,{replace:!0})},[n,f]);let p;return p=i&&!i.enabled?(0,I.jsx)(Y,{icon:`folder_off`,children:i.error&&!/are off/.test(i.error)?(0,I.jsx)(`span`,{className:`text-bad`,children:i.error}):(0,I.jsxs)(I.Fragment,{children:[`Projects are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&u.length===0?(0,I.jsx)(ps,{root:i.root,onCreated:l}):n===`home`?(0,I.jsx)(Y,{children:`loading…`}):t&&!d?(0,I.jsxs)(Y,{icon:`folder_off`,children:[`no project named `,t]}):n===`chat`&&t&&r===`new`?(0,I.jsx)(ms,{slug:t,title:d?.title??t},t):n===`chat`&&t&&r?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(hs,{chatId:r,title:d?.title??t,goal:d?.goal},r)}):n===`info`&&t?(0,I.jsx)(_s,{slug:t,onChanged:l},t):t?(0,I.jsx)(ms,{slug:t,title:d?.title??t},t):(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(Y,{children:`loading…`}),(0,I.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t&&d?`in-project`:``}`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`projects`,count:i?.enabled?u.length:void 0,action:i?.enabled&&(c||u.length===0)&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/projects/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[u.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,innerProps:{"data-project":e.slug},leading:(0,I.jsx)($e,{tone:e.configError?`bad`:ns[e.status],title:e.status}),title:e.title,sub:e.configError?e.configError:e.goal||e.status,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,I.jsx)(`span`,{title:e.updatedAt,children:W(e.updatedAt)})},e.slug)),i&&i.enabled&&u.length===0&&(0,I.jsx)(kt,{children:`no projects yet`}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:p})]})}function fs(){let e=N(`projects.list`,{},{interval:6e4});return e&&!e.enabled?(0,I.jsxs)(Y,{icon:`folder_off`,children:[`Projects are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),`.`]}):(0,I.jsx)(ps,{root:e?.root,onCreated:async()=>{}})}function ps({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await A.request(`projects.create`,{body:{title:r,goal:i.trim()}});if(!e.ok)throw Error(M(e));let n=e.data;H(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,I.jsxs)(`form`,{className:`new-chat mx-auto flex w-full max-w-[640px] animate-rise flex-col gap-4`,onSubmit:e=>void u(e),children:[(0,I.jsx)(it,{size:`lg`,children:`new project`}),(0,I.jsx)(X,{children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})}),(0,I.jsx)(Q,{label:`goal (one line)`,children:(0,I.jsx)(Z,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(G,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim(),children:o?`creating…`:`create project`})}),c&&(0,I.jsx)(tt,{tone:`bad`,children:c}),(0,I.jsxs)(J,{children:[`One folder each under `,(0,I.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function ms({slug:e,title:t}){let n=Te(),r=N(`projects.get`,{slug:e}),i=N(`chats.list`,{}),a=os.find(e=>e.id===r?.harness)??os[0],o=n.vibeables?(r?.links.vibeables??[]).filter(e=>e.found).map(e=>e.slug):[],s=t=>`/projects/${encodeURIComponent(e)}/chat/${t}`;return(0,I.jsx)(Xo,{placeholder:`New session in ${t}`,byDefault:{...Be,sub:r?`the project's assistant · ${ss(r)}`:`the project's assistant`,hint:r?ss(r):``},firstGroup:{label:`agents of the project`,slugs:new Set((r?.links.agents??[]).map(e=>e.slug))},agentHint:`works with the project's context`,sessions:i?cs(i.chats,e):null,hrefOf:t=>ls(t,e),create:t=>Zo(t?{agent:`claude`,scope:{kind:`agent`,slug:t},project:e}:{agent:a.id,scope:{kind:`project`,slug:e}},s),children:o.length>0&&(0,I.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`pinned apps`,children:[(0,I.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Apps`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 px-1`,children:o.map(t=>(0,I.jsxs)(U,{href:`/projects/${encodeURIComponent(e)}?app=${encodeURIComponent(t)}`,className:`pinned-app flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5 text-sm text-fg no-underline hover:bg-surface-2`,title:`open ${t} beside the project's chat`,"data-app":t,children:[(0,I.jsx)(R,{name:`web`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]},t))})]})})}function hs({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return A.call(`chats.get`,{id:e}).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=r?.kind===`agent`?r.slug:void 0,d=N(`channels.list`,l?{}:null,{interval:4e3}),f=N(`agents.list`,l||u?{}:null,{interval:8e3});if(a)return(0,I.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!r)return(0,I.jsx)(Y,{children:`loading…`});if(l){let t=d?.channels.find(e=>e.slug===l);return d?t?(0,I.jsx)(Ko,{id:e,channel:t,agents:f?.agents??[]},`${e}:channel`):(0,I.jsxs)(Y,{icon:`forum`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,I.jsx)(Y,{children:`loading…`})}if(u){let t=f?.agents.find(e=>e.slug===u);return f?(0,I.jsx)(Ko,{id:e,agentName:t?`${t.emoji||`🤖`} ${t.name}`:u,agentDescription:t?.description,onConverted:()=>c(e=>e+1)},`${e}:${s}`):(0,I.jsx)(Y,{children:`loading…`})}return(0,I.jsx)(Ko,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}var gs=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`apps`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`},{kind:`contacts`,label:`contacts`,icon:`person`,href:e=>`/contacts/${encodeURIComponent(e)}`},{kind:`places`,label:`places`,icon:`location_on`,href:e=>`/places/${encodeURIComponent(e)}`},{kind:`events`,label:`events`,icon:`event`,href:e=>`/events/${encodeURIComponent(e)}`}];function _s({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`active`),[x,S]=(0,v.useState)(`claude`),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),F=be(),te=Te(),R=e=>{r(e),h(e.title),_(e.goal),b(e.status),S(e.harness),w(e.model??``),E(e.effort??``),O(e.brief),ee(e.state),M(!1)};(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&R(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let z=()=>{M(!0),d(!1),s(``)},ne=async(n,i={})=>{l(!0),s(``);try{let a=await us(e,n);i.keepEdits?r(a):R(a),d(!i.keepEdits),await t()}catch(e){s(e.message)}finally{l(!1)}},re=async()=>{l(!0);try{let n=await A.request(`projects.delete`,{slug:e});if(!n.ok)throw Error(n.error||`failed`);await t(),H(`/`,{replace:!0})}catch(e){s(e.message),l(!1)}},ie=async()=>{let t=N.trim();if(t){l(!0),s(``);try{let n=await A.request(`projects.log`,{slug:e,body:{entry:t}});if(!n.ok)throw Error(n.error||`failed`);let i=n.data;P(``),r(e=>e&&{...e,log:i.log??e.log})}catch(e){s(e.message)}finally{l(!1)}}};return i?(0,I.jsx)(Y,{icon:`folder_off`,children:`project not found`}):n?(0,I.jsxs)(`div`,{className:`chat-main project-page flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,I.jsx)(st,{children:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`})}),(0,I.jsx)(it,{size:`lg`,children:n.title}),(0,I.jsx)(q,{tone:rs[n.status],children:n.status}),(0,I.jsx)(q,{title:`harness · model · effort every chat in this project runs on`,children:ss(n)}),F&&(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-fg-2`,title:n.path,children:n.path})]}),n.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`project.yml: `,n.configError]}),(0,I.jsx)(X,{title:`project`,className:`flex-none`,actions:(0,I.jsxs)(I.Fragment,{children:[u&&!j&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`saved`}),(0,I.jsx)(G,{variant:`primary`,size:`sm`,busy:c,disabled:!j,onClick:()=>void ne({title:m,goal:g,status:y,harness:x,model:C,effort:T,brief:D,state:k}),children:c?`saving…`:`save changes`})]}),children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Z,{value:m,"aria-label":`title`,onChange:e=>{h(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`status`,children:(0,I.jsx)(bt,{value:y,"aria-label":`status`,onChange:e=>{b(e.target.value),z()},children:ts.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})})]}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`harness`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(bt,{value:x,"aria-label":`harness`,onChange:e=>{S(e.target.value),z()},children:os.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,I.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Z,{value:C,"aria-label":`model`,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>{w(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`effort`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(bt,{value:T,"aria-label":`effort`,onChange:e=>{E(e.target.value),z()},children:qe.map(e=>(0,I.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,I.jsx)(Q,{label:`goal (one line)`,children:(0,I.jsx)(Z,{value:g,"aria-label":`goal`,placeholder:`what the project is for`,onChange:e=>{_(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`brief.md — what done looks like, constraints, stakeholders`,children:(0,I.jsx)(yt,{rows:10,className:`resize-y font-mono text-sm`,value:D,"aria-label":`brief`,onChange:e=>{O(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`state.md — current state, rewritten at the end of a session`,children:(0,I.jsx)(yt,{rows:6,className:`resize-y font-mono text-sm`,value:k,"aria-label":`state`,onChange:e=>{ee(e.target.value),z()}})}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})}),(0,I.jsx)(Ss,{records:n.records,saving:c,onSave:e=>ne({records:e},{keepEdits:!0})}),(0,I.jsx)(X,{title:`links`,className:`flex-none`,actions:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`by name; a target that is missing in this workspace is marked`}),children:(0,I.jsx)(ut,{children:gs.filter(e=>e.kind!==`contacts`&&e.kind!==`places`&&e.kind!==`events`||te[e.kind]).map(i=>(0,I.jsx)(bs,{kind:i.kind,label:i.label,icon:i.icon,href:i.href,links:n.links[i.kind],saving:c,onChange:(n,a)=>void vs(e,i.kind,n,a,e=>{r(e),t()},s)},i.kind))})}),(0,I.jsxs)(X,{title:`log`,className:`flex-none`,children:[(0,I.jsx)(xt,{className:`max-w-[680px]`,children:(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`new entry — a decision, a milestone`,className:`flex-1`,children:(0,I.jsx)(Z,{value:N,"aria-label":`log entry`,placeholder:`e.g. Decided on NodeHive as the CMS`,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ie())}})}),(0,I.jsx)(G,{icon:`add`,disabled:c||!N.trim(),onClick:()=>void ie(),children:`log`})]})}),(0,I.jsx)(`div`,{className:`md-body h-auto overflow-visible px-[18px] pt-1 pb-4 text-sm [&_h1]:hidden [&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-xs [&_ul]:m-0 [&_ul]:pl-[18px]`,dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parse(n.log||`_no entries yet_`,{async:!1}))}})]}),(0,I.jsx)(X,{title:`danger zone`,className:`flex-none [&>div]:border-b-0`,actions:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>void re(),children:`confirm delete`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>p(!1),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>p(!0),title:`Move the project, its files and log to the trash; #/trash puts it back`,children:`delete project`}),children:null})]}):(0,I.jsx)(Y,{children:`loading…`})}async function vs(e,t,n,r,i,a){try{let a=await A.request(`projects.link`,{slug:e,body:{kind:t,target:n,remove:r}});if(!a.ok)throw Error(M(a));i(a.data)}catch(e){a(e.message)}}async function ys(e){switch(e){case`knowledge`:return(await A.call(`knowledge.list`)).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await A.call(`vibeables.list`)).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await A.call(`repos.list`)).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await A.call(`workflows.list`)).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await A.call(`agents.list`)).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}));case`contacts`:return(await A.call(`contacts.list`)).items.map(e=>({slug:e.slug,hint:[e.role,e.org].filter(Boolean).join(`, `)||void 0}));case`places`:return(await A.call(`places.list`)).items.map(e=>({slug:e.slug,hint:e.address}));case`events`:return(await A.call(`events.list`)).items.map(e=>({slug:e.slug,hint:e.start}))}}function bs({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return ys(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,I.jsxs)(lt,{icon:n,title:t,"data-link-kind":e,action:!s&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>c(!0),children:`link`}),children:[i.length===0&&!s&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none linked`}),i.length>0&&(0,I.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,I.jsxs)(q,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,I.jsx)(U,{href:r(e.slug),className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`,(0,I.jsx)(`button`,{type:`button`,className:`-mr-1 ml-1 inline-grid size-4 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-inherit opacity-70 hover:bg-surface hover:opacity-100 disabled:cursor-default [&_.ms]:text-[13px]`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,I.jsx)(R,{name:`close`})})]},e.slug))}),s&&(0,I.jsx)(`span`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:l===null?(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`loading…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(bt,{className:`w-auto max-w-full min-w-48 flex-1`,"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,I.jsx)(G,{disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>c(!1),children:`cancel`})]})})]})}var xs={kind:`url`};function Ss({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??xs,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,I.jsx)(X,{title:`systems of record`,className:`flex-none`,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>i({...xs}),children:`add`})]}),children:(0,I.jsxs)(ut,{children:[e.map((r,i)=>(0,I.jsx)(lt,{"data-record-kind":r.kind,icon:`database`,title:(0,I.jsxs)(I.Fragment,{children:[as(r.kind),r.title&&(0,I.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,children:r.title}),r.workspace&&(0,I.jsxs)(q,{children:[`workspace `,r.workspace]})]}),action:(0,I.jsx)(K,{icon:`close`,size:`sm`,label:`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i))}),children:(r.url||r.note)&&(0,I.jsxs)(`span`,{className:`text-xs leading-normal text-fg-2`,children:[r.url&&(0,I.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})},i)),e.length===0&&!r&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`kind`,children:a?(0,I.jsx)(Z,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,I.jsxs)(bt,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(is).map(([e,t])=>(0,I.jsx)(`option`,{value:e,children:t},e)),(0,I.jsx)(`option`,{value:`__other`,children:`other…`})]})}),(0,I.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Z,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})}),(0,I.jsx)(Q,{label:`workspace / id`,children:(0,I.jsx)(Z,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})})]}),(0,I.jsx)(Q,{label:`url`,children:(0,I.jsx)(Z,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`note — what lives there and how it is usually reached`,className:`flex-1`,children:(0,I.jsx)(Z,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})}),(0,I.jsx)(G,{disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})})}async function Cs(e,t){let n=window.open(``,`_blank`);if(!n)return;let r=t?`${e}/${t}`:e;n.document.write(`<title>${Ds(r)}</title><body style="font-family:system-ui;padding:40px;color:#555">preparing ${Ds(r)}…</body>`);let i,a=``;try{let[n,r]=await Promise.all([t?Promise.resolve([t]):A.call(`knowledge.get`,{bundle:e}).then(e=>e.concepts.map(e=>e.id)),A.call(`meta.get`).catch(()=>({}))]);if(a=r.workspaceName??``,i=await Promise.all(n.map(t=>A.call(`knowledge.concept`,{bundle:e,query:{id:t}}))),i.some(e=>typeof e?.id!=`string`))throw Error(`missing concept`)}catch{n.document.body.textContent=`could not load "${r}"`;return}let o=[],s=i.map(e=>{let t=[e.type,e.generated?.at?`updated ${e.generated.at.slice(0,10)}`:``,e.trustTier===`human-reviewed`?`human-reviewed`:``,(e.tags??[]).map(e=>`#${e}`).join(` `)].filter(Boolean).join(` · `),{md:n,notes:r}=Ts(ws(e.body??``,null)),i=!e.title||e.title===e.id||e.title===e.id.split(`/`).pop(),{html:a,title:s}=Es(Da.sanitize(Jr.parse(n,{async:!1})),{title:e.title||e.id,meta:t,titleIsFallback:i});return o.push(s),`<article>
86
+ `).length)),onChange:e=>{l(e.target.value),w(0),E(!1)},onPaste:e=>{let t=Array.from(e.clipboardData.items).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),b(t))},onKeyDown:e=>{if(V){if(e.key===`ArrowDown`)return e.preventDefault(),w((fe+1)%B.length);if(e.key===`ArrowUp`)return e.preventDefault(),w((fe-1+B.length)%B.length);if(e.key===`Tab`||e.key===`Enter`)return e.preventDefault(),B[fe].pick();if(e.key===`Escape`)return e.preventDefault(),E(!0)}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}}),t&&(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,className:`mr-1 self-center`,onClick:()=>A.request(`chats.cancel`,{id:e}).catch(()=>{}),children:`stop`}),!te&&(0,I.jsx)(K,{icon:`attach_file`,label:`attach files (or drop / paste them)`,className:`size-9 rounded-full [&_.ms]:text-[20px]`,onClick:()=>M.current?.click()}),(0,I.jsx)(`input`,{ref:M,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&b(e.target.files),e.target.value=``}}),!te&&(0,I.jsx)(`button`,{type:`button`,className:`inline-grid size-9 flex-none cursor-pointer place-items-center rounded-full border-0 bg-accent p-0 text-on-accent transition-[filter,opacity] hover:enabled:brightness-110 active:enabled:scale-95 disabled:cursor-default disabled:opacity-30`,disabled:!c.trim()&&p.length===0||h>0,onClick:H,"aria-label":F?`steer`:`send`,title:F?`steer: hand this into the running turn (Enter)`:`send (Enter)`,children:(0,I.jsx)(R,{name:F?`alt_route`:`send`,className:`text-[19px]`})})]})]})}var Wo=`inline-flex items-center gap-1.5 rounded-full border border-line bg-surface-2 px-2 py-0.5 text-2xs text-fg-2`;function Go({id:e,live:t}){let n=be(),[r,i]=(0,v.useState)(null),a=t.config.filter(e=>e.category===`model`||e.category===`thought_level`);async function o(t,n){i(t.id);let r=await A.request(`chats.config`,{id:e,body:{configId:t.id,value:n}}).catch(()=>null);i(null),r&&!r.ok&&alert(r.error??`setting refused (${r.status})`)}return(0,I.jsxs)(I.Fragment,{children:[t.auth?.kind===`none`&&(0,I.jsx)(`span`,{title:[t.auth.detail,t.auth.email,t.auth.organization,t.auth.plan].filter(Boolean).join(` · `),children:(0,I.jsxs)(q,{tone:t.auth.kind===`none`?`bad`:`neutral`,children:[(0,I.jsx)(R,{name:t.auth.kind===`none`?`person_off`:`person`,className:`ms-sm mr-1`}),` `,t.auth.email??t.auth.label]})}),n&&t.usage&&t.usage.size>0&&(0,I.jsx)(`span`,{className:`font-mono`,title:`${t.usage.used.toLocaleString()} of ${t.usage.size.toLocaleString()} context tokens${t.usage.costUsd==null?``:` · $${t.usage.costUsd.toFixed(2)} so far`}`,children:(0,I.jsxs)(q,{children:[Math.round(100*t.usage.used/t.usage.size),`% ctx`,t.usage.costUsd!=null&&` · $${t.usage.costUsd.toFixed(2)}`]})}),n&&a.map(e=>e.type===`select`?(0,I.jsx)(bt,{className:`h-7 w-auto max-w-[22ch] px-2 pr-6 text-xs text-fg-2`,value:e.value,disabled:r===e.id,title:e.description??e.name,"aria-label":e.name,onChange:t=>o(e,t.target.value),children:e.choices.map(e=>(0,I.jsxs)(`option`,{value:e.value,title:e.description,children:[e.group?`${e.group} · `:``,e.name]},e.value))},e.id):(0,I.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-fg-2`,title:e.description??e.name,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:e.value,disabled:r===e.id,onChange:t=>o(e,t.target.checked)}),` `,e.name]},e.id))]})}function Ko({id:e,agentName:t,agentDescription:n,channel:r,agents:i,onConverted:a}){let[o,s]=(0,v.useState)(null),c=N(`chats.list`,{})?.chats.find(t=>t.id===e)?.title;(0,v.useEffect)(()=>{c!==void 0&&s(e=>e&&e.title!==c?{...e,title:c}:e)},[c]);let[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),S=Te(),C=be(),w=N(`agents.list`,r?null:{},{interval:3e4})?.agents??[],T=o?.vibeable&&S.vibeables?o.vibeable:null,[E,D]=(0,v.useState)(null);(0,v.useEffect)(()=>T?(ja({chatId:e,slug:T}),D(document.getElementById(Aa)),()=>ja(null)):D(null),[e,T]);let O=(0,v.useMemo)(()=>so(l),[l]);(0,v.useEffect)(()=>{let t=!0,n;return A.call(`chats.get`,{id:e}).then(r=>{if(!t)return;s(r.meta),u(r.events);let i=r.events[r.events.length-1]?.seq??0;n=j.subscribe(`chat.${e}`,{after:i},e=>{let t=e;u(e=>e.some(e=>e.seq===t.seq)?e:[...e,t])})}).catch(()=>t&&f(!0)),()=>{t=!1,n?.()}},[e]);let k=(0,v.useMemo)(()=>{if(!r)return[];let e=new Set;for(let t of l)t.from?.kind===`agent`&&(t.type===`turn_start`&&e.add(t.from.slug),(t.type===`turn_end`||t.type===`error`)&&e.delete(t.from.slug));return[...e]},[l,r]),ee=(0,v.useMemo)(()=>{if(r)return k.length>0;for(let e=l.length-1;e>=0;e--){let t=l[e].type;if(t===`user_message`)return!0;if(t===`turn_end`||t===`error`)return!1}return!1},[l,r,k]),M=(0,v.useMemo)(()=>{if(o?.title)return o.title;let e=l.find(e=>e.type===`user_message`);return e&&e.type===`user_message`?e.text.replace(/\s+/g,` `).trim().slice(0,80):``},[o,l]);if((0,v.useEffect)(()=>o?r?(ce(`#${r.slug} · ${r.name}`),()=>ce(``)):(ce([t??(o.scope.kind===`agent`?o.scope.slug:o.agent),n,M||`new chat`].filter(Boolean).join(` · `)),()=>ce(``)):void 0,[o,M,t,n,r]),d)return(0,I.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!o)return(0,I.jsx)(Y,{children:`loading…`});let F=new Map((i??[]).map(e=>[e.slug,e]));if(r)return(0,I.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[(0,I.jsxs)(`div`,{className:`channel-head flex flex-none flex-wrap items-center gap-x-3 gap-y-2 pb-1.5`,children:[(0,I.jsx)($e,{tone:ee?`working`:`ok`}),(0,I.jsxs)(it,{children:[`#`,r.slug]}),(0,I.jsx)(`span`,{className:`text-md text-fg-2`,children:r.name}),(0,I.jsx)(`span`,{className:`flex-1`}),k.length>0&&(0,I.jsxs)(G,{size:`sm`,variant:`danger`,icon:`stop`,title:`interrupt every agent working in this channel`,onClick:()=>io(e),children:[`stop all (`,k.length,`)`]}),(0,I.jsx)(G,{size:`sm`,icon:`tune`,href:`/channels/${encodeURIComponent(r.slug)}/edit`,title:`members, purpose, responder`,children:`members`})]}),(0,I.jsxs)(`div`,{className:`channel-members flex flex-none flex-wrap items-center gap-x-2.5 gap-y-2 pb-3`,children:[r.purpose&&(0,I.jsx)(`span`,{className:`channel-purpose w-full text-sm text-fg-2`,children:r.purpose}),r.members.map(t=>{let n=F.get(t),i=k.includes(t),a=oo(l,t);return(0,I.jsxs)(`div`,{className:P(`member-chip inline-flex items-center gap-1 rounded-full py-[3px] pr-1.5 pl-[3px] text-sm transition-colors`,i?`bg-accent-soft`:`bg-surface-2`,b===t&&`outline-2 outline-accent`),title:n?.description,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 cursor-pointer items-center gap-2 border-0 bg-transparent p-0 text-left font-[inherit] text-inherit`,onClick:()=>x(b===t?null:t),title:b===t?`back to the channel`:`look at @${t}'s session`,children:[(0,I.jsxs)(`span`,{className:`relative grid size-7 flex-none place-items-center rounded-full bg-surface text-[15px]`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:n?.emoji??`🤖`}),(0,I.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 grid rounded-full bg-surface p-px`,children:(0,I.jsx)($e,{tone:i?`working`:`idle`})})]}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`font-medium text-fg`,children:n?.name??t}),(0,I.jsxs)(`span`,{className:`member-handle font-mono text-2xs text-fg-2`,children:[`@`,t]}),r.responder===t&&(0,I.jsx)(q,{children:`responder`})]}),(a.task||a.now)&&(0,I.jsx)(`span`,{className:`max-w-[44ch] truncate text-2xs text-fg-2`,children:i?a.now?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(nt,{className:`mr-1`,children:`now`}),` `,a.now]}):(0,I.jsxs)(I.Fragment,{children:[`working on: `,a.task]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(nt,{className:`mr-1`,children:`last`}),` `,a.task]})})]})]}),i&&(0,I.jsx)(K,{icon:`stop`,label:`interrupt @${t}`,variant:`danger`,size:`sm`,className:`size-6`,onClick:()=>io(e,t)}),(0,I.jsx)(K,{icon:`info`,label:`agent definition`,size:`sm`,className:`size-6`,href:`/agents/${encodeURIComponent(t)}/info`})]},t)})]}),b&&(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line py-1.5 text-sm`,children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_back`,onClick:()=>x(null),children:`channel`}),(0,I.jsxs)(`span`,{className:`min-w-0 truncate text-fg-2`,children:[F.get(b)?.emoji??`🤖`,` @`,b,`'s session — everything this agent did, tools included`]}),(0,I.jsx)(`span`,{className:`flex-1`}),k.includes(b)&&(0,I.jsxs)(G,{size:`sm`,variant:`danger`,icon:`stop`,onClick:()=>io(e,b),children:[`stop @`,b]})]}),(0,I.jsxs)(co.Provider,{value:e=>{let t=e?.kind===`agent`?F.get(e.slug):void 0;return e?.kind===`agent`?`${t?.emoji??`🤖`} ${t?.name??e.slug}`:`The agent`},children:[(0,I.jsx)(Po,{id:e,events:l,busy:ee,channel:r,agentMap:F,working:k,focus:b??void 0}),(0,I.jsx)(Uo,{id:e,busy:ee,scope:o.scope,channel:r,agentMap:F})]})]});let te=(o.scope.kind===`agent`||o.scope.kind===`project`)&&!o.scope.routine,R=O.auth?.kind===`none`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`chat-thread flex min-h-0 w-full flex-1 animate-rise flex-col`,children:[o.scope.kind===`agent`&&!o.scope.routine&&(0,I.jsx)(Xa,{children:(0,I.jsx)(Jo,{id:e,project:o.project,onFiled:e=>s(t=>t&&{...t,project:e})})}),te&&(0,I.jsx)(Xa,{children:(0,I.jsx)(K,{size:`sm`,icon:`group_add`,label:`add coworker`,title:o.scope.kind===`project`?`add coworker: turn this chat into a channel of the project and invite agents`:`add coworker: turn this chat into a channel and invite more agents`,onClick:()=>m(!0),disabled:ee})}),(C||R)&&(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-2.5 gap-y-1.5 pb-1.5`,children:[C&&o.agent!==`pi`&&o.sessions?.main&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`call_split`,busy:h,className:o.agent===`codex`?`opacity-50`:void 0,disabled:ee,"aria-disabled":o.agent===`codex`,title:o.agent===`codex`?`not supported: codex has no session fork`:`Branch this conversation: a new chat with the same history, the original stays as it is`,onClick:async()=>{if(o.agent===`codex`)return y(`fork is not supported by codex`);g(!0);let t=await A.request(`chats.fork`,{id:e});if(g(!1),!t.ok||!t.data?.id)return alert(t.error??`fork failed (${t.status})`);let n=t.data;H(n.scope?.kind===`agent`?`/agents/${encodeURIComponent(n.scope.slug)}/chat/${n.id}`:`/agents/chats/${n.id}`)},children:h?`forking…`:`fork`}),C&&_&&(0,I.jsx)(`span`,{className:`text-2xs text-fg-2`,children:_}),C&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsx)(q,{children:o.agent})}),(0,I.jsx)(Go,{id:e,live:O}),C&&o.scope.kind===`run`&&(0,I.jsx)(qo,{href:`/runs/${o.scope.runId}`,children:o.scope.runId}),C&&o.scope.kind===`kraftwerk`&&(0,I.jsx)(q,{children:`kraftwerk-aware`}),C&&o.scope.kind===`knowledge`&&(0,I.jsxs)(qo,{href:o.scope.bundle?`/knowledge/${encodeURIComponent(o.scope.bundle)}`:`/knowledge`,children:[`knowledge`,o.scope.bundle?`:${o.scope.bundle}`:``]}),C&&o.scope.kind===`agent`&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsxs)(qo,{href:`/agents/${encodeURIComponent(o.scope.slug)}/info`,children:[`agent:`,o.scope.slug]})}),C&&(0,I.jsx)(`span`,{className:`rid max-w-[34ch] min-w-0 truncate font-mono text-xs text-fg-2 max-[800px]:hidden`,title:o.cwd,children:o.cwd})]}),o.vibeable&&!S.vibeables&&(0,I.jsx)(za,{chatId:e,slug:o.vibeable,onClosed:s}),(0,I.jsxs)(co.Provider,{value:()=>fo(o.scope,w,t),children:[(0,I.jsx)(Po,{id:e,events:l,busy:ee}),(0,I.jsx)(Uo,{id:e,busy:ee,scope:o.scope,commands:O.commands,canSteer:o.agent!==`pi`,account:O.auth&&O.auth.kind!==`none`?O.auth.email??O.auth.label:void 0})]})]}),T&&E&&(0,Oa.createPortal)((0,I.jsx)(Na,{chatId:e,slug:T,agentBusy:ee,onClosed:s},T),E),p&&o.scope.kind===`agent`&&(0,I.jsx)(Ja,{chatId:e,agentSlug:o.scope.slug,title:M,onClose:()=>m(!1)}),p&&o.scope.kind===`project`&&(0,I.jsx)(Ja,{chatId:e,project:o.scope.slug,title:M||t||``,onClose:()=>m(!1),onCreated:a})]})}function qo({href:e,children:t}){return(0,I.jsx)(U,{href:e,className:`no-underline hover:opacity-80`,children:(0,I.jsx)(q,{children:t})})}function Jo({id:e,project:t,onFiled:n}){let r=N(`projects.list`,{},{interval:6e4}),[i,a]=(0,v.useState)(!1),o=r?.enabled===!1?[]:r?.projects??[];return!o.length&&!t?null:(0,I.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-fg-2`,title:`file this chat under a project: the agent works in its context`,children:[(0,I.jsx)(R,{name:`folder`,className:`ms-sm`}),(0,I.jsxs)(bt,{"aria-label":`project`,className:`h-7 w-auto max-w-[180px] py-0 pl-2 text-sm`,value:t??``,disabled:i,onChange:async t=>{let r=t.target.value||null;a(!0);let i=await A.request(`chats.setProject`,{id:e,body:{project:r}}).catch(()=>null);a(!1),i?.ok&&n(r??void 0)},children:[(0,I.jsx)(`option`,{value:``,children:`no project`}),o.map(e=>(0,I.jsx)(`option`,{value:e.slug,children:e.title},e.slug))]})]})}async function Yo(e,t,n,r){let i=await A.request(`chats.create`,{body:{agent:e,scope:t,...n?{resume:n}:{},...r?{project:r}:{}}}),a=i.ok?i.data:null;a?.id&&H(a.project?`/projects/${encodeURIComponent(a.project)}/chat/${a.id}`:a.scope?.kind===`agent`?`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:a.scope?.kind===`project`?`/projects/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`:`/agents/chats/${a.id}`)}function Xo({placeholder:e,byDefault:t,firstGroup:n,agentHint:r,exclude:i,placeOf:a,sessions:o,hrefOf:s,create:c,children:l}){let u=N(`agents.list`,{},{interval:3e4}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=(0,v.useRef)(null);(0,v.useEffect)(()=>{document.querySelector(`[role=dialog]`)||b.current?.focus()},[]);let x=(u?.agents??[]).filter(e=>!e.archived),S=x.filter(e=>e.slug!==i),C=n?S.filter(e=>n.slugs.has(e.slug)):[],w=n?S.filter(e=>!n.slugs.has(e.slug)):S,T=d?S.find(e=>e.slug===d):void 0,E=e=>{let t=x.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e},D=async()=>{if(h)return;g(!0),y(``);let e=await c(d||void 0);if(`error`in e)return g(!1),y(e.error);let t=p.trim();if(t){let n=await A.request(`chats.message`,{id:e.id,body:{text:t}});if(!n.ok)return g(!1),y(M(n))}H(e.href)},O=T?`${T.emoji||`🤖`} ${T.name}`:`${t.emoji} ${t.name}`,k=(e,t)=>(0,I.jsx)($o,{emoji:e.emoji||`🤖`,name:e.name,sub:e.description,on:d===e.slug,onClick:()=>{f(e.slug),t()}},e.slug);return(0,I.jsxs)(`div`,{className:`session-home mx-auto flex w-full max-w-[760px] animate-rise flex-col gap-7 px-6 pt-8 pb-12 max-[800px]:px-3 max-[800px]:pt-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`rounded-[18px] border border-line bg-surface shadow-[0_1px_2px_rgb(0_0_0/0.04),0_4px_16px_rgb(0_0_0/0.04)] focus-within:border-line-strong`,children:[(0,I.jsx)(`textarea`,{ref:b,rows:2,value:p,"aria-label":`new session`,placeholder:e,className:`block max-h-[40vh] min-h-[64px] w-full resize-none rounded-t-[18px] border-0 bg-transparent px-4 pt-3.5 pb-1 font-[inherit] text-base text-fg shadow-none outline-none focus:shadow-none focus:outline-none focus-visible:outline-none placeholder:text-fg-2 [field-sizing:content]`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),D())}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 pb-2.5`,children:[(0,I.jsx)(At,{className:`max-h-[50vh] overflow-y-auto`,trigger:({open:e,toggle:t})=>(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":e,"aria-label":`session with`,className:`inline-flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-sm font-medium text-fg transition-colors hover:bg-surface-2`,onClick:t,children:[O,(0,I.jsx)(R,{name:`expand_more`,className:`ms-sm text-fg-2`})]}),children:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)($o,{emoji:t.emoji,name:`${t.name} (default)`,sub:t.sub,on:!d,onClick:()=>{f(``),e()}}),C.length>0&&n&&(0,I.jsx)(Qo,{children:n.label}),C.map(t=>k(t,e)),w.length>0&&(0,I.jsx)(Qo,{children:C.length>0?`other agents`:`agents`}),w.map(t=>k(t,e))]})}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2 max-[800px]:hidden`,children:T?r??``:t.hint??``}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`start session`,title:`start session (Enter)`,className:`inline-grid size-8 flex-none cursor-pointer place-items-center rounded-full bg-accent text-on-accent transition-[filter] hover:enabled:brightness-110 disabled:cursor-default disabled:opacity-60`,disabled:h,onClick:()=>void D(),children:(0,I.jsx)(R,{name:h?`progress_activity`:`arrow_upward`,className:`ms-sm`})})]})]}),_&&(0,I.jsx)(tt,{tone:`bad`,children:_})]}),l,(0,I.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`recent sessions`,children:[(0,I.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Recents`}),o&&o.length===0&&(0,I.jsx)(`p`,{className:`m-0 px-3 text-sm text-fg-2`,children:`No sessions yet — start one above.`}),(o??[]).map(e=>(0,I.jsx)(es,{chat:e,href:s(e),place:a?.(e),who:e.scope.kind===`channel`?`👥 coworkers · #${e.scope.slug}`:e.scope.kind===`agent`?E(e.scope.slug):e.scope.kind===`project`?`${Be.emoji} ${Be.name}`:`${t.emoji} ${t.name}`},e.id))]})]})}async function Zo(e,t){let n=await A.request(`chats.create`,{body:e});return n.ok?{id:n.data.id,href:t(n.data.id)}:{error:M(n)}}function Qo({children:e}){return(0,I.jsx)(`div`,{className:`mt-1.5 border-t border-line px-2 pt-2 pb-1 text-2xs font-semibold tracking-[0.06em] text-fg-2 uppercase`,children:e})}function $o({emoji:e,name:t,sub:n,on:r,onClick:i}){return(0,I.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,className:`flex w-full cursor-pointer items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,onClick:i,children:[(0,I.jsx)(`span`,{className:`w-5 flex-none text-center text-base leading-5`,children:e}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm text-fg`,children:t}),n&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:n})]}),r&&(0,I.jsx)(R,{name:`check`,className:`ms-sm mt-0.5 text-accent`})]})}function es({chat:e,href:t,who:n,place:r}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=$a(e,`new session`);return i?(0,I.jsx)(`div`,{className:`px-1.5 py-1`,children:(0,I.jsx)(Za,{name:c,className:`w-full text-base`,onDone:t=>{a(!1),t&&A.request(`chats.rename`,{id:e.id,body:{title:t}}).catch(()=>null)}})}):(0,I.jsxs)(`div`,{className:`recent-session group/recent relative flex items-center rounded-card transition-colors hover:bg-surface-2 has-[[aria-expanded=true]]:bg-surface-2`,"data-chat":e.id,children:[(0,I.jsxs)(U,{href:t,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-2.5 text-[15px] text-fg no-underline`,children:[(e.busy||e.awaitingApproval)&&(0,I.jsx)($e,{tone:e.awaitingApproval?`bad`:`working`,title:e.awaitingApproval?`waiting for your approval`:`working`}),e.scope.kind===`channel`&&(0,I.jsx)(R,{name:`forum`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate`,children:c}),r&&(0,I.jsx)(`span`,{className:`recent-place flex-none truncate text-xs text-fg-2`,children:r})]}),(0,I.jsx)(`span`,{className:`recent-agent flex-none truncate rounded-full bg-surface-2 px-2 py-0.5 text-xs text-fg-2 max-w-[40%]`,title:`session with ${n}`,children:n}),(0,I.jsx)(`span`,{className:`flex-none px-3 text-sm text-fg-2 tabular-nums group-hover/recent:hidden group-has-[[aria-expanded=true]]/recent:hidden`,title:e.updatedAt,children:W(e.updatedAt)}),(0,I.jsx)(`span`,{className:`hidden flex-none pr-1.5 group-hover/recent:inline-flex group-has-[[aria-expanded=true]]/recent:inline-flex pointer-coarse:inline-flex`,children:(0,I.jsx)(At,{align:`end`,trigger:({open:e,toggle:t})=>(0,I.jsx)(K,{icon:`more_horiz`,size:`sm`,label:`more for ${c}`,"aria-haspopup":`menu`,"aria-expanded":e,onClick:()=>{s(!1),t()}}),children:t=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qa,{icon:`edit`,label:`rename`,onClick:()=>{t(),a(!0)}}),(0,I.jsx)(Qa,{icon:`delete`,label:o?`confirm delete`:`delete`,danger:!0,onClick:()=>{if(!o)return s(!0);t(),A.request(`chats.delete`,{id:e.id}).catch(()=>null)}})]})})})]})}var ts=[`active`,`paused`,`done`,`archived`],ns={active:`working`,paused:`idle`,done:`ok`,archived:`idle`},rs={active:`accent`,paused:`neutral`,done:`ok`,archived:`neutral`},is={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,crm:`CRM`,newsletter:`Newsletter tool`,calendar:`Calendar`,"google-maps":`Google Maps`,url:`Link`},as=e=>is[e]??e,os=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`}],ss=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),cs=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),ls=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function us(e,t){let n=await A.request(`projects.save`,{slug:e,body:t});if(!n.ok)throw Error(M(n));return n.data}function ds({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=be(),l=(0,v.useCallback)(async()=>{try{let e=await A.request(`projects.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);a(e.data),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await l(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[l]),(0,v.useEffect)(()=>{l()},[t,n,l]);let u=i?.projects??[],d=t?u.find(e=>e.slug===t):void 0,f=[...u].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&f&&H(`/projects/${encodeURIComponent(f)}`,{replace:!0})},[n,f]);let p;return p=i&&!i.enabled?(0,I.jsx)(Y,{icon:`folder_off`,children:i.error&&!/are off/.test(i.error)?(0,I.jsx)(`span`,{className:`text-bad`,children:i.error}):(0,I.jsxs)(I.Fragment,{children:[`Projects are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&u.length===0?(0,I.jsx)(ps,{root:i.root,onCreated:l}):n===`home`?(0,I.jsx)(Y,{children:`loading…`}):t&&!d?(0,I.jsxs)(Y,{icon:`folder_off`,children:[`no project named `,t]}):n===`chat`&&t&&r===`new`?(0,I.jsx)(ms,{slug:t,title:d?.title??t},t):n===`chat`&&t&&r?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(hs,{chatId:r,title:d?.title??t,goal:d?.goal},r)}):n===`info`&&t?(0,I.jsx)(_s,{slug:t,onChanged:l},t):t?(0,I.jsx)(ms,{slug:t,title:d?.title??t},t):(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(Y,{children:`loading…`}),(0,I.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t&&d?`in-project`:``}`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`projects`,count:i?.enabled?u.length:void 0,action:i?.enabled&&(c||u.length===0)&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/projects/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[u.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,innerProps:{"data-project":e.slug},leading:(0,I.jsx)($e,{tone:e.configError?`bad`:ns[e.status],title:e.status}),title:e.title,sub:e.configError?e.configError:e.goal||e.status,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,I.jsx)(`span`,{title:e.updatedAt,children:W(e.updatedAt)})},e.slug)),i&&i.enabled&&u.length===0&&(0,I.jsx)(kt,{children:`no projects yet`}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:p})]})}function fs(){let e=N(`projects.list`,{},{interval:6e4});return e&&!e.enabled?(0,I.jsxs)(Y,{icon:`folder_off`,children:[`Projects are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),`.`]}):(0,I.jsx)(ps,{root:e?.root,onCreated:async()=>{}})}function ps({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await A.request(`projects.create`,{body:{title:r,goal:i.trim()}});if(!e.ok)throw Error(M(e));let n=e.data;H(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,I.jsxs)(`form`,{className:`new-chat mx-auto flex w-full max-w-[640px] animate-rise flex-col gap-4`,onSubmit:e=>void u(e),children:[(0,I.jsx)(it,{size:`lg`,children:`new project`}),(0,I.jsx)(X,{children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})}),(0,I.jsx)(Q,{label:`goal (one line)`,children:(0,I.jsx)(Z,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(G,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim(),children:o?`creating…`:`create project`})}),c&&(0,I.jsx)(tt,{tone:`bad`,children:c}),(0,I.jsxs)(J,{children:[`One folder each under `,(0,I.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function ms({slug:e,title:t}){let n=Te(),r=N(`projects.get`,{slug:e}),i=N(`chats.list`,{}),a=os.find(e=>e.id===r?.harness)??os[0],o=n.vibeables?(r?.links.vibeables??[]).filter(e=>e.found).map(e=>e.slug):[],s=t=>`/projects/${encodeURIComponent(e)}/chat/${t}`;return(0,I.jsx)(Xo,{placeholder:`New session in ${t}`,byDefault:{...Be,sub:r?`the project's assistant · ${ss(r)}`:`the project's assistant`,hint:r?ss(r):``},firstGroup:{label:`agents of the project`,slugs:new Set((r?.links.agents??[]).map(e=>e.slug))},agentHint:`works with the project's context`,sessions:i?cs(i.chats,e):null,hrefOf:t=>ls(t,e),create:t=>Zo(t?{agent:`claude`,scope:{kind:`agent`,slug:t},project:e}:{agent:a.id,scope:{kind:`project`,slug:e}},s),children:o.length>0&&(0,I.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`pinned apps`,children:[(0,I.jsx)(`h2`,{className:`m-0 px-3 pb-1 text-sm font-medium text-fg-2`,children:`Apps`}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 px-1`,children:o.map(t=>(0,I.jsxs)(U,{href:`/projects/${encodeURIComponent(e)}?app=${encodeURIComponent(t)}`,className:`pinned-app flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-2.5 text-sm text-fg no-underline hover:bg-surface-2`,title:`open ${t} beside the project's chat`,"data-app":t,children:[(0,I.jsx)(R,{name:`web`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]},t))})]})})}function hs({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return A.call(`chats.get`,{id:e}).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=r?.kind===`agent`?r.slug:void 0,d=N(`channels.list`,l?{}:null,{interval:4e3}),f=N(`agents.list`,l||u?{}:null,{interval:8e3});if(a)return(0,I.jsx)(Y,{icon:`chat_error`,children:`chat not found`});if(!r)return(0,I.jsx)(Y,{children:`loading…`});if(l){let t=d?.channels.find(e=>e.slug===l);return d?t?(0,I.jsx)(Ko,{id:e,channel:t,agents:f?.agents??[]},`${e}:channel`):(0,I.jsxs)(Y,{icon:`forum`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,I.jsx)(Y,{children:`loading…`})}if(u){let t=f?.agents.find(e=>e.slug===u);return f?(0,I.jsx)(Ko,{id:e,agentName:t?`${t.emoji||`🤖`} ${t.name}`:u,agentDescription:t?.description,onConverted:()=>c(e=>e+1)},`${e}:${s}`):(0,I.jsx)(Y,{children:`loading…`})}return(0,I.jsx)(Ko,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}var gs=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`apps`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`},{kind:`contacts`,label:`contacts`,icon:`person`,href:e=>`/contacts/${encodeURIComponent(e)}`},{kind:`places`,label:`places`,icon:`location_on`,href:e=>`/places/${encodeURIComponent(e)}`},{kind:`events`,label:`events`,icon:`event`,href:e=>`/events/${encodeURIComponent(e)}`}];function _s({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`active`),[x,S]=(0,v.useState)(`claude`),[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),F=be(),te=Te(),R=e=>{r(e),h(e.title),_(e.goal),b(e.status),S(e.harness),w(e.model??``),E(e.effort??``),O(e.brief),ee(e.state),M(!1)};(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&R(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let z=()=>{M(!0),d(!1),s(``)},ne=async(n,i={})=>{l(!0),s(``);try{let a=await us(e,n);i.keepEdits?r(a):R(a),d(!i.keepEdits),await t()}catch(e){s(e.message)}finally{l(!1)}},re=async()=>{l(!0);try{let n=await A.request(`projects.delete`,{slug:e});if(!n.ok)throw Error(n.error||`failed`);await t(),H(`/`,{replace:!0})}catch(e){s(e.message),l(!1)}},ie=async()=>{let t=N.trim();if(t){l(!0),s(``);try{let n=await A.request(`projects.log`,{slug:e,body:{entry:t}});if(!n.ok)throw Error(n.error||`failed`);let i=n.data;P(``),r(e=>e&&{...e,log:i.log??e.log})}catch(e){s(e.message)}finally{l(!1)}}};return i?(0,I.jsx)(Y,{icon:`folder_off`,children:`project not found`}):n?(0,I.jsxs)(`div`,{className:`chat-main project-page flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,I.jsx)(st,{children:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`})}),(0,I.jsx)(it,{size:`lg`,children:n.title}),(0,I.jsx)(q,{tone:rs[n.status],children:n.status}),(0,I.jsx)(q,{title:`harness · model · effort every chat in this project runs on`,children:ss(n)}),F&&(0,I.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-fg-2`,title:n.path,children:n.path})]}),n.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`project.yml: `,n.configError]}),(0,I.jsx)(X,{title:`project`,className:`flex-none`,actions:(0,I.jsxs)(I.Fragment,{children:[u&&!j&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`saved`}),(0,I.jsx)(G,{variant:`primary`,size:`sm`,busy:c,disabled:!j,onClick:()=>void ne({title:m,goal:g,status:y,harness:x,model:C,effort:T,brief:D,state:k}),children:c?`saving…`:`save changes`})]}),children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Z,{value:m,"aria-label":`title`,onChange:e=>{h(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`status`,children:(0,I.jsx)(bt,{value:y,"aria-label":`status`,onChange:e=>{b(e.target.value),z()},children:ts.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})})]}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`harness`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(bt,{value:x,"aria-label":`harness`,onChange:e=>{S(e.target.value),z()},children:os.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,I.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Z,{value:C,"aria-label":`model`,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>{w(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`effort`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(bt,{value:T,"aria-label":`effort`,onChange:e=>{E(e.target.value),z()},children:qe.map(e=>(0,I.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,I.jsx)(Q,{label:`goal (one line)`,children:(0,I.jsx)(Z,{value:g,"aria-label":`goal`,placeholder:`what the project is for`,onChange:e=>{_(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`brief.md — what done looks like, constraints, stakeholders`,children:(0,I.jsx)(yt,{rows:10,className:`resize-y font-mono text-sm`,value:D,"aria-label":`brief`,onChange:e=>{O(e.target.value),z()}})}),(0,I.jsx)(Q,{label:`state.md — current state, rewritten at the end of a session`,children:(0,I.jsx)(yt,{rows:6,className:`resize-y font-mono text-sm`,value:k,"aria-label":`state`,onChange:e=>{ee(e.target.value),z()}})}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})}),(0,I.jsx)(Ss,{records:n.records,saving:c,onSave:e=>ne({records:e},{keepEdits:!0})}),(0,I.jsx)(X,{title:`links`,className:`flex-none`,actions:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`by name; a target that is missing in this workspace is marked`}),children:(0,I.jsx)(ut,{children:gs.filter(e=>e.kind!==`contacts`&&e.kind!==`places`&&e.kind!==`events`||te[e.kind]).map(i=>(0,I.jsx)(bs,{kind:i.kind,label:i.label,icon:i.icon,href:i.href,links:n.links[i.kind],saving:c,onChange:(n,a)=>void vs(e,i.kind,n,a,e=>{r(e),t()},s)},i.kind))})}),(0,I.jsxs)(X,{title:`log`,className:`flex-none`,children:[(0,I.jsx)(xt,{className:`max-w-[680px]`,children:(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`new entry — a decision, a milestone`,className:`flex-1`,children:(0,I.jsx)(Z,{value:N,"aria-label":`log entry`,placeholder:`e.g. Decided on NodeHive as the CMS`,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ie())}})}),(0,I.jsx)(G,{icon:`add`,disabled:c||!N.trim(),onClick:()=>void ie(),children:`log`})]})}),(0,I.jsx)(`div`,{className:`md-body h-auto overflow-visible px-[18px] pt-1 pb-4 text-sm [&_h1]:hidden [&_h2]:mt-3 [&_h2]:mb-1 [&_h2]:text-xs [&_ul]:m-0 [&_ul]:pl-[18px]`,dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parse(n.log||`_no entries yet_`,{async:!1}))}})]}),(0,I.jsx)(X,{title:`danger zone`,className:`flex-none [&>div]:border-b-0`,actions:f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>void re(),children:`confirm delete`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>p(!1),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>p(!0),title:`Move the project, its files and log to the trash; #/trash puts it back`,children:`delete project`}),children:null})]}):(0,I.jsx)(Y,{children:`loading…`})}async function vs(e,t,n,r,i,a){try{let a=await A.request(`projects.link`,{slug:e,body:{kind:t,target:n,remove:r}});if(!a.ok)throw Error(M(a));i(a.data)}catch(e){a(e.message)}}async function ys(e){switch(e){case`knowledge`:return(await A.call(`knowledge.list`)).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await A.call(`vibeables.list`)).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await A.call(`repos.list`)).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await A.call(`workflows.list`)).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await A.call(`agents.list`)).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}));case`contacts`:return(await A.call(`contacts.list`)).items.map(e=>({slug:e.slug,hint:[e.role,e.org].filter(Boolean).join(`, `)||void 0}));case`places`:return(await A.call(`places.list`)).items.map(e=>({slug:e.slug,hint:e.address}));case`events`:return(await A.call(`events.list`)).items.map(e=>({slug:e.slug,hint:e.start}))}}function bs({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return ys(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,I.jsxs)(lt,{icon:n,title:t,"data-link-kind":e,action:!s&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>c(!0),children:`link`}),children:[i.length===0&&!s&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none linked`}),i.length>0&&(0,I.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,I.jsxs)(q,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,I.jsx)(U,{href:r(e.slug),className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`,(0,I.jsx)(`button`,{type:`button`,className:`-mr-1 ml-1 inline-grid size-4 cursor-pointer place-items-center rounded-full border-0 bg-transparent p-0 text-inherit opacity-70 hover:bg-surface hover:opacity-100 disabled:cursor-default [&_.ms]:text-[13px]`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,I.jsx)(R,{name:`close`})})]},e.slug))}),s&&(0,I.jsx)(`span`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:l===null?(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`loading…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(bt,{className:`w-auto max-w-full min-w-48 flex-1`,"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,I.jsx)(G,{disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>c(!1),children:`cancel`})]})})]})}var xs={kind:`url`};function Ss({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??xs,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,I.jsx)(X,{title:`systems of record`,className:`flex-none`,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>i({...xs}),children:`add`})]}),children:(0,I.jsxs)(ut,{children:[e.map((r,i)=>(0,I.jsx)(lt,{"data-record-kind":r.kind,icon:`database`,title:(0,I.jsxs)(I.Fragment,{children:[as(r.kind),r.title&&(0,I.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,children:r.title}),r.workspace&&(0,I.jsxs)(q,{children:[`workspace `,r.workspace]})]}),action:(0,I.jsx)(K,{icon:`close`,size:`sm`,label:`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i))}),children:(r.url||r.note)&&(0,I.jsxs)(`span`,{className:`text-xs leading-normal text-fg-2`,children:[r.url&&(0,I.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})},i)),e.length===0&&!r&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`kind`,children:a?(0,I.jsx)(Z,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,I.jsxs)(bt,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(is).map(([e,t])=>(0,I.jsx)(`option`,{value:e,children:t},e)),(0,I.jsx)(`option`,{value:`__other`,children:`other…`})]})}),(0,I.jsx)(Q,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Z,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})}),(0,I.jsx)(Q,{label:`workspace / id`,children:(0,I.jsx)(Z,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})})]}),(0,I.jsx)(Q,{label:`url`,children:(0,I.jsx)(Z,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`note — what lives there and how it is usually reached`,className:`flex-1`,children:(0,I.jsx)(Z,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})}),(0,I.jsx)(G,{disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})})}async function Cs(e,t){let n=window.open(``,`_blank`);if(!n)return;let r=t?`${e}/${t}`:e;n.document.write(`<title>${Ds(r)}</title><body style="font-family:system-ui;padding:40px;color:#555">preparing ${Ds(r)}…</body>`);let i,a=``;try{let[n,r]=await Promise.all([t?Promise.resolve([t]):A.call(`knowledge.get`,{bundle:e}).then(e=>e.concepts.map(e=>e.id)),A.call(`meta.get`).catch(()=>({}))]);if(a=r.workspaceName??``,i=await Promise.all(n.map(t=>A.call(`knowledge.concept`,{bundle:e,query:{id:t}}))),i.some(e=>typeof e?.id!=`string`))throw Error(`missing concept`)}catch{n.document.body.textContent=`could not load "${r}"`;return}let o=[],s=i.map(e=>{let t=[e.type,e.generated?.at?`updated ${e.generated.at.slice(0,10)}`:``,e.trustTier===`human-reviewed`?`human-reviewed`:``,(e.tags??[]).map(e=>`#${e}`).join(` `)].filter(Boolean).join(` · `),{md:n,notes:r}=Ts(ws(e.body??``,null)),i=!e.title||e.title===e.id||e.title===e.id.split(`/`).pop(),{html:a,title:s}=Es(Da.sanitize(Jr.parse(n,{async:!1})),{title:e.title||e.id,meta:t,titleIsFallback:i});return o.push(s),`<article>
87
87
  ${a}
88
88
  ${r.length?`<ol class="notes">${r.map(e=>`<li id="fn-${Ds(e.id)}">${Da.sanitize(Jr.parseInline(e.text,{async:!1}))}</li>`).join(``)}</ol>`:``}
89
89
  </article>`}).join(`
@@ -217,9 +217,9 @@ Instructions this agent follows when the skill applies or is invoked with /<name
217
217
  `;function Us({slug:e}){let t=N(`agents.skills`,{slug:e})?.skills??[],[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);async function c(t){s(``);let n=await A.request(`agents.skill`,{slug:e,name:t}).catch(()=>null);if(!n)return void s(`could not load skill`);if(!n.ok||!n.data||typeof n.data!=`object`)return void s(n.error??`could not load skill`);r({name:t,content:n.data.content??``,isNew:!1})}async function l(){if(!n)return;a(!0),s(``);let t=await A.request(`agents.saveSkill`,{slug:e,body:{name:n.name,content:n.content}});a(!1),!t.ok||!t.data||typeof t.data!=`object`?s(t.error??`save failed`):r(null)}async function u(t){window.confirm(`Move skill "/${t}" of this agent to the trash?`)&&(await A.request(`agents.deleteSkill`,{slug:e,name:t}).catch(()=>{}),n?.name===t&&r(null))}return(0,I.jsxs)(X,{title:`own skills — only this agent`,actions:!n&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>{r({name:``,content:Hs,isNew:!0}),s(``)},children:`new skill`}),children:[t.length===0&&!n&&(0,I.jsxs)(J,{className:`px-[18px] py-3 text-xs`,children:[`none — skills in `,(0,I.jsxs)(`code`,{children:[`agents/`,e,`/skills/`]}),` are private to this agent; skills for every agent live in the workspace skills folder.`]}),t.length>0&&!n&&(0,I.jsx)(ut,{children:t.map(e=>(0,I.jsx)(lt,{icon:`extension`,title:`/${e.name}`,action:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,icon:`edit`,onClick:()=>void c(e.name),children:`edit`}),(0,I.jsx)(K,{icon:`delete`,label:`delete /${e.name}`,variant:`danger`,size:`sm`,onClick:()=>void u(e.name)})]}),children:(0,I.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:e.description||(0,I.jsx)(`code`,{children:`SKILL.md`})})},e.name))}),n&&(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`name — invoked as /<name>`,children:(0,I.jsx)(Z,{className:`font-mono`,value:n.name,placeholder:`e.g. report-html`,disabled:!n.isNew,onChange:e=>r({...n,name:e.target.value})})}),(0,I.jsx)(Q,{label:`SKILL.md — frontmatter (description) + the instructions`,children:(0,I.jsx)(yt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,rows:Math.min(28,Math.max(12,n.content.split(`
218
218
  `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)(G,{variant:`primary`,busy:i,disabled:!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,I.jsx)(G,{variant:`quiet`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,I.jsx)(tt,{tone:`bad`,children:o})})]})}function Ws(e){let t=e.adopted.length;if(t===0)return{note:`nothing to adopt — already running here`,error:``};let n=t===1?`"${e.adopted[0].name}" runs`:`${t} routines run`;return e.commit&&!e.commit.ok?{note:``,error:`${n} on ${e.runsOn} — routines.yml written, but not committed: ${e.commit.error??`git failed`}`}:{note:`${n} on ${e.runsOn} now${e.commit?` — committed`:``}`,error:``}}function Gs({r:e}){return e.runner===`here`?(0,I.jsx)(q,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,I.jsx)(q,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):e.retired?(0,I.jsxs)(q,{tone:`ask`,title:`${e.runsOn} is a retired identity of this machine — it fires nowhere until reassigned`,children:[`runs on `,e.runsOn,` · retired`]}):(0,I.jsxs)(q,{title:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]})}function Ks({slug:e}){let[t,n]=(0,v.useState)(0),r=N(`agents.routines`,{slug:e},{refresh:t}),i=N(`identity.get`,{},{interval:6e4}),a=r?.routines??[],[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),g=(Lt()??[]).filter(e=>e.kind===`runner`),_=g.flatMap(e=>e.routines??[]),y=g.some(e=>e.id.startsWith(`runner:retired:`))||a.some(e=>e.retired),b=a.filter(e=>e.runner===`unassigned`&&e.enabled||e.retired).length,x=_.filter(t=>t.agent!==e).length;async function S(t){l(``);let n=await A.request(`agents.saveRoutine`,{slug:e,body:t});return n.ok?!0:(l(M(n)),!1)}async function C(t){p(t),l(``);let n=await A.request(`agents.runRoutine`,{slug:e,id:t});p(``),n.ok?n.data.chatId&&H(`/agents/${encodeURIComponent(e)}/chat/${n.data.chatId}`):l(M(n))}function w(e){let t=Ws(e);d(t.note),l(t.error),n(e=>e+1),It()}async function T(t){h(t),l(``),d(``);let n=await A.request(`agents.adoptRoutine`,{slug:e,id:t});h(``),n.ok?w(n.data):l(M(n))}async function E(){h(`*`),l(``),d(``);let e=await A.request(`routines.adopt`,{body:{retired:y}});h(``),e.ok?w(e.data):l(M(e))}async function D(t){window.confirm(`Delete the scheduled prompt "${t}"?`)&&await A.request(`agents.deleteRoutine`,{slug:e,id:t}).catch(()=>{})}return(0,I.jsxs)(X,{title:`schedule — prompts that run on their own`,actions:!o&&(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>s({name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0}),children:`schedule a prompt`}),children:[a.length===0&&!o&&(0,I.jsx)(J,{className:`px-[18px] py-3 text-xs`,children:`none — a routine messages this agent on a schedule (cron, server local time) and each run opens a new session with the result.`}),b>0&&(0,I.jsx)(lt,{icon:`event_busy`,title:`${b} routine${b===1?` fires`:`s fire`} nowhere`,action:(0,I.jsx)(G,{size:`sm`,icon:`download_done`,busy:m===`*`,onClick:()=>void E(),children:m===`*`?`adopting…`:`run these here`}),children:(0,I.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[y?`no runner, or a retired identity`:`no runner`,` — makes `,(0,I.jsx)(`code`,{children:i?.identity??`this machine`}),` the runner`,x>0?` of these and ${x} on other agents`:``,` and commits routines.yml`]})}),a.length>0&&(0,I.jsx)(ut,{children:a.map(t=>(0,I.jsx)(lt,{icon:`schedule`,title:(0,I.jsxs)(I.Fragment,{children:[t.name,(0,I.jsx)(Gs,{r:t}),t.lastError&&(0,I.jsx)(`span`,{title:t.lastError,children:(0,I.jsx)(q,{tone:`bad`,children:`error`})}),t.awaitingApproval&&t.lastChatId&&(0,I.jsx)(q,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,tone:`bad`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`})]}),action:(0,I.jsxs)(I.Fragment,{children:[t.runner!==`here`&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,busy:m===t.id,title:`make ${i?.identity??`this machine`} its runner and commit routines.yml`,onClick:()=>void T(t.id),children:m===t.id?`adopting…`:`run here`}),(0,I.jsx)(G,{size:`sm`,icon:`play_arrow`,busy:f===t.id,onClick:()=>C(t.id),children:f===t.id?`starting…`:`run`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>s({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:t.enabled,runsOn:t.runsOn??``,private:t.private??!1}),children:`edit`}),(0,I.jsx)(G,{size:`sm`,variant:`danger`,onClick:()=>void D(t.id),children:`delete`}),(0,I.jsx)(wt,{checked:t.enabled,label:t.enabled?`enabled — click to pause`:`paused — click to enable`,onChange:()=>void S({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:!t.enabled})})]}),children:(0,I.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[(0,I.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ge(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,I.jsxs)(U,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ge(t.lastRunAt)]}):`never ran`]})},t.id))}),o&&(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,I.jsx)(Z,{value:o.name,placeholder:`e.g. Morning report`,onChange:e=>s({...o,name:e.target.value})})}),(0,I.jsx)(Q,{label:`schedule (cron)`,className:`w-[200px] max-[900px]:w-auto`,children:(0,I.jsx)(Z,{className:`font-mono`,value:o.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>s({...o,schedule:e.target.value})})}),(0,I.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.enabled,onChange:e=>s({...o,enabled:e.target.checked})}),`enabled`]})]}),(0,I.jsx)(Q,{label:`prompt — what to ask this agent on each run`,children:(0,I.jsx)(yt,{rows:5,value:o.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>s({...o,prompt:e.target.value})})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`runs on — the one machine that fires it`,className:`flex-1`,children:(0,I.jsx)(Z,{className:`font-mono`,value:o.runsOn??i?.identity??``,placeholder:`<handle>@<machine> — empty: no runner`,onChange:e=>s({...o,runsOn:e.target.value})})}),(0,I.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 text-sm text-fg`,title:`stored in routines.yml; nothing reads it yet`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:o.private??!1,onChange:e=>s({...o,private:e.target.checked})}),`private`]})]}),i&&(0,I.jsxs)(J,{children:[`This machine is `,(0,I.jsx)(`code`,{children:i.identity}),`. Empty: no runner — it fires nowhere.`]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)(G,{variant:`primary`,disabled:!o.name.trim()||!o.prompt.trim(),onClick:async()=>{let{runsOn:e,...t}=o;await S(e===void 0?t:{...t,runsOn:e.trim()||null})&&s(null)},children:o.id?`save`:`add to the schedule`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>(s(null),l(``)),children:`cancel`})]})]}),(c||u)&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:c?(0,I.jsx)(tt,{tone:`bad`,children:c}):(0,I.jsx)(tt,{children:u})})]})}function qs({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!0),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=Te(),x=N(`workflows.list`,{}),S=N(`knowledge.list`,{}),C=N(`vibeables.list`,b.vibeables?{}:null),w=N(`skills.list`,{});(0,v.useEffect)(()=>{let t=!0;return A.call(`agents.get`,{slug:e}).then(e=>t&&n(e)).catch(()=>t&&i(!0)),()=>{t=!1}},[e]);async function T(r){if(t){g(!0),y(``);try{let i=await A.request(`agents.save`,{slug:e,body:{name:t.name,emoji:t.emoji,description:t.description,harness:t.harness,model:t.model,effort:t.effort,group:t.group,system:t.system,workflows:t.workflows,knowledge:t.knowledge,vibeables:t.vibeables,skills:t.skills,...r}});i.ok?(n(i.data),c(``)):y(M(i))}catch(e){y(e.message)}g(!1)}}function E(e,t){f(t?[...d,e]:d.filter(t=>t!==e))}async function D(t){g(!0),y(``);try{let r=await A.request(`agents.archive`,{slug:e,body:{archived:t}});r.ok?n(r.data):y(M(r))}catch(e){y(e.message)}g(!1)}if(r)return(0,I.jsx)(Y,{icon:`person_off`,children:`agent not found`});if(!t)return(0,I.jsx)(Y,{children:`loading…`});let O=e=>(0,I.jsxs)(`div`,{className:`mt-2 flex items-center gap-2.5`,children:[(0,I.jsx)(G,{variant:`primary`,busy:h,onClick:()=>void T(e),children:h?`saving…`:`save`}),(0,I.jsx)(G,{variant:`quiet`,disabled:h,onClick:()=>(c(``),y(``)),children:`cancel`})]}),k=e=>(0,I.jsx)(G,{size:`sm`,onClick:()=>{e(),y(``)},children:`edit`});return(0,I.jsxs)(`div`,{className:`agent-view flex animate-rise flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,I.jsx)(st,{children:(0,I.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,I.jsx)(it,{size:`lg`,children:t.name}),(0,I.jsx)(q,{children:t.harness}),t.model&&(0,I.jsx)(q,{children:t.model}),t.effort&&(0,I.jsxs)(q,{children:[`effort: `,t.effort]}),t.archived&&(0,I.jsxs)(q,{children:[(0,I.jsx)(R,{name:`inventory_2`,className:`ms-sm mr-1`}),` archived`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{href:`/agents/${encodeURIComponent(e)}/edit`,children:`edit`}),t.archived?(0,I.jsx)(G,{variant:`primary`,icon:`unarchive`,busy:h,onClick:()=>void D(!1),children:h?`…`:`unarchive`}):(0,I.jsx)(G,{variant:`quiet`,icon:`archive`,disabled:h,title:`Hide this agent from the roster — restorable any time`,onClick:()=>void D(!0),children:`archive`})]}),(0,I.jsxs)(X,{children:[(0,I.jsxs)(ut,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-3.5 border-0 bg-transparent px-[18px] py-3 text-left font-[inherit] text-inherit hover:bg-surface-2`,"aria-expanded":a,onClick:()=>o(!a),children:[(0,I.jsx)(ct,{name:`badge`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,I.jsx)(`span`,{className:`text-[13.5px] font-medium text-fg`,children:`role`}),!a&&(0,I.jsx)(`span`,{className:P(`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,`truncate`),children:(t.system||``).trim().split(`
219
219
  `)[0]||`empty — expand to give this agent a role`})]}),(0,I.jsx)(R,{name:`expand_more`,className:P(`ms-sm flex-none text-fg-2 transition-transform`,a&&`rotate-180`)})]}),a&&s!==`role`&&(0,I.jsxs)(`div`,{className:`pr-[18px] pb-4 pl-16`,children:[(0,I.jsx)(`pre`,{className:`m-0 font-mono text-[12.5px] leading-[1.65] whitespace-pre-wrap`,children:t.system||`(empty — click edit to give this agent a role)`}),(0,I.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-2.5`,children:[(0,I.jsx)(G,{size:`sm`,icon:`edit`,onClick:()=>{u(t.system),c(`role`),y(``)},children:`edit role`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:[`agents/`,t.slug,`/system.md`]})]})]}),a&&s===`role`&&(0,I.jsxs)(`div`,{className:`pr-[18px] pb-4 pl-16`,children:[(0,I.jsx)(yt,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`role`,rows:Math.min(24,Math.max(8,l.split(`
220
- `).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),O({system:l})]})]}),(0,I.jsx)(lt,{icon:`account_tree`,title:`workflows`,action:s!==`workflows`&&k(()=>(f(t.workflows),c(`workflows`))),children:s===`workflows`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(x?.workflows??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(x?.workflows??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),O({workflows:d})]}):t.workflows.length===0?(0,I.jsx)(`span`,{className:Os,children:`none connected — the agent can run any workflow you connect`}):(0,I.jsx)(ks,{children:t.workflows.map(e=>(0,I.jsx)(q,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,I.jsx)(lt,{icon:`menu_book`,title:`knowledge`,action:s!==`knowledge`&&k(()=>(f(t.knowledge),c(`knowledge`))),children:s===`knowledge`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(S?.bundles??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(S?.bundles??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),O({knowledge:d})]}):t.knowledge.length===0?(0,I.jsx)(`span`,{className:Os,children:`none connected — connected bundles are read and kept current by the agent`}):(0,I.jsx)(ks,{children:t.knowledge.map(e=>(0,I.jsx)(q,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(b.vibeables||(t.vibeables??[]).length>0)&&(0,I.jsx)(lt,{icon:`web`,title:`apps`,"data-link-kind":`vibeables`,action:s!==`vibeables`&&k(()=>(f(t.vibeables??[]),c(`vibeables`))),children:s===`vibeables`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(C?.vibeables??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),d.filter(e=>!(C?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,I.jsx)($,{checked:!0,onChange:t=>E(e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!b.vibeables&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),b.vibeables&&(C?.vibeables??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}),O({vibeables:d})]}):(t.vibeables??[]).length===0?(0,I.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:`none linked — linked apps are the agent's to build and maintain; it knows them from the first message`}):(0,I.jsx)(ks,{children:(t.vibeables??[]).map(e=>{let t=!b.vibeables||!C||C.vibeables.some(t=>t.slug===e);return(0,I.jsxs)(q,{href:`/vibeables/${encodeURIComponent(e)}`,tone:t?`neutral`:`bad`,title:t?void 0:`configured but not found in this workspace`,children:[e,!t&&` · not found`]},e)})})}),(0,I.jsx)(lt,{icon:`extension`,title:`shared skills`,action:s!==`skills`&&k(()=>{m(t.skills===void 0),f(t.skills??[]),c(`skills`)}),children:s===`skills`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(0,I.jsx)($,{checked:p,onChange:m,hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!p&&(w?.skills??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!p&&(w?.skills??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),O({skills:p?void 0:d})]}):t.skills===void 0?(0,I.jsx)(`span`,{className:Os,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,I.jsx)(`span`,{className:Os,children:`none — this agent runs without skills`}):(0,I.jsx)(ks,{children:t.skills.map(e=>(0,I.jsxs)(q,{children:[`/`,e]},e))})})]}),_&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,I.jsx)(tt,{tone:`bad`,children:_})})]}),(0,I.jsx)(Us,{slug:e}),(0,I.jsx)(Ks,{slug:e})]})}var Js=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Ys({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=N(`workflows.list`,{})?.workflows??[],c=N(`knowledge.list`,{})?.bundles??[],l=Te(),u=N(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=N(`skills.list`,{})?.skills??[];(0,v.useEffect)(()=>{e&&A.call(`agents.get`,{slug:e}).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n={...t,skills:t.skillsAll?void 0:t.skills},r=e?await A.request(`agents.save`,{slug:e,body:n}):await A.request(`agents.create`,{body:n});o(!1),r.ok?H(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(M(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),H(`/agents`))}if(!t)return(0,I.jsx)(Y,{children:r||`loading…`});let h=e=>n({...t,...e}),g=(e,n,r)=>h({[e]:r?[...t[e],n]:t[e].filter(e=>e!==n)});return(0,I.jsxs)(ot,{width:`narrow`,children:[(0,I.jsx)(it,{children:e?`edit ${e}`:`new agent`}),(0,I.jsx)(X,{children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,I.jsx)(Z,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,I.jsx)(Q,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,I.jsx)(Z,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Js.map(e=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:P(`cursor-pointer rounded-xl border px-2.5 py-1.5 text-base transition-colors`,t.emoji===e?`border-transparent bg-accent-soft`:`border-line bg-transparent hover:bg-surface-2`),onClick:()=>h({emoji:e}),children:e},e))}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`description`,className:`flex-1`,children:(0,I.jsx)(Z,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,I.jsx)(Q,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,I.jsx)(Z,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsxs)(bt,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,I.jsx)(`option`,{value:`claude`,children:`claude`}),(0,I.jsx)(`option`,{value:`codex`,children:`codex`}),(0,I.jsx)(`option`,{value:`pi`,children:`pi`})]})}),(0,I.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Z,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,I.jsx)(Q,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsx)(bt,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:qe.map(e=>(0,I.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,I.jsx)(Q,{label:`system prompt — the agent's role`,children:(0,I.jsx)(yt,{className:js,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,I.jsxs)(Xs,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,I.jsx)($,{checked:t.workflows.includes(e.slug),onChange:t=>g(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),s.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,I.jsxs)(Xs,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,I.jsx)($,{checked:t.knowledge.includes(e.name),onChange:t=>g(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),c.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,I.jsxs)(Xs,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,I.jsx)($,{checked:t.vibeables.includes(e.slug),onChange:t=>g(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,I.jsx)($,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,I.jsxs)(Xs,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,I.jsx)($,{checked:t.skillsAll,onChange:e=>h({skillsAll:e}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!t.skillsAll&&d.map(e=>(0,I.jsx)($,{checked:t.skills.includes(e.name),onChange:t=>g(`skills`,e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!t.skillsAll&&d.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,I.jsx)(tt,{tone:`bad`,children:r}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)(G,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,I.jsx)(`span`,{className:`flex-1`}),e&&(0,I.jsx)(G,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Xs({label:e,linkKind:t,children:n}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,I.jsx)(As,{children:n})]})}var Zs=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Qs=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function $s({seg:e}){let t=e[0]&&e[0]!==`new`&&e[0]!==`chats`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[0]===`chats`?`chats`:e[1]===`edit`?`edit`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`agent`:`home`,r=n===`chats`&&e[1]===`new`,i=n===`chat`?e[2]:n===`chats`&&!r?e[1]:void 0,a=N(`agents.list`,{}),o=be(),[s,c]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)({}),w=(a?.agents??[]).map(e=>S[e.slug]===void 0?e:{...e,group:S[e.slug]||void 0});(0,v.useEffect)(()=>{C(e=>{let t={...e},n=!1;for(let e of a?.agents??[])t[e.slug]!==void 0&&(e.group??``)===t[e.slug]&&(delete t[e.slug],n=!0);return n?t:e})},[a]);let T=w.filter(e=>!e.archived),E=w.filter(e=>e.archived),[D,O]=(0,v.useState)(!1),k=[...new Set([...T.map(e=>e.group??``).filter(Boolean),...s])].sort((e,t)=>e.localeCompare(t)),ee=T.filter(e=>!e.group);function j(e){c(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function M(){let e=d.trim();u(!1),f(``),e&&!k.includes(e)&&j([...s,e])}function F(e,t){m(null);let n=t.trim();if(n&&n!==e){for(let t of w.filter(t=>t.group===e))te(t.slug,n);s.includes(e)&&j([...new Set(s.map(t=>t===e?n:t))])}}async function te(e,t){if((w.find(t=>t.slug===e)?.group??``)!==t){C(n=>({...n,[e]:t}));try{let n=await A.call(`agents.get`,{slug:e});await A.call(`agents.save`,{slug:e,body:{...n,group:t||void 0}})}catch{C(t=>{let n={...t};return delete n[e],n})}}}let z=e=>o?{onDragOver:t=>{_!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,b!==e&&x(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||_;n&&te(n,e),y(null),x(null)}}:{},ne=e=>(0,I.jsx)(`div`,{className:_===e.slug?`opacity-40`:void 0,onDragStart:t=>{if(!o)return t.preventDefault();t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,y(e.slug)},onDragEnd:()=>{y(null),x(null)},children:(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),re=e=>(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),ie;ie=n===`new`?(0,I.jsx)(Ys,{},`new`):n===`edit`&&t?(0,I.jsx)(Ys,{slug:t},t):n===`chat`&&t&&i===`new`?(0,I.jsx)(Fs,{slug:t},t):n===`chat`&&t&&i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Ko,{id:i,agentName:w.find(e=>e.slug===t)?.name??t,agentDescription:w.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Ko,{id:i},i)}):(0,I.jsx)(Is,{}):n===`info`&&t?(0,I.jsx)(qs,{slug:t},t):t?(0,I.jsx)(Fs,{slug:t},t):a?T.length?(0,I.jsx)(Bs,{agents:T}):(0,I.jsx)(Vs,{}):(0,I.jsx)(Y,{children:`loading…`});let ae=(n===`agent`||n===`info`||n===`chat`)&&t?w.find(e=>e.slug===t)?.knowledge??[]:[],[oe,se]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[ce,le]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),ue=ae.length>0&&oe;function de(e){se(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function B(e){le(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,I.jsxs)(`div`,{className:`runs-screen agents-screen ${t?`in-agent`:``} ${ue?`has-knowledge`:``}`,style:ue?{"--kside-w":`${ce}px`}:void 0,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`agents`,action:o&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[(0,I.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,I.jsx)(mt,{href:`/agents/chats`,active:n===`chats`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,I.jsxs)(`div`,{className:P(`rounded-xl`,_&&b===``&&Zs),...z(``),children:[ee.map(ne),_!=null&&ee.length===0&&(0,I.jsx)(`div`,{className:Qs,children:`no group — drop here`})]}),k.map(e=>{let t=T.filter(t=>t.group===e);return(0,I.jsxs)(`div`,{className:P(`group/grp mt-3 rounded-xl`,_&&b===e&&Zs),...z(e),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[p===e?(0,I.jsx)(Z,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:h,onChange:e=>g(e.target.value),onKeyDown:t=>{t.key===`Enter`&&F(e,h),t.key===`Escape`&&m(null)},onBlur:()=>F(e,h)}):(0,I.jsx)(nt,{children:e}),(0,I.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,I.jsx)(`span`,{className:`flex-1`}),o&&p!==e&&(0,I.jsx)(K,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{m(e),g(e)}}),o&&t.length===0&&s.includes(e)&&(0,I.jsx)(K,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>j(s.filter(t=>t!==e))})]}),t.map(ne),t.length===0&&(0,I.jsx)(`div`,{className:Qs,children:o?`drag agents here`:`no agents`})]},e)}),E.length>0&&(0,I.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`group/arch flex w-full cursor-pointer items-center gap-1.5 border-0 bg-transparent px-2.5 pt-1.5 pb-0.5 text-left text-fg-2`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,I.jsx)(nt,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,I.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:E.length}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(R,{name:D?`expand_less`:`expand_more`,className:`ms-sm`})]}),D&&E.map(re)]}),a&&w.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-2.5`,children:`no agents yet`}),o&&(l?(0,I.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,I.jsx)(Z,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:d,placeholder:`group name, e.g. Team Content`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(),e.key===`Escape`&&(u(!1),f(``))},onBlur:M})}):(0,I.jsxs)(`button`,{type:`button`,className:`mx-2.5 mt-3 mb-1 flex cursor-pointer items-center gap-1 rounded-lg border border-dashed border-line bg-transparent px-2.5 py-1 text-2xs text-fg-2 hover:text-accent`,onClick:()=>u(!0),children:[(0,I.jsx)(R,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:ie}),ue&&(0,I.jsx)(Ms,{bundles:ae,onHide:()=>de(!1),onResize:B}),ae.length>0&&!oe&&(0,I.jsxs)(`button`,{type:`button`,className:`kside-reopen fixed top-[60px] right-3.5 z-5 inline-flex cursor-pointer items-center gap-1 rounded-full border border-line bg-surface-2 px-3 py-1 text-2xs text-fg-2 hover:text-fg`,onClick:()=>de(!0),title:`Show knowledge sidebar`,children:[(0,I.jsx)(R,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function ec(e){if(!fe(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,I.jsx)(fs,{},`new-project`):r?(0,I.jsx)(Ys,{},`new-agent`):(0,I.jsx)(Ua,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,I.jsx)(_s,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,I.jsx)(qs,{slug:n},n):r&&t[2]===`edit`?(0,I.jsx)(Ys,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,I.jsx)(Ua,{slug:n},n):null}function tc({back:e,children:t}){let n=()=>H(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,I.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[6vh] pb-4 max-[800px]:p-0`,onMouseDown:n,children:(0,I.jsxs)(`div`,{className:`edit-modal relative max-h-[88dvh] w-[min(960px,100%)] animate-modal overflow-y-auto rounded-card border border-line bg-surface shadow-modal max-[800px]:max-h-dvh max-[800px]:rounded-none`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,I.jsx)(K,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,I.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function nc({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,I.jsx)(`section`,{className:P(rc,`decision-panel is-decided`),"aria-label":`decision`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,I.jsx)(`div`,{className:ic,children:n.title??`Decision`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,I.jsx)(q,{tone:`ok`,children:f(r.decision)}),r.note&&(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,I.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ge(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await A.request(`runs.decide`,{id:e,body:{decision:i,note:o.trim()}}).catch(()=>null);t?.ok||(d(t?.error??`could not save the decision`),l(!1))}return(0,I.jsx)(`section`,{className:P(rc,`decision-panel`),"aria-label":`decision needed`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)($e,{tone:`working`}),(0,I.jsx)(`div`,{className:ic,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,I.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,I.jsx)(G,{role:`radio`,"aria-checked":i===e.value,variant:i===e.value?`primary`:`secondary`,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,I.jsx)(Z,{value:o,placeholder:n.note===`required`?`Note (required)`:`Note`,"aria-label":`note`,className:`max-w-[60ch]`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),u&&(0,I.jsx)(tt,{tone:`bad`,children:u}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(G,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var rc=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,ic=`text-[16px] font-medium text-fg`;function ac(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function oc({status:e}){return(0,I.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,I.jsx)(q,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function sc(){return(0,I.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,I.jsx)(q,{tone:`accent`,children:`decision needed`})})}function cc({label:e,children:t,className:n}){return(0,I.jsxs)(`div`,{className:n,children:[(0,I.jsx)(nt,{className:`mb-px block`,children:e}),(0,I.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var lc=`mb-[22px] flex flex-wrap gap-[26px]`;function uc({id:e,workflow:t}){let n=N(`runs.list`,{},{fast:!0}),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,I.jsx)(Dt,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{label:`runs list`,children:[o.map(t=>(0,I.jsx)(dc,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,I.jsx)(kt,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,I.jsxs)(kt,{children:[`no run matches “`,i,`”`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:(0,I.jsx)(fc,{id:e},e)})]})}function dc({r:e,active:t}){return(0,I.jsx)(mt,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ge(e.startedAt),sub:(0,I.jsxs)(`span`,{className:`flex gap-2`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)})]})})}function fc({id:e}){let t=N(`runs.get`,{id:e},{fast:!0}),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=be();if(!t)return(0,I.jsx)(Y,{children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!yc(e.name)).length;async function p(){o(!0),c(null);let t=await A.request(`runs.stop`,{id:e}).catch(()=>null);t?.ok||(o(!1),c(t?.error??`stop failed`))}async function m(){if(!window.confirm(`Move run ${e} to the trash?`))return;c(null);let n=await A.request(`runs.delete`,{id:e}).catch(()=>null);n?.ok?H(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`):c(n?.error??`remove failed`)}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,I.jsx)($e,{tone:ac(t.status),title:t.status}),(0,I.jsx)(it,{size:`lg`,children:t.workflow?(0,I.jsx)(U,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,I.jsx)(oc,{status:t.status}),u&&(0,I.jsxs)(q,{children:[(0,I.jsx)(R,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,I.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,I.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Yo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,I.jsx)(ht,{className:`border-b-0 px-0`,label:`run sections`,value:d,onChange:i,items:[{id:`run`,label:`run`},{id:`artifacts`,label:`artifacts`,count:f}]})]}),t.request&&(0,I.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,I.jsx)(pc,{run:t,live:n}):(0,I.jsx)(xc,{id:e,files:t.files,live:n})]})}function pc({run:e,live:t}){return(0,I.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,I.jsx)(nc,{runId:e.id,decision:e.decision}),(0,I.jsxs)(`div`,{className:lc,children:[(0,I.jsxs)(cc,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,I.jsx)(cc,{label:`duration`,children:t?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),(0,I.jsx)(cc,{label:`cost`,children:He(e.costUsd??hc(e.phases))}),(0,I.jsxs)(cc,{label:`tokens in / out`,children:[Ue(mc(e.phases,`tokensIn`)),` / `,Ue(mc(e.phases,`tokensOut`))]})]}),(0,I.jsx)(X,{title:`phase timeline`,actions:t&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,I.jsx)($e,{tone:`working`}),` live · polling`]}),children:(0,I.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,I.jsx)(_c,{p:e},e.phase))})})]})}function mc(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function hc(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var gc=`relative border-line/55 [&+&]:border-t before:absolute before:top-0 before:bottom-0 before:w-px before:bg-line last:before:bottom-auto`;function _c({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,I.jsxs)(`div`,{className:P(gc,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,I.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,I.jsx)($e,{tone:ac(e.status),title:e.status})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,I.jsxs)(q,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,I.jsx)(q,{children:`script`}),e.status===`skipped`&&(0,I.jsx)(oc,{status:`skipped`}),(0,I.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,I.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):e.durationMs!=null&&(0,I.jsx)(`span`,{children:Ve(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,I.jsxs)(`span`,{children:[Ue(e.tokensIn),` / `,Ue(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:He(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,I.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,I.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,I.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-[5px] rounded-lg px-2.5 py-0.5 font-mono text-2xs`,e.passed?`bg-ok-soft text-ok`:`bg-bad-soft text-on-bad-soft`),title:e.failure??``,children:[(0,I.jsx)(R,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,I.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var vc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function yc(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function bc(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||vc.has(t)?0:yc(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function xc({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=be(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!yc(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&yc(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(bc(o))},[o,r]),(0,I.jsxs)(`div`,{className:`grid h-[calc(100vh-172px)] min-h-[420px] grid-cols-[280px_minmax(0,1fr)] gap-3.5 max-[940px]:h-auto max-[940px]:grid-cols-1`,children:[(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`files `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:P(`flex w-full cursor-pointer items-center gap-2.5 border-0 border-b border-line/55 px-[18px] py-2 text-left font-mono text-[12.5px] transition-colors last:border-b-0`,r===e.name?`bg-accent-soft text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),onClick:()=>i(e.name),children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,I.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:We(e.size)})]},e.name)),o.length===0&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,I.jsx)(X,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,I.jsx)(`a`,{className:Sc,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,I.jsx)(Dc,{id:e,name:r,live:n}):(0,I.jsx)(Y,{className:`flex-1 justify-center`,children:`select a file`})})]})}var Sc=`inline-flex h-7 items-center rounded-control px-2.5 text-sm font-medium text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-fg`,Cc=`flex min-h-0 flex-1 flex-col`,wc=`min-h-0 flex-1`,Tc=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Ec=`block h-full min-h-[560px] w-full border-0 bg-white`;function Dc({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=A.url(`runs.file`,{id:e,query:{name:t,raw:!0}});return r===`html`?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`iframe`,{className:Ec,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`iframe`,{className:Ec,src:i,title:t})})}):vc.has(r)?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`img`,{className:`block max-h-full max-w-full object-contain px-[18px] py-3.5`,src:i,alt:t})})}):r===`md`||r===`markdown`?(0,I.jsx)(kc,{id:e,name:t,live:n}):(0,I.jsx)(Ac,{id:e,name:t,live:n})}var Oc=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function kc({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=N(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?Da.sanitize(Jr.parse(a.content,{async:!1})):``,[a?.content]);return(0,I.jsxs)(`div`,{className:Cc,children:[(0,I.jsxs)(`div`,{className:Oc,children:[(0,I.jsx)(ht,{className:`border-b-0 px-0`,label:`markdown view`,value:r,onChange:i,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),a?.truncated&&(0,I.jsxs)(`span`,{children:[`large file — showing the last `,We(4e5)]})]}),(0,I.jsx)(`div`,{className:P(wc,`overflow-auto`),children:a?r===`rendered`?(0,I.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,I.jsx)(`pre`,{className:Tc,children:a.content||`(empty)`}):(0,I.jsx)(`pre`,{className:Tc,children:`loading…`})})]})}function Ac({id:e,name:t,live:n}){let r=N(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,I.jsxs)(`div`,{className:Cc,children:[r?.truncated&&(0,I.jsxs)(`div`,{className:Oc,children:[`large file — showing the last `,We(4e5)]}),(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`pre`,{className:Tc,children:r?r.content||`(empty)`:`loading…`})})]})}function jc(){return N(`workflows.runner`,{slug:`any`},{interval:15e3})}var Mc=e=>!!e?.available&&!!e?.image;function Nc(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function Pc(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Fc(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=jc();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!Mc(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||Mc(m));async function g(){if(h){d(!0),p(null);try{let t=await Pc(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):H(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function Ic({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Fc(e,t,n,r);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 pt-4 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-4 max-[700px]:flex-wrap`,children:[t?(0,I.jsx)(Z,{className:`h-11 min-w-0 flex-1 text-md`,value:i.request,placeholder:`Request`,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}):(0,I.jsx)(`span`,{className:`flex-1 text-base text-fg-2`,children:`This workflow takes no request.`}),(0,I.jsx)(G,{variant:`primary`,icon:`play_arrow`,className:`h-11 px-5 max-[700px]:w-full`,busy:i.busy,onClick:i.launch,disabled:!i.canRun,children:i.busy?`Starting…`:`Run`})]}),(0,I.jsxs)(`div`,{className:`-mx-2 mt-1 flex flex-wrap gap-x-2`,children:[(0,I.jsx)(Tt,{label:`Docker sandbox`,hint:Nc(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,I.jsx)(Tt,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,I.jsx)(tt,{tone:`bad`,children:i.error})]})}var Lc=`\0done`,Rc=5;function zc(e,t){return e.status===`ok`?Lc:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Lc}var Bc=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function Vc(e){return e==null?`var(--text-2)`:Bc[e%Bc.length]}function Hc({colour:e,children:t,small:n}){return(0,I.jsx)(`span`,{style:{"--aid":e},className:P(`relative z-1 grid flex-none place-items-center rounded-full border font-mono font-bold tabular-nums`,`border-[color-mix(in_srgb,var(--aid)_55%,var(--line))] bg-[color-mix(in_srgb,var(--aid)_18%,var(--surface-1))] text-[var(--aid)]`,n?`size-[22px] text-2xs`:`mt-px size-[26px] text-[11.5px]`),children:t})}function Uc({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Lc].map(e=>[e,[]]));for(let e of t)a.get(zc(e,i)).push(e);let o=a.get(Lc)??[];return(0,I.jsxs)(`div`,{className:`board flex items-start gap-3 overflow-x-auto px-[18px] pt-3.5 pb-[18px]`,children:[e.steps.map((e,t)=>{let i=a.get(e.name)??[];return(0,I.jsx)(Wc,{step:e.name,index:(0,I.jsx)(Hc,{small:!0,colour:Vc(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,I.jsx)(Gc,{cards:i,moreHref:r})},e.name)}),(0,I.jsx)(Wc,{step:`done`,name:`done`,done:!0,index:(0,I.jsx)(Hc,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,I.jsx)(Gc,{cards:o,moreHref:r})})]})}function Wc({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,I.jsxs)(`div`,{className:P(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,I.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,I.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function Gc({cards:e,moreHref:t}){return(0,I.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,Rc).map(e=>(0,I.jsx)(Kc,{r:e},e.id)),e.length===0&&(0,I.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>Rc&&(0,I.jsxs)(U,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-Rc,` more ↗`]})]})}function Kc({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,I.jsxs)(U,{href:`/runs/${e.id}`,className:`board-card block rounded-xl border border-line bg-surface px-3 py-2.5 text-inherit no-underline transition-colors hover:bg-surface-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,I.jsx)(`span`,{children:Ge(e.startedAt)}),(0,I.jsx)(`span`,{children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:He(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,I.jsx)(sc,{}),(e.status===`failed`||e.status===`aborted`)&&(0,I.jsx)(oc,{status:e.status})]})]})}function qc({slug:e,tab:t}){let n=N(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=N(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,I.jsx)(Y,{children:`loading…`});if(n.error)return(0,I.jsxs)(Y,{children:[(0,I.jsx)(q,{tone:`bad`,children:`broken workflow`}),(0,I.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(Yc,{slug:n.slug})})]});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5 in-[.ctx-embed]:mb-3 in-[.ctx-embed]:gap-y-2`,children:[(0,I.jsx)(it,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,I.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(ht,{bare:!0,label:`workflow sections`,value:t,items:[{id:`overview`,href:u,label:`overview`},{id:`details`,href:`${u}/details`,label:`details`},{id:`runs`,href:`${u}/runs`,label:(0,I.jsxs)(I.Fragment,{children:[`runs `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,I.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{className:`run-panel mb-[18px]`,children:(0,I.jsx)(Ic,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`board`,` `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,I.jsx)(Uc,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,I.jsx)(Jc,{wf:n,agentIdx:c}),t===`runs`&&(0,I.jsx)(Xc,{runs:l})]})}function Jc({wf:e,agentIdx:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:lc,children:[(0,I.jsx)(cc,{label:`agents`,children:e.agents.length}),(0,I.jsxs)(cc,{label:`steps`,children:[e.steps.length,` `,(0,I.jsxs)(`span`,{className:`font-normal text-fg-2`,children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent · `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]}),e.workspace&&(0,I.jsx)(cc,{label:`workspace`,className:`max-w-[420px]`,children:(0,I.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,I.jsx)(X,{title:`agents`,className:`mb-[18px]`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,I.jsx)(Qc,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,I.jsxs)(`div`,{className:`grid items-start gap-[18px] grid-cols-[minmax(430px,5fr)_minmax(360px,4fr)] max-[1100px]:grid-cols-1 in-[.ctx-embed]:grid-cols-1`,children:[(0,I.jsx)(X,{title:`pipeline`,children:(0,I.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,I.jsx)($c,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`folder `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,I.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,I.jsx)(`div`,{className:`truncate border-b border-line/55 px-[18px] py-2 font-mono text-[12.5px] text-fg-2 last:border-b-0`,children:e},e))})})]}),(0,I.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,I.jsx)(Yc,{slug:e.slug})})]})}function Yc({slug:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async()=>{i(!0),o(``);try{let t=await A.request(`workflows.delete`,{slug:e});if(!t.ok)throw Error(t.error||`failed`);H(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,I.jsx)(J,{children:`its runs stay; the trash can put it back`})]}):(0,I.jsx)(G,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,I.jsx)(tt,{tone:`bad`,children:a})]})}function Xc({runs:e}){return e.length===0?(0,I.jsx)(Y,{children:`no runs of this workflow yet`}):(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,I.jsxs)(U,{href:`/runs/${e.id}`,className:`run-card grid grid-cols-[12px_200px_1fr_auto] items-center gap-x-4 gap-y-2 rounded-card border border-line bg-surface px-5 py-3.5 text-inherit no-underline transition-colors hover:bg-surface-2 max-[900px]:grid-cols-[12px_1fr]`,children:[(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),(0,I.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,I.jsxs)(`span`,{className:`flex items-center gap-3.5 font-mono text-xs tabular-nums text-fg-2 max-[900px]:col-span-2`,children:[e.awaitingDecision&&(0,I.jsx)(sc,{}),(0,I.jsx)(oc,{status:e.status}),(0,I.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,I.jsx)(`i`,{className:P(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,I.jsx)(`span`,{children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),(0,I.jsx)(`span`,{children:He(e.costUsd)}),(0,I.jsx)(`span`,{children:Ge(e.startedAt)})]})]},e.id)})})}var Zc=`border-line/55`;function Qc({a:e,idx:t}){return(0,I.jsxs)(`div`,{className:P(`agent-card border-r border-b px-[18px] py-3.5`,Zc),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:Vc(t)}}),(0,I.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,I.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(q,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,I.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,I.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-px font-mono text-2xs text-fg-2`,children:e},e))}),e.persona&&(0,I.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function $c({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,I.jsxs)(`div`,{className:P(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,gc),children:[(0,I.jsx)(Hc,{colour:Vc(n),children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:Vc(n??0),borderColor:`color-mix(in srgb, ${Vc(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,I.jsxs)(q,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,I.jsxs)(`details`,{className:`mt-1.5`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,I.jsx)(`pre`,{className:`mt-1.5 max-h-[360px] overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 text-[11.5px] leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:r})]}),e.gates.length>0&&(0,I.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] rounded-lg bg-surface-2 px-2.5 py-0.5 font-mono text-2xs text-fg-2`,children:[`⛨ `,e]},e))})]})]})}function el(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function tl(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function nl({slug:e,tab:t}){let n=N(`workflows.list`,{}),r=N(`runs.list`,{}),[i,a]=(0,v.useState)(``),o=(0,v.useMemo)(()=>n?.workflows??[],[n]),s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:el(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&H(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,I.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`workflows`,count:n?o.length:void 0,action:(0,I.jsxs)(G,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,I.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,I.jsx)(Dt,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{children:[c.map(t=>{let n=el(s,t);return(0,I.jsx)(mt,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,I.jsx)($e,{tone:ac(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,I.jsx)(q,{tone:`bad`,children:`broken`}),meta:n.last&&W(n.last.updatedAt),sub:(0,I.jsx)(`span`,{title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),subTone:t.error?`bad`:`plain`,actionsAlways:!0,actions:n.last?(0,I.jsxs)(`button`,{type:`button`,className:`wf-runs inline-flex cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent px-1.5 py-0.5 text-2xs tabular-nums text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg`,title:`show the runs of this workflow`,onClick:()=>H(tl(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,I.jsx)(oc,{status:n.last.status})]}):(0,I.jsx)(`span`,{className:`wf-runs px-1.5 text-2xs text-fg-2 opacity-80`,children:`no runs yet`})},t.slug)}),n&&o.length>0&&c.length===0&&(0,I.jsxs)(kt,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,I.jsx)(kt,{children:`no workflows yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(qc,{slug:e,tab:t},e):n&&o.length===0?(0,I.jsxs)(Y,{icon:`account_tree`,children:[`No workflows found — expected `,(0,I.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,I.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,I.jsx)(Y,{children:`loading…`})})]})}var rl=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,il=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function al(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function ol(e,t,n){switch(e.scope.kind){case`agent`:{let r=e.scope.slug,i=t.find(e=>e.slug===r),a=i?`${i.emoji||`🤖`} ${i.name}`:r;return e.project?`📁 ${n(e.project)} · ${a}`:a}case`project`:return`📁 ${n(e.scope.slug)}`;case`channel`:return e.project?`📁 ${n(e.project)} · #${e.scope.slug}`:`#${e.scope.slug}`;case`run`:return`⚙️ run ${e.scope.runId}`;case`knowledge`:return e.scope.bundle?`📚 ${e.scope.bundle}`:`📚 knowledge`;default:return`🎩 Ralv`}}function sl(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function cl(){let e=N(`runs.list`,{}),t=N(`chats.list`,{}),n=N(`knowledge.list`,{}),r=N(`agents.list`,{}),i=N(`workflows.list`,{}),a=N(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=be(),l=N(`projects.list`,{},{interval:3e4}),u=e=>l?.projects.find(t=>t.slug===e)?.title??e,d=e?.runs??[],f=t?.chats??[],p=n?.bundles??[],m=(a?.skills??[]).filter(e=>e.source===`workspace`),h=[[i?.workflows.length,`workflows`,`/workflows`],[e?d.length:void 0,`runs`,`/runs`],[n?p.length:void 0,`bundles`,`/knowledge`],[a?m.length:void 0,`skills`,`/skills`],[t?f.length:void 0,`chats`,`/agents/chats`]],g=d.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,I.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,I.jsx)(gl,{runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:u,loaded:!!e&&!!t}),c&&(0,I.jsx)(`div`,{className:`mx-0.5 mt-3.5 mb-3 flex flex-wrap justify-end gap-x-[18px] gap-y-1 text-xs text-fg-2 max-[800px]:justify-start max-[800px]:gap-x-3.5`,children:h.map(([e,t,n])=>(0,I.jsxs)(U,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,I.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),c&&g.length>0&&o!==`failed`&&(0,I.jsxs)(`button`,{type:`button`,className:`mb-3.5 flex w-full cursor-pointer items-center gap-2 rounded-xl border border-bad/40 bg-bad-soft px-3.5 py-[9px] text-left text-[12.5px] text-on-bad-soft hover:brightness-104`,onClick:()=>s(`failed`),children:[`⚠ `,g.length,` run`,g.length===1?``:`s`,` failed in the last 24 h — review`]}),c&&(0,I.jsx)(dl,{projectTitle:u,runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function ll(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var ul=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function dl({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=be(),l=(0,v.useMemo)(()=>{let s=[],l=e=>e?a.find(t=>t.slug===e)?.name??e:void 0;for(let e of t)s.push({at:e.updatedAt,kind:`run`,emoji:`⚙️`,title:l(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:rl(e.status),status:il(e.status)});for(let t of n){let n=t.scope.kind===`agent`?i.find(e=>t.scope.kind===`agent`&&e.slug===t.scope.slug):void 0;s.push({at:t.updatedAt,kind:`session`,emoji:n?n.emoji||`🤖`:`💬`,title:n?n.name:t.title||`new chat`,sub:n?`${t.title||`new chat`}${c?` · ${t.agent}`:``}`:c?`${t.agent} · ${ol(t,i,e)}`:ol(t,i,e),href:al(t),lamp:t.awaitingApproval?`blocked`:t.busy?`running`:`ok`,status:t.awaitingApproval?`needs approval`:t.busy?`working`:void 0})}for(let e of r)e.updatedAt&&s.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(o===`all`?s:o===`failed`?s.filter(e=>e.kind===`run`&&e.lamp===`failed`):s.filter(e=>e.kind===o)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[t,n,r,i,c,o]),u=``,d=(e,t)=>P(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?P(`border-transparent`,t?`bg-bad-soft text-on-bad-soft`:`bg-accent-soft text-on-accent-soft`):`border-line bg-transparent text-fg-2 hover:text-fg`);return(0,I.jsx)(X,{className:`animate-rise`,title:`all activity`,actions:(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[ul.map(([e,t])=>(0,I.jsx)(`button`,{type:`button`,className:d(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,I.jsxs)(`button`,{type:`button`,className:d(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,I.jsx)(R,{name:`close`,className:`ms-sm`})]})]}),children:l.length===0?(0,I.jsx)(`div`,{className:`px-[18px] py-4 text-sm text-fg-2`,children:o===`all`?`nothing yet — run a workflow or start a chat`:`nothing here for this filter`}):(0,I.jsx)(`div`,{className:`flex flex-col p-1.5`,children:l.map(e=>{let t=ll(e),n=t===u?null:t;return u=t,(0,I.jsxs)(`div`,{children:[n&&(0,I.jsx)(nt,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,I.jsx)(mt,{href:e.href,leading:(0,I.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,I.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,I.jsx)($e,{tone:`working`})})]}),title:sl(e.title),titleExtra:(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsx)(q,{tone:fl[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&sl(e.sub),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,I.jsx)(q,{tone:pl[e.lamp]??`neutral`,children:e.status}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:W(e.at)}),(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var fl={run:`accent`,session:`ask`,knowledge:`ok`},pl={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function ml(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return t<1?`just started`:t<60?`${t} min`:`${Math.floor(t/60)} h ${t%60} min`}var hl=e=>new Date(e).toDateString()===new Date().toDateString();function gl({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=Lt()??[],c=z(),l=N(`agents.status`,{},{interval:5e3}),u=e=>e?i.find(t=>t.slug===e)?.name??e:`workflow`,d=new Map;for(let e of Object.values(l??{}))for(let t of e.working)t.since&&d.set(t.chatId,t.since);let f=[...t.filter(e=>e.busy&&!e.awaitingApproval).map(e=>({key:`c:${e.id}`,owner:ol(e,r,a),title:sl(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${ml(d.get(e.id))}`:``}`,href:al(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:sl(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&hl(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:ol(e,r,a),title:sl(e.title),meta:W(e.updatedAt),href:al(e)})),...e.filter(e=>e.status!==`running`&&hl(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:sl(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${W(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&hl(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:W(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=Wt(s,c),h=o&&s.length===0&&f.length===0;return(0,I.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,I.jsxs)(X,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,I.jsxs)(G,{variant:`primary`,size:`sm`,onClick:()=>Gt(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:h?`Nothing waiting, nothing running.`:`Nothing is waiting for you.`}):(0,I.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,I.jsx)(mt,{className:`today-row waiting`,onClick:()=>Gt(e),over:Vt(e.owner),title:e.title,meta:(0,I.jsxs)(`span`,{className:`font-semibold text-bad`,children:[Bt(e.kind),` · `,W(e.since)]})},e.id))}),h&&(0,I.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,I.jsx)(G,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,I.jsx)(X,{className:`today-section`,title:`in progress`,children:(0,I.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,I.jsx)(_l,{r:e},e.key))})}),(0,I.jsx)(X,{className:`today-section`,title:`done today`,children:p.length===0?(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,I.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,I.jsx)(_l,{r:e},e.key))})})]})}function _l({r:e}){return(0,I.jsx)(mt,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,I.jsx)($e,{tone:`working`}),e.meta]})})}var vl=l(o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.leaflet={}))})(n,(function(e){var t=`1.9.4`;function n(e){for(var t,n=1,r=arguments.length,i;n<r;n++)for(t in i=arguments[n],i)e[t]=i[t];return e}var r=Object.create||(function(){function e(){}return function(t){return e.prototype=t,new e}})();function i(e,t){var n=Array.prototype.slice;if(e.bind)return e.bind.apply(e,n.call(arguments,1));var r=n.call(arguments,2);return function(){return e.apply(t,r.length?r.concat(n.call(arguments)):arguments)}}var a=0;function o(e){return`_leaflet_id`in e||(e._leaflet_id=++a),e._leaflet_id}function s(e,t,n){var r,i,a,o=function(){r=!1,i&&=(a.apply(n,i),!1)};return a=function(){r?i=arguments:(e.apply(n,arguments),setTimeout(o,t),r=!0)},a}function c(e,t,n){var r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function l(){return!1}function u(e,t){if(t===!1)return e;var n=10**(t===void 0?6:t);return Math.round(e*n)/n}function d(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,``)}function f(e){return d(e).split(/\s+/)}function p(e,t){for(var n in Object.prototype.hasOwnProperty.call(e,`options`)||(e.options=e.options?r(e.options):{}),t)e.options[n]=t[n];return e.options}function m(e,t,n){var r=[];for(var i in e)r.push(encodeURIComponent(n?i.toUpperCase():i)+`=`+encodeURIComponent(e[i]));return(!t||t.indexOf(`?`)===-1?`?`:`&`)+r.join(`&`)}var h=/\{ *([\w_ -]+) *\}/g;function g(e,t){return e.replace(h,function(e,n){var r=t[n];if(r===void 0)throw Error(`No value provided for variable `+e);return typeof r==`function`&&(r=r(t)),r})}var _=Array.isArray||function(e){return Object.prototype.toString.call(e)===`[object Array]`};function v(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var y=`data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=`;function b(e){return window[`webkit`+e]||window[`moz`+e]||window[`ms`+e]}var x=0;function S(e){var t=+new Date,n=Math.max(0,16-(t-x));return x=t+n,window.setTimeout(e,n)}var C=window.requestAnimationFrame||b(`RequestAnimationFrame`)||S,w=window.cancelAnimationFrame||b(`CancelAnimationFrame`)||b(`CancelRequestAnimationFrame`)||function(e){window.clearTimeout(e)};function T(e,t,n){if(n&&C===S)e.call(t);else return C.call(window,i(e,t))}function E(e){e&&w.call(window,e)}var D={__proto__:null,extend:n,create:r,bind:i,get lastId(){return a},stamp:o,throttle:s,wrapNum:c,falseFn:l,formatNum:u,trim:d,splitWords:f,setOptions:p,getParamString:m,template:g,isArray:_,indexOf:v,emptyImageUrl:y,requestFn:C,cancelFn:w,requestAnimFrame:T,cancelAnimFrame:E};function O(){}O.extend=function(e){var t=function(){p(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},i=t.__super__=this.prototype,a=r(i);for(var o in a.constructor=t,t.prototype=a,this)Object.prototype.hasOwnProperty.call(this,o)&&o!==`prototype`&&o!==`__super__`&&(t[o]=this[o]);return e.statics&&n(t,e.statics),e.includes&&(k(e.includes),n.apply(null,[a].concat(e.includes))),n(a,e),delete a.statics,delete a.includes,a.options&&(a.options=i.options?r(i.options):{},n(a.options,e.options)),a._initHooks=[],a.callInitHooks=function(){if(!this._initHooksCalled){i.callInitHooks&&i.callInitHooks.call(this),this._initHooksCalled=!0;for(var e=0,t=a._initHooks.length;e<t;e++)a._initHooks[e].call(this)}},t},O.include=function(e){var t=this.prototype.options;return n(this.prototype,e),e.options&&(this.prototype.options=t,this.mergeOptions(e.options)),this},O.mergeOptions=function(e){return n(this.prototype.options,e),this},O.addInitHook=function(e){var t=Array.prototype.slice.call(arguments,1),n=typeof e==`function`?e:function(){this[e].apply(this,t)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(n),this};function k(e){if(typeof L<`u`&&L&&L.Mixin){e=_(e)?e:[e];for(var t=0;t<e.length;t++)e[t]===L.Mixin.Events&&console.warn(`Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.`,Error().stack)}}var A={on:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n)}return this},off:function(e,t,n){if(!arguments.length)delete this._events;else if(typeof e==`object`)for(var r in e)this._off(r,e[r],t);else{e=f(e);for(var i=arguments.length===1,a=0,o=e.length;a<o;a++)i?this._off(e[a]):this._off(e[a],t,n)}return this},_on:function(e,t,n,r){if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else if(this._listens(e,t,n)===!1){n===this&&(n=void 0);var i={fn:t,ctx:n};r&&(i.once=!0),this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(i)}},_off:function(e,t,n){var r,i,a;if(this._events&&(r=this._events[e],r)){if(arguments.length===1){if(this._firingCount)for(i=0,a=r.length;i<a;i++)r[i].fn=l;delete this._events[e]}else if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else{var o=this._listens(e,t,n);if(o!==!1){var s=r[o];this._firingCount&&(s.fn=l,this._events[e]=r=r.slice()),r.splice(o,1)}}}},fire:function(e,t,r){if(!this.listens(e,r))return this;var i=n({},t,{type:e,target:this,sourceTarget:t&&t.sourceTarget||this});if(this._events){var a=this._events[e];if(a){this._firingCount=this._firingCount+1||1;for(var o=0,s=a.length;o<s;o++){var c=a[o],l=c.fn;c.once&&this.off(e,l,c.ctx),l.call(c.ctx||this,i)}this._firingCount--}}return r&&this._propagateEvent(i),this},listens:function(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);var i=t;typeof t!=`function`&&(r=!!t,i=void 0,n=void 0);var a=this._events&&this._events[e];if(a&&a.length&&this._listens(e,i,n)!==!1)return!0;if(r){for(var o in this._eventParents)if(this._eventParents[o].listens(e,t,n,r))return!0}return!1},_listens:function(e,t,n){if(!this._events)return!1;var r=this._events[e]||[];if(!t)return!!r.length;n===this&&(n=void 0);for(var i=0,a=r.length;i<a;i++)if(r[i].fn===t&&r[i].ctx===n)return i;return!1},once:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t,!0);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n,!0)}return this},addEventParent:function(e){return this._eventParents=this._eventParents||{},this._eventParents[o(e)]=e,this},removeEventParent:function(e){return this._eventParents&&delete this._eventParents[o(e)],this},_propagateEvent:function(e){for(var t in this._eventParents)this._eventParents[t].fire(e.type,n({layer:e.target,propagatedFrom:e.target},e),!0)}};A.addEventListener=A.on,A.removeEventListener=A.clearAllEventListeners=A.off,A.addOneTimeEventListener=A.once,A.fireEvent=A.fire,A.hasEventListeners=A.listens;var ee=O.extend(A);function j(e,t,n){this.x=n?Math.round(e):e,this.y=n?Math.round(t):t}var M=Math.trunc||function(e){return e>0?Math.floor(e):Math.ceil(e)};j.prototype={clone:function(){return new j(this.x,this.y)},add:function(e){return this.clone()._add(N(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(N(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},scaleBy:function(e){return new j(this.x*e.x,this.y*e.y)},unscaleBy:function(e){return new j(this.x/e.x,this.y/e.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=M(this.x),this.y=M(this.y),this},distanceTo:function(e){e=N(e);var t=e.x-this.x,n=e.y-this.y;return Math.sqrt(t*t+n*n)},equals:function(e){return e=N(e),e.x===this.x&&e.y===this.y},contains:function(e){return e=N(e),Math.abs(e.x)<=Math.abs(this.x)&&Math.abs(e.y)<=Math.abs(this.y)},toString:function(){return`Point(`+u(this.x)+`, `+u(this.y)+`)`}};function N(e,t,n){return e instanceof j?e:_(e)?new j(e[0],e[1]):e==null?e:typeof e==`object`&&`x`in e&&`y`in e?new j(e.x,e.y):new j(e,t,n)}function P(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}P.prototype={extend:function(e){var t,n;if(!e)return this;if(e instanceof j||typeof e[0]==`number`||`x`in e)t=n=N(e);else if(e=F(e),t=e.min,n=e.max,!t||!n)return this;return!this.min&&!this.max?(this.min=t.clone(),this.max=n.clone()):(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(n.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(n.y,this.max.y)),this},getCenter:function(e){return N((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)},getBottomLeft:function(){return N(this.min.x,this.max.y)},getTopRight:function(){return N(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(e){var t,n;return e=typeof e[0]==`number`||e instanceof j?N(e):F(e),e instanceof P?(t=e.min,n=e.max):t=n=e,t.x>=this.min.x&&n.x<=this.max.x&&t.y>=this.min.y&&n.y<=this.max.y},intersects:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return a&&o},overlaps:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>t.x&&r.x<n.x,o=i.y>t.y&&r.y<n.y;return a&&o},isValid:function(){return!!(this.min&&this.max)},pad:function(e){var t=this.min,n=this.max,r=Math.abs(t.x-n.x)*e,i=Math.abs(t.y-n.y)*e;return F(N(t.x-r,t.y-i),N(n.x+r,n.y+i))},equals:function(e){return e?(e=F(e),this.min.equals(e.getTopLeft())&&this.max.equals(e.getBottomRight())):!1}};function F(e,t){return!e||e instanceof P?e:new P(e,t)}function te(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}te.prototype={extend:function(e){var t=this._southWest,n=this._northEast,r,i;if(e instanceof R)r=e,i=e;else if(e instanceof te){if(r=e._southWest,i=e._northEast,!r||!i)return this}else return e?this.extend(z(e)||I(e)):this;return!t&&!n?(this._southWest=new R(r.lat,r.lng),this._northEast=new R(i.lat,i.lng)):(t.lat=Math.min(r.lat,t.lat),t.lng=Math.min(r.lng,t.lng),n.lat=Math.max(i.lat,n.lat),n.lng=Math.max(i.lng,n.lng)),this},pad:function(e){var t=this._southWest,n=this._northEast,r=Math.abs(t.lat-n.lat)*e,i=Math.abs(t.lng-n.lng)*e;return new te(new R(t.lat-r,t.lng-i),new R(n.lat+r,n.lng+i))},getCenter:function(){return new R((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new R(this.getNorth(),this.getWest())},getSouthEast:function(){return new R(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(e){e=typeof e[0]==`number`||e instanceof R||`lat`in e?z(e):I(e);var t=this._southWest,n=this._northEast,r,i;return e instanceof te?(r=e.getSouthWest(),i=e.getNorthEast()):r=i=e,r.lat>=t.lat&&i.lat<=n.lat&&r.lng>=t.lng&&i.lng<=n.lng},intersects:function(e){e=I(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return a&&o},overlaps:function(e){e=I(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>t.lat&&r.lat<n.lat,o=i.lng>t.lng&&r.lng<n.lng;return a&&o},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)},equals:function(e,t){return e?(e=I(e),this._southWest.equals(e.getSouthWest(),t)&&this._northEast.equals(e.getNorthEast(),t)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function I(e,t){return e instanceof te?e:new te(e,t)}function R(e,t,n){if(isNaN(e)||isNaN(t))throw Error(`Invalid LatLng object: (`+e+`, `+t+`)`);this.lat=+e,this.lng=+t,n!==void 0&&(this.alt=+n)}R.prototype={equals:function(e,t){return e?(e=z(e),Math.max(Math.abs(this.lat-e.lat),Math.abs(this.lng-e.lng))<=(t===void 0?1e-9:t)):!1},toString:function(e){return`LatLng(`+u(this.lat,e)+`, `+u(this.lng,e)+`)`},distanceTo:function(e){return re.distance(this,z(e))},wrap:function(){return re.wrapLatLng(this)},toBounds:function(e){var t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return I([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])},clone:function(){return new R(this.lat,this.lng,this.alt)}};function z(e,t,n){return e instanceof R?e:_(e)&&typeof e[0]!=`object`?e.length===3?new R(e[0],e[1],e[2]):e.length===2?new R(e[0],e[1]):null:e==null?e:typeof e==`object`&&`lat`in e?new R(e.lat,`lng`in e?e.lng:e.lon,e.alt):t===void 0?null:new R(e,t,n)}var ne={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},unproject:function(e){return this.projection.unproject(e)},scale:function(e){return 256*2**e},zoom:function(e){return Math.log(e/256)/Math.LN2},getProjectedBounds:function(e){if(this.infinite)return null;var t=this.projection.bounds,n=this.scale(e);return new P(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))},infinite:!1,wrapLatLng:function(e){var t=this.wrapLng?c(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?c(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new R(n,t,r)},wrapLatLngBounds:function(e){var t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;var a=e.getSouthWest(),o=e.getNorthEast();return new te(new R(a.lat-r,a.lng-i),new R(o.lat-r,o.lng-i))}},re=n({},ne,{wrapLng:[-180,180],R:6371e3,distance:function(e,t){var n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin((t.lat-e.lat)*n/2),o=Math.sin((t.lng-e.lng)*n/2),s=a*a+Math.cos(r)*Math.cos(i)*o*o,c=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s));return this.R*c}}),ie=6378137,ae={R:ie,MAX_LATITUDE:85.0511287798,project:function(e){var t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new j(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject:function(e){var t=180/Math.PI;return new R((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:(function(){var e=ie*Math.PI;return new P([-e,-e],[e,e])})()};function oe(e,t,n,r){_(e)?(this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3]):(this._a=e,this._b=t,this._c=n,this._d=r)}oe.prototype={transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(e,t){return t||=1,new j((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}};function se(e,t,n,r){return new oe(e,t,n,r)}var ce=n({},re,{code:`EPSG:3857`,projection:ae,transformation:function(){var e=.5/(Math.PI*ae.R);return se(e,.5,-e,.5)}()}),le=n({},ce,{code:`EPSG:900913`});function ue(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}function de(e,t){for(var n=``,r=0,i,a=e.length,o,s,c;r<a;r++){for(s=e[r],i=0,o=s.length;i<o;i++)c=s[i],n+=(i?`L`:`M`)+c.x+` `+c.y;n+=t?W.svg?`z`:`x`:``}return n||`M0 0`}var B=document.documentElement.style,V=`ActiveXObject`in window,fe=V&&!document.addEventListener,H=`msLaunchUri`in navigator&&!(`documentMode`in document),pe=Ge(`webkit`),me=Ge(`android`),he=Ge(`android 2`)||Ge(`android 3`),U=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),ge=me&&Ge(`Google`)&&U<537&&!(`AudioNode`in window),_e=!!window.opera,ve=!H&&Ge(`chrome`),ye=Ge(`gecko`)&&!pe&&!_e&&!V,be=!ve&&Ge(`safari`),xe=Ge(`phantom`),Se=`OTransition`in B,Ce=navigator.platform.indexOf(`Win`)===0,we=V&&`transition`in B,Te=`WebKitCSSMatrix`in window&&`m11`in new window.WebKitCSSMatrix&&!he,Ee=`MozPerspective`in B,De=!window.L_DISABLE_3D&&(we||Te||Ee)&&!Se&&!xe,Oe=typeof orientation<`u`||Ge(`mobile`),ke=Oe&&pe,Ae=Oe&&Te,je=!window.PointerEvent&&window.MSPointerEvent,Me=!!(window.PointerEvent||je),Ne=`ontouchstart`in window||!!window.TouchEvent,Pe=!window.L_NO_TOUCH&&(Ne||Me),Fe=Oe&&_e,Ie=Oe&&ye,Le=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Re=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener(`testPassiveEventSupport`,l,t),window.removeEventListener(`testPassiveEventSupport`,l,t)}catch{}return e}(),ze=function(){return!!document.createElement(`canvas`).getContext}(),Be=!!(document.createElementNS&&ue(`svg`).createSVGRect),Ve=!!Be&&(function(){var e=document.createElement(`div`);return e.innerHTML=`<svg/>`,(e.firstChild&&e.firstChild.namespaceURI)===`http://www.w3.org/2000/svg`})(),He=!Be&&function(){try{var e=document.createElement(`div`);e.innerHTML=`<v:shape adj="1"/>`;var t=e.firstChild;return t.style.behavior=`url(#default#VML)`,t&&typeof t.adj==`object`}catch{return!1}}(),Ue=navigator.platform.indexOf(`Mac`)===0,We=navigator.platform.indexOf(`Linux`)===0;function Ge(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var W={ie:V,ielt9:fe,edge:H,webkit:pe,android:me,android23:he,androidStock:ge,opera:_e,chrome:ve,gecko:ye,safari:be,phantom:xe,opera12:Se,win:Ce,ie3d:we,webkit3d:Te,gecko3d:Ee,any3d:De,mobile:Oe,mobileWebkit:ke,mobileWebkit3d:Ae,msPointer:je,pointer:Me,touch:Pe,touchNative:Ne,mobileOpera:Fe,mobileGecko:Ie,retina:Le,passiveEvents:Re,canvas:ze,svg:Be,vml:He,inlineSvg:Ve,mac:Ue,linux:We},Ke=W.msPointer?`MSPointerDown`:`pointerdown`,qe=W.msPointer?`MSPointerMove`:`pointermove`,Je=W.msPointer?`MSPointerUp`:`pointerup`,Ye=W.msPointer?`MSPointerCancel`:`pointercancel`,Xe={touchstart:Ke,touchmove:qe,touchend:Je,touchcancel:Ye},Ze={touchstart:nt,touchmove:tt,touchend:tt,touchcancel:tt},G={},K=!1;function Qe(e,t,n){return t===`touchstart`&&Y(),Ze[t]?(n=Ze[t].bind(this,n),e.addEventListener(Xe[t],n,!1),n):(console.warn(`wrong event specified:`,t),l)}function $e(e,t,n){Xe[t]?e.removeEventListener(Xe[t],n,!1):console.warn(`wrong event specified:`,t)}function q(e){G[e.pointerId]=e}function et(e){G[e.pointerId]&&(G[e.pointerId]=e)}function J(e){delete G[e.pointerId]}function Y(){K||=(document.addEventListener(Ke,q,!0),document.addEventListener(qe,et,!0),document.addEventListener(Je,J,!0),document.addEventListener(Ye,J,!0),!0)}function tt(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||`mouse`)){for(var n in t.touches=[],G)t.touches.push(G[n]);t.changedTouches=[t],e(t)}}function nt(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&qt(t),tt(e,t)}function rt(e){var t={},n,r;for(r in e)n=e[r],t[r]=n&&n.bind?n.bind(e):n;return e=t,t.type=`dblclick`,t.detail=2,t.isTrusted=!1,t._simulated=!0,t}var X=200;function it(e,t){e.addEventListener(`dblclick`,t);var n=0,r;function i(e){if(e.detail!==1)r=e.detail;else if(!(e.pointerType===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)){var i=Yt(e);if(!i.some(function(e){return e instanceof HTMLLabelElement&&e.attributes.for})||i.some(function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement})){var a=Date.now();a-n<=X?(r++,r===2&&t(rt(e))):r=1,n=a}}}return e.addEventListener(`click`,i),{dblclick:t,simDblclick:i}}function at(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`click`,t.simDblclick)}var ot=xt([`transform`,`webkitTransform`,`OTransform`,`MozTransform`,`msTransform`]),st=xt([`webkitTransition`,`transition`,`OTransition`,`MozTransition`,`msTransition`]),ct=st===`webkitTransition`||st===`OTransition`?st+`End`:`transitionend`;function lt(e){return typeof e==`string`?document.getElementById(e):e}function ut(e,t){var n=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!n||n===`auto`)&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n===`auto`?null:n}function dt(e,t,n){var r=document.createElement(e);return r.className=t||``,n&&n.appendChild(r),r}function ft(e){var t=e.parentNode;t&&t.removeChild(e)}function pt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function mt(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function ht(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function gt(e,t){if(e.classList!==void 0)return e.classList.contains(t);var n=yt(e);return n.length>0&&RegExp(`(^|\\s)`+t+`(\\s|$)`).test(n)}function _t(e,t){if(e.classList!==void 0)for(var n=f(t),r=0,i=n.length;r<i;r++)e.classList.add(n[r]);else if(!gt(e,t)){var a=yt(e);Z(e,(a?a+` `:``)+t)}}function vt(e,t){e.classList===void 0?Z(e,d((` `+yt(e)+` `).replace(` `+t+` `,` `))):e.classList.remove(t)}function Z(e,t){e.className.baseVal===void 0?e.className=t:e.className.baseVal=t}function yt(e){return e.correspondingElement&&(e=e.correspondingElement),e.className.baseVal===void 0?e.className:e.className.baseVal}function bt(e,t){`opacity`in e.style?e.style.opacity=t:`filter`in e.style&&Q(e,t)}function Q(e,t){var n=!1,r=`DXImageTransform.Microsoft.Alpha`;try{n=e.filters.item(r)}catch{if(t===1)return}t=Math.round(t*100),n?(n.Enabled=t!==100,n.Opacity=t):e.style.filter+=` progid:`+r+`(opacity=`+t+`)`}function xt(e){for(var t=document.documentElement.style,n=0;n<e.length;n++)if(e[n]in t)return e[n];return!1}function St(e,t,n){var r=t||new j(0,0);e.style[ot]=(W.ie3d?`translate(`+r.x+`px,`+r.y+`px)`:`translate3d(`+r.x+`px,`+r.y+`px,0)`)+(n?` scale(`+n+`)`:``)}function $(e,t){e._leaflet_pos=t,W.any3d?St(e,t):(e.style.left=t.x+`px`,e.style.top=t.y+`px`)}function Ct(e){return e._leaflet_pos||new j(0,0)}var wt,Tt,Et;if(`onselectstart`in document)wt=function(){Lt(window,`selectstart`,qt)},Tt=function(){zt(window,`selectstart`,qt)};else{var Dt=xt([`userSelect`,`WebkitUserSelect`,`OUserSelect`,`MozUserSelect`,`msUserSelect`]);wt=function(){if(Dt){var e=document.documentElement.style;Et=e[Dt],e[Dt]=`none`}},Tt=function(){Dt&&(document.documentElement.style[Dt]=Et,Et=void 0)}}function Ot(){Lt(window,`dragstart`,qt)}function kt(){zt(window,`dragstart`,qt)}var At,jt;function Mt(e){for(;e.tabIndex===-1;)e=e.parentNode;e.style&&(Nt(),At=e,jt=e.style.outlineStyle,e.style.outlineStyle=`none`,Lt(window,`keydown`,Nt))}function Nt(){At&&(At.style.outlineStyle=jt,At=void 0,jt=void 0,zt(window,`keydown`,Nt))}function Pt(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function Ft(e){var t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}var It={__proto__:null,TRANSFORM:ot,TRANSITION:st,TRANSITION_END:ct,get:lt,getStyle:ut,create:dt,remove:ft,empty:pt,toFront:mt,toBack:ht,hasClass:gt,addClass:_t,removeClass:vt,setClass:Z,getClass:yt,setOpacity:bt,testProp:xt,setTransform:St,setPosition:$,getPosition:Ct,get disableTextSelection(){return wt},get enableTextSelection(){return Tt},disableImageDrag:Ot,enableImageDrag:kt,preventOutline:Mt,restoreOutline:Nt,getSizedParentNode:Pt,getScale:Ft};function Lt(e,t,n,r){if(t&&typeof t==`object`)for(var i in t)Ht(e,i,t[i],n);else{t=f(t);for(var a=0,o=t.length;a<o;a++)Ht(e,t[a],n,r)}return this}var Rt=`_leaflet_events`;function zt(e,t,n,r){if(arguments.length===1)Bt(e),delete e[Rt];else if(t&&typeof t==`object`)for(var i in t)Ut(e,i,t[i],n);else if(t=f(t),arguments.length===2)Bt(e,function(e){return v(t,e)!==-1});else for(var a=0,o=t.length;a<o;a++)Ut(e,t[a],n,r);return this}function Bt(e,t){for(var n in e[Rt]){var r=n.split(/\d/)[0];(!t||t(r))&&Ut(e,r,null,null,n)}}var Vt={mouseenter:`mouseover`,mouseleave:`mouseout`,wheel:!(`onwheel`in window)&&`mousewheel`};function Ht(e,t,n,r){var i=t+o(n)+(r?`_`+o(r):``);if(e[Rt]&&e[Rt][i])return this;var a=function(t){return n.call(r||e,t||window.event)},s=a;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?a=Qe(e,t,a):W.touch&&t===`dblclick`?a=it(e,a):`addEventListener`in e?t===`touchstart`||t===`touchmove`||t===`wheel`||t===`mousewheel`?e.addEventListener(Vt[t]||t,a,W.passiveEvents?{passive:!1}:!1):t===`mouseenter`||t===`mouseleave`?(a=function(t){t||=window.event,$t(e,t)&&s(t)},e.addEventListener(Vt[t],a,!1)):e.addEventListener(t,s,!1):e.attachEvent(`on`+t,a),e[Rt]=e[Rt]||{},e[Rt][i]=a}function Ut(e,t,n,r,i){i||=t+o(n)+(r?`_`+o(r):``);var a=e[Rt]&&e[Rt][i];if(!a)return this;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?$e(e,t,a):W.touch&&t===`dblclick`?at(e,a):`removeEventListener`in e?e.removeEventListener(Vt[t]||t,a,!1):e.detachEvent(`on`+t,a),e[Rt][i]=null}function Wt(e){return e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:e.cancelBubble=!0,this}function Gt(e){return Ht(e,`wheel`,Wt),this}function Kt(e){return Lt(e,`mousedown touchstart dblclick contextmenu`,Wt),e._leaflet_disable_click=!0,this}function qt(e){return e.preventDefault?e.preventDefault():e.returnValue=!1,this}function Jt(e){return qt(e),Wt(e),this}function Yt(e){if(e.composedPath)return e.composedPath();for(var t=[],n=e.target;n;)t.push(n),n=n.parentNode;return t}function Xt(e,t){if(!t)return new j(e.clientX,e.clientY);var n=Ft(t),r=n.boundingClientRect;return new j((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}var Zt=W.linux&&W.chrome?window.devicePixelRatio:W.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Qt(e){return W.edge?e.wheelDeltaY/2:e.deltaY&&e.deltaMode===0?-e.deltaY/Zt:e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?-e.detail*20:e.detail?e.detail/-32765*60:0}function $t(e,t){var n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch{return!1}return n!==e}var en={__proto__:null,on:Lt,off:zt,stopPropagation:Wt,disableScrollPropagation:Gt,disableClickPropagation:Kt,preventDefault:qt,stop:Jt,getPropagationPath:Yt,getMousePosition:Xt,getWheelDelta:Qt,isExternalTarget:$t,addListener:Lt,removeListener:zt},tn=ee.extend({run:function(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(r||.5,.2),this._startPos=Ct(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire(`start`),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())},_runFrame:function(e,t){var n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),$(this._el,n),this.fire(`step`)},_complete:function(){E(this._animId),this._inProgress=!1,this.fire(`end`)},_easeOut:function(e){return 1-(1-e)**this._easeOutPower}}),nn=ee.extend({options:{crs:ce,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(e,t){t=p(this,t),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(e),this._initLayout(),this._onResize=i(this._onResize,this),this._initEvents(),t.maxBounds&&this.setMaxBounds(t.maxBounds),t.zoom!==void 0&&(this._zoom=this._limitZoom(t.zoom)),t.center&&t.zoom!==void 0&&this.setView(z(t.center),t.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=st&&W.any3d&&!W.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Lt(this._proxy,ct,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(e,t,r){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(z(e),t,this.options.maxBounds),r||={},this._stop(),this._loaded&&!r.reset&&r!==!0&&(r.animate!==void 0&&(r.zoom=n({animate:r.animate},r.zoom),r.pan=n({animate:r.animate,duration:r.duration},r.pan)),this._zoom===t?this._tryAnimatedPan(e,r.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,r.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,r.pan&&r.pan.noMoveStart),this)},setZoom:function(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)},zoomIn:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom+e,t)},zoomOut:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom-e,t)},setZoomAround:function(e,t,n){var r=this.getZoomScale(t),i=this.getSize().divideBy(2),a=(e instanceof j?e:this.latLngToContainerPoint(e)).subtract(i).multiplyBy(1-1/r),o=this.containerPointToLatLng(i.add(a));return this.setView(o,t,{zoom:n})},_getBoundsCenterZoom:function(e,t){t||={},e=e.getBounds?e.getBounds():I(e);var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};var a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}},fitBounds:function(e,t){if(e=I(e),!e.isValid())throw Error(`Bounds are not valid.`);var n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)},fitWorld:function(e){return this.fitBounds([[-90,-180],[90,180]],e)},panTo:function(e,t){return this.setView(e,this._zoom,{pan:t})},panBy:function(e,t){if(e=N(e).round(),t||={},!e.x&&!e.y)return this.fire(`moveend`);if(t.animate!==!0&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new tn,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`),t.animate!==!1){_t(this._mapPane,`leaflet-pan-anim`);var n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this.fire(`move`).fire(`moveend`);return this},flyTo:function(e,t,n){if(n||={},n.animate===!1||!W.any3d)return this.setView(e,t,n);this._stop();var r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom;e=z(e),t=t===void 0?o:t;var s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){var t=e?-1:1,n=e?c:s,r=(c*c-s*s+t*d*d*l*l)/(2*n*d*l),i=Math.sqrt(r*r+1)-r;return i<1e-9?-18:Math.log(i)}function p(e){return(Math.exp(e)-Math.exp(-e))/2}function m(e){return(Math.exp(e)+Math.exp(-e))/2}function h(e){return p(e)/m(e)}var g=f(0);function _(e){return s*(m(g)/m(g+u*e))}function v(e){return s*(m(g)*h(g+u*e)-p(g))/d}function y(e){return 1-(1-e)**1.5}var b=Date.now(),x=(f(1)-g)/u,S=n.duration?1e3*n.duration:1e3*x*.8;function C(){var n=(Date.now()-b)/S,a=y(n)*x;n<=1?(this._flyToFrame=T(C,this),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(v(a)/l)),o),this.getScaleZoom(s/_(a),o),{flyTo:!0})):this._move(e,t)._moveEnd(!0)}return this._moveStart(!0,n.noMoveStart),C.call(this),this},flyToBounds:function(e,t){var n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)},setMaxBounds:function(e){return e=I(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(e){var t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this},setMaxZoom:function(e){var t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var n=this.getCenter(),r=this._limitCenter(n,this._zoom,I(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this},panInside:function(e,t){t||={};var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=F([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;var l=a.subtract(s.getCenter()),u=s.extend(a).getSize().subtract(c);i.x+=l.x<0?-u.x:u.x,i.y+=l.y<0?-u.y:u.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=n({animate:!1,pan:!0},e===!0?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),a=t.divideBy(2).round(),o=r.divideBy(2).round(),s=a.subtract(o);return!s.x&&!s.y?this:(e.animate&&e.pan?this.panBy(s):(e.pan&&this._rawPanBy(s),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(i(this.fire,this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:r}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()},locate:function(e){if(e=this._locateOptions=n({timeout:1e4,watch:!1},e),!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;var t=i(this._handleGeolocationResponse,this),r=i(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,r,e):navigator.geolocation.getCurrentPosition(t,r,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: `+n+`.`})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=e.coords.latitude,n=e.coords.longitude,r=new R(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){var o=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(o,a.maxZoom):o)}var s={latlng:r,bounds:i,timestamp:e.timestamp};for(var c in e.coords)typeof e.coords[c]==`number`&&(s[c]=e.coords[c]);this.fire(`locationfound`,s)}},addHandler:function(e,t){if(!t)return this;var n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw Error(`Map container is being reused by another instance`);try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}for(var e in this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ft(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&=(E(this._resizeRequest),null),this._clearHandlers(),this._loaded&&this.fire(`unload`),this._layers)this._layers[e].remove();for(e in this._panes)ft(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var n=dt(`div`,`leaflet-pane`+(e?` leaflet-`+e.replace(`Pane`,``)+`-pane`:``),t||this._mapPane);return e&&(this._panes[e]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new te(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=I(e),n=N(n||[0,0]);var r=this.getZoom()||0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=F(this.project(s,r),this.project(o,r)).getSize(),u=W.any3d?this.options.zoomSnap:1,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new j(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var n=this._getTopLeftPoint(e,t);return new P(n,n.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(e===void 0?this.getZoom():e)},getPane:function(e){return typeof e==`string`?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var n=this.options.crs;return t=t===void 0?this._zoom:t,n.scale(e)/n.scale(t)},getScaleZoom:function(e,t){var n=this.options.crs;t=t===void 0?this._zoom:t;var r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r},project:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.latLngToPoint(z(e),t)},unproject:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.pointToLatLng(N(e),t)},layerPointToLatLng:function(e){var t=N(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(z(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(z(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(I(e))},distance:function(e,t){return this.options.crs.distance(z(e),z(t))},containerPointToLayerPoint:function(e){return N(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return N(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(N(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(z(e)))},mouseEventToContainerPoint:function(e){return Xt(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=lt(e);if(!t)throw Error(`Map container not found.`);if(t._leaflet_id)throw Error(`Map container is already initialized.`);Lt(t,`scroll`,this._onScroll,this),this._containerId=o(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&W.any3d,_t(e,`leaflet-container`+(W.touch?` leaflet-touch`:``)+(W.retina?` leaflet-retina`:``)+(W.ielt9?` leaflet-oldie`:``)+(W.safari?` leaflet-safari`:``)+(this._fadeAnimated?` leaflet-fade-anim`:``));var t=ut(e,`position`);t!==`absolute`&&t!==`relative`&&t!==`fixed`&&t!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),$(this._mapPane,new j(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(_t(e.markerPane,`leaflet-zoom-hide`),_t(e.shadowPane,`leaflet-zoom-hide`))},_resetView:function(e,t,n){$(this._mapPane,new j(0,0));var r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`);var i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)},_moveStart:function(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this},_move:function(e,t,n,r){t===void 0&&(t=this._zoom);var i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n&&n.pinch&&this.fire(`zoom`,n):((i||n&&n.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this},_moveEnd:function(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)},_stop:function(){return E(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){$(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw Error(`Set map center and zoom first.`)},_initEvents:function(e){this._targets={},this._targets[o(this._container)]=this;var t=e?zt:Lt;t(this._container,`click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&t(window,`resize`,this._onResize,this),W.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)},_onResize:function(){E(this._resizeRequest),this._resizeRequest=T(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var n=[],r,i=t===`mouseout`||t===`mouseover`,a=e.target||e.srcElement,s=!1;a;){if(r=this._targets[o(a)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){s=!0;break}if(r&&r.listens(t,!0)&&(i&&!$t(a,e)||(n.push(r),i))||a===this._container)break;a=a.parentNode}return!n.length&&!s&&!i&&this.listens(t,!0)&&(n=[this]),n},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||e.type===`click`&&this._isClickDisabled(t))){var n=e.type;n===`mousedown`&&Mt(t),this._fireDOMEvent(e,n)}},_mouseEvents:[`click`,`dblclick`,`mouseover`,`mouseout`,`contextmenu`],_fireDOMEvent:function(e,t,r){if(e.type===`click`){var i=n({},e);i.type=`preclick`,this._fireDOMEvent(i,i.type,r)}var a=this._findEventTargets(e,t);if(r){for(var o=[],s=0;s<r.length;s++)r[s].listens(t,!0)&&o.push(r[s]);a=o.concat(a)}if(a.length){t===`contextmenu`&&qt(e);var c=a[0],l={originalEvent:e};if(e.type!==`keypress`&&e.type!==`keydown`&&e.type!==`keyup`){var u=c.getLatLng&&(!c._radius||c._radius<=10);l.containerPoint=u?this.latLngToContainerPoint(c.getLatLng()):this.mouseEventToContainerPoint(e),l.layerPoint=this.containerPointToLayerPoint(l.containerPoint),l.latlng=u?c.getLatLng():this.layerPointToLatLng(l.layerPoint)}for(s=0;s<a.length;s++)if(a[s].fire(t,l,!0),l.originalEvent._stopped||a[s].options.bubblingMouseEvents===!1&&v(this._mouseEvents,t)!==-1)return}},_draggableMoved:function(e){return e=e.dragging&&e.dragging.enabled()?e:this,e.dragging&&e.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var e=0,t=this._handlers.length;e<t;e++)this._handlers[e].disable()},whenReady:function(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this},_getMapPanePos:function(){return Ct(this._mapPane)||new j(0,0)},_moved:function(){var e=this._getMapPanePos();return e&&!e.equals([0,0])},_getTopLeftPoint:function(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(e,t){var n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)},_latLngBoundsToNewLayerBounds:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return F([this.project(e.getSouthWest(),t)._subtract(r),this.project(e.getNorthWest(),t)._subtract(r),this.project(e.getSouthEast(),t)._subtract(r),this.project(e.getNorthEast(),t)._subtract(r)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())},_limitCenter:function(e,t,n){if(!n)return e;var r=this.project(e,t),i=this.getSize().divideBy(2),a=new P(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)},_limitOffset:function(e,t){if(!t)return e;var n=this.getPixelBounds(),r=new P(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))},_getBoundsOffset:function(e,t,n){var r=F(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new j(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))},_rebound:function(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),n=this.getMaxZoom(),r=W.any3d?this.options.zoomSnap:1;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))},_onPanTransitionStep:function(){this.fire(`move`)},_onPanTransitionEnd:function(){vt(this._mapPane,`leaflet-pan-anim`),this.fire(`moveend`)},_tryAnimatedPan:function(e,t){var n=this._getCenterOffset(e)._trunc();return(t&&t.animate)!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},_createAnimProxy:function(){var e=this._proxy=dt(`div`,`leaflet-proxy leaflet-zoom-animated`);this._panes.mapPane.appendChild(e),this.on(`zoomanim`,function(e){var t=ot,n=this._proxy.style[t];St(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on(`load moveend`,this._animMoveEnd,this),this._on(`unload`,this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ft(this._proxy),this.off(`load moveend`,this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();St(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf(`transform`)>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName(`leaflet-zoom-animated`).length},_tryAnimatedZoom:function(e,t,n){if(this._animatingZoom)return!0;if(n||={},!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var r=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/r);return n.animate!==!0&&!this.getSize().contains(i)?!1:(T(function(){this._moveStart(!0,n.noMoveStart||!1)._animateZoom(e,t,!0)},this),!0)},_animateZoom:function(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,_t(this._mapPane,`leaflet-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(i(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&vt(this._mapPane,`leaflet-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}});function rn(e,t){return new nn(e,t)}var an=O.extend({options:{position:`topright`},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];return _t(t,`leaflet-control`),n.indexOf(`bottom`)===-1?r.appendChild(t):r.insertBefore(t,r.firstChild),this._map.on(`unload`,this.remove,this),this},remove:function(){return this._map&&=(ft(this._container),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),null),this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),on=function(e){return new an(e)};nn.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t=`leaflet-`,n=this._controlContainer=dt(`div`,t+`control-container`,this._container);function r(r,i){var a=t+r+` `+t+i;e[r+i]=dt(`div`,a,n)}r(`top`,`left`),r(`top`,`right`),r(`bottom`,`left`),r(`bottom`,`right`)},_clearControlPos:function(){for(var e in this._controlCorners)ft(this._controlCorners[e]);ft(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var sn=an.extend({options:{collapsed:!0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,n,r){return n<r?-1:+(r<n)}},initialize:function(e,t,n){for(var r in p(this,n),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1,e)this._addLayer(e[r],r);for(r in t)this._addLayer(t[r],r,!0)},onAdd:function(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.on(`add remove`,this._onLayerChange,this);return this._container},addTo:function(e){return an.prototype.addTo.call(this,e),this._expandIfNotCollapsed()},onRemove:function(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(var e=0;e<this._layers.length;e++)this._layers[e].layer.off(`add remove`,this._onLayerChange,this)},addBaseLayer:function(e,t){return this._addLayer(e,t),this._map?this._update():this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._map?this._update():this},removeLayer:function(e){e.off(`add remove`,this._onLayerChange,this);var t=this._getLayer(o(e));return t&&this._layers.splice(this._layers.indexOf(t),1),this._map?this._update():this},expand:function(){_t(this._container,`leaflet-control-layers-expanded`),this._section.style.height=null;var e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(_t(this._section,`leaflet-control-layers-scrollbar`),this._section.style.height=e+`px`):vt(this._section,`leaflet-control-layers-scrollbar`),this._checkDisabledLayers(),this},collapse:function(){return vt(this._container,`leaflet-control-layers-expanded`),this},_initLayout:function(){var e=`leaflet-control-layers`,t=this._container=dt(`div`,e),n=this.options.collapsed;t.setAttribute(`aria-haspopup`,!0),Kt(t),Gt(t);var r=this._section=dt(`section`,e+`-list`);n&&(this._map.on(`click`,this.collapse,this),Lt(t,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var i=this._layersLink=dt(`a`,e+`-toggle`,t);i.href=`#`,i.title=`Layers`,i.setAttribute(`role`,`button`),Lt(i,{keydown:function(e){e.keyCode===13&&this._expandSafely()},click:function(e){qt(e),this._expandSafely()}},this),n||this.expand(),this._baseLayersList=dt(`div`,e+`-base`,r),this._separator=dt(`div`,e+`-separator`,r),this._overlaysList=dt(`div`,e+`-overlays`,r),t.appendChild(r)},_getLayer:function(e){for(var t=0;t<this._layers.length;t++)if(this._layers[t]&&o(this._layers[t].layer)===e)return this._layers[t]},_addLayer:function(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:n}),this.options.sortLayers&&this._layers.sort(i(function(e,t){return this.options.sortFunction(e.layer,t.layer,e.name,t.name)},this)),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;pt(this._baseLayersList),pt(this._overlaysList),this._layerControlInputs=[];var e,t,n,r,i=0;for(n=0;n<this._layers.length;n++)r=this._layers[n],this._addItem(r),t||=r.overlay,e||=!r.overlay,i+=+!r.overlay;return this.options.hideSingleBase&&(e&&=i>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(o(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,t)},_createRadioElement:function(e,t){var n=`<input type="radio" class="leaflet-control-layers-selector" name="`+e+`"`+(t?` checked="checked"`:``)+`/>`,r=document.createElement(`div`);return r.innerHTML=n,r.firstChild},_addItem:function(e){var t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r;e.overlay?(r=document.createElement(`input`),r.type=`checkbox`,r.className=`leaflet-control-layers-selector`,r.defaultChecked=n):r=this._createRadioElement(`leaflet-base-layers_`+o(this),n),this._layerControlInputs.push(r),r.layerId=o(e.layer),Lt(r,`click`,this._onInputClick,this);var i=document.createElement(`span`);i.innerHTML=` `+e.name;var a=document.createElement(`span`);return t.appendChild(a),a.appendChild(r),a.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(t),this._checkDisabledLayers(),t},_onInputClick:function(){if(!this._preventClick){var e=this._layerControlInputs,t,n,r=[],i=[];this._handlingClick=!0;for(var a=e.length-1;a>=0;a--)t=e[a],n=this._getLayer(t.layerId).layer,t.checked?r.push(n):t.checked||i.push(n);for(a=0;a<i.length;a++)this._map.hasLayer(i[a])&&this._map.removeLayer(i[a]);for(a=0;a<r.length;a++)this._map.hasLayer(r[a])||this._map.addLayer(r[a]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var e=this._layerControlInputs,t,n,r=this._map.getZoom(),i=e.length-1;i>=0;i--)t=e[i],n=this._getLayer(t.layerId).layer,t.disabled=n.options.minZoom!==void 0&&r<n.options.minZoom||n.options.maxZoom!==void 0&&r>n.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,Lt(e,`click`,qt),this.expand();var t=this;setTimeout(function(){zt(e,`click`,qt),t._preventClick=!1})}}),cn=function(e,t,n){return new sn(e,t,n)},ln=an.extend({options:{position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomInTitle:`Zoom in`,zoomOutText:`<span aria-hidden="true">&#x2212;</span>`,zoomOutTitle:`Zoom out`},onAdd:function(e){var t=`leaflet-control-zoom`,n=dt(`div`,t+` leaflet-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,r.zoomInTitle,t+`-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,r.zoomOutTitle,t+`-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n},onRemove:function(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(e.shiftKey?3:1))},_zoomOut:function(e){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,n,r,i){var a=dt(`a`,n,r);return a.innerHTML=e,a.href=`#`,a.title=t,a.setAttribute(`role`,`button`),a.setAttribute(`aria-label`,t),Kt(a),Lt(a,`click`,Jt),Lt(a,`click`,i,this),Lt(a,`click`,this._refocusOnMap,this),a},_updateDisabled:function(){var e=this._map,t=`leaflet-disabled`;vt(this._zoomInButton,t),vt(this._zoomOutButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(_t(this._zoomOutButton,t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(_t(this._zoomInButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}});nn.mergeOptions({zoomControl:!0}),nn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ln,this.addControl(this.zoomControl))});var un=function(e){return new ln(e)},dn=an.extend({options:{position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t=`leaflet-control-scale`,n=dt(`div`,t),r=this.options;return this._addScales(r,t+`-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n},onRemove:function(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)},_addScales:function(e,t,n){e.metric&&(this._mScale=dt(`div`,t,n)),e.imperial&&(this._iScale=dt(`div`,t,n))},_update:function(){var e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),n=t<1e3?t+` m`:t/1e3+` km`;this._updateScale(this._mScale,n,t/e)},_updateImperial:function(e){var t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,r+` mi`,r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,i+` ft`,i/t))},_updateScale:function(e,t,n){e.style.width=Math.round(this.options.maxWidth*n)+`px`,e.innerHTML=t},_getRoundNum:function(e){var t=10**((Math.floor(e)+``).length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),fn=function(e){return new dn(e)},pn=an.extend({options:{position:`bottomright`,prefix:`<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">`+(W.inlineSvg?`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg> `:``)+`Leaflet</a>`},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=dt(`div`,`leaflet-control-attribution`),Kt(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on(`layeradd`,this._addAttribution,this),this._container},onRemove:function(e){e.off(`layeradd`,this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once(`remove`,function(){this.removeAttribution(e.layer.getAttribution())},this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e&&(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()),this},removeAttribution:function(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(`, `)),this._container.innerHTML=n.join(` <span aria-hidden="true">|</span> `)}}});nn.mergeOptions({attributionControl:!0}),nn.addInitHook(function(){this.options.attributionControl&&new pn().addTo(this)}),an.Layers=sn,an.Zoom=ln,an.Scale=dn,an.Attribution=pn,on.layers=cn,on.zoom=un,on.scale=fn,on.attribution=function(e){return new pn(e)};var mn=O.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});mn.addTo=function(e,t){return e.addHandler(t,this),this};var hn={Events:A},gn=W.touch?`touchstart mousedown`:`mousedown`,_n=ee.extend({options:{clickTolerance:3},initialize:function(e,t,n,r){p(this,r),this._element=e,this._dragStartTarget=t||e,this._preventOutline=n},enable:function(){this._enabled||=(Lt(this._dragStartTarget,gn,this._onDown,this),!0)},disable:function(){this._enabled&&(_n._dragging===this&&this.finishDrag(!0),zt(this._dragStartTarget,gn,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!gt(this._element,`leaflet-zoom-anim`))){if(e.touches&&e.touches.length!==1)_n._dragging===this&&this.finishDrag();else if(!(_n._dragging||e.shiftKey||e.which!==1&&e.button!==1&&!e.touches)&&(_n._dragging=this,this._preventOutline&&Mt(this._element),Ot(),wt(),!this._moving)){this.fire(`down`);var t=e.touches?e.touches[0]:e,n=Pt(this._element);this._startPoint=new j(t.clientX,t.clientY),this._startPos=Ct(this._element),this._parentScale=Ft(n);var r=e.type===`mousedown`;Lt(document,r?`mousemove`:`touchmove`,this._onMove,this),Lt(document,r?`mouseup`:`touchend touchcancel`,this._onUp,this)}}},_onMove:function(e){if(this._enabled){if(e.touches&&e.touches.length>1)this._moved=!0;else{var t=e.touches&&e.touches.length===1?e.touches[0]:e,n=new j(t.clientX,t.clientY)._subtract(this._startPoint);(n.x||n.y)&&(Math.abs(n.x)+Math.abs(n.y)<this.options.clickTolerance||(n.x/=this._parentScale.x,n.y/=this._parentScale.y,qt(e),this._moved||(this.fire(`dragstart`),this._moved=!0,_t(document.body,`leaflet-dragging`),this._lastTarget=e.target||e.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),_t(this._lastTarget,`leaflet-drag-target`)),this._newPos=this._startPos.add(n),this._moving=!0,this._lastEvent=e,this._updatePosition()))}}},_updatePosition:function(){var e={originalEvent:this._lastEvent};this.fire(`predrag`,e),$(this._element,this._newPos),this.fire(`drag`,e)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(e){vt(document.body,`leaflet-dragging`),this._lastTarget&&=(vt(this._lastTarget,`leaflet-drag-target`),null),zt(document,`mousemove touchmove`,this._onMove,this),zt(document,`mouseup touchend touchcancel`,this._onUp,this),kt(),Tt();var t=this._moved&&this._moving;this._moving=!1,_n._dragging=!1,t&&this.fire(`dragend`,{noInertia:e,distance:this._newPos.distanceTo(this._startPos)})}});function vn(e,t,n){for(var r,i=[1,4,2,8],a=0,o,s,c,l,u=e.length,d,f;a<u;a++)e[a]._code=jn(e[a],t);for(s=0;s<4;s++){for(d=i[s],r=[],a=0,u=e.length,o=u-1;a<u;o=a++)c=e[a],l=e[o],c._code&d?l._code&d||(f=An(l,c,d,t,n),f._code=jn(f,t),r.push(f)):(l._code&d&&(f=An(l,c,d,t,n),f._code=jn(f,t),r.push(f)),r.push(c));e=r}return e}function yn(e,t){var n,r,i,a,o,s,c,l,u;if(!e||e.length===0)throw Error(`latlngs not passed`);Pn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var d=z([0,0]),f=I(e);f.getNorthWest().distanceTo(f.getSouthWest())*f.getNorthEast().distanceTo(f.getNorthWest())<1700&&(d=bn(e));var p=e.length,m=[];for(n=0;n<p;n++){var h=z(e[n]);m.push(t.project(z([h.lat-d.lat,h.lng-d.lng])))}for(s=c=l=0,n=0,r=p-1;n<p;r=n++)i=m[n],a=m[r],o=i.y*a.x-a.y*i.x,c+=(i.x+a.x)*o,l+=(i.y+a.y)*o,s+=o*3;u=s===0?m[0]:[c/s,l/s];var g=t.unproject(N(u));return z([g.lat+d.lat,g.lng+d.lng])}function bn(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=z(e[i]);t+=a.lat,n+=a.lng,r++}return z([t/r,n/r])}var xn={__proto__:null,clipPolygon:vn,polygonCenter:yn,centroid:bn};function Sn(e,t){if(!t||!e.length)return e.slice();var n=t*t;return e=Dn(e,n),e=Tn(e,n),e}function Cn(e,t,n){return Math.sqrt(Nn(e,t,n,!0))}function wn(e,t,n){return Nn(e,t,n)}function Tn(e,t){var n=e.length,r=new(typeof Uint8Array<`u`?Uint8Array:Array)(n);r[0]=r[n-1]=1,En(e,r,t,0,n-1);var i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function En(e,t,n,r,i){for(var a=0,o,s=r+1,c;s<=i-1;s++)c=Nn(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,En(e,t,n,r,o),En(e,t,n,o,i))}function Dn(e,t){for(var n=[e[0]],r=1,i=0,a=e.length;r<a;r++)Mn(e[r],e[i])>t&&(n.push(e[r]),i=r);return i<a-1&&n.push(e[a-1]),n}var On;function kn(e,t,n,r,i){var a=r?On:jn(e,n),o=jn(t,n),s,c,l;for(On=o;;){if(!(a|o))return[e,t];if(a&o)return!1;s=a||o,c=An(e,t,s,n,i),l=jn(c,n),s===a?(e=c,a=l):(t=c,o=l)}}function An(e,t,n,r,i){var a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new j(l,u,i)}function jn(e,t){var n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function Mn(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function Nn(e,t,n,r){var i=t.x,a=t.y,o=n.x-i,s=n.y-a,c=o*o+s*s,l;return c>0&&(l=((e.x-i)*o+(e.y-a)*s)/c,l>1?(i=n.x,a=n.y):l>0&&(i+=o*l,a+=s*l)),o=e.x-i,s=e.y-a,r?o*o+s*s:new j(i,a)}function Pn(e){return!_(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function Fn(e){return console.warn(`Deprecated use of _flat, please use L.LineUtil.isFlat instead.`),Pn(e)}function In(e,t){var n,r,i,a,o,s,c,l;if(!e||e.length===0)throw Error(`latlngs not passed`);Pn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var u=z([0,0]),d=I(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(u=bn(e));var f=e.length,p=[];for(n=0;n<f;n++){var m=z(e[n]);p.push(t.project(z([m.lat-u.lat,m.lng-u.lng])))}for(n=0,r=0;n<f-1;n++)r+=p[n].distanceTo(p[n+1])/2;if(r===0)l=p[0];else for(n=0,a=0;n<f-1;n++)if(o=p[n],s=p[n+1],i=o.distanceTo(s),a+=i,a>r){c=(a-r)/i,l=[s.x-c*(s.x-o.x),s.y-c*(s.y-o.y)];break}var h=t.unproject(N(l));return z([h.lat+u.lat,h.lng+u.lng])}var Ln={__proto__:null,simplify:Sn,pointToSegmentDistance:Cn,closestPointOnSegment:wn,clipSegment:kn,_getEdgeIntersection:An,_getBitCode:jn,_sqClosestPointOnSegment:Nn,isFlat:Pn,_flat:Fn,polylineCenter:In},Rn={project:function(e){return new j(e.lng,e.lat)},unproject:function(e){return new R(e.y,e.x)},bounds:new P([-180,-90],[180,90])},zn={R:6378137,R_MINOR:6356752.314245179,bounds:new P([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,n=this.R,r=e.lat*t,i=this.R_MINOR/n,a=Math.sqrt(1-i*i),o=a*Math.sin(r),s=Math.tan(Math.PI/4-r/2)/((1-o)/(1+o))**(a/2);return r=-n*Math.log(Math.max(s,1e-10)),new j(e.lng*t*n,r)},unproject:function(e){for(var t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a),s=0,c=.1,l;s<15&&Math.abs(c)>1e-7;s++)l=i*Math.sin(o),l=((1-l)/(1+l))**(i/2),c=Math.PI/2-2*Math.atan(a*l)-o,o+=c;return new R(o*t,e.x*t/n)}},Bn={__proto__:null,LonLat:Rn,Mercator:zn,SphericalMercator:ae},Vn=n({},re,{code:`EPSG:3395`,projection:zn,transformation:function(){var e=.5/(Math.PI*zn.R);return se(e,.5,-e,.5)}()}),Hn=n({},re,{code:`EPSG:4326`,projection:Rn,transformation:se(1/180,1,-1/180,.5)}),Un=n({},ne,{projection:Rn,transformation:se(1,0,-1,0),scale:function(e){return 2**e},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)},infinite:!0});ne.Earth=re,ne.EPSG3395=Vn,ne.EPSG3857=ce,ne.EPSG900913=le,ne.EPSG4326=Hn,ne.Simple=Un;var Wn=ee.extend({options:{pane:`overlayPane`,attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[o(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[o(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var n=this.getEvents();t.on(n,this),this.once(`remove`,function(){t.off(n,this)},this)}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}});nn.include({addLayer:function(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);var t=o(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer:function(e){var t=o(e);return this._layers[t]&&(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null),this},hasLayer:function(e){return o(e)in this._layers},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},_addLayers:function(e){e=e?_(e)?e:[e]:[];for(var t=0,n=e.length;t<n;t++)this.addLayer(e[t])},_addZoomLimit:function(e){isNaN(e.options.maxZoom)&&isNaN(e.options.minZoom)||(this._zoomBoundLayers[o(e)]=e,this._updateZoomLevels())},_removeZoomLimit:function(e){var t=o(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels:function(){var e=1/0,t=-1/0,n=this._getZoomSpan();for(var r in this._zoomBoundLayers){var i=this._zoomBoundLayers[r].options;e=i.minZoom===void 0?e:Math.min(e,i.minZoom),t=i.maxZoom===void 0?t:Math.max(t,i.maxZoom)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Gn=Wn.extend({initialize:function(e,t){p(this,t),this._layers={};var n,r;if(e)for(n=0,r=e.length;n<r;n++)this.addLayer(e[n])},addLayer:function(e){var t=this.getLayerId(e);return this._layers[t]=e,this._map&&this._map.addLayer(e),this},removeLayer:function(e){var t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this},hasLayer:function(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(e){var t=Array.prototype.slice.call(arguments,1),n,r;for(n in this._layers)r=this._layers[n],r[e]&&r[e].apply(r,t);return this},onAdd:function(e){this.eachLayer(e.addLayer,e)},onRemove:function(e){this.eachLayer(e.removeLayer,e)},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},getLayer:function(e){return this._layers[e]},getLayers:function(){var e=[];return this.eachLayer(e.push,e),e},setZIndex:function(e){return this.invoke(`setZIndex`,e)},getLayerId:function(e){return o(e)}}),Kn=function(e,t){return new Gn(e,t)},qn=Gn.extend({addLayer:function(e){return this.hasLayer(e)?this:(e.addEventParent(this),Gn.prototype.addLayer.call(this,e),this.fire(`layeradd`,{layer:e}))},removeLayer:function(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),Gn.prototype.removeLayer.call(this,e),this.fire(`layerremove`,{layer:e})):this},setStyle:function(e){return this.invoke(`setStyle`,e)},bringToFront:function(){return this.invoke(`bringToFront`)},bringToBack:function(){return this.invoke(`bringToBack`)},getBounds:function(){var e=new te;for(var t in this._layers){var n=this._layers[t];e.extend(n.getBounds?n.getBounds():n.getLatLng())}return e}}),Jn=function(e,t){return new qn(e,t)},Yn=O.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(e){p(this,e)},createIcon:function(e){return this._createIcon(`icon`,e)},createShadow:function(e){return this._createIcon(`shadow`,e)},_createIcon:function(e,t){var n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}var r=this._createImg(n,t&&t.tagName===`IMG`?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r},_setIconStyles:function(e,t){var n=this.options,r=n[t+`Size`];typeof r==`number`&&(r=[r,r]);var i=N(r),a=N(t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0));e.className=`leaflet-marker-`+t+` `+(n.className||``),a&&(e.style.marginLeft=-a.x+`px`,e.style.marginTop=-a.y+`px`),i&&(e.style.width=i.x+`px`,e.style.height=i.y+`px`)},_createImg:function(e,t){return t||=document.createElement(`img`),t.src=e,t},_getIconUrl:function(e){return W.retina&&this.options[e+`RetinaUrl`]||this.options[e+`Url`]}});function Xn(e){return new Yn(e)}var Zn=Yn.extend({options:{iconUrl:`marker-icon.png`,iconRetinaUrl:`marker-icon-2x.png`,shadowUrl:`marker-shadow.png`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(e){return typeof Zn.imagePath!=`string`&&(Zn.imagePath=this._detectIconPath()),(this.options.imagePath||Zn.imagePath)+Yn.prototype._getIconUrl.call(this,e)},_stripUrl:function(e){var t=function(e,t,n){var r=t.exec(e);return r&&r[n]};return e=t(e,/^url\((['"])?(.+)\1\)$/,2),e&&t(e,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var e=dt(`div`,`leaflet-default-icon-path`,document.body),t=ut(e,`background-image`)||ut(e,`backgroundImage`);if(document.body.removeChild(e),t=this._stripUrl(t),t)return t;var n=document.querySelector(`link[href$="leaflet.css"]`);return n?n.href.substring(0,n.href.length-11-1):``}}),Qn=mn.extend({initialize:function(e){this._marker=e},addHooks:function(){var e=this._marker._icon;this._draggable||=new _n(e,e,!0),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),_t(e,`leaflet-marker-draggable`)},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&vt(this._marker._icon,`leaflet-marker-draggable`)},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(e){var t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=Ct(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=F(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){var l=N((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(l,{animate:!1}),this._draggable._newPos._add(l),this._draggable._startPos._add(l),$(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=T(this._adjustPan.bind(this,e))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire(`movestart`).fire(`dragstart`)},_onPreDrag:function(e){this._marker.options.autoPan&&(E(this._panRequest),this._panRequest=T(this._adjustPan.bind(this,e)))},_onDrag:function(e){var t=this._marker,n=t._shadow,r=Ct(t._icon),i=t._map.layerPointToLatLng(r);n&&$(n,r),t._latlng=i,e.latlng=i,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)},_onDragEnd:function(e){E(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}}),$n=Wn.extend({options:{icon:new Zn,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(e,t){p(this,t),this._latlng=z(e)},onAdd:function(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(e){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},setZIndexOffset:function(e){return this.options.zIndexOffset=e,this.update()},getIcon:function(){return this.options.icon},setIcon:function(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var e=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(e)}return this},_initIcon:function(){var e=this.options,t=`leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`),n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n.tagName===`IMG`&&(n.alt=e.alt||``)),_t(n,t),e.keyboard&&(n.tabIndex=`0`,n.setAttribute(`role`,`button`)),this._icon=n,e.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Lt(n,`focus`,this._panOnFocus,this);var i=e.icon.createShadow(this._shadow),a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(_t(i,t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&zt(this._icon,`focus`,this._panOnFocus,this),ft(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ft(this._shadow),this._shadow=null},_setPos:function(e){this._icon&&$(this._icon,e),this._shadow&&$(this._shadow,e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(e){this._icon&&(this._icon.style.zIndex=this._zIndex+e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center).round();this._setPos(t)},_initInteraction:function(){if(this.options.interactive&&(_t(this._icon,`leaflet-interactive`),this.addInteractiveTarget(this._icon),Qn)){var e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Qn(this),e&&this.dragging.enable()}},setOpacity:function(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var e=this.options.opacity;this._icon&&bt(this._icon,e),this._shadow&&bt(this._shadow,e)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var e=this._map;if(e){var t=this.options.icon.options,n=t.iconSize?N(t.iconSize):N(0,0),r=t.iconAnchor?N(t.iconAnchor):N(0,0);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:n.subtract(r)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function er(e,t){return new $n(e,t)}var tr=Wn.extend({options:{stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(e){this._renderer=e.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(e){return p(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.prototype.hasOwnProperty.call(e,`weight`)&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),nr=tr.extend({options:{fill:!0,radius:10},initialize:function(e,t){p(this,t),this._latlng=z(e),this._radius=this.options.radius},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(e){return this.options.radius=this._radius=e,this.redraw()},getRadius:function(){return this._radius},setStyle:function(e){var t=e&&e.radius||this._radius;return tr.prototype.setStyle.call(this,e),this.setRadius(t),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var e=this._radius,t=this._radiusY||e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new P(this._point.subtract(r),this._point.add(r))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(e){return e.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function rr(e,t){return new nr(e,t)}var ir=nr.extend({initialize:function(e,t,r){if(typeof t==`number`&&(t=n({},r,{radius:t})),p(this,t),this._latlng=z(e),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this._mRadius=this.options.radius},setRadius:function(e){return this._mRadius=e,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var e=[this._radius,this._radiusY||this._radius];return new te(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))},setStyle:tr.prototype.setStyle,_project:function(){var e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===re.distance){var i=Math.PI/180,a=this._mRadius/re.R/i,o=n.project([t+a,e]),s=n.project([t-a,e]),c=o.add(s).divideBy(2),l=n.unproject(c).lat,u=Math.acos((Math.cos(a*i)-Math.sin(t*i)*Math.sin(l*i))/(Math.cos(t*i)*Math.cos(l*i)))/i;(isNaN(u)||u===0)&&(u=a/Math.cos(Math.PI/180*t)),this._point=c.subtract(n.getPixelOrigin()),this._radius=isNaN(u)?0:c.x-n.project([l,e-u]).x,this._radiusY=c.y-o.y}else{var d=r.unproject(r.project(this._latlng).subtract([this._mRadius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._radius=this._point.x-n.latLngToLayerPoint(d).x}this._updateBounds()}});function ar(e,t,n){return new ir(e,t,n)}var or=tr.extend({options:{smoothFactor:1,noClip:!1},initialize:function(e,t){p(this,t),this._setLatLngs(e)},getLatLngs:function(){return this._latlngs},setLatLngs:function(e){return this._setLatLngs(e),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(e){for(var t=1/0,n=null,r=Nn,i,a,o=0,s=this._parts.length;o<s;o++)for(var c=this._parts[o],l=1,u=c.length;l<u;l++){i=c[l-1],a=c[l];var d=r(e,i,a,!0);d<t&&(t=d,n=r(e,i,a))}return n&&(n.distance=Math.sqrt(t)),n},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return In(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(e,t){return t||=this._defaultShape(),e=z(e),t.push(e),this._bounds.extend(e),this.redraw()},_setLatLngs:function(e){this._bounds=new te,this._latlngs=this._convertLatLngs(e)},_defaultShape:function(){return Pn(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(e){for(var t=[],n=Pn(e),r=0,i=e.length;r<i;r++)n?(t[r]=z(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t},_project:function(){var e=new P;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())},_updateBounds:function(){var e=this._clickTolerance(),t=new j(e,e);this._rawPxBounds&&(this._pxBounds=new P([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))},_projectLatlngs:function(e,t,n){var r=e[0]instanceof R,i=e.length,a,o;if(r){for(o=[],a=0;a<i;a++)o[a]=this._map.latLngToLayerPoint(e[a]),n.extend(o[a]);t.push(o)}else for(a=0;a<i;a++)this._projectLatlngs(e[a],t,n)},_clipPoints:function(){var e=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var t=this._parts,n=0,r,i=0,a=this._rings.length,o,s,c;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=kn(c[r],c[r+1],e,r,!0),s&&(t[i]=t[i]||[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}},_simplifyPoints:function(){for(var e=this._parts,t=this.options.smoothFactor,n=0,r=e.length;n<r;n++)e[n]=Sn(e[n],t)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(e,t){var n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&Cn(e,s[i],s[r])<=c)return!0;return!1}});function sr(e,t){return new or(e,t)}or._flat=Fn;var cr=or.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return yn(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(e){var t=or.prototype._convertLatLngs.call(this,e),n=t.length;return n>=2&&t[0]instanceof R&&t[0].equals(t[n-1])&&t.pop(),t},_setLatLngs:function(e){or.prototype._setLatLngs.call(this,e),Pn(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Pn(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,n=new j(t,t);if(e=new P(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var r=0,i=this._rings.length,a;r<i;r++)a=vn(this._rings[r],e,!0),a.length&&this._parts.push(a)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(e){var t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||or.prototype._containsPoint.call(this,e,!0)}});function lr(e,t){return new cr(e,t)}var ur=qn.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=_(e)?e:e.features,n,r,i;if(t){for(n=0,r=t.length;n<r;n++)i=t[n],(i.geometries||i.geometry||i.features||i.coordinates)&&this.addData(i);return this}var a=this.options;if(a.filter&&!a.filter(e))return this;var o=dr(e,a);return o?(o.feature=vr(e),o.defaultOptions=o.options,this.resetStyle(o),a.onEachFeature&&a.onEachFeature(e,o),this.addLayer(o)):this},resetStyle:function(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=n({},e.defaultOptions),this._setLayerStyle(e,this.options.style),this)},setStyle:function(e){return this.eachLayer(function(t){this._setLayerStyle(t,e)},this)},_setLayerStyle:function(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}});function dr(e,t){var n=e.type===`Feature`?e.geometry:e,r=n?n.coordinates:null,i=[],a=t&&t.pointToLayer,o=t&&t.coordsToLatLng||pr,s,c,l,u;if(!r&&!n)return null;switch(n.type){case`Point`:return s=o(r),fr(a,e,s,t);case`MultiPoint`:for(l=0,u=r.length;l<u;l++)s=o(r[l]),i.push(fr(a,e,s,t));return new qn(i);case`LineString`:case`MultiLineString`:return c=mr(r,n.type===`LineString`?0:1,o),new or(c,t);case`Polygon`:case`MultiPolygon`:return c=mr(r,n.type===`Polygon`?1:2,o),new cr(c,t);case`GeometryCollection`:for(l=0,u=n.geometries.length;l<u;l++){var d=dr({geometry:n.geometries[l],type:`Feature`,properties:e.properties},t);d&&i.push(d)}return new qn(i);case`FeatureCollection`:for(l=0,u=n.features.length;l<u;l++){var f=dr(n.features[l],t);f&&i.push(f)}return new qn(i);default:throw Error(`Invalid GeoJSON object.`)}}function fr(e,t,n,r){return e?e(t,n):new $n(n,r&&r.markersInheritOptions&&r)}function pr(e){return new R(e[1],e[0],e[2])}function mr(e,t,n){for(var r=[],i=0,a=e.length,o;i<a;i++)o=t?mr(e[i],t-1,n):(n||pr)(e[i]),r.push(o);return r}function hr(e,t){return e=z(e),e.alt===void 0?[u(e.lng,t),u(e.lat,t)]:[u(e.lng,t),u(e.lat,t),u(e.alt,t)]}function gr(e,t,n,r){for(var i=[],a=0,o=e.length;a<o;a++)i.push(t?gr(e[a],Pn(e[a])?0:t-1,n,r):hr(e[a],r));return!t&&n&&i.length>0&&i.push(i[0].slice()),i}function _r(e,t){return e.feature?n({},e.feature,{geometry:t}):vr(t)}function vr(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}var yr={toGeoJSON:function(e){return _r(this,{type:`Point`,coordinates:hr(this.getLatLng(),e)})}};$n.include(yr),ir.include(yr),nr.include(yr),or.include({toGeoJSON:function(e){var t=!Pn(this._latlngs),n=gr(this._latlngs,+!!t,!1,e);return _r(this,{type:(t?`Multi`:``)+`LineString`,coordinates:n})}}),cr.include({toGeoJSON:function(e){var t=!Pn(this._latlngs),n=t&&!Pn(this._latlngs[0]),r=gr(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),_r(this,{type:(n?`Multi`:``)+`Polygon`,coordinates:r})}}),Gn.include({toMultiPoint:function(e){var t=[];return this.eachLayer(function(n){t.push(n.toGeoJSON(e).geometry.coordinates)}),_r(this,{type:`MultiPoint`,coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(t===`MultiPoint`)return this.toMultiPoint(e);var n=t===`GeometryCollection`,r=[];return this.eachLayer(function(t){if(t.toGeoJSON){var i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{var a=vr(i);a.type===`FeatureCollection`?r.push.apply(r,a.features):r.push(a)}}}),n?_r(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}});function br(e,t){return new ur(e,t)}var xr=br,Sr=Wn.extend({options:{opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``},initialize:function(e,t,n){this._url=e,this._bounds=I(t),p(this,n)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(_t(this._image,`leaflet-interactive`),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ft(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&&mt(this._image),this},bringToBack:function(){return this._map&&ht(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=I(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e=this._url.tagName===`IMG`,t=this._image=e?this._url:dt(`img`);_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onload=i(this.fire,this,`load`),t.onerror=i(this._overlayOnError,this,`error`),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;St(this._image,n,t)},_reset:function(){var e=this._image,t=new P(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();$(e,t.min),e.style.width=n.x+`px`,e.style.height=n.y+`px`},_updateOpacity:function(){bt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire(`error`);var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),Cr=function(e,t,n){return new Sr(e,t,n)},wr=Sr.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e=this._url.tagName===`VIDEO`,t=this._image=e?this._url:dt(`video`);if(_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onloadeddata=i(this.fire,this,`load`),e){for(var n=t.getElementsByTagName(`source`),r=[],a=0;a<n.length;a++)r.push(n[a].src);this._url=n.length>0?r:[t.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,`objectFit`)&&(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var o=0;o<this._url.length;o++){var s=dt(`source`);s.src=this._url[o],t.appendChild(s)}}}});function Tr(e,t,n){return new wr(e,t,n)}var Er=Sr.extend({_initImage:function(){var e=this._image=this._url;_t(e,`leaflet-image-layer`),this._zoomAnimated&&_t(e,`leaflet-zoom-animated`),this.options.className&&_t(e,this.options.className),e.onselectstart=l,e.onmousemove=l}});function Dr(e,t,n){return new Er(e,t,n)}var Or=Wn.extend({options:{interactive:!1,offset:[0,0],className:``,pane:void 0,content:``},initialize:function(e,t){e&&(e instanceof R||_(e))?(this._latlng=z(e),p(this,t)):(p(this,e),this._source=t),this.options.content&&(this._content=this.options.content)},openOn:function(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this},onAdd:function(e){this._zoomAnimated=e._zoomAnimated,this._container||this._initLayout(),e._fadeAnimated&&bt(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),e._fadeAnimated&&bt(this._container,1),this.bringToFront(),this.options.interactive&&(_t(this._container,`leaflet-interactive`),this.addInteractiveTarget(this._container))},onRemove:function(e){e._fadeAnimated?(bt(this._container,0),this._removeTimeout=setTimeout(i(ft,void 0,this._container),200)):ft(this._container),this.options.interactive&&(vt(this._container,`leaflet-interactive`),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(e){return this._latlng=z(e),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(e){return this._content=e,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())},getEvents:function(){var e={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&mt(this._container),this},bringToBack:function(){return this._map&&ht(this._container),this},_prepareOpen:function(e){var t=this._source;if(!t._map)return!1;if(t instanceof qn){t=null;var n=this._source._layers;for(var r in n)if(n[r]._map){t=n[r];break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var e=this._contentNode,t=typeof this._content==`function`?this._content(this._source||this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}},_updatePosition:function(){if(this._map){var e=this._map.latLngToLayerPoint(this._latlng),t=N(this.options.offset),n=this._getAnchor();this._zoomAnimated?$(this._container,e.add(n)):t=t.add(e).add(n);var r=this._containerBottom=-t.y,i=this._containerLeft=-Math.round(this._containerWidth/2)+t.x;this._container.style.bottom=r+`px`,this._container.style.left=i+`px`}},_getAnchor:function(){return[0,0]}});nn.include({_initOverlay:function(e,t,n,r){var i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}}),Wn.include({_initOverlay:function(e,t,n,r){var i=n;return i instanceof e?(p(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}});var kr=Or.extend({options:{pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``},openOn:function(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,Or.prototype.openOn.call(this,e)},onAdd:function(e){Or.prototype.onAdd.call(this,e),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof tr||this._source.on(`preclick`,Wt))},onRemove:function(e){Or.prototype.onRemove.call(this,e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof tr||this._source.off(`preclick`,Wt))},getEvents:function(){var e=Or.prototype.getEvents.call(this);return(this.options.closeOnClick===void 0?this._map.options.closePopupOnClick:this.options.closeOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e},_initLayout:function(){var e=`leaflet-popup`,t=this._container=dt(`div`,e+` `+(this.options.className||``)+` leaflet-zoom-animated`),n=this._wrapper=dt(`div`,e+`-content-wrapper`,t);if(this._contentNode=dt(`div`,e+`-content`,n),Kt(t),Gt(this._contentNode),Lt(t,`contextmenu`,Wt),this._tipContainer=dt(`div`,e+`-tip-container`,t),this._tip=dt(`div`,e+`-tip`,this._tipContainer),this.options.closeButton){var r=this._closeButton=dt(`a`,e+`-close-button`,t);r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,`Close popup`),r.href=`#close`,r.innerHTML=`<span aria-hidden="true">&#215;</span>`,Lt(r,`click`,function(e){qt(e),this.close()},this)}},_updateLayout:function(){var e=this._contentNode,t=e.style;t.width=``,t.whiteSpace=`nowrap`;var n=e.offsetWidth;n=Math.min(n,this.options.maxWidth),n=Math.max(n,this.options.minWidth),t.width=n+1+`px`,t.whiteSpace=``,t.height=``;var r=e.offsetHeight,i=this.options.maxHeight,a=`leaflet-popup-scrolled`;i&&r>i?(t.height=i+`px`,_t(e,a)):vt(e,a),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();$(this._container,t.add(n))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var e=this._map,t=parseInt(ut(this._container,`marginBottom`),10)||0,n=this._container.offsetHeight+t,r=this._containerWidth,i=new j(this._containerLeft,-n-this._containerBottom);i._add(Ct(this._container));var a=e.layerPointToContainerPoint(i),o=N(this.options.autoPanPadding),s=N(this.options.autoPanPaddingTopLeft||o),c=N(this.options.autoPanPaddingBottomRight||o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}}},_getAnchor:function(){return N(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Ar=function(e,t){return new kr(e,t)};nn.mergeOptions({closePopupOnClick:!0}),nn.include({openPopup:function(e,t,n){return this._initOverlay(kr,e,t,n).openOn(this),this},closePopup:function(e){return e=arguments.length?e:this._popup,e&&e.close(),this}}),Wn.include({bindPopup:function(e,t){return this._popup=this._initOverlay(kr,this._popup,e,t),this._popupHandlersAdded||=(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),!0),this},unbindPopup:function(){return this._popup&&=(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,null),this},openPopup:function(e){return this._popup&&(this instanceof qn||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(e){return this._popup&&this._popup.setContent(e),this},getPopup:function(){return this._popup},_openPopup:function(e){if(this._popup&&this._map){Jt(e);var t=e.layer||e.target;this._popup._source===t&&!(t instanceof tr)?this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng):(this._popup._source=t,this.openPopup(e.latlng))}},_movePopup:function(e){this._popup.setLatLng(e.latlng)},_onKeyPress:function(e){e.originalEvent.keyCode===13&&this._openPopup(e)}});var jr=Or.extend({options:{pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9},onAdd:function(e){Or.prototype.onAdd.call(this,e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))},onRemove:function(e){Or.prototype.onRemove.call(this,e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))},getEvents:function(){var e=Or.prototype.getEvents.call(this);return this.options.permanent||(e.preclick=this.close),e},_initLayout:function(){var e=`leaflet-tooltip `+(this.options.className||``)+` leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`);this._contentNode=this._container=dt(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`leaflet-tooltip-`+o(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(e){var t,n,r=this._map,i=this._container,a=r.latLngToContainerPoint(r.getCenter()),o=r.layerPointToContainerPoint(e),s=this.options.direction,c=i.offsetWidth,l=i.offsetHeight,u=N(this.options.offset),d=this._getAnchor();s===`top`?(t=c/2,n=l):s===`bottom`?(t=c/2,n=0):s===`center`?(t=c/2,n=l/2):s===`right`?(t=0,n=l/2):s===`left`?(t=c,n=l/2):o.x<a.x?(s=`right`,t=0,n=l/2):(s=`left`,t=c+(u.x+d.x)*2,n=l/2),e=e.subtract(N(t,n,!0)).add(u).add(d),vt(i,`leaflet-tooltip-right`),vt(i,`leaflet-tooltip-left`),vt(i,`leaflet-tooltip-top`),vt(i,`leaflet-tooltip-bottom`),_t(i,`leaflet-tooltip-`+s),$(i,e)},_updatePosition:function(){var e=this._map.latLngToLayerPoint(this._latlng);this._setPosition(e)},setOpacity:function(e){this.options.opacity=e,this._container&&bt(this._container,e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)},_getAnchor:function(){return N(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Mr=function(e,t){return new jr(e,t)};nn.include({openTooltip:function(e,t,n){return this._initOverlay(jr,e,t,n).openOn(this),this},closeTooltip:function(e){return e.close(),this}}),Wn.include({bindTooltip:function(e,t){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(jr,this._tooltip,e,t),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions:function(e){if(e||!this._tooltipHandlersAdded){var t=e?`off`:`on`,n={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?n.add=this._openTooltip:(n.mouseover=this._openTooltip,n.mouseout=this.closeTooltip,n.click=this._openTooltip,this._map?this._addFocusListeners():n.add=this._addFocusListeners),this._tooltip.options.sticky&&(n.mousemove=this._moveTooltip),this[t](n),this._tooltipHandlersAdded=!e}},openTooltip:function(e){return this._tooltip&&(this instanceof qn||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(e){return this._tooltip&&this._tooltip.setContent(e),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&(Lt(t,`focus`,function(){this._tooltip._source=e,this.openTooltip()},this),Lt(t,`blur`,this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&t.setAttribute(`aria-describedby`,this._tooltip._container.id)},_openTooltip:function(e){if(this._tooltip&&this._map){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var t=this;this._map.once(`moveend`,function(){t._openOnceFlag=!1,t._openTooltip(e)})}else this._tooltip._source=e.layer||e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)}},_moveTooltip:function(e){var t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.mouseEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}});var Nr=Yn.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:`leaflet-div-icon`},createIcon:function(e){var t=e&&e.tagName===`DIV`?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(pt(t),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){var r=N(n.bgPos);t.style.backgroundPosition=-r.x+`px `+-r.y+`px`}return this._setIconStyles(t,`icon`),t},createShadow:function(){return null}});function Pr(e){return new Nr(e)}Yn.Default=Zn;var Fr=Wn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:W.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,keepBuffer:2},initialize:function(e){p(this,e)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(e){e._addZoomLimit(this)},onRemove:function(e){this._removeAllTiles(),ft(this._container),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(mt(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(ht(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var e=this._clampZoom(this._map.getZoom());e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this},getEvents:function(){var e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||=s(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},createTile:function(){return document.createElement(`div`)},getTileSize:function(){var e=this.options.tileSize;return e instanceof j?e:new j(e,e)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(e){for(var t=this.getPane().children,n=-e(-1/0,1/0),r=0,i=t.length,a;r<i;r++)a=t[r].style.zIndex,t[r]!==this._container&&a&&(n=e(n,+a));isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!W.ielt9){bt(this._container,this.options.opacity);var e=+new Date,t=!1,n=!1;for(var r in this._tiles){var i=this._tiles[r];if(i.current&&i.loaded){var a=Math.min(1,(e-i.loaded)/200);bt(i.el,a),a<1?t=!0:(i.active?n=!0:this._onOpaqueTile(i),i.active=!0)}}n&&!this._noPrune&&this._pruneTiles(),t&&(E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this))}},_onOpaqueTile:l,_initContainer:function(){this._container||(this._container=dt(`div`,`leaflet-layer `+(this.options.className||``)),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var e=this._tileZoom,t=this.options.maxZoom;if(e!==void 0){for(var n in this._levels)n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=t-Math.abs(e-n),this._onUpdateLevel(n)):(ft(this._levels[n].el),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);var r=this._levels[e],i=this._map;return r||(r=this._levels[e]={},r.el=dt(`div`,`leaflet-tile-container leaflet-zoom-animated`,this._container),r.el.style.zIndex=t,r.origin=i.project(i.unproject(i.getPixelOrigin()),e).round(),r.zoom=e,this._setZoomTransform(r,i.getCenter(),i.getZoom()),r.el.offsetWidth,this._onCreateLevel(r)),this._level=r,r}},_onUpdateLevel:l,_onRemoveLevel:l,_onCreateLevel:l,_pruneTiles:function(){if(this._map){var e,t,n=this._map.getZoom();if(n>this.options.maxZoom||n<this.options.minZoom)this._removeAllTiles();else{for(e in this._tiles)t=this._tiles[e],t.retain=t.current;for(e in this._tiles)if(t=this._tiles[e],t.current&&!t.active){var r=t.coords;this._retainParent(r.x,r.y,r.z,r.z-5)||this._retainChildren(r.x,r.y,r.z,r.z+2)}for(e in this._tiles)this._tiles[e].retain||this._removeTile(e)}}},_removeTilesAtZoom:function(e){for(var t in this._tiles)this._tiles[t].coords.z===e&&this._removeTile(t)},_removeAllTiles:function(){for(var e in this._tiles)this._removeTile(e)},_invalidateAll:function(){for(var e in this._levels)ft(this._levels[e].el),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(e,t,n,r){var i=Math.floor(e/2),a=Math.floor(t/2),o=n-1,s=new j(+i,+a);s.z=+o;var c=this._tileCoordsToKey(s),l=this._tiles[c];return l&&l.active?(l.retain=!0,!0):(l&&l.loaded&&(l.retain=!0),o>r&&this._retainParent(i,a,o,r))},_retainChildren:function(e,t,n,r){for(var i=2*e;i<2*e+2;i++)for(var a=2*t;a<2*t+2;a++){var o=new j(i,a);o.z=n+1;var s=this._tileCoordsToKey(o),c=this._tiles[s];c&&c.active?c.retain=!0:(c&&c.loaded&&(c.retain=!0),n+1<r&&this._retainChildren(i,a,n+1,r))}},_resetView:function(e){var t=e&&(e.pinch||e.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)},_animateZoom:function(e){this._setView(e.center,e.zoom,!0,e.noUpdate)},_clampZoom:function(e){var t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e},_setView:function(e,t,n,r){var i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);var a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)},_setZoomTransforms:function(e,t){for(var n in this._levels)this._setZoomTransform(this._levels[n],e,t)},_setZoomTransform:function(e,t,n){var r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();W.any3d?St(e.el,i,r):$(e.el,i)},_resetGrid:function(){var e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.y)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.x),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(e){var t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new P(i.subtract(a),i.add(a))},_update:function(e){var t=this._map;if(t){var n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom!==void 0){var r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new P(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(var l in this._tiles){var u=this._tiles[l].coords;u.z===this._tileZoom&&c.contains(new j(u.x,u.y))||(this._tiles[l].current=!1)}if(Math.abs(n-this._tileZoom)>1)this._setView(e,n);else{for(var d=i.min.y;d<=i.max.y;d++)for(var f=i.min.x;f<=i.max.x;f++){var p=new j(f,d);if(p.z=this._tileZoom,this._isValidTile(p)){var m=this._tiles[this._tileCoordsToKey(p)];m?m.current=!0:o.push(p)}}if(o.sort(function(e,t){return e.distanceTo(a)-t.distanceTo(a)}),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`));var h=document.createDocumentFragment();for(f=0;f<o.length;f++)this._addTile(o[f],h);this._level.el.appendChild(h)}}}}},_isValidTile:function(e){var t=this._map.options.crs;if(!t.infinite){var n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;var r=this._tileCoordsToBounds(e);return I(this.options.bounds).overlaps(r)},_keyToBounds:function(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))},_tileCoordsToNwSe:function(e){var t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]},_tileCoordsToBounds:function(e){var t=this._tileCoordsToNwSe(e),n=new te(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n},_tileCoordsToKey:function(e){return e.x+`:`+e.y+`:`+e.z},_keyToTileCoords:function(e){var t=e.split(`:`),n=new j(+t[0],+t[1]);return n.z=+t[2],n},_removeTile:function(e){var t=this._tiles[e];t&&(ft(t.el),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:this._keyToTileCoords(e)}))},_initTile:function(e){_t(e,`leaflet-tile`);var t=this.getTileSize();e.style.width=t.x+`px`,e.style.height=t.y+`px`,e.onselectstart=l,e.onmousemove=l,W.ielt9&&this.options.opacity<1&&bt(e,this.options.opacity)},_addTile:function(e,t){var n=this._getTilePos(e),r=this._tileCoordsToKey(e),a=this.createTile(this._wrapCoords(e),i(this._tileReady,this,e));this._initTile(a),this.createTile.length<2&&T(i(this._tileReady,this,e,null,a)),$(a,n),this._tiles[r]={el:a,coords:e,current:!0},t.appendChild(a),this.fire(`tileloadstart`,{tile:a,coords:e})},_tileReady:function(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});var r=this._tileCoordsToKey(e);n=this._tiles[r],n&&(n.loaded=+new Date,this._map._fadeAnimated?(bt(n.el,0),E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),t||(_t(n.el,`leaflet-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire(`load`),W.ielt9||!this._map._fadeAnimated?T(this._pruneTiles,this):setTimeout(i(this._pruneTiles,this),250)))},_getTilePos:function(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(e){var t=new j(this._wrapX?c(e.x,this._wrapX):e.x,this._wrapY?c(e.y,this._wrapY):e.y);return t.z=e.z,t},_pxBoundsToTileRange:function(e){var t=this.getTileSize();return new P(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var e in this._tiles)if(!this._tiles[e].loaded)return!1;return!0}});function Ir(e){return new Fr(e)}var Lr=Fr.extend({options:{minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(e,t){this._url=e,t=p(this,t),t.detectRetina&&W.retina&&t.maxZoom>0?(t.tileSize=Math.floor(t.tileSize/2),t.zoomReverse?(t.zoomOffset--,t.minZoom=Math.min(t.maxZoom,t.minZoom+1)):(t.zoomOffset++,t.maxZoom=Math.max(t.minZoom,t.maxZoom-1)),t.minZoom=Math.max(0,t.minZoom)):t.zoomReverse?t.minZoom=Math.min(t.maxZoom,t.minZoom):t.maxZoom=Math.max(t.minZoom,t.maxZoom),typeof t.subdomains==`string`&&(t.subdomains=t.subdomains.split(``)),this.on(`tileunload`,this._onTileRemove)},setUrl:function(e,t){return this._url===e&&t===void 0&&(t=!0),this._url=e,t||this.redraw(),this},createTile:function(e,t){var n=document.createElement(`img`);return Lt(n,`load`,i(this._tileOnLoad,this,t,n)),Lt(n,`error`,i(this._tileOnError,this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``,n.src=this.getTileUrl(e),n},getTileUrl:function(e){var t={r:W.retina?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var r=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=r),t[`-y`]=r}return g(this._url,n(t,this.options))},_tileOnLoad:function(e,t){W.ielt9?setTimeout(i(e,this,null,t),0):e(null,t)},_tileOnError:function(e,t,n){var r=this.options.errorTileUrl;r&&t.getAttribute(`src`)!==r&&(t.src=r),e(n,t)},_onTileRemove:function(e){e.tile.onload=null},_getZoomForUrl:function(){var e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r},_getSubdomain:function(e){var t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_abortLoading:function(){var e,t;for(e in this._tiles)if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,t.onload=l,t.onerror=l,!t.complete)){t.src=y;var n=this._tiles[e].coords;ft(t),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}},_removeTile:function(e){var t=this._tiles[e];if(t)return t.el.setAttribute(`src`,y),Fr.prototype._removeTile.call(this,e)},_tileReady:function(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===y))return Fr.prototype._tileReady.call(this,e,t,n)}});function Rr(e,t){return new Lr(e,t)}var zr=Lr.extend({defaultWmsParams:{service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`},options:{crs:null,uppercase:!1},initialize:function(e,t){this._url=e;var r=n({},this.defaultWmsParams);for(var i in t)i in this.options||(r[i]=t[i]);t=p(this,t);var a=t.detectRetina&&W.retina?2:1,o=this.getTileSize();r.width=o.x*a,r.height=o.y*a,this.wmsParams=r},onAdd:function(e){this._crs=this.options.crs||e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var t=this._wmsVersion>=1.3?`crs`:`srs`;this.wmsParams[t]=this._crs.code,Lr.prototype.onAdd.call(this,e)},getTileUrl:function(e){var t=this._tileCoordsToNwSe(e),n=this._crs,r=F(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===Hn?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=Lr.prototype.getTileUrl.call(this,e);return s+m(this.wmsParams,s,this.options.uppercase)+(this.options.uppercase?`&BBOX=`:`&bbox=`)+o},setParams:function(e,t){return n(this.wmsParams,e),t||this.redraw(),this}});function Br(e,t){return new zr(e,t)}Lr.WMS=zr,Rr.wms=Br;var Vr=Wn.extend({options:{padding:.1},initialize:function(e){p(this,e),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),_t(this._container,`leaflet-zoom-animated`)),this.getPane().appendChild(this._container),this._update(),this.on(`update`,this._updatePaths,this)},onRemove:function(){this.off(`update`,this._updatePaths,this),this._destroyContainer()},getEvents:function(){var e={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(e,t){var n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n).add(i).subtract(this._map._getNewPixelOrigin(e,t));W.any3d?St(this._container,a,n):$(this._container,a)},_reset:function(){for(var e in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[e]._reset()},_onZoomEnd:function(){for(var e in this._layers)this._layers[e]._project()},_updatePaths:function(){for(var e in this._layers)this._layers[e]._update()},_update:function(){var e=this.options.padding,t=this._map.getSize(),n=this._map.containerPointToLayerPoint(t.multiplyBy(-e)).round();this._bounds=new P(n,n.add(t.multiplyBy(1+e*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Hr=Vr.extend({options:{tolerance:0},getEvents:function(){var e=Vr.prototype.getEvents.call(this);return e.viewprereset=this._onViewPreReset,e},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Vr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var e=this._container=document.createElement(`canvas`);Lt(e,`mousemove`,this._onMouseMove,this),Lt(e,`click dblclick mousedown mouseup contextmenu`,this._onClick,this),Lt(e,`mouseout`,this._handleMouseOut,this),e._leaflet_disable_events=!0,this._ctx=e.getContext(`2d`)},_destroyContainer:function(){E(this._redrawRequest),delete this._ctx,ft(this._container),zt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var e;for(var t in this._redrawBounds=null,this._layers)e=this._layers[t],e._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vr.prototype._update.call(this);var e=this._bounds,t=this._container,n=e.getSize(),r=W.retina?2:1;$(t,e.min),t.width=r*n.x,t.height=r*n.y,t.style.width=n.x+`px`,t.style.height=n.y+`px`,W.retina&&this._ctx.scale(2,2),this._ctx.translate(-e.min.x,-e.min.y),this.fire(`update`)}},_reset:function(){Vr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(e){this._updateDashArray(e),this._layers[o(e)]=e;var t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(e){this._requestRedraw(e)},_removePath:function(e){var t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[o(e)],this._requestRedraw(e)},_updatePath:function(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)},_updateStyle:function(e){this._updateDashArray(e),this._requestRedraw(e)},_updateDashArray:function(e){if(typeof e.options.dashArray==`string`){for(var t=e.options.dashArray.split(/[, ]+/),n=[],r,i=0;i<t.length;i++){if(r=Number(t[i]),isNaN(r))return;n.push(r)}e.options._dashArray=n}else e.options._dashArray=e.options.dashArray},_requestRedraw:function(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest=this._redrawRequest||T(this._redraw,this))},_extendRedrawBounds:function(e){if(e._pxBounds){var t=(e.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new P,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var e=this._redrawBounds;if(e){var t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var e,t=this._redrawBounds;if(this._ctx.save(),t){var n=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,n.x,n.y),this._ctx.clip()}this._drawing=!0;for(var r=this._drawFirst;r;r=r.next)e=r.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(e,t){if(this._drawing){var n,r,i,a,o=e._parts,s=o.length,c=this._ctx;if(s){for(c.beginPath(),n=0;n<s;n++){for(r=0,i=o[n].length;r<i;r++)a=o[n][r],c[r?`lineTo`:`moveTo`](a.x,a.y);t&&c.closePath()}this._fillStroke(c,e)}}},_updateCircle:function(e){if(this._drawing&&!e._empty()){var t=e._point,n=this._ctx,r=Math.max(Math.round(e._radius),1),i=(Math.max(Math.round(e._radiusY),1)||r)/r;i!==1&&(n.save(),n.scale(1,i)),n.beginPath(),n.arc(t.x,t.y/i,r,0,Math.PI*2,!1),i!==1&&n.restore(),this._fillStroke(n,e)}},_fillStroke:function(e,t){var n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor||n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.setLineDash&&e.setLineDash(t.options&&t.options._dashArray||[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())},_onClick:function(e){for(var t=this._map.mouseEventToLayerPoint(e),n,r,i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)},_onMouseMove:function(e){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var t=this._map.mouseEventToLayerPoint(e);this._handleMouseHover(e,t)}},_handleMouseOut:function(e){var t=this._hoveredLayer;t&&(vt(this._container,`leaflet-interactive`),this._fireEvent([t],e,`mouseout`),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(e,t){if(!this._mouseHoverThrottled){for(var n,r,a=this._drawFirst;a;a=a.next)n=a.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handleMouseOut(e),r&&(_t(this._container,`leaflet-interactive`),this._fireEvent([r],e,`mouseover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._mouseHoverThrottled=!0,setTimeout(i(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)},_bringToFront:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}},_bringToBack:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}}});function Ur(e){return W.canvas?new Hr(e):null}var Wr=(function(){try{return document.namespaces.add(`lvml`,`urn:schemas-microsoft-com:vml`),function(e){return document.createElement(`<lvml:`+e+` class="lvml">`)}}catch{}return function(e){return document.createElement(`<`+e+` xmlns="urn:schemas-microsoft.com:vml" class="lvml">`)}})(),Gr={_initContainer:function(){this._container=dt(`div`,`leaflet-vml-container`)},_update:function(){this._map._animatingZoom||(Vr.prototype._update.call(this),this.fire(`update`))},_initPath:function(e){var t=e._container=Wr(`shape`);_t(t,`leaflet-vml-shape `+(this.options.className||``)),t.coordsize=`1 1`,e._path=Wr(`path`),t.appendChild(e._path),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){var t=e._container;this._container.appendChild(t),e.options.interactive&&e.addInteractiveTarget(t)},_removePath:function(e){var t=e._container;ft(t),e.removeInteractiveTarget(t),delete this._layers[o(e)]},_updateStyle:function(e){var t=e._stroke,n=e._fill,r=e.options,i=e._container;i.stroked=!!r.stroke,i.filled=!!r.fill,r.stroke?(t||=e._stroke=Wr(`stroke`),i.appendChild(t),t.weight=r.weight+`px`,t.color=r.color,t.opacity=r.opacity,r.dashArray?t.dashStyle=_(r.dashArray)?r.dashArray.join(` `):r.dashArray.replace(/( *, *)/g,` `):t.dashStyle=``,t.endcap=r.lineCap.replace(`butt`,`flat`),t.joinstyle=r.lineJoin):t&&(i.removeChild(t),e._stroke=null),r.fill?(n||=e._fill=Wr(`fill`),i.appendChild(n),n.color=r.fillColor||r.color,n.opacity=r.fillOpacity):n&&(i.removeChild(n),e._fill=null)},_updateCircle:function(e){var t=e._point.round(),n=Math.round(e._radius),r=Math.round(e._radiusY||n);this._setPath(e,e._empty()?`M0 0`:`AL `+t.x+`,`+t.y+` `+n+`,`+r+` 0,23592600`)},_setPath:function(e,t){e._path.v=t},_bringToFront:function(e){mt(e._container)},_bringToBack:function(e){ht(e._container)}},Kr=W.vml?Wr:ue,qr=Vr.extend({_initContainer:function(){this._container=Kr(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=Kr(`g`),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ft(this._container),zt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vr.prototype._update.call(this);var e=this._bounds,t=e.getSize(),n=this._container;this._svgSize&&this._svgSize.equals(t)||(this._svgSize=t,n.setAttribute(`width`,t.x),n.setAttribute(`height`,t.y)),$(n,e.min),n.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}},_initPath:function(e){var t=e._path=Kr(`path`);e.options.className&&_t(t,e.options.className),e.options.interactive&&_t(t,`leaflet-interactive`),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)},_removePath:function(e){ft(e._path),e.removeInteractiveTarget(e._path),delete this._layers[o(e)]},_updatePath:function(e){e._project(),e._update()},_updateStyle:function(e){var t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,n.opacity),t.setAttribute(`stroke-width`,n.weight),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,n.fillOpacity),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))},_updatePoly:function(e,t){this._setPath(e,de(e._parts,t))},_updateCircle:function(e){var t=e._point,n=Math.max(Math.round(e._radius),1),r=Math.max(Math.round(e._radiusY),1)||n,i=`a`+n+`,`+r+` 0 1,0 `,a=e._empty()?`M0 0`:`M`+(t.x-n)+`,`+t.y+i+n*2+`,0 `+i+-n*2+`,0 `;this._setPath(e,a)},_setPath:function(e,t){e._path.setAttribute(`d`,t)},_bringToFront:function(e){mt(e._path)},_bringToBack:function(e){ht(e._path)}});W.vml&&qr.include(Gr);function Jr(e){return W.svg||W.vml?new qr(e):null}nn.include({getRenderer:function(e){var t=e.options.renderer||this._getPaneRenderer(e.options.pane)||this.options.renderer||this._renderer;return t||=this._renderer=this._createRenderer(),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(e){if(e===`overlayPane`||e===void 0)return!1;var t=this._paneRenderers[e];return t===void 0&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer:function(e){return this.options.preferCanvas&&Ur(e)||Jr(e)}});var Yr=cr.extend({initialize:function(e,t){cr.prototype.initialize.call(this,this._boundsToLatLngs(e),t)},setBounds:function(e){return this.setLatLngs(this._boundsToLatLngs(e))},_boundsToLatLngs:function(e){return e=I(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}});function Xr(e,t){return new Yr(e,t)}qr.create=Kr,qr.pointsToPath=de,ur.geometryToLayer=dr,ur.coordsToLatLng=pr,ur.coordsToLatLngs=mr,ur.latLngToCoords=hr,ur.latLngsToCoords=gr,ur.getFeature=_r,ur.asFeature=vr,nn.mergeOptions({boxZoom:!0});var Zr=mn.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane,this._resetStateTimeout=0,e.on(`unload`,this._destroy,this)},addHooks:function(){Lt(this._container,`mousedown`,this._onMouseDown,this)},removeHooks:function(){zt(this._container,`mousedown`,this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ft(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(e){if(!e.shiftKey||e.which!==1&&e.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),wt(),Ot(),this._startPoint=this._map.mouseEventToContainerPoint(e),Lt(document,{contextmenu:Jt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=dt(`div`,`leaflet-zoom-box`,this._container),_t(this._container,`leaflet-crosshair`),this._map.fire(`boxzoomstart`)),this._point=this._map.mouseEventToContainerPoint(e);var t=new P(this._point,this._startPoint),n=t.getSize();$(this._box,t.min),this._box.style.width=n.x+`px`,this._box.style.height=n.y+`px`},_finish:function(){this._moved&&(ft(this._box),vt(this._container,`leaflet-crosshair`)),Tt(),kt(),zt(document,{contextmenu:Jt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(e){if((e.which===1||e.button===1)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(i(this._resetState,this),0);var t=new te(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire(`boxzoomend`,{boxZoomBounds:t})}},_onKeyDown:function(e){e.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});nn.addInitHook(`addHandler`,`boxZoom`,Zr),nn.mergeOptions({doubleClickZoom:!0});var Qr=mn.extend({addHooks:function(){this._map.on(`dblclick`,this._onDoubleClick,this)},removeHooks:function(){this._map.off(`dblclick`,this._onDoubleClick,this)},_onDoubleClick:function(e){var t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}});nn.addInitHook(`addHandler`,`doubleClickZoom`,Qr),nn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var $r=mn.extend({addHooks:function(){if(!this._draggable){var e=this._map;this._draggable=new _n(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on(`predrag`,this._onPreDragWrap,this),e.on(`zoomend`,this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}_t(this._map._container,`leaflet-grab leaflet-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){vt(this._map._container,`leaflet-grab`),vt(this._map._container,`leaflet-touch-drag`),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var t=I(this._map.options.maxBounds);this._offsetLimit=F(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire(`movestart`).fire(`dragstart`),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var t=this._lastTime=+new Date,n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(t),this._prunePositions(t)}this._map.fire(`move`,e).fire(`drag`,e)},_prunePositions:function(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(e,t){return e-(e-t)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}},_onPreDragWrap:function(){var e=this._worldWidth,t=Math.round(e/2),n=this._initialWorldOffset,r=this._draggable._newPos.x,i=(r-t+n)%e+t-n,a=(r+t+n)%e-t-n,o=Math.abs(i+n)<Math.abs(a+n)?i:a;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=o},_onDragEnd:function(e){var t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(+new Date);var i=this._lastPos.subtract(this._positions[0]),a=(this._lastTime-this._times[0])/1e3,o=n.easeLinearity,s=i.multiplyBy(o/a),c=s.distanceTo([0,0]),l=Math.min(n.inertiaMaxSpeed,c),u=s.multiplyBy(l/c),d=l/(n.inertiaDeceleration*o),f=u.multiplyBy(-d/2).round();!f.x&&!f.y?t.fire(`moveend`):(f=t._limitOffset(f,t.options.maxBounds),T(function(){t.panBy(f,{duration:d,easeLinearity:o,noMoveStart:!0,animate:!0})}))}}});nn.addInitHook(`addHandler`,`dragging`,$r),nn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var ei=mn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(e){this._map=e,this._setPanDelta(e.options.keyboardPanDelta),this._setZoomDelta(e.options.zoomDelta)},addHooks:function(){var e=this._map._container;e.tabIndex<=0&&(e.tabIndex=`0`),Lt(e,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),zt(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var e=document.body,t=document.documentElement,n=e.scrollTop||t.scrollTop,r=e.scrollLeft||t.scrollLeft;this._map._container.focus(),window.scrollTo(r,n)}},_onFocus:function(){this._focused=!0,this._map.fire(`focus`)},_onBlur:function(){this._focused=!1,this._map.fire(`blur`)},_setPanDelta:function(e){for(var t=this._panKeys={},n=this.keyCodes,r=0,i=n.left.length;r<i;r++)t[n.left[r]]=[-1*e,0];for(r=0,i=n.right.length;r<i;r++)t[n.right[r]]=[e,0];for(r=0,i=n.down.length;r<i;r++)t[n.down[r]]=[0,e];for(r=0,i=n.up.length;r<i;r++)t[n.up[r]]=[0,-1*e]},_setZoomDelta:function(e){for(var t=this._zoomKeys={},n=this.keyCodes,r=0,i=n.zoomIn.length;r<i;r++)t[n.zoomIn[r]]=e;for(r=0,i=n.zoomOut.length;r<i;r++)t[n.zoomOut[r]]=-e},_addHooks:function(){Lt(document,`keydown`,this._onKeyDown,this)},_removeHooks:function(){zt(document,`keydown`,this._onKeyDown,this)},_onKeyDown:function(e){if(!(e.altKey||e.ctrlKey||e.metaKey)){var t=e.keyCode,n=this._map,r;if(t in this._panKeys){if(!n._panAnim||!n._panAnim._inProgress){if(r=this._panKeys[t],e.shiftKey&&(r=N(r).multiplyBy(3)),n.options.maxBounds&&(r=n._limitOffset(N(r),n.options.maxBounds)),n.options.worldCopyJump){var i=n.wrapLatLng(n.unproject(n.project(n.getCenter()).add(r)));n.panTo(i)}else n.panBy(r)}}else if(t in this._zoomKeys)n.setZoom(n.getZoom()+(e.shiftKey?3:1)*this._zoomKeys[t]);else if(t===27&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup();else return;Jt(e)}}});nn.addInitHook(`addHandler`,`keyboard`,ei),nn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ti=mn.extend({addHooks:function(){Lt(this._map._container,`wheel`,this._onWheelScroll,this),this._delta=0},removeHooks:function(){zt(this._map._container,`wheel`,this._onWheelScroll,this)},_onWheelScroll:function(e){var t=Qt(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._startTime||=+new Date;var r=Math.max(n-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(i(this._performZoom,this),r),Jt(e)},_performZoom:function(){var e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap||0;e._stop();var r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._limitZoom(t+(this._delta>0?a:-a))-t;this._delta=0,this._startTime=null,o&&(e.options.scrollWheelZoom===`center`?e.setZoom(t+o):e.setZoomAround(this._lastMousePos,t+o))}});nn.addInitHook(`addHandler`,`scrollWheelZoom`,ti);var ni=600;nn.mergeOptions({tapHold:W.touchNative&&W.safari&&W.mobile,tapTolerance:15});var ri=mn.extend({addHooks:function(){Lt(this._map._container,`touchstart`,this._onDown,this)},removeHooks:function(){zt(this._map._container,`touchstart`,this._onDown,this)},_onDown:function(e){if(clearTimeout(this._holdTimeout),e.touches.length===1){var t=e.touches[0];this._startPos=this._newPos=new j(t.clientX,t.clientY),this._holdTimeout=setTimeout(i(function(){this._cancel(),this._isTapValid()&&(Lt(document,`touchend`,qt),Lt(document,`touchend touchcancel`,this._cancelClickPrevent),this._simulateEvent(`contextmenu`,t))},this),ni),Lt(document,`touchend touchcancel contextmenu`,this._cancel,this),Lt(document,`touchmove`,this._onMove,this)}},_cancelClickPrevent:function e(){zt(document,`touchend`,qt),zt(document,`touchend touchcancel`,e)},_cancel:function(){clearTimeout(this._holdTimeout),zt(document,`touchend touchcancel contextmenu`,this._cancel,this),zt(document,`touchmove`,this._onMove,this)},_onMove:function(e){var t=e.touches[0];this._newPos=new j(t.clientX,t.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(e,t){var n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}});nn.addInitHook(`addHandler`,`tapHold`,ri),nn.mergeOptions({touchZoom:W.touch,bounceAtZoomLimits:!0});var ii=mn.extend({addHooks:function(){_t(this._map._container,`leaflet-touch-zoom`),Lt(this._map._container,`touchstart`,this._onTouchStart,this)},removeHooks:function(){vt(this._map._container,`leaflet-touch-zoom`),zt(this._map._container,`touchstart`,this._onTouchStart,this)},_onTouchStart:function(e){var t=this._map;if(!(!e.touches||e.touches.length!==2||t._animatingZoom||this._zooming)){var n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.touchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(n.add(r)._divideBy(2))),this._startDist=n.distanceTo(r),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),Lt(document,`touchmove`,this._onTouchMove,this),Lt(document,`touchend touchcancel`,this._onTouchEnd,this),qt(e)}},_onTouchMove:function(e){if(e.touches&&e.touches.length===2&&this._zooming){var t=this._map,n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]),a=n.distanceTo(r)/this._startDist;if(this._zoom=t.getScaleZoom(a,this._startZoom),!t.options.bounceAtZoomLimits&&(this._zoom<t.getMinZoom()&&a<1||this._zoom>t.getMaxZoom()&&a>1)&&(this._zoom=t._limitZoom(this._zoom)),t.options.touchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{var o=n._add(r)._divideBy(2)._subtract(this._centerPoint);if(a===1&&o.x===0&&o.y===0)return;this._center=t.unproject(t.project(this._pinchStartLatLng,this._zoom).subtract(o),this._zoom)}this._moved||=(t._moveStart(!0,!1),!0),E(this._animRequest);var s=i(t._move,t,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=T(s,this,!0),qt(e)}},_onTouchEnd:function(){!this._moved||!this._zooming?this._zooming=!1:(this._zooming=!1,E(this._animRequest),zt(document,`touchmove`,this._onTouchMove,this),zt(document,`touchend touchcancel`,this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}});nn.addInitHook(`addHandler`,`touchZoom`,ii),nn.BoxZoom=Zr,nn.DoubleClickZoom=Qr,nn.Drag=$r,nn.Keyboard=ei,nn.ScrollWheelZoom=ti,nn.TapHold=ri,nn.TouchZoom=ii,e.Bounds=P,e.Browser=W,e.CRS=ne,e.Canvas=Hr,e.Circle=ir,e.CircleMarker=nr,e.Class=O,e.Control=an,e.DivIcon=Nr,e.DivOverlay=Or,e.DomEvent=en,e.DomUtil=It,e.Draggable=_n,e.Evented=ee,e.FeatureGroup=qn,e.GeoJSON=ur,e.GridLayer=Fr,e.Handler=mn,e.Icon=Yn,e.ImageOverlay=Sr,e.LatLng=R,e.LatLngBounds=te,e.Layer=Wn,e.LayerGroup=Gn,e.LineUtil=Ln,e.Map=nn,e.Marker=$n,e.Mixin=hn,e.Path=tr,e.Point=j,e.PolyUtil=xn,e.Polygon=cr,e.Polyline=or,e.Popup=kr,e.PosAnimation=tn,e.Projection=Bn,e.Rectangle=Yr,e.Renderer=Vr,e.SVG=qr,e.SVGOverlay=Er,e.TileLayer=Lr,e.Tooltip=jr,e.Transformation=oe,e.Util=D,e.VideoOverlay=wr,e.bind=i,e.bounds=F,e.canvas=Ur,e.circle=ar,e.circleMarker=rr,e.control=on,e.divIcon=Pr,e.extend=n,e.featureGroup=Jn,e.geoJSON=br,e.geoJson=xr,e.gridLayer=Ir,e.icon=Xn,e.imageOverlay=Cr,e.latLng=z,e.latLngBounds=I,e.layerGroup=Kn,e.map=rn,e.marker=er,e.point=N,e.polygon=lr,e.polyline=sr,e.popup=Ar,e.rectangle=Xr,e.setOptions=p,e.stamp=o,e.svg=Jr,e.svgOverlay=Dr,e.tileLayer=Rr,e.tooltip=Mr,e.transformation=se,e.version=t,e.videoOverlay=Tr;var ai=window.L;e.noConflict=function(){return window.L=ai,this},window.L=e}))}))(),1);function yl({places:e,selected:t,onPick:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(n);o.current=n,(0,v.useEffect)(()=>{if(!r.current)return;let e=vl.default.map(r.current,{zoomControl:!0,attributionControl:!0}).setView([46.8,8.2],7);vl.default.tileLayer(`https://tile.openstreetmap.org/{z}/{x}/{y}.png`,{maxZoom:19,attribution:`&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a>`}).addTo(e),a.current=vl.default.layerGroup().addTo(e),i.current=e;let t=new ResizeObserver(()=>e.invalidateSize());return t.observe(r.current),()=>{t.disconnect(),e.remove(),i.current=null}},[]);let s=e.map(e=>`${e.slug}@${e.lat},${e.lng}`).join(`|`);return(0,v.useEffect)(()=>{let n=i.current,r=a.current;if(!n||!r)return;r.clearLayers();let s=getComputedStyle(document.documentElement).getPropertyValue(`--color-accent`).trim()||`#2563eb`;for(let n of e){let e=n.slug===t;vl.default.circleMarker([n.lat,n.lng],{radius:e?10:7,weight:2,color:`#fff`,fillColor:e?s:`#be123c`,fillOpacity:1}).bindTooltip(n.title,{direction:`top`,offset:[0,-8],permanent:e}).on(`click`,()=>o.current(n.slug)).addTo(r).getElement()?.setAttribute(`data-place`,n.slug)}let c=e.find(e=>e.slug===t);c?n.flyTo([c.lat,c.lng],Math.max(n.getZoom(),15),{duration:.6}):e.length===1?n.setView([e[0].lat,e[0].lng],14):e.length>1&&n.fitBounds(vl.default.latLngBounds(e.map(e=>[e.lat,e.lng])),{padding:[32,32],maxZoom:15})},[s,t]),(0,I.jsx)(`div`,{ref:r,className:`places-map size-full min-h-[240px] overflow-hidden rounded-lg border border-line`,role:`region`,"aria-label":`map of the places`})}var bl=e=>e.slice(0,10),xl=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Sl=e=>new Date(Number(e.slice(0,4)),Number(e.slice(5,7))-1,1),Cl=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function wl({events:e,selected:t,onPick:n}){let r=e.find(e=>e.slug===t),[i,a]=(0,v.useState)(()=>Sl(r?r.start:xl(new Date)));(0,v.useEffect)(()=>{r&&a(Sl(r.start))},[r?.slug,r?.start]);let o=new Date(i),s=(o.getDay()+6)%7,c=new Date(o.getFullYear(),o.getMonth(),1-s),l=new Date(o.getFullYear(),o.getMonth()+1,0).getDate(),u=Math.ceil((s+l)/7),d=Array.from({length:u*7},(e,t)=>new Date(c.getFullYear(),c.getMonth(),c.getDate()+t)),f=xl(new Date),p=t=>e.filter(e=>bl(e.start)<=t&&t<=bl(e.end||e.start)).sort((e,t)=>e.start.localeCompare(t.start)),m=e.filter(e=>bl(e.start)<=xl(d[d.length-1])&&bl(e.end||e.start)>=xl(d[0])).length,h=e=>a(new Date(i.getFullYear(),i.getMonth()+e,1));return(0,I.jsxs)(`div`,{className:`events-calendar flex min-h-0 flex-1 flex-col gap-2`,role:`region`,"aria-label":`calendar of the events`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,I.jsxs)(`h3`,{className:`m-0 flex-1 text-base font-semibold text-fg`,"aria-live":`polite`,children:[i.toLocaleDateString([],{month:`long`,year:`numeric`}),(0,I.jsxs)(`span`,{className:`ms-2 text-xs font-normal text-fg-2`,children:[m,` event`,m===1?``:`s`]})]}),(0,I.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded-full px-2.5 py-1 text-xs text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>a(Sl(f)),children:`today`}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`previous month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(-1),children:(0,I.jsx)(R,{name:`chevron_left`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`next month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(1),children:(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm`})})]}),(0,I.jsx)(`div`,{className:`grid flex-none grid-cols-7 text-center text-2xs tracking-wide text-fg-2 uppercase`,children:Cl.map(e=>(0,I.jsx)(`span`,{children:e},e))}),(0,I.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 overflow-y-auto rounded-lg border border-line bg-line`,style:{gridTemplateRows:`repeat(${u}, minmax(44px, 1fr))`,gap:1},children:d.map(e=>{let r=xl(e),a=p(r),o=e.getMonth()!==i.getMonth();return(0,I.jsxs)(`div`,{"data-day":r,className:P(`flex min-h-0 min-w-0 flex-col gap-px overflow-hidden bg-surface p-0.5`,o&&`bg-[color-mix(in_srgb,var(--color-surface-2)_35%,var(--color-surface))]`),children:[(0,I.jsx)(`span`,{className:P(`self-end px-1 text-2xs tabular-nums`,o?`text-fg-2/60`:`text-fg-2`,r===f&&`rounded-full bg-accent px-1.5 font-semibold text-on-accent`),children:e.getDate()}),a.slice(0,4).map(e=>{let i=bl(e.start)===r&&e.start.length>10?e.start.slice(11,16):``;return(0,I.jsxs)(`button`,{type:`button`,"data-event":e.slug,"aria-pressed":e.slug===t,title:`${e.title} · ${e.start.replace(`T`,` `)}${e.end?`–${e.end.replace(`T`,` `)}`:``}`,className:P(`block w-full cursor-pointer truncate rounded px-1 text-left text-2xs leading-4`,e.slug===t?`bg-accent text-on-accent`:`bg-[color-mix(in_srgb,#a16207_16%,var(--color-surface))] text-fg hover:brightness-95`),onClick:()=>n(e.slug),children:[i&&(0,I.jsx)(`span`,{className:`me-1 tabular-nums opacity-70`,children:i}),e.title]},e.slug)}),a.length>4&&(0,I.jsxs)(`span`,{className:`px-1 text-2xs text-fg-2`,children:[`+`,a.length-4,` more`]})]},r)})})]})}var Tl=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),El=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,Dl=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,Ol=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function kl({here:e,onClick:t,children:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:t,className:P(`cursor-pointer rounded-md border-0 bg-transparent px-1 py-0.5 font-[inherit] hover:bg-surface-2 hover:text-fg`,e?`font-semibold text-fg`:`text-fg-2`),children:n})}function Al(e){if(e.type===`dir`)return`folder`;let t=e.mime??``;return t.startsWith(`image/`)?`image`:t===`application/pdf`?`picture_as_pdf`:t.startsWith(`video/`)?`movie`:t.startsWith(`audio/`)?`music_note`:/csv|tab-separated|spreadsheet/.test(t)?`table`:/zip/.test(t)?`folder_zip`:/presentation/.test(t)?`slideshow`:t.startsWith(`text/`)||/json|yaml|xml|wordprocessing/.test(t)?`description`:`draft`}function jl({scope:e,dir:t,file:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(0);(0,v.useEffect)(()=>{A.call(`files.scopes`).then(e=>i(e.scopes),()=>i([]))},[a]);let s=(r??[]).filter(e=>e.scope!==`workspace`);return(0,I.jsxs)(`div`,{className:`runs-screen files-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`files`}),(0,I.jsxs)(Ot,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,I.jsx)(Ml,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,I.jsx)(Et,{title:`projects`,divided:!0}),s.map(t=>(0,I.jsx)(Ml,{s:t,active:e===t.scope,icon:`folder_special`},t.scope))]})]}),(0,I.jsx)(`div`,{className:`runs-main min-w-0`,children:(0,I.jsx)(Nl,{scope:e,dir:t,file:n,onOpen:(t,n)=>H(El(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function Ml({s:e,active:t,icon:n}){return(0,I.jsx)(mt,{href:El(e.scope),active:t,size:`sm`,leading:(0,I.jsx)(R,{name:n,className:`ms-sm`}),title:e.label,sub:(0,I.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function Nl({scope:e,dir:t,file:n,onOpen:r,onChanged:i,compact:a=!1}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useRef)(null),S=(0,v.useCallback)(async()=>{let n=await A.request(`files.list`,{query:{scope:e,path:t}}).catch(()=>null);!n?.ok||!n.data||typeof n.data!=`object`?(l(n?.error??`could not load the folder`),s(null)):(l(``),s(n.data))},[e,t]);(0,v.useEffect)(()=>{S();let e=setInterval(()=>void S(),1e4);return()=>clearInterval(e)},[S]);let C=async()=>{await S(),i?.()};async function w(n){let r=[...n];if(r.length){l(``);for(let[n,i]of r.entries()){d(r.length>1?`uploading ${n+1} of ${r.length}…`:`uploading ${i.name}…`);let a=await A.request(`files.upload`,{query:{scope:e,path:t},headers:{"x-file-name":encodeURIComponent(i.name),"content-type":i.type||`application/octet-stream`},body:i}).catch(()=>null);a?.ok||l(a?.error??`could not upload ${i.name}`)}d(``),await C()}}async function T(n){let r=n.trim();if(h(null),!r)return;let i=M(await A.request(`files.mkdir`,{body:{scope:e,path:t?`${t}/${r}`:r}}));i&&l(i),await C()}async function E(i,a){_(null);let o=a.trim();if(!o||o===i.split(`/`).pop())return;let s=i.includes(`/`)?`${i.slice(0,i.lastIndexOf(`/`))}/${o}`:o,c=M(await A.request(`files.move`,{body:{scope:e,from:i,to:s}}));c?l(c):n===i&&r(t,s),await C()}async function D(i){b(null);let a=await A.request(`files.delete`,{query:{scope:e,path:i}}).catch(()=>null);a?.ok||l(a?.error??`could not delete`),n===i&&r(t),await C()}let O=t?t.split(`/`):[],k=n?o?.entries.find(e=>e.path===n):void 0,ee=!(a&&n);return(0,I.jsxs)(`div`,{className:P(`files-browser h-full min-h-0`,a?`flex flex-col gap-2 px-1.5 py-1`:P(`grid gap-4`,n?`grid-cols-1 min-[900px]:grid-cols-[minmax(280px,1fr)_minmax(0,1.3fr)]`:`grid-cols-1`)),children:[ee&&(0,I.jsxs)(`div`,{className:P(`flex min-h-0 flex-col rounded-card outline-2 -outline-offset-2 outline-dashed transition-colors`,f?`bg-accent/5 outline-accent`:`outline-transparent`),onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||p(!1)},onDrop:e=>{e.preventDefault(),p(!1),w(e.dataTransfer.files)},children:[(0,I.jsxs)(`div`,{className:P(`flex items-center gap-1`,a?`px-1 pb-1.5 pt-0.5`:`px-0.5 pb-2.5 pt-1`),children:[(0,I.jsxs)(`nav`,{className:P(`flex min-w-0 flex-wrap items-center`,a?`text-sm`:`text-md`),"aria-label":`Folder`,children:[(0,I.jsx)(kl,{here:!O.length,onClick:()=>r(``),children:o?.label??(e===`workspace`?`Workspace`:e.replace(/^project:/,``))}),O.map((e,t)=>(0,I.jsxs)(`span`,{className:`inline-flex items-center text-fg-2`,children:[(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(kl,{here:t===O.length-1,onClick:()=>r(O.slice(0,t+1).join(`/`)),children:e})]},t))]}),(0,I.jsx)(`span`,{className:`flex-1`}),a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,I.jsx)(K,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`upload`,onClick:()=>x.current?.click(),title:`Upload files`,children:`upload`})]}),(0,I.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`Upload files`,onChange:e=>e.target.files&&void w(e.target.files)})]}),u&&(0,I.jsx)(tt,{children:u}),c&&(0,I.jsx)(tt,{tone:`bad`,children:c}),(0,I.jsxs)(`div`,{className:`files-list flex min-h-0 flex-1 flex-col gap-px overflow-y-auto`,role:`list`,children:[m!==null&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,I.jsx)(R,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,I.jsx)(Z,{className:`h-8`,autoFocus:!0,value:m,placeholder:`folder name`,"aria-label":`Folder name`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(m),e.key===`Escape`&&h(null)},onBlur:()=>void T(m)})]}),o?.entries.map(i=>g?.path===i.path?(0,I.jsxs)(`div`,{role:`listitem`,className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,I.jsx)(R,{name:Al(i),className:`text-[20px] text-fg-2`}),(0,I.jsx)(Z,{className:`h-8`,autoFocus:!0,value:g.name,"aria-label":`New name`,onChange:e=>_({path:i.path,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E(i.path,g.name),e.key===`Escape`&&_(null)},onBlur:()=>void E(i.path,g.name)})]},i.path):(0,I.jsx)(`div`,{role:`listitem`,children:(0,I.jsx)(mt,{className:`files-row`,active:i.path===n,onClick:()=>i.type===`dir`?r(i.path):r(t,i.path),label:i.name,leading:(0,I.jsx)(R,{name:Al(i),className:`text-[20px] text-fg-2`}),title:(0,I.jsx)(`span`,{className:`font-normal`,children:i.name}),titleExtra:i.local?(0,I.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,title:`Over 25 MB: kept out of git, stays on this machine`,children:`local only`}):void 0,meta:(0,I.jsxs)(I.Fragment,{children:[i.type===`dir`?`${i.count??0} file${i.count===1?``:`s`}`:We(i.size??0),!a&&` · ${W(i.modifiedAt)}`]}),actions:(0,I.jsxs)(I.Fragment,{children:[i.type===`file`&&(0,I.jsx)(`a`,{className:`inline-grid size-7 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,href:Tl(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,I.jsx)(R,{name:`download`,className:`ms-sm`})}),(0,I.jsx)(K,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,I.jsx)(G,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,I.jsx)(K,{icon:`delete`,size:`sm`,label:`Delete ${i.name}`,onClick:()=>b(i.path)})]})})},i.path)),o&&o.entries.length===0&&m===null&&(0,I.jsxs)(Y,{icon:`upload_file`,action:(0,I.jsxs)(`span`,{className:`font-mono text-2xs opacity-80`,children:[o.root,`/`,t?`${t}/`:``]}),children:[`Drop files here, or`,` `,(0,I.jsx)(`button`,{type:`button`,className:`cursor-pointer border-0 bg-transparent p-0 font-[inherit] text-accent underline`,onClick:()=>x.current?.click(),children:`choose some`}),`.`]}),!o&&!c&&(0,I.jsx)(Y,{children:`loading…`})]})]}),n&&(0,I.jsx)(Pl,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function Pl({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=Tl(e,t),c=/^text\/|json|yaml|xml/.test(a)&&!/html/.test(a),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(u(null),!c||(n?.size??0)>2e6)return;let e=!0;return fetch(s,{cache:`no-store`}).then(e=>e.text()).then(t=>e&&u(t)).catch(()=>{}),()=>{e=!1}},[s,c,n?.size]);let d;return d=n?a.startsWith(`image/`)?(0,I.jsx)(`img`,{className:`m-auto max-h-full max-w-full flex-none object-contain p-4`,src:s,alt:o}):a===`application/pdf`?(0,I.jsx)(`iframe`,{className:P(`w-full border-0 bg-white`,i?`min-h-[60vh]`:`min-h-[70vh]`),src:s,title:o}):a.startsWith(`video/`)?(0,I.jsx)(`video`,{className:`m-auto max-h-full w-full p-4`,src:s,controls:!0}):a.startsWith(`audio/`)?(0,I.jsx)(`audio`,{className:`m-auto w-full p-4`,src:s,controls:!0}):c&&l!==null?/markdown/.test(a)?(0,I.jsx)(`div`,{className:`md-body files-md px-5 py-4`,dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,I.jsx)(Fl,{text:l,tab:/tab-separated/.test(a)}):(0,I.jsx)(`pre`,{className:`files-text m-0 whitespace-pre-wrap p-4 font-mono text-[12.5px] leading-relaxed [overflow-wrap:anywhere]`,children:l}):c&&(n.size??0)<=2e6?(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(Y,{icon:Al(n),action:(0,I.jsx)(G,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=Tl(e,t,!0),children:`download`}),children:`No preview for this kind of file.`}):(0,I.jsx)(Y,{children:`loading…`}),(0,I.jsxs)(`section`,{className:P(`files-preview flex min-h-0 flex-col overflow-hidden rounded-card border border-line bg-surface`,i&&`min-h-[60vh]`),"aria-label":`Preview of ${o}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[i&&(0,I.jsx)(K,{icon:`arrow_back`,label:`Back to the folder`,size:`sm`,onClick:r}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold`,title:t,children:o}),n?.size!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:We(n.size)}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`a`,{className:Dl,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`})}),(0,I.jsx)(`a`,{className:Dl,href:Tl(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,I.jsx)(R,{name:`download`,className:`ms-sm`})}),!i&&(0,I.jsx)(K,{icon:`close`,label:`Close the preview`,size:`sm`,onClick:r})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-auto [&>*]:flex-1`,children:d})]})}function Fl({text:e,tab:t}){let n=t?` `:e.split(`
220
+ `).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),O({system:l})]})]}),(0,I.jsx)(lt,{icon:`account_tree`,title:`workflows`,action:s!==`workflows`&&k(()=>(f(t.workflows),c(`workflows`))),children:s===`workflows`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(x?.workflows??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),(x?.workflows??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),O({workflows:d})]}):t.workflows.length===0?(0,I.jsx)(`span`,{className:Os,children:`none connected — the agent can run any workflow you connect`}):(0,I.jsx)(ks,{children:t.workflows.map(e=>(0,I.jsx)(q,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,I.jsx)(lt,{icon:`menu_book`,title:`knowledge`,action:s!==`knowledge`&&k(()=>(f(t.knowledge),c(`knowledge`))),children:s===`knowledge`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(S?.bundles??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),(S?.bundles??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),O({knowledge:d})]}):t.knowledge.length===0?(0,I.jsx)(`span`,{className:Os,children:`none connected — connected bundles are read and kept current by the agent`}):(0,I.jsx)(ks,{children:t.knowledge.map(e=>(0,I.jsx)(q,{href:`/knowledge/${encodeURIComponent(e)}`,children:e},e))})}),(b.vibeables||(t.vibeables??[]).length>0)&&(0,I.jsx)(lt,{icon:`web`,title:`apps`,"data-link-kind":`vibeables`,action:s!==`vibeables`&&k(()=>(f(t.vibeables??[]),c(`vibeables`))),children:s===`vibeables`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(C?.vibeables??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.slug),onChange:t=>E(e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),d.filter(e=>!(C?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,I.jsx)($,{checked:!0,onChange:t=>E(e,t),hint:`not found in this workspace`,mono:!0,children:e},e)),!b.vibeables&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),b.vibeables&&(C?.vibeables??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no apps in this workspace yet — create one on the apps page`})]}),O({vibeables:d})]}):(t.vibeables??[]).length===0?(0,I.jsx)(`span`,{className:`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`,children:`none linked — linked apps are the agent's to build and maintain; it knows them from the first message`}):(0,I.jsx)(ks,{children:(t.vibeables??[]).map(e=>{let t=!b.vibeables||!C||C.vibeables.some(t=>t.slug===e);return(0,I.jsxs)(q,{href:`/vibeables/${encodeURIComponent(e)}`,tone:t?`neutral`:`bad`,title:t?void 0:`configured but not found in this workspace`,children:[e,!t&&` · not found`]},e)})})}),(0,I.jsx)(lt,{icon:`extension`,title:`shared skills`,action:s!==`skills`&&k(()=>{m(t.skills===void 0),f(t.skills??[]),c(`skills`)}),children:s===`skills`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(As,{children:[(0,I.jsx)($,{checked:p,onChange:m,hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!p&&(w?.skills??[]).map(e=>(0,I.jsx)($,{checked:d.includes(e.name),onChange:t=>E(e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!p&&(w?.skills??[]).length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),O({skills:p?void 0:d})]}):t.skills===void 0?(0,I.jsx)(`span`,{className:Os,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,I.jsx)(`span`,{className:Os,children:`none — this agent runs without skills`}):(0,I.jsx)(ks,{children:t.skills.map(e=>(0,I.jsxs)(q,{children:[`/`,e]},e))})})]}),_&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,I.jsx)(tt,{tone:`bad`,children:_})})]}),(0,I.jsx)(Us,{slug:e}),(0,I.jsx)(Ks,{slug:e})]})}var Js=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Ys({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=N(`workflows.list`,{})?.workflows??[],c=N(`knowledge.list`,{})?.bundles??[],l=Te(),u=N(`vibeables.list`,l.vibeables?{}:null)?.vibeables??[],d=N(`skills.list`,{})?.skills??[];(0,v.useEffect)(()=>{e&&A.call(`agents.get`,{slug:e}).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n={...t,skills:t.skillsAll?void 0:t.skills},r=e?await A.request(`agents.save`,{slug:e,body:n}):await A.request(`agents.create`,{body:n});o(!1),r.ok?H(`/agents/${encodeURIComponent(r.data.slug)}/info`):i(M(r))}async function m(){e&&window.confirm(`Move agent "${e}" to the trash?`)&&(await A.request(`agents.delete`,{slug:e}).catch(()=>{}),H(`/agents`))}if(!t)return(0,I.jsx)(Y,{children:r||`loading…`});let h=e=>n({...t,...e}),g=(e,n,r)=>h({[e]:r?[...t[e],n]:t[e].filter(e=>e!==n)});return(0,I.jsxs)(ot,{width:`narrow`,children:[(0,I.jsx)(it,{children:e?`edit ${e}`:`new agent`}),(0,I.jsx)(X,{children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`name`,className:`flex-1`,children:(0,I.jsx)(Z,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,I.jsx)(Q,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,I.jsx)(Z,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Js.map(e=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.emoji===e,className:P(`cursor-pointer rounded-xl border px-2.5 py-1.5 text-base transition-colors`,t.emoji===e?`border-transparent bg-accent-soft`:`border-line bg-transparent hover:bg-surface-2`),onClick:()=>h({emoji:e}),children:e},e))}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`description`,className:`flex-1`,children:(0,I.jsx)(Z,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,I.jsx)(Q,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,I.jsx)(Z,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsxs)(bt,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,I.jsx)(`option`,{value:`claude`,children:`claude`}),(0,I.jsx)(`option`,{value:`codex`,children:`codex`}),(0,I.jsx)(`option`,{value:`pi`,children:`pi`})]})}),(0,I.jsx)(Q,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Z,{className:`font-mono`,value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})}),(0,I.jsx)(Q,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsx)(bt,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:qe.map(e=>(0,I.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,I.jsx)(Q,{label:`system prompt — the agent's role`,children:(0,I.jsx)(yt,{className:js,rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})}),(0,I.jsxs)(Xs,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,I.jsx)($,{checked:t.workflows.includes(e.slug),onChange:t=>g(`workflows`,e.slug,t),hint:e.description,mono:!0,children:e.slug},e.slug)),s.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no workflows in this project`})]}),(0,I.jsxs)(Xs,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,I.jsx)($,{checked:t.knowledge.includes(e.name),onChange:t=>g(`knowledge`,e.name,t),hint:`${e.concepts} concepts`,mono:!0,children:e.name},e.name)),c.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no knowledge bundles in this project`})]}),(l.vibeables||t.vibeables.length>0)&&(0,I.jsxs)(Xs,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,I.jsx)($,{checked:t.vibeables.includes(e.slug),onChange:t=>g(`vibeables`,e.slug,t),hint:e.dev?`dev`:`static`,mono:!0,children:e.slug},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,I.jsx)($,{checked:!0,onChange:()=>g(`vibeables`,e,!1),hint:`not found in this workspace`,mono:!0,children:e},e)),!l.vibeables&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no vibeables in this workspace yet`})]}),(0,I.jsxs)(Xs,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,I.jsx)($,{checked:t.skillsAll,onChange:e=>h({skillsAll:e}),hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!t.skillsAll&&d.map(e=>(0,I.jsx)($,{checked:t.skills.includes(e.name),onChange:t=>g(`skills`,e.name,t),hint:e.description,mono:!0,children:`/${e.name}`},e.name)),!t.skillsAll&&d.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-0`,children:`no skills found (.claude/skills, project or user)`})]}),r&&(0,I.jsx)(tt,{tone:`bad`,children:r}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)(G,{variant:`primary`,busy:a,disabled:!t.name.trim(),onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,I.jsx)(`span`,{className:`flex-1`}),e&&(0,I.jsx)(G,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Xs({label:e,linkKind:t,children:n}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,"data-link-kind":t,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e}),(0,I.jsx)(As,{children:n})]})}var Zs=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Qs=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function $s({seg:e}){let t=e[0]&&e[0]!==`new`&&e[0]!==`chats`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[0]===`chats`?`chats`:e[1]===`edit`?`edit`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`agent`:`home`,r=n===`chats`&&e[1]===`new`,i=n===`chat`?e[2]:n===`chats`&&!r?e[1]:void 0,a=N(`agents.list`,{}),o=be(),[s,c]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)({}),w=(a?.agents??[]).map(e=>S[e.slug]===void 0?e:{...e,group:S[e.slug]||void 0});(0,v.useEffect)(()=>{C(e=>{let t={...e},n=!1;for(let e of a?.agents??[])t[e.slug]!==void 0&&(e.group??``)===t[e.slug]&&(delete t[e.slug],n=!0);return n?t:e})},[a]);let T=w.filter(e=>!e.archived),E=w.filter(e=>e.archived),[D,O]=(0,v.useState)(!1),k=[...new Set([...T.map(e=>e.group??``).filter(Boolean),...s])].sort((e,t)=>e.localeCompare(t)),ee=T.filter(e=>!e.group);function j(e){c(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function M(){let e=d.trim();u(!1),f(``),e&&!k.includes(e)&&j([...s,e])}function F(e,t){m(null);let n=t.trim();if(n&&n!==e){for(let t of w.filter(t=>t.group===e))te(t.slug,n);s.includes(e)&&j([...new Set(s.map(t=>t===e?n:t))])}}async function te(e,t){if((w.find(t=>t.slug===e)?.group??``)!==t){C(n=>({...n,[e]:t}));try{let n=await A.call(`agents.get`,{slug:e});await A.call(`agents.save`,{slug:e,body:{...n,group:t||void 0}})}catch{C(t=>{let n={...t};return delete n[e],n})}}}let z=e=>o?{onDragOver:t=>{_!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,b!==e&&x(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||_;n&&te(n,e),y(null),x(null)}}:{},ne=e=>(0,I.jsx)(`div`,{className:_===e.slug?`opacity-40`:void 0,onDragStart:t=>{if(!o)return t.preventDefault();t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,y(e.slug)},onDragEnd:()=>{y(null),x(null)},children:(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:e.slug===t,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness})},e.slug),re=e=>(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}/info`,active:e.slug===t,dim:e.slug!==t,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),title:e.name,sub:e.description||e.harness},e.slug),ie;ie=n===`new`?(0,I.jsx)(Ys,{},`new`):n===`edit`&&t?(0,I.jsx)(Ys,{slug:t},t):n===`chat`&&t&&i===`new`?(0,I.jsx)(Fs,{slug:t},t):n===`chat`&&t&&i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Ko,{id:i,agentName:w.find(e=>e.slug===t)?.name??t,agentDescription:w.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Ko,{id:i},i)}):(0,I.jsx)(Is,{}):n===`info`&&t?(0,I.jsx)(qs,{slug:t},t):t?(0,I.jsx)(Fs,{slug:t},t):a?T.length?(0,I.jsx)(Bs,{agents:T}):(0,I.jsx)(Vs,{}):(0,I.jsx)(Y,{children:`loading…`});let ae=(n===`agent`||n===`info`||n===`chat`)&&t?w.find(e=>e.slug===t)?.knowledge??[]:[],[oe,se]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[ce,le]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),ue=ae.length>0&&oe;function de(e){se(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function B(e){le(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,I.jsxs)(`div`,{className:`runs-screen agents-screen ${t?`in-agent`:``} ${ue?`has-knowledge`:``}`,style:ue?{"--kside-w":`${ce}px`}:void 0,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`agents`,action:o&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[(0,I.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,I.jsx)(mt,{href:`/agents/chats`,active:n===`chats`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,sub:`chief of staff of the workspace`})}),(0,I.jsxs)(`div`,{className:P(`rounded-xl`,_&&b===``&&Zs),...z(``),children:[ee.map(ne),_!=null&&ee.length===0&&(0,I.jsx)(`div`,{className:Qs,children:`no group — drop here`})]}),k.map(e=>{let t=T.filter(t=>t.group===e);return(0,I.jsxs)(`div`,{className:P(`group/grp mt-3 rounded-xl`,_&&b===e&&Zs),...z(e),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[p===e?(0,I.jsx)(Z,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:h,onChange:e=>g(e.target.value),onKeyDown:t=>{t.key===`Enter`&&F(e,h),t.key===`Escape`&&m(null)},onBlur:()=>F(e,h)}):(0,I.jsx)(nt,{children:e}),(0,I.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-2`,children:t.length}),(0,I.jsx)(`span`,{className:`flex-1`}),o&&p!==e&&(0,I.jsx)(K,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{m(e),g(e)}}),o&&t.length===0&&s.includes(e)&&(0,I.jsx)(K,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>j(s.filter(t=>t!==e))})]}),t.map(ne),t.length===0&&(0,I.jsx)(`div`,{className:Qs,children:o?`drag agents here`:`no agents`})]},e)}),E.length>0&&(0,I.jsxs)(`div`,{className:`mt-2.5 border-t border-line pt-1`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`group/arch flex w-full cursor-pointer items-center gap-1.5 border-0 bg-transparent px-2.5 pt-1.5 pb-0.5 text-left text-fg-2`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,I.jsx)(nt,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,I.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:E.length}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(R,{name:D?`expand_less`:`expand_more`,className:`ms-sm`})]}),D&&E.map(re)]}),a&&w.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-2.5`,children:`no agents yet`}),o&&(l?(0,I.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,I.jsx)(Z,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:d,placeholder:`group name, e.g. Team Content`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(),e.key===`Escape`&&(u(!1),f(``))},onBlur:M})}):(0,I.jsxs)(`button`,{type:`button`,className:`mx-2.5 mt-3 mb-1 flex cursor-pointer items-center gap-1 rounded-lg border border-dashed border-line bg-transparent px-2.5 py-1 text-2xs text-fg-2 hover:text-accent`,onClick:()=>u(!0),children:[(0,I.jsx)(R,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:ie}),ue&&(0,I.jsx)(Ms,{bundles:ae,onHide:()=>de(!1),onResize:B}),ae.length>0&&!oe&&(0,I.jsxs)(`button`,{type:`button`,className:`kside-reopen fixed top-[60px] right-3.5 z-5 inline-flex cursor-pointer items-center gap-1 rounded-full border border-line bg-surface-2 px-3 py-1 text-2xs text-fg-2 hover:text-fg`,onClick:()=>de(!0),title:`Show knowledge sidebar`,children:[(0,I.jsx)(R,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function ec(e){if(!fe(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,I.jsx)(fs,{},`new-project`):r?(0,I.jsx)(Ys,{},`new-agent`):(0,I.jsx)(Ua,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,I.jsx)(_s,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,I.jsx)(qs,{slug:n},n):r&&t[2]===`edit`?(0,I.jsx)(Ys,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,I.jsx)(Ua,{slug:n},n):null}function tc({back:e,children:t}){let n=()=>H(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,I.jsx)(`div`,{className:`fixed inset-0 z-40 flex animate-fade items-start justify-center bg-black/38 px-4 pt-[6vh] pb-4 max-[800px]:p-0`,onMouseDown:n,children:(0,I.jsxs)(`div`,{className:`edit-modal relative max-h-[88dvh] w-[min(960px,100%)] animate-modal overflow-y-auto rounded-card border border-line bg-surface shadow-modal max-[800px]:max-h-dvh max-[800px]:rounded-none`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,I.jsx)(K,{icon:`close`,label:`close (esc)`,className:`absolute top-3 right-3 z-1 rounded-full`,onClick:n}),(0,I.jsx)(`div`,{className:`runs-main min-w-0 pt-[18px] pr-12 pb-10 pl-6`,children:t})]})})}function nc({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,I.jsx)(`section`,{className:P(rc,`decision-panel is-decided`),"aria-label":`decision`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,I.jsx)(`div`,{className:ic,children:n.title??`Decision`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-base`,children:[(0,I.jsx)(q,{tone:`ok`,children:f(r.decision)}),r.note&&(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,I.jsx)(`span`,{className:`text-xs tabular-nums text-fg-2`,children:Ge(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await A.request(`runs.decide`,{id:e,body:{decision:i,note:o.trim()}}).catch(()=>null);t?.ok||(d(t?.error??`could not save the decision`),l(!1))}return(0,I.jsx)(`section`,{className:P(rc,`decision-panel`),"aria-label":`decision needed`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)($e,{tone:`working`}),(0,I.jsx)(`div`,{className:ic,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,I.jsx)(`p`,{className:`m-0 max-w-[80ch] text-base text-fg-2`,children:n.prompt}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2 self-start`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,I.jsx)(G,{role:`radio`,"aria-checked":i===e.value,variant:i===e.value?`primary`:`secondary`,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,I.jsx)(Z,{value:o,placeholder:n.note===`required`?`Note (required)`:`Note`,"aria-label":`note`,className:`max-w-[60ch]`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),u&&(0,I.jsx)(tt,{tone:`bad`,children:u}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(G,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var rc=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,ic=`text-[16px] font-medium text-fg`;function ac(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function oc({status:e}){return(0,I.jsx)(`span`,{"data-ui":`status`,"data-status":e,className:`inline-flex`,children:(0,I.jsx)(q,{tone:e===`ok`?`ok`:e===`failed`||e===`blocked`?`bad`:e===`running`?`accent`:`neutral`,children:e})})}function sc(){return(0,I.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,I.jsx)(q,{tone:`accent`,children:`decision needed`})})}function cc({label:e,children:t,className:n}){return(0,I.jsxs)(`div`,{className:n,children:[(0,I.jsx)(nt,{className:`mb-px block`,children:e}),(0,I.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var lc=`mb-[22px] flex flex-wrap gap-[26px]`;function uc({id:e,workflow:t}){let n=N(`runs.list`,{},{fast:!0}),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,I.jsx)(Dt,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{label:`runs list`,children:[o.map(t=>(0,I.jsx)(dc,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,I.jsx)(kt,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,I.jsxs)(kt,{children:[`no run matches “`,i,`”`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:(0,I.jsx)(fc,{id:e},e)})]})}function dc({r:e,active:t}){return(0,I.jsx)(mt,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),title:e.workflow??`unknown`,meta:Ge(e.startedAt),sub:(0,I.jsxs)(`span`,{className:`flex gap-2`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,I.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)})]})})}function fc({id:e}){let t=N(`runs.get`,{id:e},{fast:!0}),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=be();if(!t)return(0,I.jsx)(Y,{children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!yc(e.name)).length;async function p(){o(!0),c(null);let t=await A.request(`runs.stop`,{id:e}).catch(()=>null);t?.ok||(o(!1),c(t?.error??`stop failed`))}async function m(){if(!window.confirm(`Move run ${e} to the trash?`))return;c(null);let n=await A.request(`runs.delete`,{id:e}).catch(()=>null);n?.ok?H(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`):c(n?.error??`remove failed`)}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5`,children:[(0,I.jsx)($e,{tone:ac(t.status),title:t.status}),(0,I.jsx)(it,{size:`lg`,children:t.workflow?(0,I.jsx)(U,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,className:`text-inherit no-underline hover:text-accent`,children:t.workflow}):`unknown workflow`}),(0,I.jsx)(oc,{status:t.status}),u&&(0,I.jsxs)(q,{children:[(0,I.jsx)(R,{name:`science`,className:`ms-sm mr-1`}),` sandbox`]}),(0,I.jsx)(`span`,{className:`font-mono text-xs text-fg-2`,children:e.replace(/^run-/,``)}),n?(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:m,title:`delete this run's folder`,children:`remove`}),s&&(0,I.jsx)(`span`,{className:`text-xs text-bad`,children:s}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Yo(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,I.jsx)(ht,{className:`border-b-0 px-0`,label:`run sections`,value:d,onChange:i,items:[{id:`run`,label:`run`},{id:`artifacts`,label:`artifacts`,count:f}]})]}),t.request&&(0,I.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:t.request}),d===`run`?(0,I.jsx)(pc,{run:t,live:n}):(0,I.jsx)(xc,{id:e,files:t.files,live:n})]})}function pc({run:e,live:t}){return(0,I.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,I.jsx)(nc,{runId:e.id,decision:e.decision}),(0,I.jsxs)(`div`,{className:lc,children:[(0,I.jsxs)(cc,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,I.jsx)(cc,{label:`duration`,children:t?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),(0,I.jsx)(cc,{label:`cost`,children:He(e.costUsd??hc(e.phases))}),(0,I.jsxs)(cc,{label:`tokens in / out`,children:[Ue(mc(e.phases,`tokensIn`)),` / `,Ue(mc(e.phases,`tokensOut`))]})]}),(0,I.jsx)(X,{title:`phase timeline`,actions:t&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-[7px] text-2xs text-fg-2`,children:[(0,I.jsx)($e,{tone:`working`}),` live · polling`]}),children:(0,I.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,I.jsx)(_c,{p:e},e.phase))})})]})}function mc(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function hc(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var gc=`relative border-line/55 [&+&]:border-t before:absolute before:top-0 before:bottom-0 before:w-px before:bg-line last:before:bottom-auto`;function _c({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,I.jsxs)(`div`,{className:P(gc,`py-2.5 pr-[18px] pl-[42px] before:left-[23px] first:before:top-4 last:before:h-4`),children:[(0,I.jsx)(`span`,{className:`absolute top-4 left-[19px] z-1 grid`,children:(0,I.jsx)($e,{tone:ac(e.status),title:e.status})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.phase}),e.kind===`agent`?(0,I.jsxs)(q,{tone:`accent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,I.jsx)(q,{children:`script`}),e.status===`skipped`&&(0,I.jsx)(oc,{status:`skipped`}),(0,I.jsxs)(`span`,{className:`ml-auto flex gap-3.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[e.attempts>1&&(0,I.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):e.durationMs!=null&&(0,I.jsx)(`span`,{children:Ve(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,I.jsxs)(`span`,{children:[Ue(e.tokensIn),` / `,Ue(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:He(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,I.jsxs)(`div`,{className:`mt-[3px] font-mono text-[11.5px] text-accent`,children:[`▸ `,e.lastActivity]}),e.summary&&e.status!==`running`&&(0,I.jsx)(`div`,{className:`mt-[3px] max-w-[72ch] text-[12.5px] text-fg-2`,children:e.summary}),e.gates.length>0&&(0,I.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-[5px] rounded-lg px-2.5 py-0.5 font-mono text-2xs`,e.passed?`bg-ok-soft text-ok`:`bg-bad-soft text-on-bad-soft`),title:e.failure??``,children:[(0,I.jsx)(R,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,I.jsx)(`div`,{className:`mt-1 text-xs text-bad`,children:e.failure},e.gate))]})}var vc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function yc(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function bc(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||vc.has(t)?0:yc(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function xc({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=be(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!yc(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&yc(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(bc(o))},[o,r]),(0,I.jsxs)(`div`,{className:`grid h-[calc(100vh-172px)] min-h-[420px] grid-cols-[280px_minmax(0,1fr)] gap-3.5 max-[940px]:h-auto max-[940px]:grid-cols-1`,children:[(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`files `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,o.length,`)`]})]}),className:`flex min-h-0 flex-col`,children:(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto max-[940px]:max-h-60`,children:[o.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:P(`flex w-full cursor-pointer items-center gap-2.5 border-0 border-b border-line/55 px-[18px] py-2 text-left font-mono text-[12.5px] transition-colors last:border-b-0`,r===e.name?`bg-accent-soft text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),onClick:()=>i(e.name),children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,I.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:We(e.size)})]},e.name)),o.length===0&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})}),(0,I.jsx)(X,{title:r??`viewer`,className:`flex min-h-0 flex-col`,actions:r&&(0,I.jsx)(`a`,{className:Sc,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,I.jsx)(Dc,{id:e,name:r,live:n}):(0,I.jsx)(Y,{className:`flex-1 justify-center`,children:`select a file`})})]})}var Sc=`inline-flex h-7 items-center rounded-control px-2.5 text-sm font-medium text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-fg`,Cc=`flex min-h-0 flex-1 flex-col`,wc=`min-h-0 flex-1`,Tc=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Ec=`block h-full min-h-[560px] w-full border-0 bg-white`;function Dc({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=A.url(`runs.file`,{id:e,query:{name:t,raw:!0}});return r===`html`?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`iframe`,{className:Ec,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`iframe`,{className:Ec,src:i,title:t})})}):vc.has(r)?(0,I.jsx)(`div`,{className:Cc,children:(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`img`,{className:`block max-h-full max-w-full object-contain px-[18px] py-3.5`,src:i,alt:t})})}):r===`md`||r===`markdown`?(0,I.jsx)(kc,{id:e,name:t,live:n}):(0,I.jsx)(Ac,{id:e,name:t,live:n})}var Oc=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function kc({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=N(`runs.fileText`,{id:e,query:{name:t}},{fast:n}),o=(0,v.useMemo)(()=>a?Da.sanitize(Jr.parse(a.content,{async:!1})):``,[a?.content]);return(0,I.jsxs)(`div`,{className:Cc,children:[(0,I.jsxs)(`div`,{className:Oc,children:[(0,I.jsx)(ht,{className:`border-b-0 px-0`,label:`markdown view`,value:r,onChange:i,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),a?.truncated&&(0,I.jsxs)(`span`,{children:[`large file — showing the last `,We(4e5)]})]}),(0,I.jsx)(`div`,{className:P(wc,`overflow-auto`),children:a?r===`rendered`?(0,I.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,I.jsx)(`pre`,{className:Tc,children:a.content||`(empty)`}):(0,I.jsx)(`pre`,{className:Tc,children:`loading…`})})]})}function Ac({id:e,name:t,live:n}){let r=N(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,I.jsxs)(`div`,{className:Cc,children:[r?.truncated&&(0,I.jsxs)(`div`,{className:Oc,children:[`large file — showing the last `,We(4e5)]}),(0,I.jsx)(`div`,{className:wc,children:(0,I.jsx)(`pre`,{className:Tc,children:r?r.content||`(empty)`:`loading…`})})]})}function jc(){return N(`workflows.runner`,{slug:`any`},{interval:15e3})}var Mc=e=>!!e?.available&&!!e?.image;function Nc(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function Pc(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function Fc(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=jc();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]);let h=!u&&(!t||!!i.trim())&&(!o||Mc(m));async function g(){if(h){d(!0),p(null);try{let t=await Pc(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):H(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function Ic({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=Fc(e,t,n,r);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 px-5 pt-4 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-4 max-[700px]:flex-wrap`,children:[t?(0,I.jsx)(Z,{className:`h-11 min-w-0 flex-1 text-md`,value:i.request,placeholder:`Request`,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}):(0,I.jsx)(`span`,{className:`flex-1 text-base text-fg-2`,children:`This workflow takes no request.`}),(0,I.jsx)(G,{variant:`primary`,icon:`play_arrow`,className:`h-11 px-5 max-[700px]:w-full`,busy:i.busy,onClick:i.launch,disabled:!i.canRun,children:i.busy?`Starting…`:`Run`})]}),(0,I.jsxs)(`div`,{className:`-mx-2 mt-1 flex flex-wrap gap-x-2`,children:[(0,I.jsx)(Tt,{label:`Docker sandbox`,hint:Nc(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,I.jsx)(Tt,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,I.jsx)(tt,{tone:`bad`,children:i.error})]})}var Lc=`\0done`,Rc=5;function zc(e,t){return e.status===`ok`?Lc:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Lc}var Bc=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function Vc(e){return e==null?`var(--text-2)`:Bc[e%Bc.length]}function Hc({colour:e,children:t,small:n}){return(0,I.jsx)(`span`,{style:{"--aid":e},className:P(`relative z-1 grid flex-none place-items-center rounded-full border font-mono font-bold tabular-nums`,`border-[color-mix(in_srgb,var(--aid)_55%,var(--line))] bg-[color-mix(in_srgb,var(--aid)_18%,var(--surface-1))] text-[var(--aid)]`,n?`size-[22px] text-2xs`:`mt-px size-[26px] text-[11.5px]`),children:t})}function Uc({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Lc].map(e=>[e,[]]));for(let e of t)a.get(zc(e,i)).push(e);let o=a.get(Lc)??[];return(0,I.jsxs)(`div`,{className:`board flex items-start gap-3 overflow-x-auto px-[18px] pt-3.5 pb-[18px]`,children:[e.steps.map((e,t)=>{let i=a.get(e.name)??[];return(0,I.jsx)(Wc,{step:e.name,index:(0,I.jsx)(Hc,{small:!0,colour:Vc(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,I.jsx)(Gc,{cards:i,moreHref:r})},e.name)}),(0,I.jsx)(Wc,{step:`done`,name:`done`,done:!0,index:(0,I.jsx)(Hc,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,I.jsx)(Gc,{cards:o,moreHref:r})})]})}function Wc({step:e,name:t,done:n,index:r,count:i,children:a}){return(0,I.jsxs)(`div`,{className:P(`board-col flex min-w-60 flex-[0_0_240px] flex-col gap-1.5`,n&&`is-done`),"data-step":e,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-0.5 pt-0.5 pb-1`,children:[r,(0,I.jsx)(`span`,{className:`board-col-name min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t??e,children:t??e}),(0,I.jsx)(`span`,{className:`board-col-count ml-auto font-mono text-[11.5px] tabular-nums text-fg-2`,children:i})]}),a]})}function Gc({cards:e,moreHref:t}){return(0,I.jsxs)(`div`,{className:`flex min-h-14 flex-col gap-2 rounded-xl bg-surface-2/60 p-2`,children:[e.slice(0,Rc).map(e=>(0,I.jsx)(Kc,{r:e},e.id)),e.length===0&&(0,I.jsx)(`div`,{className:`board-col-empty py-3.5 text-center text-xs text-fg-2`,children:`—`}),e.length>Rc&&(0,I.jsxs)(U,{href:t,className:`board-more block p-1.5 text-center text-xs text-fg-2 no-underline hover:text-accent`,children:[`+ `,e.length-Rc,` more ↗`]})]})}function Kc({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,I.jsxs)(U,{href:`/runs/${e.id}`,className:`board-card block rounded-xl border border-line bg-surface px-3 py-2.5 text-inherit no-underline transition-colors hover:bg-surface-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] font-medium text-fg`,title:t,children:t})]}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-2.5 font-mono text-[11.5px] tabular-nums text-fg-2`,children:[(0,I.jsx)(`span`,{children:Ge(e.startedAt)}),(0,I.jsx)(`span`,{children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:He(e.costUsd)})]}),(e.awaitingDecision||e.status===`failed`||e.status===`aborted`)&&(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[e.awaitingDecision&&(0,I.jsx)(sc,{}),(e.status===`failed`||e.status===`aborted`)&&(0,I.jsx)(oc,{status:e.status})]})]})}function qc({slug:e,tab:t}){let n=N(`workflows.get`,{slug:e}),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=N(`runs.list`,{},{fast:a>0||Date.now()-r<2e4});if(!n)return(0,I.jsx)(Y,{children:`loading…`});if(n.error)return(0,I.jsxs)(Y,{children:[(0,I.jsx)(q,{tone:`bad`,children:`broken workflow`}),(0,I.jsx)(`pre`,{className:`mt-3 text-left`,children:n.error}),(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(Yc,{slug:n.slug})})]});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-2.5 in-[.ctx-embed]:mb-3 in-[.ctx-embed]:gap-y-2`,children:[(0,I.jsx)(it,{size:`lg`,className:`in-[.ctx-embed]:text-xl`,children:n.name??n.slug}),(0,I.jsx)(`span`,{className:`min-w-0 font-mono text-xs [overflow-wrap:anywhere] text-fg-2 in-[.ctx-embed]:hidden`,children:n.dir}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(ht,{bare:!0,label:`workflow sections`,value:t,items:[{id:`overview`,href:u,label:`overview`},{id:`details`,href:`${u}/details`,label:`details`},{id:`runs`,href:`${u}/runs`,label:(0,I.jsxs)(I.Fragment,{children:[`runs `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,`)`]})]})}]})]}),n.description&&(0,I.jsx)(`p`,{className:`mb-5 max-w-[90ch] text-base text-fg-2`,children:n.description}),t===`overview`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{className:`run-panel mb-[18px]`,children:(0,I.jsx)(Ic,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`board`,` `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),actions:l[0]&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,I.jsx)(Uc,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,I.jsx)(Jc,{wf:n,agentIdx:c}),t===`runs`&&(0,I.jsx)(Xc,{runs:l})]})}function Jc({wf:e,agentIdx:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:lc,children:[(0,I.jsx)(cc,{label:`agents`,children:e.agents.length}),(0,I.jsxs)(cc,{label:`steps`,children:[e.steps.length,` `,(0,I.jsxs)(`span`,{className:`font-normal text-fg-2`,children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent · `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]}),e.workspace&&(0,I.jsx)(cc,{label:`workspace`,className:`max-w-[420px]`,children:(0,I.jsx)(`span`,{className:`text-[11.5px] font-normal whitespace-pre-wrap text-fg-2`,children:e.workspace})})]}),(0,I.jsx)(X,{title:`agents`,className:`mb-[18px]`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(280px,1fr))]`,children:[e.agents.map(e=>(0,I.jsx)(Qc,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`no agents — script-only workflow`})]})}),(0,I.jsxs)(`div`,{className:`grid items-start gap-[18px] grid-cols-[minmax(430px,5fr)_minmax(360px,4fr)] max-[1100px]:grid-cols-1 in-[.ctx-embed]:grid-cols-1`,children:[(0,I.jsx)(X,{title:`pipeline`,children:(0,I.jsx)(`div`,{className:`pipeline py-2`,children:e.steps.map((e,n)=>(0,I.jsx)($c,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})}),(0,I.jsx)(X,{title:(0,I.jsxs)(I.Fragment,{children:[`folder `,(0,I.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,e.files.length,` files)`]})]}),children:(0,I.jsx)(`div`,{className:`max-h-[300px] overflow-auto`,children:e.files.map(e=>(0,I.jsx)(`div`,{className:`truncate border-b border-line/55 px-[18px] py-2 font-mono text-[12.5px] text-fg-2 last:border-b-0`,children:e},e))})})]}),(0,I.jsx)(`div`,{className:`mt-[18px] in-[.ctx-embed]:hidden`,children:(0,I.jsx)(Yc,{slug:e.slug})})]})}function Yc({slug:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async()=>{i(!0),o(``);try{let t=await A.request(`workflows.delete`,{slug:e});if(!t.ok)throw Error(t.error||`failed`);H(`/workflows`,{replace:!0})}catch(e){o(e.message),n(!1)}finally{i(!1)}};return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,I.jsx)(J,{children:`its runs stay; the trash can put it back`})]}):(0,I.jsx)(G,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,I.jsx)(tt,{tone:`bad`,children:a})]})}function Xc({runs:e}){return e.length===0?(0,I.jsx)(Y,{children:`no runs of this workflow yet`}):(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,I.jsxs)(U,{href:`/runs/${e.id}`,className:`run-card grid grid-cols-[12px_200px_1fr_auto] items-center gap-x-4 gap-y-2 rounded-card border border-line bg-surface px-5 py-3.5 text-inherit no-underline transition-colors hover:bg-surface-2 max-[900px]:grid-cols-[12px_1fr]`,children:[(0,I.jsx)($e,{tone:ac(e.status),title:e.status}),(0,I.jsx)(`span`,{className:`font-mono text-[12.5px] text-fg-2`,children:e.id.replace(/^run-/,``)}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-fg`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,I.jsxs)(`span`,{className:`flex items-center gap-3.5 font-mono text-xs tabular-nums text-fg-2 max-[900px]:col-span-2`,children:[e.awaitingDecision&&(0,I.jsx)(sc,{}),(0,I.jsx)(oc,{status:e.status}),(0,I.jsx)(`span`,{className:`h-1 w-[90px] overflow-hidden rounded-full bg-surface-2`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,I.jsx)(`i`,{className:P(`block h-full rounded-full`,e.status===`ok`?`bg-ok`:e.status===`failed`?`bg-bad`:`bg-accent`),style:{width:`${n}%`}})}),(0,I.jsx)(`span`,{children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Ve(e.durationMs)}),(0,I.jsx)(`span`,{children:He(e.costUsd)}),(0,I.jsx)(`span`,{children:Ge(e.startedAt)})]})]},e.id)})})}var Zc=`border-line/55`;function Qc({a:e,idx:t}){return(0,I.jsxs)(`div`,{className:P(`agent-card border-r border-b px-[18px] py-3.5`,Zc),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`size-2.5 rounded-full`,style:{background:Vc(t)}}),(0,I.jsx)(`b`,{className:`text-base font-medium text-fg`,children:e.name??e.id}),(0,I.jsxs)(`code`,{className:`text-2xs text-fg-2`,children:[`[`,e.id,`]`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(q,{children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,I.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-[5px]`,children:e.tools.map(e=>(0,I.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-px font-mono text-2xs text-fg-2`,children:e},e))}),e.persona&&(0,I.jsx)(`p`,{className:`mt-2 mb-0 text-xs leading-[1.55] whitespace-pre-wrap text-fg-2`,children:e.persona})]})}function $c({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,I.jsxs)(`div`,{className:P(`step-node flex gap-3.5 px-[18px] py-3 first:before:top-[18px] last:before:h-[18px] before:left-[31px]`,gc),children:[(0,I.jsx)(Hc,{colour:Vc(n),children:t+1}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-base font-medium text-fg`,children:e.name}),e.kind===`agent`?(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded-full border px-2 text-2xs font-semibold`,style:{color:Vc(n??0),borderColor:`color-mix(in srgb, ${Vc(n??0)} 50%, var(--line))`},children:[`agent · `,e.agent]}):(0,I.jsxs)(q,{children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,I.jsxs)(`details`,{className:`mt-1.5`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-2 select-none hover:text-accent`,children:e.kind===`agent`?`prompt`:`script`}),(0,I.jsx)(`pre`,{className:`mt-1.5 max-h-[360px] overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 text-[11.5px] leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:r})]}),e.gates.length>0&&(0,I.jsx)(`div`,{className:`mt-[5px] flex flex-wrap gap-1.5`,children:e.gates.map(e=>(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] rounded-lg bg-surface-2 px-2.5 py-0.5 font-mono text-2xs text-fg-2`,children:[`⛨ `,e]},e))})]})]})}function el(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function tl(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function nl({slug:e,tab:t}){let n=N(`workflows.list`,{}),r=N(`runs.list`,{}),[i,a]=(0,v.useState)(``),o=(0,v.useMemo)(()=>n?.workflows??[],[n]),s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:el(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&H(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,I.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`workflows`,count:n?o.length:void 0,action:(0,I.jsxs)(G,{size:`sm`,variant:`quiet`,icon:`history`,href:`/runs`,title:`every run of every workflow, newest first`,children:[`runs `,(0,I.jsx)(`span`,{className:`tabular-nums`,children:s.length})]})}),o.length>0&&(0,I.jsx)(Dt,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{children:[c.map(t=>{let n=el(s,t);return(0,I.jsx)(mt,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,I.jsx)($e,{tone:ac(n.last?.status),title:n.last?.status??`no runs yet`}),title:t.name??t.slug,titleExtra:t.error&&(0,I.jsx)(q,{tone:`bad`,children:`broken`}),meta:n.last&&W(n.last.updatedAt),sub:(0,I.jsx)(`span`,{title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),subTone:t.error?`bad`:`plain`,actionsAlways:!0,actions:n.last?(0,I.jsxs)(`button`,{type:`button`,className:`wf-runs inline-flex cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent px-1.5 py-0.5 text-2xs tabular-nums text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg`,title:`show the runs of this workflow`,onClick:()=>H(tl(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,I.jsx)(oc,{status:n.last.status})]}):(0,I.jsx)(`span`,{className:`wf-runs px-1.5 text-2xs text-fg-2 opacity-80`,children:`no runs yet`})},t.slug)}),n&&o.length>0&&c.length===0&&(0,I.jsxs)(kt,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,I.jsx)(kt,{children:`no workflows yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(qc,{slug:e,tab:t},e):n&&o.length===0?(0,I.jsxs)(Y,{icon:`account_tree`,children:[`No workflows found — expected `,(0,I.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,I.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,I.jsx)(Y,{children:`loading…`})})]})}var rl=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,il=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function al(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function ol(e,t,n){switch(e.scope.kind){case`agent`:{let r=e.scope.slug,i=t.find(e=>e.slug===r),a=i?`${i.emoji||`🤖`} ${i.name}`:r;return e.project?`📁 ${n(e.project)} · ${a}`:a}case`project`:return`📁 ${n(e.scope.slug)}`;case`channel`:return e.project?`📁 ${n(e.project)} · #${e.scope.slug}`:`#${e.scope.slug}`;case`run`:return`⚙️ run ${e.scope.runId}`;case`knowledge`:return e.scope.bundle?`📚 ${e.scope.bundle}`:`📚 knowledge`;default:return`🎩 Ralv`}}function sl(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function cl(){let e=N(`runs.list`,{}),t=N(`chats.list`,{}),n=N(`knowledge.list`,{}),r=N(`agents.list`,{}),i=N(`workflows.list`,{}),a=N(`skills.list`,{}),[o,s]=(0,v.useState)(`all`),c=be(),l=N(`projects.list`,{},{interval:3e4}),u=e=>l?.projects.find(t=>t.slug===e)?.title??e,d=e?.runs??[],f=t?.chats??[],p=n?.bundles??[],m=(a?.skills??[]).filter(e=>e.source===`workspace`),h=[[i?.workflows.length,`workflows`,`/workflows`],[e?d.length:void 0,`runs`,`/runs`],[n?p.length:void 0,`bundles`,`/knowledge`],[a?m.length:void 0,`skills`,`/skills`],[t?f.length:void 0,`chats`,`/agents/chats`]],g=d.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,I.jsxs)(`div`,{className:`w-full px-7 pt-6 pb-10 max-[800px]:px-3 max-[800px]:pt-3`,children:[(0,I.jsx)(gl,{runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],projectTitle:u,loaded:!!e&&!!t}),c&&(0,I.jsx)(`div`,{className:`mx-0.5 mt-3.5 mb-3 flex flex-wrap justify-end gap-x-[18px] gap-y-1 text-xs text-fg-2 max-[800px]:justify-start max-[800px]:gap-x-3.5`,children:h.map(([e,t,n])=>(0,I.jsxs)(U,{href:n,className:`group/mini text-inherit no-underline hover:text-accent hover:underline`,children:[(0,I.jsx)(`b`,{className:`font-semibold tabular-nums text-fg group-hover/mini:text-accent`,children:e??`…`}),` `,t]},t))}),c&&g.length>0&&o!==`failed`&&(0,I.jsxs)(`button`,{type:`button`,className:`mb-3.5 flex w-full cursor-pointer items-center gap-2 rounded-xl border border-bad/40 bg-bad-soft px-3.5 py-[9px] text-left text-[12.5px] text-on-bad-soft hover:brightness-104`,onClick:()=>s(`failed`),children:[`⚠ `,g.length,` run`,g.length===1?``:`s`,` failed in the last 24 h — review`]}),c&&(0,I.jsx)(dl,{projectTitle:u,runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function ll(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var ul=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function dl({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=be(),l=(0,v.useMemo)(()=>{let s=[],l=e=>e?a.find(t=>t.slug===e)?.name??e:void 0;for(let e of t)s.push({at:e.updatedAt,kind:`run`,emoji:`⚙️`,title:l(e.workflow)??e.id,sub:e.request??``,href:`/runs/${e.id}`,lamp:rl(e.status),status:il(e.status)});for(let t of n){let n=t.scope.kind===`agent`?i.find(e=>t.scope.kind===`agent`&&e.slug===t.scope.slug):void 0;s.push({at:t.updatedAt,kind:`session`,emoji:n?n.emoji||`🤖`:`💬`,title:n?n.name:t.title||`new chat`,sub:n?`${t.title||`new chat`}${c?` · ${t.agent}`:``}`:c?`${t.agent} · ${ol(t,i,e)}`:ol(t,i,e),href:al(t),lamp:t.awaitingApproval?`blocked`:t.busy?`running`:`ok`,status:t.awaitingApproval?`needs approval`:t.busy?`working`:void 0})}for(let e of r)e.updatedAt&&s.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(o===`all`?s:o===`failed`?s.filter(e=>e.kind===`run`&&e.lamp===`failed`):s.filter(e=>e.kind===o)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[t,n,r,i,c,o]),u=``,d=(e,t)=>P(`inline-flex cursor-pointer items-center gap-0.5 rounded-lg border px-2.5 py-0.5 text-2xs transition-colors`,e?P(`border-transparent`,t?`bg-bad-soft text-on-bad-soft`:`bg-accent-soft text-on-accent-soft`):`border-line bg-transparent text-fg-2 hover:text-fg`);return(0,I.jsx)(X,{className:`animate-rise`,title:`all activity`,actions:(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1.5`,children:[ul.map(([e,t])=>(0,I.jsx)(`button`,{type:`button`,className:d(o===e),"aria-pressed":o===e,onClick:()=>s(e),children:t},e)),o===`failed`&&(0,I.jsxs)(`button`,{type:`button`,className:d(!0,!0),onClick:()=>s(`all`),children:[`failed `,(0,I.jsx)(R,{name:`close`,className:`ms-sm`})]})]}),children:l.length===0?(0,I.jsx)(`div`,{className:`px-[18px] py-4 text-sm text-fg-2`,children:o===`all`?`nothing yet — run a workflow or start a chat`:`nothing here for this filter`}):(0,I.jsx)(`div`,{className:`flex flex-col p-1.5`,children:l.map(e=>{let t=ll(e),n=t===u?null:t;return u=t,(0,I.jsxs)(`div`,{children:[n&&(0,I.jsx)(nt,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,I.jsx)(mt,{href:e.href,leading:(0,I.jsxs)(`span`,{className:`relative text-[18px] leading-none`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,I.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid rounded-full bg-surface p-px`,children:(0,I.jsx)($e,{tone:`working`})})]}),title:sl(e.title),titleExtra:(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsx)(q,{tone:fl[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&sl(e.sub),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,I.jsx)(q,{tone:pl[e.lamp]??`neutral`,children:e.status}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:W(e.at)}),(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var fl={run:`accent`,session:`ask`,knowledge:`ok`},pl={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function ml(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return t<1?`just started`:t<60?`${t} min`:`${Math.floor(t/60)} h ${t%60} min`}var hl=e=>new Date(e).toDateString()===new Date().toDateString();function gl({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=Lt()??[],c=z(),l=N(`agents.status`,{},{interval:5e3}),u=e=>e?i.find(t=>t.slug===e)?.name??e:`workflow`,d=new Map;for(let e of Object.values(l??{}))for(let t of e.working)t.since&&d.set(t.chatId,t.since);let f=[...t.filter(e=>e.busy&&!e.awaitingApproval).map(e=>({key:`c:${e.id}`,owner:ol(e,r,a),title:sl(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${ml(d.get(e.id))}`:``}`,href:al(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:sl(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&hl(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:ol(e,r,a),title:sl(e.title),meta:W(e.updatedAt),href:al(e)})),...e.filter(e=>e.status!==`running`&&hl(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:sl(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${W(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&hl(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:W(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=Wt(s,c),h=o&&s.length===0&&f.length===0;return(0,I.jsxs)(`div`,{className:`today flex flex-col gap-3.5`,children:[(0,I.jsxs)(X,{className:`today-section`,title:`needs you`,count:s.length,actions:m&&(0,I.jsxs)(G,{variant:`primary`,size:`sm`,onClick:()=>Gt(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),children:[s.length===0?(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:h?`Nothing waiting, nothing running.`:`Nothing is waiting for you.`}):(0,I.jsx)(`div`,{className:`p-1.5`,children:s.map(e=>(0,I.jsx)(mt,{className:`today-row waiting`,onClick:()=>Gt(e),over:Vt(e.owner),title:e.title,meta:(0,I.jsxs)(`span`,{className:`font-semibold text-bad`,children:[Bt(e.kind),` · `,W(e.since)]})},e.id))}),h&&(0,I.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,I.jsx)(G,{variant:`primary`,icon:`chat`,href:`/agents/chats`,children:`chat with Ralv`})})]}),f.length>0&&(0,I.jsx)(X,{className:`today-section`,title:`in progress`,children:(0,I.jsx)(`div`,{className:`p-1.5`,children:f.map(e=>(0,I.jsx)(_l,{r:e},e.key))})}),(0,I.jsx)(X,{className:`today-section`,title:`done today`,children:p.length===0?(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-4 text-sm text-fg-2`,children:`Nothing finished yet today.`}):(0,I.jsx)(`div`,{className:`p-1.5`,children:p.map(e=>(0,I.jsx)(_l,{r:e},e.key))})})]})}function _l({r:e}){return(0,I.jsx)(mt,{className:`today-row`,href:e.href,over:e.owner,title:e.title,meta:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.tone===`working`&&(0,I.jsx)($e,{tone:`working`}),e.meta]})})}var vl=l(o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.leaflet={}))})(n,(function(e){var t=`1.9.4`;function n(e){for(var t,n=1,r=arguments.length,i;n<r;n++)for(t in i=arguments[n],i)e[t]=i[t];return e}var r=Object.create||(function(){function e(){}return function(t){return e.prototype=t,new e}})();function i(e,t){var n=Array.prototype.slice;if(e.bind)return e.bind.apply(e,n.call(arguments,1));var r=n.call(arguments,2);return function(){return e.apply(t,r.length?r.concat(n.call(arguments)):arguments)}}var a=0;function o(e){return`_leaflet_id`in e||(e._leaflet_id=++a),e._leaflet_id}function s(e,t,n){var r,i,a,o=function(){r=!1,i&&=(a.apply(n,i),!1)};return a=function(){r?i=arguments:(e.apply(n,arguments),setTimeout(o,t),r=!0)},a}function c(e,t,n){var r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function l(){return!1}function u(e,t){if(t===!1)return e;var n=10**(t===void 0?6:t);return Math.round(e*n)/n}function d(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,``)}function f(e){return d(e).split(/\s+/)}function p(e,t){for(var n in Object.prototype.hasOwnProperty.call(e,`options`)||(e.options=e.options?r(e.options):{}),t)e.options[n]=t[n];return e.options}function m(e,t,n){var r=[];for(var i in e)r.push(encodeURIComponent(n?i.toUpperCase():i)+`=`+encodeURIComponent(e[i]));return(!t||t.indexOf(`?`)===-1?`?`:`&`)+r.join(`&`)}var h=/\{ *([\w_ -]+) *\}/g;function g(e,t){return e.replace(h,function(e,n){var r=t[n];if(r===void 0)throw Error(`No value provided for variable `+e);return typeof r==`function`&&(r=r(t)),r})}var _=Array.isArray||function(e){return Object.prototype.toString.call(e)===`[object Array]`};function v(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var y=`data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=`;function b(e){return window[`webkit`+e]||window[`moz`+e]||window[`ms`+e]}var x=0;function S(e){var t=+new Date,n=Math.max(0,16-(t-x));return x=t+n,window.setTimeout(e,n)}var C=window.requestAnimationFrame||b(`RequestAnimationFrame`)||S,w=window.cancelAnimationFrame||b(`CancelAnimationFrame`)||b(`CancelRequestAnimationFrame`)||function(e){window.clearTimeout(e)};function T(e,t,n){if(n&&C===S)e.call(t);else return C.call(window,i(e,t))}function E(e){e&&w.call(window,e)}var D={__proto__:null,extend:n,create:r,bind:i,get lastId(){return a},stamp:o,throttle:s,wrapNum:c,falseFn:l,formatNum:u,trim:d,splitWords:f,setOptions:p,getParamString:m,template:g,isArray:_,indexOf:v,emptyImageUrl:y,requestFn:C,cancelFn:w,requestAnimFrame:T,cancelAnimFrame:E};function O(){}O.extend=function(e){var t=function(){p(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},i=t.__super__=this.prototype,a=r(i);for(var o in a.constructor=t,t.prototype=a,this)Object.prototype.hasOwnProperty.call(this,o)&&o!==`prototype`&&o!==`__super__`&&(t[o]=this[o]);return e.statics&&n(t,e.statics),e.includes&&(k(e.includes),n.apply(null,[a].concat(e.includes))),n(a,e),delete a.statics,delete a.includes,a.options&&(a.options=i.options?r(i.options):{},n(a.options,e.options)),a._initHooks=[],a.callInitHooks=function(){if(!this._initHooksCalled){i.callInitHooks&&i.callInitHooks.call(this),this._initHooksCalled=!0;for(var e=0,t=a._initHooks.length;e<t;e++)a._initHooks[e].call(this)}},t},O.include=function(e){var t=this.prototype.options;return n(this.prototype,e),e.options&&(this.prototype.options=t,this.mergeOptions(e.options)),this},O.mergeOptions=function(e){return n(this.prototype.options,e),this},O.addInitHook=function(e){var t=Array.prototype.slice.call(arguments,1),n=typeof e==`function`?e:function(){this[e].apply(this,t)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(n),this};function k(e){if(typeof L<`u`&&L&&L.Mixin){e=_(e)?e:[e];for(var t=0;t<e.length;t++)e[t]===L.Mixin.Events&&console.warn(`Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.`,Error().stack)}}var A={on:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n)}return this},off:function(e,t,n){if(!arguments.length)delete this._events;else if(typeof e==`object`)for(var r in e)this._off(r,e[r],t);else{e=f(e);for(var i=arguments.length===1,a=0,o=e.length;a<o;a++)i?this._off(e[a]):this._off(e[a],t,n)}return this},_on:function(e,t,n,r){if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else if(this._listens(e,t,n)===!1){n===this&&(n=void 0);var i={fn:t,ctx:n};r&&(i.once=!0),this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(i)}},_off:function(e,t,n){var r,i,a;if(this._events&&(r=this._events[e],r)){if(arguments.length===1){if(this._firingCount)for(i=0,a=r.length;i<a;i++)r[i].fn=l;delete this._events[e]}else if(typeof t!=`function`)console.warn(`wrong listener type: `+typeof t);else{var o=this._listens(e,t,n);if(o!==!1){var s=r[o];this._firingCount&&(s.fn=l,this._events[e]=r=r.slice()),r.splice(o,1)}}}},fire:function(e,t,r){if(!this.listens(e,r))return this;var i=n({},t,{type:e,target:this,sourceTarget:t&&t.sourceTarget||this});if(this._events){var a=this._events[e];if(a){this._firingCount=this._firingCount+1||1;for(var o=0,s=a.length;o<s;o++){var c=a[o],l=c.fn;c.once&&this.off(e,l,c.ctx),l.call(c.ctx||this,i)}this._firingCount--}}return r&&this._propagateEvent(i),this},listens:function(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);var i=t;typeof t!=`function`&&(r=!!t,i=void 0,n=void 0);var a=this._events&&this._events[e];if(a&&a.length&&this._listens(e,i,n)!==!1)return!0;if(r){for(var o in this._eventParents)if(this._eventParents[o].listens(e,t,n,r))return!0}return!1},_listens:function(e,t,n){if(!this._events)return!1;var r=this._events[e]||[];if(!t)return!!r.length;n===this&&(n=void 0);for(var i=0,a=r.length;i<a;i++)if(r[i].fn===t&&r[i].ctx===n)return i;return!1},once:function(e,t,n){if(typeof e==`object`)for(var r in e)this._on(r,e[r],t,!0);else{e=f(e);for(var i=0,a=e.length;i<a;i++)this._on(e[i],t,n,!0)}return this},addEventParent:function(e){return this._eventParents=this._eventParents||{},this._eventParents[o(e)]=e,this},removeEventParent:function(e){return this._eventParents&&delete this._eventParents[o(e)],this},_propagateEvent:function(e){for(var t in this._eventParents)this._eventParents[t].fire(e.type,n({layer:e.target,propagatedFrom:e.target},e),!0)}};A.addEventListener=A.on,A.removeEventListener=A.clearAllEventListeners=A.off,A.addOneTimeEventListener=A.once,A.fireEvent=A.fire,A.hasEventListeners=A.listens;var ee=O.extend(A);function j(e,t,n){this.x=n?Math.round(e):e,this.y=n?Math.round(t):t}var M=Math.trunc||function(e){return e>0?Math.floor(e):Math.ceil(e)};j.prototype={clone:function(){return new j(this.x,this.y)},add:function(e){return this.clone()._add(N(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(N(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},scaleBy:function(e){return new j(this.x*e.x,this.y*e.y)},unscaleBy:function(e){return new j(this.x/e.x,this.y/e.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=M(this.x),this.y=M(this.y),this},distanceTo:function(e){e=N(e);var t=e.x-this.x,n=e.y-this.y;return Math.sqrt(t*t+n*n)},equals:function(e){return e=N(e),e.x===this.x&&e.y===this.y},contains:function(e){return e=N(e),Math.abs(e.x)<=Math.abs(this.x)&&Math.abs(e.y)<=Math.abs(this.y)},toString:function(){return`Point(`+u(this.x)+`, `+u(this.y)+`)`}};function N(e,t,n){return e instanceof j?e:_(e)?new j(e[0],e[1]):e==null?e:typeof e==`object`&&`x`in e&&`y`in e?new j(e.x,e.y):new j(e,t,n)}function P(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}P.prototype={extend:function(e){var t,n;if(!e)return this;if(e instanceof j||typeof e[0]==`number`||`x`in e)t=n=N(e);else if(e=F(e),t=e.min,n=e.max,!t||!n)return this;return!this.min&&!this.max?(this.min=t.clone(),this.max=n.clone()):(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(n.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(n.y,this.max.y)),this},getCenter:function(e){return N((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)},getBottomLeft:function(){return N(this.min.x,this.max.y)},getTopRight:function(){return N(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(e){var t,n;return e=typeof e[0]==`number`||e instanceof j?N(e):F(e),e instanceof P?(t=e.min,n=e.max):t=n=e,t.x>=this.min.x&&n.x<=this.max.x&&t.y>=this.min.y&&n.y<=this.max.y},intersects:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return a&&o},overlaps:function(e){e=F(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>t.x&&r.x<n.x,o=i.y>t.y&&r.y<n.y;return a&&o},isValid:function(){return!!(this.min&&this.max)},pad:function(e){var t=this.min,n=this.max,r=Math.abs(t.x-n.x)*e,i=Math.abs(t.y-n.y)*e;return F(N(t.x-r,t.y-i),N(n.x+r,n.y+i))},equals:function(e){return e?(e=F(e),this.min.equals(e.getTopLeft())&&this.max.equals(e.getBottomRight())):!1}};function F(e,t){return!e||e instanceof P?e:new P(e,t)}function te(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r<i;r++)this.extend(n[r])}te.prototype={extend:function(e){var t=this._southWest,n=this._northEast,r,i;if(e instanceof R)r=e,i=e;else if(e instanceof te){if(r=e._southWest,i=e._northEast,!r||!i)return this}else return e?this.extend(z(e)||I(e)):this;return!t&&!n?(this._southWest=new R(r.lat,r.lng),this._northEast=new R(i.lat,i.lng)):(t.lat=Math.min(r.lat,t.lat),t.lng=Math.min(r.lng,t.lng),n.lat=Math.max(i.lat,n.lat),n.lng=Math.max(i.lng,n.lng)),this},pad:function(e){var t=this._southWest,n=this._northEast,r=Math.abs(t.lat-n.lat)*e,i=Math.abs(t.lng-n.lng)*e;return new te(new R(t.lat-r,t.lng-i),new R(n.lat+r,n.lng+i))},getCenter:function(){return new R((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new R(this.getNorth(),this.getWest())},getSouthEast:function(){return new R(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(e){e=typeof e[0]==`number`||e instanceof R||`lat`in e?z(e):I(e);var t=this._southWest,n=this._northEast,r,i;return e instanceof te?(r=e.getSouthWest(),i=e.getNorthEast()):r=i=e,r.lat>=t.lat&&i.lat<=n.lat&&r.lng>=t.lng&&i.lng<=n.lng},intersects:function(e){e=I(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return a&&o},overlaps:function(e){e=I(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>t.lat&&r.lat<n.lat,o=i.lng>t.lng&&r.lng<n.lng;return a&&o},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)},equals:function(e,t){return e?(e=I(e),this._southWest.equals(e.getSouthWest(),t)&&this._northEast.equals(e.getNorthEast(),t)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function I(e,t){return e instanceof te?e:new te(e,t)}function R(e,t,n){if(isNaN(e)||isNaN(t))throw Error(`Invalid LatLng object: (`+e+`, `+t+`)`);this.lat=+e,this.lng=+t,n!==void 0&&(this.alt=+n)}R.prototype={equals:function(e,t){return e?(e=z(e),Math.max(Math.abs(this.lat-e.lat),Math.abs(this.lng-e.lng))<=(t===void 0?1e-9:t)):!1},toString:function(e){return`LatLng(`+u(this.lat,e)+`, `+u(this.lng,e)+`)`},distanceTo:function(e){return re.distance(this,z(e))},wrap:function(){return re.wrapLatLng(this)},toBounds:function(e){var t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return I([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])},clone:function(){return new R(this.lat,this.lng,this.alt)}};function z(e,t,n){return e instanceof R?e:_(e)&&typeof e[0]!=`object`?e.length===3?new R(e[0],e[1],e[2]):e.length===2?new R(e[0],e[1]):null:e==null?e:typeof e==`object`&&`lat`in e?new R(e.lat,`lng`in e?e.lng:e.lon,e.alt):t===void 0?null:new R(e,t,n)}var ne={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},unproject:function(e){return this.projection.unproject(e)},scale:function(e){return 256*2**e},zoom:function(e){return Math.log(e/256)/Math.LN2},getProjectedBounds:function(e){if(this.infinite)return null;var t=this.projection.bounds,n=this.scale(e);return new P(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))},infinite:!1,wrapLatLng:function(e){var t=this.wrapLng?c(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?c(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new R(n,t,r)},wrapLatLngBounds:function(e){var t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;var a=e.getSouthWest(),o=e.getNorthEast();return new te(new R(a.lat-r,a.lng-i),new R(o.lat-r,o.lng-i))}},re=n({},ne,{wrapLng:[-180,180],R:6371e3,distance:function(e,t){var n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin((t.lat-e.lat)*n/2),o=Math.sin((t.lng-e.lng)*n/2),s=a*a+Math.cos(r)*Math.cos(i)*o*o,c=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s));return this.R*c}}),ie=6378137,ae={R:ie,MAX_LATITUDE:85.0511287798,project:function(e){var t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new j(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject:function(e){var t=180/Math.PI;return new R((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:(function(){var e=ie*Math.PI;return new P([-e,-e],[e,e])})()};function oe(e,t,n,r){_(e)?(this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3]):(this._a=e,this._b=t,this._c=n,this._d=r)}oe.prototype={transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(e,t){return t||=1,new j((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}};function se(e,t,n,r){return new oe(e,t,n,r)}var ce=n({},re,{code:`EPSG:3857`,projection:ae,transformation:function(){var e=.5/(Math.PI*ae.R);return se(e,.5,-e,.5)}()}),le=n({},ce,{code:`EPSG:900913`});function ue(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}function de(e,t){for(var n=``,r=0,i,a=e.length,o,s,c;r<a;r++){for(s=e[r],i=0,o=s.length;i<o;i++)c=s[i],n+=(i?`L`:`M`)+c.x+` `+c.y;n+=t?W.svg?`z`:`x`:``}return n||`M0 0`}var B=document.documentElement.style,V=`ActiveXObject`in window,fe=V&&!document.addEventListener,H=`msLaunchUri`in navigator&&!(`documentMode`in document),pe=Ge(`webkit`),me=Ge(`android`),he=Ge(`android 2`)||Ge(`android 3`),U=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),ge=me&&Ge(`Google`)&&U<537&&!(`AudioNode`in window),_e=!!window.opera,ve=!H&&Ge(`chrome`),ye=Ge(`gecko`)&&!pe&&!_e&&!V,be=!ve&&Ge(`safari`),xe=Ge(`phantom`),Se=`OTransition`in B,Ce=navigator.platform.indexOf(`Win`)===0,we=V&&`transition`in B,Te=`WebKitCSSMatrix`in window&&`m11`in new window.WebKitCSSMatrix&&!he,Ee=`MozPerspective`in B,De=!window.L_DISABLE_3D&&(we||Te||Ee)&&!Se&&!xe,Oe=typeof orientation<`u`||Ge(`mobile`),ke=Oe&&pe,Ae=Oe&&Te,je=!window.PointerEvent&&window.MSPointerEvent,Me=!!(window.PointerEvent||je),Ne=`ontouchstart`in window||!!window.TouchEvent,Pe=!window.L_NO_TOUCH&&(Ne||Me),Fe=Oe&&_e,Ie=Oe&&ye,Le=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Re=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener(`testPassiveEventSupport`,l,t),window.removeEventListener(`testPassiveEventSupport`,l,t)}catch{}return e}(),ze=function(){return!!document.createElement(`canvas`).getContext}(),Be=!!(document.createElementNS&&ue(`svg`).createSVGRect),Ve=!!Be&&(function(){var e=document.createElement(`div`);return e.innerHTML=`<svg/>`,(e.firstChild&&e.firstChild.namespaceURI)===`http://www.w3.org/2000/svg`})(),He=!Be&&function(){try{var e=document.createElement(`div`);e.innerHTML=`<v:shape adj="1"/>`;var t=e.firstChild;return t.style.behavior=`url(#default#VML)`,t&&typeof t.adj==`object`}catch{return!1}}(),Ue=navigator.platform.indexOf(`Mac`)===0,We=navigator.platform.indexOf(`Linux`)===0;function Ge(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var W={ie:V,ielt9:fe,edge:H,webkit:pe,android:me,android23:he,androidStock:ge,opera:_e,chrome:ve,gecko:ye,safari:be,phantom:xe,opera12:Se,win:Ce,ie3d:we,webkit3d:Te,gecko3d:Ee,any3d:De,mobile:Oe,mobileWebkit:ke,mobileWebkit3d:Ae,msPointer:je,pointer:Me,touch:Pe,touchNative:Ne,mobileOpera:Fe,mobileGecko:Ie,retina:Le,passiveEvents:Re,canvas:ze,svg:Be,vml:He,inlineSvg:Ve,mac:Ue,linux:We},Ke=W.msPointer?`MSPointerDown`:`pointerdown`,qe=W.msPointer?`MSPointerMove`:`pointermove`,Je=W.msPointer?`MSPointerUp`:`pointerup`,Ye=W.msPointer?`MSPointerCancel`:`pointercancel`,Xe={touchstart:Ke,touchmove:qe,touchend:Je,touchcancel:Ye},Ze={touchstart:nt,touchmove:tt,touchend:tt,touchcancel:tt},G={},K=!1;function Qe(e,t,n){return t===`touchstart`&&Y(),Ze[t]?(n=Ze[t].bind(this,n),e.addEventListener(Xe[t],n,!1),n):(console.warn(`wrong event specified:`,t),l)}function $e(e,t,n){Xe[t]?e.removeEventListener(Xe[t],n,!1):console.warn(`wrong event specified:`,t)}function q(e){G[e.pointerId]=e}function et(e){G[e.pointerId]&&(G[e.pointerId]=e)}function J(e){delete G[e.pointerId]}function Y(){K||=(document.addEventListener(Ke,q,!0),document.addEventListener(qe,et,!0),document.addEventListener(Je,J,!0),document.addEventListener(Ye,J,!0),!0)}function tt(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||`mouse`)){for(var n in t.touches=[],G)t.touches.push(G[n]);t.changedTouches=[t],e(t)}}function nt(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&qt(t),tt(e,t)}function rt(e){var t={},n,r;for(r in e)n=e[r],t[r]=n&&n.bind?n.bind(e):n;return e=t,t.type=`dblclick`,t.detail=2,t.isTrusted=!1,t._simulated=!0,t}var X=200;function it(e,t){e.addEventListener(`dblclick`,t);var n=0,r;function i(e){if(e.detail!==1)r=e.detail;else if(!(e.pointerType===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)){var i=Yt(e);if(!i.some(function(e){return e instanceof HTMLLabelElement&&e.attributes.for})||i.some(function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement})){var a=Date.now();a-n<=X?(r++,r===2&&t(rt(e))):r=1,n=a}}}return e.addEventListener(`click`,i),{dblclick:t,simDblclick:i}}function at(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`click`,t.simDblclick)}var ot=xt([`transform`,`webkitTransform`,`OTransform`,`MozTransform`,`msTransform`]),st=xt([`webkitTransition`,`transition`,`OTransition`,`MozTransition`,`msTransition`]),ct=st===`webkitTransition`||st===`OTransition`?st+`End`:`transitionend`;function lt(e){return typeof e==`string`?document.getElementById(e):e}function ut(e,t){var n=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!n||n===`auto`)&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n===`auto`?null:n}function dt(e,t,n){var r=document.createElement(e);return r.className=t||``,n&&n.appendChild(r),r}function ft(e){var t=e.parentNode;t&&t.removeChild(e)}function pt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function mt(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function ht(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function gt(e,t){if(e.classList!==void 0)return e.classList.contains(t);var n=yt(e);return n.length>0&&RegExp(`(^|\\s)`+t+`(\\s|$)`).test(n)}function _t(e,t){if(e.classList!==void 0)for(var n=f(t),r=0,i=n.length;r<i;r++)e.classList.add(n[r]);else if(!gt(e,t)){var a=yt(e);Z(e,(a?a+` `:``)+t)}}function vt(e,t){e.classList===void 0?Z(e,d((` `+yt(e)+` `).replace(` `+t+` `,` `))):e.classList.remove(t)}function Z(e,t){e.className.baseVal===void 0?e.className=t:e.className.baseVal=t}function yt(e){return e.correspondingElement&&(e=e.correspondingElement),e.className.baseVal===void 0?e.className:e.className.baseVal}function bt(e,t){`opacity`in e.style?e.style.opacity=t:`filter`in e.style&&Q(e,t)}function Q(e,t){var n=!1,r=`DXImageTransform.Microsoft.Alpha`;try{n=e.filters.item(r)}catch{if(t===1)return}t=Math.round(t*100),n?(n.Enabled=t!==100,n.Opacity=t):e.style.filter+=` progid:`+r+`(opacity=`+t+`)`}function xt(e){for(var t=document.documentElement.style,n=0;n<e.length;n++)if(e[n]in t)return e[n];return!1}function St(e,t,n){var r=t||new j(0,0);e.style[ot]=(W.ie3d?`translate(`+r.x+`px,`+r.y+`px)`:`translate3d(`+r.x+`px,`+r.y+`px,0)`)+(n?` scale(`+n+`)`:``)}function $(e,t){e._leaflet_pos=t,W.any3d?St(e,t):(e.style.left=t.x+`px`,e.style.top=t.y+`px`)}function Ct(e){return e._leaflet_pos||new j(0,0)}var wt,Tt,Et;if(`onselectstart`in document)wt=function(){Lt(window,`selectstart`,qt)},Tt=function(){zt(window,`selectstart`,qt)};else{var Dt=xt([`userSelect`,`WebkitUserSelect`,`OUserSelect`,`MozUserSelect`,`msUserSelect`]);wt=function(){if(Dt){var e=document.documentElement.style;Et=e[Dt],e[Dt]=`none`}},Tt=function(){Dt&&(document.documentElement.style[Dt]=Et,Et=void 0)}}function Ot(){Lt(window,`dragstart`,qt)}function kt(){zt(window,`dragstart`,qt)}var At,jt;function Mt(e){for(;e.tabIndex===-1;)e=e.parentNode;e.style&&(Nt(),At=e,jt=e.style.outlineStyle,e.style.outlineStyle=`none`,Lt(window,`keydown`,Nt))}function Nt(){At&&(At.style.outlineStyle=jt,At=void 0,jt=void 0,zt(window,`keydown`,Nt))}function Pt(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function Ft(e){var t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}var It={__proto__:null,TRANSFORM:ot,TRANSITION:st,TRANSITION_END:ct,get:lt,getStyle:ut,create:dt,remove:ft,empty:pt,toFront:mt,toBack:ht,hasClass:gt,addClass:_t,removeClass:vt,setClass:Z,getClass:yt,setOpacity:bt,testProp:xt,setTransform:St,setPosition:$,getPosition:Ct,get disableTextSelection(){return wt},get enableTextSelection(){return Tt},disableImageDrag:Ot,enableImageDrag:kt,preventOutline:Mt,restoreOutline:Nt,getSizedParentNode:Pt,getScale:Ft};function Lt(e,t,n,r){if(t&&typeof t==`object`)for(var i in t)Ht(e,i,t[i],n);else{t=f(t);for(var a=0,o=t.length;a<o;a++)Ht(e,t[a],n,r)}return this}var Rt=`_leaflet_events`;function zt(e,t,n,r){if(arguments.length===1)Bt(e),delete e[Rt];else if(t&&typeof t==`object`)for(var i in t)Ut(e,i,t[i],n);else if(t=f(t),arguments.length===2)Bt(e,function(e){return v(t,e)!==-1});else for(var a=0,o=t.length;a<o;a++)Ut(e,t[a],n,r);return this}function Bt(e,t){for(var n in e[Rt]){var r=n.split(/\d/)[0];(!t||t(r))&&Ut(e,r,null,null,n)}}var Vt={mouseenter:`mouseover`,mouseleave:`mouseout`,wheel:!(`onwheel`in window)&&`mousewheel`};function Ht(e,t,n,r){var i=t+o(n)+(r?`_`+o(r):``);if(e[Rt]&&e[Rt][i])return this;var a=function(t){return n.call(r||e,t||window.event)},s=a;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?a=Qe(e,t,a):W.touch&&t===`dblclick`?a=it(e,a):`addEventListener`in e?t===`touchstart`||t===`touchmove`||t===`wheel`||t===`mousewheel`?e.addEventListener(Vt[t]||t,a,W.passiveEvents?{passive:!1}:!1):t===`mouseenter`||t===`mouseleave`?(a=function(t){t||=window.event,$t(e,t)&&s(t)},e.addEventListener(Vt[t],a,!1)):e.addEventListener(t,s,!1):e.attachEvent(`on`+t,a),e[Rt]=e[Rt]||{},e[Rt][i]=a}function Ut(e,t,n,r,i){i||=t+o(n)+(r?`_`+o(r):``);var a=e[Rt]&&e[Rt][i];if(!a)return this;!W.touchNative&&W.pointer&&t.indexOf(`touch`)===0?$e(e,t,a):W.touch&&t===`dblclick`?at(e,a):`removeEventListener`in e?e.removeEventListener(Vt[t]||t,a,!1):e.detachEvent(`on`+t,a),e[Rt][i]=null}function Wt(e){return e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:e.cancelBubble=!0,this}function Gt(e){return Ht(e,`wheel`,Wt),this}function Kt(e){return Lt(e,`mousedown touchstart dblclick contextmenu`,Wt),e._leaflet_disable_click=!0,this}function qt(e){return e.preventDefault?e.preventDefault():e.returnValue=!1,this}function Jt(e){return qt(e),Wt(e),this}function Yt(e){if(e.composedPath)return e.composedPath();for(var t=[],n=e.target;n;)t.push(n),n=n.parentNode;return t}function Xt(e,t){if(!t)return new j(e.clientX,e.clientY);var n=Ft(t),r=n.boundingClientRect;return new j((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}var Zt=W.linux&&W.chrome?window.devicePixelRatio:W.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Qt(e){return W.edge?e.wheelDeltaY/2:e.deltaY&&e.deltaMode===0?-e.deltaY/Zt:e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?-e.detail*20:e.detail?e.detail/-32765*60:0}function $t(e,t){var n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch{return!1}return n!==e}var en={__proto__:null,on:Lt,off:zt,stopPropagation:Wt,disableScrollPropagation:Gt,disableClickPropagation:Kt,preventDefault:qt,stop:Jt,getPropagationPath:Yt,getMousePosition:Xt,getWheelDelta:Qt,isExternalTarget:$t,addListener:Lt,removeListener:zt},tn=ee.extend({run:function(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(r||.5,.2),this._startPos=Ct(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire(`start`),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())},_runFrame:function(e,t){var n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),$(this._el,n),this.fire(`step`)},_complete:function(){E(this._animId),this._inProgress=!1,this.fire(`end`)},_easeOut:function(e){return 1-(1-e)**this._easeOutPower}}),nn=ee.extend({options:{crs:ce,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(e,t){t=p(this,t),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(e),this._initLayout(),this._onResize=i(this._onResize,this),this._initEvents(),t.maxBounds&&this.setMaxBounds(t.maxBounds),t.zoom!==void 0&&(this._zoom=this._limitZoom(t.zoom)),t.center&&t.zoom!==void 0&&this.setView(z(t.center),t.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=st&&W.any3d&&!W.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Lt(this._proxy,ct,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(e,t,r){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(z(e),t,this.options.maxBounds),r||={},this._stop(),this._loaded&&!r.reset&&r!==!0&&(r.animate!==void 0&&(r.zoom=n({animate:r.animate},r.zoom),r.pan=n({animate:r.animate,duration:r.duration},r.pan)),this._zoom===t?this._tryAnimatedPan(e,r.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,r.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,r.pan&&r.pan.noMoveStart),this)},setZoom:function(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)},zoomIn:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom+e,t)},zoomOut:function(e,t){return e||=W.any3d?this.options.zoomDelta:1,this.setZoom(this._zoom-e,t)},setZoomAround:function(e,t,n){var r=this.getZoomScale(t),i=this.getSize().divideBy(2),a=(e instanceof j?e:this.latLngToContainerPoint(e)).subtract(i).multiplyBy(1-1/r),o=this.containerPointToLatLng(i.add(a));return this.setView(o,t,{zoom:n})},_getBoundsCenterZoom:function(e,t){t||={},e=e.getBounds?e.getBounds():I(e);var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};var a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}},fitBounds:function(e,t){if(e=I(e),!e.isValid())throw Error(`Bounds are not valid.`);var n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)},fitWorld:function(e){return this.fitBounds([[-90,-180],[90,180]],e)},panTo:function(e,t){return this.setView(e,this._zoom,{pan:t})},panBy:function(e,t){if(e=N(e).round(),t||={},!e.x&&!e.y)return this.fire(`moveend`);if(t.animate!==!0&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new tn,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`),t.animate!==!1){_t(this._mapPane,`leaflet-pan-anim`);var n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this.fire(`move`).fire(`moveend`);return this},flyTo:function(e,t,n){if(n||={},n.animate===!1||!W.any3d)return this.setView(e,t,n);this._stop();var r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom;e=z(e),t=t===void 0?o:t;var s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){var t=e?-1:1,n=e?c:s,r=(c*c-s*s+t*d*d*l*l)/(2*n*d*l),i=Math.sqrt(r*r+1)-r;return i<1e-9?-18:Math.log(i)}function p(e){return(Math.exp(e)-Math.exp(-e))/2}function m(e){return(Math.exp(e)+Math.exp(-e))/2}function h(e){return p(e)/m(e)}var g=f(0);function _(e){return s*(m(g)/m(g+u*e))}function v(e){return s*(m(g)*h(g+u*e)-p(g))/d}function y(e){return 1-(1-e)**1.5}var b=Date.now(),x=(f(1)-g)/u,S=n.duration?1e3*n.duration:1e3*x*.8;function C(){var n=(Date.now()-b)/S,a=y(n)*x;n<=1?(this._flyToFrame=T(C,this),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(v(a)/l)),o),this.getScaleZoom(s/_(a),o),{flyTo:!0})):this._move(e,t)._moveEnd(!0)}return this._moveStart(!0,n.noMoveStart),C.call(this),this},flyToBounds:function(e,t){var n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)},setMaxBounds:function(e){return e=I(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(e){var t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this},setMaxZoom:function(e){var t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var n=this.getCenter(),r=this._limitCenter(n,this._zoom,I(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this},panInside:function(e,t){t||={};var n=N(t.paddingTopLeft||t.padding||[0,0]),r=N(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=F([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;var l=a.subtract(s.getCenter()),u=s.extend(a).getSize().subtract(c);i.x+=l.x<0?-u.x:u.x,i.y+=l.y<0?-u.y:u.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=n({animate:!1,pan:!0},e===!0?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),a=t.divideBy(2).round(),o=r.divideBy(2).round(),s=a.subtract(o);return!s.x&&!s.y?this:(e.animate&&e.pan?this.panBy(s):(e.pan&&this._rawPanBy(s),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(i(this.fire,this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:r}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()},locate:function(e){if(e=this._locateOptions=n({timeout:1e4,watch:!1},e),!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;var t=i(this._handleGeolocationResponse,this),r=i(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,r,e):navigator.geolocation.getCurrentPosition(t,r,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: `+n+`.`})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=e.coords.latitude,n=e.coords.longitude,r=new R(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){var o=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(o,a.maxZoom):o)}var s={latlng:r,bounds:i,timestamp:e.timestamp};for(var c in e.coords)typeof e.coords[c]==`number`&&(s[c]=e.coords[c]);this.fire(`locationfound`,s)}},addHandler:function(e,t){if(!t)return this;var n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw Error(`Map container is being reused by another instance`);try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}for(var e in this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ft(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&=(E(this._resizeRequest),null),this._clearHandlers(),this._loaded&&this.fire(`unload`),this._layers)this._layers[e].remove();for(e in this._panes)ft(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var n=dt(`div`,`leaflet-pane`+(e?` leaflet-`+e.replace(`Pane`,``)+`-pane`:``),t||this._mapPane);return e&&(this._panes[e]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new te(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=I(e),n=N(n||[0,0]);var r=this.getZoom()||0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=F(this.project(s,r),this.project(o,r)).getSize(),u=W.any3d?this.options.zoomSnap:1,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new j(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var n=this._getTopLeftPoint(e,t);return new P(n,n.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(e===void 0?this.getZoom():e)},getPane:function(e){return typeof e==`string`?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var n=this.options.crs;return t=t===void 0?this._zoom:t,n.scale(e)/n.scale(t)},getScaleZoom:function(e,t){var n=this.options.crs;t=t===void 0?this._zoom:t;var r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r},project:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.latLngToPoint(z(e),t)},unproject:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.pointToLatLng(N(e),t)},layerPointToLatLng:function(e){var t=N(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(z(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(z(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(I(e))},distance:function(e,t){return this.options.crs.distance(z(e),z(t))},containerPointToLayerPoint:function(e){return N(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return N(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(N(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(z(e)))},mouseEventToContainerPoint:function(e){return Xt(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=lt(e);if(!t)throw Error(`Map container not found.`);if(t._leaflet_id)throw Error(`Map container is already initialized.`);Lt(t,`scroll`,this._onScroll,this),this._containerId=o(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&W.any3d,_t(e,`leaflet-container`+(W.touch?` leaflet-touch`:``)+(W.retina?` leaflet-retina`:``)+(W.ielt9?` leaflet-oldie`:``)+(W.safari?` leaflet-safari`:``)+(this._fadeAnimated?` leaflet-fade-anim`:``));var t=ut(e,`position`);t!==`absolute`&&t!==`relative`&&t!==`fixed`&&t!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),$(this._mapPane,new j(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(_t(e.markerPane,`leaflet-zoom-hide`),_t(e.shadowPane,`leaflet-zoom-hide`))},_resetView:function(e,t,n){$(this._mapPane,new j(0,0));var r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`);var i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)},_moveStart:function(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this},_move:function(e,t,n,r){t===void 0&&(t=this._zoom);var i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n&&n.pinch&&this.fire(`zoom`,n):((i||n&&n.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this},_moveEnd:function(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)},_stop:function(){return E(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){$(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw Error(`Set map center and zoom first.`)},_initEvents:function(e){this._targets={},this._targets[o(this._container)]=this;var t=e?zt:Lt;t(this._container,`click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&t(window,`resize`,this._onResize,this),W.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)},_onResize:function(){E(this._resizeRequest),this._resizeRequest=T(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var n=[],r,i=t===`mouseout`||t===`mouseover`,a=e.target||e.srcElement,s=!1;a;){if(r=this._targets[o(a)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){s=!0;break}if(r&&r.listens(t,!0)&&(i&&!$t(a,e)||(n.push(r),i))||a===this._container)break;a=a.parentNode}return!n.length&&!s&&!i&&this.listens(t,!0)&&(n=[this]),n},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||e.type===`click`&&this._isClickDisabled(t))){var n=e.type;n===`mousedown`&&Mt(t),this._fireDOMEvent(e,n)}},_mouseEvents:[`click`,`dblclick`,`mouseover`,`mouseout`,`contextmenu`],_fireDOMEvent:function(e,t,r){if(e.type===`click`){var i=n({},e);i.type=`preclick`,this._fireDOMEvent(i,i.type,r)}var a=this._findEventTargets(e,t);if(r){for(var o=[],s=0;s<r.length;s++)r[s].listens(t,!0)&&o.push(r[s]);a=o.concat(a)}if(a.length){t===`contextmenu`&&qt(e);var c=a[0],l={originalEvent:e};if(e.type!==`keypress`&&e.type!==`keydown`&&e.type!==`keyup`){var u=c.getLatLng&&(!c._radius||c._radius<=10);l.containerPoint=u?this.latLngToContainerPoint(c.getLatLng()):this.mouseEventToContainerPoint(e),l.layerPoint=this.containerPointToLayerPoint(l.containerPoint),l.latlng=u?c.getLatLng():this.layerPointToLatLng(l.layerPoint)}for(s=0;s<a.length;s++)if(a[s].fire(t,l,!0),l.originalEvent._stopped||a[s].options.bubblingMouseEvents===!1&&v(this._mouseEvents,t)!==-1)return}},_draggableMoved:function(e){return e=e.dragging&&e.dragging.enabled()?e:this,e.dragging&&e.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var e=0,t=this._handlers.length;e<t;e++)this._handlers[e].disable()},whenReady:function(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this},_getMapPanePos:function(){return Ct(this._mapPane)||new j(0,0)},_moved:function(){var e=this._getMapPanePos();return e&&!e.equals([0,0])},_getTopLeftPoint:function(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(e,t){var n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)},_latLngBoundsToNewLayerBounds:function(e,t,n){var r=this._getNewPixelOrigin(n,t);return F([this.project(e.getSouthWest(),t)._subtract(r),this.project(e.getNorthWest(),t)._subtract(r),this.project(e.getSouthEast(),t)._subtract(r),this.project(e.getNorthEast(),t)._subtract(r)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())},_limitCenter:function(e,t,n){if(!n)return e;var r=this.project(e,t),i=this.getSize().divideBy(2),a=new P(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)},_limitOffset:function(e,t){if(!t)return e;var n=this.getPixelBounds(),r=new P(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))},_getBoundsOffset:function(e,t,n){var r=F(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new j(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))},_rebound:function(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),n=this.getMaxZoom(),r=W.any3d?this.options.zoomSnap:1;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))},_onPanTransitionStep:function(){this.fire(`move`)},_onPanTransitionEnd:function(){vt(this._mapPane,`leaflet-pan-anim`),this.fire(`moveend`)},_tryAnimatedPan:function(e,t){var n=this._getCenterOffset(e)._trunc();return(t&&t.animate)!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},_createAnimProxy:function(){var e=this._proxy=dt(`div`,`leaflet-proxy leaflet-zoom-animated`);this._panes.mapPane.appendChild(e),this.on(`zoomanim`,function(e){var t=ot,n=this._proxy.style[t];St(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on(`load moveend`,this._animMoveEnd,this),this._on(`unload`,this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ft(this._proxy),this.off(`load moveend`,this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();St(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf(`transform`)>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName(`leaflet-zoom-animated`).length},_tryAnimatedZoom:function(e,t,n){if(this._animatingZoom)return!0;if(n||={},!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var r=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/r);return n.animate!==!0&&!this.getSize().contains(i)?!1:(T(function(){this._moveStart(!0,n.noMoveStart||!1)._animateZoom(e,t,!0)},this),!0)},_animateZoom:function(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,_t(this._mapPane,`leaflet-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(i(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&vt(this._mapPane,`leaflet-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}});function rn(e,t){return new nn(e,t)}var an=O.extend({options:{position:`topright`},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];return _t(t,`leaflet-control`),n.indexOf(`bottom`)===-1?r.appendChild(t):r.insertBefore(t,r.firstChild),this._map.on(`unload`,this.remove,this),this},remove:function(){return this._map&&=(ft(this._container),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),null),this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),on=function(e){return new an(e)};nn.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t=`leaflet-`,n=this._controlContainer=dt(`div`,t+`control-container`,this._container);function r(r,i){var a=t+r+` `+t+i;e[r+i]=dt(`div`,a,n)}r(`top`,`left`),r(`top`,`right`),r(`bottom`,`left`),r(`bottom`,`right`)},_clearControlPos:function(){for(var e in this._controlCorners)ft(this._controlCorners[e]);ft(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var sn=an.extend({options:{collapsed:!0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,n,r){return n<r?-1:+(r<n)}},initialize:function(e,t,n){for(var r in p(this,n),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1,e)this._addLayer(e[r],r);for(r in t)this._addLayer(t[r],r,!0)},onAdd:function(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.on(`add remove`,this._onLayerChange,this);return this._container},addTo:function(e){return an.prototype.addTo.call(this,e),this._expandIfNotCollapsed()},onRemove:function(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(var e=0;e<this._layers.length;e++)this._layers[e].layer.off(`add remove`,this._onLayerChange,this)},addBaseLayer:function(e,t){return this._addLayer(e,t),this._map?this._update():this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._map?this._update():this},removeLayer:function(e){e.off(`add remove`,this._onLayerChange,this);var t=this._getLayer(o(e));return t&&this._layers.splice(this._layers.indexOf(t),1),this._map?this._update():this},expand:function(){_t(this._container,`leaflet-control-layers-expanded`),this._section.style.height=null;var e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(_t(this._section,`leaflet-control-layers-scrollbar`),this._section.style.height=e+`px`):vt(this._section,`leaflet-control-layers-scrollbar`),this._checkDisabledLayers(),this},collapse:function(){return vt(this._container,`leaflet-control-layers-expanded`),this},_initLayout:function(){var e=`leaflet-control-layers`,t=this._container=dt(`div`,e),n=this.options.collapsed;t.setAttribute(`aria-haspopup`,!0),Kt(t),Gt(t);var r=this._section=dt(`section`,e+`-list`);n&&(this._map.on(`click`,this.collapse,this),Lt(t,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var i=this._layersLink=dt(`a`,e+`-toggle`,t);i.href=`#`,i.title=`Layers`,i.setAttribute(`role`,`button`),Lt(i,{keydown:function(e){e.keyCode===13&&this._expandSafely()},click:function(e){qt(e),this._expandSafely()}},this),n||this.expand(),this._baseLayersList=dt(`div`,e+`-base`,r),this._separator=dt(`div`,e+`-separator`,r),this._overlaysList=dt(`div`,e+`-overlays`,r),t.appendChild(r)},_getLayer:function(e){for(var t=0;t<this._layers.length;t++)if(this._layers[t]&&o(this._layers[t].layer)===e)return this._layers[t]},_addLayer:function(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:n}),this.options.sortLayers&&this._layers.sort(i(function(e,t){return this.options.sortFunction(e.layer,t.layer,e.name,t.name)},this)),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;pt(this._baseLayersList),pt(this._overlaysList),this._layerControlInputs=[];var e,t,n,r,i=0;for(n=0;n<this._layers.length;n++)r=this._layers[n],this._addItem(r),t||=r.overlay,e||=!r.overlay,i+=+!r.overlay;return this.options.hideSingleBase&&(e&&=i>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(o(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,t)},_createRadioElement:function(e,t){var n=`<input type="radio" class="leaflet-control-layers-selector" name="`+e+`"`+(t?` checked="checked"`:``)+`/>`,r=document.createElement(`div`);return r.innerHTML=n,r.firstChild},_addItem:function(e){var t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r;e.overlay?(r=document.createElement(`input`),r.type=`checkbox`,r.className=`leaflet-control-layers-selector`,r.defaultChecked=n):r=this._createRadioElement(`leaflet-base-layers_`+o(this),n),this._layerControlInputs.push(r),r.layerId=o(e.layer),Lt(r,`click`,this._onInputClick,this);var i=document.createElement(`span`);i.innerHTML=` `+e.name;var a=document.createElement(`span`);return t.appendChild(a),a.appendChild(r),a.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(t),this._checkDisabledLayers(),t},_onInputClick:function(){if(!this._preventClick){var e=this._layerControlInputs,t,n,r=[],i=[];this._handlingClick=!0;for(var a=e.length-1;a>=0;a--)t=e[a],n=this._getLayer(t.layerId).layer,t.checked?r.push(n):t.checked||i.push(n);for(a=0;a<i.length;a++)this._map.hasLayer(i[a])&&this._map.removeLayer(i[a]);for(a=0;a<r.length;a++)this._map.hasLayer(r[a])||this._map.addLayer(r[a]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var e=this._layerControlInputs,t,n,r=this._map.getZoom(),i=e.length-1;i>=0;i--)t=e[i],n=this._getLayer(t.layerId).layer,t.disabled=n.options.minZoom!==void 0&&r<n.options.minZoom||n.options.maxZoom!==void 0&&r>n.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,Lt(e,`click`,qt),this.expand();var t=this;setTimeout(function(){zt(e,`click`,qt),t._preventClick=!1})}}),cn=function(e,t,n){return new sn(e,t,n)},ln=an.extend({options:{position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomInTitle:`Zoom in`,zoomOutText:`<span aria-hidden="true">&#x2212;</span>`,zoomOutTitle:`Zoom out`},onAdd:function(e){var t=`leaflet-control-zoom`,n=dt(`div`,t+` leaflet-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,r.zoomInTitle,t+`-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,r.zoomOutTitle,t+`-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n},onRemove:function(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(e.shiftKey?3:1))},_zoomOut:function(e){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,n,r,i){var a=dt(`a`,n,r);return a.innerHTML=e,a.href=`#`,a.title=t,a.setAttribute(`role`,`button`),a.setAttribute(`aria-label`,t),Kt(a),Lt(a,`click`,Jt),Lt(a,`click`,i,this),Lt(a,`click`,this._refocusOnMap,this),a},_updateDisabled:function(){var e=this._map,t=`leaflet-disabled`;vt(this._zoomInButton,t),vt(this._zoomOutButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(_t(this._zoomOutButton,t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(_t(this._zoomInButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}});nn.mergeOptions({zoomControl:!0}),nn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ln,this.addControl(this.zoomControl))});var un=function(e){return new ln(e)},dn=an.extend({options:{position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t=`leaflet-control-scale`,n=dt(`div`,t),r=this.options;return this._addScales(r,t+`-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n},onRemove:function(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)},_addScales:function(e,t,n){e.metric&&(this._mScale=dt(`div`,t,n)),e.imperial&&(this._iScale=dt(`div`,t,n))},_update:function(){var e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),n=t<1e3?t+` m`:t/1e3+` km`;this._updateScale(this._mScale,n,t/e)},_updateImperial:function(e){var t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,r+` mi`,r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,i+` ft`,i/t))},_updateScale:function(e,t,n){e.style.width=Math.round(this.options.maxWidth*n)+`px`,e.innerHTML=t},_getRoundNum:function(e){var t=10**((Math.floor(e)+``).length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),fn=function(e){return new dn(e)},pn=an.extend({options:{position:`bottomright`,prefix:`<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">`+(W.inlineSvg?`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg> `:``)+`Leaflet</a>`},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=dt(`div`,`leaflet-control-attribution`),Kt(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on(`layeradd`,this._addAttribution,this),this._container},onRemove:function(e){e.off(`layeradd`,this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once(`remove`,function(){this.removeAttribution(e.layer.getAttribution())},this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e&&(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()),this},removeAttribution:function(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(`, `)),this._container.innerHTML=n.join(` <span aria-hidden="true">|</span> `)}}});nn.mergeOptions({attributionControl:!0}),nn.addInitHook(function(){this.options.attributionControl&&new pn().addTo(this)}),an.Layers=sn,an.Zoom=ln,an.Scale=dn,an.Attribution=pn,on.layers=cn,on.zoom=un,on.scale=fn,on.attribution=function(e){return new pn(e)};var mn=O.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});mn.addTo=function(e,t){return e.addHandler(t,this),this};var hn={Events:A},gn=W.touch?`touchstart mousedown`:`mousedown`,_n=ee.extend({options:{clickTolerance:3},initialize:function(e,t,n,r){p(this,r),this._element=e,this._dragStartTarget=t||e,this._preventOutline=n},enable:function(){this._enabled||=(Lt(this._dragStartTarget,gn,this._onDown,this),!0)},disable:function(){this._enabled&&(_n._dragging===this&&this.finishDrag(!0),zt(this._dragStartTarget,gn,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!gt(this._element,`leaflet-zoom-anim`))){if(e.touches&&e.touches.length!==1)_n._dragging===this&&this.finishDrag();else if(!(_n._dragging||e.shiftKey||e.which!==1&&e.button!==1&&!e.touches)&&(_n._dragging=this,this._preventOutline&&Mt(this._element),Ot(),wt(),!this._moving)){this.fire(`down`);var t=e.touches?e.touches[0]:e,n=Pt(this._element);this._startPoint=new j(t.clientX,t.clientY),this._startPos=Ct(this._element),this._parentScale=Ft(n);var r=e.type===`mousedown`;Lt(document,r?`mousemove`:`touchmove`,this._onMove,this),Lt(document,r?`mouseup`:`touchend touchcancel`,this._onUp,this)}}},_onMove:function(e){if(this._enabled){if(e.touches&&e.touches.length>1)this._moved=!0;else{var t=e.touches&&e.touches.length===1?e.touches[0]:e,n=new j(t.clientX,t.clientY)._subtract(this._startPoint);(n.x||n.y)&&(Math.abs(n.x)+Math.abs(n.y)<this.options.clickTolerance||(n.x/=this._parentScale.x,n.y/=this._parentScale.y,qt(e),this._moved||(this.fire(`dragstart`),this._moved=!0,_t(document.body,`leaflet-dragging`),this._lastTarget=e.target||e.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),_t(this._lastTarget,`leaflet-drag-target`)),this._newPos=this._startPos.add(n),this._moving=!0,this._lastEvent=e,this._updatePosition()))}}},_updatePosition:function(){var e={originalEvent:this._lastEvent};this.fire(`predrag`,e),$(this._element,this._newPos),this.fire(`drag`,e)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(e){vt(document.body,`leaflet-dragging`),this._lastTarget&&=(vt(this._lastTarget,`leaflet-drag-target`),null),zt(document,`mousemove touchmove`,this._onMove,this),zt(document,`mouseup touchend touchcancel`,this._onUp,this),kt(),Tt();var t=this._moved&&this._moving;this._moving=!1,_n._dragging=!1,t&&this.fire(`dragend`,{noInertia:e,distance:this._newPos.distanceTo(this._startPos)})}});function vn(e,t,n){for(var r,i=[1,4,2,8],a=0,o,s,c,l,u=e.length,d,f;a<u;a++)e[a]._code=jn(e[a],t);for(s=0;s<4;s++){for(d=i[s],r=[],a=0,u=e.length,o=u-1;a<u;o=a++)c=e[a],l=e[o],c._code&d?l._code&d||(f=An(l,c,d,t,n),f._code=jn(f,t),r.push(f)):(l._code&d&&(f=An(l,c,d,t,n),f._code=jn(f,t),r.push(f)),r.push(c));e=r}return e}function yn(e,t){var n,r,i,a,o,s,c,l,u;if(!e||e.length===0)throw Error(`latlngs not passed`);Pn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var d=z([0,0]),f=I(e);f.getNorthWest().distanceTo(f.getSouthWest())*f.getNorthEast().distanceTo(f.getNorthWest())<1700&&(d=bn(e));var p=e.length,m=[];for(n=0;n<p;n++){var h=z(e[n]);m.push(t.project(z([h.lat-d.lat,h.lng-d.lng])))}for(s=c=l=0,n=0,r=p-1;n<p;r=n++)i=m[n],a=m[r],o=i.y*a.x-a.y*i.x,c+=(i.x+a.x)*o,l+=(i.y+a.y)*o,s+=o*3;u=s===0?m[0]:[c/s,l/s];var g=t.unproject(N(u));return z([g.lat+d.lat,g.lng+d.lng])}function bn(e){for(var t=0,n=0,r=0,i=0;i<e.length;i++){var a=z(e[i]);t+=a.lat,n+=a.lng,r++}return z([t/r,n/r])}var xn={__proto__:null,clipPolygon:vn,polygonCenter:yn,centroid:bn};function Sn(e,t){if(!t||!e.length)return e.slice();var n=t*t;return e=Dn(e,n),e=Tn(e,n),e}function Cn(e,t,n){return Math.sqrt(Nn(e,t,n,!0))}function wn(e,t,n){return Nn(e,t,n)}function Tn(e,t){var n=e.length,r=new(typeof Uint8Array<`u`?Uint8Array:Array)(n);r[0]=r[n-1]=1,En(e,r,t,0,n-1);var i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function En(e,t,n,r,i){for(var a=0,o,s=r+1,c;s<=i-1;s++)c=Nn(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,En(e,t,n,r,o),En(e,t,n,o,i))}function Dn(e,t){for(var n=[e[0]],r=1,i=0,a=e.length;r<a;r++)Mn(e[r],e[i])>t&&(n.push(e[r]),i=r);return i<a-1&&n.push(e[a-1]),n}var On;function kn(e,t,n,r,i){var a=r?On:jn(e,n),o=jn(t,n),s,c,l;for(On=o;;){if(!(a|o))return[e,t];if(a&o)return!1;s=a||o,c=An(e,t,s,n,i),l=jn(c,n),s===a?(e=c,a=l):(t=c,o=l)}}function An(e,t,n,r,i){var a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new j(l,u,i)}function jn(e,t){var n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function Mn(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function Nn(e,t,n,r){var i=t.x,a=t.y,o=n.x-i,s=n.y-a,c=o*o+s*s,l;return c>0&&(l=((e.x-i)*o+(e.y-a)*s)/c,l>1?(i=n.x,a=n.y):l>0&&(i+=o*l,a+=s*l)),o=e.x-i,s=e.y-a,r?o*o+s*s:new j(i,a)}function Pn(e){return!_(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function Fn(e){return console.warn(`Deprecated use of _flat, please use L.LineUtil.isFlat instead.`),Pn(e)}function In(e,t){var n,r,i,a,o,s,c,l;if(!e||e.length===0)throw Error(`latlngs not passed`);Pn(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var u=z([0,0]),d=I(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(u=bn(e));var f=e.length,p=[];for(n=0;n<f;n++){var m=z(e[n]);p.push(t.project(z([m.lat-u.lat,m.lng-u.lng])))}for(n=0,r=0;n<f-1;n++)r+=p[n].distanceTo(p[n+1])/2;if(r===0)l=p[0];else for(n=0,a=0;n<f-1;n++)if(o=p[n],s=p[n+1],i=o.distanceTo(s),a+=i,a>r){c=(a-r)/i,l=[s.x-c*(s.x-o.x),s.y-c*(s.y-o.y)];break}var h=t.unproject(N(l));return z([h.lat+u.lat,h.lng+u.lng])}var Ln={__proto__:null,simplify:Sn,pointToSegmentDistance:Cn,closestPointOnSegment:wn,clipSegment:kn,_getEdgeIntersection:An,_getBitCode:jn,_sqClosestPointOnSegment:Nn,isFlat:Pn,_flat:Fn,polylineCenter:In},Rn={project:function(e){return new j(e.lng,e.lat)},unproject:function(e){return new R(e.y,e.x)},bounds:new P([-180,-90],[180,90])},zn={R:6378137,R_MINOR:6356752.314245179,bounds:new P([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,n=this.R,r=e.lat*t,i=this.R_MINOR/n,a=Math.sqrt(1-i*i),o=a*Math.sin(r),s=Math.tan(Math.PI/4-r/2)/((1-o)/(1+o))**(a/2);return r=-n*Math.log(Math.max(s,1e-10)),new j(e.lng*t*n,r)},unproject:function(e){for(var t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a),s=0,c=.1,l;s<15&&Math.abs(c)>1e-7;s++)l=i*Math.sin(o),l=((1-l)/(1+l))**(i/2),c=Math.PI/2-2*Math.atan(a*l)-o,o+=c;return new R(o*t,e.x*t/n)}},Bn={__proto__:null,LonLat:Rn,Mercator:zn,SphericalMercator:ae},Vn=n({},re,{code:`EPSG:3395`,projection:zn,transformation:function(){var e=.5/(Math.PI*zn.R);return se(e,.5,-e,.5)}()}),Hn=n({},re,{code:`EPSG:4326`,projection:Rn,transformation:se(1/180,1,-1/180,.5)}),Un=n({},ne,{projection:Rn,transformation:se(1,0,-1,0),scale:function(e){return 2**e},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)},infinite:!0});ne.Earth=re,ne.EPSG3395=Vn,ne.EPSG3857=ce,ne.EPSG900913=le,ne.EPSG4326=Hn,ne.Simple=Un;var Wn=ee.extend({options:{pane:`overlayPane`,attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[o(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[o(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var n=this.getEvents();t.on(n,this),this.once(`remove`,function(){t.off(n,this)},this)}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}});nn.include({addLayer:function(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);var t=o(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer:function(e){var t=o(e);return this._layers[t]&&(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null),this},hasLayer:function(e){return o(e)in this._layers},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},_addLayers:function(e){e=e?_(e)?e:[e]:[];for(var t=0,n=e.length;t<n;t++)this.addLayer(e[t])},_addZoomLimit:function(e){isNaN(e.options.maxZoom)&&isNaN(e.options.minZoom)||(this._zoomBoundLayers[o(e)]=e,this._updateZoomLevels())},_removeZoomLimit:function(e){var t=o(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels:function(){var e=1/0,t=-1/0,n=this._getZoomSpan();for(var r in this._zoomBoundLayers){var i=this._zoomBoundLayers[r].options;e=i.minZoom===void 0?e:Math.min(e,i.minZoom),t=i.maxZoom===void 0?t:Math.max(t,i.maxZoom)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Gn=Wn.extend({initialize:function(e,t){p(this,t),this._layers={};var n,r;if(e)for(n=0,r=e.length;n<r;n++)this.addLayer(e[n])},addLayer:function(e){var t=this.getLayerId(e);return this._layers[t]=e,this._map&&this._map.addLayer(e),this},removeLayer:function(e){var t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this},hasLayer:function(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(e){var t=Array.prototype.slice.call(arguments,1),n,r;for(n in this._layers)r=this._layers[n],r[e]&&r[e].apply(r,t);return this},onAdd:function(e){this.eachLayer(e.addLayer,e)},onRemove:function(e){this.eachLayer(e.removeLayer,e)},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},getLayer:function(e){return this._layers[e]},getLayers:function(){var e=[];return this.eachLayer(e.push,e),e},setZIndex:function(e){return this.invoke(`setZIndex`,e)},getLayerId:function(e){return o(e)}}),Kn=function(e,t){return new Gn(e,t)},qn=Gn.extend({addLayer:function(e){return this.hasLayer(e)?this:(e.addEventParent(this),Gn.prototype.addLayer.call(this,e),this.fire(`layeradd`,{layer:e}))},removeLayer:function(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),Gn.prototype.removeLayer.call(this,e),this.fire(`layerremove`,{layer:e})):this},setStyle:function(e){return this.invoke(`setStyle`,e)},bringToFront:function(){return this.invoke(`bringToFront`)},bringToBack:function(){return this.invoke(`bringToBack`)},getBounds:function(){var e=new te;for(var t in this._layers){var n=this._layers[t];e.extend(n.getBounds?n.getBounds():n.getLatLng())}return e}}),Jn=function(e,t){return new qn(e,t)},Yn=O.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(e){p(this,e)},createIcon:function(e){return this._createIcon(`icon`,e)},createShadow:function(e){return this._createIcon(`shadow`,e)},_createIcon:function(e,t){var n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}var r=this._createImg(n,t&&t.tagName===`IMG`?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r},_setIconStyles:function(e,t){var n=this.options,r=n[t+`Size`];typeof r==`number`&&(r=[r,r]);var i=N(r),a=N(t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0));e.className=`leaflet-marker-`+t+` `+(n.className||``),a&&(e.style.marginLeft=-a.x+`px`,e.style.marginTop=-a.y+`px`),i&&(e.style.width=i.x+`px`,e.style.height=i.y+`px`)},_createImg:function(e,t){return t||=document.createElement(`img`),t.src=e,t},_getIconUrl:function(e){return W.retina&&this.options[e+`RetinaUrl`]||this.options[e+`Url`]}});function Xn(e){return new Yn(e)}var Zn=Yn.extend({options:{iconUrl:`marker-icon.png`,iconRetinaUrl:`marker-icon-2x.png`,shadowUrl:`marker-shadow.png`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(e){return typeof Zn.imagePath!=`string`&&(Zn.imagePath=this._detectIconPath()),(this.options.imagePath||Zn.imagePath)+Yn.prototype._getIconUrl.call(this,e)},_stripUrl:function(e){var t=function(e,t,n){var r=t.exec(e);return r&&r[n]};return e=t(e,/^url\((['"])?(.+)\1\)$/,2),e&&t(e,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var e=dt(`div`,`leaflet-default-icon-path`,document.body),t=ut(e,`background-image`)||ut(e,`backgroundImage`);if(document.body.removeChild(e),t=this._stripUrl(t),t)return t;var n=document.querySelector(`link[href$="leaflet.css"]`);return n?n.href.substring(0,n.href.length-11-1):``}}),Qn=mn.extend({initialize:function(e){this._marker=e},addHooks:function(){var e=this._marker._icon;this._draggable||=new _n(e,e,!0),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),_t(e,`leaflet-marker-draggable`)},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&vt(this._marker._icon,`leaflet-marker-draggable`)},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(e){var t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=Ct(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=F(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){var l=N((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(l,{animate:!1}),this._draggable._newPos._add(l),this._draggable._startPos._add(l),$(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=T(this._adjustPan.bind(this,e))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire(`movestart`).fire(`dragstart`)},_onPreDrag:function(e){this._marker.options.autoPan&&(E(this._panRequest),this._panRequest=T(this._adjustPan.bind(this,e)))},_onDrag:function(e){var t=this._marker,n=t._shadow,r=Ct(t._icon),i=t._map.layerPointToLatLng(r);n&&$(n,r),t._latlng=i,e.latlng=i,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)},_onDragEnd:function(e){E(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}}),$n=Wn.extend({options:{icon:new Zn,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(e,t){p(this,t),this._latlng=z(e)},onAdd:function(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(e){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},setZIndexOffset:function(e){return this.options.zIndexOffset=e,this.update()},getIcon:function(){return this.options.icon},setIcon:function(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var e=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(e)}return this},_initIcon:function(){var e=this.options,t=`leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`),n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n.tagName===`IMG`&&(n.alt=e.alt||``)),_t(n,t),e.keyboard&&(n.tabIndex=`0`,n.setAttribute(`role`,`button`)),this._icon=n,e.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Lt(n,`focus`,this._panOnFocus,this);var i=e.icon.createShadow(this._shadow),a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(_t(i,t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&zt(this._icon,`focus`,this._panOnFocus,this),ft(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ft(this._shadow),this._shadow=null},_setPos:function(e){this._icon&&$(this._icon,e),this._shadow&&$(this._shadow,e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(e){this._icon&&(this._icon.style.zIndex=this._zIndex+e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center).round();this._setPos(t)},_initInteraction:function(){if(this.options.interactive&&(_t(this._icon,`leaflet-interactive`),this.addInteractiveTarget(this._icon),Qn)){var e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Qn(this),e&&this.dragging.enable()}},setOpacity:function(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var e=this.options.opacity;this._icon&&bt(this._icon,e),this._shadow&&bt(this._shadow,e)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var e=this._map;if(e){var t=this.options.icon.options,n=t.iconSize?N(t.iconSize):N(0,0),r=t.iconAnchor?N(t.iconAnchor):N(0,0);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:n.subtract(r)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function er(e,t){return new $n(e,t)}var tr=Wn.extend({options:{stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(e){this._renderer=e.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(e){return p(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.prototype.hasOwnProperty.call(e,`weight`)&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),nr=tr.extend({options:{fill:!0,radius:10},initialize:function(e,t){p(this,t),this._latlng=z(e),this._radius=this.options.radius},setLatLng:function(e){var t=this._latlng;return this._latlng=z(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(e){return this.options.radius=this._radius=e,this.redraw()},getRadius:function(){return this._radius},setStyle:function(e){var t=e&&e.radius||this._radius;return tr.prototype.setStyle.call(this,e),this.setRadius(t),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var e=this._radius,t=this._radiusY||e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new P(this._point.subtract(r),this._point.add(r))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(e){return e.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function rr(e,t){return new nr(e,t)}var ir=nr.extend({initialize:function(e,t,r){if(typeof t==`number`&&(t=n({},r,{radius:t})),p(this,t),this._latlng=z(e),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this._mRadius=this.options.radius},setRadius:function(e){return this._mRadius=e,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var e=[this._radius,this._radiusY||this._radius];return new te(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))},setStyle:tr.prototype.setStyle,_project:function(){var e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===re.distance){var i=Math.PI/180,a=this._mRadius/re.R/i,o=n.project([t+a,e]),s=n.project([t-a,e]),c=o.add(s).divideBy(2),l=n.unproject(c).lat,u=Math.acos((Math.cos(a*i)-Math.sin(t*i)*Math.sin(l*i))/(Math.cos(t*i)*Math.cos(l*i)))/i;(isNaN(u)||u===0)&&(u=a/Math.cos(Math.PI/180*t)),this._point=c.subtract(n.getPixelOrigin()),this._radius=isNaN(u)?0:c.x-n.project([l,e-u]).x,this._radiusY=c.y-o.y}else{var d=r.unproject(r.project(this._latlng).subtract([this._mRadius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._radius=this._point.x-n.latLngToLayerPoint(d).x}this._updateBounds()}});function ar(e,t,n){return new ir(e,t,n)}var or=tr.extend({options:{smoothFactor:1,noClip:!1},initialize:function(e,t){p(this,t),this._setLatLngs(e)},getLatLngs:function(){return this._latlngs},setLatLngs:function(e){return this._setLatLngs(e),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(e){for(var t=1/0,n=null,r=Nn,i,a,o=0,s=this._parts.length;o<s;o++)for(var c=this._parts[o],l=1,u=c.length;l<u;l++){i=c[l-1],a=c[l];var d=r(e,i,a,!0);d<t&&(t=d,n=r(e,i,a))}return n&&(n.distance=Math.sqrt(t)),n},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return In(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(e,t){return t||=this._defaultShape(),e=z(e),t.push(e),this._bounds.extend(e),this.redraw()},_setLatLngs:function(e){this._bounds=new te,this._latlngs=this._convertLatLngs(e)},_defaultShape:function(){return Pn(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(e){for(var t=[],n=Pn(e),r=0,i=e.length;r<i;r++)n?(t[r]=z(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t},_project:function(){var e=new P;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())},_updateBounds:function(){var e=this._clickTolerance(),t=new j(e,e);this._rawPxBounds&&(this._pxBounds=new P([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))},_projectLatlngs:function(e,t,n){var r=e[0]instanceof R,i=e.length,a,o;if(r){for(o=[],a=0;a<i;a++)o[a]=this._map.latLngToLayerPoint(e[a]),n.extend(o[a]);t.push(o)}else for(a=0;a<i;a++)this._projectLatlngs(e[a],t,n)},_clipPoints:function(){var e=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var t=this._parts,n=0,r,i=0,a=this._rings.length,o,s,c;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=kn(c[r],c[r+1],e,r,!0),s&&(t[i]=t[i]||[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}},_simplifyPoints:function(){for(var e=this._parts,t=this.options.smoothFactor,n=0,r=e.length;n<r;n++)e[n]=Sn(e[n],t)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(e,t){var n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&Cn(e,s[i],s[r])<=c)return!0;return!1}});function sr(e,t){return new or(e,t)}or._flat=Fn;var cr=or.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return yn(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(e){var t=or.prototype._convertLatLngs.call(this,e),n=t.length;return n>=2&&t[0]instanceof R&&t[0].equals(t[n-1])&&t.pop(),t},_setLatLngs:function(e){or.prototype._setLatLngs.call(this,e),Pn(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Pn(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,n=new j(t,t);if(e=new P(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(var r=0,i=this._rings.length,a;r<i;r++)a=vn(this._rings[r],e,!0),a.length&&this._parts.push(a)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(e){var t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||or.prototype._containsPoint.call(this,e,!0)}});function lr(e,t){return new cr(e,t)}var ur=qn.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=_(e)?e:e.features,n,r,i;if(t){for(n=0,r=t.length;n<r;n++)i=t[n],(i.geometries||i.geometry||i.features||i.coordinates)&&this.addData(i);return this}var a=this.options;if(a.filter&&!a.filter(e))return this;var o=dr(e,a);return o?(o.feature=vr(e),o.defaultOptions=o.options,this.resetStyle(o),a.onEachFeature&&a.onEachFeature(e,o),this.addLayer(o)):this},resetStyle:function(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=n({},e.defaultOptions),this._setLayerStyle(e,this.options.style),this)},setStyle:function(e){return this.eachLayer(function(t){this._setLayerStyle(t,e)},this)},_setLayerStyle:function(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}});function dr(e,t){var n=e.type===`Feature`?e.geometry:e,r=n?n.coordinates:null,i=[],a=t&&t.pointToLayer,o=t&&t.coordsToLatLng||pr,s,c,l,u;if(!r&&!n)return null;switch(n.type){case`Point`:return s=o(r),fr(a,e,s,t);case`MultiPoint`:for(l=0,u=r.length;l<u;l++)s=o(r[l]),i.push(fr(a,e,s,t));return new qn(i);case`LineString`:case`MultiLineString`:return c=mr(r,n.type===`LineString`?0:1,o),new or(c,t);case`Polygon`:case`MultiPolygon`:return c=mr(r,n.type===`Polygon`?1:2,o),new cr(c,t);case`GeometryCollection`:for(l=0,u=n.geometries.length;l<u;l++){var d=dr({geometry:n.geometries[l],type:`Feature`,properties:e.properties},t);d&&i.push(d)}return new qn(i);case`FeatureCollection`:for(l=0,u=n.features.length;l<u;l++){var f=dr(n.features[l],t);f&&i.push(f)}return new qn(i);default:throw Error(`Invalid GeoJSON object.`)}}function fr(e,t,n,r){return e?e(t,n):new $n(n,r&&r.markersInheritOptions&&r)}function pr(e){return new R(e[1],e[0],e[2])}function mr(e,t,n){for(var r=[],i=0,a=e.length,o;i<a;i++)o=t?mr(e[i],t-1,n):(n||pr)(e[i]),r.push(o);return r}function hr(e,t){return e=z(e),e.alt===void 0?[u(e.lng,t),u(e.lat,t)]:[u(e.lng,t),u(e.lat,t),u(e.alt,t)]}function gr(e,t,n,r){for(var i=[],a=0,o=e.length;a<o;a++)i.push(t?gr(e[a],Pn(e[a])?0:t-1,n,r):hr(e[a],r));return!t&&n&&i.length>0&&i.push(i[0].slice()),i}function _r(e,t){return e.feature?n({},e.feature,{geometry:t}):vr(t)}function vr(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}var yr={toGeoJSON:function(e){return _r(this,{type:`Point`,coordinates:hr(this.getLatLng(),e)})}};$n.include(yr),ir.include(yr),nr.include(yr),or.include({toGeoJSON:function(e){var t=!Pn(this._latlngs),n=gr(this._latlngs,+!!t,!1,e);return _r(this,{type:(t?`Multi`:``)+`LineString`,coordinates:n})}}),cr.include({toGeoJSON:function(e){var t=!Pn(this._latlngs),n=t&&!Pn(this._latlngs[0]),r=gr(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),_r(this,{type:(n?`Multi`:``)+`Polygon`,coordinates:r})}}),Gn.include({toMultiPoint:function(e){var t=[];return this.eachLayer(function(n){t.push(n.toGeoJSON(e).geometry.coordinates)}),_r(this,{type:`MultiPoint`,coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(t===`MultiPoint`)return this.toMultiPoint(e);var n=t===`GeometryCollection`,r=[];return this.eachLayer(function(t){if(t.toGeoJSON){var i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{var a=vr(i);a.type===`FeatureCollection`?r.push.apply(r,a.features):r.push(a)}}}),n?_r(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}});function br(e,t){return new ur(e,t)}var xr=br,Sr=Wn.extend({options:{opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``},initialize:function(e,t,n){this._url=e,this._bounds=I(t),p(this,n)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(_t(this._image,`leaflet-interactive`),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ft(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&&mt(this._image),this},bringToBack:function(){return this._map&&ht(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=I(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e=this._url.tagName===`IMG`,t=this._image=e?this._url:dt(`img`);_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onload=i(this.fire,this,`load`),t.onerror=i(this._overlayOnError,this,`error`),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;St(this._image,n,t)},_reset:function(){var e=this._image,t=new P(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();$(e,t.min),e.style.width=n.x+`px`,e.style.height=n.y+`px`},_updateOpacity:function(){bt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire(`error`);var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),Cr=function(e,t,n){return new Sr(e,t,n)},wr=Sr.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e=this._url.tagName===`VIDEO`,t=this._image=e?this._url:dt(`video`);if(_t(t,`leaflet-image-layer`),this._zoomAnimated&&_t(t,`leaflet-zoom-animated`),this.options.className&&_t(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onloadeddata=i(this.fire,this,`load`),e){for(var n=t.getElementsByTagName(`source`),r=[],a=0;a<n.length;a++)r.push(n[a].src);this._url=n.length>0?r:[t.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,`objectFit`)&&(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var o=0;o<this._url.length;o++){var s=dt(`source`);s.src=this._url[o],t.appendChild(s)}}}});function Tr(e,t,n){return new wr(e,t,n)}var Er=Sr.extend({_initImage:function(){var e=this._image=this._url;_t(e,`leaflet-image-layer`),this._zoomAnimated&&_t(e,`leaflet-zoom-animated`),this.options.className&&_t(e,this.options.className),e.onselectstart=l,e.onmousemove=l}});function Dr(e,t,n){return new Er(e,t,n)}var Or=Wn.extend({options:{interactive:!1,offset:[0,0],className:``,pane:void 0,content:``},initialize:function(e,t){e&&(e instanceof R||_(e))?(this._latlng=z(e),p(this,t)):(p(this,e),this._source=t),this.options.content&&(this._content=this.options.content)},openOn:function(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this},onAdd:function(e){this._zoomAnimated=e._zoomAnimated,this._container||this._initLayout(),e._fadeAnimated&&bt(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),e._fadeAnimated&&bt(this._container,1),this.bringToFront(),this.options.interactive&&(_t(this._container,`leaflet-interactive`),this.addInteractiveTarget(this._container))},onRemove:function(e){e._fadeAnimated?(bt(this._container,0),this._removeTimeout=setTimeout(i(ft,void 0,this._container),200)):ft(this._container),this.options.interactive&&(vt(this._container,`leaflet-interactive`),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(e){return this._latlng=z(e),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(e){return this._content=e,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())},getEvents:function(){var e={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&mt(this._container),this},bringToBack:function(){return this._map&&ht(this._container),this},_prepareOpen:function(e){var t=this._source;if(!t._map)return!1;if(t instanceof qn){t=null;var n=this._source._layers;for(var r in n)if(n[r]._map){t=n[r];break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var e=this._contentNode,t=typeof this._content==`function`?this._content(this._source||this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}},_updatePosition:function(){if(this._map){var e=this._map.latLngToLayerPoint(this._latlng),t=N(this.options.offset),n=this._getAnchor();this._zoomAnimated?$(this._container,e.add(n)):t=t.add(e).add(n);var r=this._containerBottom=-t.y,i=this._containerLeft=-Math.round(this._containerWidth/2)+t.x;this._container.style.bottom=r+`px`,this._container.style.left=i+`px`}},_getAnchor:function(){return[0,0]}});nn.include({_initOverlay:function(e,t,n,r){var i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}}),Wn.include({_initOverlay:function(e,t,n,r){var i=n;return i instanceof e?(p(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}});var kr=Or.extend({options:{pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``},openOn:function(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,Or.prototype.openOn.call(this,e)},onAdd:function(e){Or.prototype.onAdd.call(this,e),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof tr||this._source.on(`preclick`,Wt))},onRemove:function(e){Or.prototype.onRemove.call(this,e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof tr||this._source.off(`preclick`,Wt))},getEvents:function(){var e=Or.prototype.getEvents.call(this);return(this.options.closeOnClick===void 0?this._map.options.closePopupOnClick:this.options.closeOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e},_initLayout:function(){var e=`leaflet-popup`,t=this._container=dt(`div`,e+` `+(this.options.className||``)+` leaflet-zoom-animated`),n=this._wrapper=dt(`div`,e+`-content-wrapper`,t);if(this._contentNode=dt(`div`,e+`-content`,n),Kt(t),Gt(this._contentNode),Lt(t,`contextmenu`,Wt),this._tipContainer=dt(`div`,e+`-tip-container`,t),this._tip=dt(`div`,e+`-tip`,this._tipContainer),this.options.closeButton){var r=this._closeButton=dt(`a`,e+`-close-button`,t);r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,`Close popup`),r.href=`#close`,r.innerHTML=`<span aria-hidden="true">&#215;</span>`,Lt(r,`click`,function(e){qt(e),this.close()},this)}},_updateLayout:function(){var e=this._contentNode,t=e.style;t.width=``,t.whiteSpace=`nowrap`;var n=e.offsetWidth;n=Math.min(n,this.options.maxWidth),n=Math.max(n,this.options.minWidth),t.width=n+1+`px`,t.whiteSpace=``,t.height=``;var r=e.offsetHeight,i=this.options.maxHeight,a=`leaflet-popup-scrolled`;i&&r>i?(t.height=i+`px`,_t(e,a)):vt(e,a),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();$(this._container,t.add(n))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var e=this._map,t=parseInt(ut(this._container,`marginBottom`),10)||0,n=this._container.offsetHeight+t,r=this._containerWidth,i=new j(this._containerLeft,-n-this._containerBottom);i._add(Ct(this._container));var a=e.layerPointToContainerPoint(i),o=N(this.options.autoPanPadding),s=N(this.options.autoPanPaddingTopLeft||o),c=N(this.options.autoPanPaddingBottomRight||o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}}},_getAnchor:function(){return N(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Ar=function(e,t){return new kr(e,t)};nn.mergeOptions({closePopupOnClick:!0}),nn.include({openPopup:function(e,t,n){return this._initOverlay(kr,e,t,n).openOn(this),this},closePopup:function(e){return e=arguments.length?e:this._popup,e&&e.close(),this}}),Wn.include({bindPopup:function(e,t){return this._popup=this._initOverlay(kr,this._popup,e,t),this._popupHandlersAdded||=(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),!0),this},unbindPopup:function(){return this._popup&&=(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,null),this},openPopup:function(e){return this._popup&&(this instanceof qn||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(e){return this._popup&&this._popup.setContent(e),this},getPopup:function(){return this._popup},_openPopup:function(e){if(this._popup&&this._map){Jt(e);var t=e.layer||e.target;this._popup._source===t&&!(t instanceof tr)?this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng):(this._popup._source=t,this.openPopup(e.latlng))}},_movePopup:function(e){this._popup.setLatLng(e.latlng)},_onKeyPress:function(e){e.originalEvent.keyCode===13&&this._openPopup(e)}});var jr=Or.extend({options:{pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9},onAdd:function(e){Or.prototype.onAdd.call(this,e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))},onRemove:function(e){Or.prototype.onRemove.call(this,e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))},getEvents:function(){var e=Or.prototype.getEvents.call(this);return this.options.permanent||(e.preclick=this.close),e},_initLayout:function(){var e=`leaflet-tooltip `+(this.options.className||``)+` leaflet-zoom-`+(this._zoomAnimated?`animated`:`hide`);this._contentNode=this._container=dt(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`leaflet-tooltip-`+o(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(e){var t,n,r=this._map,i=this._container,a=r.latLngToContainerPoint(r.getCenter()),o=r.layerPointToContainerPoint(e),s=this.options.direction,c=i.offsetWidth,l=i.offsetHeight,u=N(this.options.offset),d=this._getAnchor();s===`top`?(t=c/2,n=l):s===`bottom`?(t=c/2,n=0):s===`center`?(t=c/2,n=l/2):s===`right`?(t=0,n=l/2):s===`left`?(t=c,n=l/2):o.x<a.x?(s=`right`,t=0,n=l/2):(s=`left`,t=c+(u.x+d.x)*2,n=l/2),e=e.subtract(N(t,n,!0)).add(u).add(d),vt(i,`leaflet-tooltip-right`),vt(i,`leaflet-tooltip-left`),vt(i,`leaflet-tooltip-top`),vt(i,`leaflet-tooltip-bottom`),_t(i,`leaflet-tooltip-`+s),$(i,e)},_updatePosition:function(){var e=this._map.latLngToLayerPoint(this._latlng);this._setPosition(e)},setOpacity:function(e){this.options.opacity=e,this._container&&bt(this._container,e)},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)},_getAnchor:function(){return N(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),Mr=function(e,t){return new jr(e,t)};nn.include({openTooltip:function(e,t,n){return this._initOverlay(jr,e,t,n).openOn(this),this},closeTooltip:function(e){return e.close(),this}}),Wn.include({bindTooltip:function(e,t){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(jr,this._tooltip,e,t),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions:function(e){if(e||!this._tooltipHandlersAdded){var t=e?`off`:`on`,n={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?n.add=this._openTooltip:(n.mouseover=this._openTooltip,n.mouseout=this.closeTooltip,n.click=this._openTooltip,this._map?this._addFocusListeners():n.add=this._addFocusListeners),this._tooltip.options.sticky&&(n.mousemove=this._moveTooltip),this[t](n),this._tooltipHandlersAdded=!e}},openTooltip:function(e){return this._tooltip&&(this instanceof qn||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(e){return this._tooltip&&this._tooltip.setContent(e),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&(Lt(t,`focus`,function(){this._tooltip._source=e,this.openTooltip()},this),Lt(t,`blur`,this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(e){var t=typeof e.getElement==`function`&&e.getElement();t&&t.setAttribute(`aria-describedby`,this._tooltip._container.id)},_openTooltip:function(e){if(this._tooltip&&this._map){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var t=this;this._map.once(`moveend`,function(){t._openOnceFlag=!1,t._openTooltip(e)})}else this._tooltip._source=e.layer||e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)}},_moveTooltip:function(e){var t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.mouseEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}});var Nr=Yn.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:`leaflet-div-icon`},createIcon:function(e){var t=e&&e.tagName===`DIV`?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(pt(t),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){var r=N(n.bgPos);t.style.backgroundPosition=-r.x+`px `+-r.y+`px`}return this._setIconStyles(t,`icon`),t},createShadow:function(){return null}});function Pr(e){return new Nr(e)}Yn.Default=Zn;var Fr=Wn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:W.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,keepBuffer:2},initialize:function(e){p(this,e)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(e){e._addZoomLimit(this)},onRemove:function(e){this._removeAllTiles(),ft(this._container),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(mt(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(ht(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var e=this._clampZoom(this._map.getZoom());e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this},getEvents:function(){var e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||=s(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},createTile:function(){return document.createElement(`div`)},getTileSize:function(){var e=this.options.tileSize;return e instanceof j?e:new j(e,e)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(e){for(var t=this.getPane().children,n=-e(-1/0,1/0),r=0,i=t.length,a;r<i;r++)a=t[r].style.zIndex,t[r]!==this._container&&a&&(n=e(n,+a));isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!W.ielt9){bt(this._container,this.options.opacity);var e=+new Date,t=!1,n=!1;for(var r in this._tiles){var i=this._tiles[r];if(i.current&&i.loaded){var a=Math.min(1,(e-i.loaded)/200);bt(i.el,a),a<1?t=!0:(i.active?n=!0:this._onOpaqueTile(i),i.active=!0)}}n&&!this._noPrune&&this._pruneTiles(),t&&(E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this))}},_onOpaqueTile:l,_initContainer:function(){this._container||(this._container=dt(`div`,`leaflet-layer `+(this.options.className||``)),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var e=this._tileZoom,t=this.options.maxZoom;if(e!==void 0){for(var n in this._levels)n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=t-Math.abs(e-n),this._onUpdateLevel(n)):(ft(this._levels[n].el),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);var r=this._levels[e],i=this._map;return r||(r=this._levels[e]={},r.el=dt(`div`,`leaflet-tile-container leaflet-zoom-animated`,this._container),r.el.style.zIndex=t,r.origin=i.project(i.unproject(i.getPixelOrigin()),e).round(),r.zoom=e,this._setZoomTransform(r,i.getCenter(),i.getZoom()),r.el.offsetWidth,this._onCreateLevel(r)),this._level=r,r}},_onUpdateLevel:l,_onRemoveLevel:l,_onCreateLevel:l,_pruneTiles:function(){if(this._map){var e,t,n=this._map.getZoom();if(n>this.options.maxZoom||n<this.options.minZoom)this._removeAllTiles();else{for(e in this._tiles)t=this._tiles[e],t.retain=t.current;for(e in this._tiles)if(t=this._tiles[e],t.current&&!t.active){var r=t.coords;this._retainParent(r.x,r.y,r.z,r.z-5)||this._retainChildren(r.x,r.y,r.z,r.z+2)}for(e in this._tiles)this._tiles[e].retain||this._removeTile(e)}}},_removeTilesAtZoom:function(e){for(var t in this._tiles)this._tiles[t].coords.z===e&&this._removeTile(t)},_removeAllTiles:function(){for(var e in this._tiles)this._removeTile(e)},_invalidateAll:function(){for(var e in this._levels)ft(this._levels[e].el),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(e,t,n,r){var i=Math.floor(e/2),a=Math.floor(t/2),o=n-1,s=new j(+i,+a);s.z=+o;var c=this._tileCoordsToKey(s),l=this._tiles[c];return l&&l.active?(l.retain=!0,!0):(l&&l.loaded&&(l.retain=!0),o>r&&this._retainParent(i,a,o,r))},_retainChildren:function(e,t,n,r){for(var i=2*e;i<2*e+2;i++)for(var a=2*t;a<2*t+2;a++){var o=new j(i,a);o.z=n+1;var s=this._tileCoordsToKey(o),c=this._tiles[s];c&&c.active?c.retain=!0:(c&&c.loaded&&(c.retain=!0),n+1<r&&this._retainChildren(i,a,n+1,r))}},_resetView:function(e){var t=e&&(e.pinch||e.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)},_animateZoom:function(e){this._setView(e.center,e.zoom,!0,e.noUpdate)},_clampZoom:function(e){var t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e},_setView:function(e,t,n,r){var i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);var a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)},_setZoomTransforms:function(e,t){for(var n in this._levels)this._setZoomTransform(this._levels[n],e,t)},_setZoomTransform:function(e,t,n){var r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();W.any3d?St(e.el,i,r):$(e.el,i)},_resetGrid:function(){var e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.y)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.x),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(e){var t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new P(i.subtract(a),i.add(a))},_update:function(e){var t=this._map;if(t){var n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom!==void 0){var r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new P(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(var l in this._tiles){var u=this._tiles[l].coords;u.z===this._tileZoom&&c.contains(new j(u.x,u.y))||(this._tiles[l].current=!1)}if(Math.abs(n-this._tileZoom)>1)this._setView(e,n);else{for(var d=i.min.y;d<=i.max.y;d++)for(var f=i.min.x;f<=i.max.x;f++){var p=new j(f,d);if(p.z=this._tileZoom,this._isValidTile(p)){var m=this._tiles[this._tileCoordsToKey(p)];m?m.current=!0:o.push(p)}}if(o.sort(function(e,t){return e.distanceTo(a)-t.distanceTo(a)}),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`));var h=document.createDocumentFragment();for(f=0;f<o.length;f++)this._addTile(o[f],h);this._level.el.appendChild(h)}}}}},_isValidTile:function(e){var t=this._map.options.crs;if(!t.infinite){var n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;var r=this._tileCoordsToBounds(e);return I(this.options.bounds).overlaps(r)},_keyToBounds:function(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))},_tileCoordsToNwSe:function(e){var t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]},_tileCoordsToBounds:function(e){var t=this._tileCoordsToNwSe(e),n=new te(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n},_tileCoordsToKey:function(e){return e.x+`:`+e.y+`:`+e.z},_keyToTileCoords:function(e){var t=e.split(`:`),n=new j(+t[0],+t[1]);return n.z=+t[2],n},_removeTile:function(e){var t=this._tiles[e];t&&(ft(t.el),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:this._keyToTileCoords(e)}))},_initTile:function(e){_t(e,`leaflet-tile`);var t=this.getTileSize();e.style.width=t.x+`px`,e.style.height=t.y+`px`,e.onselectstart=l,e.onmousemove=l,W.ielt9&&this.options.opacity<1&&bt(e,this.options.opacity)},_addTile:function(e,t){var n=this._getTilePos(e),r=this._tileCoordsToKey(e),a=this.createTile(this._wrapCoords(e),i(this._tileReady,this,e));this._initTile(a),this.createTile.length<2&&T(i(this._tileReady,this,e,null,a)),$(a,n),this._tiles[r]={el:a,coords:e,current:!0},t.appendChild(a),this.fire(`tileloadstart`,{tile:a,coords:e})},_tileReady:function(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});var r=this._tileCoordsToKey(e);n=this._tiles[r],n&&(n.loaded=+new Date,this._map._fadeAnimated?(bt(n.el,0),E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),t||(_t(n.el,`leaflet-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire(`load`),W.ielt9||!this._map._fadeAnimated?T(this._pruneTiles,this):setTimeout(i(this._pruneTiles,this),250)))},_getTilePos:function(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(e){var t=new j(this._wrapX?c(e.x,this._wrapX):e.x,this._wrapY?c(e.y,this._wrapY):e.y);return t.z=e.z,t},_pxBoundsToTileRange:function(e){var t=this.getTileSize();return new P(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var e in this._tiles)if(!this._tiles[e].loaded)return!1;return!0}});function Ir(e){return new Fr(e)}var Lr=Fr.extend({options:{minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(e,t){this._url=e,t=p(this,t),t.detectRetina&&W.retina&&t.maxZoom>0?(t.tileSize=Math.floor(t.tileSize/2),t.zoomReverse?(t.zoomOffset--,t.minZoom=Math.min(t.maxZoom,t.minZoom+1)):(t.zoomOffset++,t.maxZoom=Math.max(t.minZoom,t.maxZoom-1)),t.minZoom=Math.max(0,t.minZoom)):t.zoomReverse?t.minZoom=Math.min(t.maxZoom,t.minZoom):t.maxZoom=Math.max(t.minZoom,t.maxZoom),typeof t.subdomains==`string`&&(t.subdomains=t.subdomains.split(``)),this.on(`tileunload`,this._onTileRemove)},setUrl:function(e,t){return this._url===e&&t===void 0&&(t=!0),this._url=e,t||this.redraw(),this},createTile:function(e,t){var n=document.createElement(`img`);return Lt(n,`load`,i(this._tileOnLoad,this,t,n)),Lt(n,`error`,i(this._tileOnError,this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``,n.src=this.getTileUrl(e),n},getTileUrl:function(e){var t={r:W.retina?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var r=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=r),t[`-y`]=r}return g(this._url,n(t,this.options))},_tileOnLoad:function(e,t){W.ielt9?setTimeout(i(e,this,null,t),0):e(null,t)},_tileOnError:function(e,t,n){var r=this.options.errorTileUrl;r&&t.getAttribute(`src`)!==r&&(t.src=r),e(n,t)},_onTileRemove:function(e){e.tile.onload=null},_getZoomForUrl:function(){var e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r},_getSubdomain:function(e){var t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_abortLoading:function(){var e,t;for(e in this._tiles)if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,t.onload=l,t.onerror=l,!t.complete)){t.src=y;var n=this._tiles[e].coords;ft(t),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}},_removeTile:function(e){var t=this._tiles[e];if(t)return t.el.setAttribute(`src`,y),Fr.prototype._removeTile.call(this,e)},_tileReady:function(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===y))return Fr.prototype._tileReady.call(this,e,t,n)}});function Rr(e,t){return new Lr(e,t)}var zr=Lr.extend({defaultWmsParams:{service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`},options:{crs:null,uppercase:!1},initialize:function(e,t){this._url=e;var r=n({},this.defaultWmsParams);for(var i in t)i in this.options||(r[i]=t[i]);t=p(this,t);var a=t.detectRetina&&W.retina?2:1,o=this.getTileSize();r.width=o.x*a,r.height=o.y*a,this.wmsParams=r},onAdd:function(e){this._crs=this.options.crs||e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var t=this._wmsVersion>=1.3?`crs`:`srs`;this.wmsParams[t]=this._crs.code,Lr.prototype.onAdd.call(this,e)},getTileUrl:function(e){var t=this._tileCoordsToNwSe(e),n=this._crs,r=F(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===Hn?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=Lr.prototype.getTileUrl.call(this,e);return s+m(this.wmsParams,s,this.options.uppercase)+(this.options.uppercase?`&BBOX=`:`&bbox=`)+o},setParams:function(e,t){return n(this.wmsParams,e),t||this.redraw(),this}});function Br(e,t){return new zr(e,t)}Lr.WMS=zr,Rr.wms=Br;var Vr=Wn.extend({options:{padding:.1},initialize:function(e){p(this,e),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),_t(this._container,`leaflet-zoom-animated`)),this.getPane().appendChild(this._container),this._update(),this.on(`update`,this._updatePaths,this)},onRemove:function(){this.off(`update`,this._updatePaths,this),this._destroyContainer()},getEvents:function(){var e={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(e,t){var n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n).add(i).subtract(this._map._getNewPixelOrigin(e,t));W.any3d?St(this._container,a,n):$(this._container,a)},_reset:function(){for(var e in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[e]._reset()},_onZoomEnd:function(){for(var e in this._layers)this._layers[e]._project()},_updatePaths:function(){for(var e in this._layers)this._layers[e]._update()},_update:function(){var e=this.options.padding,t=this._map.getSize(),n=this._map.containerPointToLayerPoint(t.multiplyBy(-e)).round();this._bounds=new P(n,n.add(t.multiplyBy(1+e*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Hr=Vr.extend({options:{tolerance:0},getEvents:function(){var e=Vr.prototype.getEvents.call(this);return e.viewprereset=this._onViewPreReset,e},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Vr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var e=this._container=document.createElement(`canvas`);Lt(e,`mousemove`,this._onMouseMove,this),Lt(e,`click dblclick mousedown mouseup contextmenu`,this._onClick,this),Lt(e,`mouseout`,this._handleMouseOut,this),e._leaflet_disable_events=!0,this._ctx=e.getContext(`2d`)},_destroyContainer:function(){E(this._redrawRequest),delete this._ctx,ft(this._container),zt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var e;for(var t in this._redrawBounds=null,this._layers)e=this._layers[t],e._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vr.prototype._update.call(this);var e=this._bounds,t=this._container,n=e.getSize(),r=W.retina?2:1;$(t,e.min),t.width=r*n.x,t.height=r*n.y,t.style.width=n.x+`px`,t.style.height=n.y+`px`,W.retina&&this._ctx.scale(2,2),this._ctx.translate(-e.min.x,-e.min.y),this.fire(`update`)}},_reset:function(){Vr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(e){this._updateDashArray(e),this._layers[o(e)]=e;var t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(e){this._requestRedraw(e)},_removePath:function(e){var t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[o(e)],this._requestRedraw(e)},_updatePath:function(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)},_updateStyle:function(e){this._updateDashArray(e),this._requestRedraw(e)},_updateDashArray:function(e){if(typeof e.options.dashArray==`string`){for(var t=e.options.dashArray.split(/[, ]+/),n=[],r,i=0;i<t.length;i++){if(r=Number(t[i]),isNaN(r))return;n.push(r)}e.options._dashArray=n}else e.options._dashArray=e.options.dashArray},_requestRedraw:function(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest=this._redrawRequest||T(this._redraw,this))},_extendRedrawBounds:function(e){if(e._pxBounds){var t=(e.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new P,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var e=this._redrawBounds;if(e){var t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var e,t=this._redrawBounds;if(this._ctx.save(),t){var n=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,n.x,n.y),this._ctx.clip()}this._drawing=!0;for(var r=this._drawFirst;r;r=r.next)e=r.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(e,t){if(this._drawing){var n,r,i,a,o=e._parts,s=o.length,c=this._ctx;if(s){for(c.beginPath(),n=0;n<s;n++){for(r=0,i=o[n].length;r<i;r++)a=o[n][r],c[r?`lineTo`:`moveTo`](a.x,a.y);t&&c.closePath()}this._fillStroke(c,e)}}},_updateCircle:function(e){if(this._drawing&&!e._empty()){var t=e._point,n=this._ctx,r=Math.max(Math.round(e._radius),1),i=(Math.max(Math.round(e._radiusY),1)||r)/r;i!==1&&(n.save(),n.scale(1,i)),n.beginPath(),n.arc(t.x,t.y/i,r,0,Math.PI*2,!1),i!==1&&n.restore(),this._fillStroke(n,e)}},_fillStroke:function(e,t){var n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor||n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.setLineDash&&e.setLineDash(t.options&&t.options._dashArray||[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())},_onClick:function(e){for(var t=this._map.mouseEventToLayerPoint(e),n,r,i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)},_onMouseMove:function(e){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var t=this._map.mouseEventToLayerPoint(e);this._handleMouseHover(e,t)}},_handleMouseOut:function(e){var t=this._hoveredLayer;t&&(vt(this._container,`leaflet-interactive`),this._fireEvent([t],e,`mouseout`),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(e,t){if(!this._mouseHoverThrottled){for(var n,r,a=this._drawFirst;a;a=a.next)n=a.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handleMouseOut(e),r&&(_t(this._container,`leaflet-interactive`),this._fireEvent([r],e,`mouseover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._mouseHoverThrottled=!0,setTimeout(i(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)},_bringToFront:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}},_bringToBack:function(e){var t=e._order;if(t){var n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}}});function Ur(e){return W.canvas?new Hr(e):null}var Wr=(function(){try{return document.namespaces.add(`lvml`,`urn:schemas-microsoft-com:vml`),function(e){return document.createElement(`<lvml:`+e+` class="lvml">`)}}catch{}return function(e){return document.createElement(`<`+e+` xmlns="urn:schemas-microsoft.com:vml" class="lvml">`)}})(),Gr={_initContainer:function(){this._container=dt(`div`,`leaflet-vml-container`)},_update:function(){this._map._animatingZoom||(Vr.prototype._update.call(this),this.fire(`update`))},_initPath:function(e){var t=e._container=Wr(`shape`);_t(t,`leaflet-vml-shape `+(this.options.className||``)),t.coordsize=`1 1`,e._path=Wr(`path`),t.appendChild(e._path),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){var t=e._container;this._container.appendChild(t),e.options.interactive&&e.addInteractiveTarget(t)},_removePath:function(e){var t=e._container;ft(t),e.removeInteractiveTarget(t),delete this._layers[o(e)]},_updateStyle:function(e){var t=e._stroke,n=e._fill,r=e.options,i=e._container;i.stroked=!!r.stroke,i.filled=!!r.fill,r.stroke?(t||=e._stroke=Wr(`stroke`),i.appendChild(t),t.weight=r.weight+`px`,t.color=r.color,t.opacity=r.opacity,r.dashArray?t.dashStyle=_(r.dashArray)?r.dashArray.join(` `):r.dashArray.replace(/( *, *)/g,` `):t.dashStyle=``,t.endcap=r.lineCap.replace(`butt`,`flat`),t.joinstyle=r.lineJoin):t&&(i.removeChild(t),e._stroke=null),r.fill?(n||=e._fill=Wr(`fill`),i.appendChild(n),n.color=r.fillColor||r.color,n.opacity=r.fillOpacity):n&&(i.removeChild(n),e._fill=null)},_updateCircle:function(e){var t=e._point.round(),n=Math.round(e._radius),r=Math.round(e._radiusY||n);this._setPath(e,e._empty()?`M0 0`:`AL `+t.x+`,`+t.y+` `+n+`,`+r+` 0,23592600`)},_setPath:function(e,t){e._path.v=t},_bringToFront:function(e){mt(e._container)},_bringToBack:function(e){ht(e._container)}},Kr=W.vml?Wr:ue,qr=Vr.extend({_initContainer:function(){this._container=Kr(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=Kr(`g`),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ft(this._container),zt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vr.prototype._update.call(this);var e=this._bounds,t=e.getSize(),n=this._container;this._svgSize&&this._svgSize.equals(t)||(this._svgSize=t,n.setAttribute(`width`,t.x),n.setAttribute(`height`,t.y)),$(n,e.min),n.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}},_initPath:function(e){var t=e._path=Kr(`path`);e.options.className&&_t(t,e.options.className),e.options.interactive&&_t(t,`leaflet-interactive`),this._updateStyle(e),this._layers[o(e)]=e},_addPath:function(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)},_removePath:function(e){ft(e._path),e.removeInteractiveTarget(e._path),delete this._layers[o(e)]},_updatePath:function(e){e._project(),e._update()},_updateStyle:function(e){var t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,n.opacity),t.setAttribute(`stroke-width`,n.weight),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,n.fillOpacity),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))},_updatePoly:function(e,t){this._setPath(e,de(e._parts,t))},_updateCircle:function(e){var t=e._point,n=Math.max(Math.round(e._radius),1),r=Math.max(Math.round(e._radiusY),1)||n,i=`a`+n+`,`+r+` 0 1,0 `,a=e._empty()?`M0 0`:`M`+(t.x-n)+`,`+t.y+i+n*2+`,0 `+i+-n*2+`,0 `;this._setPath(e,a)},_setPath:function(e,t){e._path.setAttribute(`d`,t)},_bringToFront:function(e){mt(e._path)},_bringToBack:function(e){ht(e._path)}});W.vml&&qr.include(Gr);function Jr(e){return W.svg||W.vml?new qr(e):null}nn.include({getRenderer:function(e){var t=e.options.renderer||this._getPaneRenderer(e.options.pane)||this.options.renderer||this._renderer;return t||=this._renderer=this._createRenderer(),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(e){if(e===`overlayPane`||e===void 0)return!1;var t=this._paneRenderers[e];return t===void 0&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer:function(e){return this.options.preferCanvas&&Ur(e)||Jr(e)}});var Yr=cr.extend({initialize:function(e,t){cr.prototype.initialize.call(this,this._boundsToLatLngs(e),t)},setBounds:function(e){return this.setLatLngs(this._boundsToLatLngs(e))},_boundsToLatLngs:function(e){return e=I(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}});function Xr(e,t){return new Yr(e,t)}qr.create=Kr,qr.pointsToPath=de,ur.geometryToLayer=dr,ur.coordsToLatLng=pr,ur.coordsToLatLngs=mr,ur.latLngToCoords=hr,ur.latLngsToCoords=gr,ur.getFeature=_r,ur.asFeature=vr,nn.mergeOptions({boxZoom:!0});var Zr=mn.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane,this._resetStateTimeout=0,e.on(`unload`,this._destroy,this)},addHooks:function(){Lt(this._container,`mousedown`,this._onMouseDown,this)},removeHooks:function(){zt(this._container,`mousedown`,this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ft(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(e){if(!e.shiftKey||e.which!==1&&e.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),wt(),Ot(),this._startPoint=this._map.mouseEventToContainerPoint(e),Lt(document,{contextmenu:Jt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=dt(`div`,`leaflet-zoom-box`,this._container),_t(this._container,`leaflet-crosshair`),this._map.fire(`boxzoomstart`)),this._point=this._map.mouseEventToContainerPoint(e);var t=new P(this._point,this._startPoint),n=t.getSize();$(this._box,t.min),this._box.style.width=n.x+`px`,this._box.style.height=n.y+`px`},_finish:function(){this._moved&&(ft(this._box),vt(this._container,`leaflet-crosshair`)),Tt(),kt(),zt(document,{contextmenu:Jt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(e){if((e.which===1||e.button===1)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(i(this._resetState,this),0);var t=new te(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire(`boxzoomend`,{boxZoomBounds:t})}},_onKeyDown:function(e){e.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});nn.addInitHook(`addHandler`,`boxZoom`,Zr),nn.mergeOptions({doubleClickZoom:!0});var Qr=mn.extend({addHooks:function(){this._map.on(`dblclick`,this._onDoubleClick,this)},removeHooks:function(){this._map.off(`dblclick`,this._onDoubleClick,this)},_onDoubleClick:function(e){var t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}});nn.addInitHook(`addHandler`,`doubleClickZoom`,Qr),nn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var $r=mn.extend({addHooks:function(){if(!this._draggable){var e=this._map;this._draggable=new _n(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on(`predrag`,this._onPreDragWrap,this),e.on(`zoomend`,this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}_t(this._map._container,`leaflet-grab leaflet-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){vt(this._map._container,`leaflet-grab`),vt(this._map._container,`leaflet-touch-drag`),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var t=I(this._map.options.maxBounds);this._offsetLimit=F(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire(`movestart`).fire(`dragstart`),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var t=this._lastTime=+new Date,n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(t),this._prunePositions(t)}this._map.fire(`move`,e).fire(`drag`,e)},_prunePositions:function(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(e,t){return e-(e-t)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}},_onPreDragWrap:function(){var e=this._worldWidth,t=Math.round(e/2),n=this._initialWorldOffset,r=this._draggable._newPos.x,i=(r-t+n)%e+t-n,a=(r+t+n)%e-t-n,o=Math.abs(i+n)<Math.abs(a+n)?i:a;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=o},_onDragEnd:function(e){var t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(+new Date);var i=this._lastPos.subtract(this._positions[0]),a=(this._lastTime-this._times[0])/1e3,o=n.easeLinearity,s=i.multiplyBy(o/a),c=s.distanceTo([0,0]),l=Math.min(n.inertiaMaxSpeed,c),u=s.multiplyBy(l/c),d=l/(n.inertiaDeceleration*o),f=u.multiplyBy(-d/2).round();!f.x&&!f.y?t.fire(`moveend`):(f=t._limitOffset(f,t.options.maxBounds),T(function(){t.panBy(f,{duration:d,easeLinearity:o,noMoveStart:!0,animate:!0})}))}}});nn.addInitHook(`addHandler`,`dragging`,$r),nn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var ei=mn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(e){this._map=e,this._setPanDelta(e.options.keyboardPanDelta),this._setZoomDelta(e.options.zoomDelta)},addHooks:function(){var e=this._map._container;e.tabIndex<=0&&(e.tabIndex=`0`),Lt(e,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),zt(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var e=document.body,t=document.documentElement,n=e.scrollTop||t.scrollTop,r=e.scrollLeft||t.scrollLeft;this._map._container.focus(),window.scrollTo(r,n)}},_onFocus:function(){this._focused=!0,this._map.fire(`focus`)},_onBlur:function(){this._focused=!1,this._map.fire(`blur`)},_setPanDelta:function(e){for(var t=this._panKeys={},n=this.keyCodes,r=0,i=n.left.length;r<i;r++)t[n.left[r]]=[-1*e,0];for(r=0,i=n.right.length;r<i;r++)t[n.right[r]]=[e,0];for(r=0,i=n.down.length;r<i;r++)t[n.down[r]]=[0,e];for(r=0,i=n.up.length;r<i;r++)t[n.up[r]]=[0,-1*e]},_setZoomDelta:function(e){for(var t=this._zoomKeys={},n=this.keyCodes,r=0,i=n.zoomIn.length;r<i;r++)t[n.zoomIn[r]]=e;for(r=0,i=n.zoomOut.length;r<i;r++)t[n.zoomOut[r]]=-e},_addHooks:function(){Lt(document,`keydown`,this._onKeyDown,this)},_removeHooks:function(){zt(document,`keydown`,this._onKeyDown,this)},_onKeyDown:function(e){if(!(e.altKey||e.ctrlKey||e.metaKey)){var t=e.keyCode,n=this._map,r;if(t in this._panKeys){if(!n._panAnim||!n._panAnim._inProgress){if(r=this._panKeys[t],e.shiftKey&&(r=N(r).multiplyBy(3)),n.options.maxBounds&&(r=n._limitOffset(N(r),n.options.maxBounds)),n.options.worldCopyJump){var i=n.wrapLatLng(n.unproject(n.project(n.getCenter()).add(r)));n.panTo(i)}else n.panBy(r)}}else if(t in this._zoomKeys)n.setZoom(n.getZoom()+(e.shiftKey?3:1)*this._zoomKeys[t]);else if(t===27&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup();else return;Jt(e)}}});nn.addInitHook(`addHandler`,`keyboard`,ei),nn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ti=mn.extend({addHooks:function(){Lt(this._map._container,`wheel`,this._onWheelScroll,this),this._delta=0},removeHooks:function(){zt(this._map._container,`wheel`,this._onWheelScroll,this)},_onWheelScroll:function(e){var t=Qt(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._startTime||=+new Date;var r=Math.max(n-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(i(this._performZoom,this),r),Jt(e)},_performZoom:function(){var e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap||0;e._stop();var r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._limitZoom(t+(this._delta>0?a:-a))-t;this._delta=0,this._startTime=null,o&&(e.options.scrollWheelZoom===`center`?e.setZoom(t+o):e.setZoomAround(this._lastMousePos,t+o))}});nn.addInitHook(`addHandler`,`scrollWheelZoom`,ti);var ni=600;nn.mergeOptions({tapHold:W.touchNative&&W.safari&&W.mobile,tapTolerance:15});var ri=mn.extend({addHooks:function(){Lt(this._map._container,`touchstart`,this._onDown,this)},removeHooks:function(){zt(this._map._container,`touchstart`,this._onDown,this)},_onDown:function(e){if(clearTimeout(this._holdTimeout),e.touches.length===1){var t=e.touches[0];this._startPos=this._newPos=new j(t.clientX,t.clientY),this._holdTimeout=setTimeout(i(function(){this._cancel(),this._isTapValid()&&(Lt(document,`touchend`,qt),Lt(document,`touchend touchcancel`,this._cancelClickPrevent),this._simulateEvent(`contextmenu`,t))},this),ni),Lt(document,`touchend touchcancel contextmenu`,this._cancel,this),Lt(document,`touchmove`,this._onMove,this)}},_cancelClickPrevent:function e(){zt(document,`touchend`,qt),zt(document,`touchend touchcancel`,e)},_cancel:function(){clearTimeout(this._holdTimeout),zt(document,`touchend touchcancel contextmenu`,this._cancel,this),zt(document,`touchmove`,this._onMove,this)},_onMove:function(e){var t=e.touches[0];this._newPos=new j(t.clientX,t.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(e,t){var n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}});nn.addInitHook(`addHandler`,`tapHold`,ri),nn.mergeOptions({touchZoom:W.touch,bounceAtZoomLimits:!0});var ii=mn.extend({addHooks:function(){_t(this._map._container,`leaflet-touch-zoom`),Lt(this._map._container,`touchstart`,this._onTouchStart,this)},removeHooks:function(){vt(this._map._container,`leaflet-touch-zoom`),zt(this._map._container,`touchstart`,this._onTouchStart,this)},_onTouchStart:function(e){var t=this._map;if(!(!e.touches||e.touches.length!==2||t._animatingZoom||this._zooming)){var n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.touchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(n.add(r)._divideBy(2))),this._startDist=n.distanceTo(r),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),Lt(document,`touchmove`,this._onTouchMove,this),Lt(document,`touchend touchcancel`,this._onTouchEnd,this),qt(e)}},_onTouchMove:function(e){if(e.touches&&e.touches.length===2&&this._zooming){var t=this._map,n=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]),a=n.distanceTo(r)/this._startDist;if(this._zoom=t.getScaleZoom(a,this._startZoom),!t.options.bounceAtZoomLimits&&(this._zoom<t.getMinZoom()&&a<1||this._zoom>t.getMaxZoom()&&a>1)&&(this._zoom=t._limitZoom(this._zoom)),t.options.touchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{var o=n._add(r)._divideBy(2)._subtract(this._centerPoint);if(a===1&&o.x===0&&o.y===0)return;this._center=t.unproject(t.project(this._pinchStartLatLng,this._zoom).subtract(o),this._zoom)}this._moved||=(t._moveStart(!0,!1),!0),E(this._animRequest);var s=i(t._move,t,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=T(s,this,!0),qt(e)}},_onTouchEnd:function(){!this._moved||!this._zooming?this._zooming=!1:(this._zooming=!1,E(this._animRequest),zt(document,`touchmove`,this._onTouchMove,this),zt(document,`touchend touchcancel`,this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}});nn.addInitHook(`addHandler`,`touchZoom`,ii),nn.BoxZoom=Zr,nn.DoubleClickZoom=Qr,nn.Drag=$r,nn.Keyboard=ei,nn.ScrollWheelZoom=ti,nn.TapHold=ri,nn.TouchZoom=ii,e.Bounds=P,e.Browser=W,e.CRS=ne,e.Canvas=Hr,e.Circle=ir,e.CircleMarker=nr,e.Class=O,e.Control=an,e.DivIcon=Nr,e.DivOverlay=Or,e.DomEvent=en,e.DomUtil=It,e.Draggable=_n,e.Evented=ee,e.FeatureGroup=qn,e.GeoJSON=ur,e.GridLayer=Fr,e.Handler=mn,e.Icon=Yn,e.ImageOverlay=Sr,e.LatLng=R,e.LatLngBounds=te,e.Layer=Wn,e.LayerGroup=Gn,e.LineUtil=Ln,e.Map=nn,e.Marker=$n,e.Mixin=hn,e.Path=tr,e.Point=j,e.PolyUtil=xn,e.Polygon=cr,e.Polyline=or,e.Popup=kr,e.PosAnimation=tn,e.Projection=Bn,e.Rectangle=Yr,e.Renderer=Vr,e.SVG=qr,e.SVGOverlay=Er,e.TileLayer=Lr,e.Tooltip=jr,e.Transformation=oe,e.Util=D,e.VideoOverlay=wr,e.bind=i,e.bounds=F,e.canvas=Ur,e.circle=ar,e.circleMarker=rr,e.control=on,e.divIcon=Pr,e.extend=n,e.featureGroup=Jn,e.geoJSON=br,e.geoJson=xr,e.gridLayer=Ir,e.icon=Xn,e.imageOverlay=Cr,e.latLng=z,e.latLngBounds=I,e.layerGroup=Kn,e.map=rn,e.marker=er,e.point=N,e.polygon=lr,e.polyline=sr,e.popup=Ar,e.rectangle=Xr,e.setOptions=p,e.stamp=o,e.svg=Jr,e.svgOverlay=Dr,e.tileLayer=Rr,e.tooltip=Mr,e.transformation=se,e.version=t,e.videoOverlay=Tr;var ai=window.L;e.noConflict=function(){return window.L=ai,this},window.L=e}))}))(),1);function yl({places:e,selected:t,onPick:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(n);o.current=n,(0,v.useEffect)(()=>{if(!r.current)return;let e=vl.default.map(r.current,{zoomControl:!0,attributionControl:!0}).setView([46.8,8.2],7);vl.default.tileLayer(`https://tile.openstreetmap.org/{z}/{x}/{y}.png`,{maxZoom:19,attribution:`&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">OpenStreetMap</a>`}).addTo(e),a.current=vl.default.layerGroup().addTo(e),i.current=e;let t=new ResizeObserver(()=>e.invalidateSize());return t.observe(r.current),()=>{t.disconnect(),e.remove(),i.current=null}},[]);let s=e.map(e=>`${e.slug}@${e.lat},${e.lng}`).join(`|`);return(0,v.useEffect)(()=>{let n=i.current,r=a.current;if(!n||!r)return;r.clearLayers();let s=getComputedStyle(document.documentElement).getPropertyValue(`--color-accent`).trim()||`#2563eb`;for(let n of e){let e=n.slug===t;vl.default.circleMarker([n.lat,n.lng],{radius:e?10:7,weight:2,color:`#fff`,fillColor:e?s:`#be123c`,fillOpacity:1}).bindTooltip(n.title,{direction:`top`,offset:[0,-8],permanent:e}).on(`click`,()=>o.current(n.slug)).addTo(r).getElement()?.setAttribute(`data-place`,n.slug)}let c=e.find(e=>e.slug===t);c?n.flyTo([c.lat,c.lng],Math.max(n.getZoom(),15),{duration:.6}):e.length===1?n.setView([e[0].lat,e[0].lng],14):e.length>1&&n.fitBounds(vl.default.latLngBounds(e.map(e=>[e.lat,e.lng])),{padding:[32,32],maxZoom:15})},[s,t]),(0,I.jsx)(`div`,{ref:r,className:`places-map size-full min-h-[240px] overflow-hidden rounded-lg border border-line`,role:`region`,"aria-label":`map of the places`})}var bl=e=>e.slice(0,10),xl=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Sl=e=>new Date(Number(e.slice(0,4)),Number(e.slice(5,7))-1,1),Cl=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function wl({events:e,selected:t,onPick:n}){let r=e.find(e=>e.slug===t),[i,a]=(0,v.useState)(()=>Sl(r?r.start:xl(new Date)));(0,v.useEffect)(()=>{r&&a(Sl(r.start))},[r?.slug,r?.start]);let o=new Date(i),s=(o.getDay()+6)%7,c=new Date(o.getFullYear(),o.getMonth(),1-s),l=new Date(o.getFullYear(),o.getMonth()+1,0).getDate(),u=Math.ceil((s+l)/7),d=Array.from({length:u*7},(e,t)=>new Date(c.getFullYear(),c.getMonth(),c.getDate()+t)),f=xl(new Date),p=t=>e.filter(e=>bl(e.start)<=t&&t<=bl(e.end||e.start)).sort((e,t)=>e.start.localeCompare(t.start)),m=e.filter(e=>bl(e.start)<=xl(d[d.length-1])&&bl(e.end||e.start)>=xl(d[0])).length,h=e=>a(new Date(i.getFullYear(),i.getMonth()+e,1));return(0,I.jsxs)(`div`,{className:`events-calendar flex min-h-0 flex-1 flex-col gap-2`,role:`region`,"aria-label":`calendar of the events`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,I.jsxs)(`h3`,{className:`m-0 flex-1 text-base font-semibold text-fg`,"aria-live":`polite`,children:[i.toLocaleDateString([],{month:`long`,year:`numeric`}),(0,I.jsxs)(`span`,{className:`ms-2 text-xs font-normal text-fg-2`,children:[m,` event`,m===1?``:`s`]})]}),(0,I.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded-full px-2.5 py-1 text-xs text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>a(Sl(f)),children:`today`}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`previous month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(-1),children:(0,I.jsx)(R,{name:`chevron_left`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`next month`,className:`grid size-7 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>h(1),children:(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm`})})]}),(0,I.jsx)(`div`,{className:`grid flex-none grid-cols-7 text-center text-2xs tracking-wide text-fg-2 uppercase`,children:Cl.map(e=>(0,I.jsx)(`span`,{children:e},e))}),(0,I.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 overflow-y-auto rounded-lg border border-line bg-line`,style:{gridTemplateRows:`repeat(${u}, minmax(44px, 1fr))`,gap:1},children:d.map(e=>{let r=xl(e),a=p(r),o=e.getMonth()!==i.getMonth();return(0,I.jsxs)(`div`,{"data-day":r,className:P(`flex min-h-0 min-w-0 flex-col gap-px overflow-hidden bg-surface p-0.5`,o&&`bg-[color-mix(in_srgb,var(--color-surface-2)_35%,var(--color-surface))]`),children:[(0,I.jsx)(`span`,{className:P(`self-end px-1 text-2xs tabular-nums`,o?`text-fg-2/60`:`text-fg-2`,r===f&&`rounded-full bg-accent px-1.5 font-semibold text-on-accent`),children:e.getDate()}),a.slice(0,4).map(e=>{let i=bl(e.start)===r&&e.start.length>10?e.start.slice(11,16):``;return(0,I.jsxs)(`button`,{type:`button`,"data-event":e.slug,"aria-pressed":e.slug===t,title:`${e.title} · ${e.start.replace(`T`,` `)}${e.end?`–${e.end.replace(`T`,` `)}`:``}`,className:P(`block w-full cursor-pointer truncate rounded px-1 text-left text-2xs leading-4`,e.slug===t?`bg-accent text-on-accent`:`bg-[color-mix(in_srgb,#a16207_16%,var(--color-surface))] text-fg hover:brightness-95`),onClick:()=>n(e.slug),children:[i&&(0,I.jsx)(`span`,{className:`me-1 tabular-nums opacity-70`,children:i}),e.title]},e.slug)}),a.length>4&&(0,I.jsxs)(`span`,{className:`px-1 text-2xs text-fg-2`,children:[`+`,a.length-4,` more`]})]},r)})})]})}var Tl=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),El=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,Dl=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,Ol=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function kl({here:e,onClick:t,children:n}){return(0,I.jsx)(`button`,{type:`button`,onClick:t,className:P(`cursor-pointer rounded-md border-0 bg-transparent px-1 py-0.5 font-[inherit] hover:bg-surface-2 hover:text-fg`,e?`font-semibold text-fg`:`text-fg-2`),children:n})}function Al(e){if(e.type===`dir`)return`folder`;let t=e.mime??``;return t.startsWith(`image/`)?`image`:t===`application/pdf`?`picture_as_pdf`:t.startsWith(`video/`)?`movie`:t.startsWith(`audio/`)?`music_note`:/csv|tab-separated|spreadsheet/.test(t)?`table`:/zip/.test(t)?`folder_zip`:/presentation/.test(t)?`slideshow`:t.startsWith(`text/`)||/json|yaml|xml|wordprocessing/.test(t)?`description`:`draft`}function jl({scope:e,dir:t,file:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(0);(0,v.useEffect)(()=>{A.call(`files.scopes`).then(e=>i(e.scopes),()=>i([]))},[a]);let s=(r??[]).filter(e=>e.scope!==`workspace`);return(0,I.jsxs)(`div`,{className:`runs-screen files-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`files`}),(0,I.jsxs)(Ot,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,I.jsx)(Ml,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,I.jsx)(Et,{title:`projects`,divided:!0}),s.map(t=>(0,I.jsx)(Ml,{s:t,active:e===t.scope,icon:`folder_special`},t.scope))]})]}),(0,I.jsx)(`div`,{className:`runs-main min-w-0`,children:(0,I.jsx)(Nl,{scope:e,dir:t,file:n,onOpen:(t,n)=>H(El(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function Ml({s:e,active:t,icon:n}){return(0,I.jsx)(mt,{href:El(e.scope),active:t,size:`sm`,leading:(0,I.jsx)(R,{name:n,className:`ms-sm`}),title:e.label,sub:(0,I.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function Nl({scope:e,dir:t,file:n,onOpen:r,onChanged:i,compact:a=!1}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(null),x=(0,v.useRef)(null),S=(0,v.useCallback)(async()=>{let n=await A.request(`files.list`,{query:{scope:e,path:t}}).catch(()=>null);!n?.ok||!n.data||typeof n.data!=`object`?(l(n?.error??`could not load the folder`),s(null)):(l(``),s(n.data))},[e,t]);(0,v.useEffect)(()=>{S();let e=setInterval(()=>void S(),1e4);return()=>clearInterval(e)},[S]);let C=async()=>{await S(),i?.()};async function w(n){let r=[...n];if(r.length){l(``);for(let[n,i]of r.entries()){d(r.length>1?`uploading ${n+1} of ${r.length}…`:`uploading ${i.name}…`);let a=await A.request(`files.upload`,{query:{scope:e,path:t},headers:{"x-file-name":encodeURIComponent(i.name),"content-type":i.type||`application/octet-stream`},body:i}).catch(()=>null);a?.ok||l(a?.error??`could not upload ${i.name}`)}d(``),await C()}}async function T(n){let r=n.trim();if(h(null),!r)return;let i=M(await A.request(`files.mkdir`,{body:{scope:e,path:t?`${t}/${r}`:r}}));i&&l(i),await C()}async function E(i,a){_(null);let o=a.trim();if(!o||o===i.split(`/`).pop())return;let s=i.includes(`/`)?`${i.slice(0,i.lastIndexOf(`/`))}/${o}`:o,c=M(await A.request(`files.move`,{body:{scope:e,from:i,to:s}}));c?l(c):n===i&&r(t,s),await C()}async function D(i){b(null);let a=await A.request(`files.delete`,{query:{scope:e,path:i}}).catch(()=>null);a?.ok||l(a?.error??`could not delete`),n===i&&r(t),await C()}let O=t?t.split(`/`):[],k=n?o?.entries.find(e=>e.path===n):void 0,ee=!(a&&n);return(0,I.jsxs)(`div`,{className:P(`files-browser h-full min-h-0`,a?`flex flex-col gap-2 px-1.5 py-1`:P(`grid gap-4`,n?`grid-cols-1 min-[900px]:grid-cols-[minmax(280px,1fr)_minmax(0,1.3fr)]`:`grid-cols-1`)),children:[ee&&(0,I.jsxs)(`div`,{className:P(`flex min-h-0 flex-col rounded-card outline-2 -outline-offset-2 outline-dashed transition-colors`,f?`bg-accent/5 outline-accent`:`outline-transparent`),onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||p(!1)},onDrop:e=>{e.preventDefault(),p(!1),w(e.dataTransfer.files)},children:[(0,I.jsxs)(`div`,{className:P(`flex items-center gap-1`,a?`px-1 pb-1.5 pt-0.5`:`px-0.5 pb-2.5 pt-1`),children:[(0,I.jsxs)(`nav`,{className:P(`flex min-w-0 flex-wrap items-center`,a?`text-sm`:`text-md`),"aria-label":`Folder`,children:[(0,I.jsx)(kl,{here:!O.length,onClick:()=>r(``),children:o?.label??(e===`workspace`?`Workspace`:e.replace(/^project:/,``))}),O.map((e,t)=>(0,I.jsxs)(`span`,{className:`inline-flex items-center text-fg-2`,children:[(0,I.jsx)(R,{name:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(kl,{here:t===O.length-1,onClick:()=>r(O.slice(0,t+1).join(`/`)),children:e})]},t))]}),(0,I.jsx)(`span`,{className:`flex-1`}),a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,I.jsx)(K,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`upload`,onClick:()=>x.current?.click(),title:`Upload files`,children:`upload`})]}),(0,I.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`Upload files`,onChange:e=>e.target.files&&void w(e.target.files)})]}),u&&(0,I.jsx)(tt,{children:u}),c&&(0,I.jsx)(tt,{tone:`bad`,children:c}),(0,I.jsxs)(`div`,{className:`files-list flex min-h-0 flex-1 flex-col gap-px overflow-y-auto`,role:`list`,children:[m!==null&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,I.jsx)(R,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,I.jsx)(Z,{className:`h-8`,autoFocus:!0,value:m,placeholder:`folder name`,"aria-label":`Folder name`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(m),e.key===`Escape`&&h(null)},onBlur:()=>void T(m)})]}),o?.entries.map(i=>g?.path===i.path?(0,I.jsxs)(`div`,{role:`listitem`,className:`flex items-center gap-2.5 px-2.5 py-1`,children:[(0,I.jsx)(R,{name:Al(i),className:`text-[20px] text-fg-2`}),(0,I.jsx)(Z,{className:`h-8`,autoFocus:!0,value:g.name,"aria-label":`New name`,onChange:e=>_({path:i.path,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E(i.path,g.name),e.key===`Escape`&&_(null)},onBlur:()=>void E(i.path,g.name)})]},i.path):(0,I.jsx)(`div`,{role:`listitem`,children:(0,I.jsx)(mt,{className:`files-row`,active:i.path===n,onClick:()=>i.type===`dir`?r(i.path):r(t,i.path),label:i.name,leading:(0,I.jsx)(R,{name:Al(i),className:`text-[20px] text-fg-2`}),title:(0,I.jsx)(`span`,{className:`font-normal`,children:i.name}),titleExtra:i.local?(0,I.jsx)(`span`,{className:`text-xs font-normal text-fg-2`,title:`Over 25 MB: kept out of git, stays on this machine`,children:`local only`}):void 0,meta:(0,I.jsxs)(I.Fragment,{children:[i.type===`dir`?`${i.count??0} file${i.count===1?``:`s`}`:We(i.size??0),!a&&` · ${W(i.modifiedAt)}`]}),actions:(0,I.jsxs)(I.Fragment,{children:[i.type===`file`&&(0,I.jsx)(`a`,{className:`inline-grid size-7 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,href:Tl(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,I.jsx)(R,{name:`download`,className:`ms-sm`})}),(0,I.jsx)(K,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,I.jsx)(G,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,I.jsx)(K,{icon:`delete`,size:`sm`,label:`Delete ${i.name}`,onClick:()=>b(i.path)})]})})},i.path)),o&&o.entries.length===0&&m===null&&(0,I.jsxs)(Y,{icon:`upload_file`,action:(0,I.jsxs)(`span`,{className:`font-mono text-2xs opacity-80`,children:[o.root,`/`,t?`${t}/`:``]}),children:[`Drop files here, or`,` `,(0,I.jsx)(`button`,{type:`button`,className:`cursor-pointer border-0 bg-transparent p-0 font-[inherit] text-accent underline`,onClick:()=>x.current?.click(),children:`choose some`}),`.`]}),!o&&!c&&(0,I.jsx)(Y,{children:`loading…`})]})]}),n&&(0,I.jsx)(Pl,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function Pl({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=Tl(e,t),c=/^text\/|json|yaml|xml/.test(a)&&!/html/.test(a),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(u(null),!c||(n?.size??0)>2e6)return;let e=!0;return fetch(s,{cache:`no-store`}).then(e=>e.text()).then(t=>e&&u(t)).catch(()=>{}),()=>{e=!1}},[s,c,n?.size]);let d;return d=n?a.startsWith(`image/`)?(0,I.jsx)(`img`,{className:`m-auto max-h-full max-w-full flex-none object-contain p-4`,src:s,alt:o}):a===`application/pdf`?(0,I.jsx)(`iframe`,{className:P(`w-full border-0 bg-white`,i?`min-h-[60vh]`:`min-h-[70vh]`),src:s,title:o}):a.startsWith(`video/`)?(0,I.jsx)(`video`,{className:`m-auto max-h-full w-full p-4`,src:s,controls:!0}):a.startsWith(`audio/`)?(0,I.jsx)(`audio`,{className:`m-auto w-full p-4`,src:s,controls:!0}):c&&l!==null?/markdown/.test(a)?(0,I.jsx)(`div`,{className:`md-body files-md px-5 py-4`,dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,I.jsx)(Fl,{text:l,tab:/tab-separated/.test(a)}):(0,I.jsx)(`pre`,{className:`files-text m-0 whitespace-pre-wrap p-4 font-mono text-[12.5px] leading-relaxed [overflow-wrap:anywhere]`,children:l}):c&&(n.size??0)<=2e6?(0,I.jsx)(Y,{children:`loading…`}):(0,I.jsx)(Y,{icon:Al(n),action:(0,I.jsx)(G,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=Tl(e,t,!0),children:`download`}),children:`No preview for this kind of file.`}):(0,I.jsx)(Y,{children:`loading…`}),(0,I.jsxs)(`section`,{className:P(`files-preview flex min-h-0 flex-col overflow-hidden rounded-card border border-line bg-surface`,i&&`min-h-[60vh]`),"aria-label":`Preview of ${o}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-3 py-2`,children:[i&&(0,I.jsx)(K,{icon:`arrow_back`,label:`Back to the folder`,size:`sm`,onClick:r}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold`,title:t,children:o}),n?.size!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-2`,children:We(n.size)}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`a`,{className:Dl,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`})}),(0,I.jsx)(`a`,{className:Dl,href:Tl(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,I.jsx)(R,{name:`download`,className:`ms-sm`})}),!i&&(0,I.jsx)(K,{icon:`close`,label:`Close the preview`,size:`sm`,onClick:r})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-auto [&>*]:flex-1`,children:d})]})}function Fl({text:e,tab:t}){let n=t?` `:e.split(`
221
221
  `)[0].includes(`;`)&&!e.split(`
222
- `)[0].includes(`,`)?`;`:`,`,r=[];for(let t of e.split(/\r?\n/).slice(0,501)){if(!t)continue;let e=[],i=``,a=!1;for(let r=0;r<t.length;r++){let o=t[r];a&&o===`"`&&t[r+1]===`"`?(i+=`"`,r++):o===`"`?a=!a:o===n&&!a?(e.push(i),i=``):i+=o}e.push(i),r.push(e)}let[i,...a]=r;return(0,I.jsx)(`div`,{className:`overflow-auto`,children:(0,I.jsxs)(`table`,{className:`border-collapse text-[12.5px]`,children:[i&&(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:i.map((e,t)=>(0,I.jsx)(`th`,{className:P(Ol,`sticky top-0 bg-surface font-semibold`),children:e},t))})}),(0,I.jsx)(`tbody`,{children:a.map((e,t)=>(0,I.jsx)(`tr`,{children:e.map((e,t)=>(0,I.jsx)(`td`,{className:Ol,children:e},t))},t))})]})})}var Il=`modulepreload`,Ll=function(e){return`/`+e},Rl={},zl=function(e){return e.pathname.endsWith(`.css`)},Bl=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Vl=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Ll(t,n);let r=s(t),i=zl(r);return Bl(Rl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Il,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Hl=(0,v.lazy)(()=>Vl(()=>import(`./editor-CXOAhwnW.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Ul=()=>Vl(()=>import(`./editor-CXOAhwnW.js`),__vite__mapDeps([0,1,2,3,4,5,6])),Wl=encodeURIComponent,Gl=e=>e?{project:e}:{},Kl=e=>e.project?`/projects/${Wl(e.project)}/boards/${Wl(e.board)}`:`/boards/${Wl(e.board)}`,ql=(e,t)=>`${Kl(e)}/${Wl(t)}`,Jl=(e,t)=>e.order-t.order||e.number-t.number,Yl=e=>e.trim()?To(Da.sanitize(Jr.parse(e,{async:!1}))):``,Xl=()=>new Date().toISOString().slice(0,10),Zl=e=>e.find(e=>e.slug===`todo`)??e[1],Ql=e=>e.find(e=>e.done);function $l({project:e,board:t}){let n={project:e,board:t},r=Gl(e),i=N(`boards.get`,{board:t,query:r},{interval:5e3}),a=N(`agents.list`,{},{interval:6e4}),o=e=>(a?.agents??[]).find(t=>t.slug===e),[s,c]=(0,v.useState)(null),l=JSON.stringify(i?.items??null);(0,v.useEffect)(()=>c(null),[l]);let u=s??i?.items??[],[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),ee=i?.columns??[],j=new Set(ee.map(e=>e.slug)),F=u.filter(e=>!j.has(e.status)),te=[...ee.map(e=>({col:e,tasks:u.filter(t=>t.status===e.slug).sort(Jl)})),...F.length?[{col:{slug:``,label:`No column`},tasks:F.sort(Jl)}]:[]],z=[...new Set(u.map(e=>e.assignee).filter(e=>!!e))].sort(),ne=[...new Set(u.flatMap(e=>e.tags))].sort(),re=te.some(e=>e.col.done&&e.tasks.length>10),ie=w??!re,ae=_.trim().toLowerCase(),oe=e=>(!ae||`${e.title} ${e.slug} ${e.assignee??``} ${e.tags.join(` `)}`.toLowerCase().includes(ae))&&(!b||e.assignee===b)&&(!S||e.tags.includes(S)),se=!!ae||!!b||!!S,ce=(0,v.useMemo)(()=>Yl(i?.notes??``),[i?.notes]),le=async(e,n,i)=>{let a=u.find(t=>t.slug===e);if(!a||!n||i===e)return;let o=u.filter(t=>t.status===n&&t.slug!==e).sort(Jl),s=i?o.findIndex(e=>e.slug===i):-1,l=[...o];if(l.splice(s<0?o.length:s,0,{...a,status:n}),a.status===n&&l.map(e=>e.slug).join()===u.filter(e=>e.status===n).sort(Jl).map(e=>e.slug).join())return;let d=new Map(l.map((e,t)=>[e.slug,(t+1)*10]));c(u.map(e=>d.has(e.slug)?{...e,status:n,order:d.get(e.slug)}:e)),f(``);let p=await A.request(`tasks.move`,{board:t,task:e,query:r,body:{status:n,...i?{before:i}:{}}});p.ok||(f(M(p)),c(null))},ue=()=>{D(null),k(null)},de=(e,t)=>({draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.slug),D(e.slug)},onDragEnd:ue,onDragOver:n=>{if(!E||!e.status||!j.has(e.status))return;n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect=`move`;let r=n.currentTarget.getBoundingClientRect(),i=n.clientY>r.top+r.height/2,a=t.findIndex(t=>t.slug===e.slug),o=i?t[a+1]?.slug??null:e.slug;(O?.status!==e.status||O.before!==o)&&k({status:e.status,before:o})},onDrop:e=>{if(!E||!O)return;e.preventDefault(),e.stopPropagation();let{status:t,before:n}=O;ue(),le(E,t,n)}}),B=e=>({onDragOver:t=>{E&&e.slug&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,(O?.status!==e.slug||O.before!==null)&&k({status:e.slug,before:null}))},onDrop:e=>{if(!E||!O)return;e.preventDefault();let{status:t,before:n}=O;ue(),le(E,t,n)}}),V=(e,t)=>E&&O&&O.status===e&&O.before===t?(0,I.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,I.jsx)(`div`,{className:`absolute inset-x-1 -top-1 h-0.5 rounded-full bg-accent`})}):null,fe=async()=>{let n=await A.request(`boards.delete`,{board:t,query:r});if(!n.ok)return f(M(n));H(e?`/projects/${Wl(e)}`:`/boards`,{replace:!0})};return i?(0,I.jsxs)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,I.jsx)(R,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(it,{children:i.title}),(0,I.jsxs)(q,{title:`tasks on the board`,children:[i.tasks,` `,i.tasks===1?`task`:`tasks`]}),(0,I.jsx)(Qe,{n:i.review,title:`waiting for review`}),i.agent&&(0,I.jsxs)(q,{tone:`accent`,title:`tasks entering todo without an assignee go to this agent`,children:[`→ `,i.agent]}),(0,I.jsx)(`span`,{className:`flex-1`}),i.notes.trim()&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:p?`expand_less`:`gavel`,"aria-expanded":p,onClick:()=>m(e=>!e),children:`rules`}),(0,I.jsx)(K,{size:`sm`,icon:`settings`,label:`board settings: columns, default agent, rules`,href:`${Kl(n)}/settings`}),!e&&(h?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,onClick:()=>void fe(),children:`move to trash`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>g(!1),children:`cancel`})]}):(0,I.jsx)(K,{size:`sm`,icon:`delete`,label:`move the board, tasks and all, to the trash`,onClick:()=>g(!0)}))]}),i.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`board.md: `,i.configError,` — the columns show defaults; fix the file by hand.`]}),d&&(0,I.jsx)(tt,{tone:`bad`,children:d}),p&&(0,I.jsx)(X,{title:`rules`,className:`flex-none`,children:ce?(0,I.jsx)(`div`,{className:`md-body px-[18px] py-3 text-sm`,dangerouslySetInnerHTML:{__html:ce}}):(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`no rules yet — the body of board.md`})}),(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2`,children:[(0,I.jsx)(Z,{value:_,className:`h-8 w-auto min-w-[180px] text-sm`,placeholder:`filter tasks…`,"aria-label":`filter tasks`,onChange:e=>y(e.target.value)}),z.length>0&&(0,I.jsxs)(bt,{className:`h-8 w-auto text-sm`,value:b,"aria-label":`assignee`,onChange:e=>x(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`anyone`}),z.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),ne.length>0&&(0,I.jsxs)(bt,{className:`h-8 w-auto text-sm`,value:S,"aria-label":`tag`,onChange:e=>C(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`any tag`}),ne.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),se&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`close`,onClick:()=>{y(``),x(``),C(``)},children:`clear`}),(0,I.jsx)(`span`,{className:`flex-1`}),te.some(e=>e.col.done&&e.tasks.length>0)&&(0,I.jsx)($,{checked:ie,onChange:T,className:`text-xs`,children:`show finished`})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3 overflow-x-auto overflow-y-hidden pb-2`,children:te.map(({col:e,tasks:t})=>{let r=e.done&&!ie?[]:t.filter(oe),a=e.limit!==void 0&&t.length>e.limit;return(0,I.jsxs)(`section`,{className:`flex max-h-full min-w-[208px] max-w-[360px] flex-1 basis-0 flex-col rounded-card border border-line bg-surface-2`,"aria-label":e.label,"data-column":e.slug||void 0,children:[(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3 pt-2.5 pb-1.5`,children:[(0,I.jsx)(nt,{className:`truncate text-fg`,children:e.label}),(0,I.jsxs)(`span`,{className:P(`text-2xs font-semibold tabular-nums`,a?`rounded-full bg-ask-soft px-1.5 text-on-ask-soft`:`text-fg-2`),title:e.limit===void 0?`${t.length} tasks`:`${t.length} of a limit of ${e.limit}`,children:[t.length,e.limit!==void 0&&`/${e.limit}`]}),e.review&&(0,I.jsx)(R,{name:`rate_review`,className:`ms-sm text-fg-2`}),e.done&&(0,I.jsx)(R,{name:`check_circle`,className:`ms-sm text-fg-2`})]}),(0,I.jsxs)(`div`,{className:`flex min-h-[48px] flex-col gap-1.5 overflow-y-auto px-2 pb-1`,...B(e),children:[r.map(r=>(0,I.jsxs)(v.Fragment,{children:[V(e.slug,r.slug),(0,I.jsx)(eu,{at:n,task:r,agent:r.assignee?o(r.assignee):void 0,dragging:E===r.slug,...de(r,t)})]},r.slug)),V(e.slug,null),e.done&&!ie&&t.length>0&&(0,I.jsxs)(kt,{className:`px-1 py-1.5`,children:[t.length,` finished, hidden`]}),E&&(0,I.jsx)(`div`,{className:`h-6`})]}),e.slug&&!i.configError&&(0,I.jsx)(tu,{at:n,status:e.slug,onError:f})]},e.slug||`~`)})})]}):(0,I.jsx)(Y,{children:`loading…`})}function eu({at:e,task:t,agent:n,dragging:r,...i}){let a=!!t.due&&t.due.slice(0,10)<Xl();return(0,I.jsxs)(`article`,{...i,className:P(`flex cursor-grab flex-col gap-1 rounded-card border border-line bg-surface px-2.5 py-2 active:cursor-grabbing`,r&&`opacity-40`),"data-task":t.slug,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(U,{href:ql(e,t.slug),className:`min-w-0 flex-1 text-sm font-medium leading-snug text-fg no-underline [overflow-wrap:anywhere] hover:underline`,children:t.title}),(0,I.jsxs)(`span`,{className:`flex-none font-mono text-2xs text-fg-2`,children:[`#`,t.number]})]}),t.configError&&(0,I.jsx)(`span`,{className:`text-2xs text-bad`,children:`unreadable frontmatter`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-2`,children:[t.assignee?(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full bg-surface-2 px-1.5 font-medium text-fg`,title:`assigned to ${n?`${n.name} (${t.assignee})`:t.assignee}`,children:[n?.emoji?(0,I.jsx)(`span`,{"aria-hidden":!0,children:n.emoji}):(0,I.jsx)(R,{name:`person`,className:`ms-sm text-[13px]`}),n?.name??t.assignee]}):(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-fg-2 ring-1 ring-inset ring-line`,title:`nobody is assigned`,children:[(0,I.jsx)(R,{name:`person_off`,className:`ms-sm text-[13px]`}),` unassigned`]}),t.due&&(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-0.5`,a&&`text-bad`),title:a?`overdue`:`due`,children:[(0,I.jsx)(R,{name:`event`,className:`ms-sm text-[13px]`}),` `,t.due]}),t.files>0&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:`files in the task folder`,children:[(0,I.jsx)(R,{name:`attach_file`,className:`ms-sm text-[13px]`}),` `,t.files]}),t.stale&&(0,I.jsx)(q,{tone:`ask`,title:`assigned, in a work column, and nothing logged for a while`,children:`stale`})]}),t.tags.length>0&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,I.jsx)(q,{children:e},e))}),t.lastLog&&(0,I.jsx)(`div`,{className:`truncate text-2xs text-fg-2 opacity-80`,title:t.lastLog,children:t.lastLog})]})}function tu({at:e,status:t,onError:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=async()=>{let r=a.trim();if(!r||s)return;c(!0);let i=await A.request(`tasks.create`,{board:e.board,query:Gl(e.project),body:{title:r,status:t}});if(c(!1),!i.ok)return n(M(i));n(``),o(``)};return r?(0,I.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5`,children:[(0,I.jsx)(Z,{autoFocus:!0,value:a,className:`h-8 text-sm`,placeholder:`task title — Enter adds`,"aria-label":`new task in ${t}`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(i(!1),o(``))},onBlur:()=>!a.trim()&&i(!1)}),(0,I.jsx)(K,{size:`sm`,icon:`close`,label:`close`,onClick:()=>{i(!1),o(``)}})]}):(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,className:`m-1 justify-start`,onClick:()=>i(!0),children:`task`})}var nu={presentations:`slideshow`,contacts:`person`,places:`location_on`,events:`event`,projects:`folder`,knowledge:`menu_book`,workflows:`account_tree`,agents:`smart_toy`,repos:`source`,vibeables:`web`,boards:`view_kanban`,tasks:`task_alt`};function ru({refs:e,busy:t,onChange:n}){let r=Te(),i=N(`presentations.list`,r.presentations?{query:{all:`1`}}:null,{interval:3e4}),[a,o]=(0,v.useState)([]),s=e.join(`,`);(0,v.useEffect)(()=>{if(!e.length)return o([]);let t=!0;return A.request(`refs.resolve`,{body:{tokens:e}}).then(e=>t&&e.ok&&o(e.data.refs)),()=>{t=!1}},[s]);let c=(i?.presentations??[]).filter(t=>!e.includes(`presentation:${t.name}`));return!e.length&&!r.presentations?null:(0,I.jsx)(Q,{label:`links`,hint:`what this task is about: its agent gets them with the task`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`list`,"aria-label":`links`,children:[e.map(r=>{let i=a.find(e=>e.token===r);return(0,I.jsxs)(`span`,{role:`listitem`,className:`inline-flex max-w-full items-center gap-1 rounded-full border border-line bg-surface py-0.5 pl-2 pr-1 text-xs`,children:[(0,I.jsx)(R,{name:nu[i?.kind??``]??`link`,className:`ms-sm text-fg-2`}),i?.found?(0,I.jsx)(U,{href:i.href,className:`min-w-0 truncate text-fg no-underline hover:underline`,title:r,children:i.label||r}):(0,I.jsx)(`span`,{className:P(`min-w-0 truncate`,i&&`text-fg-2 line-through`),title:i?`${r} — not found`:r,children:r}),(0,I.jsx)(K,{icon:`close`,label:`unlink ${r}`,size:`sm`,disabled:t,onClick:()=>n(e.filter(e=>e!==r))})]},r)}),r.presentations&&c.length>0&&(0,I.jsxs)(bt,{value:``,"aria-label":`link a presentation`,className:`h-7 w-auto text-xs`,disabled:t,onChange:t=>t.target.value&&n([...e,t.target.value]),children:[(0,I.jsx)(`option`,{value:``,children:`+ link a presentation…`}),c.map(e=>(0,I.jsxs)(`option`,{value:`presentation:${e.name}`,children:[e.title,e.project?` · ${e.project}`:``]},`${e.project??``}/${e.name}`))]})]})})}function iu(e){let t=[],n=``;for(let r of e.split(`
222
+ `)[0].includes(`,`)?`;`:`,`,r=[];for(let t of e.split(/\r?\n/).slice(0,501)){if(!t)continue;let e=[],i=``,a=!1;for(let r=0;r<t.length;r++){let o=t[r];a&&o===`"`&&t[r+1]===`"`?(i+=`"`,r++):o===`"`?a=!a:o===n&&!a?(e.push(i),i=``):i+=o}e.push(i),r.push(e)}let[i,...a]=r;return(0,I.jsx)(`div`,{className:`overflow-auto`,children:(0,I.jsxs)(`table`,{className:`border-collapse text-[12.5px]`,children:[i&&(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:i.map((e,t)=>(0,I.jsx)(`th`,{className:P(Ol,`sticky top-0 bg-surface font-semibold`),children:e},t))})}),(0,I.jsx)(`tbody`,{children:a.map((e,t)=>(0,I.jsx)(`tr`,{children:e.map((e,t)=>(0,I.jsx)(`td`,{className:Ol,children:e},t))},t))})]})})}var Il=`modulepreload`,Ll=function(e){return`/`+e},Rl={},zl=function(e){return e.pathname.endsWith(`.css`)},Bl=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Vl=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Ll(t,n);let r=s(t),i=zl(r);return Bl(Rl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Il,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Hl=(0,v.lazy)(()=>Vl(()=>import(`./editor-D7Y97r7h.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Ul=()=>Vl(()=>import(`./editor-D7Y97r7h.js`),__vite__mapDeps([0,1,2,3,4,5,6])),Wl=encodeURIComponent,Gl=e=>e?{project:e}:{},Kl=e=>e.project?`/projects/${Wl(e.project)}/boards/${Wl(e.board)}`:`/boards/${Wl(e.board)}`,ql=(e,t)=>`${Kl(e)}/${Wl(t)}`,Jl=(e,t)=>e.order-t.order||e.number-t.number,Yl=e=>e.trim()?To(Da.sanitize(Jr.parse(e,{async:!1}))):``,Xl=()=>new Date().toISOString().slice(0,10),Zl=e=>e.find(e=>e.slug===`todo`)??e[1],Ql=e=>e.find(e=>e.done);function $l({project:e,board:t}){let n={project:e,board:t},r=Gl(e),i=N(`boards.get`,{board:t,query:r},{interval:5e3}),a=N(`agents.list`,{},{interval:6e4}),o=e=>(a?.agents??[]).find(t=>t.slug===e),[s,c]=(0,v.useState)(null),l=JSON.stringify(i?.items??null);(0,v.useEffect)(()=>c(null),[l]);let u=s??i?.items??[],[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),ee=i?.columns??[],j=new Set(ee.map(e=>e.slug)),F=u.filter(e=>!j.has(e.status)),te=[...ee.map(e=>({col:e,tasks:u.filter(t=>t.status===e.slug).sort(Jl)})),...F.length?[{col:{slug:``,label:`No column`},tasks:F.sort(Jl)}]:[]],z=[...new Set(u.map(e=>e.assignee).filter(e=>!!e))].sort(),ne=[...new Set(u.flatMap(e=>e.tags))].sort(),re=te.some(e=>e.col.done&&e.tasks.length>10),ie=w??!re,ae=_.trim().toLowerCase(),oe=e=>(!ae||`${e.title} ${e.slug} ${e.assignee??``} ${e.tags.join(` `)}`.toLowerCase().includes(ae))&&(!b||e.assignee===b)&&(!S||e.tags.includes(S)),se=!!ae||!!b||!!S,ce=(0,v.useMemo)(()=>Yl(i?.notes??``),[i?.notes]),le=async(e,n,i)=>{let a=u.find(t=>t.slug===e);if(!a||!n||i===e)return;let o=u.filter(t=>t.status===n&&t.slug!==e).sort(Jl),s=i?o.findIndex(e=>e.slug===i):-1,l=[...o];if(l.splice(s<0?o.length:s,0,{...a,status:n}),a.status===n&&l.map(e=>e.slug).join()===u.filter(e=>e.status===n).sort(Jl).map(e=>e.slug).join())return;let d=new Map(l.map((e,t)=>[e.slug,(t+1)*10]));c(u.map(e=>d.has(e.slug)?{...e,status:n,order:d.get(e.slug)}:e)),f(``);let p=await A.request(`tasks.move`,{board:t,task:e,query:r,body:{status:n,...i?{before:i}:{}}});p.ok||(f(M(p)),c(null))},ue=()=>{D(null),k(null)},de=(e,t)=>({draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.slug),D(e.slug)},onDragEnd:ue,onDragOver:n=>{if(!E||!e.status||!j.has(e.status))return;n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect=`move`;let r=n.currentTarget.getBoundingClientRect(),i=n.clientY>r.top+r.height/2,a=t.findIndex(t=>t.slug===e.slug),o=i?t[a+1]?.slug??null:e.slug;(O?.status!==e.status||O.before!==o)&&k({status:e.status,before:o})},onDrop:e=>{if(!E||!O)return;e.preventDefault(),e.stopPropagation();let{status:t,before:n}=O;ue(),le(E,t,n)}}),B=e=>({onDragOver:t=>{E&&e.slug&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,(O?.status!==e.slug||O.before!==null)&&k({status:e.slug,before:null}))},onDrop:e=>{if(!E||!O)return;e.preventDefault();let{status:t,before:n}=O;ue(),le(E,t,n)}}),V=(e,t)=>E&&O&&O.status===e&&O.before===t?(0,I.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,I.jsx)(`div`,{className:`absolute inset-x-1 -top-1 h-0.5 rounded-full bg-accent`})}):null,fe=async()=>{let n=await A.request(`boards.delete`,{board:t,query:r});if(!n.ok)return f(M(n));H(e?`/projects/${Wl(e)}`:`/boards`,{replace:!0})};return i?(0,I.jsxs)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,I.jsx)(R,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(it,{children:i.title}),(0,I.jsxs)(q,{title:`tasks on the board`,children:[i.tasks,` `,i.tasks===1?`task`:`tasks`]}),(0,I.jsx)(Qe,{n:i.review,title:`waiting for review`}),i.agent&&(0,I.jsxs)(q,{tone:`accent`,title:`tasks entering todo without an assignee go to this agent`,children:[`→ `,i.agent]}),(0,I.jsx)(`span`,{className:`flex-1`}),i.notes.trim()&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:p?`expand_less`:`gavel`,"aria-expanded":p,onClick:()=>m(e=>!e),children:`rules`}),(0,I.jsx)(K,{size:`sm`,icon:`settings`,label:`board settings: columns, default agent, rules`,href:`${Kl(n)}/settings`}),!e&&(h?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,onClick:()=>void fe(),children:`move to trash`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>g(!1),children:`cancel`})]}):(0,I.jsx)(K,{size:`sm`,icon:`delete`,label:`move the board, tasks and all, to the trash`,onClick:()=>g(!0)}))]}),i.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`board.md: `,i.configError,` — the columns show defaults; fix the file by hand.`]}),d&&(0,I.jsx)(tt,{tone:`bad`,children:d}),p&&(0,I.jsx)(X,{title:`rules`,className:`flex-none`,children:ce?(0,I.jsx)(`div`,{className:`md-body px-[18px] py-3 text-sm`,dangerouslySetInnerHTML:{__html:ce}}):(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`no rules yet — the body of board.md`})}),(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2`,children:[(0,I.jsx)(Z,{value:_,className:`h-8 w-auto min-w-[180px] text-sm`,placeholder:`filter tasks…`,"aria-label":`filter tasks`,onChange:e=>y(e.target.value)}),z.length>0&&(0,I.jsxs)(bt,{className:`h-8 w-auto text-sm`,value:b,"aria-label":`assignee`,onChange:e=>x(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`anyone`}),z.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),ne.length>0&&(0,I.jsxs)(bt,{className:`h-8 w-auto text-sm`,value:S,"aria-label":`tag`,onChange:e=>C(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`any tag`}),ne.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),se&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`close`,onClick:()=>{y(``),x(``),C(``)},children:`clear`}),(0,I.jsx)(`span`,{className:`flex-1`}),te.some(e=>e.col.done&&e.tasks.length>0)&&(0,I.jsx)($,{checked:ie,onChange:T,className:`text-xs`,children:`show finished`})]}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3 overflow-x-auto overflow-y-hidden pb-2`,children:te.map(({col:e,tasks:t})=>{let r=e.done&&!ie?[]:t.filter(oe),a=e.limit!==void 0&&t.length>e.limit;return(0,I.jsxs)(`section`,{className:`flex max-h-full min-w-[208px] max-w-[360px] flex-1 basis-0 flex-col rounded-card border border-line bg-surface-2`,"aria-label":e.label,"data-column":e.slug||void 0,children:[(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3 pt-2.5 pb-1.5`,children:[(0,I.jsx)(nt,{className:`truncate text-fg`,children:e.label}),(0,I.jsxs)(`span`,{className:P(`text-2xs font-semibold tabular-nums`,a?`rounded-full bg-ask-soft px-1.5 text-on-ask-soft`:`text-fg-2`),title:e.limit===void 0?`${t.length} tasks`:`${t.length} of a limit of ${e.limit}`,children:[t.length,e.limit!==void 0&&`/${e.limit}`]}),e.review&&(0,I.jsx)(R,{name:`rate_review`,className:`ms-sm text-fg-2`}),e.done&&(0,I.jsx)(R,{name:`check_circle`,className:`ms-sm text-fg-2`})]}),(0,I.jsxs)(`div`,{className:`flex min-h-[48px] flex-col gap-1.5 overflow-y-auto px-2 pb-1`,...B(e),children:[r.map(r=>(0,I.jsxs)(v.Fragment,{children:[V(e.slug,r.slug),(0,I.jsx)(eu,{at:n,task:r,agent:r.assignee?o(r.assignee):void 0,dragging:E===r.slug,...de(r,t)})]},r.slug)),V(e.slug,null),e.done&&!ie&&t.length>0&&(0,I.jsxs)(kt,{className:`px-1 py-1.5`,children:[t.length,` finished, hidden`]}),E&&(0,I.jsx)(`div`,{className:`h-6`})]}),e.slug&&!i.configError&&(0,I.jsx)(tu,{at:n,status:e.slug,onError:f})]},e.slug||`~`)})})]}):(0,I.jsx)(Y,{children:`loading…`})}function eu({at:e,task:t,agent:n,dragging:r,...i}){let a=!!t.due&&t.due.slice(0,10)<Xl();return(0,I.jsxs)(`article`,{...i,className:P(`flex cursor-grab flex-col gap-1 rounded-card border border-line bg-surface px-2.5 py-2 active:cursor-grabbing`,r&&`opacity-40`),"data-task":t.slug,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(U,{href:ql(e,t.slug),className:`min-w-0 flex-1 text-sm font-medium leading-snug text-fg no-underline [overflow-wrap:anywhere] hover:underline`,children:t.title}),(0,I.jsxs)(`span`,{className:`flex-none font-mono text-2xs text-fg-2`,children:[`#`,t.number]})]}),t.configError&&(0,I.jsx)(`span`,{className:`text-2xs text-bad`,children:`unreadable frontmatter`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-2xs text-fg-2`,children:[t.assignee?(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full bg-surface-2 px-1.5 font-medium text-fg`,title:`assigned to ${n?`${n.name} (${t.assignee})`:t.assignee}`,children:[n?.emoji?(0,I.jsx)(`span`,{"aria-hidden":!0,children:n.emoji}):(0,I.jsx)(R,{name:`person`,className:`ms-sm text-[13px]`}),n?.name??t.assignee]}):(0,I.jsxs)(`span`,{className:`inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-fg-2 ring-1 ring-inset ring-line`,title:`nobody is assigned`,children:[(0,I.jsx)(R,{name:`person_off`,className:`ms-sm text-[13px]`}),` unassigned`]}),t.due&&(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-0.5`,a&&`text-bad`),title:a?`overdue`:`due`,children:[(0,I.jsx)(R,{name:`event`,className:`ms-sm text-[13px]`}),` `,t.due]}),t.files>0&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,title:`files in the task folder`,children:[(0,I.jsx)(R,{name:`attach_file`,className:`ms-sm text-[13px]`}),` `,t.files]}),t.stale&&(0,I.jsx)(q,{tone:`ask`,title:`assigned, in a work column, and nothing logged for a while`,children:`stale`})]}),t.tags.length>0&&(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,I.jsx)(q,{children:e},e))}),t.lastLog&&(0,I.jsx)(`div`,{className:`truncate text-2xs text-fg-2 opacity-80`,title:t.lastLog,children:t.lastLog})]})}function tu({at:e,status:t,onError:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=async()=>{let r=a.trim();if(!r||s)return;c(!0);let i=await A.request(`tasks.create`,{board:e.board,query:Gl(e.project),body:{title:r,status:t}});if(c(!1),!i.ok)return n(M(i));n(``),o(``)};return r?(0,I.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5`,children:[(0,I.jsx)(Z,{autoFocus:!0,value:a,className:`h-8 text-sm`,placeholder:`task title — Enter adds`,"aria-label":`new task in ${t}`,disabled:s,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(i(!1),o(``))},onBlur:()=>!a.trim()&&i(!1)}),(0,I.jsx)(K,{size:`sm`,icon:`close`,label:`close`,onClick:()=>{i(!1),o(``)}})]}):(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,className:`m-1 justify-start`,onClick:()=>i(!0),children:`task`})}var nu={presentations:`slideshow`,contacts:`person`,places:`location_on`,events:`event`,projects:`folder`,knowledge:`menu_book`,workflows:`account_tree`,agents:`smart_toy`,repos:`source`,vibeables:`web`,boards:`view_kanban`,tasks:`task_alt`};function ru({refs:e,busy:t,onChange:n}){let r=Te(),i=N(`presentations.list`,r.presentations?{query:{all:`1`}}:null,{interval:3e4}),[a,o]=(0,v.useState)([]),s=e.join(`,`);(0,v.useEffect)(()=>{if(!e.length)return o([]);let t=!0;return A.request(`refs.resolve`,{body:{tokens:e}}).then(e=>t&&e.ok&&o(e.data.refs)),()=>{t=!1}},[s]);let c=(i?.presentations??[]).filter(t=>!e.includes(`presentation:${t.name}`));return!e.length&&!r.presentations?null:(0,I.jsx)(Q,{label:`links`,hint:`what this task is about: its agent gets them with the task`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`list`,"aria-label":`links`,children:[e.map(r=>{let i=a.find(e=>e.token===r);return(0,I.jsxs)(`span`,{role:`listitem`,className:`inline-flex max-w-full items-center gap-1 rounded-full border border-line bg-surface py-0.5 pl-2 pr-1 text-xs`,children:[(0,I.jsx)(R,{name:nu[i?.kind??``]??`link`,className:`ms-sm text-fg-2`}),i?.found?(0,I.jsx)(U,{href:i.href,className:`min-w-0 truncate text-fg no-underline hover:underline`,title:r,children:i.label||r}):(0,I.jsx)(`span`,{className:P(`min-w-0 truncate`,i&&`text-fg-2 line-through`),title:i?`${r} — not found`:r,children:r}),(0,I.jsx)(K,{icon:`close`,label:`unlink ${r}`,size:`sm`,disabled:t,onClick:()=>n(e.filter(e=>e!==r))})]},r)}),r.presentations&&c.length>0&&(0,I.jsxs)(bt,{value:``,"aria-label":`link a presentation`,className:`h-7 w-auto text-xs`,disabled:t,onChange:t=>t.target.value&&n([...e,t.target.value]),children:[(0,I.jsx)(`option`,{value:``,children:`+ link a presentation…`}),c.map(e=>(0,I.jsxs)(`option`,{value:`presentation:${e.name}`,children:[e.title,e.project?` · ${e.project}`:``]},`${e.project??``}/${e.name}`))]})]})})}function iu(e){let t=[],n=``;for(let r of e.split(`
223
223
  `)){let e=/^##\s+(\S+)/.exec(r);if(e){n=e[1];continue}let i=/^[*-]\s+(\d{1,2}:\d{2})\s+(.*)$/.exec(r);if(!i)continue;let a=i[2].trim(),o,s=/\s\(([^()]+)\)$/.exec(a);s&&(o=s[1],a=a.slice(0,s.index).trim()),t.push({day:n,time:i[1],text:a,...o?{actor:o}:{}})}return t}function au({project:e,board:t,task:n}){let r={project:e,board:t},i=Gl(e),a=N(`tasks.get`,{board:t,task:n,query:i},{interval:5e3}),o=N(`boards.get`,{board:t,query:i},{interval:15e3}),s=N(`agents.list`,{},{interval:3e4}),c=o?.columns??[],[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)({dir:``}),O=async e=>{f(!0),u(``);let r=h.trim(),a=await A.request(`tasks.save`,{board:t,task:n,query:i,body:{...e,...r&&(e.status||e.assignee!==void 0)?{message:r}:{}}});if(f(!1),!a.ok)return u(M(a));r&&(e.status||e.assignee!==void 0)&&g(``)},k=async(e,r)=>{f(!0),u(``);let a=await A.request(`tasks.move`,{board:t,task:n,query:i,body:{status:e,...r?{message:r}:{}}});if(f(!1),!a.ok)return u(M(a));g(``)},ee=async()=>{let e=w.trim();if(!e)return;f(!0),u(``);let r=await A.request(`tasks.log`,{board:t,task:n,query:i,body:{entry:e}});if(f(!1),!r.ok)return u(M(r));T(``)},j=async()=>{let e=await A.request(`tasks.delete`,{board:t,task:n,query:i});if(!e.ok)return u(M(e));H(Kl(r),{replace:!0})},F=async()=>{if(!a)return;f(!0),u(``);let n=e?{kind:`project`,slug:e}:{kind:`general`},r=await A.request(`chats.create`,{body:{agent:`claude`,scope:n,task:a.ref}});if(!r.ok)return f(!1),u(M(r));let i=r.data.id,o=`npx kraftwerk tasks show ${a.number}${e?` --project ${e}`:``} --board ${t}`,s=`Work on task ${a.number} ${a.title} (task:${a.slug} on board ${t}): read it with \`${o}\``,c=await A.request(`chats.message`,{id:i,body:{text:s}});if(f(!1),!c.ok)return u(M(c));H(e?`/projects/${Wl(e)}/chat/${i}`:`/agents/chats/${i}`)},[te,z]=(0,v.useState)(null),[ne,re]=(0,v.useState)(`saved`),[ie,ae]=(0,v.useState)(null),oe=(0,v.useRef)(null),se=(0,v.useRef)(null),ce=(0,v.useRef)(!1),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=a?.notes;(0,v.useEffect)(()=>{if(de===void 0||de===oe.current||se.current!==null||ue.current||ie!==null)return;let e=!0;return Ul().then(({unwrapParagraphs:t})=>{e&&(oe.current=de,ce.current=!1,z(e=>({key:(e?.key??0)+1,body:t(de)})))}),()=>{e=!1}},[de,ie]);async function B(){ue.current&&await ue.current;let e=se.current;if(e===null)return;se.current=null,re(`saving`);let r=(async()=>{let r=await A.request(`tasks.save`,{board:t,task:n,query:i,body:{notes:e},keepalive:!0});r.ok?(oe.current=r.data.notes,u(``),re(se.current===null?`saved`:`unsaved`)):(u(M(r)),re(`error`),se.current===null&&(se.current=e))})();ue.current=r,await r,ue.current=null}function V(e){ce.current&&(se.current=e,re(`unsaved`),le.current&&clearTimeout(le.current),le.current=setTimeout(()=>void B(),1e3))}(0,v.useEffect)(()=>{let e=()=>{se.current!==null&&B()};return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),le.current&&clearTimeout(le.current),se.current!==null&&B()}},[]);let fe=async()=>{if(ie===null)return;f(!0);let e=await A.request(`tasks.save`,{board:t,task:n,query:i,body:{notes:ie}});if(f(!1),!e.ok)return u(M(e));oe.current=null,ae(null)},pe=(0,v.useMemo)(()=>iu(a?.log??``),[a?.log]),me=a?.sessions??[],he=e=>{let[t,n]=e.split(`/`);return me.find(e=>e.agent===t)??(t===`kraftwerk-chat`&&n?me.find(e=>e.agent===n):void 0)},ge=(s?.agents??[]).filter(e=>!e.archived);if(!a)return(0,I.jsx)(Y,{children:`loading…`});let _e=Zl(c),ve=Ql(c),ye=c.find(e=>e.slug===a.status),be=(e,t)=>{if(t!==null){if(e===`title`){let e=t.trim();e&&e!==a.title&&O({title:e}),y(null)}else if(e===`due`){let e=t.trim();e!==(a.due??``)&&O({due:e||null}),x(null)}else{let e=t.split(`,`).map(e=>e.trim()).filter(Boolean);e.join(`,`)!==a.tags.join(`,`)&&O({tags:e}),C(null)}}},xe=e=>t=>{t.key===`Enter`&&(t.preventDefault(),e(),t.target.blur())};return(0,I.jsxs)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3 overflow-y-auto`,children:[(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,I.jsxs)(U,{href:Kl(r),className:`inline-flex items-center gap-1 text-sm text-fg-2 no-underline hover:text-fg`,title:`back to the board`,children:[(0,I.jsx)(R,{name:`arrow_back`,className:`ms-sm`}),` `,o?.title??t]}),(0,I.jsxs)(`span`,{className:`font-mono text-sm text-fg-2`,children:[`#`,a.number]}),(0,I.jsx)(Z,{value:_??a.title,"aria-label":`task title`,className:`h-auto min-w-[240px] flex-1 border-0 bg-transparent px-0 text-xl font-semibold shadow-none`,onChange:e=>y(e.target.value),onBlur:()=>be(`title`,_),onKeyDown:xe(()=>be(`title`,_))})]}),(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2 text-sm text-fg-2`,children:[(0,I.jsxs)(`code`,{className:`font-mono text-xs`,children:[`task:`,a.slug]}),(0,I.jsxs)(`span`,{children:[`created `,a.created]}),a.updatedAt&&(0,I.jsxs)(`span`,{children:[`· changed `,W(a.updatedAt)]}),a.stale&&(0,I.jsx)(q,{tone:`ask`,children:`stale`}),a.configError&&(0,I.jsx)(q,{tone:`bad`,title:a.configError,children:`unreadable frontmatter`})]}),me.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-none flex-wrap items-center gap-2 text-sm text-fg-2`,"aria-label":`sessions`,children:[(0,I.jsx)(`span`,{children:`worked on in`}),me.map(e=>(0,I.jsxs)(U,{href:e.href,className:`inline-flex items-center gap-1 rounded-full border border-line px-2 py-0.5 text-xs text-fg no-underline hover:bg-surface-2`,title:e.title||e.id,children:[e.emoji&&(0,I.jsx)(`span`,{children:e.emoji}),e.name??e.agent,(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[`· `,e.busy?`working`:W(e.updatedAt)]})]},e.id))]}),l&&(0,I.jsx)(tt,{tone:`bad`,children:l}),(0,I.jsxs)(`div`,{className:`grid flex-none grid-cols-1 items-start gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:(0,I.jsxs)(X,{title:`task`,className:`flex-none`,actions:ne!==`saved`&&(0,I.jsx)(`span`,{className:P(`text-xs`,ne===`error`?`text-bad`:`text-fg-2`),children:ne===`saving`?`saving…`:ne===`unsaved`?`unsaved`:`not saved`}),children:[(0,I.jsxs)(xt,{className:`pb-3`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`status`,children:(0,I.jsxs)(bt,{value:ye?a.status:``,"aria-label":`status`,disabled:d||!c.length,onChange:e=>e.target.value&&void O({status:e.target.value}),children:[!ye&&(0,I.jsx)(`option`,{value:``,children:a.status||`no column`}),c.map(e=>(0,I.jsx)(`option`,{value:e.slug,children:e.label},e.slug))]})}),(0,I.jsx)(Q,{label:`assignee`,children:(0,I.jsxs)(bt,{value:a.assignee??``,"aria-label":`assignee`,disabled:d,onChange:e=>void O({assignee:e.target.value||null}),children:[(0,I.jsx)(`option`,{value:``,children:`unassigned`}),a.assignee&&!ge.some(e=>e.slug===a.assignee)&&(0,I.jsx)(`option`,{value:a.assignee,children:a.assignee}),ge.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})}),(0,I.jsx)(Q,{label:`due`,children:(0,I.jsx)(Z,{type:`date`,value:b??a.due??``,"aria-label":`due date`,className:`w-auto`,onChange:e=>x(e.target.value),onBlur:()=>be(`due`,b),onKeyDown:xe(()=>be(`due`,b))})}),(0,I.jsx)(Q,{label:`tags`,className:`flex-1`,children:(0,I.jsx)(Z,{value:S??a.tags.join(`, `),placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>C(e.target.value),onBlur:()=>be(`tags`,S),onKeyDown:xe(()=>be(`tags`,S))})})]}),(0,I.jsx)(ru,{refs:a.refs,busy:d,onChange:e=>void O({refs:e})}),(0,I.jsx)(Q,{label:`note for the log`,hint:`sent with the next status or assignee change`,children:(0,I.jsx)(Z,{value:h,placeholder:`why, or what to look at (optional)`,"aria-label":`note for the log`,onChange:e=>g(e.target.value)})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(G,{variant:`primary`,icon:`chat`,busy:d,onClick:()=>void F(),title:e?`start a chat in the project about this task`:`start a chat with Ralv about this task`,children:`work on this`}),_e&&a.status!==_e.slug&&(0,I.jsxs)(G,{icon:`undo`,disabled:d,onClick:()=>{let e=h.trim()||(window.prompt(`Back to ${_e.label} — a line for the log (optional)`,``)??``);k(_e.slug,e.trim()||void 0)},children:[`back to `,_e.label]}),ve&&a.status!==ve.slug&&(0,I.jsx)(G,{icon:`check`,disabled:d,onClick:()=>void k(ve.slug,h.trim()||void 0),children:ve.label.toLowerCase()}),(0,I.jsx)(`span`,{className:`flex-1`}),p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,onClick:()=>void j(),children:`move to trash`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>m(!1),children:`cancel`})]}):(0,I.jsx)(G,{variant:`quiet`,icon:`delete`,title:`move the task folder to the trash`,onClick:()=>m(!0),children:`remove`})]})]}),ie===null?(0,I.jsxs)(`div`,{className:`task-doc border-t border-line`,onPointerDownCapture:()=>ce.current=!0,onKeyDownCapture:()=>ce.current=!0,onPasteCapture:()=>ce.current=!0,onDropCapture:()=>ce.current=!0,children:[te?(0,I.jsx)(v.Suspense,{fallback:(0,I.jsx)(J,{className:`px-[18px] py-2`,children:`loading the editor…`}),children:(0,I.jsx)(Hl,{markdown:te.body,autoFocus:!1,onChange:V,onError:()=>ae(a.notes)},te.key)}):(0,I.jsx)(J,{className:`px-[18px] py-2`,children:`loading…`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-[18px] py-1.5`,children:[(0,I.jsx)(J,{className:`flex-1`,children:`what the task is, saved as you type`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`code`,onClick:()=>ae(a.notes),children:`markdown`})]})]}):(0,I.jsxs)(`div`,{className:`border-t border-line`,children:[(0,I.jsx)(yt,{value:ie,"aria-label":`task markdown`,rows:14,className:`rounded-none border-0 font-mono text-[13px]`,onChange:e=>ae(e.target.value)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-line px-[18px] py-2`,children:[(0,I.jsx)(G,{size:`sm`,variant:`primary`,busy:d,onClick:()=>void fe(),children:`save`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>{ae(null),oe.current=null},children:`cancel`}),(0,I.jsx)(J,{children:`the body of task.md as text; the frontmatter (status, assignee, …) is the fields above`})]})]})]})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:sticky lg:top-0`,children:[(0,I.jsx)(X,{title:`files`,className:`flex-none`,actions:(0,I.jsx)(J,{children:`the task's folder: drop files on the list`}),children:(0,I.jsx)(`div`,{className:`px-2 py-1`,children:(0,I.jsx)(Nl,{compact:!0,scope:`task:${a.ref}`,dir:E.dir,file:E.file,onOpen:(e,t)=>D({dir:e,file:t})},a.ref)})}),(0,I.jsxs)(X,{title:`log`,className:`min-w-0 flex-none`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-[18px] pt-3`,children:[(0,I.jsx)(Z,{value:w,placeholder:`a comment, a question, what was done…`,"aria-label":`log entry`,disabled:d,onChange:e=>T(e.target.value),onKeyDown:xe(()=>void ee())}),(0,I.jsx)(G,{size:`sm`,icon:`send`,busy:d,disabled:!w.trim(),onClick:()=>void ee(),children:`log`})]}),pe.length===0?(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`nothing logged yet`}):(0,I.jsx)(`ol`,{className:`m-0 flex list-none flex-col px-[18px] py-3`,children:pe.map((e,t)=>(0,I.jsxs)(v.Fragment,{children:[(t===0||pe[t-1].day!==e.day)&&(0,I.jsx)(nt,{className:P(`pb-1`,t>0&&`pt-3`),children:e.day}),(0,I.jsxs)(`li`,{className:`flex items-baseline gap-3 border-l border-line py-1 pl-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`w-11 flex-none font-mono text-2xs text-fg-2`,children:e.time}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e.text}),e.actor&&(()=>{let t=he(e.actor);return t?(0,I.jsx)(U,{href:t.href,className:`flex-none text-2xs text-fg-2 underline decoration-dotted hover:text-fg`,title:`open the session ${t.name??t.agent} worked in`,children:e.actor}):(0,I.jsx)(`span`,{className:`flex-none text-2xs text-fg-2`,children:e.actor})})()]})]},t))})]})]})]})]})}function ou({project:e,board:t}){let n={project:e,board:t},r=Gl(e),i=N(`agents.list`,{},{interval:3e4}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return A.request(`boards.get`,{board:t,query:r}).then(t=>{if(!e)return;if(!t.ok)return c(M(t));let n=t.data;o(n),u(n.title),f(n.columns.map(e=>({slug:e.slug,label:e.label,limit:e.limit===void 0?``:String(e.limit),review:!!e.review,done:!!e.done}))),m(n.agent??``),g(n.staleAfter??``),y(n.notes)}),()=>{e=!1}},[t,e]);let O=()=>{x(!0),T(!1),D(``)},k=(e,t)=>{f(n=>n.map((n,r)=>r===e?{...n,...t}:n)),O()},ee=(e,t)=>{f(n=>{let r=e+t;if(r<0||r>=n.length)return n;let i=[...n];return[i[e],i[r]]=[i[r],i[e]],i}),O()},j=async()=>{C(!0),D(``);let e={title:l.trim(),columns:d.map(e=>({slug:e.slug.trim(),label:e.label.trim()||e.slug.trim(),...e.limit.trim()?{limit:Number(e.limit)}:{},...e.review?{review:!0}:{},...e.done?{done:!0}:{}})),agent:p||null,staleAfter:h.trim()||null,notes:_},n=await A.request(`boards.save`,{board:t,query:r,body:e});if(C(!1),!n.ok)return D(M(n));o(n.data),x(!1),T(!0)};if(s)return(0,I.jsx)(Y,{icon:`view_kanban`,children:s});if(!a)return(0,I.jsx)(Y,{children:`loading…`});let P=(i?.agents??[]).filter(e=>!e.archived);return(0,I.jsx)(`div`,{className:`chat-main flex min-h-0 flex-col gap-3 overflow-y-auto`,children:(0,I.jsxs)(ot,{className:`animate-none`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(U,{href:Kl(n),className:`inline-flex items-center gap-1 text-sm text-fg-2 no-underline hover:text-fg`,children:[(0,I.jsx)(R,{name:`arrow_back`,className:`ms-sm`}),` `,a.title]}),(0,I.jsx)(it,{children:`board settings`}),(0,I.jsx)(`span`,{className:`flex-1`}),E&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:E}),w&&!b&&(0,I.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,I.jsx)(G,{variant:`primary`,icon:`save`,busy:S,disabled:!b||S||!l.trim()||d.length===0,onClick:()=>void j(),children:`save`})]}),a.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`board.md: `,a.configError,` — the values below are defaults; saving overwrites the file.`]}),(0,I.jsx)(X,{title:`board`,children:(0,I.jsxs)(xt,{className:`max-w-[760px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:l,"aria-label":`board title`,onChange:e=>{u(e.target.value),O()}})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`default agent`,hint:`a task entering the pick column without an assignee goes to this agent, which is woken`,className:`flex-1`,children:(0,I.jsxs)(bt,{value:p,"aria-label":`default agent`,onChange:e=>{m(e.target.value),O()},children:[(0,I.jsx)(`option`,{value:``,children:`none`}),p&&!P.some(e=>e.slug===p)&&(0,I.jsx)(`option`,{value:p,children:p}),P.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})}),(0,I.jsx)(Q,{label:`stale after`,hint:`a task in a work column with nothing logged for this long is marked stale (default 1d)`,children:(0,I.jsx)(Z,{value:h,placeholder:`1d`,"aria-label":`stale after`,className:`w-[120px]`,onChange:e=>{g(e.target.value),O()}})})]})]})}),(0,I.jsxs)(X,{title:`columns`,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,onClick:()=>{f(e=>[...e,{slug:``,label:``,limit:``,review:!1,done:!1}]),O()},children:`column`}),children:[(0,I.jsx)(`div`,{className:`flex flex-col divide-y divide-line`,children:d.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-[18px] py-2`,"data-column-row":t,children:[(0,I.jsx)(Z,{value:e.slug,placeholder:`slug`,"aria-label":`column ${t+1} slug`,className:`h-8 w-[130px] font-mono text-xs`,onChange:e=>k(t,{slug:e.target.value})}),(0,I.jsx)(Z,{value:e.label,placeholder:`label`,"aria-label":`column ${t+1} label`,className:`h-8 w-[160px] text-sm`,onChange:e=>k(t,{label:e.target.value})}),(0,I.jsx)(Z,{value:e.limit,placeholder:`limit`,inputMode:`numeric`,"aria-label":`column ${t+1} limit`,className:`h-8 w-[70px] text-sm`,onChange:e=>k(t,{limit:e.target.value.replace(/\D/g,``)})}),(0,I.jsx)($,{checked:e.review,onChange:e=>k(t,{review:e}),className:`text-xs`,children:`review`}),(0,I.jsx)($,{checked:e.done,onChange:e=>k(t,{done:e}),className:`text-xs`,children:`done`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{size:`sm`,icon:`arrow_upward`,label:`move column ${e.label||e.slug||t+1} up`,disabled:t===0,onClick:()=>ee(t,-1)}),(0,I.jsx)(K,{size:`sm`,icon:`arrow_downward`,label:`move column ${e.label||e.slug||t+1} down`,disabled:t===d.length-1,onClick:()=>ee(t,1)}),(0,I.jsx)(K,{size:`sm`,icon:`close`,label:`remove column ${e.label||e.slug||t+1}`,onClick:()=>{f(e=>e.filter((e,n)=>n!==t)),O()}})]},t))}),(0,I.jsxs)(J,{className:`px-[18px] py-3`,children:[`In order, left to right. The first column is where drafts sit; agents pick from `,(0,I.jsx)(`code`,{children:`todo`}),` (else the second column); a `,(0,I.jsx)(`b`,{children:`review`}),` column waits for a human and counts as attention; a `,(0,I.jsx)(`b`,{children:`done`}),` column is finished work. Tasks in a removed column keep their status and show under "No column".`]})]}),(0,I.jsx)(X,{title:`rules`,children:(0,I.jsxs)(xt,{children:[(0,I.jsx)(yt,{value:_,"aria-label":`rules`,rows:8,className:`font-mono text-[13px]`,placeholder:`What the board is for and the rules agents follow — Markdown, the body of board.md`,onChange:e=>{y(e.target.value),O()}}),(0,I.jsxs)(J,{children:[`Everything here is `,(0,I.jsx)(`code`,{children:`board.md`}),` in `,(0,I.jsx)(`code`,{title:a.path,children:a.path}),`: frontmatter (title, columns, agent, stale_after) and these rules as its body. The file can be edited by hand just as well.`]})]})})]})})}function su({seg:e,project:t}){let n=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,r=e[0]===`new`,i=e[1]?decodeURIComponent(e[1]):void 0,a=N(`boards.list`,t?{query:{project:t}}:{},{interval:1e4}),o=a?.boards??[],s=t?`/projects/${Wl(t)}/boards`:`/boards`,c=e=>({...t?{project:t}:{},board:e}),l;return l=a&&!a.enabled?(0,I.jsx)(Y,{icon:`view_kanban`,children:a.error&&!/are off/.test(a.error)?(0,I.jsx)(`span`,{className:`text-bad`,children:a.error}):(0,I.jsxs)(I.Fragment,{children:[`Boards are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`boards:`}),` block to kraftwerk.yml.`]})}):a?a.error?(0,I.jsx)(Y,{icon:`view_kanban`,children:(0,I.jsx)(`span`,{className:`text-bad`,children:a.error})}):r?(0,I.jsx)(lu,{root:a.root,project:t}):!n&&t?o.length===0?(0,I.jsx)(uu,{slug:t}):(0,I.jsx)(cu,{to:Kl(c(o[0].board))}):!n&&o.length===0?(0,I.jsx)(lu,{root:a.root}):n&&i===`settings`?(0,I.jsx)(ou,{...c(n)},`${t??``}/${n}/settings`):n&&i?(0,I.jsx)(au,{...c(n),task:i},`${t??``}/${n}/${i}`):n?(0,I.jsx)($l,{...c(n)},`${t??``}/${n}`):(0,I.jsx)(Y,{icon:`view_kanban`,action:(0,I.jsx)(G,{variant:`primary`,icon:`add`,href:`${s}/new`,children:`new board`}),children:`Workspace boards: the work that belongs to no project, as columns of tasks. A project's boards live with the project.`}):(0,I.jsx)(Y,{children:`loading…`}),(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:t?`${t} · boards`:`boards`,count:a?.enabled?o.length:void 0,action:a?.enabled&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`${s}/new`,children:`new`})}),(0,I.jsxs)(Ot,{label:`boards`,children:[o.map(e=>(0,I.jsx)(mt,{href:Kl(c(e.board)),active:e.board===n,size:`sm`,leading:(0,I.jsx)(R,{name:`view_kanban`,className:`ms-sm`}),title:e.title,titleExtra:(0,I.jsx)(Qe,{n:e.review,title:`waiting for review`}),sub:e.configError?`unreadable board.md`:`${e.tasks} ${e.tasks===1?`task`:`tasks`}`,subTone:e.configError?`bad`:`plain`,meta:e.updatedAt&&(0,I.jsx)(`span`,{title:e.updatedAt,children:W(e.updatedAt)})},e.board)),a&&!a.enabled&&(0,I.jsx)(kt,{children:a.error}),a?.enabled&&o.length===0&&(0,I.jsxs)(kt,{children:[`no `,t?``:`workspace `,`boards yet`]}),t&&(0,I.jsx)(kt,{children:(0,I.jsx)(U,{href:`/projects/${Wl(t)}`,className:`text-accent`,children:`← back to the project`})})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:l})]})}function cu({to:e}){return(0,v.useEffect)(()=>H(e,{replace:!0}),[e]),(0,I.jsx)(Y,{children:`opening the board…`})}function lu({root:e,project:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{let e=n.trim();if(!e||i)return;a(!0),s(``);let r=await A.request(`boards.create`,{body:{title:e,...t?{project:t}:{}}});if(a(!1),!r.ok)return s(M(r));H(Kl({...t?{project:t}:{},board:r.data.board}),{replace:!0})};return(0,I.jsxs)(ot,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(R,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(it,{children:`new board`})]}),(0,I.jsx)(X,{children:(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),c()},children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:n,"aria-label":`board title`,autoFocus:!0,placeholder:`e.g. Marketing`,onChange:e=>r(e.target.value)})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(G,{variant:`primary`,type:`submit`,icon:`add`,busy:i,disabled:!n.trim()||i,children:`create board`}),(0,I.jsx)(G,{variant:`quiet`,href:t?`/projects/${Wl(t)}/boards`:`/boards`,children:`cancel`}),o&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:o})]}),(0,I.jsxs)(J,{children:[`One folder `,t?(0,I.jsxs)(I.Fragment,{children:[`under the project's `,(0,I.jsx)(`code`,{children:`boards/`})]}):(0,I.jsxs)(I.Fragment,{children:[`under `,(0,I.jsx)(`code`,{title:e,children:e??`the boards root`})]}),` with board.md and a tasks/ folder; the columns start as Draft, Todo, In progress, Review, Done and are changed in the board's settings.`]})]})})})]})}function uu({slug:e}){let[t,n]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let t=!0;return A.request(`boards.ensure`,{body:{project:e}}).then(r=>{t&&(r.ok?H(`/projects/${Wl(e)}/boards/${Wl(r.data.board)}`,{replace:!0}):n(M(r)))}),()=>{t=!1}},[e]),t?(0,I.jsx)(Y,{icon:`view_kanban`,children:(0,I.jsx)(`span`,{className:`text-bad`,children:t})}):(0,I.jsx)(Y,{children:`opening the board…`})}function du({project:e,board:t}){let n={project:e,board:t},r=N(`boards.get`,{board:t,query:Gl(e)},{interval:1e4}),i=N(`agents.list`,{},{interval:6e4});if(!r)return null;let a=new Set(r.columns.map(e=>e.slug)),o=[...r.columns,...r.items.some(e=>!a.has(e.status))?[{slug:``,label:`No column`}]:[]].map(e=>({col:e,tasks:r.items.filter(t=>e.slug?t.status===e.slug:!a.has(t.status)).sort(Jl)})),s=e=>(i?.agents??[]).find(t=>t.slug===e),c=r.tasks;return(0,I.jsxs)(`section`,{className:`flex flex-col gap-2.5 pb-3`,"aria-label":`board ${r.title}`,children:[(0,I.jsx)(mt,{href:Kl(n),size:`sm`,leading:(0,I.jsx)(R,{name:`view_kanban`,className:`ms-sm`}),title:r.title,titleExtra:(0,I.jsx)(Qe,{n:r.review,title:`waiting for review`}),meta:c===0?`empty`:`${c} task${c===1?``:`s`}`}),c===0&&(0,I.jsxs)(`p`,{className:`m-0 px-2.5 text-xs text-fg-2`,children:[`Nothing on the board yet. `,(0,I.jsx)(U,{href:Kl(n),className:`text-accent`,children:`Add a task`})]}),(0,I.jsx)(`div`,{className:`board-glance flex gap-2 overflow-x-auto px-2.5 pb-1`,"aria-label":`columns`,children:o.map(({col:e,tasks:t})=>{let r=e.limit!==void 0&&t.length>e.limit,i=e.done?3:8;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.label,className:P(`flex w-[168px] flex-none flex-col gap-1 rounded-card bg-surface-2 p-1.5`,e.review&&t.length>0&&`bg-ask-soft`,r&&`bg-bad-soft`),children:[(0,I.jsxs)(U,{href:Kl(n),title:`${e.label}: ${t.length}${e.limit===void 0?``:` of ${e.limit}`}`,className:`flex items-baseline gap-1.5 px-1 pt-0.5 pb-1 no-underline`,children:[(0,I.jsx)(nt,{className:P(`truncate`,e.review&&`text-on-ask-soft`,r&&`text-on-bad-soft`),children:e.label}),(0,I.jsxs)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:[t.length,e.limit===void 0?``:`/${e.limit}`]})]}),t.slice(0,i).map(t=>{let r=t.assignee?s(t.assignee):void 0;return(0,I.jsxs)(U,{href:ql(n,t.slug),title:t.title,className:P(`flex min-w-0 flex-col gap-1 rounded-control border border-line bg-surface px-2 py-1.5 text-xs text-fg no-underline transition-colors hover:border-accent`,e.done&&`opacity-70`),children:[(0,I.jsx)(`span`,{className:`line-clamp-2 font-medium`,children:t.title}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-2xs text-fg-2`,children:[(0,I.jsxs)(`span`,{className:`font-mono`,children:[`#`,t.number]}),t.due&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:t.due.slice(5)}),t.stale&&(0,I.jsx)(R,{name:`hourglass_bottom`,className:`ms-sm text-[13px] text-on-ask-soft`}),t.assignee&&(0,I.jsx)(`span`,{className:`ml-auto`,title:r?`${r.name} (${t.assignee})`:t.assignee,children:r?.emoji?r.emoji:t.assignee})]})]},t.slug)}),t.length>i&&(0,I.jsxs)(U,{href:Kl(n),className:`px-1 text-2xs text-fg-2 no-underline hover:text-fg`,children:[t.length-i,` more`]})]},e.slug||`~`)})})]})}function fu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pu=fu();function mu(e){pu=e}var hu={exec:()=>null};function gu(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function _u(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(yu.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var vu=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),yu={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:gu(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gu(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:gu(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:gu(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:gu(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:gu(e=>RegExp(`^ {0,${e}}(?:</?(?:${Pu})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:gu(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},bu=/^(?:[ \t]*(?:\n|$))+/,xu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Su=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,Cu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,wu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Tu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Eu=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,Du=_u(Eu).replace(/bull/g,Tu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Ou=_u(Eu).replace(/bull/g,Tu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ku=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Au=/^[^\n]+/,ju=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Mu=_u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ju).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),Nu=_u(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Tu).getRegex(),Pu=`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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Fu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Iu=_u(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Fu).replace(`tag`,Pu).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Lu=e=>_u(ku).replace(`hr`,Cu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Pu).getRegex(),Ru=Lu(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),zu=Lu(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Bu={blockquote:_u(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,zu).getRegex(),code:xu,def:Mu,fences:Su,heading:wu,hr:Cu,html:Iu,lheading:Du,list:Nu,newline:bu,paragraph:Ru,table:hu,text:Au},Vu=_u(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Cu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Pu).getRegex(),Hu={...Bu,lheading:Ou,table:Vu,paragraph:_u(ku).replace(`hr`,Cu).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Vu).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Pu).getRegex()},Uu={...Bu,html:_u(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,Fu).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hu,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_u(ku).replace(`hr`,Cu).replace(`heading`,` *#{1,6} *[^
224
224
  ]`).replace(`lheading`,Du).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Wu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ku=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,qu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ju=/[\p{P}\p{S}]/u,Yu=/[\s\p{P}\p{S}]/u,Xu=/[^\s\p{P}\p{S}]/u,Zu=_u(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Yu).getRegex(),Qu=/[\p{Pi}\p{Ps}"']/u,$u=/(?!~)[\p{P}\p{S}]/u,ed=/(?!~)[\s\p{P}\p{S}]/u,td=/(?:[^\s\p{P}\p{S}]|~)/u,nd=_u(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,vu?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),rd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,id=_u(rd,`u`).replace(/punct/g,Ju).getRegex(),ad=_u(rd,`u`).replace(/punct/g,$u).getRegex(),od=_u(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Qu).replace(/punct/g,Ju).getRegex(),sd=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,cd=_u(sd,`gu`).replace(/notPunctSpace/g,Xu).replace(/punctSpace/g,Yu).replace(/punct/g,Ju).getRegex(),ld=_u(sd,`gu`).replace(/notPunctSpace/g,td).replace(/punctSpace/g,ed).replace(/punct/g,$u).getRegex(),ud=_u(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Xu).replace(/punctSpace/g,Yu).replace(/punct/g,Ju).getRegex(),dd=_u(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Xu).replace(/punctSpace/g,Yu).replace(/punct/g,Ju).getRegex(),fd=_u(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Xu).replace(/punctSpace/g,Yu).replace(/punct/g,Ju).getRegex(),pd=_u(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Ju).getRegex(),md=_u(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Xu).replace(/punctSpace/g,Yu).replace(/punct/g,Ju).getRegex(),hd=_u(/\\(punct)/,`gu`).replace(/punct/g,Ju).getRegex(),gd=_u(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,Ju).getRegex(),_d=_u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),vd=_u(Fu).replace(`(?:-->|$)`,`-->`).getRegex(),yd=_u(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,vd).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bd=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,xd=_u(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,bd).getRegex(),Sd=_u(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,xd).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),Cd=_u(/^!?\[(label)\]\[(ref)\]/).replace(`label`,xd).replace(`ref`,ju).getRegex(),wd=_u(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ju).getRegex(),Td=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Ed=_u(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,bd).getRegex(),Dd=_u(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,_u(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ed).replace(`ref`,Td).getRegex()).replace(`nolink`,_u(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Td).getRegex()).getRegex(),Od=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,kd=_u(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Ad={_backpedal:hu,anyPunctuation:hd,anyPunctuationOutsideCode:gd,autolink:_d,blockSkip:nd,br:Ku,code:Gu,del:hu,delLDelim:hu,delRDelim:hu,emStrongLDelim:id,emStrongRDelimAst:cd,emStrongRDelimUnd:dd,escape:Wu,link:Sd,nolink:wd,punctuation:Zu,reflink:Cd,reflinkSearch:Dd,tag:yd,text:qu,url:hu},jd={...Ad,emStrongLDelim:od,emStrongRDelimAst:ud,emStrongRDelimUnd:fd,link:_u(/^!?\[(label)\]\((.*?)\)/).replace(`label`,xd).getRegex(),reflink:_u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,xd).getRegex()},Md={...Ad,emStrongRDelimAst:ld,emStrongLDelim:ad,delLDelim:pd,delRDelim:md,url:_u(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,kd).replace(`protocol`,Od).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:_u(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,Od).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,vu?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},Nd={...Md,br:_u(Ku).replace(`{2,}`,`*`).getRegex(),text:_u(Md.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Pd={normal:Bu,gfm:Hu,pedantic:Uu},Fd={normal:Ad,gfm:Md,breaks:Nd,pedantic:jd},Id={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Ld=e=>Id[e];function Rd(e,t){if(t){if(yu.escapeTest.test(e))return e.replace(yu.escapeReplace,Ld)}else if(yu.escapeTestNoEncode.test(e))return e.replace(yu.escapeReplaceNoEncode,Ld);return e}function zd(e){return yu.numericCharacterReference.test(e)?e.replace(yu.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&amp;`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&amp;`:String.fromCodePoint(r)}):e}function Bd(e){try{e=encodeURI(e).replace(yu.percentDecode,`%`)}catch{return null}return e}function Vd(e,t){let n=e.replace(yu.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(yu.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(yu.slashPipe,`|`);return n}function Hd(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Ud(e){let t=e.split(`
225
225
  `),n=t.length-1;for(;n>=0&&yu.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
@@ -468,18 +468,18 @@ series:
468
468
  </body></html>`,J_=[{name:`Rectangle`,icon:`rectangle`,html:`<div></div>`,w:3,h:1.8,patch:{fill:`accent`}},{name:`Rounded`,icon:`rounded_corner`,html:`<div></div>`,w:3,h:1.8,patch:{fill:`accent`,radius:12}},{name:`Circle`,icon:`circle`,html:`<div></div>`,w:2,h:2,patch:{fill:`accent`,radius:999}},{name:`Line`,icon:`horizontal_rule`,html:`<svg viewBox="0 0 100 10" preserveAspectRatio="none" style="width:100%;height:100%;overflow:visible"><line x1="0" y1="5" x2="100" y2="5" stroke="currentColor" stroke-width="3" vector-effect="non-scaling-stroke"/></svg>`,w:4,h:.3,patch:{color:`text`}},{name:`Arrow`,icon:`arrow_right_alt`,html:`<svg viewBox="0 0 100 20" preserveAspectRatio="none" style="width:100%;height:100%;overflow:visible"><line x1="0" y1="10" x2="92" y2="10" stroke="currentColor" stroke-width="3" vector-effect="non-scaling-stroke"/><polygon points="88,2 100,10 88,18" fill="currentColor"/></svg>`,w:4,h:.5,patch:{color:`accent`}},{name:`Star`,icon:`star`,html:`<svg viewBox="0 0 100 100" style="width:100%;height:100%"><polygon points="50,4 61,38 97,38 68,59 79,94 50,73 21,94 32,59 3,38 39,38" fill="currentColor"/></svg>`,w:1.6,h:1.6,patch:{color:`accent`}}],Y_=[];function X_({project:e,name:t}){let n={project:e,name:t},r=M_(e),i=N(`presentations.get`,{name:t,query:r},{interval:4e3}),a=N(`presentations.links`,{name:t,query:r},{interval:3e4}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(0),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(`none`),[T,E]=(0,v.useState)(void 0),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(!1),[j,F]=(0,v.useState)(null),[te,z]=(0,v.useState)(!1),[ne,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(`none`),[oe,se]=(0,v.useState)(null),[ce,le]=(0,v.useState)(!1),[ue,de]=(0,v.useState)(null),[B,V]=(0,v.useState)(0),[fe,pe]=(0,v.useState)(0),[me,he]=(0,v.useState)(()=>{try{return localStorage.getItem(I_(n))}catch{return null}}),[ge,_e]=(0,v.useState)(``),[ve,ye]=(0,v.useState)(0),be=(0,v.useRef)(null),xe=(0,v.useRef)(void 0),Se=(0,v.useRef)(null),Ce=(0,v.useRef)(null),we=(0,v.useRef)(null),Te=(0,v.useRef)([]),Ee=(0,v.useRef)([]),De=(0,v.useRef)(null);De.current=o;let Oe=(0,v.useRef)(null);(0,v.useEffect)(()=>{i&&!c&&!y&&i.updatedAt!==xe.current&&(xe.current=i.updatedAt,Oe.current=V_(i),s(V_(i)),(j===null||C!==`source`)&&F(i.source))},[i,c,C,j,y]);let ke=(0,v.useCallback)(async e=>{d(!0),p(``);let n=await A.request(`presentations.save`,{name:t,query:r,body:{title:e.title,template:e.template,numbers:e.numbers!==!1,slides:e.slides,...xe.current?{base:xe.current}:{}}});if(d(!1),!n.ok&&n.status===409){let n=await A.call(`presentations.get`,{name:t,query:r}).catch(()=>null);if(!n||!Oe.current)return p(`the deck changed elsewhere; reload to see it`);let{draft:i,lost:a}=Zg(Oe.current,e,V_(n));xe.current=n.updatedAt,Oe.current=V_(n),De.current=i,s(i),O(a.length?`Changed elsewhere meanwhile: your edit to slide ${a.join(`, `)} gave way to theirs (⌘Z brings it back).`:`Changed elsewhere meanwhile: merged with your edits.`),ke(i)}else{if(!n.ok)return p(M(n));if(Oe.current=e,(n.data.deck.css??``)!==e.css){let i=e.css.trim(),a=n.data.source.replace(/^---\n([\s\S]*?)\n---\n/,(e,t)=>`---\n${t.replace(/^css: [\s\S]*?(?=^\S|$(?![\s\S]))/m,``).replace(/\n+$/,``)}${i?`\ncss: |\n${i.split(`
469
469
  `).map(e=>` ${e}`).join(`
470
470
  `)}`:``}\n---\n`),o=await A.request(`presentations.save`,{name:t,query:r,body:{source:a}});if(!o.ok)return p(M(o));xe.current=o.data.updatedAt,F(o.data.source)}else xe.current=n.data.updatedAt,F(n.data.source);l(!1)}},[t,e]),Ae=(e,t)=>{let n=De.current;if(!n)return;let r=e(n),i=Te.current[Te.current.length-1];t&&i?.mark===t&&Date.now()-i.at<1500?i.at=Date.now():Te.current.push({draft:n,mark:t,at:Date.now()}),Te.current.length>200&&Te.current.shift(),Ee.current=[],De.current=r,s(r),l(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>void ke(r),600)},je=e=>{De.current=e,s(e),l(!0),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>void ke(e),600)},Me=()=>{let e=Te.current.pop();e&&De.current&&(Ee.current.push(De.current),je(e.draft))},Ne=()=>{let e=Ee.current.pop();e&&De.current&&(Te.current.push({draft:De.current,at:Date.now()}),je(e))};(0,v.useEffect)(()=>()=>{be.current&&clearTimeout(be.current)},[]);let Pe=i?.themes??[],Fe=(o&&Pe.find(e=>e.slug===o.template))??i?.theme;o_(Fe?[Fe,...Pe.filter(e=>e.slug!==Fe.slug)]:[],o?.css);let Ie=`${i?.updatedAt??``}-${B}`,Le=(0,v.useMemo)(()=>F_(n,Ie),[t,e,Ie]),Re=o?.slides??[],ze=Math.min(m,Math.max(0,Re.length-1)),Be=Re[ze],Ve=l_(Be,Fe,Le),He=Re.filter(e=>!U_(e)).length,Ue=e=>o?.numbers===!1?void 0:{n:Re.slice(0,e+1).filter(e=>!U_(e)).length,of:He},We=(e,t)=>Ae(t=>({...t,slides:t.slides.map((t,n)=>n===ze?{...t,...e}:t)}),t),Ge=(e,t,n)=>{Be&&Ve&&Fe&&We({content:Mg(Be.content,e,t,p_(Fe,Ve.layout))},n)};(0,v.useEffect)(()=>{let e=e=>{let t=e.target,n=!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)),r=e.metaKey||e.ctrlKey;r&&e.key.toLowerCase()===`z`&&!n?(e.preventDefault(),e.shiftKey?Ne():Me()):r&&e.key.toLowerCase()===`y`&&!n?(e.preventDefault(),Ne()):!n&&e.key===`PageDown`?h(e=>Math.min(e+1,Re.length-1)):!n&&e.key===`PageUp`&&h(e=>Math.max(0,e-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let Ke=ev(n,ze+1,g.length===1?g[0]:void 0,!!o),qe=(0,v.useRef)(null),Je=!!i&&!!o;if((0,v.useEffect)(()=>{if(!Je)return;let e=null;try{e=sessionStorage.getItem(z_(n)),e&&sessionStorage.removeItem(z_(n))}catch{}e&&qe.current?.(B_(e))},[Je]),!i||!o||!Fe)return(0,I.jsx)(Y,{children:`loading…`});let Ye=Object.entries(Fe.layouts),Xe=i.warnings.filter(e=>e.slide===0),Ze=e=>i.warnings.filter(t=>t.slide===e),Qe=e?`/projects/${j_(e)}/presentations`:`/presentations`,$e=e=>{h(e),_([]),b(null),S(null)},q=e=>{Ae(t=>({...t,slides:[...t.slides.slice(0,ze+1),{layout:e,extra:{},content:``},...t.slides.slice(ze+1)]})),$e(ze+1),ae(`none`)},et=e=>{let t=e=>{let t=structuredClone(e.extra??{});return delete t.id,{...e,extra:t}};Ae(n=>({...n,slides:[...n.slides.slice(0,e+1),t(n.slides[e]),...n.slides.slice(e+1)]})),$e(e+1)},nt=e=>{Re.length<=1||(Ae(t=>({...t,slides:t.slides.filter((t,n)=>n!==e)})),$e(Math.max(0,e<=ze?ze-1:ze)))},rt=e=>Ae(t=>({...t,slides:t.slides.map((t,n)=>{if(n!==e)return t;let r={...t.extra};return r.hidden===!0?delete r.hidden:r.hidden=!0,{...t,extra:r}})})),it=(e,t)=>{e===t||t<0||t>=Re.length||(Ae(n=>{let r=[...n.slides],[i]=r.splice(e,1);return r.splice(t,0,i),{...n,slides:r}}),$e(t))},at=(e,t)=>{let n=1;for(;t.has(`${e}${n}`);)n++;return t.add(`${e}${n}`),`${e}${n}`},ot=(e,t,n,r,i,a,o={})=>{if(!Be||!Ve)return;let s=at(t,new Set(Ve.slots.map(e=>e.name))),c=gg/160,l=Lg(Fe.size)/160,u={x:a_((c-r)/2),y:a_((l-i)/2),w:r,h:i};We({...f_(Be,{[s]:{kind:e,...u,...e===`markdown`||e===`text`?{size:18}:e===`table`||e===`chart`?{size:13}:e===`html`?{size:15}:{},...o}}),content:Mg(Be.content,s,n,p_(Fe,Ve.layout))}),_([s]),b(a===`edit`?s:null),S(a===`source`?s:null),ae(`none`)},st=async e=>{p(``);let n=await A.request(`presentations.upload`,{name:t,query:r,headers:{"x-file-name":encodeURIComponent(e.name),"content-type":e.type||`application/octet-stream`},body:e}).catch(()=>null);return n?.ok?(V(e=>e+1),n.data.path):(p(n?M(n):`could not upload ${e.name}`),null)},ct=async(e,t)=>{if(!Be||!Ve)return;let n=await st(e);if(!n)return;let r=`![${e.name.replace(/\.[^.]+$/,``)}](${n})`,i=t&&Ve.slots.find(e=>e.name===t)||Ve.slots.find(e=>e.kind===`image`&&!e.md);i?(Ge(i.name,r),_([i.name])):ot(`image`,`image`,r,4,3,`none`)},lt=e=>{if(!Be||!Ve)return;let t=p_(Fe,Ve.layout),n=Be.content,r={};for(let i of e){let e=Ve.slots.find(e=>e.name===i);e&&(n=Mg(n,i,``,t),e.own&&(r[i]=null))}We({...f_(Be,r),content:n}),_([]),x&&e.includes(x)&&S(null)},ut=e=>{Be&&Ve&&(Y_=Ve.slots.filter(t=>e.includes(t.name)).map(e=>{let t=d_(Be)[e.name]??{};return{kind:e.kind,base:e.name.replace(/\d+$/,``)||`box`,md:e.md??``,patch:{...t,kind:e.kind,x:e.x,y:e.y,w:e.w,h:e.h,...e.size?{size:e.size}:{},...e.color?{color:e.color}:{},...e.bold?{bold:!0}:{},...e.italic?{italic:!0}:{},...e.align?{align:e.align}:{},...e.valign?{valign:e.valign}:{},...e.font?{font:e.font}:{},...e.class?{class:e.class}:{}}}}),ye(e=>e+1))},dt=(e=.2)=>{if(!Be||!Ve||!Y_.length)return;let t=new Set(Ve.slots.map(e=>e.name)),n={},r=Be.content,i=[];for(let a of Y_){let o=at(a.base,t);n[o]={...a.patch,x:a_((a.patch.x??0)+e),y:a_((a.patch.y??0)+e)},r=Mg(r,o,a.md,p_(Fe,Ve.layout)),i.push(o)}We({...f_(Be,n),content:r}),_(i)},ft=e=>{ut(e),dt()},pt=(e,t)=>{if(t)return void Q(`In the box "${e}" on slide ${ze+1}: ${t}`);_e(`In the box "${e}" on slide ${ze+1}: `),requestAnimationFrame(()=>we.current?.focus())},mt=i.comments??[],ht=mt.filter(e=>!e.resolved),gt=e=>ht.filter(t=>t.n===e).length,_t={};for(let e of ht)e.n===ze+1&&(_t[e.slot??``]=(_t[e.slot??``]??0)+1);let vt=e=>{S(null),E(e),w(`comments`)},Z=async()=>{let e=`presentation:${t}`;try{await navigator.clipboard.writeText(e),O(`Copied ${e}: paste it into a chat, a task or a note, and it links here.`)}catch{O(e)}ae(`none`)},bt=async e=>{let t=`${location.origin}${location.pathname}#${N_(n)}${e===`present`?`/present`:``}`;try{await navigator.clipboard.writeText(t),O(`Link copied: ${t}`)}catch{O(t)}ae(`none`)},Q=async r=>{let a=(r??ge).trim();if(!a)return;p(``);let s=e?` --project ${e}`:``,c=me,l=!1;if(!c){let t=e?{kind:`project`,slug:e}:{kind:`general`},r=await A.request(`chats.create`,{body:{agent:`claude`,scope:t}});if(!r.ok)return p(M(r));c=r.data.id,l=!0,he(c);try{localStorage.setItem(I_(n),c)}catch{}}let u=l?`You are working on the presentation "${o.title}" (presentation:${t}, file ${i.path}/deck.md) beside me; I see every change you save at once. I am on slide ${ze+1}. ${a}\n\nEdit deck.md directly (slots hold markdown or HTML; \`npx kraftwerk presentations show ${t}${s}\` lists the layouts, slots and the theme's pieces), then run \`npx kraftwerk presentations check ${t}${s}\` and look at the PNGs \`npx kraftwerk presentations render ${t} --png${s}\` writes before you answer. Keep your answer short.`:`(slide ${ze+1}) ${a}`,d=await A.request(`chats.message`,{id:c,body:{text:u}});if(!d.ok)return p(M(d));r===void 0&&_e(``),w(`chat`),S(null)};qe.current=e=>void Q(e);let $=e=>{S(null),w(t=>t===e?`none`:e)},Ct=Ve?.slots.find(e=>e.name===x)??null,wt=`inline-flex h-8 items-center gap-1.5 rounded-control px-2 text-sm text-fg-2 hover:bg-surface-2 hover:text-fg`,Tt=`relative flex items-center gap-0.5 rounded-full border border-line bg-surface px-1.5 py-1`,Et=Ct||C!==`none`;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,"aria-label":`presentation toolbar`,children:[(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsx)(K,{icon:`arrow_back`,label:`all presentations`,size:`sm`,href:Qe}),(0,I.jsx)(`input`,{value:o.title,"aria-label":`presentation title`,className:`h-8 w-[200px] border-0 bg-transparent px-1 text-sm font-semibold text-fg outline-none`,onChange:e=>Ae(t=>({...t,title:e.target.value}),`title`)})]}),(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsxs)(`button`,{type:`button`,className:wt,"aria-haspopup":`menu`,"aria-expanded":ie===`slide`,onClick:()=>ae(e=>e===`slide`?`none`:`slide`),children:[(0,I.jsx)(R,{name:`add_to_photos`,className:`ms-sm`}),`slide`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,title:`a text box on this slide`,onClick:()=>ot(`markdown`,`text`,`Text`,4,.9,`edit`),children:[(0,I.jsx)(R,{name:`title`,className:`ms-sm`}),`text`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,title:`a picture on this slide (png, jpg, gif) — or drop one onto the slide`,onClick:()=>{Ce.current=null,Se.current?.click()},children:[(0,I.jsx)(R,{name:`image`,className:`ms-sm`}),`picture`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,title:`a chart on this slide`,onClick:()=>ot(`chart`,`chart`,W_,6,3.2,`source`),children:[(0,I.jsx)(R,{name:`bar_chart`,className:`ms-sm`}),`chart`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,title:`a table on this slide`,onClick:()=>ot(`table`,`table`,G_,6,1.6,`none`),children:[(0,I.jsx)(R,{name:`table`,className:`ms-sm`}),`table`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,"aria-haspopup":`menu`,"aria-expanded":ie===`shapes`,title:`rectangles, circles, lines, arrows`,onClick:()=>ae(e=>e===`shapes`?`none`:`shapes`),children:[(0,I.jsx)(R,{name:`category`,className:`ms-sm`}),`shapes`]}),(0,I.jsxs)(`button`,{type:`button`,className:wt,"aria-haspopup":`menu`,"aria-expanded":ie===`insert`,title:`HTML, embeds and the theme's pieces`,onClick:()=>ae(e=>e===`insert`?`none`:`insert`),children:[(0,I.jsx)(R,{name:`widgets`,className:`ms-sm`}),`more`]}),ie===`slide`&&(0,I.jsx)(__,{label:`new slide`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[520px]`,children:(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-2 p-1`,children:Ye.map(([e,t])=>(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex flex-col items-start gap-1 rounded-md p-1 text-left hover:bg-surface-2`,title:t.description,onClick:()=>q(e),children:[(0,I.jsx)(u_,{slide:{layout:e,extra:{},content:``},theme:Fe,asset:Le,width:152}),(0,I.jsx)(`span`,{className:`text-xs text-fg`,children:e})]},e))})}),ie===`shapes`&&(0,I.jsx)(__,{label:`shapes`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[240px]`,children:J_.map(e=>(0,I.jsx)(v_,{icon:e.icon,title:e.name,onClick:()=>ot(`html`,e.name.toLowerCase(),e.html,e.w,e.h,`none`,e.patch)},e.name))}),ie===`insert`&&(0,I.jsxs)(__,{label:`insert`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[340px]`,children:[(0,I.jsx)(v_,{icon:`code`,title:`HTML`,sub:`any markup; the theme's classes apply`,onClick:()=>ot(`html`,`html`,K_,6,1.2,`source`)}),(0,I.jsx)(v_,{icon:`public`,title:`Embed`,sub:`a web page by URL, or a page of your own with scripts`,onClick:()=>ot(`embed`,`embed`,q_,4,2.4,`source`)}),Fe.snippets.length>0&&(0,I.jsx)(`div`,{className:`mt-1 border-t border-line px-2 pb-1 pt-2 text-[11px] uppercase tracking-wider text-fg-2`,children:`from the theme`}),Fe.snippets.map(e=>(0,I.jsx)(v_,{icon:`dashboard_customize`,title:e.name,sub:e.description,onClick:()=>ot(e.kind===`markdown`?`markdown`:`html`,e.name.toLowerCase().replace(/[^a-z0-9]+/g,``)||`piece`,e.content,Math.min(e.w,10),e.h,`none`)},e.name))]}),(0,I.jsx)(`input`,{ref:Se,type:`file`,accept:`image/png,image/jpeg,image/gif`,"aria-label":`picture file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&ct(t,Ce.current)}})]}),Be&&!ce&&(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsx)(`span`,{className:`pl-1.5 text-xs text-fg-2`,children:`layout`}),(0,I.jsx)(`select`,{value:Ve?.layout??Be.layout??``,"aria-label":`layout`,className:`h-8 cursor-pointer border-0 bg-transparent pr-1 text-sm text-fg outline-none`,onChange:e=>We({layout:e.target.value}),children:Ye.map(([e,t])=>(0,I.jsx)(`option`,{value:e,title:t.description,children:e},e))})]}),(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsx)(`button`,{type:`button`,className:wt,disabled:!Te.current.length,title:`undo (⌘Z)`,"aria-label":`undo`,onClick:Me,children:(0,I.jsx)(R,{name:`undo`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:wt,disabled:!Ee.current.length,title:`redo (⇧⌘Z)`,"aria-label":`redo`,onClick:Ne,children:(0,I.jsx)(R,{name:`redo`,className:`ms-sm`})}),(0,I.jsxs)(`button`,{type:`button`,className:wt,"aria-haspopup":`menu`,"aria-expanded":ie===`zoom`,"aria-label":`zoom`,title:`zoom`,onClick:()=>ae(e=>e===`zoom`?`none`:`zoom`),children:[ue?`${Math.round(ue*100)}%`:`fit`,(0,I.jsx)(R,{name:`expand_more`,className:`ms-sm`})]}),(0,I.jsx)(`button`,{type:`button`,className:P(wt,ce&&`bg-surface-2 text-fg`),"aria-pressed":ce,"aria-label":`grid view`,title:`all slides at once`,onClick:()=>le(e=>!e),children:(0,I.jsx)(R,{name:`grid_view`,className:`ms-sm`})}),ie===`zoom`&&(0,I.jsx)(__,{label:`zoom`,onClose:()=>ae(`none`),className:`absolute right-0 top-[calc(100%+6px)] w-[140px]`,children:[null,.5,.75,1,1.5].map(e=>(0,I.jsx)(v_,{title:e?`${e*100}%`:`fit`,onClick:()=>{de(e),ae(`none`)}},String(e)))})]}),(0,I.jsx)(`span`,{className:`flex-1`}),Ke.length>0&&(0,I.jsx)(`div`,{className:`flex items-center -space-x-1.5`,role:`group`,"aria-label":`also here`,children:Ke.map(e=>(0,I.jsx)(`button`,{type:`button`,title:`${e.who} · slide ${e.slide}${e.slot?` · ${e.slot}`:``}`,"aria-label":`${e.who} on slide ${e.slide}`,className:`grid h-7 w-7 place-items-center rounded-full border-2 border-bg text-[11px] font-semibold uppercase text-white`,style:{background:e.color},onClick:()=>$e(e.slide-1),children:e.who.replace(/[^a-z0-9]/gi,``).slice(0,2)||`?`},e.client))}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,"aria-live":`polite`,children:u?`saving…`:c?`unsaved`:i.updatedAt?`saved ${W(i.updatedAt)}`:``}),(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`format`&&`bg-surface-2 text-fg`),"aria-pressed":C===`format`,onClick:()=>$(`format`),children:[(0,I.jsx)(R,{name:`tune`,className:`ms-sm`}),`format`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`design`&&`bg-surface-2 text-fg`),"aria-pressed":C===`design`,onClick:()=>$(`design`),children:[(0,I.jsx)(R,{name:`palette`,className:`ms-sm`}),`design`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`chat`&&`bg-surface-2 text-fg`),"aria-pressed":C===`chat`,onClick:()=>$(`chat`),children:[(0,I.jsx)(R,{name:`forum`,className:`ms-sm`}),`chat`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`comments`&&`bg-surface-2 text-fg`),"aria-pressed":C===`comments`,"aria-label":`comments`,onClick:()=>C===`comments`?w(`none`):vt(g.length===1?g[0]:void 0),children:[(0,I.jsx)(R,{name:`comment`,className:`ms-sm`}),ht.length>0&&(0,I.jsx)(`span`,{className:`rounded-full bg-[#f59e0b] px-1.5 text-[11px] font-semibold text-black`,children:ht.length})]}),(0,I.jsx)(`button`,{type:`button`,className:P(wt,C===`history`&&`bg-surface-2 text-fg`),"aria-pressed":C===`history`,"aria-label":`version history`,title:`version history`,onClick:()=>$(`history`),children:(0,I.jsx)(R,{name:`history`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:wt,"aria-haspopup":`menu`,"aria-expanded":ie===`share`,"aria-label":`share`,onClick:()=>ae(e=>e===`share`?`none`:`share`),children:(0,I.jsx)(R,{name:`share`,className:`ms-sm`})}),ie===`share`&&(0,I.jsxs)(__,{label:`share`,onClose:()=>ae(`none`),className:`absolute right-0 top-[calc(100%+6px)] w-[280px]`,children:[(0,I.jsx)(v_,{icon:`link`,title:`Copy link to the editor`,sub:`for anyone with this workspace (paired devices, members)`,onClick:()=>void bt(`edit`)}),(0,I.jsx)(v_,{icon:`slideshow`,title:`Copy link to present mode`,onClick:()=>void bt(`present`)}),(0,I.jsx)(v_,{icon:`html`,title:`Download as one HTML file`,sub:`opens anywhere, no kraftwerk needed`,onClick:()=>(ae(`none`),window.location.href=P_(n,`html`))}),(0,I.jsx)(v_,{icon:`alternate_email`,title:`Copy reference`,sub:`presentation:${t} — paste into a chat, a task or a note`,onClick:()=>void Z()}),(0,I.jsx)(y_,{}),(0,I.jsx)(`div`,{className:`px-2 pb-1 pt-0.5 text-[11px] font-semibold uppercase tracking-wide text-fg-2`,children:`linked from tasks`}),a?.tasks.length?a.tasks.map(e=>(0,I.jsx)(v_,{icon:`task_alt`,title:`${e.number} ${e.title}`,sub:`${e.project?`${e.project} · `:``}${e.board} · ${e.status}${e.assignee?` · ${e.assignee}`:``}`,onClick:()=>(ae(`none`),H(e.href))},e.ref)):(0,I.jsx)(`div`,{className:`px-2 pb-1.5 text-xs text-fg-2`,children:`none yet — link the deck from a task's links`})]})]}),(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsxs)(U,{href:`${N_(n)}/present`,className:P(wt,`font-semibold text-fg no-underline`),"aria-label":`present`,children:[(0,I.jsx)(R,{name:`play_arrow`,className:`ms-sm`}),`present`]}),(0,I.jsx)(`button`,{type:`button`,className:P(wt,`px-1`),"aria-haspopup":`menu`,"aria-expanded":ie===`present`,"aria-label":`present options`,onClick:()=>ae(e=>e===`present`?`none`:`present`),children:(0,I.jsx)(R,{name:`expand_more`,className:`ms-sm`})}),(0,I.jsxs)(`a`,{className:P(wt,`no-underline`),href:P_(n,`pptx`),download:!0,title:`download as PowerPoint`,"aria-label":`pptx`,children:[(0,I.jsx)(R,{name:`download`,className:`ms-sm`}),`pptx`]}),(0,I.jsx)(`a`,{className:P(wt,`no-underline`),href:P_(n,`pdf`),download:!0,title:`download as PDF`,"aria-label":`pdf`,children:(0,I.jsx)(R,{name:`picture_as_pdf`,className:`ms-sm`})}),(0,I.jsx)(`a`,{className:P(wt,`no-underline`),href:P_(n,`html`),download:!0,title:`download as one HTML file`,"aria-label":`html`,children:(0,I.jsx)(R,{name:`html`,className:`ms-sm`})}),ie===`present`&&(0,I.jsxs)(__,{label:`present`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[230px]`,children:[(0,I.jsx)(v_,{icon:`play_arrow`,title:`From the start`,onClick:()=>H(`${N_(n)}/present`)}),(0,I.jsx)(v_,{icon:`slideshow`,title:`From slide ${ze+1}`,onClick:()=>H(`${N_(n)}/present/${ze+1}`)}),(0,I.jsx)(v_,{icon:`co_present`,title:`With notes (presenter view)`,sub:`current and next slide, notes, a clock`,onClick:()=>H(`${N_(n)}/presenter/${ze+1}`)})]})]}),(0,I.jsxs)(`div`,{className:Tt,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`markdown`&&`bg-surface-2 text-fg`),"aria-pressed":C===`markdown`,title:`this slide's markdown`,onClick:()=>$(`markdown`),children:[(0,I.jsx)(R,{name:`notes`,className:`ms-sm`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`markdown`})]}),(0,I.jsxs)(`button`,{type:`button`,className:P(wt,C===`source`&&`bg-surface-2 text-fg`),"aria-pressed":C===`source`,title:`the whole deck.md`,onClick:()=>$(`source`),children:[(0,I.jsx)(R,{name:`code`,className:`ms-sm`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`source`})]}),te?(0,I.jsxs)(`span`,{className:`flex items-center gap-1 pl-1`,children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,onClick:()=>void Ot(),children:`move to trash`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>z(!1),children:`keep`})]}):(0,I.jsx)(K,{icon:`delete`,label:`remove presentation`,size:`sm`,onClick:()=>z(!0)})]})]}),f&&(0,I.jsx)(tt,{tone:`bad`,children:f}),D&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5 text-sm`,role:`status`,children:[(0,I.jsx)(R,{name:`info`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:D}),(0,I.jsx)(K,{icon:`close`,label:`dismiss`,size:`sm`,onClick:()=>O(``)})]}),Xe.length>0&&(0,I.jsx)(rv,{items:Xe}),C===`source`?(0,I.jsx)(X,{title:`deck.md`,children:(0,I.jsxs)(xt,{children:[(0,I.jsx)(yt,{value:j??``,"aria-label":`deck source`,spellCheck:!1,className:`min-h-[60vh] font-mono text-[13px] leading-5`,onChange:e=>{F(e.target.value),l(!0)}}),(0,I.jsxs)(St,{children:[(0,I.jsx)(G,{variant:`primary`,icon:`save`,busy:u,disabled:!c||u,onClick:()=>void Dt(),children:`save deck.md`}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(`code`,{children:[i.path,`/deck.md`]}),` — slides are separated by `,(0,I.jsx)(`code`,{children:`---`}),` lines; a YAML block right after one sets `,(0,I.jsx)(`code`,{children:`layout:`}),` and `,(0,I.jsx)(`code`,{children:`slots:`}),`; `,(0,I.jsx)(`code`,{children:`::slot::`}),` marks a slot, `,(0,I.jsx)(`code`,{children:`::notes::`}),` the speaker notes.`]})]})]})}):(0,I.jsxs)(`div`,{className:P(`grid items-start gap-4`,Et?`grid-cols-[172px_minmax(0,1fr)_minmax(300px,380px)]`:`grid-cols-[172px_minmax(0,1fr)]`),children:[(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center px-1 text-xs text-fg-2`,children:[(0,I.jsxs)(`span`,{children:[Re.length,` `,Re.length===1?`slide`:`slides`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:`add`,label:`add slide`,size:`sm`,onClick:()=>q(Ve?.layout&&Ve.layout!==`title`?Ve.layout:Fe.default??`content`)})]}),(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,role:`list`,"aria-label":`slides`,children:Re.map((e,t)=>(0,I.jsxs)(`div`,{role:`listitem`,"aria-current":t===ze,draggable:!0,className:P(`group relative flex items-start gap-1.5`,ne===t&&`opacity-40`),onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,re(t)},onDragOver:e=>{ne!==null&&e.preventDefault()},onDrop:e=>{e.preventDefault(),ne!==null&&it(ne,t),re(null)},onDragEnd:()=>re(null),onContextMenu:e=>{e.preventDefault(),$e(t),se({i:t,x:e.clientX,y:e.clientY})},children:[(0,I.jsx)(`span`,{className:P(`w-4 pt-1 text-right text-[11px]`,t===ze?`font-semibold text-fg`:`text-fg-2`),children:t+1}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`slide ${t+1}${U_(e)?` (hidden)`:``}`,className:P(`min-w-0 flex-1 overflow-hidden rounded-md border-2`,t===ze?`border-accent`:`border-transparent hover:border-line-strong`,U_(e)&&`opacity-45`),title:H_(e),onClick:()=>$e(t),onKeyDown:e=>{e.key===`Backspace`||e.key===`Delete`?(e.preventDefault(),nt(t)):e.key===`ArrowDown`&&e.altKey?it(t,t+1):e.key===`ArrowUp`&&e.altKey&&it(t,t-1)},children:(0,I.jsx)(u_,{slide:e,theme:Fe,asset:Le,width:136,number:Ue(t)})}),Ke.some(e=>e.slide===t+1)&&(0,I.jsx)(`span`,{className:`pointer-events-none absolute left-6 top-1 flex gap-0.5`,"aria-label":`${Ke.filter(e=>e.slide===t+1).map(e=>e.who).join(`, `)} here`,children:Ke.filter(e=>e.slide===t+1).map(e=>(0,I.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full border border-white`,style:{background:e.color}},e.client))}),gt(t+1)>0&&(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-1 bottom-1 rounded-full bg-[#f59e0b] px-1.5 text-[10px] font-semibold text-black`,"aria-label":`${gt(t+1)} open comments`,children:gt(t+1)}),U_(e)&&(0,I.jsx)(R,{name:`visibility_off`,className:`ms-sm pointer-events-none absolute left-[calc(50%+4px)] top-[calc(50%-10px)] text-fg-2`}),Ze(t+1).length>0&&(0,I.jsx)(R,{name:Ze(t+1).some(e=>e.level===`error`)?`error`:`warning`,className:P(`ms-sm absolute left-6 top-1`,Ze(t+1).some(e=>e.level===`error`)?`text-bad`:`text-ask`)}),(0,I.jsxs)(`span`,{className:`absolute right-1 top-1 hidden gap-0.5 rounded-md bg-surface/90 group-hover:flex`,children:[(0,I.jsx)(K,{icon:`content_copy`,label:`duplicate slide ${t+1}`,size:`sm`,onClick:()=>et(t)}),(0,I.jsx)(K,{icon:`delete`,label:`remove slide ${t+1}`,size:`sm`,disabled:Re.length<=1,onClick:()=>nt(t)})]})]},t))})]}),oe&&(0,I.jsxs)(__,{label:`slide actions`,onClose:()=>se(null),className:`fixed w-[220px]`,style:{left:oe.x,top:oe.y},children:[(0,I.jsx)(v_,{icon:`library_add`,title:`Duplicate`,onClick:()=>(et(oe.i),se(null))}),(0,I.jsx)(v_,{icon:U_(Re[oe.i])?`visibility`:`visibility_off`,title:U_(Re[oe.i])?`Show`:`Hide`,sub:`hidden slides stay out of present mode and the exports`,onClick:()=>(rt(oe.i),se(null))}),(0,I.jsx)(v_,{icon:`arrow_upward`,title:`Move up`,keys:`⌥↑`,disabled:oe.i===0,onClick:()=>(it(oe.i,oe.i-1),se(null))}),(0,I.jsx)(v_,{icon:`arrow_downward`,title:`Move down`,keys:`⌥↓`,disabled:oe.i>=Re.length-1,onClick:()=>(it(oe.i,oe.i+1),se(null))}),(0,I.jsx)(y_,{}),(0,I.jsx)(v_,{icon:`delete`,title:`Delete`,keys:`⌫`,danger:!0,disabled:Re.length<=1,onClick:()=>(nt(oe.i),se(null))})]}),ce?(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4`,role:`list`,"aria-label":`all slides`,children:Re.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,role:`listitem`,className:P(`flex flex-col gap-1 rounded-md p-1 text-left hover:bg-surface-2`,t===ze&&`ring-2 ring-accent`,U_(e)&&`opacity-45`),onClick:()=>{$e(t),le(!1)},children:[(0,I.jsx)(u_,{slide:e,theme:Fe,asset:Le,width:280,number:Ue(t)}),(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[t+1,` · `,H_(e)||e.layout,U_(e)?` · hidden`:``]})]},t))}):Be&&Ve&&(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,I.jsx)(b_,{view:Ve,theme:Fe,slide:Be,number:Ue(ze),zoom:ue,selected:g,editing:y,onSelect:e=>{_(e),x&&!e.includes(x)&&S(null)},onEditing:b,onSource:e=>{Ve.slots.find(t=>t.name===e)?.kind===`image`?(Ce.current=e,Se.current?.click()):S(e)},onPatches:(e,t)=>We(f_(Be,e),t),onText:(e,t)=>Ge(e,t),onRemove:lt,onDuplicate:ft,onCopy:ut,onPaste:()=>dt(),canPaste:ve>=0&&Y_.length>0,onAsk:pt,onFormat:()=>{S(null),w(`format`)},onDropFile:e=>void ct(e),onWidth:pe,pins:_t,others:Ke.filter(e=>e.slide===ze+1&&e.slot).map(e=>({slot:e.slot,who:e.who,color:e.color})),onComments:vt}),(0,I.jsxs)(`div`,{className:`flex w-full items-start gap-3`,style:{maxWidth:fe||void 0},children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:Ze(ze+1).length>0?(0,I.jsx)(rv,{items:Ze(ze+1)}):(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`no warnings on this slide · double click a box to edit it · ⇧ or a frame for several · right click for more`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-fg-2 hover:text-fg`,"aria-expanded":k,onClick:()=>ee(e=>!e),children:[(0,I.jsx)(R,{name:k?`expand_less`:`expand_more`,className:`ms-sm`}),`speaker notes`,Be.notes?.trim()?` ·`:``]})]}),(0,I.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,style:{maxWidth:fe||void 0},children:[k&&(0,I.jsx)(yt,{value:Be.notes??``,"aria-label":`speaker notes`,rows:3,placeholder:`what you say on this slide`,onChange:e=>We({notes:e.target.value},`notes`)}),(0,I.jsxs)(`form`,{className:`mt-1 flex items-center gap-2 rounded-2xl border border-line bg-surface px-3 py-1.5`,onSubmit:e=>{e.preventDefault(),Q()},children:[(0,I.jsx)(R,{name:`auto_awesome`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`input`,{ref:we,value:ge,"aria-label":`ask an agent`,placeholder:`ask an agent to change slide ${ze+1} or the deck…`,className:`h-8 min-w-0 flex-1 border-0 bg-transparent text-sm text-fg outline-none placeholder:text-fg-2`,onChange:e=>_e(e.target.value)}),(0,I.jsx)(K,{icon:`arrow_upward`,label:`send to an agent`,size:`sm`,disabled:!ge.trim(),onClick:()=>void Q()})]})]})]}),Ct&&Be?(0,I.jsx)(A_,{s:Ct,onChange:e=>Ge(Ct.name,e,`src:${Ct.name}`),onClose:()=>S(null)},`${ze}:${Ct.name}`):C===`format`&&Be&&Ve?(0,I.jsx)(O_,{theme:Fe,slide:Be,view:Ve,selected:g,assets:i.assets,onPatches:(e,t)=>We(f_(Be,e),t),onSlide:e=>We(e),numbers:o.numbers!==!1,onNumbers:e=>Ae(t=>({...t,numbers:e})),onUpload:st,onClose:()=>w(`none`)}):C===`design`?(0,I.jsx)(Z_,{themes:Pe,current:o.template,css:o.css,slide:Be,asset:Le,onTemplate:e=>Ae(t=>({...t,template:e})),onCss:e=>Ae(t=>({...t,css:e}),`css`)}):C===`history`?(0,I.jsx)(tv,{at:n,theme:Fe,asset:Le,onRestore:e=>{Ae(t=>({...t,title:e.deck.title||t.title,template:e.deck.template||t.template,css:e.deck.css??``,numbers:e.deck.numbers!==!1,slides:e.deck.slides.map(e=>({...e,extra:{...e.extra}}))})),h(0),O(`Restored the version from ${new Date(e.at).toLocaleString()}. ⌘Z takes it back; the version before it is in the history too.`)},onClose:()=>w(`none`)}):C===`comments`?(0,I.jsx)(nv,{at:n,comments:mt,slide:ze+1,slot:T,onSlot:E,onGo:(e,t)=>($e(e-1),t&&_([t])),onClose:()=>w(`none`)}):C===`chat`?(0,I.jsxs)(`div`,{className:`sticky top-3 flex h-[calc(100vh-130px)] flex-col overflow-hidden rounded-xl border border-line bg-surface`,role:`region`,"aria-label":`agent chat`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2 text-sm`,children:[(0,I.jsx)(R,{name:`forum`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:`Agent`}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`edits deck.md; the slide follows`}),(0,I.jsx)(`span`,{className:`flex-1`}),me&&(0,I.jsx)(K,{icon:`add_comment`,label:`new chat`,size:`sm`,onClick:()=>{he(null);try{localStorage.removeItem(I_(n))}catch{}}}),(0,I.jsx)(K,{icon:`close`,label:`close chat`,size:`sm`,onClick:()=>w(`none`)})]}),me?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,I.jsx)(Ko,{id:me},me)}):(0,I.jsx)(Y,{icon:`auto_awesome`,children:`Ask below the slide: “make slide 3 a comparison”, “add a chart of these numbers”, “tighten every title”. The agent edits the deck and you watch it change.`})]}):C===`markdown`&&Be?(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1 text-xs text-fg-2`,children:[`slots:`,Ve?.slots.map(e=>(0,I.jsx)(`code`,{className:`rounded bg-surface-2 px-1`,title:`${e.kind}${e.required?`, required`:``}`,children:e.name===`title`?`# title`:`::${e.name}::`},e.name))]}),(0,I.jsx)(yt,{value:Be.content,"aria-label":`slide content`,spellCheck:!1,className:`min-h-[380px] font-mono text-[13px] leading-5`,onChange:e=>We({content:e.target.value},`md`)}),i.assets.length>0&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`pictures: `,i.assets.join(`, `)]})]}):null]})]});async function Dt(){if(j===null)return;d(!0),p(``);let e=await A.request(`presentations.save`,{name:t,query:r,body:{source:j}});if(d(!1),!e.ok)return p(M(e));xe.current=e.data.updatedAt,Te.current.push({draft:De.current,at:Date.now()}),s(V_(e.data)),F(e.data.source),l(!1)}async function Ot(){let e=await A.request(`presentations.delete`,{name:t,query:r});if(!e.ok)return p(M(e));H(Qe,{replace:!0})}}function Z_({themes:e,current:t,css:n,slide:r,asset:i,onTemplate:a,onCss:o}){let[s,c]=(0,v.useState)(n);return(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-3 overflow-auto rounded-xl border border-line bg-surface p-3`,role:`region`,"aria-label":`design`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold`,children:`Theme`}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":e.slug===t,"aria-label":`theme ${e.name}`,className:P(`flex flex-col gap-1 rounded-md border-2 p-1 text-left`,e.slug===t?`border-accent`:`border-transparent hover:border-line-strong`),onClick:()=>a(e.slug),children:[r&&(0,I.jsx)(u_,{slide:r,theme:e,asset:i,width:150}),(0,I.jsx)(`span`,{className:`text-xs text-fg`,children:e.name})]},e.slug))}),(0,I.jsxs)(J,{children:[`A theme is a folder: `,(0,I.jsx)(`code`,{children:`templates/<name>/template.yml`}),` (layouts, colors, fonts, pieces) and `,(0,I.jsx)(`code`,{children:`theme.css`}),` with its fonts and pictures beside it. `,(0,I.jsx)(`code`,{children:`kraftwerk presentations templates init <name>`}),` starts one from the default; agents can write them too.`]}),(0,I.jsx)(`div`,{className:`text-sm font-semibold`,children:`This deck's CSS`}),(0,I.jsx)(`textarea`,{value:s,"aria-label":`deck css`,spellCheck:!1,placeholder:`.layout-title { background: linear-gradient(135deg, #0284c7, #312e81); }
471
- .slot-title { letter-spacing: -0.03em; }`,className:`min-h-[180px] resize-y rounded-md border border-line bg-bg p-2 font-mono text-[12px] leading-5 text-fg outline-none focus:border-accent`,onChange:e=>{c(e.target.value),o(e.target.value)}}),(0,I.jsxs)(J,{children:[`Over the theme, for this deck only: `,(0,I.jsx)(`code`,{children:`.layout-<name>`}),` a layout, `,(0,I.jsx)(`code`,{children:`.slot-<name>`}),` a box, `,(0,I.jsx)(`code`,{children:`--c-accent`}),` and the other colors as variables, `,(0,I.jsx)(`code`,{children:`attr(data-nn)`}),` the slide number.`]})]})}var Q_=[`#e11d48`,`#7c3aed`,`#059669`,`#d97706`,`#0891b2`,`#db2777`,`#4f46e5`,`#65a30d`],$_=e=>Q_[[...e].reduce((e,t)=>e*31+t.charCodeAt(0)>>>0,7)%Q_.length];function ev(e,t,n,r){let i=(0,v.useMemo)(()=>`t${Math.random().toString(36).slice(2,10)}`,[]),[a,o]=(0,v.useState)([]),s=M_(e.project),c=e.project?`${e.project}/${e.name}`:e.name;return(0,v.useEffect)(()=>j.subscribe(`deck.${c}@${i}`,{},e=>o(e.viewers??[])),[c,i]),(0,v.useEffect)(()=>{if(!r)return;let a=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:t,...n?{slot:n}:{}}}).catch(()=>{});a();let o=setInterval(a,8e3);return()=>clearInterval(o)},[c,i,t,n,r]),(0,v.useEffect)(()=>{let t=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:1,leave:!0}}).catch(()=>{});return window.addEventListener(`pagehide`,t),()=>{window.removeEventListener(`pagehide`,t),t()}},[c,i]),a.filter(e=>e.client!==i).map(e=>({...e,color:$_(e.client)}))}function tv({at:e,theme:t,asset:n,onRestore:r,onClose:i}){let a=M_(e.project),o=N(`presentations.history`,{name:e.name,query:a},{interval:8e3}),[s,c]=(0,v.useState)(null),l=N(`presentations.version`,s?{name:e.name,id:s,query:a}:null,{interval:6e5}),u=l&&l.id===s?l:null;return(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`version history`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(R,{name:`history`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:`Version history`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:`close`,label:`close history`,size:`sm`,onClick:i})]}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Kept before saves (once a minute while you edit) and whenever an agent or a tool changes deck.md. The newest 50 stay.`}),o&&o.versions.length===0&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`No earlier versions yet.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-1`,"aria-label":`versions`,children:(o?.versions??[]).map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-current":s===e.id,className:P(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,s===e.id&&`bg-surface-2`),onClick:()=>c(s===e.id?null:e.id),children:[(0,I.jsxs)(`span`,{className:`flex-1`,children:[(0,I.jsx)(`span`,{className:`block text-fg`,children:new Date(e.at).toLocaleString()}),(0,I.jsxs)(`span`,{className:`block text-xs text-fg-2`,children:[W(e.at),` · `,e.title,` · `,e.slides,` slide`,e.slides===1?``:`s`]})]}),(0,I.jsx)(R,{name:s===e.id?`expand_less`:`expand_more`,className:`ms-sm text-fg-2`})]}),s===e.id&&u&&(0,I.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 rounded-md border border-line p-2`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,"aria-label":`slides of this version`,children:u.deck.slides.map((e,r)=>(0,I.jsx)(`div`,{className:`overflow-hidden rounded border border-line`,children:(0,I.jsx)(u_,{slide:e,theme:t,asset:n,width:128,number:u.deck.numbers===!1?void 0:{n:r+1,of:u.deck.slides.length}})},r))}),(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`restore`,onClick:()=>r(u),children:`restore this version`})]})]},e.id))})]})}function nv({at:e,comments:t,slide:n,slot:r,onSlot:i,onGo:a,onClose:o}){let s=M_(e.project),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=async()=>{if(!c.trim())return;let t=await A.request(`presentations.comment`,{name:e.name,query:s,body:{slide:n,text:c,...r?{slot:r}:{}}});if(!t.ok)return h(M(t));l(``),h(``)},_=async(t,n)=>{let r=await A.request(`presentations.commentSave`,{name:e.name,id:t,query:s,body:n});if(!r.ok)return h(M(r));p(e=>({...e,[t]:``}))},y=async t=>{let n=await A.request(`presentations.commentDelete`,{name:e.name,id:t,query:s});n.ok||h(M(n))},b=t.filter(e=>u||!e.resolved).sort((e,t)=>(e.n===n?-1:0)-(t.n===n?-1:0)||(e.n??999)-(t.n??999)||e.at.localeCompare(t.at));return(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`comments`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(R,{name:`comment`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:`Comments`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-fg-2`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":`show resolved`}),`resolved`]}),(0,I.jsx)(K,{icon:`close`,label:`close comments`,size:`sm`,onClick:o})]}),(0,I.jsxs)(`form`,{className:`flex flex-col gap-1.5 rounded-lg border border-line bg-bg p-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`on slide `,n,r?(0,I.jsxs)(I.Fragment,{children:[` `,`· box `,(0,I.jsx)(`b`,{children:r}),` `,(0,I.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>i(void 0),children:`(the whole slide)`})]}):` (select a box to comment on it)`]}),(0,I.jsx)(`textarea`,{value:c,"aria-label":`new comment`,rows:2,placeholder:`What should change here?`,className:`resize-y rounded-md border border-line bg-surface p-1.5 text-sm text-fg outline-none focus:border-accent`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),void g())}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(G,{size:`sm`,variant:`primary`,type:`submit`,disabled:!c.trim(),children:`comment`})})]}),m&&(0,I.jsx)(`span`,{className:`text-xs text-bad`,children:m}),b.length===0&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`No `,u?``:`open `,"comments. Agents see them too: `kraftwerk presentations comments`."]}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`comment list`,children:b.map(e=>(0,I.jsxs)(`li`,{className:P(`flex flex-col gap-1 rounded-lg border p-2`,e.n===n?`border-accent/50`:`border-line`,e.resolved&&`opacity-60`),"aria-label":`comment by ${e.author}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`font-semibold text-fg hover:text-accent`,onClick:()=>e.n&&a(e.n,e.slot),children:[`slide `,e.n??`?`,e.slot?` · ${e.slot}`:``]}),(0,I.jsxs)(`span`,{children:[`· `,e.author]}),(0,I.jsxs)(`span`,{children:[`· `,W(e.at)]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:e.resolved?`replay`:`check_circle`,label:e.resolved?`reopen`:`resolve`,size:`sm`,onClick:()=>void _(e.id,{resolved:!e.resolved})}),(0,I.jsx)(K,{icon:`delete`,label:`delete comment`,size:`sm`,onClick:()=>void y(e.id)})]}),(0,I.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.text}),e.replies.map((e,t)=>(0,I.jsxs)(`p`,{className:`ml-3 border-l-2 border-line pl-2 text-xs`,children:[(0,I.jsx)(`b`,{children:e.author}),` · `,W(e.at),(0,I.jsx)(`br`,{}),e.text]},t)),!e.resolved&&(0,I.jsx)(`form`,{className:`flex gap-1`,onSubmit:t=>{t.preventDefault(),f[e.id]?.trim()&&_(e.id,{reply:f[e.id]})},children:(0,I.jsx)(`input`,{value:f[e.id]??``,"aria-label":`reply to ${e.id}`,placeholder:`reply…`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1.5 text-xs text-fg outline-none focus:border-accent`,onChange:t=>p(n=>({...n,[e.id]:t.target.value}))})})]},e.id))})]})}function rv({items:e}){return(0,I.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,"aria-label":`warnings`,children:e.map((e,t)=>(0,I.jsxs)(`li`,{className:P(`flex items-start gap-1.5`,e.level===`error`?`text-bad`:`text-fg-2`),children:[(0,I.jsx)(R,{name:e.level===`error`?`error`:`warning`,className:`ms-sm mt-px`}),(0,I.jsxs)(`span`,{children:[e.slide?`slide ${e.slide}`:`deck`,e.slot?` · ${e.slot}`:``,`: `,e.message]})]},t))})}function iv({project:e,name:t,presenter:n,start:r}){let i={project:e,name:t},a=N(`presentations.get`,{name:t,query:M_(e)},{interval:1e4}),o=(a?.deck.slides??[]).map((e,t)=>({s:e,i:t})).filter(e=>!U_(e.s)),s=Math.max(1,o.findIndex(e=>e.i>=r-1)+1),[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({w:window.innerWidth,h:window.innerHeight}),[m]=(0,v.useState)(Date.now()),[h,g]=(0,v.useState)(Date.now()),_=o.length,y=e=>a?.deck.numbers===!1?void 0:{n:e,of:_},b=N_(i),x=e=>l(Math.min(Math.max(1,e),Math.max(1,_))),S=a?.theme;o_(S?[S]:[],a?.deck.css);let C=(0,v.useMemo)(()=>F_(i,a?.updatedAt??``),[t,e,a?.updatedAt]),w=o[c-1]?.s,T=o[c]?.s,E=l_(w,S,C),D=l_(T,S,C);(0,v.useEffect)(()=>l(s),[s]),(0,v.useEffect)(()=>{let e=()=>p({w:window.innerWidth,h:window.innerHeight}),t=setInterval(()=>g(Date.now()),1e3),n=e=>{e.key===`ArrowRight`||e.key===` `||e.key===`PageDown`||e.key===`Enter`?(e.preventDefault(),l(e=>Math.min(e+1,Math.max(1,_)))):e.key===`ArrowLeft`||e.key===`PageUp`||e.key===`Backspace`?(e.preventDefault(),l(e=>Math.max(1,e-1))):e.key===`Home`?l(1):e.key===`End`?l(Math.max(1,_)):e.key===`Escape`?H(b):e.key===`n`||e.key===`N`?d(e=>!e):(e.key===`f`||e.key===`F`)&&document.documentElement.requestFullscreen?.().catch(()=>{})};return window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e),clearInterval(t)}},[_,b]);let O=S?Lg(S.size):900,k=Math.floor((h-m)/1e3),A=`${String(Math.floor(k/60)).padStart(2,`0`)}:${String(k%60).padStart(2,`0`)}`;if(n){let e=Math.min(f.w*.62,(f.h-120)*gg/O);return(0,I.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col gap-4 bg-[#111] p-6 text-white`,role:`region`,"aria-label":`presenter view`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-white/70`,children:[(0,I.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{children:a?.title}),(0,I.jsxs)(`span`,{className:`tabular-nums`,"aria-label":`slide counter`,children:[c,` / `,_]}),(0,I.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums text-white`,"aria-label":`elapsed time`,children:A})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`now`}),E&&S&&(0,I.jsx)(`div`,{role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,I.jsx)(c_,{view:E,theme:S,width:e,number:y(c)})})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,I.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`next`}),D&&S?(0,I.jsx)(c_,{view:D,theme:S,width:Math.min(360,f.w*.3),thumb:!0,number:y(c+1)}):(0,I.jsx)(`span`,{className:`text-sm text-white/40`,children:`the end`}),(0,I.jsx)(`span`,{className:`mt-2 text-xs uppercase tracking-wider text-white/50`,children:`notes`}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap text-xl leading-8 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,I.jsx)(`span`,{className:`text-white/40`,children:`no notes on this slide`})})]})]})]})}let ee=f.h-36-(u?Math.min(f.h*.3,180):0),j=Math.min(f.w,ee*gg/O);return(0,I.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col bg-black text-white`,role:`region`,"aria-label":`presentation`,children:[(0,I.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center`,children:[E&&S?(0,I.jsx)(`div`,{className:E.transition===`slide`?`animate-[deckslide_420ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`zoom`?`animate-[deckzoom_380ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`none`?``:`animate-[deckfade_300ms_ease-out] motion-reduce:animate-none`,"data-transition":E.transition,role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,I.jsx)(c_,{view:E,theme:S,width:j,number:y(c)})},c):(0,I.jsx)(`span`,{className:`text-white/60`,children:a?`this deck has no slides`:`loading…`}),(0,I.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 left-0 w-1/4 cursor-w-resize opacity-0`,"aria-label":`previous slide`,onClick:()=>x(c-1)}),(0,I.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 w-1/4 cursor-e-resize opacity-0`,"aria-label":`next slide`,onClick:()=>x(c+1)})]}),u&&(0,I.jsx)(`div`,{className:`max-h-[30vh] overflow-auto border-t border-white/20 bg-black/90 px-6 py-3 text-base leading-6 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,I.jsx)(`span`,{className:`text-white/50`,children:`no notes on this slide`})}),(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-3 px-4 text-xs text-white/60`,children:[(0,I.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{children:a?.title}),(0,I.jsxs)(`span`,{children:[c,` / `,_]}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:A}),(0,I.jsx)(`button`,{type:`button`,className:P(`hover:text-white`,u&&`text-white`),onClick:()=>d(e=>!e),"aria-pressed":u,children:`notes (N)`}),(0,I.jsx)(`span`,{children:`fullscreen (F)`})]})]})}function av({project:e,name:t}){let n={project:e,name:t},r=N(`presentations.get`,{name:t,query:M_(e)},{interval:1e4}),i=r?.theme;o_(i?[i]:[],r?.deck.css);let a=(0,v.useMemo)(()=>F_(n,r?.updatedAt??``),[t,e,r?.updatedAt]),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(()=>c(Math.floor(e.clientWidth)));return t.observe(e),()=>t.disconnect()},[]);let l=r?.deck.slides??[],u=r?.deck.numbers!==!1;return(0,I.jsxs)(`div`,{ref:o,className:`deck-glance flex flex-col gap-3`,"aria-label":`slides`,children:[!r&&(0,I.jsx)(Y,{children:`loading…`}),r&&l.length===0&&(0,I.jsx)(Y,{icon:`slideshow`,children:`No slides yet.`}),i&&s>0&&l.map((e,t)=>(0,I.jsx)(U,{href:N_(n),className:P(`block overflow-hidden rounded-lg border border-line no-underline shadow-sm transition-shadow hover:shadow-md`,U_(e)&&`opacity-40`),title:`slide ${t+1}`,"data-slide":t+1,children:(0,I.jsx)(u_,{slide:e,theme:i,asset:a,width:s-2,number:u?{n:t+1,of:l.length}:void 0})},t))]})}var ov=e=>e==null?``:String(e),sv={contacts:{singular:`contact`,icon:`person`,what:`people and organisations the workspace works with`,fields:[{name:`role`,label:`role`,type:`text`,hint:`What they do (CTO, project lead)`},{name:`org`,label:`organisation`,type:`text`,hint:`Company or organisation`},{name:`email`,label:`email`,type:`email`,hint:`Email address`},{name:`phone`,label:`phone`,type:`text`,hint:`Phone number`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place they are usually at`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>[ov(e.role),ov(e.org)].filter(Boolean).join(`, `)},places:{singular:`place`,icon:`location_on`,what:`addresses and points of interest`,fields:[{name:`address`,label:`address`,type:`text`,hint:`Street, number, postcode, town`},{name:`lat`,label:`latitude`,type:`number`,hint:`47.05`},{name:`lng`,label:`longitude`,type:`number`,hint:`8.30`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>ov(e.address)},events:{singular:`event`,icon:`event`,what:`dated, one-off entries — a meeting, a launch, a deadline`,fields:[{name:`start`,label:`start`,type:`date`,required:!0,hint:`2026-11-03 or 2026-11-03T14:00`},{name:`end`,label:`end`,type:`date`,hint:`not before start`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place`},{name:`contacts`,label:`contacts`,type:`refs`,refKind:`contacts`,hint:`Contact slugs, comma-separated`},{name:`project`,label:`project`,type:`ref`,refKind:`projects`,hint:`Slug of the project`},{name:`url`,label:`link`,type:`url`,hint:`https://…`}],describe:e=>`${ov(e.start).replace(`T`,` `)}${e.end?`–${ov(e.end).replace(`T`,` `)}`:``}`}},cv=(e,t)=>`${e}.${t}`,lv=(e,t)=>A.request(cv(e,`get`),{slug:t}),uv=(e,t,n)=>A.request(cv(e,`save`),{slug:t,body:n}),dv=(e,t)=>A.request(cv(e,`create`),{body:t}),fv=(e,t)=>A.request(cv(e,`delete`),{slug:t}),pv=()=>new Date().toISOString().slice(0,10);function mv(e,t){if(e!==`events`)return t;let n=pv(),r=t.filter(e=>ov(e.end||e.start).slice(0,10)>=n),i=t.filter(e=>ov(e.end||e.start).slice(0,10)<n).reverse();return[...r,...i]}function hv({kind:e,slug:t}){let n=sv[e],r=N(cv(e,`list`),{}),[i,a]=(0,v.useState)(``),o=mv(e,r?.items??[]),s=i.trim()?o.filter(e=>`${e.title} ${e.slug} ${n.describe(e)} ${e.tags.join(` `)}`.toLowerCase().includes(i.trim().toLowerCase())):o,c=t===`new`,l=e===`events`?new Set(o.filter(e=>ov(e.end||e.start).slice(0,10)<pv()).map(e=>e.slug)):new Set;return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:e,count:r?.items.length,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/${e}/new`,children:`new`})}),o.length>6&&(0,I.jsx)(Dt,{value:i,placeholder:`find a ${n.singular}…`,"aria-label":`find a ${n.singular}`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{label:e,children:[s.map(r=>(0,I.jsx)(mt,{href:`/${e}/${encodeURIComponent(r.slug)}`,active:r.slug===t,size:`sm`,dim:l.has(r.slug),leading:r.configError?(0,I.jsx)($e,{tone:`bad`,title:r.configError}):(0,I.jsx)(R,{name:n.icon,className:`ms-sm`}),title:r.title,sub:r.configError?`unreadable frontmatter`:n.describe(r)||void 0},r.slug)),r&&!r.enabled&&(0,I.jsx)(kt,{children:r.error}),r?.enabled&&o.length===0&&(0,I.jsxs)(kt,{children:[`no `,e,` yet`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:t&&!c?(0,I.jsx)(vv,{kind:e,slug:t},`${e}/${t}`):c?(0,I.jsx)(yv,{kind:e}):(0,I.jsx)(Y,{icon:n.icon,action:r?.enabled?(0,I.jsxs)(G,{variant:`primary`,icon:`add`,href:`/${e}/new`,children:[`new `,n.singular]}):void 0,children:r&&!r.enabled?r.error:(0,I.jsxs)(I.Fragment,{children:[e,`: `,n.what,`. One Markdown file each under the `,e,` root; reference one anywhere as `,(0,I.jsxs)(`code`,{children:[n.singular,`:<slug>`]}),`.`]})})})]})}function gv({field:e,value:t,onChange:n,disabled:r}){return(0,I.jsx)(Z,{value:t,placeholder:e.hint,"aria-label":`${e.label}`,inputMode:e.type===`number`?`decimal`:void 0,type:e.type===`email`?`email`:`text`,disabled:r,onChange:e=>n(e.target.value)})}function _v({links:e,refKind:t}){return e?.length?(0,I.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,I.jsxs)(q,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`not found in this workspace`,children:[e.found?(0,I.jsx)(U,{href:`/${t}/${encodeURIComponent(e.slug)}`,className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`]},e.slug))}):null}function vv({kind:e,slug:t}){let n=sv[e],[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!0),O=e=>{i(e),c(e.title),u(Object.fromEntries(n.fields.map(t=>[t.name,Array.isArray(e[t.name])?e[t.name].join(`, `):ov(e[t.name])]))),f(e.tags.join(`, `)),m(e.notes),g(!1)};(0,v.useEffect)(()=>{let n=!0;return lv(e,t).then(e=>{n&&(e.ok?O(e.data):o(M(e)))}),()=>{n=!1}},[e,t]);let k=()=>{g(!0),x(!1),C(``)},A=async(n,r={})=>{y(!0),C(``);try{let a=await uv(e,t,n);if(!a.ok)throw Error(M(a));r.keepEdits?i(a.data):(O(a.data),D(!0)),x(!0)}catch(e){C(e.message)}finally{y(!1)}},ee=()=>A({title:s,tags:d,notes:p,...Object.fromEntries(n.fields.map(e=>[e.name,l[e.name]??``]))}),j=async()=>{let n=await fv(e,t);if(!n.ok)return C(M(n));H(`/${e}`,{replace:!0})},N=(0,v.useMemo)(()=>p.trim()?To(Da.sanitize(Jr.parse(p,{async:!1}))):``,[p]);if(a&&!r)return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:n.icon,title:t}),(0,I.jsx)(tt,{tone:`bad`,children:a})]});if(!r)return(0,I.jsx)(Y,{children:`loading…`});let P=e===`places`?ov(r.mapsUrl):``;return(0,I.jsxs)(ot,{className:`${n.singular}-page`,children:[(0,I.jsx)(at,{icon:n.icon,title:(0,I.jsx)(Z,{value:s,"aria-label":`${n.singular} title`,className:`h-auto border-0 bg-transparent px-0 text-xl font-semibold shadow-none`,onChange:e=>{c(e.target.value),k()}}),sub:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`font-mono text-xs`,children:[n.singular,`:`,r.slug]}),r.updatedAt&&(0,I.jsxs)(`span`,{children:[`changed `,W(r.updatedAt)]}),P&&(0,I.jsxs)(`a`,{href:P,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent`,children:[(0,I.jsx)(R,{name:`map`,className:`ms-sm`}),` open in Google Maps`]})]}),actions:(0,I.jsxs)(I.Fragment,{children:[S&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:S}),b&&!h&&(0,I.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,I.jsx)(G,{variant:`primary`,icon:`save`,busy:_,disabled:!h||_||!s.trim(),onClick:()=>void ee(),children:`save`}),w?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,onClick:()=>void j(),children:`move to trash`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>T(!1),children:`cancel`})]}):(0,I.jsx)(G,{variant:`quiet`,icon:`delete`,title:`move to the trash`,onClick:()=>T(!0),children:`remove`})]})}),r.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`frontmatter: `,r.configError,` — the fields below show defaults and cannot be saved; fix the file by hand first.`]}),(0,I.jsx)(X,{title:`fields`,className:`flex-none`,children:(0,I.jsxs)(xt,{className:`max-w-[760px]`,children:[n.fields.map(e=>(0,I.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,hint:e.type===`ref`||e.type===`refs`?(0,I.jsx)(_v,{links:r.links[e.name],refKind:e.refKind}):void 0,children:(0,I.jsx)(gv,{field:e,value:l[e.name]??``,onChange:t=>{u(n=>({...n,[e.name]:t})),k()}})},e.name)),(0,I.jsx)(St,{children:(0,I.jsx)(Q,{label:`tags`,className:`flex-1`,children:(0,I.jsx)(Z,{value:d,placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>{f(e.target.value),k()}})})}),r.extra&&Object.keys(r.extra).length>0&&(0,I.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[`Also in the file, kept as written: `,Object.entries(r.extra).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`).join(` · `)]})]})}),(0,I.jsx)(X,{title:`notes`,className:`flex-none`,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:E?`edit`:`visibility`,onClick:()=>D(e=>!e),children:E?`edit`:`preview`}),children:E?N?(0,I.jsx)(`div`,{className:`md-body px-[18px] py-3`,dangerouslySetInnerHTML:{__html:N}}):(0,I.jsx)(`div`,{className:`px-[18px] py-3 text-xs text-fg-2`,children:`no notes yet — Markdown; reference other entries as contact:<slug>, place:<slug>, event:<slug>`}):(0,I.jsx)(xt,{children:(0,I.jsx)(yt,{value:p,"aria-label":`notes`,rows:10,className:`font-mono text-[13px]`,placeholder:`Markdown notes`,onChange:e=>{m(e.target.value),k()}})})}),(0,I.jsx)(Ss,{records:r.records,saving:_,onSave:e=>A({records:e},{keepEdits:!0})})]})}function yv({kind:e}){let t=sv[e],[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async()=>{s(!0),l(``);try{let t=await dv(e,{title:n,...i});if(!t.ok)throw Error(M(t));H(`/${e}/${encodeURIComponent(t.data.slug)}`,{replace:!0})}catch(e){l(e.message)}finally{s(!1)}};return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:t.icon,title:`new ${t.singular}`,sub:`a Markdown file under the ${e} root; the file name derives from the title`}),(0,I.jsx)(X,{children:(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&u()},children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:n,"aria-label":`${t.singular} title`,autoFocus:!0,placeholder:e===`contacts`?`e.g. Anna Meier`:e===`places`?`e.g. NETNODE Office`:`e.g. Kickoff`,onChange:e=>r(e.target.value)})}),t.fields.map(e=>(0,I.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,children:(0,I.jsx)(gv,{field:e,value:i[e.name]??``,onChange:t=>a(n=>({...n,[e.name]:t}))})},e.name)),(0,I.jsxs)(St,{children:[(0,I.jsxs)(G,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim()||o,children:[`create `,t.singular]}),(0,I.jsx)(G,{variant:`quiet`,href:`/${e}`,children:`cancel`}),c&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:c})]})]})})})]})}var bv=(0,v.lazy)(()=>Vl(()=>import(`./editor-CXOAhwnW.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),xv=()=>Vl(()=>import(`./editor-CXOAhwnW.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Sv({bundle:e,conceptId:t}){let n=N(`knowledge.list`,{}),[r,i]=(0,v.useState)([]);(0,v.useEffect)(()=>{n&&i(e=>e.filter(e=>n.bundles.some(t=>t.name===e)))},[n]);let a=(n?.bundles??[]).filter(e=>!r.includes(e.name)),o=e===`new`,s=a.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&s&&H(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`bundles`,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[a.map(t=>(0,I.jsx)(mt,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)($e,{tone:`ok`}),title:t.name,meta:t.concepts,sub:`${t.okfVersion?`okf ${t.okfVersion}`:`okf`}${t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``}`},t.name)),n&&a.length===0&&(0,I.jsx)(kt,{children:`no bundles yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,I.jsx)(kv,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),H(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,I.jsx)(Cv,{}):(0,I.jsx)(Y,{children:`loading…`})})]})}function Cv(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await A.request(`knowledge.create`,{body:{name:t}});a(!1),n.ok?H(`/knowledge/${encodeURIComponent(t)}`):r(M(n))}return(0,I.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,I.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,I.jsx)(Z,{className:`flex-1 font-mono text-sm`,value:e,placeholder:`bundle name, e.g. customer-support`,"aria-label":`bundle name`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,I.jsx)(G,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}function wv({tier:e}){return(0,I.jsx)(q,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var Tv=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,Ev=()=>(0,v.useContext)(he)!==null,Dv=`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Ov=`@activity`;function kv({name:e,conceptId:t,onRemoved:n}){let r=N(`knowledge.get`,{bundle:e}),i=Ev(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``);async function l(){let t=await A.request(`knowledge.delete`,{bundle:e}).catch(()=>null);t?.ok?n?n():H(`/knowledge`,{replace:!0}):(c(t?.error??`delete failed`),o(!1))}if(!r)return(0,I.jsx)(Y,{children:`loading…`});if(`error`in r)return(0,I.jsx)(Y,{icon:`menu_book`,children:`bundle not found`});let u=t===Ov?`activity`:`pages`,d=r.concepts,f=u===`pages`?t&&d.some(e=>e.id===t)?t:d[0]?.id:void 0,p=`/knowledge/${encodeURIComponent(e)}`;return(0,I.jsxs)(`div`,{className:P(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,I.jsxs)(`div`,{className:P(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,I.jsx)(it,{size:i?`md`:`lg`,children:e}),(0,I.jsxs)(`span`,{className:P(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,I.jsx)(ht,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${Ov}`,label:`activity`}]}),(0,I.jsx)(`span`,{className:`flex-1`}),!i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void Cs(e),children:`export PDF`}),a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`}),(0,I.jsx)(G,{variant:`primary`,onClick:()=>void Yo(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]})]}),s&&(0,I.jsx)(tt,{tone:`bad`,children:s}),u===`activity`?r.log?(0,I.jsx)(Mv,{name:e,log:r.log}):(0,I.jsx)(X,{children:(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,I.jsx)(X,{children:(0,I.jsxs)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,I.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,I.jsxs)(`div`,{className:P(`grid items-start`,i?`grid-cols-[170px_minmax(0,1fr)] gap-3.5 @max-[560px]:grid-cols-1`:`grid-cols-[260px_minmax(0,1fr)] gap-6 max-[1100px]:grid-cols-1`),children:[(0,I.jsx)(`aside`,{className:P(`flex flex-col gap-0.5 overflow-y-auto border-r border-line`,i?`sticky top-0 max-h-[calc(100vh-var(--topbar-h)-160px)] pr-2 pb-1.5 @max-[560px]:static @max-[560px]:max-h-[200px] @max-[560px]:border-r-0 @max-[560px]:pr-0`:`sticky top-[calc(var(--topbar-h)+18px)] max-h-[calc(100vh-var(--topbar-h)-36px)] py-1.5 pr-3 max-[1100px]:static max-[1100px]:max-h-none max-[1100px]:border-r-0 max-[1100px]:pr-0`),children:(0,I.jsx)(Pv,{concepts:d,base:p,selected:f})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:f&&(0,I.jsx)(Iv,{bundle:e,conceptId:f},f)})]})]})}function Av(e){let t=[];for(let n of e.split(`
471
+ .slot-title { letter-spacing: -0.03em; }`,className:`min-h-[180px] resize-y rounded-md border border-line bg-bg p-2 font-mono text-[12px] leading-5 text-fg outline-none focus:border-accent`,onChange:e=>{c(e.target.value),o(e.target.value)}}),(0,I.jsxs)(J,{children:[`Over the theme, for this deck only: `,(0,I.jsx)(`code`,{children:`.layout-<name>`}),` a layout, `,(0,I.jsx)(`code`,{children:`.slot-<name>`}),` a box, `,(0,I.jsx)(`code`,{children:`--c-accent`}),` and the other colors as variables, `,(0,I.jsx)(`code`,{children:`attr(data-nn)`}),` the slide number.`]})]})}var Q_=[`#e11d48`,`#7c3aed`,`#059669`,`#d97706`,`#0891b2`,`#db2777`,`#4f46e5`,`#65a30d`],$_=e=>Q_[[...e].reduce((e,t)=>e*31+t.charCodeAt(0)>>>0,7)%Q_.length];function ev(e,t,n,r){let i=(0,v.useMemo)(()=>`t${Math.random().toString(36).slice(2,10)}`,[]),[a,o]=(0,v.useState)([]),s=M_(e.project),c=e.project?`${e.project}/${e.name}`:e.name;return(0,v.useEffect)(()=>j.subscribe(`deck.${c}@${i}`,{},e=>o(e.viewers??[])),[c,i]),(0,v.useEffect)(()=>{if(!r)return;let a=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:t,...n?{slot:n}:{}}}).catch(()=>{});a();let o=setInterval(a,8e3);return()=>clearInterval(o)},[c,i,t,n,r]),(0,v.useEffect)(()=>{let t=()=>void A.request(`presentations.presence`,{name:e.name,query:s,body:{client:i,slide:1,leave:!0}}).catch(()=>{});return window.addEventListener(`pagehide`,t),()=>{window.removeEventListener(`pagehide`,t),t()}},[c,i]),a.filter(e=>e.client!==i).map(e=>({...e,color:$_(e.client)}))}function tv({at:e,theme:t,asset:n,onRestore:r,onClose:i}){let a=M_(e.project),o=N(`presentations.history`,{name:e.name,query:a},{interval:8e3}),[s,c]=(0,v.useState)(null),l=N(`presentations.version`,s?{name:e.name,id:s,query:a}:null,{interval:6e5}),u=l&&l.id===s?l:null;return(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`version history`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(R,{name:`history`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:`Version history`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:`close`,label:`close history`,size:`sm`,onClick:i})]}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Kept before saves (once a minute while you edit) and whenever an agent or a tool changes deck.md. The newest 50 stay.`}),o&&o.versions.length===0&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`No earlier versions yet.`}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-1`,"aria-label":`versions`,children:(o?.versions??[]).map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`button`,{type:`button`,"aria-current":s===e.id,className:P(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-surface-2`,s===e.id&&`bg-surface-2`),onClick:()=>c(s===e.id?null:e.id),children:[(0,I.jsxs)(`span`,{className:`flex-1`,children:[(0,I.jsx)(`span`,{className:`block text-fg`,children:new Date(e.at).toLocaleString()}),(0,I.jsxs)(`span`,{className:`block text-xs text-fg-2`,children:[W(e.at),` · `,e.title,` · `,e.slides,` slide`,e.slides===1?``:`s`]})]}),(0,I.jsx)(R,{name:s===e.id?`expand_less`:`expand_more`,className:`ms-sm text-fg-2`})]}),s===e.id&&u&&(0,I.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 rounded-md border border-line p-2`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,"aria-label":`slides of this version`,children:u.deck.slides.map((e,r)=>(0,I.jsx)(`div`,{className:`overflow-hidden rounded border border-line`,children:(0,I.jsx)(u_,{slide:e,theme:t,asset:n,width:128,number:u.deck.numbers===!1?void 0:{n:r+1,of:u.deck.slides.length}})},r))}),(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`restore`,onClick:()=>r(u),children:`restore this version`})]})]},e.id))})]})}function nv({at:e,comments:t,slide:n,slot:r,onSlot:i,onGo:a,onClose:o}){let s=M_(e.project),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(``),g=async()=>{if(!c.trim())return;let t=await A.request(`presentations.comment`,{name:e.name,query:s,body:{slide:n,text:c,...r?{slot:r}:{}}});if(!t.ok)return h(M(t));l(``),h(``)},_=async(t,n)=>{let r=await A.request(`presentations.commentSave`,{name:e.name,id:t,query:s,body:n});if(!r.ok)return h(M(r));p(e=>({...e,[t]:``}))},y=async t=>{let n=await A.request(`presentations.commentDelete`,{name:e.name,id:t,query:s});n.ok||h(M(n))},b=t.filter(e=>u||!e.resolved).sort((e,t)=>(e.n===n?-1:0)-(t.n===n?-1:0)||(e.n??999)-(t.n??999)||e.at.localeCompare(t.at));return(0,I.jsxs)(`div`,{className:`sticky top-3 flex max-h-[calc(100vh-130px)] flex-col gap-2 overflow-auto rounded-xl border border-line bg-surface p-3 text-sm`,role:`region`,"aria-label":`comments`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(R,{name:`comment`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:`Comments`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-fg-2`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),"aria-label":`show resolved`}),`resolved`]}),(0,I.jsx)(K,{icon:`close`,label:`close comments`,size:`sm`,onClick:o})]}),(0,I.jsxs)(`form`,{className:`flex flex-col gap-1.5 rounded-lg border border-line bg-bg p-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`on slide `,n,r?(0,I.jsxs)(I.Fragment,{children:[` `,`· box `,(0,I.jsx)(`b`,{children:r}),` `,(0,I.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>i(void 0),children:`(the whole slide)`})]}):` (select a box to comment on it)`]}),(0,I.jsx)(`textarea`,{value:c,"aria-label":`new comment`,rows:2,placeholder:`What should change here?`,className:`resize-y rounded-md border border-line bg-surface p-1.5 text-sm text-fg outline-none focus:border-accent`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),void g())}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(G,{size:`sm`,variant:`primary`,type:`submit`,disabled:!c.trim(),children:`comment`})})]}),m&&(0,I.jsx)(`span`,{className:`text-xs text-bad`,children:m}),b.length===0&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`No `,u?``:`open `,"comments. Agents see them too: `kraftwerk presentations comments`."]}),(0,I.jsx)(`ul`,{className:`flex flex-col gap-2`,"aria-label":`comment list`,children:b.map(e=>(0,I.jsxs)(`li`,{className:P(`flex flex-col gap-1 rounded-lg border p-2`,e.n===n?`border-accent/50`:`border-line`,e.resolved&&`opacity-60`),"aria-label":`comment by ${e.author}`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-2`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`font-semibold text-fg hover:text-accent`,onClick:()=>e.n&&a(e.n,e.slot),children:[`slide `,e.n??`?`,e.slot?` · ${e.slot}`:``]}),(0,I.jsxs)(`span`,{children:[`· `,e.author]}),(0,I.jsxs)(`span`,{children:[`· `,W(e.at)]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(K,{icon:e.resolved?`replay`:`check_circle`,label:e.resolved?`reopen`:`resolve`,size:`sm`,onClick:()=>void _(e.id,{resolved:!e.resolved})}),(0,I.jsx)(K,{icon:`delete`,label:`delete comment`,size:`sm`,onClick:()=>void y(e.id)})]}),(0,I.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.text}),e.replies.map((e,t)=>(0,I.jsxs)(`p`,{className:`ml-3 border-l-2 border-line pl-2 text-xs`,children:[(0,I.jsx)(`b`,{children:e.author}),` · `,W(e.at),(0,I.jsx)(`br`,{}),e.text]},t)),!e.resolved&&(0,I.jsx)(`form`,{className:`flex gap-1`,onSubmit:t=>{t.preventDefault(),f[e.id]?.trim()&&_(e.id,{reply:f[e.id]})},children:(0,I.jsx)(`input`,{value:f[e.id]??``,"aria-label":`reply to ${e.id}`,placeholder:`reply…`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1.5 text-xs text-fg outline-none focus:border-accent`,onChange:t=>p(n=>({...n,[e.id]:t.target.value}))})})]},e.id))})]})}function rv({items:e}){return(0,I.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,"aria-label":`warnings`,children:e.map((e,t)=>(0,I.jsxs)(`li`,{className:P(`flex items-start gap-1.5`,e.level===`error`?`text-bad`:`text-fg-2`),children:[(0,I.jsx)(R,{name:e.level===`error`?`error`:`warning`,className:`ms-sm mt-px`}),(0,I.jsxs)(`span`,{children:[e.slide?`slide ${e.slide}`:`deck`,e.slot?` · ${e.slot}`:``,`: `,e.message]})]},t))})}function iv({project:e,name:t,presenter:n,start:r}){let i={project:e,name:t},a=N(`presentations.get`,{name:t,query:M_(e)},{interval:1e4}),o=(a?.deck.slides??[]).map((e,t)=>({s:e,i:t})).filter(e=>!U_(e.s)),s=Math.max(1,o.findIndex(e=>e.i>=r-1)+1),[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)({w:window.innerWidth,h:window.innerHeight}),[m]=(0,v.useState)(Date.now()),[h,g]=(0,v.useState)(Date.now()),_=o.length,y=e=>a?.deck.numbers===!1?void 0:{n:e,of:_},b=N_(i),x=e=>l(Math.min(Math.max(1,e),Math.max(1,_))),S=a?.theme;o_(S?[S]:[],a?.deck.css);let C=(0,v.useMemo)(()=>F_(i,a?.updatedAt??``),[t,e,a?.updatedAt]),w=o[c-1]?.s,T=o[c]?.s,E=l_(w,S,C),D=l_(T,S,C);(0,v.useEffect)(()=>l(s),[s]),(0,v.useEffect)(()=>{let e=()=>p({w:window.innerWidth,h:window.innerHeight}),t=setInterval(()=>g(Date.now()),1e3),n=e=>{e.key===`ArrowRight`||e.key===` `||e.key===`PageDown`||e.key===`Enter`?(e.preventDefault(),l(e=>Math.min(e+1,Math.max(1,_)))):e.key===`ArrowLeft`||e.key===`PageUp`||e.key===`Backspace`?(e.preventDefault(),l(e=>Math.max(1,e-1))):e.key===`Home`?l(1):e.key===`End`?l(Math.max(1,_)):e.key===`Escape`?H(b):e.key===`n`||e.key===`N`?d(e=>!e):(e.key===`f`||e.key===`F`)&&document.documentElement.requestFullscreen?.().catch(()=>{})};return window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e),clearInterval(t)}},[_,b]);let O=S?Lg(S.size):900,k=Math.floor((h-m)/1e3),A=`${String(Math.floor(k/60)).padStart(2,`0`)}:${String(k%60).padStart(2,`0`)}`;if(n){let e=Math.min(f.w*.62,(f.h-120)*gg/O);return(0,I.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col gap-4 bg-[#111] p-6 text-white`,role:`region`,"aria-label":`presenter view`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-white/70`,children:[(0,I.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{children:a?.title}),(0,I.jsxs)(`span`,{className:`tabular-nums`,"aria-label":`slide counter`,children:[c,` / `,_]}),(0,I.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums text-white`,"aria-label":`elapsed time`,children:A})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-6`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`now`}),E&&S&&(0,I.jsx)(`div`,{role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,I.jsx)(c_,{view:E,theme:S,width:e,number:y(c)})})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,I.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-white/50`,children:`next`}),D&&S?(0,I.jsx)(c_,{view:D,theme:S,width:Math.min(360,f.w*.3),thumb:!0,number:y(c+1)}):(0,I.jsx)(`span`,{className:`text-sm text-white/40`,children:`the end`}),(0,I.jsx)(`span`,{className:`mt-2 text-xs uppercase tracking-wider text-white/50`,children:`notes`}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap text-xl leading-8 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,I.jsx)(`span`,{className:`text-white/40`,children:`no notes on this slide`})})]})]})]})}let ee=f.h-36-(u?Math.min(f.h*.3,180):0),j=Math.min(f.w,ee*gg/O);return(0,I.jsxs)(`div`,{className:`fixed inset-0 z-[1000] flex select-none flex-col bg-black text-white`,role:`region`,"aria-label":`presentation`,children:[(0,I.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center`,children:[E&&S?(0,I.jsx)(`div`,{className:E.transition===`slide`?`animate-[deckslide_420ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`zoom`?`animate-[deckzoom_380ms_cubic-bezier(.2,.7,.2,1)] motion-reduce:animate-none`:E.transition===`none`?``:`animate-[deckfade_300ms_ease-out] motion-reduce:animate-none`,"data-transition":E.transition,role:`img`,"aria-label":`slide ${c} of ${_}`,children:(0,I.jsx)(c_,{view:E,theme:S,width:j,number:y(c)})},c):(0,I.jsx)(`span`,{className:`text-white/60`,children:a?`this deck has no slides`:`loading…`}),(0,I.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 left-0 w-1/4 cursor-w-resize opacity-0`,"aria-label":`previous slide`,onClick:()=>x(c-1)}),(0,I.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 w-1/4 cursor-e-resize opacity-0`,"aria-label":`next slide`,onClick:()=>x(c+1)})]}),u&&(0,I.jsx)(`div`,{className:`max-h-[30vh] overflow-auto border-t border-white/20 bg-black/90 px-6 py-3 text-base leading-6 text-white/90`,"aria-label":`speaker notes`,children:w?.notes||(0,I.jsx)(`span`,{className:`text-white/50`,children:`no notes on this slide`})}),(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-3 px-4 text-xs text-white/60`,children:[(0,I.jsx)(`button`,{type:`button`,className:`hover:text-white`,onClick:()=>H(b),children:`← back to the editor (Esc)`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{children:a?.title}),(0,I.jsxs)(`span`,{children:[c,` / `,_]}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:A}),(0,I.jsx)(`button`,{type:`button`,className:P(`hover:text-white`,u&&`text-white`),onClick:()=>d(e=>!e),"aria-pressed":u,children:`notes (N)`}),(0,I.jsx)(`span`,{children:`fullscreen (F)`})]})]})}function av({project:e,name:t}){let n={project:e,name:t},r=N(`presentations.get`,{name:t,query:M_(e)},{interval:1e4}),i=r?.theme;o_(i?[i]:[],r?.deck.css);let a=(0,v.useMemo)(()=>F_(n,r?.updatedAt??``),[t,e,r?.updatedAt]),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=o.current;if(!e)return;let t=new ResizeObserver(()=>c(Math.floor(e.clientWidth)));return t.observe(e),()=>t.disconnect()},[]);let l=r?.deck.slides??[],u=r?.deck.numbers!==!1;return(0,I.jsxs)(`div`,{ref:o,className:`deck-glance flex flex-col gap-3`,"aria-label":`slides`,children:[!r&&(0,I.jsx)(Y,{children:`loading…`}),r&&l.length===0&&(0,I.jsx)(Y,{icon:`slideshow`,children:`No slides yet.`}),i&&s>0&&l.map((e,t)=>(0,I.jsx)(U,{href:N_(n),className:P(`block overflow-hidden rounded-lg border border-line no-underline shadow-sm transition-shadow hover:shadow-md`,U_(e)&&`opacity-40`),title:`slide ${t+1}`,"data-slide":t+1,children:(0,I.jsx)(u_,{slide:e,theme:i,asset:a,width:s-2,number:u?{n:t+1,of:l.length}:void 0})},t))]})}var ov=e=>e==null?``:String(e),sv={contacts:{singular:`contact`,icon:`person`,what:`people and organisations the workspace works with`,fields:[{name:`role`,label:`role`,type:`text`,hint:`What they do (CTO, project lead)`},{name:`org`,label:`organisation`,type:`text`,hint:`Company or organisation`},{name:`email`,label:`email`,type:`email`,hint:`Email address`},{name:`phone`,label:`phone`,type:`text`,hint:`Phone number`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place they are usually at`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>[ov(e.role),ov(e.org)].filter(Boolean).join(`, `)},places:{singular:`place`,icon:`location_on`,what:`addresses and points of interest`,fields:[{name:`address`,label:`address`,type:`text`,hint:`Street, number, postcode, town`},{name:`lat`,label:`latitude`,type:`number`,hint:`47.05`},{name:`lng`,label:`longitude`,type:`number`,hint:`8.30`},{name:`url`,label:`website`,type:`url`,hint:`https://…`}],describe:e=>ov(e.address)},events:{singular:`event`,icon:`event`,what:`dated, one-off entries — a meeting, a launch, a deadline`,fields:[{name:`start`,label:`start`,type:`date`,required:!0,hint:`2026-11-03 or 2026-11-03T14:00`},{name:`end`,label:`end`,type:`date`,hint:`not before start`},{name:`place`,label:`place`,type:`ref`,refKind:`places`,hint:`Slug of the place`},{name:`contacts`,label:`contacts`,type:`refs`,refKind:`contacts`,hint:`Contact slugs, comma-separated`},{name:`project`,label:`project`,type:`ref`,refKind:`projects`,hint:`Slug of the project`},{name:`url`,label:`link`,type:`url`,hint:`https://…`}],describe:e=>`${ov(e.start).replace(`T`,` `)}${e.end?`–${ov(e.end).replace(`T`,` `)}`:``}`}},cv=(e,t)=>`${e}.${t}`,lv=(e,t)=>A.request(cv(e,`get`),{slug:t}),uv=(e,t,n)=>A.request(cv(e,`save`),{slug:t,body:n}),dv=(e,t)=>A.request(cv(e,`create`),{body:t}),fv=(e,t)=>A.request(cv(e,`delete`),{slug:t}),pv=()=>new Date().toISOString().slice(0,10);function mv(e,t){if(e!==`events`)return t;let n=pv(),r=t.filter(e=>ov(e.end||e.start).slice(0,10)>=n),i=t.filter(e=>ov(e.end||e.start).slice(0,10)<n).reverse();return[...r,...i]}function hv({kind:e,slug:t}){let n=sv[e],r=N(cv(e,`list`),{}),[i,a]=(0,v.useState)(``),o=mv(e,r?.items??[]),s=i.trim()?o.filter(e=>`${e.title} ${e.slug} ${n.describe(e)} ${e.tags.join(` `)}`.toLowerCase().includes(i.trim().toLowerCase())):o,c=t===`new`,l=e===`events`?new Set(o.filter(e=>ov(e.end||e.start).slice(0,10)<pv()).map(e=>e.slug)):new Set;return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:e,count:r?.items.length,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/${e}/new`,children:`new`})}),o.length>6&&(0,I.jsx)(Dt,{value:i,placeholder:`find a ${n.singular}…`,"aria-label":`find a ${n.singular}`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Ot,{label:e,children:[s.map(r=>(0,I.jsx)(mt,{href:`/${e}/${encodeURIComponent(r.slug)}`,active:r.slug===t,size:`sm`,dim:l.has(r.slug),leading:r.configError?(0,I.jsx)($e,{tone:`bad`,title:r.configError}):(0,I.jsx)(R,{name:n.icon,className:`ms-sm`}),title:r.title,sub:r.configError?`unreadable frontmatter`:n.describe(r)||void 0},r.slug)),r&&!r.enabled&&(0,I.jsx)(kt,{children:r.error}),r?.enabled&&o.length===0&&(0,I.jsxs)(kt,{children:[`no `,e,` yet`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:t&&!c?(0,I.jsx)(vv,{kind:e,slug:t},`${e}/${t}`):c?(0,I.jsx)(yv,{kind:e}):(0,I.jsx)(Y,{icon:n.icon,action:r?.enabled?(0,I.jsxs)(G,{variant:`primary`,icon:`add`,href:`/${e}/new`,children:[`new `,n.singular]}):void 0,children:r&&!r.enabled?r.error:(0,I.jsxs)(I.Fragment,{children:[e,`: `,n.what,`. One Markdown file each under the `,e,` root; reference one anywhere as `,(0,I.jsxs)(`code`,{children:[n.singular,`:<slug>`]}),`.`]})})})]})}function gv({field:e,value:t,onChange:n,disabled:r}){return(0,I.jsx)(Z,{value:t,placeholder:e.hint,"aria-label":`${e.label}`,inputMode:e.type===`number`?`decimal`:void 0,type:e.type===`email`?`email`:`text`,disabled:r,onChange:e=>n(e.target.value)})}function _v({links:e,refKind:t}){return e?.length?(0,I.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,I.jsxs)(q,{tone:e.found?`neutral`:`bad`,title:e.found?e.label:`not found in this workspace`,children:[e.found?(0,I.jsx)(U,{href:`/${t}/${encodeURIComponent(e.slug)}`,className:`text-inherit no-underline hover:underline`,children:e.slug}):e.slug,!e.found&&` · not found`]},e.slug))}):null}function vv({kind:e,slug:t}){let n=sv[e],[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!0),O=e=>{i(e),c(e.title),u(Object.fromEntries(n.fields.map(t=>[t.name,Array.isArray(e[t.name])?e[t.name].join(`, `):ov(e[t.name])]))),f(e.tags.join(`, `)),m(e.notes),g(!1)};(0,v.useEffect)(()=>{let n=!0;return lv(e,t).then(e=>{n&&(e.ok?O(e.data):o(M(e)))}),()=>{n=!1}},[e,t]);let k=()=>{g(!0),x(!1),C(``)},A=async(n,r={})=>{y(!0),C(``);try{let a=await uv(e,t,n);if(!a.ok)throw Error(M(a));r.keepEdits?i(a.data):(O(a.data),D(!0)),x(!0)}catch(e){C(e.message)}finally{y(!1)}},ee=()=>A({title:s,tags:d,notes:p,...Object.fromEntries(n.fields.map(e=>[e.name,l[e.name]??``]))}),j=async()=>{let n=await fv(e,t);if(!n.ok)return C(M(n));H(`/${e}`,{replace:!0})},N=(0,v.useMemo)(()=>p.trim()?To(Da.sanitize(Jr.parse(p,{async:!1}))):``,[p]);if(a&&!r)return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:n.icon,title:t}),(0,I.jsx)(tt,{tone:`bad`,children:a})]});if(!r)return(0,I.jsx)(Y,{children:`loading…`});let P=e===`places`?ov(r.mapsUrl):``;return(0,I.jsxs)(ot,{className:`${n.singular}-page`,children:[(0,I.jsx)(at,{icon:n.icon,title:(0,I.jsx)(Z,{value:s,"aria-label":`${n.singular} title`,className:`h-auto border-0 bg-transparent px-0 text-xl font-semibold shadow-none`,onChange:e=>{c(e.target.value),k()}}),sub:(0,I.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`font-mono text-xs`,children:[n.singular,`:`,r.slug]}),r.updatedAt&&(0,I.jsxs)(`span`,{children:[`changed `,W(r.updatedAt)]}),P&&(0,I.jsxs)(`a`,{href:P,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent`,children:[(0,I.jsx)(R,{name:`map`,className:`ms-sm`}),` open in Google Maps`]})]}),actions:(0,I.jsxs)(I.Fragment,{children:[S&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:S}),b&&!h&&(0,I.jsx)(`span`,{className:`text-sm text-fg-2`,children:`saved`}),(0,I.jsx)(G,{variant:`primary`,icon:`save`,busy:_,disabled:!h||_||!s.trim(),onClick:()=>void ee(),children:`save`}),w?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{variant:`danger`,onClick:()=>void j(),children:`move to trash`}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>T(!1),children:`cancel`})]}):(0,I.jsx)(G,{variant:`quiet`,icon:`delete`,title:`move to the trash`,onClick:()=>T(!0),children:`remove`})]})}),r.configError&&(0,I.jsxs)(tt,{tone:`bad`,children:[`frontmatter: `,r.configError,` — the fields below show defaults and cannot be saved; fix the file by hand first.`]}),(0,I.jsx)(X,{title:`fields`,className:`flex-none`,children:(0,I.jsxs)(xt,{className:`max-w-[760px]`,children:[n.fields.map(e=>(0,I.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,hint:e.type===`ref`||e.type===`refs`?(0,I.jsx)(_v,{links:r.links[e.name],refKind:e.refKind}):void 0,children:(0,I.jsx)(gv,{field:e,value:l[e.name]??``,onChange:t=>{u(n=>({...n,[e.name]:t})),k()}})},e.name)),(0,I.jsx)(St,{children:(0,I.jsx)(Q,{label:`tags`,className:`flex-1`,children:(0,I.jsx)(Z,{value:d,placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>{f(e.target.value),k()}})})}),r.extra&&Object.keys(r.extra).length>0&&(0,I.jsxs)(`div`,{className:`text-xs text-fg-2`,children:[`Also in the file, kept as written: `,Object.entries(r.extra).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`).join(` · `)]})]})}),(0,I.jsx)(X,{title:`notes`,className:`flex-none`,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:E?`edit`:`visibility`,onClick:()=>D(e=>!e),children:E?`edit`:`preview`}),children:E?N?(0,I.jsx)(`div`,{className:`md-body px-[18px] py-3`,dangerouslySetInnerHTML:{__html:N}}):(0,I.jsx)(`div`,{className:`px-[18px] py-3 text-xs text-fg-2`,children:`no notes yet — Markdown; reference other entries as contact:<slug>, place:<slug>, event:<slug>`}):(0,I.jsx)(xt,{children:(0,I.jsx)(yt,{value:p,"aria-label":`notes`,rows:10,className:`font-mono text-[13px]`,placeholder:`Markdown notes`,onChange:e=>{m(e.target.value),k()}})})}),(0,I.jsx)(Ss,{records:r.records,saving:_,onSave:e=>A({records:e},{keepEdits:!0})})]})}function yv({kind:e}){let t=sv[e],[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async()=>{s(!0),l(``);try{let t=await dv(e,{title:n,...i});if(!t.ok)throw Error(M(t));H(`/${e}/${encodeURIComponent(t.data.slug)}`,{replace:!0})}catch(e){l(e.message)}finally{s(!1)}};return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:t.icon,title:`new ${t.singular}`,sub:`a Markdown file under the ${e} root; the file name derives from the title`}),(0,I.jsx)(X,{children:(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&u()},children:(0,I.jsxs)(xt,{className:`max-w-[680px]`,children:[(0,I.jsx)(Q,{label:`title`,children:(0,I.jsx)(Z,{value:n,"aria-label":`${t.singular} title`,autoFocus:!0,placeholder:e===`contacts`?`e.g. Anna Meier`:e===`places`?`e.g. NETNODE Office`:`e.g. Kickoff`,onChange:e=>r(e.target.value)})}),t.fields.map(e=>(0,I.jsx)(Q,{label:`${e.label}${e.required?` *`:``}`,children:(0,I.jsx)(gv,{field:e,value:i[e.name]??``,onChange:t=>a(n=>({...n,[e.name]:t}))})},e.name)),(0,I.jsxs)(St,{children:[(0,I.jsxs)(G,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim()||o,children:[`create `,t.singular]}),(0,I.jsx)(G,{variant:`quiet`,href:`/${e}`,children:`cancel`}),c&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:c})]})]})})})]})}var bv=(0,v.lazy)(()=>Vl(()=>import(`./editor-D7Y97r7h.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),xv=()=>Vl(()=>import(`./editor-D7Y97r7h.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Sv({bundle:e,conceptId:t}){let n=N(`knowledge.list`,{}),[r,i]=(0,v.useState)([]);(0,v.useEffect)(()=>{n&&i(e=>e.filter(e=>n.bundles.some(t=>t.name===e)))},[n]);let a=(n?.bundles??[]).filter(e=>!r.includes(e.name)),o=e===`new`,s=a.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&s&&H(`/knowledge/${encodeURIComponent(s.name)}`,{replace:!0})},[e,s?.name]),(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`bundles`,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,I.jsxs)(Ot,{children:[a.map(t=>(0,I.jsx)(mt,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)($e,{tone:`ok`}),title:t.name,meta:t.concepts,sub:`${t.okfVersion?`okf ${t.okfVersion}`:`okf`}${t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``}`},t.name)),n&&a.length===0&&(0,I.jsx)(kt,{children:`no bundles yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,I.jsx)(kv,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),H(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,I.jsx)(Cv,{}):(0,I.jsx)(Y,{children:`loading…`})})]})}function Cv(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await A.request(`knowledge.create`,{body:{name:t}});a(!1),n.ok?H(`/knowledge/${encodeURIComponent(t)}`):r(M(n))}return(0,I.jsxs)(`div`,{className:`empty-action flex flex-col items-center gap-3 px-4 py-16`,children:[(0,I.jsxs)(`div`,{className:`flex w-full max-w-[520px] gap-2.5`,children:[(0,I.jsx)(Z,{className:`flex-1 font-mono text-sm`,value:e,placeholder:`bundle name, e.g. customer-support`,"aria-label":`bundle name`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,I.jsx)(G,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}function wv({tier:e}){return(0,I.jsx)(q,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var Tv=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,Ev=()=>(0,v.useContext)(he)!==null,Dv=`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Ov=`@activity`;function kv({name:e,conceptId:t,onRemoved:n}){let r=N(`knowledge.get`,{bundle:e}),i=Ev(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``);async function l(){let t=await A.request(`knowledge.delete`,{bundle:e}).catch(()=>null);t?.ok?n?n():H(`/knowledge`,{replace:!0}):(c(t?.error??`delete failed`),o(!1))}if(!r)return(0,I.jsx)(Y,{children:`loading…`});if(`error`in r)return(0,I.jsx)(Y,{icon:`menu_book`,children:`bundle not found`});let u=t===Ov?`activity`:`pages`,d=r.concepts,f=u===`pages`?t&&d.some(e=>e.id===t)?t:d[0]?.id:void 0,p=`/knowledge/${encodeURIComponent(e)}`;return(0,I.jsxs)(`div`,{className:P(`agent-view @container flex flex-col`,i?`gap-2.5`:`gap-4`),children:[(0,I.jsxs)(`div`,{className:P(`flex flex-wrap items-center gap-x-4 gap-y-2`,i?`mb-0.5`:`mx-0.5 mt-1 mb-2`),children:[(0,I.jsx)(it,{size:i?`md`:`lg`,children:e}),(0,I.jsxs)(`span`,{className:P(`text-fg-2`,i?`text-[12.5px]`:`text-base`),children:[d.length,` pages`]}),(0,I.jsx)(ht,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${Ov}`,label:`activity`}]}),(0,I.jsx)(`span`,{className:`flex-1`}),!i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void Cs(e),children:`export PDF`}),a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`}),(0,I.jsx)(G,{variant:`primary`,onClick:()=>void Yo(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]})]}),s&&(0,I.jsx)(tt,{tone:`bad`,children:s}),u===`activity`?r.log?(0,I.jsx)(Mv,{name:e,log:r.log}):(0,I.jsx)(X,{children:(0,I.jsx)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:`no activity yet`})}):d.length===0?(0,I.jsx)(X,{children:(0,I.jsxs)(`p`,{className:`m-0 px-[18px] py-3 text-sm text-fg-2`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,I.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,I.jsxs)(`div`,{className:P(`grid items-start`,i?`grid-cols-[170px_minmax(0,1fr)] gap-3.5 @max-[560px]:grid-cols-1`:`grid-cols-[260px_minmax(0,1fr)] gap-6 max-[1100px]:grid-cols-1`),children:[(0,I.jsx)(`aside`,{className:P(`flex flex-col gap-0.5 overflow-y-auto border-r border-line`,i?`sticky top-0 max-h-[calc(100vh-var(--topbar-h)-160px)] pr-2 pb-1.5 @max-[560px]:static @max-[560px]:max-h-[200px] @max-[560px]:border-r-0 @max-[560px]:pr-0`:`sticky top-[calc(var(--topbar-h)+18px)] max-h-[calc(100vh-var(--topbar-h)-36px)] py-1.5 pr-3 max-[1100px]:static max-[1100px]:max-h-none max-[1100px]:border-r-0 max-[1100px]:pr-0`),children:(0,I.jsx)(Pv,{concepts:d,base:p,selected:f})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:f&&(0,I.jsx)(Iv,{bundle:e,conceptId:f},f)})]})]})}function Av(e){let t=[];for(let n of e.split(`
472
472
  `)){let e=n.match(/^##\s+(\d{4}-\d{2}-\d{2})/);if(e){t.push({date:e[1],entries:[]});continue}let r=n.match(/^[*-]\s+\*\*([^*]+)\*\*:\s*(.*)$/);r&&t.length>0&&t[t.length-1].entries.push({kind:r[1].toLowerCase(),text:r[2]})}return t.filter(e=>e.entries.length>0)}function jv(e,t){let n=[],r=/\[([^\]]+)\]\(\/?([^)]+?)\.md\)/g,i=0,a;for(;a=r.exec(t);)a.index>i&&n.push(t.slice(i,a.index)),n.push((0,I.jsx)(U,{href:`/knowledge/${encodeURIComponent(e)}/${a[2].replace(/^\//,``)}`,children:a[1]},a.index)),i=a.index+a[0].length;return i<t.length&&n.push(t.slice(i)),n}function Mv({name:e,log:t}){let n=Av(t),[r,i]=(0,v.useState)(!1);return(0,I.jsx)(X,{title:`activity`,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>i(!r),children:r?`timeline`:`raw log`}),children:r||n.length===0?(0,I.jsx)(`pre`,{className:Dv,children:t}):(0,I.jsx)(`div`,{className:`pt-0.5 pb-2.5`,children:n.map((t,n)=>(0,I.jsxs)(v.Fragment,{children:[(0,I.jsx)(`div`,{className:P(`px-[18px] pt-3.5 pb-1 font-mono text-2xs tracking-[0.05em] text-fg-2 tabular-nums`,n>0&&`mt-1 border-t border-line`),children:t.date}),t.entries.map((t,n)=>(0,I.jsxs)(`div`,{className:`flex items-baseline gap-2.5 px-[18px] py-1`,children:[(0,I.jsx)(q,{tone:t.kind===`verification`?`ok`:t.kind===`creation`||t.kind===`initialization`?`accent`:`neutral`,children:t.kind}),(0,I.jsx)(`span`,{className:`min-w-0 text-[12.5px] leading-[1.55] break-words text-fg-2 [&_a]:text-accent`,children:jv(e,t.text)})]},n))]},t.date))})})}function Nv(e){let t={name:``,path:``,folders:[],pages:[],total:0};for(let n of e){let e=n.id.split(`/`),r=t;r.total++;for(let t of e.slice(0,-1)){let e=r.folders.find(e=>e.name===t);e||(e={name:t,path:r.path?`${r.path}/${t}`:t,folders:[],pages:[],total:0},r.folders.push(e)),r=e,r.total++}r.pages.push(n)}let n=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.pages.sort((e,t)=>e.title.localeCompare(t.title)),e.folders.forEach(n)};return n(t),t}function Pv({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>Nv(e),[e]),[i,a]=(0,v.useState)(()=>new Set);(0,v.useEffect)(()=>{n&&n.includes(`/`)&&a(e=>{let t=new Set(e),r=n.split(`/`).slice(0,-1);for(let e=1;e<=r.length;e++)t.delete(r.slice(0,e).join(`/`));return t.size===e.size?e:t})},[n]);let o=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),s=Ev();return(0,I.jsx)(Fv,{folder:r,base:t,selected:n,closed:i,toggle:o,embedded:s})}function Fv({folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a}){return(0,I.jsxs)(I.Fragment,{children:[e.pages.map(e=>{let r=e.id===n;return(0,I.jsxs)(U,{href:`${t}/${e.id}`,"aria-current":r?`page`:void 0,className:P(`wiki-page flex items-center gap-2 rounded-control px-2.5 py-1.5 leading-[1.35] no-underline transition-colors`,a?`text-[12.5px]`:`text-sm`,r?`active bg-accent-soft font-medium text-on-accent-soft`:`text-fg hover:bg-surface-2`),title:`${e.id}.md`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(e.stale||e.error)&&(0,I.jsx)(`span`,{className:`size-1.5 flex-none rounded-full bg-bad`,title:e.error??`stale`})]},e.id)}),e.folders.map(e=>{let o=!r.has(e.path),s=!!n&&n.startsWith(`${e.path}/`)&&!o;return(0,I.jsxs)(v.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:P(`wiki-folder mt-2.5 mb-0.5 flex w-full cursor-pointer items-center gap-1 rounded-control border-0 bg-transparent py-1 pr-2 pl-0.5 text-left`,`font-[inherit] text-2xs leading-[1.3] font-semibold tracking-[0.06em] uppercase transition-colors`,o&&`open`,s?`holds text-accent`:`text-fg-2 hover:text-fg`),onClick:()=>i(e.path),"aria-expanded":o,title:`${e.path}/`,children:[(0,I.jsx)(R,{name:`chevron_right`,className:P(`ms-sm flex-none text-[16px] transition-transform`,o&&`rotate-90`,!s&&`text-fg-2`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,I.jsx)(`span`,{className:`text-[10.5px] font-medium tracking-normal text-fg-2 tabular-nums opacity-70`,children:e.total})]}),o&&(0,I.jsx)(`div`,{className:`wiki-branch ml-[9px] flex flex-col gap-0.5 border-l border-line pl-1`,children:(0,I.jsx)(Fv,{folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a})})]},e.path)})]})}function Iv({bundle:e,conceptId:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=Ev(),[l,u]=(0,v.useState)(`document`),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(`saved`),[S,C]=(0,v.useState)(``),w=(0,v.useRef)(``),T=(0,v.useRef)(null),E=(0,v.useRef)(!1),D=(0,v.useRef)(null),O=(0,v.useRef)(null),k=(0,v.useRef)(null),ee=()=>{A.call(`knowledge.concept`,{bundle:e,query:{id:t}}).then(r,()=>a(!0))};(0,v.useEffect)(()=>{if(l===`markdown`)return;let n=!0,i,o=async()=>{try{let i=await A.request(`knowledge.concept`,{bundle:e,query:{id:t}});if(i.ok){let e=i.data;n&&(a(!1),r(t=>JSON.stringify(t)===JSON.stringify(e)?t:e))}else i.status===404&&n&&a(!0)}catch{}n&&(i=setTimeout(o,6e3))};return o(),()=>{n=!1,clearTimeout(i)}},[e,t,l]),(0,v.useEffect)(()=>{if(!n||n.raw===T.current||D.current!==null||k.current)return;let e=!0;return xv().then(({splitFrontmatter:t,unwrapParagraphs:r})=>{if(!e)return;let{head:i,body:a}=t(n.raw);w.current=i,T.current=n.raw,E.current=!1,y(e=>({key:(e?.key??0)+1,body:r(a)}))}),()=>{e=!1}},[n]);async function j(){k.current&&await k.current;let n=D.current;if(n===null)return;D.current=null,x(`saving`);let i=(async()=>{try{let i=w.current,a=i?`${i}${i.endsWith(`
473
473
  `)?``:`
474
474
  `}${n.replace(/^\n+/,`
475
475
  `)}`:n,o=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:a},keepalive:!0});if(!o.ok)throw Error(M(o));let s=o.data;if(s.error)throw Error(s.error);w.current=(await xv()).splitFrontmatter(s.raw).head,T.current=s.raw,r(s),C(``),x(D.current===null?`saved`:`unsaved`)}catch(e){C(e.message),x(`error`),D.current===null&&(D.current=n)}})();k.current=i,await i,k.current=null}function N(e){E.current&&(D.current=e,x(`unsaved`),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>void j(),1e3))}(0,v.useEffect)(()=>{let e=()=>{D.current!==null&&j()};return window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e),O.current&&clearTimeout(O.current),D.current!==null&&j()}},[]);async function F(){s(!0),await A.request(`knowledge.verify`,{bundle:e,body:{id:t}}).catch(()=>{}),s(!1),ee()}function te(){n&&(f(n.raw),g(``),u(`markdown`))}async function R(){m(!0),g(``);let n=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:d}}).catch(()=>null);m(!1),!n?.ok||!n.data||typeof n.data!=`object`?g(n?.error??`save failed`):n.data.error?g(n.data.error):(T.current=null,r(n.data),u(`document`))}if(i)return(0,I.jsx)(Y,{icon:`description`,children:`concept not found`});if(!n)return(0,I.jsx)(Y,{children:`loading…`});let z=b===`saving`?`saving…`:b===`unsaved`?`unsaved changes`:b===`error`?`not saved — ${S}`:`all changes saved`;return(0,I.jsxs)(`div`,{className:P(`agent-view flex flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,I.jsx)(it,{size:c?`md`:`lg`,children:n.title}),n.type&&(0,I.jsx)(q,{children:n.type}),(0,I.jsx)(wv,{tier:n.trustTier}),n.status!==`stable`&&(0,I.jsx)(q,{tone:Tv(n.status),children:n.status}),n.stale&&(0,I.jsxs)(q,{tone:`bad`,children:[`stale since `,n.staleAfter?.slice(0,10)]}),(0,I.jsx)(`span`,{className:`flex-1`}),!c&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void Cs(e,n.id),children:`export PDF`}),(0,I.jsx)(G,{variant:`primary`,size:c?`sm`:`md`,icon:`check`,busy:o,onClick:F,children:o?`verifying…`:`verify (human)`})]}),n.error&&(0,I.jsx)(tt,{tone:`bad`,children:n.error}),(0,I.jsxs)(`div`,{className:P(`grid items-start`,c?`grid-cols-1 gap-3`:`grid-cols-[minmax(0,1fr)_320px] gap-4 max-[1020px]:grid-cols-1`),children:[(0,I.jsxs)(X,{className:`min-w-0`,title:`content`,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[10.5px] text-fg-2`,children:[e,`/`,n.id,`.md`]}),l===`markdown`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>{u(`document`),g(``)},children:`cancel`}),(0,I.jsx)(G,{size:`sm`,icon:`check`,busy:p,onClick:()=>void R(),children:p?`saving…`:`save`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:P(`text-xs whitespace-nowrap`,b===`error`?`text-bad`:b===`unsaved`||b===`saving`?`text-ask`:`text-fg-2`),children:z}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`code`,title:`The whole file as text, frontmatter included`,onClick:te,children:`edit markdown`})]})]}),children:[l===`markdown`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`concept-edit block w-full resize-y border-0 border-b border-line bg-surface px-[18px] py-3.5 font-mono text-[12.5px] leading-[1.65] text-fg outline-none`,value:d,rows:Math.min(40,Math.max(18,d.split(`
476
- `).length+2)),onChange:e=>f(e.target.value),spellCheck:!1}),(0,I.jsxs)(J,{className:`border-b border-line px-[18px] py-1.5`,children:[`full file (frontmatter + markdown body) — saving stamps provenance as `,(0,I.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}):(0,I.jsxs)(`div`,{className:P(`concept-doc`,c?`[&_.editor-content]:min-h-[220px]`:`[&_.editor-content]:min-h-[280px]`),onPointerDownCapture:()=>E.current=!0,onKeyDownCapture:()=>E.current=!0,onPasteCapture:()=>E.current=!0,onDropCapture:()=>E.current=!0,children:[_?(0,I.jsx)(v.Suspense,{fallback:(0,I.jsx)(J,{className:`border-b border-line px-[18px] py-1.5`,children:`loading the editor…`}),children:(0,I.jsx)(bv,{markdown:_.body,autoFocus:!1,onChange:N,onError:te},_.key)}):(0,I.jsx)(J,{className:`border-b border-line px-[18px] py-1.5`,children:`loading…`}),(0,I.jsxs)(J,{className:`border-b border-line px-[18px] py-1.5`,children:[`the page as a document, saved as you type; every save stamps provenance as `,(0,I.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}),h&&(0,I.jsx)(`div`,{className:`px-3 py-1`,children:(0,I.jsx)(tt,{tone:`bad`,children:h})})]}),(0,I.jsxs)(`aside`,{className:P(`flex min-w-0 flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,I.jsx)(X,{title:`about`,children:(0,I.jsxs)(ft,{compact:c,children:[(0,I.jsx)(pt,{label:`trust`,children:(0,I.jsx)(wv,{tier:n.trustTier})}),(0,I.jsx)(pt,{label:`generated`,dim:!n.generated,children:n.generated?`${n.generated.by??`?`} · ${(n.generated.at??`?`).slice(0,10)}`:`not stamped`}),(0,I.jsx)(pt,{label:`verified`,dim:n.verified.length===0,children:n.verified.length===0?`never`:n.verified.map((e,t)=>(0,I.jsxs)(`span`,{className:`block`,children:[e.by??`?`,` · `,(e.at??`?`).slice(0,10)]},t))}),n.staleAfter&&(0,I.jsxs)(pt,{label:`stale after`,dim:!n.stale,children:[n.staleAfter.slice(0,10),n.stale&&(0,I.jsx)(q,{tone:`bad`,children:`stale`})]}),n.tags.length>0&&(0,I.jsx)(pt,{label:`tags`,children:n.tags.map(e=>(0,I.jsx)(q,{children:e},e))})]})}),n.sources.length>0&&(0,I.jsx)(X,{title:`sources`,children:(0,I.jsx)(ft,{compact:c,children:n.sources.map((e,t)=>(0,I.jsxs)(`div`,{className:P(`flex flex-col gap-[3px] break-words`,c?`px-3.5 py-1.5 text-xs`:`px-[18px] py-2.5 text-[12.5px]`),children:[(0,I.jsxs)(`span`,{className:`text-fg [&_a]:text-accent`,children:[e.resource?.startsWith(`http`)?(0,I.jsx)(`a`,{href:e.resource,target:`_blank`,rel:`noreferrer`,children:e.title??e.resource}):e.title??e.resource??`?`,e.id&&(0,I.jsxs)(`span`,{className:`ml-2 font-mono text-2xs text-fg-2`,children:[`[^`,e.id,`]`]})]}),(0,I.jsx)(`span`,{className:`text-fg-2`,children:[e.author,e.usage_count==null?null:`${e.usage_count} uses`,e.last_modified?`mod ${e.last_modified.slice(0,10)}`:null].filter(Boolean).join(` · `)})]},t))})})]})]})]})}var Lv=[{id:`workflows`,label:`Workflows`,one:`Workflow`,icon:`account_tree`,hue:`#0e7490`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a workflow`},{id:`knowledge`,label:`Knowledge`,one:`Knowledge bundle`,icon:`menu_book`,hue:`#4d7c0f`,newHref:`/knowledge/new`},{id:`presentations`,label:`Presentations`,one:`Slides`,icon:`slideshow`,hue:`#c2410c`,newHref:`/presentations/new`},{id:`vibeables`,label:`Apps`,one:`App`,icon:`web`,hue:`#2563eb`,newHref:`/vibeables`},{id:`boards`,label:`Boards`,one:`Board`,icon:`view_kanban`,hue:`#15803d`,newHref:`/boards/new`},{id:`contacts`,label:`Contacts`,one:`Contact`,icon:`person`,hue:`#7c3aed`,newHref:`/contacts/new`},{id:`places`,label:`Places`,one:`Place`,icon:`location_on`,hue:`#be123c`,newHref:`/places/new`},{id:`events`,label:`Events`,one:`Event`,icon:`event`,hue:`#a16207`,newHref:`/events/new`}],Rv=encodeURIComponent,zv=(e,t)=>t===`workflows`||t===`knowledge`||!!e[t],Bv=e=>Lv.find(t=>t.id===e);function Vv(){let e=z(),t=new URLSearchParams(e.split(`?`)[1]??``),n=t.get(`kind`);return{kind:Lv.some(e=>e.id===n)?n:`all`,open:t.get(`open`)??void 0}}var Hv=({kind:e,open:t})=>{let n=new URLSearchParams;e&&e!==`all`&&n.set(`kind`,e),t&&n.set(`open`,t);let r=n.toString();return r?`/artifacts?${r}`:`/artifacts`};function Uv(){let e=Te(),t=N(`workflows.list`,{},{interval:3e4}),n=N(`knowledge.list`,{},{interval:3e4}),r=N(`vibeables.list`,e.vibeables?{}:null,{interval:3e4}),i=N(`presentations.list`,e.presentations?{query:{all:`1`}}:null,{interval:3e4}),a=N(`boards.list`,e.boards?{query:{all:`1`}}:null,{interval:3e4}),o=N(`contacts.list`,e.contacts?{}:null,{interval:3e4}),s=N(`places.list`,e.places?{}:null,{interval:3e4}),c=N(`events.list`,e.events?{}:null,{interval:3e4}),l=N(`projects.list`,e.projects?{}:null,{interval:6e4}),u=e=>e?l?.projects.find(t=>t.slug===e)?.title??e:void 0;return{items:[...(t?.workflows??[]).map(e=>({key:`workflows:${e.slug}`,kind:`workflows`,title:e.name||e.slug,href:`/workflows/${Rv(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.error})),...(n?.bundles??[]).map(e=>({key:`knowledge:${e.name}`,kind:`knowledge`,title:e.name,href:`/knowledge/${Rv(e.name)}`,updatedAt:e.updatedAt,sub:`${e.concepts} concept${e.concepts===1?``:`s`}`})),...(r?.vibeables??[]).map(e=>({key:`vibeables:${e.slug}`,kind:`vibeables`,title:e.slug,href:`/vibeables/${Rv(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.configError})),...(i?.presentations??[]).map(e=>({key:`presentations:${e.project??``}:${e.name}`,kind:`presentations`,title:e.title,href:e.project?`/projects/${Rv(e.project)}/presentations/${Rv(e.name)}`:`/presentations/${Rv(e.name)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.error})),...(a?.boards??[]).map(e=>({key:`boards:${e.project??``}:${e.board}`,kind:`boards`,title:e.title,href:e.project?`/projects/${Rv(e.project)}/boards/${Rv(e.board)}`:`/boards/${Rv(e.board)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError})),...[[`contacts`,o],[`places`,s],[`events`,c]].flatMap(([e,t])=>(t?.items??[]).map(t=>{let n=t;return{key:`${e}:${t.slug}`,kind:e,title:t.title||t.slug,href:`/${e}/${Rv(t.slug)}`,updatedAt:t.updatedAt,broken:!!t.configError,lat:n.lat,lng:n.lng,start:n.start,end:n.end}}))].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``)),loading:!t&&!n&&!r&&!i&&!a&&!o&&!s&&!c,projectTitle:u}}function Wv(){let e=Te(),t=Lv.filter(t=>zv(e,t.id)),{kind:n,open:r}=Vv(),i=e=>H(Hv({kind:e,open:e===`all`||r?.startsWith(`${e}:`)?r:void 0}),{replace:!0}),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),{items:l,loading:u,projectTitle:d}=Uv(),f=a.trim().toLowerCase(),p=l.filter(e=>(n===`all`||e.kind===n)&&(!f||`${e.title} ${d(e.project)??``}`.toLowerCase().includes(f))),m=t.length>0&&u;return(0,I.jsxs)(`div`,{className:`artifacts-screen mx-auto flex w-full max-w-[920px] flex-col gap-6 px-6 pt-8 pb-12 max-[800px]:px-4`,children:[(0,I.jsx)(`h1`,{className:`m-0 text-3xl font-semibold tracking-[-0.02em] text-fg`,children:`Artifacts`}),t.length>0&&(0,I.jsx)(`section`,{className:`grid grid-cols-4 gap-3 max-[600px]:grid-cols-3`,"aria-label":`kinds`,children:t.map(e=>{let t=n===e.id;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm text-fg`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,"aria-label":`show only ${e.label.toLowerCase()}`,title:t?`show everything`:`show only ${e.label.toLowerCase()}`,className:P(`grid h-[72px] cursor-pointer place-items-center rounded-2xl outline-offset-2 transition-[filter,box-shadow] hover:brightness-95`,t&&`shadow-[0_0_0_2px_currentColor]`,n!==`all`&&!t&&`opacity-55`),style:{background:`color-mix(in srgb, ${e.hue} 20%, var(--color-surface))`,color:e.hue},onClick:()=>i(t?`all`:e.id),children:(0,I.jsx)(R,{name:e.icon,className:`text-[34px]`})}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1 px-0.5`,children:[(0,I.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate`,t&&`font-medium`),children:e.label}),(0,I.jsx)(U,{href:e.newHref,"aria-label":`new ${e.one.toLowerCase()}`,title:e.newTitle??`new ${e.one.toLowerCase()}`,className:`grid size-6 flex-none place-items-center rounded-full text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,children:(0,I.jsx)(R,{name:`add`,className:`ms-sm`})})]})]},e.id)})}),(0,I.jsxs)(`div`,{className:`-mb-3 flex items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`m-0 flex-1 text-sm font-normal text-fg-2`,children:n===`all`?`Everything`:Bv(n).label}),s?(0,I.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`search artifacts`,placeholder:`Search`,value:a,onChange:e=>o(e.target.value),onBlur:()=>!a&&c(!1),className:`w-56 rounded-full border border-line bg-surface px-3 py-1.5 text-sm text-fg outline-none focus:border-accent`}):(0,I.jsx)(`button`,{type:`button`,"aria-label":`search artifacts`,className:`grid size-8 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>c(!0),children:(0,I.jsx)(R,{name:`search`})})]}),(0,I.jsxs)(`section`,{className:`flex flex-col`,"aria-label":`artifacts`,children:[t.length===0&&(0,I.jsxs)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:[`Nothing to list yet: turn on apps, presentations, boards, contacts, places or events in `,(0,I.jsx)(U,{href:`/settings`,className:`text-accent`,children:`settings`}),`.`]}),!m&&t.length>0&&p.length===0&&(0,I.jsx)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:f?`Nothing matches “${a.trim()}”.`:`Nothing here yet — make something above.`}),p.map(e=>{let t=Bv(e.kind),i=d(e.project);return(0,I.jsxs)(U,{href:Hv({kind:n,open:e.key}),"data-artifact":e.kind,"aria-current":r===e.key?`true`:void 0,className:`artifact-row flex items-center gap-3 rounded-xl px-2 py-2.5 text-fg no-underline hover:bg-surface-2 aria-[current=true]:bg-surface-2`,children:[(0,I.jsx)(`span`,{className:`grid size-9 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${t.hue} 16%, var(--color-surface))`,color:t.hue},title:t.one,children:(0,I.jsx)(R,{name:t.icon,className:`ms-sm`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:P(`truncate text-[15px]`,e.broken&&`text-on-bad-soft`),children:e.title}),(0,I.jsxs)(`span`,{className:`truncate text-xs text-fg-2`,children:[t.one,e.sub?` · ${e.sub}`:``,i?` · 📁 ${i}`:``,e.broken?` · unreadable`:``]})]}),e.updatedAt&&(0,I.jsxs)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.updatedAt,children:[`Edited `,W(e.updatedAt)]})]},e.key)})]})]})}function Gv(){let{kind:e,open:t}=Vv(),{items:n,loading:r}=Uv(),i=t?n.find(e=>e.key===t):void 0,a=i?Bv(i.kind):void 0,[,o=``,s=``]=(t??``).split(`:`),c=e===`places`||i?.kind===`places`,l=n.filter(e=>e.kind===`places`),u=l.flatMap(e=>e.lat!==void 0&&e.lng!==void 0?[{slug:e.key.slice(7),title:e.title,lat:e.lat,lng:e.lng}]:[]),d=l.length-u.length,f=Hv({kind:e}),p=e===`events`||i?.kind===`events`,m=n.flatMap(e=>e.kind===`events`&&e.start?[{slug:e.key.slice(7),title:e.title,start:String(e.start),end:e.end?String(e.end):void 0}]:[]),h=i&&a&&(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${a.hue} 16%, var(--color-surface))`,color:a.hue},title:a.one,children:(0,I.jsx)(R,{name:a.icon,className:`ms-sm`})}),(0,I.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-base font-semibold text-fg`,title:i.title,children:i.title}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:i.href,title:`open the ${a.one.toLowerCase()} where it lives`,children:`open`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`close`,href:f,"aria-label":`close the preview`})]});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`}),(0,I.jsx)(`aside`,{className:`ctx artifact-preview`,"aria-label":`Preview`,"data-open":i?.key,children:p?(0,I.jsxs)(I.Fragment,{children:[h,(0,I.jsx)(`div`,{className:P(`flex min-h-0 flex-col p-3`,i?`h-[52%] flex-none`:`flex-1`),children:(0,I.jsx)(wl,{events:m,selected:i?o:void 0,onPick:t=>H(Hv({kind:e,open:`events:${t}`}))})}),i?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,I.jsx)(vv,{kind:`events`,slug:o})},i.key):(0,I.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick an event on the left or in the calendar to see its details.`})]}):c?(0,I.jsxs)(I.Fragment,{children:[h,(0,I.jsxs)(`div`,{className:P(`flex min-h-0 flex-col gap-1.5 p-3`,i?`h-[48%] flex-none`:`flex-1`),children:[(0,I.jsx)(yl,{places:u,selected:i?o:void 0,onPick:t=>H(Hv({kind:e,open:`places:${t}`}))}),(d>0||i&&i.lat===void 0)&&(0,I.jsx)(`p`,{className:`m-0 text-xs text-fg-2`,children:i&&i.lat===void 0?`This place has no coordinates yet: add latitude and longitude below to put it on the map.`:`${d} of ${l.length} places have no coordinates and are not on the map.`})]}),i?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,I.jsx)(vv,{kind:`places`,slug:o})},i.key):(0,I.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick a place on the left or a dot on the map to zoom in and see its details.`})]}):!i||!a?(0,I.jsx)(Y,{icon:`preview`,className:`my-auto`,children:t&&!r?`That one is gone.`:`Pick an artifact on the left to see it here.`}):(0,I.jsxs)(I.Fragment,{children:[h,i.kind===`vibeables`?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,I.jsx)(Na,{slug:o},i.key)}):(0,I.jsxs)(`div`,{className:`ctx-body ctx-embed`,children:[i.kind===`workflows`&&(0,I.jsx)(Kv,{slug:o}),i.kind===`knowledge`&&(0,I.jsx)(qv,{name:o}),i.kind===`presentations`&&(0,I.jsx)(av,{project:o||void 0,name:s}),i.kind===`boards`&&(0,I.jsx)(du,{project:o||void 0,board:s}),i.kind===`contacts`&&(0,I.jsx)(vv,{kind:i.kind,slug:o})]},i.key)]})})]})}function Kv({slug:e}){let[t,n]=(0,v.useState)(`overview`),r=`/workflows/${Rv(e)}`;return(0,I.jsx)(he.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t===`details`||t===`runs`?t:`overview`),!0},children:(0,I.jsx)(qc,{slug:e,tab:t},e)})}function qv({name:e}){let[t,n]=(0,v.useState)(void 0),r=`/knowledge/${Rv(e)}`;return(0,I.jsx)(he.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t?t.split(`/`).map(decodeURIComponent).join(`/`):void 0),!0},children:(0,I.jsx)(kv,{name:e,conceptId:t},e)})}var Jv={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function Yv(e){return(0,I.jsx)(q,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:Jv[e]})}function Xv({name:e}){let t=N(`skills.list`,{}),n=t?.skills??[],r=n.filter(e=>e.source===`workspace`),i=n.filter(e=>e.source!==`workspace`),a=r[0]??i[0];(0,v.useEffect)(()=>{!e&&a&&H(`/skills/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]);let o=t=>(0,I.jsx)(mt,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)($e,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&Yv(t.source),sub:t.description||`no description`},`${t.source}:${t.name}`);return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`workspace skills`}),(0,I.jsxs)(Ot,{children:[r.map(o),t&&r.length===0&&(0,I.jsx)(kt,{children:`no workspace skills yet`}),i.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Et,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(Qv,{name:e},e):t&&!a?(0,I.jsx)(Zv,{root:t.root}):(0,I.jsx)(Y,{children:`loading…`})})]})}function Zv({root:e}){return(0,I.jsx)(`div`,{className:`empty-action py-6`,children:(0,I.jsxs)(Y,{icon:`extension`,children:[`Create `,(0,I.jsxs)(`code`,{children:[e,`/<name>/SKILL.md`]}),` and it appears here and in every session's `,(0,I.jsx)(`code`,{children:`/`}),` menu.`]})})}function Qv({name:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(`rendered`),s=(0,v.useMemo)(()=>t?t.content.replace(/^---\r?\n[\s\S]*?\r?\n---(\r?\n|$)/,``):``,[t?.content]),c=(0,v.useMemo)(()=>t?Da.sanitize(Jr.parse(s,{async:!1})):``,[s]);return(0,v.useEffect)(()=>{A.call(`skills.get`,{name:e}).then(n,()=>i(!0))},[e]),r?(0,I.jsx)(Y,{icon:`extension`,children:`skill not found`}):t?(0,I.jsxs)(`div`,{className:`agent-view flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,I.jsxs)(it,{size:`lg`,children:[`/`,t.name]}),Yv(t.source)]}),t.description&&(0,I.jsx)(`p`,{className:`-mt-2 mb-0 mx-0.5 text-sm leading-[1.6] text-fg-2`,children:t.description}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 max-[1020px]:grid-cols-1`,children:[(0,I.jsx)(X,{className:`min-w-0`,title:`SKILL.md`,actions:(0,I.jsx)(ht,{bare:!0,label:`SKILL.md view`,value:a,onChange:o,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),children:a===`rendered`?(0,I.jsx)(`div`,{className:`md-body h-auto overflow-visible [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2`,dangerouslySetInnerHTML:{__html:c}}):(0,I.jsx)(`pre`,{className:`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:t.content.trim()||`(empty)`})}),(0,I.jsx)(`aside`,{className:`flex min-w-0 flex-col gap-4`,children:(0,I.jsx)(X,{title:`about`,children:(0,I.jsxs)(ft,{children:[(0,I.jsx)(pt,{label:`source`,children:t.source===`workspace`?`workspace — git-tracked, shared with the team`:t.source===`project`?`repo .claude/skills — tracked, but outside the workspace root`:`global ~/.claude/skills — only on this machine`}),(0,I.jsx)(pt,{label:`path`,mono:!0,children:(0,I.jsx)(`span`,{title:t.path,children:t.path})}),(0,I.jsx)(pt,{label:`invoke`,children:(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`code`,{children:[`/`,t.name]}),` in any session`]})}),t.files.length>0&&(0,I.jsx)(pt,{label:`bundled files`,mono:!0,children:t.files.map(e=>(0,I.jsx)(`span`,{className:`block w-full`,children:e},e))})]})})})]})]}):(0,I.jsx)(Y,{children:`loading…`})}var $v=function(e,t){let n=e,r=ty[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=ry.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=ry.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=ry.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=ry.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=ry.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=ry.getErrorCorrectPolynomial(l),d=ay(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=oy.getRSBlocks(e,t),i=sy();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),ry.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=cy(e);break;case`Alphanumeric`:n=ly(e);break;case`Byte`:n=uy(e);break;case`Kanji`:n=dy(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=oy.getRSBlocks(e,r),n=sy();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),ry.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return gy(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
477
- `}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
478
- `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};$v.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},$v.createStringToBytes=function(e,t){let n=function(){let n=my(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var ey={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},ty={L:1,M:0,Q:3,H:2},ny={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},ry=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case ny.PATTERN000:return function(e,t){return(e+t)%2==0};case ny.PATTERN001:return function(e,t){return e%2==0};case ny.PATTERN010:return function(e,t){return t%3==0};case ny.PATTERN011:return function(e,t){return(e+t)%3==0};case ny.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case ny.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case ny.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case ny.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=ay([1],0);for(let n=0;n<e;n+=1)t=t.multiply(ay([1,iy.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case ey.MODE_NUMBER:return 10;case ey.MODE_ALPHA_NUM:return 9;case ey.MODE_8BIT_BYTE:return 8;case ey.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case ey.MODE_NUMBER:return 12;case ey.MODE_ALPHA_NUM:return 11;case ey.MODE_8BIT_BYTE:return 16;case ey.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case ey.MODE_NUMBER:return 14;case ey.MODE_ALPHA_NUM:return 13;case ey.MODE_8BIT_BYTE:return 16;case ey.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),iy=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),ay=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=iy.gexp(iy.glog(r.getAt(n))+iy.glog(e.getAt(i)));return ay(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=iy.glog(r.getAt(0))-iy.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=iy.gexp(iy.glog(e.getAt(r))+t);return ay(n,0).mod(e)},r},oy=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case ty.L:return e[(t-1)*4+0];case ty.M:return e[(t-1)*4+1];case ty.Q:return e[(t-1)*4+2];case ty.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),sy=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},cy=function(e){let t=ey.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},ly=function(e){let t=ey.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},uy=function(e){let t=ey.MODE_8BIT_BYTE,n=$v.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},dy=function(e){let t=ey.MODE_KANJI,n=$v.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},fy=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},py=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},my=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},hy=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=fy(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},gy=function(e,t,n){let r=hy(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=fy();r.write(i);let a=py(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};$v.stringToBytes;function _y(){let e=navigator.userAgent,t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Mac/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`,n=/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n?`${t} · ${n}`:t}function vy(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(_y),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{a(!0),s(``);let t=await A.request(`devices.pair`,{body:{code:e,name:n}}).catch(()=>null);if(t?.ok)return location.reload();a(!1),s(t?M(t):`could not reach kraftwerk`)};return(0,I.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(R,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,I.jsx)(it,{size:`lg`,children:`Pair this device`}),(0,I.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,I.jsx)(`code`,{children:`kraftwerk devices pair`}),` or open settings → devices, and enter the code here. You pair once; it stays paired until it is removed there.`]})]}),(0,I.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,I.jsx)(Q,{label:`pairing code`,children:(0,I.jsx)(Z,{value:e,onChange:e=>t(e.target.value.toUpperCase()),placeholder:`ABCD-EF23`,autoFocus:!0,autoComplete:`one-time-code`,autoCapitalize:`characters`,"aria-label":`pairing code`,className:`font-mono tracking-widest`})}),(0,I.jsx)(Q,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,I.jsx)(Z,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o}),(0,I.jsx)(G,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function yy({children:e}){return O()?(0,I.jsx)(vy,{}):(0,I.jsx)(I.Fragment,{children:e})}function by({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=$v(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i+4} ${e+4}h1v1h-1z`);return{d:r,n:n+8}},[e]);return(0,I.jsx)(`svg`,{viewBox:`0 0 ${n.n} ${n.n}`,width:t,height:t,role:`img`,"aria-label":`pairing QR code`,className:`rounded-lg bg-white text-black`,shapeRendering:`crispEdges`,children:(0,I.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function xy({onError:e}){let t=N(`devices.relay`,{},{interval:1e4}),[n,r]=(0,v.useState)(!1);if(!t)return null;let i=async()=>{r(!0);let n=await A.request(`devices.setRelay`,{body:{enabled:!t.enabled}}).catch(()=>null);r(!1),n&&!n.ok&&e(M(n))},a=t.enabled?t.daemon?t.state===`connected`?`connected${t.clients?` · ${t.clients} device${t.clients===1?``:`s`} now`:``}`:t.state===`error`?`not connected: ${t.error??`unknown error`}`:`connecting…`:"on — the daemon connects it (this kraftwerk is not the daemon: `kraftwerk daemon`)":`off — devices reach this machine on your network only`;return(0,I.jsx)(ut,{children:(0,I.jsx)(lt,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,I.jsx)(G,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,I.jsxs)(I.Fragment,{children:[` · machine key `,(0,I.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function Sy(){let e=N(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=N(`devices.list`,t?{}:null,{interval:15e3}),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);if(!e)return null;if(!t)return(0,I.jsx)(X,{title:`devices`,children:(0,I.jsx)(ut,{children:(0,I.jsx)(lt,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`devices are managed on the machine kraftwerk runs on`})})})});let s=async()=>{o(``);let e=await A.request(`devices.code`).catch(()=>null);e?.ok?i(e.data):o(e?M(e):`could not make a code`)},c=async(e,t)=>{if(!window.confirm(`Unpair “${t}”? It loses access at once.`))return;let n=await A.request(`devices.revoke`,{id:e}).catch(()=>null);n&&!n.ok&&o(M(n))};return(0,I.jsxs)(X,{title:`devices`,actions:(0,I.jsx)(G,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,I.jsxs)(xt,{className:`border-b border-line`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`once, until `,new Date(r.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]})]}),r.remote&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsx)(by,{text:r.remote}),(0,I.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,I.jsx)(`a`,{href:r.remote,target:`_blank`,rel:`noreferrer`,children:`the pairing link`}),` on it. It carries the code — treat it like a password.`]})]}),r.urls.length?(0,I.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&` or `,(0,I.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,I.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,I.jsx)(`code`,{children:`kraftwerk ui --lan`}),` to reach it from your network (or use a tunnel), then enter the code on the device — or turn on “reach this machine from anywhere”.`]})]}),(0,I.jsx)(xy,{onError:o}),a&&(0,I.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,I.jsx)(tt,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,I.jsx)(Y,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,I.jsx)(ut,{children:n.devices.map(e=>(0,I.jsx)(lt,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,W(e.createdAt),` · `,e.lastSeenAt?`last seen ${W(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var Cy={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function wy(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??Cy.remote,branch:t.branch??``,interval:String(t.interval??Cy.interval),autosync:t.autosync??Cy.autosync}:Cy}var Ty={enabled:!1,root:``};function Ey(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ty}function Dy(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ty}function Oy(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ty}function ky(e){let t=e.config.boards;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ty}function Ay(e){let t=e.config.presentations;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ty}var jy=[`contacts`,`places`,`events`],My={contacts:Ty,places:Ty,events:Ty};function Ny(e){let t=t=>{let n=e.config[t];return n?{enabled:n.enabled!==!1,root:n.root??``}:Ty};return{contacts:t(`contacts`),places:t(`places`),events:t(`events`)}}var Py={contacts:{icon:`person`,what:`keep people and organisations as contacts, referenced as contact:<slug> from projects, events and text`,files:`one Markdown file per contact (frontmatter: role, org, email, phone, place, records; notes below)`},places:{icon:`location_on`,what:`keep addresses and points of interest as places, referenced as place:<slug>; a Google Maps link derives from coordinates or the address`,files:`one Markdown file per place (frontmatter: address, lat, lng, url, records; notes below)`},events:{icon:`event`,what:`keep dated one-off entries as events with a place, contacts and a project, referenced as event:<slug>`,files:`one Markdown file per event, named by its date (frontmatter: start, end, place, contacts, project, records; notes below)`}};function Fy(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{let e=!0,n=()=>A.call(`meta.get`).then(n=>e&&n.cloud&&t(n.cloud)).catch(()=>{});n();let r=setInterval(n,1e4);return()=>{e=!1,clearInterval(r)}},[]),(0,v.useEffect)(()=>{if(!i)return;if(e?.account)return void a(!1);let n=setInterval(()=>{A.call(`cloud.sync`).then(e=>{t(t=>t&&{...t,...e}),e.account&&a(!1)}).catch(()=>{})},2e3),r=setTimeout(()=>a(!1),6e5);return()=>{clearInterval(n),clearTimeout(r)}},[i,e?.account]),!e)return null;let o=e.state===`connected`?e.account?`claimed`:`unclaimed`:e.state,s=e.state===`connected`&&e.account?`ok`:e.state===`error`?`bad`:`neutral`;return(0,I.jsx)(X,{title:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`cloud `,(0,I.jsx)(q,{tone:s,children:o})]}),actions:e.url&&(0,I.jsxs)(`a`,{className:Ze(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,I.jsx)(R,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,I.jsxs)(xt,{children:[e.state===`off`&&(0,I.jsxs)(J,{children:[`Off — `,e.reason??`turned off for this machine`,`. The daemon registers the machine with the kraftwerk cloud, so its owner sees its workspaces running from anywhere; `,(0,I.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,I.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,I.jsxs)(J,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,I.jsxs)(J,{children:[`Could not reach `,e.url,`: `,e.error,`. Retrying every `,e.interval??60,`s — the UI works as before meanwhile.`]}),e.state===`connected`&&e.account&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(J,{children:[`This machine`,e.machine?(0,I.jsxs)(I.Fragment,{children:[` (`,(0,I.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,I.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(G,{size:`sm`,variant:`secondary`,icon:`logout`,onClick:()=>{confirm(`Sign this machine out of ${e.account}? It stays registered, unclaimed, and sends no folder paths until claimed again.`)&&A.call(`cloud.unlink`).then(e=>t(t=>t&&{...t,...e,account:null})).catch(()=>{})},children:`sign out`})})]}),e.state===`connected`&&!e.account&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(J,{children:[`This machine is registered at `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),`, not yet under an account (no folder paths are sent until it is). Sign in there and enter this code — or open the link, or run `,(0,I.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,I.jsx)(`code`,{className:`rounded-control border border-line bg-surface-2 px-3 py-1.5 font-mono text-lg tracking-[0.12em] text-fg`,children:e.claimCode??`…`}),e.claimCode&&(0,I.jsx)(G,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,I.jsxs)(`a`,{className:Ze(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,onClick:()=>a(!0),children:[(0,I.jsx)(R,{name:`link`,className:`ms-sm`}),` sign in & claim`]}),i&&(0,I.jsx)(`span`,{className:`text-fg-dim text-sm`,children:`waiting for the claim …`})]}),(0,I.jsxs)(J,{children:[`A claim made there reaches this machine with the next heartbeat (every `,e.interval??60,`s). To keep this workspace out of the cloud, set `,(0,I.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,I.jsxs)(J,{children:[`This workspace is left out of the machine's record: `,(0,I.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function Iy(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(Cy),[f,p]=(0,v.useState)(Ty),[m,h]=(0,v.useState)(Ty),[g,_]=(0,v.useState)(Ty),[y,b]=(0,v.useState)(Ty),[x,S]=(0,v.useState)(Ty),[C,w]=(0,v.useState)(My),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),[k,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(``),P=N(`identity.get`,{},{interval:6e4});(0,v.useEffect)(()=>{A.call(`settings.get`).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(wy(e)),p(Ey(e)),h(Dy(e)),_(Oy(e)),b(ky(e)),S(Ay(e)),w(Ny(e))}).catch(()=>M(`could not load settings`))},[]);let F=()=>{E(!0),ee(!1),M(``)};async function te(){O(!0),M(``);try{let e=await A.request(`settings.save`,{body:{name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g,boards:y,presentations:x,...C}});if(!e.ok)throw Error(e.error||`save failed`);let r=e.data;t(r),l(r.config.switcher??[]),d(wy(r)),p(Ey(r)),h(Dy(r)),_(Oy(r)),b(ky(r)),S(Ay(r)),w(Ny(r)),E(!1),ee(!0)}catch(e){M(e.message)}finally{O(!1)}}let z=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),F()},ne=e=>{d(t=>({...t,...e})),F()},re=e=>{p(t=>({...t,...e})),F()},ie=e=>{h(t=>({...t,...e})),F()},ae=e=>{_(t=>({...t,...e})),F()},oe=e=>{b(t=>({...t,...e})),F()},se=e=>{S(t=>({...t,...e})),F()},ce=(e,t)=>{w(n=>({...n,[e]:{...n[e],...t}})),F()};if(!e)return(0,I.jsx)(Y,{children:j||`loading…`});let le=[[`identity`,P?.identity??`…`,`this machine — the runner routines name in runs_on (kraftwerk whoami to rename)`],[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-4`,children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`settings`,className:`text-[28px] text-fg-2`}),title:`Settings`,actions:(0,I.jsxs)(I.Fragment,{children:[j&&(0,I.jsx)(tt,{tone:`bad`,children:j}),k&&!T&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm`}),` saved`]}),(0,I.jsx)(G,{variant:`primary`,busy:D,disabled:!T,onClick:()=>void te(),children:D?`saving…`:`save changes`})]})}),(0,I.jsx)(X,{title:`workspace`,children:(0,I.jsxs)(xt,{children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`icon`,className:`w-[90px]`,children:(0,I.jsx)(Z,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),F()}})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-40 flex-1`,children:(0,I.jsx)(Z,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),F()}})}),(0,I.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5`,title:`Accent in the workspace switcher; empty = derived from the folder`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`color`}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-9 w-10 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),F()}}),(0,I.jsx)(Z,{className:`min-w-0 px-2`,value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),F()}})]})]})]}),(0,I.jsx)(J,{children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})}),(0,I.jsx)(X,{title:`workspace switcher`,actions:(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),F()},children:`add entry`}),children:(0,I.jsxs)(xt,{children:[c.length===0&&(0,I.jsx)(J,{children:`No manual entries.`}),c.map((e,t)=>(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`icon`,className:`w-[70px]`,children:(0,I.jsx)(Z,{value:e.icon??``,placeholder:`•`,onChange:e=>z(t,{icon:e.target.value})})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:e.name,placeholder:`other workspace`,onChange:e=>z(t,{name:e.target.value})})}),(0,I.jsx)(Q,{label:`url`,className:`min-w-40 flex-[1.4]`,children:(0,I.jsx)(Z,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>z(t,{url:e.target.value})})}),(0,I.jsx)(K,{icon:`close`,label:`remove entry`,className:`mb-0.5`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),F()}})]},t)),(0,I.jsx)(J,{children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})}),(0,I.jsx)(X,{title:`git sync`,actions:(0,I.jsx)(G,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:u.enabled,onChange:e=>ne({enabled:e}),children:`sync workflows, knowledge, agents and skills with a git remote`}),u.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`remote`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:u.remote,placeholder:`origin`,onChange:e=>ne({remote:e.target.value})})}),(0,I.jsx)(Q,{label:`branch`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>ne({branch:e.target.value})})}),(0,I.jsx)(Q,{label:`interval (s)`,className:`w-[120px]`,children:(0,I.jsx)(Z,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>ne({interval:e.target.value})})}),(0,I.jsx)(Q,{label:`autosync`,className:`w-[150px]`,children:(0,I.jsxs)(bt,{value:u.autosync,onChange:e=>ne({autosync:e.target.value}),children:[(0,I.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,I.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]}),(0,I.jsx)(J,{children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})}),(0,I.jsx)(X,{title:`repositories`,actions:(0,I.jsx)(G,{size:`sm`,icon:`source`,href:`/repos`,children:`open repositories`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:f.enabled,onChange:e=>re({enabled:e}),children:`keep git repositories the agents work on under one folder`}),f.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`repos root`,children:(0,I.jsx)(Z,{value:f.root,placeholder:`repos`,onChange:e=>re({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,I.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})}),(0,I.jsx)(X,{title:`apps (vibeables)`,actions:(0,I.jsx)(G,{size:`sm`,icon:`web`,href:`/vibeables`,children:`open apps`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:m.enabled,onChange:e=>ie({enabled:e}),children:`build small apps live in a chat, with a preview pane next to the thread`}),m.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`vibeables root`,children:(0,I.jsx)(Z,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>ie({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,I.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})}),(0,I.jsx)(X,{title:`projects`,actions:(0,I.jsx)(G,{size:`sm`,icon:`folder_special`,href:`/projects`,children:`open projects`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:g.enabled,onChange:e=>ae({enabled:e}),children:`gather a goal, its brief, systems of record and links in one folder, and chat inside it`}),g.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`projects root`,children:(0,I.jsx)(Z,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>ae({root:e.target.value})})}),(0,I.jsx)(J,{children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})}),(0,I.jsx)(X,{title:`boards`,actions:(0,I.jsx)(G,{size:`sm`,icon:`view_kanban`,href:`/boards`,children:`open boards`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:y.enabled,onChange:e=>oe({enabled:e}),children:`keep the work as boards of tasks — columns Draft, Todo, In progress, Review, Done; each task a folder with task.md, log.md and its files, per project and workspace-wide; agents are woken when a task is assigned to them`}),y.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`boards root`,children:(0,I.jsx)(Z,{value:y.root,placeholder:`kraftwerk-data/boards`,onChange:e=>oe({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per board under the root (workspace boards); a project's boards live in `,(0,I.jsx)(`code`,{children:`projects/<slug>/boards/`}),`. Part of the workspace: versioned with it on the git screen. Agents read and write them with `,(0,I.jsx)(`code`,{children:`kraftwerk tasks`}),`.`]})]})]})}),(0,I.jsx)(X,{title:`presentations`,actions:(0,I.jsx)(G,{size:`sm`,icon:`slideshow`,href:`/presentations`,children:`open presentations`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:x.enabled,onChange:e=>se({enabled:e}),children:`make slide decks — each a folder with a deck.md (markdown slides on a template's layouts) and its pictures, per project and workspace-wide; previewed, presented and exported as PowerPoint or PDF from the same render`}),x.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`presentations root`,children:(0,I.jsx)(Z,{value:x.root,placeholder:`kraftwerk-data/presentations`,onChange:e=>se({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per deck under the root (workspace decks) and `,(0,I.jsx)(`code`,{children:`templates/<slug>/template.yml`}),` for your own templates; a project's decks live in`,` `,(0,I.jsx)(`code`,{children:`projects/<slug>/presentations/`}),`. Part of the workspace: versioned with it on the git screen. Agents write and render them with `,(0,I.jsx)(`code`,{children:`kraftwerk presentations`}),`.`]})]})]})}),jy.map(e=>(0,I.jsx)(X,{title:e,actions:(0,I.jsxs)(G,{size:`sm`,icon:Py[e].icon,href:`/${e}`,children:[`open `,e]}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:C[e].enabled,onChange:t=>ce(e,{enabled:t}),children:Py[e].what}),C[e].enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`${e} root`,children:(0,I.jsx)(Z,{value:C[e].root,placeholder:`kraftwerk-data/${e}`,onChange:t=>ce(e,{root:t.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, `,Py[e].files,`. Part of the workspace: versioned with it on the git screen. Agents read and write them with `,(0,I.jsxs)(`code`,{children:[`kraftwerk `,e]}),`.`]})]})]})},e)),(0,I.jsx)(Fy,{}),(0,I.jsx)(Sy,{}),(0,I.jsxs)(X,{title:`paths & port`,actions:(0,I.jsx)(`code`,{className:`max-w-[60%] truncate text-2xs text-fg-2`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`}),children:[(0,I.jsx)(`div`,{className:`flex flex-col pt-1.5 pb-2.5`,children:le.map(([e,t,n])=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[110px_1fr] items-baseline gap-x-3.5 gap-y-px border-line/55 px-[18px] py-2 [&+&]:border-t`,children:[(0,I.jsx)(nt,{children:e}),(0,I.jsx)(`code`,{className:`text-xs break-all`,children:t}),(0,I.jsx)(`span`,{className:`col-start-2 text-2xs text-fg-2`,children:n})]},e))}),(0,I.jsxs)(J,{className:`px-[18px] pb-3.5`,children:[`Read-only here — edit `,(0,I.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var Ly={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},boards:{label:`boards`,icon:`view_kanban`},tasks:{label:`tasks`,icon:`task`},presentations:{label:`presentations`,icon:`slideshow`},workflows:{label:`workflows`,icon:`account_tree`},knowledge:{label:`knowledge bundles`,icon:`menu_book`},vibeables:{label:`apps`,icon:`web`},channels:{label:`channels`,icon:`forum`},repos:{label:`repositories`,icon:`source`},chats:{label:`chats`,icon:`chat`},runs:{label:`runs`,icon:`play_circle`}};function Ry(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{let e=await A.request(`trash.list`).catch(()=>null);e?.ok?t(e.data):r(e?.status===404?`this server has no trash yet — restart it after updating`:`could not load the trash`)},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async(e,t)=>{a(t),r(``),s(null);try{let n=e===`empty`?(await A.request(`trash.empty`)).error:M(await A.request(`trash.${e}`,{body:{id:t}}));if(n)throw Error(n)}catch(e){r(e.message)}finally{a(null),c()}},u=e?.entries??[],d=[...new Set(u.map(e=>e.kind))].sort((e,t)=>Object.keys(Ly).indexOf(e)-Object.keys(Ly).indexOf(t));return(0,I.jsxs)(ot,{className:`px-6 py-6`,children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`delete`,className:`text-[28px] text-fg-2`}),title:`Trash`,sub:e?`${u.length} item${u.length===1?``:`s`}`:void 0,actions:u.length>0&&(o===`*`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(G,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n}),!e&&!n&&(0,I.jsx)(X,{children:(0,I.jsx)(Y,{children:`loading…`})}),e&&u.length===0&&(0,I.jsx)(X,{children:(0,I.jsx)(Y,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,I.jsx)(X,{title:Ly[e]?.label??e,actions:(0,I.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,I.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,I.jsx)(mt,{className:`trash-row`,leading:(0,I.jsx)(R,{name:Ly[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,I.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,W(t.trashedAt)]})]}),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(G,{size:`sm`,variant:`secondary`,icon:`restore_from_trash`,busy:i===t.id,disabled:!!i,onClick:()=>void l(`restore`,t.id),title:`Put it back at ${t.from}`,children:`restore`}),o===t.id?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,I.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,I.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,I.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,I.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,I.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}function zy(){let[e,t]=(0,v.useState)(`overview`),[n,r]=(0,v.useState)(!0);return(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4 p-6`,children:[(0,I.jsx)(at,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,I.jsx)(G,{variant:`primary`,icon:`add`,children:`primary`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsxs)(X,{title:`Buttons`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-4`,children:[(0,I.jsx)(G,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,I.jsx)(G,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,I.jsx)(G,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,I.jsx)(G,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,I.jsx)(G,{variant:`primary`,busy:!0,children:`Saving`}),(0,I.jsx)(G,{variant:`secondary`,disabled:!0,children:`Disabled`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-4`,children:[(0,I.jsx)(G,{size:`sm`,variant:`primary`,children:`small`}),(0,I.jsx)(G,{size:`sm`,variant:`secondary`,children:`small`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,children:`small`}),(0,I.jsx)(K,{icon:`edit`,label:`Rename`}),(0,I.jsx)(K,{icon:`download`,label:`Download`}),(0,I.jsx)(K,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,I.jsx)(K,{icon:`close`,label:`Close`,size:`sm`})]})]}),(0,I.jsxs)(X,{title:`Status`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,I.jsx)(Qe,{n:3}),` `,(0,I.jsx)(Qe,{n:12,tone:`neutral`}),(0,I.jsx)($e,{tone:`ok`}),` `,(0,I.jsx)($e,{tone:`bad`}),` `,(0,I.jsx)($e,{tone:`ask`}),` `,(0,I.jsx)($e,{tone:`live`}),` `,(0,I.jsx)($e,{tone:`working`}),` `,(0,I.jsx)($e,{tone:`idle`}),(0,I.jsx)(q,{children:`static`}),` `,(0,I.jsx)(q,{tone:`ok`,children:`done`}),` `,(0,I.jsx)(q,{tone:`bad`,children:`failed`}),` `,(0,I.jsx)(q,{tone:`ask`,children:`needs approval`}),` `,(0,I.jsx)(q,{tone:`accent`,children:`running`})]}),(0,I.jsx)(tt,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,I.jsx)(tt,{children:`uploading 2 of 3…`})]}),(0,I.jsx)(X,{title:`Rows`,count:1,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,I.jsxs)(`div`,{className:`p-1.5`,children:[(0,I.jsx)(mt,{leading:`🐻`,title:`Max`,sub:`waiting for you · Set up the build`,subTone:`bad`,titleExtra:(0,I.jsx)(Qe,{n:1}),href:`/ui`}),(0,I.jsx)(mt,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,I.jsx)(mt,{leading:(0,I.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,I.jsx)(K,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,I.jsx)(mt,{leading:(0,I.jsx)($e,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,I.jsx)(mt,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,I.jsxs)(X,{title:`Tabs and sections`,children:[(0,I.jsx)(ht,{items:[{id:`overview`,label:`overview`},{id:`files`,label:`files`,count:4},{id:`knowledge`,label:`knowledge`,count:0}],value:e,onChange:t}),(0,I.jsxs)(`div`,{className:`p-2`,children:[(0,I.jsx)(rt,{size:`lg`,title:`needs you`,count:2,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,I.jsx)(mt,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,I.jsx)(rt,{title:`team`,children:(0,I.jsx)(mt,{leading:`🦊`,title:`Lisa`,sub:`Research`})})]})]}),(0,I.jsx)(X,{title:`Fields`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,I.jsx)(Q,{label:`Name`,hint:`Shown in the rail.`,children:(0,I.jsx)(Z,{placeholder:`e.g. Max`})}),(0,I.jsx)(Q,{label:`Harness`,children:(0,I.jsxs)(bt,{defaultValue:`claude`,children:[(0,I.jsx)(`option`,{children:`claude`}),(0,I.jsx)(`option`,{children:`codex`}),(0,I.jsx)(`option`,{children:`pi`})]})}),(0,I.jsx)(Q,{label:`Role`,children:(0,I.jsx)(yt,{rows:3,placeholder:`What this agent does`})})]})}),(0,I.jsxs)(X,{title:`Empty and menus`,children:[(0,I.jsx)(Y,{icon:`upload_file`,action:(0,I.jsx)(G,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsx)(At,{trigger:({toggle:e})=>(0,I.jsx)(G,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(mt,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,I.jsx)(mt,{leading:`🗑`,title:`Trash`,onClick:e,size:`sm`})]})})})]}),(0,I.jsx)(X,{title:`Sidebar parts`,children:(0,I.jsxs)(`div`,{className:`w-[300px] border-r border-line`,children:[(0,I.jsx)(Et,{title:`workflows`,count:3,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,I.jsx)(Dt,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,I.jsxs)(Ot,{children:[(0,I.jsx)(mt,{leading:(0,I.jsx)($e,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,I.jsx)(kt,{children:`no workflow matches “x”`})]})]})}),(0,I.jsx)(X,{title:`Choices`,children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,I.jsx)($,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,I.jsxs)(St,{children:[(0,I.jsx)(wt,{checked:n,onChange:r,label:`routine enabled`}),(0,I.jsxs)(J,{children:[`Hint: a small explaining line. Keys look like `,(0,I.jsx)(et,{children:`⌘K`}),`.`]})]}),(0,I.jsx)(Tt,{label:`Docker sandbox`,hint:`Docker is not running`,checked:n,onChange:r})]})}),(0,I.jsxs)(X,{title:`Page parts`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(st,{children:`🐻`}),(0,I.jsx)(it,{size:`lg`,children:`Max`}),(0,I.jsx)(q,{href:`#/ui`,children:`linked tag`})]}),(0,I.jsx)(ht,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,I.jsxs)(ut,{children:[(0,I.jsx)(lt,{icon:`account_tree`,title:`workflows`,action:(0,I.jsx)(G,{size:`sm`,children:`edit`}),children:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,I.jsx)(lt,{icon:`menu_book`,title:`knowledge`})]}),(0,I.jsxs)(ft,{children:[(0,I.jsx)(pt,{label:`source`,children:`workspace`}),(0,I.jsx)(pt,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var By={running:{label:`running`},stopped:{label:`stopped`},died:{label:`died`,note:`was killed or crashed`},missing:{label:`missing`,note:`folder is gone`},orphaned:{label:`orphaned`,note:`no kraftwerk.yml any more`}},Vy={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},Hy={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function Uy(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(async()=>{try{let e=await A.request(`workspaces.list`);if(e.ok){t(e.data),r(``);return}r(e.status===404?`This workspace runs a kraftwerk without the workspaces API. Update it and restart its UI.`:`Could not load the workspace registry (HTTP ${e.status}).`)}catch(e){r(e.message||`Could not reach this workspace's server.`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await u(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]);let d=e=>e.root??e.url,f=async(e,t)=>{let n=d(e);a(e=>({...e,[n]:t})),s(e=>({...e,[n]:``})),l(null);try{let n=t===`stop`?{root:e.root,url:e.url}:{root:e.root},r=await A.request(`workspaces.${t}`,{body:n});if(!r.ok)throw Error(M(r));if(!r.data.ok)throw Error(`failed`)}catch(e){s(t=>({...t,[n]:e.message}))}finally{a(e=>{let t={...e};return delete t[n],t}),u()}},p=e?.filter(e=>e.live).length??0,m=new Map;for(let t of e??[])t.icon&&m.set(t.icon,(m.get(t.icon)??0)+1);let h=e=>!!e&&(m.get(e)??0)>1;return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`hub`,className:`text-[28px] text-fg-2`}),title:`Workspaces`,actions:(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}),(0,I.jsxs)(X,{title:`workspaces on this machine`,actions:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`registry: `,(0,I.jsx)(`code`,{className:`text-2xs`,children:`~/.kraftwerk/workspaces`})]}),children:[!e&&!n&&(0,I.jsx)(Y,{className:`py-6`,children:`loading…`}),!e&&n&&(0,I.jsx)(`div`,{className:`px-[18px] py-4`,children:(0,I.jsx)(tt,{tone:`bad`,children:n})}),e&&e.length===0&&(0,I.jsx)(Y,{className:`py-6`,children:`No workspaces known yet.`}),e?.map(e=>{let t=d(e),n=i[t],r=!e.live&&!!e.root&&(e.exists===!1||e.hasConfig===!1),a=P(`text-md font-semibold text-fg`,e.named===!1&&`italic text-fg-2`);return(0,I.jsxs)(`div`,{className:P(`grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 px-[18px] py-3.5 [&+&]:border-t [&+&]:border-line/55`,e.state===`died`&&`bg-ask-soft/30`),children:[(0,I.jsx)(ze,{className:P(`size-10`,Hy[e.state]),icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[e.live&&!e.current?(0,I.jsx)(`a`,{href:pe(e),className:P(a,`no-underline hover:underline`),children:e.name}):(0,I.jsx)(`span`,{className:a,children:e.name}),e.current&&(0,I.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.4px] text-fg-2 uppercase`,children:`current`}),(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-1.5 text-2xs font-semibold tracking-[0.4px] uppercase`,Vy[e.state]),children:[e.live&&(0,I.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),By[e.state].label]}),By[e.state].note&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:By[e.state].note})]}),(0,I.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.root,children:e.rootLabel??(0,I.jsx)(`span`,{className:`font-sans opacity-70`,children:`no root recorded (started by an older version)`})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-3.5 gap-y-1 text-xs text-fg-2`,children:[e.state!==`missing`&&e.state!==`orphaned`&&(0,I.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,I.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,I.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,I.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,I.jsxs)(`span`,{title:e.lastStarted,children:[`started `,W(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,I.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,W(e.lastStopped)]}),e.startCount!=null&&(0,I.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,I.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,W(e.firstSeen)]})]}),o[t]&&(0,I.jsx)(tt,{tone:`bad`,children:o[t]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e.live&&!e.current&&(0,I.jsxs)(`a`,{className:Ze(`secondary`,`sm`),href:pe(e),title:`Open this workspace`,children:[(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`play_arrow`,busy:n===`start`,disabled:!!n,onClick:()=>void f(e,`start`),children:n===`start`?`starting…`:`start`}),e.live&&!e.current&&(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,busy:n===`stop`,disabled:!!n,onClick:()=>void f(e,`stop`),children:n===`stop`?`stopping…`:`stop`}),r&&c!==t&&(0,I.jsx)(G,{size:`sm`,icon:`delete`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:`remove`}),r&&c===t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,I.jsxs)(`p`,{className:`m-0 text-xs text-fg-2 [&_code]:text-2xs`,children:[`Start launches `,(0,I.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,I.jsx)(`code`,{children:`~/.kraftwerk/logs`}),`). Stop sends SIGTERM to the running server. Remove is offered only for records whose root no longer holds a `,(0,I.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,I.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}function Wy(e){if(e<60)return`${e}s`;let t=Math.round(e/60);if(t<60)return`${t} min`;let n=Math.floor(t/60),r=t%60;return r?`${n} h ${r} min`:`${n} h`}var Gy=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],Ky=e=>Gy.find(([t])=>t.test(e))?.[1]??``;function qy({file:e}){return(0,I.jsx)(Yy,{source:{route:`git.diff`,input:{query:{path:e}}}})}var Jy=e=>(e.route===`git.diff`||e.route,A.request(e.route,e.input));function Yy({source:e,refresh:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=JSON.stringify(e);return(0,v.useEffect)(()=>{let t=!0;return r(null),s(``),Jy(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);e.ok?(r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)):(r(``),a(!1),s(e.error??``))}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,I.jsx)(`div`,{className:P(Xy,`text-bad`),children:o}):n===null?(0,I.jsx)(`div`,{className:Xy,children:`loading…`}):n.trim()?(0,I.jsxs)(`pre`,{className:Xy,children:[n.split(`
479
- `).map((e,t)=>(0,I.jsxs)(`span`,{className:Ky(e),children:[e||` `,`
476
+ `).length+2)),onChange:e=>f(e.target.value),spellCheck:!1}),(0,I.jsxs)(J,{className:`border-b border-line px-[18px] py-1.5`,children:[`full file (frontmatter + markdown body) — saving stamps provenance as `,(0,I.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}):(0,I.jsxs)(`div`,{className:P(`concept-doc`,c?`[&_.editor-content]:min-h-[220px]`:`[&_.editor-content]:min-h-[280px]`),onPointerDownCapture:()=>E.current=!0,onKeyDownCapture:()=>E.current=!0,onPasteCapture:()=>E.current=!0,onDropCapture:()=>E.current=!0,children:[_?(0,I.jsx)(v.Suspense,{fallback:(0,I.jsx)(J,{className:`border-b border-line px-[18px] py-1.5`,children:`loading the editor…`}),children:(0,I.jsx)(bv,{markdown:_.body,autoFocus:!1,onChange:N,onError:te},_.key)}):(0,I.jsx)(J,{className:`border-b border-line px-[18px] py-1.5`,children:`loading…`}),(0,I.jsxs)(J,{className:`border-b border-line px-[18px] py-1.5`,children:[`the page as a document, saved as you type; every save stamps provenance as `,(0,I.jsx)(`code`,{children:`human:user`}),` and logs an update.`]})]}),h&&(0,I.jsx)(`div`,{className:`px-3 py-1`,children:(0,I.jsx)(tt,{tone:`bad`,children:h})})]}),(0,I.jsxs)(`aside`,{className:P(`flex min-w-0 flex-col`,c?`gap-2.5`:`gap-4`),children:[(0,I.jsx)(X,{title:`about`,children:(0,I.jsxs)(ft,{compact:c,children:[(0,I.jsx)(pt,{label:`trust`,children:(0,I.jsx)(wv,{tier:n.trustTier})}),(0,I.jsx)(pt,{label:`generated`,dim:!n.generated,children:n.generated?`${n.generated.by??`?`} · ${(n.generated.at??`?`).slice(0,10)}`:`not stamped`}),(0,I.jsx)(pt,{label:`verified`,dim:n.verified.length===0,children:n.verified.length===0?`never`:n.verified.map((e,t)=>(0,I.jsxs)(`span`,{className:`block`,children:[e.by??`?`,` · `,(e.at??`?`).slice(0,10)]},t))}),n.staleAfter&&(0,I.jsxs)(pt,{label:`stale after`,dim:!n.stale,children:[n.staleAfter.slice(0,10),n.stale&&(0,I.jsx)(q,{tone:`bad`,children:`stale`})]}),n.tags.length>0&&(0,I.jsx)(pt,{label:`tags`,children:n.tags.map(e=>(0,I.jsx)(q,{children:e},e))})]})}),n.sources.length>0&&(0,I.jsx)(X,{title:`sources`,children:(0,I.jsx)(ft,{compact:c,children:n.sources.map((e,t)=>(0,I.jsxs)(`div`,{className:P(`flex flex-col gap-[3px] break-words`,c?`px-3.5 py-1.5 text-xs`:`px-[18px] py-2.5 text-[12.5px]`),children:[(0,I.jsxs)(`span`,{className:`text-fg [&_a]:text-accent`,children:[e.resource?.startsWith(`http`)?(0,I.jsx)(`a`,{href:e.resource,target:`_blank`,rel:`noreferrer`,children:e.title??e.resource}):e.title??e.resource??`?`,e.id&&(0,I.jsxs)(`span`,{className:`ml-2 font-mono text-2xs text-fg-2`,children:[`[^`,e.id,`]`]})]}),(0,I.jsx)(`span`,{className:`text-fg-2`,children:[e.author,e.usage_count==null?null:`${e.usage_count} uses`,e.last_modified?`mod ${e.last_modified.slice(0,10)}`:null].filter(Boolean).join(` · `)})]},t))})})]})]})]})}function Lv(e){if(e<60)return`${e}s`;let t=Math.round(e/60);if(t<60)return`${t} min`;let n=Math.floor(t/60),r=t%60;return r?`${n} h ${r} min`:`${n} h`}var Rv=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],zv=e=>Rv.find(([t])=>t.test(e))?.[1]??``;function Bv({file:e}){return(0,I.jsx)(Hv,{source:{route:`git.diff`,input:{query:{path:e}}}})}var Vv=e=>(e.route===`git.diff`||e.route,A.request(e.route,e.input));function Hv({source:e,refresh:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=JSON.stringify(e);return(0,v.useEffect)(()=>{let t=!0;return r(null),s(``),Vv(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);e.ok?(r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)):(r(``),a(!1),s(e.error??``))}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,I.jsx)(`div`,{className:P(Uv,`text-bad`),children:o}):n===null?(0,I.jsx)(`div`,{className:Uv,children:`loading…`}):n.trim()?(0,I.jsxs)(`pre`,{className:Uv,children:[n.split(`
477
+ `).map((e,t)=>(0,I.jsxs)(`span`,{className:zv(e),children:[e||` `,`
480
478
  `]},t)),i&&(0,I.jsxs)(`span`,{className:`text-fg-2 opacity-80`,children:[`… diff truncated, see the rest in a terminal`,`
481
- `]})]}):(0,I.jsx)(`div`,{className:Xy,children:`no textual diff (binary or empty)`})}var Xy=`git-diff mt-1.5 mb-0.5 max-h-[420px] basis-full overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 font-mono text-[11.5px] leading-[1.5] whitespace-pre`,Zy={modified:`text-accent`,added:`text-ok`,untracked:`text-ok`,deleted:`text-bad`,conflicted:`text-bad`};function Qy({status:e,muted:t}){return(0,I.jsx)(`span`,{className:P(`flex-none rounded-full border border-line px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.4px] uppercase`,t?`text-fg-2`:Zy[e]??`text-fg-2`),children:e})}var $y=`text-xs text-fg-2`,eb=`m-0 p-[18px] text-sm text-fg-2`;function tb(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(new Set),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useRef)(!0),h=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:m.current}});m.current=!1,e.ok&&t(e.data)}catch{}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await h(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[h]),(0,v.useEffect)(()=>{if(!e?.files)return;let t=new Set(e.files.filter(e=>e.syncable).map(e=>e.path));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]);let g=async(e,t)=>{l(e),d(``),p(``);try{let n=await A.request(`git.${e}`,{body:t??{}});n.ok&&n.data.ok?p(e===`push`?`pushed`:e===`pull`?`pulled`:`fetched`):d(M(n)||`${e} failed`)}catch(t){d(t.message||`${e} failed`)}finally{l(``)}h()},_=async()=>{l(`commit`),d(``),p(``);try{let e=await A.request(`git.commit`,{body:{paths:[...n],message:o}});e.ok&&e.data.ok?(p(`committed ${n.size} file${n.size===1?``:`s`}`),r(new Set),s(``)):d(M(e)||`commit failed`)}catch(e){d(e.message||`commit failed`)}finally{l(``)}h()};if(!e)return(0,I.jsx)(Y,{children:`loading…`});if(!e.enabled)return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`cloud_sync`,title:`Git sync`}),(0,I.jsx)(X,{children:(0,I.jsxs)(`p`,{className:eb,children:[`Git sync is off. Turn it on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),`, or add a `,(0,I.jsx)(`code`,{children:`git:`}),` block to kraftwerk.yml.`]})})]});let y=(e.files??[]).filter(e=>e.syncable),b=(e.files??[]).filter(e=>!e.syncable),x=(e,t)=>r(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`cloud_sync`,title:`Git sync`,actions:(0,I.jsxs)(I.Fragment,{children:[f&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm text-ok`,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,I.jsx)(tt,{tone:`bad`,children:u})]})}),(0,I.jsx)(X,{title:`branch`,actions:(0,I.jsxs)(I.Fragment,{children:[e.lastFetch&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.lastFetch,children:[`fetched `,W(e.lastFetch)]}),e.lastError&&(0,I.jsxs)(`span`,{className:`inline-flex max-w-[46ch] items-center gap-1 truncate text-xs text-bad`,title:e.lastError,children:[(0,I.jsx)(R,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
482
- `)[0]]})]}),children:e.error?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 p-[18px] text-sm text-bad`,children:[(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-[18px] py-3.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-base`,children:[(0,I.jsx)(R,{name:`account_tree`,className:`ms-sm`}),(0,I.jsx)(`strong`,{className:`font-mono`,children:e.branch}),(0,I.jsx)(`span`,{className:$y,children:e.upstream?`tracking ${e.upstream}`:`no upstream yet, push sets one`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[12.5px] font-semibold`,children:[e.diverged&&(0,I.jsx)(`span`,{className:`text-bad`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,I.jsxs)(`span`,{className:`text-accent`,children:[e.behind,` behind`]}),!!e.ahead&&(0,I.jsxs)(`span`,{className:`text-ok`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,I.jsx)(`span`,{className:P(`text-xs text-fg-2`,`font-normal`),children:`up to date`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(G,{size:`sm`,icon:`refresh`,busy:c===`fetch`,disabled:!!c,onClick:()=>void g(`fetch`),children:`fetch`}),(0,I.jsx)(G,{size:`sm`,icon:`download`,busy:c===`pull`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void g(`pull`),children:`pull`}),(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`upload`,busy:c===`push`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void g(`push`),children:`push`})]})]})}),(0,I.jsxs)(X,{title:`changes`,actions:(0,I.jsx)(`span`,{className:$y,children:y.length===0?`workspace clean`:`${n.size} of ${y.length} selected`}),children:[y.length===0&&b.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing changed under the workspace paths.`}),y.map(e=>(0,I.jsxs)(`div`,{className:P(`git-row px-[18px]`,nb),children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,"aria-label":`select ${e.path}`,checked:n.has(e.path),onChange:t=>x(e.path,t.target.checked)}),(0,I.jsxs)(`button`,{type:`button`,className:`group/file flex min-w-0 flex-1 cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,I.jsx)(R,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Qy,{status:e.status}),(0,I.jsx)(`span`,{className:P(rb,`group-hover/file:underline`),children:e.path})]}),i.has(e.path)&&(0,I.jsx)(qy,{file:e.path})]},e.path)),y.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-t border-line bg-surface-2 px-[18px] py-3`,children:[(0,I.jsx)(Z,{className:`min-w-[220px] flex-1 text-sm`,placeholder:`Commit message`,"aria-label":`commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&_()}}),(0,I.jsx)(G,{size:`sm`,disabled:n.size===y.length,onClick:()=>r(new Set(y.map(e=>e.path))),children:`select all`}),(0,I.jsxs)(G,{size:`sm`,variant:`primary`,icon:`check`,busy:c===`commit`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void _(),children:[`commit `,n.size||``]})]}),b.length>0&&(0,I.jsxs)(`details`,{className:`border-t border-line px-[18px] py-2.5`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer text-[12.5px] text-fg-2`,children:[b.length,e.blockedHidden?`+`:``,` change`,b.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),b.map(e=>(0,I.jsxs)(`div`,{className:P(`git-row blocked opacity-60`,nb),children:[(0,I.jsx)(Qy,{status:e.status,muted:!0}),(0,I.jsx)(`span`,{className:rb,children:e.path}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,I.jsx)(`div`,{className:P(`git-row blocked opacity-60`,nb),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),(0,I.jsxs)(`p`,{className:P($y,`m-0`),children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&`, `,(0,I.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,I.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval?`Fetches every ${Wy(e.interval)}${e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,`Commit and push are always manual.`]})]})}var nb=`flex flex-wrap items-center gap-2.5 py-2 [&+&]:border-t [&+&]:border-line`,rb=`truncate font-mono text-[12.5px]`,ib=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),ab=e=>e.error?{label:`unreadable`,state:`unreadable`}:e.dirty?{label:`${e.dirty} changed`,state:`changed`}:e.ahead?{label:`${e.ahead} to push`,state:`clean`}:e.behind?{label:`${e.behind} behind`,state:`behind`}:{label:`clean`,state:`clean`};function ob({label:e,state:t}){return(0,I.jsx)(`span`,{className:P(`inline-flex items-center text-2xs font-semibold tracking-[0.4px] uppercase`,t===`clean`?`text-ok`:t===`changed`?`text-ask`:t===`unreadable`?`text-bad`:`text-fg-2`),children:e})}var sb=`rounded-full border border-line px-[7px] py-px font-mono text-xs text-fg-2`,cb=`border-line px-[18px] py-2 [&+&]:border-t`,lb=`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,ub=`min-w-0 truncate font-mono text-[12.5px] group-hover/item:underline`;function db({title:e,children:t}){return(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_back`,href:`/repos`,title:`all repositories`,children:`repositories`}),(0,I.jsx)(R,{name:`folder_data`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(it,{children:e}),t]})}var fb=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function pb({slug:e}){return e?(0,I.jsx)(mb,{slug:e}):(0,I.jsx)(hb,{})}function mb({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(0),h=be(),g=(0,v.useCallback)(async()=>{try{let t=await A.request(`repos.get`,{slug:e});if(!t.ok)throw Error(M(t));n(t.data),i(``)}catch(e){i(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await g(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[g,p]);let _=async()=>{u(`update`),f(``);try{let t=await A.request(`repos.update`,{slug:e});if(!t.ok||!t.data.ok)throw Error(t.error||`failed`);t.data.error&&f(t.data.error)}catch(e){f(e.message)}finally{u(``),m(e=>e+1)}};if(r&&!t)return(0,I.jsxs)(ot,{className:`repo-page`,children:[(0,I.jsx)(db,{title:e}),(0,I.jsx)(tt,{tone:`bad`,children:r})]});if(!t)return(0,I.jsx)(Y,{children:`loading…`});let y=ab(t),b=t.commits.filter(e=>e.local).length;return(0,I.jsxs)(ot,{className:`repo-page`,children:[(0,I.jsxs)(db,{title:t.slug,children:[t.branch&&(0,I.jsx)(`span`,{className:sb,children:t.branch}),t.upstream&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:`upstream`,children:[`→ `,t.upstream]}),(0,I.jsx)(ob,{...y}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{size:`sm`,icon:`sync`,busy:l===`update`,disabled:!!l,onClick:()=>void _(),title:`git fetch, then fast-forward when clean`,children:l===`update`?`updating…`:`update`})]}),(0,I.jsxs)(`div`,{className:P($y,`flex flex-wrap gap-x-3.5 gap-y-1`),children:[t.url&&(0,I.jsx)(`span`,{title:t.url,children:ib(t.url)}),h&&(0,I.jsx)(`span`,{title:t.path,children:t.path}),t.head&&(0,I.jsxs)(`span`,{children:[`at `,(0,I.jsx)(`code`,{children:t.head}),t.committedAt?` · ${W(t.committedAt)}`:``]}),!!t.ahead&&(0,I.jsxs)(`span`,{children:[t.ahead,` to push`]}),!!t.behind&&(0,I.jsxs)(`span`,{children:[t.behind,` behind`]}),t.updatedAt&&(0,I.jsxs)(`span`,{children:[`changed `,W(t.updatedAt)]})]}),(t.error||d||r)&&(0,I.jsx)(tt,{tone:`bad`,children:t.error||d||r}),(0,I.jsxs)(X,{title:`changes · working tree against HEAD`,actions:(0,I.jsxs)(`span`,{className:$y,children:[t.files.length,` file`,t.files.length===1?``:`s`,t.insertions||t.deletions?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsxs)(`span`,{className:`text-ok`,children:[`+`,t.insertions]}),` `,(0,I.jsxs)(`span`,{className:`text-bad`,children:[`−`,t.deletions]})]}):null]}),children:[t.files.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Clean — nothing changed since the last commit.`}),t.files.map(n=>(0,I.jsxs)(`div`,{className:P(`repo-file`,cb),"data-file":n.path,children:[(0,I.jsxs)(`button`,{type:`button`,className:lb,onClick:()=>o(a===n.path?null:n.path),children:[(0,I.jsx)(R,{name:a===n.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Qy,{status:n.status}),(0,I.jsx)(`span`,{className:ub,children:n.path})]}),a===n.path&&(0,I.jsx)(Yy,{source:{route:`repos.diff`,input:{slug:e,query:{path:n.path}}},refresh:t.updatedAt})]},n.path))]}),(0,I.jsxs)(X,{title:`commits · newest first`,actions:(0,I.jsx)(`span`,{className:$y,children:b?`${b} not pushed`:t.commits.length?`all pushed`:``}),children:[t.commits.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`No commits yet.`}),t.commits.map(t=>(0,I.jsxs)(`div`,{className:P(`repo-commit`,cb),"data-commit":t.short,children:[(0,I.jsxs)(`button`,{type:`button`,className:lb,onClick:()=>c(s===t.hash?null:t.hash),title:t.hash,children:[(0,I.jsx)(R,{name:s===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(`code`,{className:`text-xs`,children:t.short}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:t.subject}),t.local&&(0,I.jsx)(q,{tone:`accent`,children:`not pushed`}),(0,I.jsxs)(`span`,{className:P($y,`ml-auto flex-none`),children:[t.author,` · `,W(t.committedAt)]})]}),s===t.hash&&(0,I.jsx)(Yy,{source:{route:`repos.commit`,input:{slug:e,hash:t.hash}}})]},t.hash))]})]})}function hb(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=be(),S=(0,v.useCallback)(async()=>{try{let e=await A.request(`repos.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);t(e.data),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await S(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[S]);let C=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await A.request(`repos.update`,{slug:e}):await A.request(`repos.remove`,{slug:e,query:{force:n}});if(!r.ok||!r.data.ok)throw Error(r.error||`failed`);let i=r.data.error;i&&s(t=>({...t,[e]:i}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),S()}},w=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await A.request(`repos.add`,{body:{url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0}});if(!e.ok)throw Error(e.error||`clone failed`);d(``),p(``),h(``),await S()}catch(e){b(e.message)}finally{_(!1)}}},T=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`source`,title:`Repositories`,actions:(0,I.jsxs)(I.Fragment,{children:[e?.enabled&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[T.length,` cloned`]}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}),e&&!e.enabled&&(0,I.jsx)(X,{children:(0,I.jsx)(`div`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:e.error&&!/are off/.test(e.error)?(0,I.jsx)(tt,{tone:`bad`,children:e.error}):(0,I.jsxs)(I.Fragment,{children:[`Repositories are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,I.jsx)(X,{title:`add a repository`,actions:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`clones into `,(0,I.jsx)(`code`,{title:e.root,children:e.root})]}),children:(0,I.jsxs)(`form`,{className:`flex flex-col gap-2.5 p-[18px]`,onSubmit:e=>void w(e),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2.5`,children:[(0,I.jsx)(Q,{label:`url`,className:`min-w-[240px] flex-[2]`,children:(0,I.jsx)(Z,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-[140px] flex-1`,children:(0,I.jsx)(Z,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})}),(0,I.jsx)(Q,{label:`branch`,className:`w-[140px]`,children:(0,I.jsx)(Z,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})}),(0,I.jsx)(G,{type:`submit`,variant:`primary`,icon:`download`,busy:g,disabled:!u.trim(),children:g?`cloning…`:`clone`})]}),y&&(0,I.jsx)(tt,{tone:`bad`,children:y}),(0,I.jsxs)(`p`,{className:P(`text-xs text-fg-2`,`m-0`),children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,I.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})}),e?.enabled&&(0,I.jsxs)(X,{title:`cloned repositories · newest change first`,children:[T.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing cloned yet.`}),T.map(e=>{let t=i[e.slug],n=ab(e);return(0,I.jsxs)(`div`,{className:P(`repo-row grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 border-line px-[18px] py-3.5 [&+&]:border-t`,n.state===`changed`&&`bg-ask-soft/40`),"data-repo":e.slug,children:[(0,I.jsx)(`span`,{className:P(`grid size-10 place-items-center rounded-full bg-surface-2 text-fg-2`,n.state===`unreadable`&&`opacity-45 grayscale`),children:(0,I.jsx)(R,{name:`folder_data`,className:`text-[22px]`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,I.jsx)(U,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`text-md font-semibold text-fg no-underline hover:underline`,title:`changes and commits`,children:e.slug}),e.branch&&(0,I.jsx)(`span`,{className:sb,children:e.branch}),(0,I.jsx)(ob,{...n}),e.updatedAt&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,W(e.updatedAt)]})]}),e.url&&(0,I.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.url,children:ib(e.url)}),x&&(0,I.jsx)(`div`,{className:`text-xs [overflow-wrap:anywhere] text-fg-2 opacity-70`,title:e.path,children:e.path}),(0,I.jsxs)(`div`,{className:P(`text-xs text-fg-2`,`flex flex-wrap gap-x-3.5 gap-y-1 [&_code]:text-[11.5px]`),children:[e.head&&(0,I.jsxs)(`span`,{title:e.committedAt,children:[(0,I.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${W(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,I.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,I.jsx)(`span`,{className:`text-bad`,children:e.error})]}),o[e.slug]&&(0,I.jsx)(tt,{tone:`bad`,children:o[e.slug]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,I.jsx)(G,{size:`sm`,icon:`difference`,href:`/repos/${encodeURIComponent(e.slug)}`,title:`changed files with diffs, recent commits`,children:`changes`}),(0,I.jsx)(G,{size:`sm`,icon:`sync`,busy:t===`update`,disabled:!!t,onClick:()=>void C(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:t===`update`?`updating…`:`update`}),c!==e.slug&&(0,I.jsx)(G,{size:`sm`,icon:`delete`,disabled:!!t,onClick:()=>l(e.slug),title:`Move the clone to the trash`,children:`remove`}),c===e.slug&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void C(e.slug,`remove`,fb(e)),children:e.dirty||e.ahead?`delete with local changes`:fb(e)?`delete anyway`:`confirm remove`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var gb=40,_b=/Mac|iPhone|iPad/.test(navigator.platform),vb=null,yb=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`})),...(e.entities??[]).map(t=>({kind:`entity`,entity:t,ws:e,key:`${e.url}|${t.kind}|${t.slug}`})),...(e.current?e.tasks??[]:[]).map(t=>({kind:`task`,task:t,ws:e,key:`${e.url}|task|${t.project??``}|${t.board}|${t.slug}`})),...(e.current?e.decks??[]:[]).map(t=>({kind:`deck`,deck:t,ws:e,key:`${e.url}|deck|${t.project??``}|${t.name}`}))]),bb=e=>e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.kind===`entity`?e.entity.title:e.kind===`task`?e.task.title:e.kind===`deck`?e.deck.title:e.channel.name,xb=e=>e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.kind===`entity`?e.entity.detail:e.kind===`task`?`${e.task.project?`${e.task.project} · `:``}${e.task.board} · ${e.task.status}`:e.kind===`deck`?`${e.deck.project?`${e.deck.project} · `:``}${e.deck.slides} ${e.deck.slides===1?`slide`:`slides`}`:e.channel.purpose,Sb=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:e.kind===`entity`?`/${e.entity.kind}/${encodeURIComponent(e.entity.slug)}`:e.kind===`task`?e.task.href:e.kind===`deck`?e.deck.href:`/channels/${encodeURIComponent(e.channel.slug)}`,Cb={contacts:`contact`,places:`place`,events:`event`},wb={contacts:`person`,places:`location_on`,events:`event`},Tb={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},Eb=e=>e.kind===`agent`?e.agent.emoji:e.kind===`project`?Tb[e.project.status]:e.kind===`entity`?(0,I.jsx)(R,{name:wb[e.entity.kind],className:`text-[18px] text-fg-2`}):e.kind===`task`?(0,I.jsx)(R,{name:`task`,className:`text-[18px] text-fg-2`}):e.kind===`deck`?(0,I.jsx)(R,{name:`slideshow`,className:`text-[18px] text-fg-2`}):(0,I.jsx)(R,{name:`forum`,className:`text-[18px] text-fg-2`}),Db=`flex-none rounded-full border border-line px-1.5 py-px text-[10px] font-semibold tracking-[0.4px] uppercase`;function Ob(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=bb(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:t.kind===`entity`?[t.entity.slug,t.entity.detail??``,Cb[t.entity.kind],`${Cb[t.entity.kind]}:${t.entity.slug}`]:t.kind===`task`?[t.task.slug,`task:${t.task.slug}`,t.task.board,t.task.project??``,t.task.status,`task`]:t.kind===`deck`?[t.deck.name,`presentation:${t.deck.name}`,t.deck.project??``,`presentation`,`deck`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function kb(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function Ab(e){let t=Sb(e);if(e.ws.current)return H(t);let n=e.ws.live||!e.ws.root?pe(e.ws):await me(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function jb(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-xl border-0 bg-transparent py-1 pr-2 pl-1.5 text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg active:scale-96`,onClick:()=>t(!0),title:`jump to an agent, project or channel`,"aria-label":`search`,children:[(0,I.jsx)(R,{name:`search`}),(0,I.jsx)(et,{className:`max-[1100px]:hidden`,children:_b?`⌘K`:`Ctrl K`})]}),e&&(0,I.jsx)(Mb,{onClose:()=>t(!1)})]})}function Mb({onClose:e}){let[t,n]=(0,v.useState)(vb),[r,i]=(0,v.useState)(vb===null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return A.call(`search.agents`).then(t=>{vb=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>yb(t),[t]),_=(0,v.useMemo)(()=>Ob(g,s).slice(0,gb),[g,s]),y=(0,v.useMemo)(()=>kb(_),[_]),b=Math.min(l,Math.max(_.length-1,0));(0,v.useEffect)(()=>{h.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[b,_]);let x=t=>{d||(t.ws.current||t.ws.live?(e(),Ab(t)):(f(t.key),m(``),Ab(t).catch(e=>{f(null),m(`${t.ws.name}: ${e.message}`)})))},S=t=>{if(t.key===`ArrowDown`)t.preventDefault(),u(_.length?(b+1)%_.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),u(_.length?(b-1+_.length)%_.length:0);else if(t.key===`Enter`){t.preventDefault();let e=_[b];e&&x(e)}else t.key===`Escape`&&(t.preventDefault(),e())},C=`px-4 py-7 text-center text-sm text-fg-2 [&_a]:underline`,w;if(_.length>0){let e=-1;w=(0,I.jsx)(`ul`,{className:`m-0 list-none overflow-y-auto overscroll-contain p-1.5`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:h,children:y.map(t=>(0,I.jsxs)(v.Fragment,{children:[(0,I.jsxs)(`li`,{className:`palette-group flex items-center gap-1.5 px-2.5 pt-3 pb-1 text-2xs font-semibold tracking-[0.4px] text-fg-2 uppercase first:pt-1.5`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,I.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,I.jsx)(`span`,{className:`truncate`,children:t.ws.name}),t.ws.current?(0,I.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:`this workspace`}):t.ws.live?(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}):(0,I.jsx)(`span`,{className:Db,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,I.jsxs)(`li`,{role:`option`,"aria-selected":n===b,className:P(`flex cursor-pointer items-center gap-2.5 rounded-xl px-2.5 py-2`,n===b&&`bg-surface-2`),onMouseMove:()=>n!==b&&u(n),onClick:()=>x(t),children:[(0,I.jsx)(`span`,{className:`w-6 flex-none text-center text-[18px] leading-none`,"aria-hidden":!0,children:Eb(t)}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-fg`,children:bb(t)}),xb(t)&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:xb(t)})]}),d===t.key?(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}):t.kind!==`agent`&&(0,I.jsx)(`span`,{className:P(Db,`text-fg-2`),children:t.kind===`entity`?Cb[t.entity.kind]:t.kind===`deck`?`presentation`:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else w=a?(0,I.jsx)(`div`,{className:C,children:`could not load the agents, projects and channels`}):r?(0,I.jsx)(`div`,{className:C,children:`looking for agents, projects and channels…`}):g.length===0?(0,I.jsxs)(`div`,{className:C,children:[`no agents yet — `,(0,I.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,I.jsxs)(`div`,{className:C,children:[`no agent, project or channel matches “`,s,`”`]});return(0,I.jsx)(`div`,{className:`palette-backdrop fixed inset-0 z-50 flex animate-fade items-start justify-center bg-black/35 px-4 pt-[12vh] pb-4`,onMouseDown:e,children:(0,I.jsxs)(`div`,{className:`flex max-h-[min(70dvh,560px)] w-[min(620px,100%)] animate-modal flex-col overflow-hidden rounded-2xl border border-line bg-surface shadow-modal`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:S,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3 text-fg-2`,children:[(0,I.jsx)(R,{name:`search`}),(0,I.jsx)(`input`,{autoFocus:!0,className:`min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-[16px] text-fg outline-none`,value:s,onChange:e=>{c(e.target.value),u(0)},placeholder:`jump to an agent, project, channel, task, presentation, contact, place or event…`,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),r&&t&&(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),(0,I.jsx)(et,{children:`esc`})]}),w,(0,I.jsxs)(`div`,{className:`flex items-center gap-3.5 border-t border-line px-3.5 py-2 text-2xs text-fg-2 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(et,{children:`↑`}),(0,I.jsx)(et,{children:`↓`}),` move`]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(et,{children:`↵`}),` open`]}),d&&(0,I.jsxs)(`span`,{className:`ml-auto`,children:[(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),p&&(0,I.jsxs)(`span`,{className:`ml-auto max-w-[60%] truncate text-bad`,title:p,children:[(0,I.jsx)(R,{name:`warning`,className:`ms-sm`}),` `,p]})]})]})})}var Nb=1296e5;function Pb(e){if(e<6e4)return`just now`;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Fb(e,t){let n=new Date(e),r=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),i=Math.round((new Date(n).setHours(0,0,0,0)-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?r:i===1?`tomorrow ${r}`:`${n.toLocaleDateString([],{weekday:`short`})} ${r}`}function Ib(e,t=``,n=new Date){if(!e)return t?{text:t,tone:`plain`}:null;let r=e=>`${e[0].title||`a session`}${e.length>1?` +${e.length-1}`:``}`;if(e.waiting.length)return{text:`waiting for you · ${r(e.waiting)}`,tone:`waiting`};if(e.working.length){let t=e.working[0].since,i=t?Pb(Math.max(0,n.getTime()-Date.parse(t))):``;return{text:`working · ${r(e.working)}${i&&i!==`just now`?` · ${i}`:``}`,tone:`working`}}if(e.nextRoutine&&Date.parse(e.nextRoutine.at)-n.getTime()<Nb)return{text:`next: ${e.nextRoutine.name} · ${Fb(e.nextRoutine.at,n)}`,tone:`plain`};if(e.lastActiveAt){let t=Pb(Math.max(0,n.getTime()-Date.parse(e.lastActiveAt)));return{text:t===`just now`?`last active just now`:`last active ${t} ago`,tone:`plain`}}return{text:t||`no sessions yet`,tone:`plain`}}var Lb=e=>`section`in e;function Rb(e){return[...e.top.map(e=>({slug:e})),...e.sections.flatMap(e=>[{section:e.name},...e.projects.map(e=>({slug:e}))])]}function zb(e){let t={top:[],sections:[]};for(let n of e)Lb(n)?t.sections.push({name:n.section,projects:[]}):(t.sections.at(-1)?.projects??t.top).push(n.slug);return t}var Bb=(e,t)=>Lb(e)?`section`in t&&e.section===t.section:`slug`in t&&e.slug===t.slug;function Vb(e,t,n){let r=e.findIndex(e=>Bb(e,t));if(r<0)return e;let i=r+1;if(`section`in t)for(;i<e.length&&!Lb(e[i]);)i++;if(n>=r&&n<=i)return e;let a=e.slice(r,i),o=[...e.slice(0,r),...e.slice(i)],s=n>r?n-a.length:n;return[...o.slice(0,s),...a,...o.slice(s)]}function Hb({layout:e,visible:t,render:n,onSave:r,collapsed:i,onCollapse:a,editing:o,onEdited:s}){let[c,l]=(0,v.useState)(null),u=c??Rb(e);(0,v.useEffect)(()=>l(null),[JSON.stringify(e)]);let[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(o);(0,v.useEffect)(()=>g(o),[o]);let _=async e=>{l(e),await r(zb(e))||l(null)},y=()=>{f(null),m(null)},b=(e,t)=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientY>n.top+n.height/2,i=u[t];if(d&&`slug`in d&&Lb(i))return t+1;if(d&&`section`in d){let e=t;for(;e>=0&&!Lb(u[e]);)e--;if(e<0)return u.findIndex(Lb)<0?u.length:u.findIndex(Lb);if(!r&&e===t)return e;let n=e+1;for(;n<u.length&&!Lb(u[n]);)n++;return n}return r?t+1:t},x=e=>({onDragOver:t=>{if(!d)return;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`;let n=e===void 0?u.length:b(t,e);n!==p&&m(n)},onDrop:t=>{if(!d)return;t.preventDefault(),t.stopPropagation();let n=Vb(u,d,e===void 0?u.length:b(t,e));y(),n!==u&&_(n)}}),S=e=>({draggable:!0,onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,`slug`in e?e.slug:e.section),f(e)},onDragEnd:y}),C=e=>t=>{if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=u.findIndex(t=>!Lb(t)&&t.slug===e),r=t.key===`ArrowUp`?n-1:n+2;r<0||r>u.length||_(Vb(u,{slug:e},r))},w=e=>d&&p===e?(0,I.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,I.jsx)(`div`,{className:`absolute inset-x-2 -top-px h-0.5 rounded-full bg-accent`})}):null,T=[],E;return u.forEach((e,r)=>{if(T.push((0,I.jsx)(v.Fragment,{children:w(r)},`line:${r}`)),Lb(e)){E=e.section;let t=e.section,n=i(t),o=0;for(let e=r+1;e<u.length&&!Lb(u[e]);e++)o++;T.push((0,I.jsx)(`div`,{...x(r),...h===t?{}:S({section:t}),className:P(`group/sec mt-2 flex items-center gap-0.5 rounded-control pl-1 pr-1`,d&&`section`in d&&d.section===t&&`opacity-40`),"data-section":t,children:h===t?(0,I.jsx)(Ub,{name:t,taken:u.filter(Lb).map(e=>e.section).filter(e=>e!==t),onDone:e=>{g(void 0),s(),e&&e!==t&&_(u.map(n=>Lb(n)&&n.section===t?{section:e}:n))}}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-0 bg-transparent px-1 py-1 text-left font-[inherit] text-xs font-semibold text-fg-2 hover:text-fg`,"aria-expanded":!n,title:n?`show the projects in ${t}`:`fold ${t}`,onClick:()=>a(t),children:[(0,I.jsx)(R,{name:`chevron_right`,className:P(`ms-sm flex-none text-[15px] transition-transform`,!n&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,I.jsx)(`span`,{className:`font-normal tabular-nums opacity-70`,children:o})]}),(0,I.jsxs)(`span`,{className:`flex items-center opacity-0 transition-opacity group-hover/sec:opacity-100 group-focus-within/sec:opacity-100 pointer-coarse:opacity-100`,children:[(0,I.jsx)(K,{size:`sm`,icon:`edit`,label:`rename section ${t}`,onClick:()=>g(t)}),(0,I.jsx)(K,{size:`sm`,icon:`close`,label:`remove section ${t}`,title:`remove the section; its projects move up`,onClick:()=>void _(u.filter(e=>!(Lb(e)&&e.section===t)))})]})]})},`section:${t}`))}else E&&i(E)&&!t(e.slug)||T.push((0,I.jsx)(`div`,{...x(r),...S({slug:e.slug}),onKeyDown:C(e.slug),className:P(`flex flex-col gap-0.5`,d&&`slug`in d&&d.slug===e.slug&&`opacity-40`),"data-sort":e.slug,children:n(e.slug)},e.slug))}),T.push((0,I.jsx)(v.Fragment,{children:w(u.length)},`line:end`)),d&&T.push((0,I.jsx)(`div`,{className:`h-4`,...x()},`drop:end`)),(0,I.jsx)(I.Fragment,{children:T})}function Ub({name:e,taken:t,onDone:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let o=r.trim().slice(0,60),s=!!o&&!t.includes(o);return(0,I.jsx)(`input`,{ref:a,value:r,"aria-label":`section name`,maxLength:60,className:P(`min-w-0 flex-1 rounded-control border bg-surface px-2 py-1 font-[inherit] text-xs font-semibold text-fg outline-none`,s?`border-line focus:border-accent`:`border-bad`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n(s?o:void 0),e.key===`Escape`&&n()},onBlur:()=>n(s?o:void 0)})}function Wb(e){let t=new Set(e.sections.map(e=>e.name)),n=`New section`;for(let e=2;t.has(n);e++)n=`New section ${e}`;return n}function Gb({chatPath:e}){let t=Te(),n=be(),r=N(`agents.list`,{},{interval:15e3}),i=N(`projects.list`,t.projects?{}:null,{interval:15e3}),a=N(`agents.status`,{},{interval:5e3}),o=e.split(`/`).filter(Boolean),s=(e,t)=>o[0]===e&&(t===void 0||(o[1]?decodeURIComponent(o[1]):void 0)===t),c=o[0]===`agents`&&o[1]===`chats`,[l,u]=Yb(),d=Lt()??[],f=new Map((r?.agents??[]).filter(e=>!e.archived).map(e=>[e.slug,e])),p=i?.projects??[],m=e=>(e.agents??[]).map(e=>f.get(e)).filter(e=>!!e),h=e=>s(`projects`,e.slug),g=new Map(p.map(e=>[e.slug,e])),_=i?.layout?[...i.layout.top,...i.layout.sections.flatMap(e=>e.projects)].map(e=>g.get(e)).filter(e=>!!e):p,y=async e=>!!(await A.request(`projects.saveLayout`,{body:e}).catch(()=>null))?.ok,[b,x]=(0,v.useState)(),S=async()=>{if(!i?.layout)return;let e=Wb(i.layout);await y({...i.layout,sections:[...i.layout.sections,{name:e,projects:[]}]})&&x(e)},C=e=>{let t=m(e).map(e=>a?.[e.slug]).filter(e=>!!e).some(e=>e.working.length&&!e.waiting.length);return(0,I.jsx)(mt,{size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:s(`projects`,e.slug),innerProps:{"data-project":e.slug,title:e.goal?`${e.title}: ${e.goal}`:e.title},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),title:e.title,titleExtra:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qe,{n:Rt.project(d,e.slug,e.agents).length,title:`waiting for you`}),t&&(0,I.jsx)($e,{tone:`working`,title:`an agent is working`})]}),titleLines:2})};return(0,I.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-2 pb-4`,children:[(0,I.jsx)(mt,{href:`/`,active:e===`/`,leading:(0,I.jsx)(R,{name:`home`}),title:`Home`,innerProps:{title:`Today: what needs you, what happened`}}),(0,I.jsx)(mt,{href:`/agents/chats`,active:c,leading:(0,I.jsx)(R,{name:`chat`}),title:`Chats`,titleExtra:(0,I.jsx)(Qe,{n:Rt.general(d).length,title:`waiting for you`}),innerProps:{title:`Every chat with Ralv and in the projects; start a new one with Ralv, the chief of staff`}}),(0,I.jsx)(mt,{href:`/artifacts`,active:e===`/artifacts`,leading:(0,I.jsx)(R,{name:`category`}),title:`Artifacts`,innerProps:{title:`Everything made here: apps, presentations, boards, contacts, places, events`}}),t.projects&&(0,I.jsxs)(Kb,{label:`projects`,href:`/projects`,add:i?.enabled?{href:`/projects/new`,label:`new project`}:void 0,badge:l.all?(0,I.jsx)(Qe,{n:new Set(p.filter(e=>!h(e)).flatMap(e=>Rt.project(d,e.slug,e.agents).map(e=>e.id))).size,title:`waiting in the projects folded away`}):void 0,fold:p.length>0?(0,I.jsxs)(I.Fragment,{children:[!l.all&&i?.layout&&(0,I.jsx)(K,{size:`sm`,icon:`create_new_folder`,label:`new section`,title:`new section: drag projects into it`,onClick:()=>void S()}),(0,I.jsx)(K,{size:`sm`,icon:l.all?`chevron_right`:`expand_more`,label:l.all?`show all projects`:`collapse projects`,"aria-expanded":!l.all,onClick:()=>u(e=>({...e,all:!e.all}))})]}):void 0,children:[l.all||!i?.layout?_.filter(e=>!l.all||h(e)).map(e=>(0,I.jsx)(v.Fragment,{children:C(e)},e.slug)):(0,I.jsx)(Hb,{layout:i.layout,visible:e=>!!g.get(e)&&h(g.get(e)),render:e=>g.get(e)?C(g.get(e)):null,onSave:y,collapsed:e=>!!l.sections[e],onCollapse:e=>u(t=>({...t,sections:{...t.sections,[e]:!t.sections[e]}})),editing:b,onEdited:()=>x(void 0)}),l.all&&p.length>0&&(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,icon:`expand_more`,className:`justify-start`,onClick:()=>u(e=>({...e,all:!1})),children:[p.filter(e=>!h(e)).length,` more`]})]}),(0,I.jsx)(Kb,{label:`agents`,href:`/agents`,add:n?{href:`/agents/new`,label:`new agent`}:void 0,children:(r?.agents??[]).filter(e=>!e.archived).map(e=>{let t=Ib(a?.[e.slug],e.description);return(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:s(`agents`,e.slug)||s(`team`,e.slug),innerProps:{title:e.description||void 0},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,titleExtra:(0,I.jsx)(qb,{n:Rt.agent(d,e.slug).length,st:a?.[e.slug]}),sub:t?(0,I.jsx)(`span`,{className:`rail-status${t.tone===`plain`?``:` ${t.tone}`}`,children:t.text}):void 0,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})]})})}function Kb({label:e,href:t,add:n,badge:r,fold:i,children:a}){return(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-0.5`,role:`group`,"aria-label":e[0].toUpperCase()+e.slice(1),children:[(0,I.jsxs)(`div`,{className:`group/head flex items-center gap-1 pl-2.5 pr-1`,children:[(0,I.jsx)(U,{href:t,className:`flex-1 px-0 py-1 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2 no-underline hover:text-fg`,children:e}),r,(0,I.jsxs)(`span`,{className:`flex items-center gap-1 opacity-0 transition-opacity group-hover/head:opacity-100 group-focus-within/head:opacity-100 pointer-coarse:opacity-100`,children:[n&&(0,I.jsx)(K,{size:`sm`,icon:`add`,label:n.label,href:n.href}),i]})]}),a]})}function qb({n:e,st:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qe,{n:e,title:`waiting for you`}),!e&&t?.working.length&&!t.waiting.length?(0,I.jsx)($e,{tone:`working`,title:`working`}):null]})}var Jb=`kw-rail-fold`;function Yb(){let[e,t]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(Jb)??`null`),t=e=>e&&typeof e==`object`?e:{};return{all:!!e?.all,open:t(e?.open),sections:t(e?.sections)}}catch{return{all:!1,open:{},sections:{}}}});return[e,e=>t(t=>{let n=e(t);try{localStorage.setItem(Jb,JSON.stringify(n))}catch{}return n})]}function Xb({path:e}){let t=be(),n=Te(),r=e.split(`/`).filter(Boolean)[0]??``;if(!t)return null;let i=[{id:`workflows`,href:`/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,href:`/knowledge`,label:`knowledge`,icon:`menu_book`},{id:`files`,href:`/files`,label:`files`,icon:`folder_open`},...n.presentations?[{id:`presentations`,href:`/presentations`,label:`presentations`,icon:`slideshow`}]:[],...n.vibeables?[{id:`vibeables`,href:`/vibeables`,label:`apps`,icon:`web`}]:[],{id:`skills`,href:`/skills`,label:`skills`,icon:`extension`},...n.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`}]:[],...n.contacts?[{id:`contacts`,href:`/contacts`,label:`contacts`,icon:`person`}]:[],...n.places?[{id:`places`,href:`/places`,label:`places`,icon:`location_on`}]:[],...n.events?[{id:`events`,href:`/events`,label:`events`,icon:`event`}]:[],...n.git?[{id:`git`,href:`/git`,label:`git`,icon:`cloud_sync`,badge:(0,I.jsx)(Zb,{})}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`},{id:`trash`,href:`/trash`,label:`trash`,icon:`delete`}],a=e=>r===e||e===`workflows`&&r===`runs`;return(0,I.jsx)(`nav`,{className:`global-nav flex min-w-0 flex-[0_1_auto] justify-start gap-0.5 overflow-x-auto [scrollbar-width:none] max-[1199px]:[mask-image:linear-gradient(to_right,#000_calc(100%-24px),transparent)] max-[800px]:hidden`,"aria-label":`Workspace`,children:i.map(e=>{let t=a(e.id);return(0,I.jsxs)(`a`,{href:`#${e.href}`,className:P(`inline-flex flex-none items-center gap-1.5 rounded-full px-3 py-1.5 text-[13.5px] font-semibold no-underline transition-colors`,`[&_.ms]:text-[18px] max-[1520px]:gap-[5px] max-[1520px]:[&_.ms]:text-[17px]`,t?`bg-surface text-accent shadow-[inset_0_0_0_1px_var(--line)]`:`text-fg-2 hover:bg-surface-2 hover:text-fg`),"aria-current":t?`page`:void 0,children:[(0,I.jsx)(R,{name:e.icon,fill:t}),` `,e.label,e.badge]},e.id)})})}function Zb(){let e=N(`git.status`,{},{interval:15e3}),t=e?.files?.filter(e=>e.syncable).length??0,n=`ml-[5px] rounded-full bg-surface-2 px-1.5 py-px text-[10.5px] font-semibold tabular-nums`;return(0,I.jsxs)(I.Fragment,{children:[!!e?.behind&&(0,I.jsxs)(`span`,{className:P(n,`text-accent`),children:[e.behind,`↓`]}),!!e?.ahead&&(0,I.jsxs)(`span`,{className:P(n,`text-ok`),children:[e.ahead,`↑`]}),!e?.ahead&&!e?.behind&&!!t&&(0,I.jsx)(`span`,{className:n,children:t})]})}var Qb=e=>e.replace(/^# .*\n+/,``).replace(/\(human:user\)/g,`(you)`),$b=`flex flex-col gap-1.5 px-1.5 pb-6 pt-3`,ex=`m-0 px-2.5 pb-0.5 text-md leading-[1.45] text-fg`,tx=`m-0 px-2.5 py-0.5 text-sm text-fg-2`,nx=`md-body px-2.5 text-sm leading-normal`,rx=e=>Da.sanitize(Jr.parse(Qb(e),{async:!1}));function ix(e,t){let n=[],r=``;for(let i of e.split(`
483
- `)){let e=/^## (.+)$/.exec(i.trim());if(e?r=e[1]:/^[-*] /.test(i)&&n.push({day:r,text:i.replace(/^[-*] /,``)}),n.length>=t)break}return n}function ax({items:e}){return e.length===0?null:(0,I.jsx)(rt,{size:`lg`,title:`needs you`,count:e.length,children:e.map(e=>(0,I.jsx)(mt,{onClick:()=>Gt(e),leading:(0,I.jsx)(R,{name:zt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${e.owner.agent?`${e.owner.agent.emoji??``} ${e.owner.agent.name} · `:``}${Bt(e.kind)} · ${W(e.since)}`},e.id))})}function ox({slugs:e,agents:t,status:n,title:r=`team`}){let i=e.map(e=>t.find(t=>t.slug===e)).filter(e=>!!e);return i.length===0?null:(0,I.jsx)(rt,{size:`lg`,title:r,children:i.map(e=>{let t=Ib(n?.[e.slug],e.description);return(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,sub:t?.text,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})}function sx({scope:e}){let t=N(`files.recent`,{query:{scope:e}},{interval:2e4});return!t||t.count===0?null:(0,I.jsx)(rt,{size:`lg`,title:`files`,count:t.count,action:(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,href:El(e),children:[`all `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),children:t.recent.map(t=>{let n=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``;return(0,I.jsx)(mt,{href:El(e,n,t.path),leading:(0,I.jsx)(R,{name:`draft`,className:`ms-sm`}),title:t.path.split(`/`).pop(),sub:`${n?`${n}/ · `:``}${W(t.at)}`},t.path)})})}function cx({of:e}){let t=Lt()??[],n=N(`agents.list`,{},{interval:15e3})?.agents??[],r=N(`agents.status`,{},{interval:5e3})??void 0;if(e.kind===`project`){let i=e.project,a=i.links.agents.map(e=>e.slug),o=ix(i.log,5);return(0,I.jsxs)(`div`,{className:$b,children:[(0,I.jsx)(rt,{size:`lg`,title:`goal`,children:(0,I.jsxs)(`p`,{className:ex,children:[i.goal||(0,I.jsx)(`span`,{className:`text-fg-2`,children:`No goal written yet.`}),i.status!==`active`&&(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[` · `,i.status]})]})}),o.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`lately`,children:o.map((e,t)=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[74px_minmax(0,1fr)] gap-2 px-2.5 py-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`pt-px text-xs tabular-nums text-fg-2`,children:e.day}),(0,I.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parseInline(Qb(e.text),{async:!1}))}})]},t))}),(0,I.jsx)(ax,{items:Rt.project(t,i.slug,a)}),(0,I.jsx)(ox,{slugs:a,agents:n,status:r}),(0,I.jsx)(rt,{size:`lg`,title:`where it stands`,children:i.state.trim()?(0,I.jsx)(`div`,{className:nx,dangerouslySetInnerHTML:{__html:rx(i.state)}}):(0,I.jsx)(`p`,{className:tx,children:`Nothing recorded yet: the project's chat writes this down at the end of a session that changed something.`})}),(0,I.jsx)(sx,{scope:`project:${i.slug}`}),i.records.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`systems of record`,children:i.records.map((e,t)=>(0,I.jsx)(mt,{onClick:()=>e.url&&window.open(e.url,`_blank`,`noopener`),leading:(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}),title:e.title||e.kind,sub:e.note},t))})]})}if(e.kind===`agent`)return(0,I.jsx)(lx,{agent:e.agent,journal:e.journal,waiting:t,status:r});if(e.kind===`channel`){let i=e.channel;return(0,I.jsxs)(`div`,{className:$b,children:[(0,I.jsx)(`p`,{className:ex,children:i.purpose||(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[`A group chat with `,i.members.length,` agent`,i.members.length===1?``:`s`,`.`]})}),(0,I.jsx)(ax,{items:Rt.channel(t,i.slug)}),(0,I.jsx)(ox,{slugs:i.members,agents:n,status:r,title:`in this channel`})]})}return(0,I.jsx)(ux,{waiting:t,agents:n,status:r})}function lx({agent:e,journal:t,waiting:n,status:r}){let i=N(`projects.list`,{},{interval:3e4})?.projects??[],a=N(`agents.routines`,{slug:e.slug},{interval:3e4})?.routines??[],[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=Ib(r?.[e.slug],e.description),l=i.filter(t=>t.agents.includes(e.slug));return(0,I.jsxs)(`div`,{className:$b,children:[(0,I.jsx)(`p`,{className:ex,children:e.description||(0,I.jsx)(`span`,{className:`text-fg-2`,children:`No description yet.`})}),c&&c.text!==e.description&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 text-sm ${c.tone===`waiting`?`text-bad`:c.tone===`working`?`text-accent`:`text-fg-2`}`,children:c.text}),(0,I.jsx)(ax,{items:Rt.agent(n,e.slug)}),l.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`works on`,children:l.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(e.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:e.title,sub:e.goal||void 0},e.slug))}),a.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`schedule`,children:a.map(e=>(0,I.jsx)(mt,{leading:(0,I.jsx)(R,{name:`schedule`,className:`ms-sm`}),title:e.name,sub:`${e.enabled?e.nextRunAt?`next ${new Date(e.nextRunAt).toLocaleString([],{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}`:e.schedule:`paused`}${e.lastRunAt?` · last ${W(e.lastRunAt)}`:``}`},e.id))}),(0,I.jsxs)(rt,{size:`lg`,title:`journal`,children:[(0,I.jsx)(dx,{slug:e.slug,onAdded:s}),(0,I.jsx)(`div`,{className:nx,dangerouslySetInnerHTML:{__html:rx(Qb(o)||`_Nothing yet: the agent notes what it learns, decides and promises here, and reads it back at the start of every session._`)}})]})]})}function ux({waiting:e,agents:t,status:n}){let r=N(`projects.list`,{},{interval:3e4}),i=(r?.projects??[]).filter(e=>e.status===`active`);return(0,I.jsxs)(`div`,{className:$b,children:[(0,I.jsx)(ax,{items:e}),r?.enabled&&(0,I.jsxs)(rt,{size:`lg`,title:`projects`,count:i.length,children:[i.length===0&&(0,I.jsx)(`p`,{className:tx,children:`No active projects.`}),i.map(t=>{let n=Rt.project(e,t.slug,t.agents).length;return(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(t.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:t.title,sub:n?`${n} waiting for you`:t.goal||`no goal yet`,subTone:n?`bad`:`plain`},t.slug)})]}),(0,I.jsx)(ox,{slugs:t.filter(e=>!e.archived).map(e=>e.slug),agents:t,status:n,title:`agents`}),(0,I.jsx)(sx,{scope:`workspace`})]})}function dx({slug:e,onAdded:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{if(!n.trim())return;a(!0),s(``);let i=await A.request(`agents.addJournal`,{slug:e,body:{entry:n,kind:`note`}}).then(e=>e.ok?{error:void 0,journal:e.data?.journal}:{error:M(e),journal:void 0}).catch(e=>({error:e.message,journal:void 0}));if(a(!1),i.error||i.journal===void 0)return s(i.error??`could not save`);r(``),t(i.journal)};return(0,I.jsxs)(`div`,{className:`px-2.5 pb-1.5 pt-0.5`,children:[(0,I.jsx)(Z,{className:`h-8 text-sm`,value:n,placeholder:`add a note for the agent to remember`,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&void c(),disabled:i}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})}var fx=[{id:`contacts`,icon:`person`},{id:`places`,icon:`location_on`},{id:`events`,icon:`event`}];function px(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}function mx(e){let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(new Date))/864e5);return i===0?`today ${n}`:i===1?`tomorrow ${n}`:i>1&&i<7?`${t.toLocaleDateString([],{weekday:`short`})} ${n}`:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})} ${n}`}var hx=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function gx({chatPath:e,workspace:t}){let n=px(e),r=e.split(`/`).filter(Boolean),i=r[0]===`agents`&&r[1]===`chats`,a=r[0]===`agents`&&n.kind===`agent`,o=(r[0]===`projects`||a)&&r[2]===`chat`&&r[3]&&r[3]!==`new`?r[3]:i&&r[2]&&r[2]!==`new`?r[2]:void 0,s=n.kind===`project`?`/projects/${encodeURIComponent(n.slug)}`:a?`/agents/${encodeURIComponent(n.slug)}`:i?`/agents/chats`:void 0,c=`${n.kind}:${`slug`in n?n.slug:``}`,l=Te(),u=be(),[d,f]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:u?[`/settings`,`workspace settings`]:[void 0,``],p=N(`workflows.list`,{},{interval:15e3}),m=N(`runs.list`,{},{interval:6e3}),h=N(`routines.list`,{},{interval:3e4}),[g,_]=(0,v.useState)(null),y=N(`knowledge.list`,{},{interval:15e3}),b=N(`vibeables.list`,l.vibeables?{}:null,{interval:15e3}),x=N(`boards.list`,l.boards&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),S=n.kind===`project`?x?.boards??[]:[],C=N(`presentations.list`,l.presentations&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),w=n.kind===`project`?C?.presentations??[]:[],[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(0),[k,ee]=(0,v.useState)(()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`overview`}catch{return`overview`}}),[j,M]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>P(`browser`);return window.addEventListener(po,e),()=>window.removeEventListener(po,e)},[]);let P=e=>{ee(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}},[F,te]=(0,v.useState)({});(0,v.useEffect)(()=>te(H.current?{vibeables:`/vibeables/${encodeURIComponent(H.current.slug)}`}:{}),[c]);let[ne,re]=(0,v.useState)(!1);(0,v.useEffect)(()=>re(!1),[c]);let ie=z(),ae=n.kind===`project`?new URLSearchParams(ie.split(`?`)[1]??``).get(`app`):null;(0,v.useEffect)(()=>{ae&&(P(`vibeables`),te(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(ae)}`})),re(!0))},[ae,c]);let oe=e=>te(t=>({...t,[_e]:e})),[se,ce]=(0,v.useState)({dir:``});(0,v.useEffect)(()=>ce({dir:``}),[c]);let le=async(e,t,n)=>{(await A.request(`projects.link`,{slug:e,body:{kind:`vibeables`,target:t,remove:n}}).catch(()=>null))?.ok&&O(e=>e+1)},ue=()=>{re(!1),te(e=>({...e,[_e]:null}))},de=e=>t=>t.startsWith(e)?(te(e=>({...e,[_e]:t})),!0):!1,[B,V]=(0,v.useState)(null),H=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;H.current=t,V(t),t?(P(`vibeables`),te(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):te(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(ka,e),()=>window.removeEventListener(ka,e)},[]);let pe=l.repos&&!!T?.repos,me=n.kind===`project`?`project:${n.slug}`:T?.channel?.project?`project:${T.channel.project}`:`workspace`,ge=[{id:`overview`,label:`overview`},{id:`files`,label:`files`,allHref:`/files/${encodeURIComponent(me)}`},{id:`knowledge`,label:`knowledge`,count:T?.knowledge.length,allHref:`/knowledge`},...l.vibeables?[{id:`vibeables`,label:`apps`,count:T?.all?b?.vibeables.length:T?.vibeables?.length??0,allHref:`/vibeables`}]:[],{id:`workflows`,label:`workflows`,count:T?.workflows.length,allHref:`/workflows`},...l.boards&&n.kind===`project`?[{id:`board`,label:`boards`,count:S.reduce((e,t)=>e+t.review,0)||void 0,allHref:`/projects/${encodeURIComponent(n.slug)}/boards`}]:[],...l.presentations&&n.kind===`project`?[{id:`presentations`,label:`presentations`,count:w.length,allHref:`/projects/${encodeURIComponent(n.slug)}/presentations`}]:[],...u&&pe?[{id:`repos`,label:`repositories`,count:T?.repos?.length,allHref:`/repos`}]:[],...fx.filter(e=>l[e.id]&&T?.[e.id]).map(e=>({id:e.id,label:e.id,count:T?.[e.id]?.length,allHref:`/${e.id}`})),...j>0||k===`browser`?[{id:`browser`,label:`browser`,count:j}]:[]],_e=ge.some(e=>e.id===k)?k:`overview`,ve=ge.find(e=>e.id===_e),ye=F[_e]??null,xe=!!B&&_e===`vibeables`&&ye===`/vibeables/${encodeURIComponent(B.slug)}`,Se=_e===`vibeables`&&!!ye,Ce=ne&&Se,we=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),oe(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>O(e=>e+1),15e3);return()=>clearInterval(e)},[]);let Ee=fe(ie),De=(0,v.useRef)(Ee);(0,v.useEffect)(()=>{De.current&&!Ee&&O(e=>e+1),De.current=Ee},[Ee]),(0,v.useEffect)(()=>{let e=!0,r=new Set((p?.workflows??[]).map(e=>e.slug)),i=new Set((y?.bundles??[]).map(e=>e.name)),a=new Set((b?.vibeables??[]).map(e=>e.slug));return(async()=>{let o=null;if(n.kind===`agent`){let e=await A.call(`agents.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,agent:e,workflows:hx(e.workflows,r),knowledge:hx(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=hx(e.vibeables,a)),o.journal=(await A.call(`agents.journal`,{slug:n.slug}).catch(()=>null))?.journal??``)}else if(n.kind===`project`){let e=await A.call(`projects.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`📁 ${e.title}`,project:e,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,contacts:e.links.contacts,places:e.links.places,events:e.links.events,records:e.records,state:e.state,log:e.log,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await A.call(`channels.list`).catch(()=>null))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>A.call(`agents.get`,{slug:e}).catch(()=>null)))).filter(e=>!!e),s=e=>[...new Set(t.flatMap(e))],c=s(e=>e.vibeables??[]);o={title:`#${e.slug}`,channel:e,workflows:hx(s(e=>e.workflows),r),knowledge:hx(s(e=>e.knowledge),i),...c.length>0?{vibeables:hx(c,a)}:{},agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else o={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:hx([...r],r),knowledge:hx([...i],i),all:!0};e&&E(o)})(),()=>{e=!1}},[c,D,p,y,b,t.name,t.icon]);let Oe=e=>p?.workflows.find(t=>t.slug===e),ke=e=>e?m?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,Ae=e=>y?.bundles.find(t=>t.name===e),je=e=>b?.vibeables.find(t=>t.slug===e),Me=e=>(0,I.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[T?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,T?.editHref&&u&&!T.all&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(U,{href:T.editHref,className:`text-accent`,children:`Edit the links`}),`.`]})]});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`,children:[s?(0,I.jsx)(U,{href:s,className:`project-home-link min-w-0 truncate rounded-control text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg no-underline animate-fade hover:text-accent max-[800px]:text-lg`,title:`${T?.title??``} · all sessions`,children:T?T.title:`…`},T?.title??``):(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg animate-fade max-[800px]:text-lg`,title:T?.title,children:T?T.title:`…`},T?.title??``),d&&(0,I.jsx)(U,{href:d,className:`ctx-edit inline-grid size-7 flex-none place-items-center rounded-full text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-accent active:scale-96 [&_.ms]:text-[18px]`,title:f,"aria-label":f,children:(0,I.jsx)(R,{name:`edit`,className:`ms-sm`})}),o&&s&&(0,I.jsx)(eo,{id:o,fallbackTitle:i||a?`new chat`:`new session`,backHref:s},o)]}),(0,I.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,"data-full":Ce||void 0,children:[(0,I.jsx)(ht,{className:`flex-none gap-y-0.5 pt-2`,label:`Categories`,items:ge,value:_e,onChange:P}),ye&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2`,children:[(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`arrow_back`,onClick:ue,"aria-label":`Back to the list`,children:ve?.label}),(0,I.jsx)(`span`,{className:`flex-1`}),Se&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:Ce?`close_fullscreen`:`open_in_full`,onClick:()=>re(!Ce),title:Ce?`back beside the chat`:`full size, in place of the chat`,children:Ce?`beside the chat`:`full size`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:ye,title:`Open as a page`,children:`page`})]}),ye&&_e===`knowledge`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(he.Provider,{value:de(`/knowledge/`),children:(()=>{let e=ye.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,I.jsx)(kv,{name:t,conceptId:n},t)})()})}),ye&&_e===`workflows`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(he.Provider,{value:de(`/workflows/`),children:(()=>{let e=ye.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,I.jsx)(qc,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),ye&&_e===`vibeables`&&!xe&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,I.jsx)(Na,{slug:decodeURIComponent(ye.split(`/`).filter(Boolean)[1]??``)},ye)}),(0,I.jsx)(`div`,{id:Aa,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!xe}),(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:_e!==`browser`,children:(0,I.jsx)(bo,{storeKey:c,onTabs:M},c)}),(0,I.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:_e===`browser`||!!ye&&[`knowledge`,`workflows`,`vibeables`].includes(_e),children:[ve?.allHref&&(0,I.jsx)(`div`,{className:`flex justify-end px-1 pb-1`,children:(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,href:ve.allHref,children:[`all `,ve.label,` `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]})}),_e===`workflows`&&(0,I.jsxs)(I.Fragment,{children:[T&&T.workflows.length===0&&Me(`workflows`),T?.workflows.map(({slug:e,found:t})=>{let n=Oe(e),r=ke(n),i=t&&!!n&&!n.error,a=(h?.routines??[]).filter(t=>t.workflows.includes(e));return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(mt,{href:`/workflows/${encodeURIComponent(e)}`,onClick:t?we(`/workflows/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)($e,{tone:!t||n?.error?`bad`:vx(r?.status)}),title:n?.name??e,sub:t?n?.error?`broken`:r?`${r.status} · ${W(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`,actionsAlways:!0,actions:i?(0,I.jsx)(K,{size:`sm`,icon:g===e?`close`:`play_arrow`,label:g===e?`close the launcher of ${n.name??e}`:`run ${n.name??e}`,"aria-expanded":g===e,onClick:()=>_(g===e?null:e)}):void 0}),a.map(e=>(0,I.jsxs)(U,{href:`/agents/${encodeURIComponent(e.agent.slug)}/info`,className:`routine-line flex min-w-0 items-center gap-1.5 pt-0.5 pb-2 pl-[46px] pr-3 text-xs text-fg-2 no-underline hover:text-fg`,title:`${e.agent.name}'s routine "${e.name}" (${e.schedule}) runs this workflow: ${e.prompt}`,children:[(0,I.jsx)(R,{name:`schedule`,className:`ms-sm flex-none text-[14px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.agent.emoji,` `,e.agent.name,` · `,e.name,` · `,e.enabled?e.nextRunAt?`next ${mx(e.nextRunAt)}`:e.schedule:`paused`]})]},`${e.agent.slug}/${e.id}`)),g===e&&n&&(0,I.jsx)(`div`,{className:`mx-1 mb-2 rounded-card border border-line bg-surface [&>div]:px-3 [&>div]:pt-3`,children:(0,I.jsx)(Ic,{slug:e,usesRequest:n.usesRequest,onLaunched:()=>{_(null),oe(`/workflows/${encodeURIComponent(e)}`)}})})]},e)})]}),_e===`knowledge`&&(0,I.jsxs)(I.Fragment,{children:[T&&T.knowledge.length===0&&Me(`knowledge`),T?.knowledge.map(({slug:e,found:t})=>{let n=Ae(e);return(0,I.jsx)(mt,{href:`/knowledge/${encodeURIComponent(e)}`,onClick:t?we(`/knowledge/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(R,{name:`menu_book`,className:`ms-sm`}),title:e,sub:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${W(n.updatedAt)}`:``}`:void 0:`not in this workspace`},e)})]}),_e===`vibeables`&&T&&(0,I.jsxs)(I.Fragment,{children:[(T.all?(b?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):T.vibeables??[]).map(({slug:e,found:t})=>{let r=je(e);return(0,I.jsx)(mt,{href:`/vibeables/${encodeURIComponent(e)}`,onClick:t?we(`/vibeables/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(R,{name:`web`,className:`ms-sm`}),title:e,sub:t?r?.updatedAt?`changed ${W(r.updatedAt)}`:void 0:`not in this workspace`,actions:n.kind===`project`?(0,I.jsx)(K,{icon:`keep_off`,size:`sm`,label:`unpin ${e}`,onClick:()=>void le(n.slug,e,!0)}):void 0},e)}),n.kind===`project`&&b&&(0,I.jsx)(_x,{options:b.vibeables.map(e=>e.slug).filter(e=>!T.vibeables?.some(t=>t.slug===e)),onPin:e=>void le(n.slug,e,!1)}),T.all&&b&&b.vibeables.length===0&&Me(`vibeables`),!T.all&&T.vibeables?.length===0&&Me(`vibeables`)]}),fx.map(e=>_e===e.id&&T?.[e.id]&&(0,I.jsxs)(v.Fragment,{children:[T[e.id].length===0&&Me(e.id),T[e.id].map(({slug:t,found:n,label:r})=>(0,I.jsx)(mt,{href:`/${e.id}/${encodeURIComponent(t)}`,dim:!n,leading:(0,I.jsx)(R,{name:e.icon,className:`ms-sm`}),title:n&&r?r:t,sub:n?r?t:void 0:`not in this workspace`},t))]},e.id)),_e===`board`&&n.kind===`project`&&(0,I.jsxs)(I.Fragment,{children:[x&&x.enabled&&S.length===0&&(0,I.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[`No board yet. `,(0,I.jsx)(U,{href:`/projects/${encodeURIComponent(n.slug)}/boards`,className:`text-accent`,children:`Open the tasks board`}),` — it is created on first use.`]}),x&&!x.enabled&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:x.error}),S.map(e=>(0,I.jsx)(du,{project:n.slug,board:e.board},e.board))]}),_e===`presentations`&&n.kind===`project`&&(0,I.jsxs)(I.Fragment,{children:[C&&!C.enabled&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:C.error}),C?.enabled&&w.length===0&&Me(`presentations`),w.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(n.slug)}/presentations/${encodeURIComponent(e.name)}`,innerProps:{"data-deck":e.name},leading:(0,I.jsx)(R,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`}${e.updatedAt?` · ${W(e.updatedAt)}`:``}`,subTone:e.error?`bad`:`plain`},e.name)),C?.enabled&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`add`,className:`justify-start`,href:`/projects/${encodeURIComponent(n.slug)}/presentations/new`,children:`new presentation`})]}),_e===`repos`&&T?.repos&&(0,I.jsxs)(I.Fragment,{children:[T.repos.length===0&&Me(`repositories`),T.repos.map(({slug:e,found:t})=>(0,I.jsx)(mt,{href:`/repos/${encodeURIComponent(e)}`,dim:!t,leading:(0,I.jsx)(R,{name:`source`,className:`ms-sm`}),title:e,sub:t?void 0:`not in this workspace`},e))]}),_e===`overview`&&T&&(0,I.jsx)(cx,{of:T.project?{kind:`project`,project:T.project}:T.agent?{kind:`agent`,agent:T.agent,journal:T.journal??``}:T.channel?{kind:`channel`,channel:T.channel}:{kind:`workspace`}},c),_e===`files`&&(0,I.jsx)(Nl,{compact:!0,scope:me,dir:se.dir,file:se.file,onOpen:(e,t)=>ce({dir:e,file:t})},me)]},_e)]})]})}function _x({options:e,onPin:t}){return e.length===0?null:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-fg-2`,children:[(0,I.jsx)(R,{name:`keep`,className:`ms-sm`}),(0,I.jsxs)(bt,{className:`h-8 text-sm`,value:``,onChange:e=>e.target.value&&t(e.target.value),"aria-label":`pin an app to this project`,children:[(0,I.jsx)(`option`,{value:``,children:`pin an app to this project…`}),e.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]})]})}function vx(e){return e===`ok`?`ok`:e===`failed`?`bad`:e===`running`?`working`:`idle`}var yx=`kw-chat-path`,bx=`kw-ctx-w`,xx=()=>{try{let e=Number(localStorage.getItem(bx));return e>0?e:null}catch{return null}};function Sx({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,I.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for half and half`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var Cx=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},wx=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function Tx(){let e=z();Jt();let[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=ue(t),y=de(t),b=le.has(n[0]??``)&&!_&&!y,x=n.length===0,S=n[0]===`artifacts`,C=x||S,[w,T]=(0,v.useState)(()=>Cx(yx,`/agents/chats`)),E=b?ec(t):null,D=b&&!E?t:w,[O,k]=(0,v.useState)(`chat`),[A,ee]=(0,v.useState)(xx),j=e=>{ee(e);try{e===null?localStorage.removeItem(bx):localStorage.setItem(bx,String(e))}catch{}};(0,v.useEffect)(()=>{k(e=>e===`side`?`chat`:e)},[e]),(0,v.useEffect)(()=>{b&&!ec(t)&&(T(t),wx(yx,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;B(t)===`chat`?(T(t),wx(yx,t)):window.location.replace(`#${t}`)};return window.addEventListener(V,e),()=>window.removeEventListener(V,e)},[]);let M=N(`meta.get`,{},{interval:3e4});(0,v.useEffect)(()=>{let e=M;e&&(i(e.workspaceName??``),o(e.workspaceIcon??``),c(e.workspaceColor??``),u(e.workspaceNamed!==!1),f(e.workspaceRootLabel??``),m(e.workspaceRoot??``),we({git:!!e.git,repos:!!e.repos,vibeables:!!e.vibeables,projects:!!e.projects,contacts:!!e.contacts,places:!!e.places,events:!!e.events,boards:!!e.boards,presentations:!!e.presentations}),g(Array.isArray(e.switcher)?e.switcher:[]))},[M]),(0,v.useEffect)(()=>{if(se(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let P=D.split(`/`).filter(Boolean),F=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=P[0]===`chats`?(0,I.jsx)($s,{seg:P}):P[0]===`projects`?(0,I.jsx)(ds,{seg:P.slice(1)}):P[0]===`channels`?(0,I.jsx)(Wa,{seg:P.slice(1)}):(0,I.jsx)($s,{seg:P.slice(1)});let ne=null;return _?ne=(0,I.jsx)(su,{seg:n.slice(3),project:decodeURIComponent(n[1])}):y?ne=(0,I.jsx)(L_,{seg:n.slice(3),project:decodeURIComponent(n[1])}):n[0]===`runs`&&n[1]?ne=(0,I.jsx)(uc,{id:n[1],workflow:F}):n[0]===`runs`?ne=(0,I.jsx)(Fx,{}):n[0]===`workflows`?ne=(0,I.jsx)(nl,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?ne=(0,I.jsx)(Ha,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?ne=(0,I.jsx)(Sv,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?ne=(0,I.jsx)(Xv,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?ne=(0,I.jsx)(Iy,{}):n[0]===`trash`?ne=(0,I.jsx)(Ry,{}):n[0]===`ui`?ne=(0,I.jsx)(zy,{}):n[0]===`files`?ne=(0,I.jsx)(jl,{scope:n[1]?decodeURIComponent(n[1]):`workspace`,dir:n.slice(2).map(decodeURIComponent).join(`/`),file:new URLSearchParams(e.split(`?`)[1]??``).get(`file`)??void 0}):n[0]===`workspaces`?ne=(0,I.jsx)(Uy,{}):n[0]===`git`?ne=(0,I.jsx)(tb,{}):n[0]===`repos`?ne=(0,I.jsx)(pb,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`contacts`||n[0]===`places`||n[0]===`events`?ne=(0,I.jsx)(hv,{kind:n[0],slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`boards`?ne=(0,I.jsx)(su,{seg:n.slice(1)}):n[0]===`presentations`&&(ne=(0,I.jsx)(L_,{seg:n.slice(1)})),(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?Le(De(s,t)):null;if(!n)delete e.dataset.wsAccent;else{for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``}},[s,p,r]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`topbar sticky top-0 z-10 flex h-[var(--topbar-h)] items-center gap-3.5 bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] max-[1520px]:gap-2.5 max-[800px]:gap-1.5 max-[800px]:px-3`,style:{"--ws-c":De(s,p||r)},children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-none items-center gap-2.5 max-[800px]:flex-[0_1_auto] max-[800px]:gap-1`,children:[(0,I.jsx)(`a`,{href:`#/`,className:`grid size-8 place-items-center rounded-full text-[15px] leading-none transition-shadow hover:shadow-[0_0_0_4px_color-mix(in_srgb,var(--ws-c,var(--text))_16%,transparent)]`,title:`Dashboard`,children:r?(0,I.jsx)(ze,{size:`sm`,icon:a,name:r,color:s,seed:p||r}):(0,I.jsx)(R,{name:`home`})}),r&&(0,I.jsx)(Px,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,I.jsx)(Xb,{path:t}),(0,I.jsx)(`span`,{className:`flex-[1_1_8px]`}),(0,I.jsx)(jb,{}),(0,I.jsx)(K,{icon:`settings`,label:`settings`,href:`/settings`,"aria-current":n[0]===`settings`?`page`:void 0}),(0,I.jsx)(Rx,{}),(0,I.jsx)(qt,{}),(0,I.jsx)(Vx,{}),(0,I.jsx)(Lx,{})]}),ne&&(0,I.jsx)(`main`,{className:`shell shell-global`,children:ne}),(0,I.jsxs)(`main`,{className:`shell three${C?` home`:``}`,"data-focus":O,hidden:!!ne,style:A?{"--ctx-w":`${A}px`}:void 0,children:[(0,I.jsx)(Gb,{chatPath:x?`/`:S?`/artifacts`:D}),(0,I.jsxs)(`section`,{className:`col-chat`,"aria-label":x?`Dashboard`:S?`Artifacts`:`Conversation`,children:[x?(0,I.jsx)(cl,{}):S?(0,I.jsx)(Wv,{}):te,(0,I.jsx)(Sx,{onResize:j})]}),S?(0,I.jsx)(Gv,{}):(0,I.jsx)(gx,{chatPath:C?`/`:D,workspace:{name:r,icon:a}}),E&&(0,I.jsx)(tc,{back:D,children:E})]}),!ne&&(0,I.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,I.jsxs)(`button`,{className:O===`side`?`active`:``,onClick:()=>k(`side`),children:[(0,I.jsx)(R,{name:`menu`}),` list`]}),(0,I.jsxs)(`button`,{className:O===`chat`?`active`:``,onClick:()=>k(`chat`),children:[(0,I.jsx)(R,{name:`forum`}),` chat`]}),(0,I.jsxs)(`button`,{className:O===`context`?`active`:``,onClick:()=>k(`context`),children:[(0,I.jsx)(R,{name:`account_tree`}),` context`]})]})]})}function Ex(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}var Dx=`truncate text-sm text-fg-2 group-aria-[current=true]/ws:text-on-accent-soft group-aria-[current=true]/ws:opacity-80`,Ox=`group/ws relative flex min-h-[60px] items-center gap-3.5 px-4 py-2.5 text-fg no-underline transition-colors`;function kx({label:e}){return e?(0,I.jsx)(`span`,{className:P(Dx,`[direction:rtl] text-left`),title:e,children:(0,I.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})}):null}function Ax({name:e,named:t}){let n=t===!1;return(0,I.jsx)(`span`,{className:P(`truncate text-md tracking-[0.2px]`,n&&`italic text-fg-2`,`group-data-[missing]/ws:line-through group-data-[stopped]/ws:text-fg-2`),title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function jx({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await me(e.root))}catch(e){r(`error`),a(e.message)}};return(0,I.jsxs)(`span`,{className:P(Ox,`cursor-default`),role:`menuitem`,"data-stopped":``,"data-missing":o?``:void 0,style:{"--ws-c":De(e.color,e.root??e.url)},children:[(0,I.jsx)(ze,{className:`opacity-60 grayscale-50`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(Ax,{name:e.name,named:e.named}),n===`error`?(0,I.jsx)(`span`,{className:P(Dx,`text-bad`),title:i,children:i}):o?(0,I.jsx)(`span`,{className:Dx,children:`folder missing`}):(0,I.jsx)(kx,{label:e.rootLabel})]}),(0,I.jsxs)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:[(0,I.jsx)(Mx,{entry:e}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`play_arrow`,busy:n===`starting`,className:`text-accent hover:text-accent`,disabled:o,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:n===`starting`?`starting`:`start`})]})]})}function Mx({entry:e}){return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-2xs font-medium tracking-[0.5px] text-fg-2`,children:[e.live&&(0,I.jsx)($e,{tone:`ok`,title:`running`}),!e.here&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:Ex(e.url)})]})}function Nx({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,I.jsxs)(`a`,{className:P(Ox,`hover:bg-surface-2 active:bg-surface-2`),role:`menuitem`,href:pe(e),style:{"--ws-c":De(e.color,n)},children:[(0,I.jsx)(ze,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(Ax,{name:e.name,named:e.named}),(0,I.jsx)(kx,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,I.jsx)(Mx,{entry:e})})]})}function Px({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=be();(0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`[data-switcher]`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]);let u=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&u.set(e,(u.get(e)??0)+1);let d=e=>!!e&&(u.get(e)??0)>1,f=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),p=a||e;return(0,I.jsxs)(`span`,{className:`relative inline-flex min-w-0`,"data-switcher":``,children:[(0,I.jsxs)(`button`,{type:`button`,className:`env-switch inline-flex max-w-[220px] min-w-0 cursor-pointer items-center gap-[5px] rounded-xl border-0 bg-transparent px-2 py-1 font-[inherit] text-[15px] font-bold tracking-[0.02em] whitespace-nowrap text-fg transition-colors hover:bg-surface-2 max-[1520px]:max-w-[250px]`,title:i?`${i} — workspace menu`:`Workspace menu`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,I.jsx)(R,{name:`expand_more`,className:`flex-none opacity-55`})]}),s&&(0,I.jsxs)(`div`,{className:`absolute top-[calc(100%+8px)] left-0 z-20 max-h-[calc(100dvh-120px)] max-w-[min(480px,92vw)] min-w-[360px] max-[800px]:fixed max-[800px]:inset-x-2 max-[800px]:top-[calc(var(--topbar-h)-4px)] max-[800px]:max-w-none max-[800px]:min-w-0 overflow-y-auto overscroll-contain rounded-card border border-line bg-surface py-2 shadow-pop`,role:`menu`,children:[o.length>0&&(0,I.jsx)(nt,{className:`block px-4 pt-1 pb-2`,children:`workspaces`}),(0,I.jsxs)(`span`,{className:P(Ox,`cursor-default bg-accent-soft text-on-accent-soft`),"aria-current":`true`,style:{"--ws-c":De(n,p)},children:[(0,I.jsx)(ze,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(Ax,{name:e,named:r}),i?(0,I.jsx)(kx,{label:i}):(0,I.jsx)(`span`,{className:Dx,children:`this workspace`})]}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,I.jsx)(R,{name:`check`,className:`text-[24px] text-on-accent-soft`})})]}),f.map(e=>(0,I.jsxs)(`div`,{className:`mt-2 border-t border-line pt-1`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(nt,{className:`block px-4 pt-2 pb-1`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,I.jsx)(jx,{entry:e,ambiguous:d(e.icon)},e.root):(0,I.jsx)(Nx,{entry:e,ambiguous:d(e.icon)},e.root??e.url))]},e.key)),l&&o.length>0&&(0,I.jsxs)(`a`,{className:`mt-2 flex min-h-12 items-center gap-4 border-t border-line px-4 text-md text-fg no-underline transition-colors hover:bg-surface-2`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,I.jsx)(R,{name:`hub`,className:`text-[22px] text-fg-2`}),` manage workspaces`]}),(0,I.jsx)(Wx,{onClose:()=>c(!1)})]})]})}function Fx(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return A.call(`runs.list`).then(n=>{e&&(n.runs.length>0?H(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,I.jsxs)(Y,{icon:`play_circle`,children:[`No runs found in `,(0,I.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,I.jsx)(`a`,{href:`#/workflows`,className:`text-accent`,children:`workflows`}),` list or with `,(0,I.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,I.jsx)(Y,{children:`loading…`})}async function Ix(e){await A.request(`server.restart`).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await A.call(`meta.get`)).version===e)break}catch{}}location.reload()}function Lx(){let e=N(`meta.get`,{},{interval:3e4}),[t,n]=(0,v.useState)(!1),r=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function i(){r&&(n(!0),await Ix(r))}return!r&&!t?null:(0,I.jsx)(`button`,{type:`button`,className:`mr-2.5 inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-accent bg-accent/10 px-3 py-1 font-[inherit] text-xs text-accent hover:bg-accent/18 disabled:cursor-default disabled:opacity-70`,disabled:t,title:`v${r} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void i(),children:t?`relaunching…`:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(R,{name:`restart_alt`,className:`ms-sm`}),` v`,r,` ready — relaunch`]})})}function Rx(){let e=be();return(0,I.jsxs)(`button`,{type:`button`,className:P(`expert-toggle inline-flex cursor-pointer items-center gap-[7px] rounded-full border-0 bg-transparent px-2 py-1 font-mono text-2xs tracking-[0.5px] transition-colors hover:text-fg`,e?`text-fg`:`text-fg-2`),title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>ye(!e),children:[(0,I.jsx)(`span`,{className:P(`relative h-[15px] w-[26px] rounded-full transition-colors`,e?`bg-accent`:`bg-fg/14`),children:(0,I.jsx)(`span`,{className:P(`absolute top-0.5 size-[11px] rounded-full transition-[left,background-color]`,e?`left-[13px] bg-on-accent`:`left-0.5 bg-surface`)})}),(0,I.jsx)(`span`,{className:`max-[640px]:hidden`,children:`expert`})]})}var zx={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`,task_woken:`view_kanban`,task_wake_failed:`view_kanban`},Bx=`kw.notif.toast.dismissed`;function Vx(){let[e,t]=(0,v.useState)(!1),n=N(`notifications.list`,{},{interval:5e3}),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(Bx)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=(c??n)?.items??[],p=Lt()??[],m=new Set(p.map(e=>e.notificationId).filter(Boolean)),h=f.filter(e=>e.kind!==`approval`&&!m.has(e.id)),g=h.filter(e=>!e.readAt).length,_=p.length;(0,v.useEffect)(()=>oe(p.length),[p.length]),(0,v.useEffect)(()=>{if(n){if(!s.current)s.current=new Set(f.map(e=>e.id));else for(let e of f)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),S(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`[data-bell]`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function y(e){try{let t=await e;if(!t.ok)return;let n=t.data;l(`items`in n?n:{items:[],unread:0})}catch{}}let b=e=>y(A.request(`notifications.read`,{body:{ids:e}})),x=()=>y(A.request(`notifications.clear`));function S(e){t(!1),e.readAt||b([e.id]),H(e.href)}async function C(e){d(e.id);try{let n=await A.request(`notifications.diagnose`,{id:e.id});n.ok?(t(!1),H(n.data.href)):n.error&&alert(n.error)}catch{}d(null)}async function w(){typeof Notification<`u`&&i(await Notification.requestPermission())}function T(){o(!0);try{localStorage.setItem(Bx,`1`)}catch{}}let E=r==="default"&&!a;return(0,I.jsxs)(`span`,{className:`relative inline-flex`,"data-bell":``,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(`relative grid size-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent transition-colors hover:bg-surface-2 hover:text-fg`,_?`text-fg`:`text-fg-2`),title:_?`${_} thing${_===1?``:`s`} waiting for you`:g?`${g} update${g===1?``:`s`}`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,I.jsx)(R,{name:_?`notifications_active`:`notifications`}),g>0&&(0,I.jsx)(`span`,{className:`absolute top-1.5 right-1.5 size-[7px] rounded-full bg-accent`})]}),e&&(0,I.jsxs)(`div`,{className:`notif-pop absolute right-0 top-[calc(100%+8px)] z-50 flex max-h-[min(80dvh,640px)] w-[min(460px,92vw)] flex-col overflow-hidden rounded-card border border-line bg-surface shadow-pop`,role:`menu`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-line px-4 py-2`,children:[(0,I.jsx)(nt,{className:`text-fg`,children:`notifications`}),(0,I.jsx)(`span`,{className:`flex-1`}),g>0&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:()=>void b(h.filter(e=>!e.readAt).map(e=>e.id)),children:`mark updates read`}),f.length>0&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:()=>void x(),children:`clear`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain pb-1.5`,children:[E&&(0,I.jsxs)(`div`,{className:`m-2 flex flex-col gap-2 rounded-control bg-surface-2 p-3 text-sm`,children:[(0,I.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,I.jsxs)(`span`,{className:`flex gap-2`,children:[(0,I.jsx)(G,{variant:`primary`,size:`sm`,onClick:()=>void w(),children:`enable`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:T,children:`not now`})]})]}),r===`denied`&&(0,I.jsx)(`p`,{className:`m-0 px-4 pt-2 text-xs text-fg-2`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),(0,I.jsx)(rt,{title:`needs you`,count:p.length||void 0,className:`px-1.5 pt-1.5`,children:p.length===0?(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`nothing is waiting for you`}):Ux(p).map(([e,n])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`notif-owner px-2.5 pb-0.5 pt-2 text-xs font-semibold text-fg`,children:e}),n.map(e=>{let n=e.notificationId?f.find(t=>t.id===e.notificationId):void 0;return(0,I.jsx)(mt,{className:`notif-row need`,onClick:()=>{t(!1),Gt(e)},leading:(0,I.jsx)(R,{name:zt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${Bt(e.kind)}${e.chatTitle?` · in ${e.chatTitle}`:``}`,meta:W(e.since),actionsAlways:!0,actions:n?.diagnose?(0,I.jsx)(Hx,{busy:u===n.id,onClick:()=>void C(n)}):void 0},e.id)})]},e))}),(0,I.jsx)(rt,{title:`updates`,className:`px-1.5 pt-1.5`,children:h.length===0?(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`no updates`}):h.slice(0,50).map(e=>(0,I.jsx)(mt,{className:P(`notif-row`,!e.readAt&&`bg-accent/5`),onClick:()=>S(e),leading:(0,I.jsx)(R,{name:zx[e.kind],className:P(`ms-sm`,e.kind.endsWith(`failed`)?`text-bad`:e.kind.endsWith(`done`)?`text-ok`:``)}),title:e.title,sub:e.body,meta:W(e.at),actionsAlways:!0,actions:e.diagnose?(0,I.jsx)(Hx,{busy:u===e.id,onClick:()=>void C(e)}):void 0},e.id))})]})]})]})}function Hx({busy:e,onClick:t}){return(0,I.jsx)(G,{variant:`secondary`,size:`sm`,icon:`troubleshoot`,busy:e,title:`Open a chat that finds the cause and proposes the fix`,onClick:e=>{e.stopPropagation(),t()},children:e?`starting…`:`diagnose`})}function Ux(e){let t=new Map;for(let n of e){let e=Vt(n.owner);t.set(e,[...t.get(e)??[],n])}return[...t.entries()]}function Wx({onClose:e}){let t=be(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``);return(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>s(e.version)).catch(()=>{}),t&&(A.call(`runs.list`).then(r).catch(()=>{}),A.call(`workflows.list`).then(a).catch(()=>{}))},[t]),(0,I.jsxs)(`div`,{className:`ws-menu mt-1.5 flex flex-col gap-0.5 border-t border-line px-1.5 pb-1 pt-2`,children:[(0,I.jsx)(Gx,{label:`Theme`,children:(0,I.jsx)(Xx,{})}),(0,I.jsx)(`div`,{className:`flex gap-1 px-1`,children:(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`delete`,href:`/trash`,onClick:e,children:`trash`})}),t&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(nt,{children:`Workflows`}),` `,i?`${i.workflows.length} discovered`:`…`,` `,(0,I.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:i?.root,children:i?.root??``})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(nt,{children:`Runs`}),` `,n?`${n.runs.length} total`:`…`,` `,(0,I.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:n?.outputDir,children:n?.outputDir??``})]})]}),(0,I.jsx)(Gx,{label:(0,I.jsx)(`span`,{className:`font-mono`,children:o?`kraftwerk ${o}`:`…`}),children:(0,I.jsx)(qx,{})})]})}function Gx({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm text-fg-2`,children:e}),t]})}function Kx(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function qx(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await A.call(`update.check`);if(!e.latest)throw Error();r(e),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await A.call(`update.status`);if(!e)return;a(t)}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await A.request(`update.start`,{body:{version:n.latest}});e.ok?a(e.data):s(e.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,I.jsxs)(`span`,{className:P(Jx,`basis-full flex-wrap`),children:[(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),` installing v`,n.latest,`…`,e&&(0,I.jsx)(`code`,{className:`max-w-full truncate text-2xs text-fg-2`,title:i.log.join(`
484
- `),children:e})]}):i.state===`done`?(0,I.jsxs)(`span`,{className:P(Jx,Yx),children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,I.jsx)(G,{size:`sm`,icon:`restart_alt`,busy:c,onClick:()=>{l(!0),Ix(n.latest)},children:c?`relaunching…`:`relaunch`}):(0,I.jsxs)(I.Fragment,{children:[`restart `,(0,I.jsx)(`code`,{children:`kraftwerk ui`}),` to use it`]})]}):(0,I.jsxs)(`span`,{className:P(Jx,`basis-full flex-wrap text-bad`),title:i.log.join(`
485
- `),children:[(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,I.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?Kx(n.current,n.latest)?(0,I.jsxs)(`span`,{className:P(Jx,Yx),children:[`v`,n.latest,` available —`,` `,o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`font-normal text-fg-2`,title:o,children:o}),` · `,(0,I.jsxs)(`code`,{className:`text-2xs`,children:[`npm i -g `,n.name,`@latest`]})]}):(0,I.jsx)(G,{size:`sm`,icon:`download`,onClick:()=>void f(),children:`update now`})]}):(0,I.jsxs)(`span`,{className:Jx,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm text-ok`}),` up to date`]}):(0,I.jsx)(G,{size:`sm`,icon:e===`busy`||e===`err`?void 0:`sync`,disabled:e===`busy`,onClick:()=>void u(),children:e===`busy`?`checking…`:e===`err`?`npm unreachable — retry`:`check for updates`})}var Jx=`inline-flex items-center gap-[5px] text-xs text-fg-2`,Yx=`basis-full flex-wrap font-medium text-accent`;function Xx(){return(0,I.jsx)(G,{size:`sm`,icon:`contrast`,onClick:()=>{let e=document.documentElement,t=e.dataset.theme===`light`?`dark`:`light`;e.dataset.theme=t;try{localStorage.setItem(`kw-theme`,t)}catch{}},children:`day / night`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(yy,{children:(0,I.jsx)(Tx,{})})}));export{o as a,d as i,te as n,s as o,h as r,l as s,Vl as t};
479
+ `]})]}):(0,I.jsx)(`div`,{className:Uv,children:`no textual diff (binary or empty)`})}var Uv=`git-diff mt-1.5 mb-0.5 max-h-[420px] basis-full overflow-auto rounded-xl bg-surface-2 px-3 py-2.5 font-mono text-[11.5px] leading-[1.5] whitespace-pre`,Wv={modified:`text-accent`,added:`text-ok`,untracked:`text-ok`,deleted:`text-bad`,conflicted:`text-bad`};function Gv({status:e,muted:t}){return(0,I.jsx)(`span`,{className:P(`flex-none rounded-full border border-line px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.4px] uppercase`,t?`text-fg-2`:Wv[e]??`text-fg-2`),children:e})}var Kv=`text-xs text-fg-2`,qv=`m-0 p-[18px] text-sm text-fg-2`;function Jv(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(new Set),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useRef)(!0),h=(0,v.useCallback)(async()=>{try{let e=await A.request(`git.status`,{query:{fresh:m.current}});m.current=!1,e.ok&&t(e.data)}catch{}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await h(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[h]),(0,v.useEffect)(()=>{if(!e?.files)return;let t=new Set(e.files.filter(e=>e.syncable).map(e=>e.path));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]);let g=async(e,t)=>{l(e),d(``),p(``);try{let n=await A.request(`git.${e}`,{body:t??{}});n.ok&&n.data.ok?p(e===`push`?`pushed`:e===`pull`?`pulled`:`fetched`):d(M(n)||`${e} failed`)}catch(t){d(t.message||`${e} failed`)}finally{l(``)}h()},_=async()=>{l(`commit`),d(``),p(``);try{let e=await A.request(`git.commit`,{body:{paths:[...n],message:o}});e.ok&&e.data.ok?(p(`committed ${n.size} file${n.size===1?``:`s`}`),r(new Set),s(``)):d(M(e)||`commit failed`)}catch(e){d(e.message||`commit failed`)}finally{l(``)}h()};if(!e)return(0,I.jsx)(Y,{children:`loading…`});if(!e.enabled)return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`cloud_sync`,title:`Git sync`}),(0,I.jsx)(X,{children:(0,I.jsxs)(`p`,{className:qv,children:[`Git sync is off. Turn it on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),`, or add a `,(0,I.jsx)(`code`,{children:`git:`}),` block to kraftwerk.yml.`]})})]});let y=(e.files??[]).filter(e=>e.syncable),b=(e.files??[]).filter(e=>!e.syncable),x=(e,t)=>r(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`cloud_sync`,title:`Git sync`,actions:(0,I.jsxs)(I.Fragment,{children:[f&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm text-ok`,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,I.jsx)(tt,{tone:`bad`,children:u})]})}),(0,I.jsx)(X,{title:`branch`,actions:(0,I.jsxs)(I.Fragment,{children:[e.lastFetch&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.lastFetch,children:[`fetched `,W(e.lastFetch)]}),e.lastError&&(0,I.jsxs)(`span`,{className:`inline-flex max-w-[46ch] items-center gap-1 truncate text-xs text-bad`,title:e.lastError,children:[(0,I.jsx)(R,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
480
+ `)[0]]})]}),children:e.error?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 p-[18px] text-sm text-bad`,children:[(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-[18px] py-3.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-base`,children:[(0,I.jsx)(R,{name:`account_tree`,className:`ms-sm`}),(0,I.jsx)(`strong`,{className:`font-mono`,children:e.branch}),(0,I.jsx)(`span`,{className:Kv,children:e.upstream?`tracking ${e.upstream}`:`no upstream yet, push sets one`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[12.5px] font-semibold`,children:[e.diverged&&(0,I.jsx)(`span`,{className:`text-bad`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,I.jsxs)(`span`,{className:`text-accent`,children:[e.behind,` behind`]}),!!e.ahead&&(0,I.jsxs)(`span`,{className:`text-ok`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,I.jsx)(`span`,{className:P(`text-xs text-fg-2`,`font-normal`),children:`up to date`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(G,{size:`sm`,icon:`refresh`,busy:c===`fetch`,disabled:!!c,onClick:()=>void g(`fetch`),children:`fetch`}),(0,I.jsx)(G,{size:`sm`,icon:`download`,busy:c===`pull`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void g(`pull`),children:`pull`}),(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`upload`,busy:c===`push`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void g(`push`),children:`push`})]})]})}),(0,I.jsxs)(X,{title:`changes`,actions:(0,I.jsx)(`span`,{className:Kv,children:y.length===0?`workspace clean`:`${n.size} of ${y.length} selected`}),children:[y.length===0&&b.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing changed under the workspace paths.`}),y.map(e=>(0,I.jsxs)(`div`,{className:P(`git-row px-[18px]`,Yv),children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,"aria-label":`select ${e.path}`,checked:n.has(e.path),onChange:t=>x(e.path,t.target.checked)}),(0,I.jsxs)(`button`,{type:`button`,className:`group/file flex min-w-0 flex-1 cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,I.jsx)(R,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Gv,{status:e.status}),(0,I.jsx)(`span`,{className:P(Xv,`group-hover/file:underline`),children:e.path})]}),i.has(e.path)&&(0,I.jsx)(Bv,{file:e.path})]},e.path)),y.length>0&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-t border-line bg-surface-2 px-[18px] py-3`,children:[(0,I.jsx)(Z,{className:`min-w-[220px] flex-1 text-sm`,placeholder:`Commit message`,"aria-label":`commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&_()}}),(0,I.jsx)(G,{size:`sm`,disabled:n.size===y.length,onClick:()=>r(new Set(y.map(e=>e.path))),children:`select all`}),(0,I.jsxs)(G,{size:`sm`,variant:`primary`,icon:`check`,busy:c===`commit`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void _(),children:[`commit `,n.size||``]})]}),b.length>0&&(0,I.jsxs)(`details`,{className:`border-t border-line px-[18px] py-2.5`,children:[(0,I.jsxs)(`summary`,{className:`cursor-pointer text-[12.5px] text-fg-2`,children:[b.length,e.blockedHidden?`+`:``,` change`,b.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),b.map(e=>(0,I.jsxs)(`div`,{className:P(`git-row blocked opacity-60`,Yv),children:[(0,I.jsx)(Gv,{status:e.status,muted:!0}),(0,I.jsx)(`span`,{className:Xv,children:e.path}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,I.jsx)(`div`,{className:P(`git-row blocked opacity-60`,Yv),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),(0,I.jsxs)(`p`,{className:P(Kv,`m-0`),children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&`, `,(0,I.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,I.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval?`Fetches every ${Lv(e.interval)}${e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,`Commit and push are always manual.`]})]})}var Yv=`flex flex-wrap items-center gap-2.5 py-2 [&+&]:border-t [&+&]:border-line`,Xv=`truncate font-mono text-[12.5px]`,Zv=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),Qv=e=>e.error?{label:`unreadable`,state:`unreadable`}:e.dirty?{label:`${e.dirty} changed`,state:`changed`}:e.ahead?{label:`${e.ahead} to push`,state:`clean`}:e.behind?{label:`${e.behind} behind`,state:`behind`}:{label:`clean`,state:`clean`};function $v({label:e,state:t}){return(0,I.jsx)(`span`,{className:P(`inline-flex items-center text-2xs font-semibold tracking-[0.4px] uppercase`,t===`clean`?`text-ok`:t===`changed`?`text-ask`:t===`unreadable`?`text-bad`:`text-fg-2`),children:e})}var ey=`rounded-full border border-line px-[7px] py-px font-mono text-xs text-fg-2`,ty=`border-line px-[18px] py-2 [&+&]:border-t`,ny=`group/item flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent px-0 py-0.5 text-left font-[inherit] text-fg`,ry=`min-w-0 truncate font-mono text-[12.5px] group-hover/item:underline`;function iy({title:e,embedded:t,children:n}){return(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[!t&&(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_back`,href:`/repos`,title:`all repositories`,children:`repositories`}),!t&&(0,I.jsx)(R,{name:`folder_data`,className:`text-[26px] text-fg-2`}),!t&&(0,I.jsx)(it,{children:e}),n]})}var ay=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function oy({slug:e}){return e?(0,I.jsx)(sy,{slug:e}):(0,I.jsx)(cy,{})}function sy({slug:e,embedded:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(0),g=be(),_=(0,v.useCallback)(async()=>{try{let t=await A.request(`repos.get`,{slug:e});if(!t.ok)throw Error(M(t));r(t.data),a(``)}catch(e){a(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await _(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[_,m]);let y=async()=>{d(`update`),p(``);try{let t=await A.request(`repos.update`,{slug:e});if(!t.ok||!t.data.ok)throw Error(t.error||`failed`);t.data.error&&p(t.data.error)}catch(e){p(e.message)}finally{d(``),h(e=>e+1)}};if(i&&!n)return(0,I.jsxs)(ot,{className:`repo-page`,children:[(0,I.jsx)(iy,{title:e,embedded:t}),(0,I.jsx)(tt,{tone:`bad`,children:i})]});if(!n)return(0,I.jsx)(Y,{children:`loading…`});let b=Qv(n),x=n.commits.filter(e=>e.local).length;return(0,I.jsxs)(ot,{className:`repo-page`,children:[(0,I.jsxs)(iy,{title:n.slug,embedded:t,children:[n.branch&&(0,I.jsx)(`span`,{className:ey,children:n.branch}),n.upstream&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:`upstream`,children:[`→ `,n.upstream]}),(0,I.jsx)($v,{...b}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{size:`sm`,icon:`sync`,busy:u===`update`,disabled:!!u,onClick:()=>void y(),title:`git fetch, then fast-forward when clean`,children:u===`update`?`updating…`:`update`})]}),(0,I.jsxs)(`div`,{className:P(Kv,`flex flex-wrap gap-x-3.5 gap-y-1`),children:[n.url&&(0,I.jsx)(`span`,{title:n.url,children:Zv(n.url)}),g&&(0,I.jsx)(`span`,{title:n.path,children:n.path}),n.head&&(0,I.jsxs)(`span`,{children:[`at `,(0,I.jsx)(`code`,{children:n.head}),n.committedAt?` · ${W(n.committedAt)}`:``]}),!!n.ahead&&(0,I.jsxs)(`span`,{children:[n.ahead,` to push`]}),!!n.behind&&(0,I.jsxs)(`span`,{children:[n.behind,` behind`]}),n.updatedAt&&(0,I.jsxs)(`span`,{children:[`changed `,W(n.updatedAt)]})]}),(n.error||f||i)&&(0,I.jsx)(tt,{tone:`bad`,children:n.error||f||i}),(0,I.jsxs)(X,{title:`changes · working tree against HEAD`,actions:(0,I.jsxs)(`span`,{className:Kv,children:[n.files.length,` file`,n.files.length===1?``:`s`,n.insertions||n.deletions?(0,I.jsxs)(I.Fragment,{children:[` · `,(0,I.jsxs)(`span`,{className:`text-ok`,children:[`+`,n.insertions]}),` `,(0,I.jsxs)(`span`,{className:`text-bad`,children:[`−`,n.deletions]})]}):null]}),children:[n.files.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Clean — nothing changed since the last commit.`}),n.files.map(t=>(0,I.jsxs)(`div`,{className:P(`repo-file`,ty),"data-file":t.path,children:[(0,I.jsxs)(`button`,{type:`button`,className:ny,onClick:()=>s(o===t.path?null:t.path),children:[(0,I.jsx)(R,{name:o===t.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Gv,{status:t.status}),(0,I.jsx)(`span`,{className:ry,children:t.path})]}),o===t.path&&(0,I.jsx)(Hv,{source:{route:`repos.diff`,input:{slug:e,query:{path:t.path}}},refresh:n.updatedAt})]},t.path))]}),(0,I.jsxs)(X,{title:`commits · newest first`,actions:(0,I.jsx)(`span`,{className:Kv,children:x?`${x} not pushed`:n.commits.length?`all pushed`:``}),children:[n.commits.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`No commits yet.`}),n.commits.map(t=>(0,I.jsxs)(`div`,{className:P(`repo-commit`,ty),"data-commit":t.short,children:[(0,I.jsxs)(`button`,{type:`button`,className:ny,onClick:()=>l(c===t.hash?null:t.hash),title:t.hash,children:[(0,I.jsx)(R,{name:c===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(`code`,{className:`text-xs`,children:t.short}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-sm group-hover/item:underline`,children:t.subject}),t.local&&(0,I.jsx)(q,{tone:`accent`,children:`not pushed`}),(0,I.jsxs)(`span`,{className:P(Kv,`ml-auto flex-none`),children:[t.author,` · `,W(t.committedAt)]})]}),c===t.hash&&(0,I.jsx)(Hv,{source:{route:`repos.commit`,input:{slug:e,hash:t.hash}}})]},t.hash))]})]})}function cy(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=be(),S=(0,v.useCallback)(async()=>{try{let e=await A.request(`repos.list`);if(!e.ok)throw Error(`HTTP ${e.status}`);t(e.data),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await S(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[S]);let C=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await A.request(`repos.update`,{slug:e}):await A.request(`repos.remove`,{slug:e,query:{force:n}});if(!r.ok||!r.data.ok)throw Error(r.error||`failed`);let i=r.data.error;i&&s(t=>({...t,[e]:i}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),S()}},w=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await A.request(`repos.add`,{body:{url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0}});if(!e.ok)throw Error(e.error||`clone failed`);d(``),p(``),h(``),await S()}catch(e){b(e.message)}finally{_(!1)}}},T=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:`source`,title:`Repositories`,actions:(0,I.jsxs)(I.Fragment,{children:[e?.enabled&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[T.length,` cloned`]}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}),e&&!e.enabled&&(0,I.jsx)(X,{children:(0,I.jsx)(`div`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:e.error&&!/are off/.test(e.error)?(0,I.jsx)(tt,{tone:`bad`,children:e.error}):(0,I.jsxs)(I.Fragment,{children:[`Repositories are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,I.jsx)(X,{title:`add a repository`,actions:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`clones into `,(0,I.jsx)(`code`,{title:e.root,children:e.root})]}),children:(0,I.jsxs)(`form`,{className:`flex flex-col gap-2.5 p-[18px]`,onSubmit:e=>void w(e),children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2.5`,children:[(0,I.jsx)(Q,{label:`url`,className:`min-w-[240px] flex-[2]`,children:(0,I.jsx)(Z,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-[140px] flex-1`,children:(0,I.jsx)(Z,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})}),(0,I.jsx)(Q,{label:`branch`,className:`w-[140px]`,children:(0,I.jsx)(Z,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})}),(0,I.jsx)(G,{type:`submit`,variant:`primary`,icon:`download`,busy:g,disabled:!u.trim(),children:g?`cloning…`:`clone`})]}),y&&(0,I.jsx)(tt,{tone:`bad`,children:y}),(0,I.jsxs)(`p`,{className:P(`text-xs text-fg-2`,`m-0`),children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,I.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})}),e?.enabled&&(0,I.jsxs)(X,{title:`cloned repositories · newest change first`,children:[T.length===0&&(0,I.jsx)(`p`,{className:`m-0 p-[18px] text-sm text-fg-2`,children:`Nothing cloned yet.`}),T.map(e=>{let t=i[e.slug],n=Qv(e);return(0,I.jsxs)(`div`,{className:P(`repo-row grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 border-line px-[18px] py-3.5 [&+&]:border-t`,n.state===`changed`&&`bg-ask-soft/40`),"data-repo":e.slug,children:[(0,I.jsx)(`span`,{className:P(`grid size-10 place-items-center rounded-full bg-surface-2 text-fg-2`,n.state===`unreadable`&&`opacity-45 grayscale`),children:(0,I.jsx)(R,{name:`folder_data`,className:`text-[22px]`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,I.jsx)(U,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`text-md font-semibold text-fg no-underline hover:underline`,title:`changes and commits`,children:e.slug}),e.branch&&(0,I.jsx)(`span`,{className:ey,children:e.branch}),(0,I.jsx)($v,{...n}),e.updatedAt&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,W(e.updatedAt)]})]}),e.url&&(0,I.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.url,children:Zv(e.url)}),x&&(0,I.jsx)(`div`,{className:`text-xs [overflow-wrap:anywhere] text-fg-2 opacity-70`,title:e.path,children:e.path}),(0,I.jsxs)(`div`,{className:P(`text-xs text-fg-2`,`flex flex-wrap gap-x-3.5 gap-y-1 [&_code]:text-[11.5px]`),children:[e.head&&(0,I.jsxs)(`span`,{title:e.committedAt,children:[(0,I.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${W(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,I.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,I.jsx)(`span`,{className:`text-bad`,children:e.error})]}),o[e.slug]&&(0,I.jsx)(tt,{tone:`bad`,children:o[e.slug]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,I.jsx)(G,{size:`sm`,icon:`difference`,href:`/repos/${encodeURIComponent(e.slug)}`,title:`changed files with diffs, recent commits`,children:`changes`}),(0,I.jsx)(G,{size:`sm`,icon:`sync`,busy:t===`update`,disabled:!!t,onClick:()=>void C(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:t===`update`?`updating…`:`update`}),c!==e.slug&&(0,I.jsx)(G,{size:`sm`,icon:`delete`,disabled:!!t,onClick:()=>l(e.slug),title:`Move the clone to the trash`,children:`remove`}),c===e.slug&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void C(e.slug,`remove`,ay(e)),children:e.dirty||e.ahead?`delete with local changes`:ay(e)?`delete anyway`:`confirm remove`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var ly={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function uy(e){return(0,I.jsx)(q,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:ly[e]})}function dy({name:e}){let t=N(`skills.list`,{}),n=t?.skills??[],r=n.filter(e=>e.source===`workspace`),i=n.filter(e=>e.source!==`workspace`),a=r[0]??i[0];(0,v.useEffect)(()=>{!e&&a&&H(`/skills/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]);let o=t=>(0,I.jsx)(mt,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)($e,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&uy(t.source),sub:t.description||`no description`},`${t.source}:${t.name}`);return(0,I.jsxs)(`div`,{className:`runs-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Et,{title:`workspace skills`}),(0,I.jsxs)(Ot,{children:[r.map(o),t&&r.length===0&&(0,I.jsx)(kt,{children:`no workspace skills yet`}),i.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Et,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(py,{name:e},e):t&&!a?(0,I.jsx)(fy,{root:t.root}):(0,I.jsx)(Y,{children:`loading…`})})]})}function fy({root:e}){return(0,I.jsx)(`div`,{className:`empty-action py-6`,children:(0,I.jsxs)(Y,{icon:`extension`,children:[`Create `,(0,I.jsxs)(`code`,{children:[e,`/<name>/SKILL.md`]}),` and it appears here and in every session's `,(0,I.jsx)(`code`,{children:`/`}),` menu.`]})})}function py({name:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(`rendered`),s=(0,v.useMemo)(()=>t?t.content.replace(/^---\r?\n[\s\S]*?\r?\n---(\r?\n|$)/,``):``,[t?.content]),c=(0,v.useMemo)(()=>t?Da.sanitize(Jr.parse(s,{async:!1})):``,[s]);return(0,v.useEffect)(()=>{A.call(`skills.get`,{name:e}).then(n,()=>i(!0))},[e]),r?(0,I.jsx)(Y,{icon:`extension`,children:`skill not found`}):t?(0,I.jsxs)(`div`,{className:`agent-view flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,I.jsxs)(it,{size:`lg`,children:[`/`,t.name]}),uy(t.source)]}),t.description&&(0,I.jsx)(`p`,{className:`-mt-2 mb-0 mx-0.5 text-sm leading-[1.6] text-fg-2`,children:t.description}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 max-[1020px]:grid-cols-1`,children:[(0,I.jsx)(X,{className:`min-w-0`,title:`SKILL.md`,actions:(0,I.jsx)(ht,{bare:!0,label:`SKILL.md view`,value:a,onChange:o,items:[{id:`rendered`,label:`rendered`},{id:`source`,label:`source`}]}),children:a===`rendered`?(0,I.jsx)(`div`,{className:`md-body h-auto overflow-visible [&_a]:text-accent [&_a]:underline [&_a]:underline-offset-2`,dangerouslySetInnerHTML:{__html:c}}):(0,I.jsx)(`pre`,{className:`m-0 max-h-[560px] overflow-auto px-[18px] py-3.5 font-mono text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,children:t.content.trim()||`(empty)`})}),(0,I.jsx)(`aside`,{className:`flex min-w-0 flex-col gap-4`,children:(0,I.jsx)(X,{title:`about`,children:(0,I.jsxs)(ft,{children:[(0,I.jsx)(pt,{label:`source`,children:t.source===`workspace`?`workspace — git-tracked, shared with the team`:t.source===`project`?`repo .claude/skills — tracked, but outside the workspace root`:`global ~/.claude/skills — only on this machine`}),(0,I.jsx)(pt,{label:`path`,mono:!0,children:(0,I.jsx)(`span`,{title:t.path,children:t.path})}),(0,I.jsx)(pt,{label:`invoke`,children:(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`code`,{children:[`/`,t.name]}),` in any session`]})}),t.files.length>0&&(0,I.jsx)(pt,{label:`bundled files`,mono:!0,children:t.files.map(e=>(0,I.jsx)(`span`,{className:`block w-full`,children:e},e))})]})})})]})]}):(0,I.jsx)(Y,{children:`loading…`})}var my=e=>e.agent?`${e.agent.emoji?`${e.agent.emoji} `:``}${e.agent.name}`:e.project?`🧭 Assistant`:`🎩 Ralv`,hy=e=>e.enabled?e.nextRunAt?`next ${Ge(e.nextRunAt)}`:e.runner===`unassigned`?`no runner`:e.runner===`elsewhere`?`runs on ${e.runsOn}`:e.schedule:`paused`,gy=(e,t)=>e.project?`/projects/${encodeURIComponent(e.project)}/chat/${t}`:e.agent?`/agents/${encodeURIComponent(e.agent.slug)}/chat/${t}`:`/agents/chats/${t}`,_y={name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0,project:``,agent:``,private:!1},vy=e=>({id:e.id,name:e.name,schedule:e.schedule,prompt:e.prompt,enabled:e.enabled,project:e.project??``,agent:e.agent?.slug??``,runsOn:e.runsOn??``,private:e.private??!1});function yy({r:e,error:t}){return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-2`,children:[(0,I.jsx)(`code`,{children:e.schedule}),(0,I.jsxs)(`span`,{children:[`· `,hy(e)]}),e.runner===`here`?(0,I.jsx)(q,{title:`runs_on: ${e.runsOn} — this machine fires it`,children:`runs here`}):e.runner===`unassigned`?(0,I.jsx)(q,{tone:e.enabled?`ask`:`neutral`,title:`no runs_on — it fires on no machine until one adopts it`,children:`no runner`}):(0,I.jsxs)(q,{tone:e.retired?`ask`:`neutral`,title:e.retired?`a retired identity of this machine — it fires nowhere until reassigned`:`another machine fires it, not this one`,children:[`runs on `,e.runsOn]}),e.lastChatId?(0,I.jsxs)(U,{href:gy(e,e.lastChatId),children:[`last run `,Ge(e.lastRunAt)]}):(0,I.jsx)(`span`,{children:`never ran`}),e.awaitingApproval&&e.lastChatId&&(0,I.jsx)(q,{href:gy(e,e.lastChatId),tone:`bad`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`}),(t||e.lastError)&&(0,I.jsx)(`span`,{title:t||e.lastError,children:(0,I.jsx)(q,{tone:`bad`,children:`error`})})]})}function by({owner:e,id:t,onOpen:n}){let r=Te(),i=N(`routines.list`,{},{interval:3e4}),a=N(`agents.list`,{},{interval:6e4}),o=N(`projects.list`,r.projects?{}:null,{interval:6e4}),s=N(`identity.get`,{},{interval:6e4}),c=e===`_`&&t===`new`,l=c?void 0:i?.routines.find(n=>n.owner===e&&n.id===t),[u,d]=(0,v.useState)(c?_y:null),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``);if((0,v.useEffect)(()=>{d(c?_y:l&&e===`_`?vy(l):null),h(``),_(``)},[e,t,!!l]),!c&&!l)return(0,I.jsx)(Y,{className:`my-auto`,children:i?`That routine is gone.`:`loading…`});async function y(e,t){p(e),h(``),_(``);try{await t()}catch(e){h(e.message)}finally{p(``)}}let b=()=>y(`run`,async()=>{let n=e===`_`?await A.request(`routines.run`,{id:t}):await A.request(`agents.runRoutine`,{slug:e,id:t});if(!n.ok)throw Error(M(n));l&&n.data.chatId&&H(gy(l,n.data.chatId))});if(l&&e!==`_`)return(0,I.jsxs)(`div`,{className:`routine-view flex flex-col gap-3 p-3`,children:[(0,I.jsx)(yy,{r:l,error:m}),(0,I.jsxs)(`p`,{className:`m-0 text-sm text-fg`,children:[`Asks `,(0,I.jsx)(`strong`,{children:my(l)}),`:`]}),(0,I.jsx)(`pre`,{className:`m-0 rounded-lg border border-line bg-surface-2 p-3 font-sans text-sm whitespace-pre-wrap text-fg`,children:l.prompt}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`play_arrow`,busy:f===`run`,onClick:()=>void b(),children:f===`run`?`starting…`:`run now`}),(0,I.jsxs)(G,{size:`sm`,icon:`edit`,href:`/agents/${encodeURIComponent(e)}/info`,title:`this routine is the agent's own: it is edited on the agent's profile`,children:[`edit on `,l.agent?.name??e,`'s profile`]})]}),m&&(0,I.jsx)(tt,{tone:`bad`,children:m})]});if(!u)return(0,I.jsx)(Y,{className:`my-auto`,children:`loading…`});let x=e=>d({...u,...e}),S=(a?.agents??[]).filter(e=>!e.archived||e.slug===u.agent),C=()=>y(`save`,async()=>{let{runsOn:e,project:t,agent:r,...i}=u,a=await A.request(`routines.save`,{body:{...i,project:t||null,agent:r||null,...e===void 0?{}:{runsOn:e.trim()||null}}});if(!a.ok)throw Error(M(a));_(`saved`),c&&n(`routines:_:${a.data.id}`)}),w=()=>y(`adopt`,async()=>{let e=await A.request(`routines.adoptOne`,{id:t});if(!e.ok)throw Error(M(e));let n=e.data.commit;if(n&&!n.ok)throw Error(`runs on ${e.data.runsOn} — routines.yml written, but not committed: ${n.error??`git failed`}`);_(`runs on ${e.data.runsOn} now${n?` — committed`:``}`),x({runsOn:e.data.runsOn}),It()});return(0,I.jsxs)(`form`,{className:`routine-form flex flex-col gap-3 p-3`,onSubmit:e=>{e.preventDefault(),C()},children:[l&&(0,I.jsx)(yy,{r:l}),(0,I.jsx)(Q,{label:`name`,children:(0,I.jsx)(Z,{value:u.name,placeholder:`e.g. Morning report`,onChange:e=>x({name:e.target.value})})}),(0,I.jsxs)(St,{className:`items-start`,children:[(0,I.jsx)(Q,{label:`runs in`,className:`min-w-[180px] flex-1`,hint:u.project?`its runs are filed under the project`:`not tied to a project`,children:(0,I.jsxs)(bt,{"aria-label":`runs in`,value:u.project,onChange:e=>x({project:e.target.value}),children:[(0,I.jsx)(`option`,{value:``,children:`the whole workspace`}),(o?.projects??[]).map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[`📁 `,e.title]},e.slug)),u.project&&!o?.projects.some(e=>e.slug===u.project)&&(0,I.jsxs)(`option`,{value:u.project,children:[`📁 `,u.project]})]})}),(0,I.jsx)(Q,{label:`who`,className:`min-w-[180px] flex-1`,hint:u.agent?`gets the prompt in a new session`:u.project?`the project's own assistant`:`the workspace's general assistant`,children:(0,I.jsxs)(bt,{"aria-label":`who`,value:u.agent,onChange:e=>x({agent:e.target.value}),children:[(0,I.jsx)(`option`,{value:``,children:u.project?`🧭 the project's assistant`:`🎩 Ralv`}),S.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.emoji,` `,e.name]},e.slug))]})})]}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`schedule (cron)`,className:`min-w-[160px] flex-1`,hint:`minute hour day month weekday, this machine's time`,children:(0,I.jsx)(Z,{className:`font-mono`,value:u.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>x({schedule:e.target.value})})}),(0,I.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 self-end pb-6 text-sm text-fg`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.enabled,onChange:e=>x({enabled:e.target.checked})}),`enabled`]})]}),(0,I.jsx)(Q,{label:`prompt — what to ask on each run`,children:(0,I.jsx)(yt,{rows:6,value:u.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>x({prompt:e.target.value})})}),(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`runs on — the one machine that fires it`,className:`min-w-[180px] flex-1`,children:(0,I.jsx)(Z,{className:`font-mono`,value:u.runsOn??s?.identity??``,placeholder:`<handle>@<machine> — empty: no runner`,onChange:e=>x({runsOn:e.target.value})})}),(0,I.jsxs)(`label`,{className:`flex h-9 cursor-pointer items-center gap-2 self-end text-sm text-fg`,title:`its runs stay off what remote members and paired devices see`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`accent-accent`,checked:u.private,onChange:e=>x({private:e.target.checked})}),`private`]})]}),s&&(0,I.jsxs)(J,{children:[`This machine is `,(0,I.jsx)(`code`,{children:s.identity}),`. Empty: no runner — it fires nowhere.`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(G,{type:`submit`,variant:`primary`,busy:f===`save`,disabled:!u.name.trim()||!u.prompt.trim()||!!f,children:c?`add the routine`:`save`}),l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{icon:`play_arrow`,busy:f===`run`,disabled:!!f,onClick:()=>void b(),title:`start a run with the saved prompt, now`,children:f===`run`?`starting…`:`run now`}),l.runner!==`here`&&(0,I.jsx)(G,{variant:`quiet`,busy:f===`adopt`,disabled:!!f,onClick:()=>void w(),title:`make ${s?.identity??`this machine`} its runner and commit routines.yml`,children:`run here`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{variant:`danger`,disabled:!!f,onClick:()=>{window.confirm(`Delete the routine "${u.name}"?`)&&y(`delete`,async()=>{let e=await A.request(`routines.delete`,{id:t});if(!e.ok)throw Error(M(e));n(void 0)})},children:`delete`})]})]}),m?(0,I.jsx)(tt,{tone:`bad`,children:m}):g?(0,I.jsx)(tt,{children:g}):null]})}var xy=[{id:`create`,label:`Create`},{id:`results`,label:`Results`},{id:`context`,label:`Context`}],Sy=[{id:`chats`,group:`create`,label:`Chats`,one:`Chat`,icon:`chat`,hue:`#4f46e5`,newHref:`/agents/chats`,newTitle:`new chat`},{id:`workflows`,group:`create`,label:`Workflows`,one:`Workflow`,icon:`account_tree`,hue:`#0e7490`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a workflow`},{id:`routines`,group:`create`,label:`Routines`,one:`Routine`,icon:`schedule`,hue:`#b45309`,newHref:`/?kind=routines&open=routines%3A_%3Anew`},{id:`boards`,group:`create`,label:`Boards`,one:`Board`,icon:`view_kanban`,hue:`#15803d`,newHref:`/boards/new`},{id:`runs`,group:`results`,label:`Workflow runs`,one:`Workflow run`,icon:`play_circle`,hue:`#0f766e`,newHref:`/?kind=workflows`,newTitle:`pick a workflow to run`},{id:`tasks`,group:`results`,label:`Tasks`,one:`Task`,icon:`task_alt`,hue:`#166534`,newHref:`/?kind=boards`,newTitle:`pick a board to add a task`},{id:`presentations`,group:`results`,label:`Presentations`,one:`Slides`,icon:`slideshow`,hue:`#c2410c`,newHref:`/presentations/new`},{id:`vibeables`,group:`results`,label:`Apps`,one:`App`,icon:`web`,hue:`#2563eb`,newHref:`/vibeables`},{id:`knowledge`,group:`context`,label:`Knowledge`,one:`Knowledge bundle`,icon:`menu_book`,hue:`#4d7c0f`,newHref:`/knowledge/new`},{id:`skills`,group:`context`,label:`Skills`,one:`Skill`,icon:`extension`,hue:`#9333ea`,newHref:`/agents/chats`,newTitle:`ask Ralv to make a skill`},{id:`repos`,group:`context`,label:`Repos`,one:`Repository`,icon:`source`,hue:`#475569`,newHref:`/repos`,newTitle:`clone a repository`},{id:`contacts`,group:`context`,label:`Contacts`,one:`Contact`,icon:`person`,hue:`#7c3aed`,newHref:`/contacts/new`},{id:`places`,group:`context`,label:`Places`,one:`Place`,icon:`location_on`,hue:`#be123c`,newHref:`/places/new`},{id:`events`,group:`context`,label:`Events`,one:`Event`,icon:`event`,hue:`#a16207`,newHref:`/events/new`}],Cy=encodeURIComponent,wy=(e,t)=>t===`chats`||t===`workflows`||t===`runs`||t===`routines`||t===`knowledge`||t===`skills`||!!e[t===`tasks`?`boards`:t],Ty=e=>Sy.find(t=>t.id===e);function Ey(){let e=z(),t=new URLSearchParams(e.split(`?`)[1]??``),n=t.get(`kind`);return{kind:Sy.some(e=>e.id===n)?n:`all`,open:t.get(`open`)??void 0}}var Dy=({kind:e,open:t})=>{let n=new URLSearchParams;e&&e!==`all`&&n.set(`kind`,e),t&&n.set(`open`,t);let r=n.toString();return r?`/?${r}`:`/`};function Oy(){let e=Te(),t=N(`chats.list`,{}),n=N(`agents.list`,{},{interval:3e4})?.agents??[],r=N(`workflows.list`,{},{interval:3e4}),i=N(`runs.list`,{},{fast:!0}),a=N(`knowledge.list`,{},{interval:3e4}),o=N(`routines.list`,{},{interval:3e4}),s=N(`skills.list`,{},{interval:3e4}),c=N(`repos.list`,e.repos?{}:null,{interval:3e4}),l=N(`vibeables.list`,e.vibeables?{}:null,{interval:3e4}),u=N(`presentations.list`,e.presentations?{query:{all:`1`}}:null,{interval:3e4}),d=N(`boards.list`,e.boards?{query:{all:`1`}}:null,{interval:3e4}),f=N(`tasks.list`,e.boards?{}:null,{interval:3e4}),p=N(`contacts.list`,e.contacts?{}:null,{interval:3e4}),m=N(`places.list`,e.places?{}:null,{interval:3e4}),h=N(`events.list`,e.events?{}:null,{interval:3e4}),g=N(`projects.list`,e.projects?{}:null,{interval:6e4}),_=e=>e?g?.projects.find(t=>t.slug===e)?.title??e:void 0;return{items:[...(t?.chats??[]).map(e=>({key:`chats:${e.id}`,kind:`chats`,title:e.title||`New chat`,href:al(e),project:e.scope.kind===`project`?e.scope.slug:e.project,updatedAt:e.updatedAt,live:e.awaitingApproval?`waiting`:e.busy?`working`:void 0,when:e.awaitingApproval?`needs approval`:e.busy?`working`:void 0,sub:e.scope.kind===`project`?`assistant`:ol({...e,project:void 0},n,e=>e)})),...(r?.workflows??[]).map(e=>({key:`workflows:${e.slug}`,kind:`workflows`,title:e.name||e.slug,href:`/workflows/${Cy(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.error})),...(i?.runs??[]).map(e=>{let t=!!e.awaitingDecision&&e.status!==`ok`&&e.status!==`aborted`,n=e.status===`running`;return{key:`runs:${e.id}`,kind:`runs`,title:e.workflow??`unknown workflow`,href:`/runs/${Cy(e.id)}`,updatedAt:e.updatedAt,live:t?`waiting`:n?`working`:void 0,since:n&&!t?e.startedAt:void 0,when:t?`decision needed`:n?e.currentPhase??`running`:e.status===`ok`?`Ran ${W(e.updatedAt)}`:`${e.status===`aborted`?`Stopped`:`Failed`} ${W(e.updatedAt)}`,broken:e.status===`failed`,sub:e.request||void 0}}),...(a?.bundles??[]).map(e=>({key:`knowledge:${e.name}`,kind:`knowledge`,title:e.name,href:`/knowledge/${Cy(e.name)}`,updatedAt:e.updatedAt,sub:`${e.concepts} concept${e.concepts===1?``:`s`}`})),...(o?.routines??[]).map(e=>({key:`routines:${e.owner}:${e.id}`,kind:`routines`,title:e.name,...e.owner===`_`?{}:{href:`/agents/${Cy(e.owner)}/info`},project:e.project,updatedAt:e.lastRunAt,when:hy(e),broken:!!e.lastError,sub:my(e)})),...(s?.skills??[]).filter(e=>e.source===`workspace`||e.source===`project`).map(e=>({key:`skills:${e.name}`,kind:`skills`,title:`/${e.name}`,href:`/skills/${Cy(e.name)}`,updatedAt:e.updatedAt,sub:e.description||void 0})),...(c?.repos??[]).map(e=>({key:`repos:${e.slug}`,kind:`repos`,title:e.slug,href:`/repos/${Cy(e.slug)}`,updatedAt:e.updatedAt??e.committedAt,broken:!!e.error,sub:[e.branch,e.dirty?`${e.dirty} changed`:e.ahead?`${e.ahead} to push`:e.behind?`${e.behind} behind`:e.error?``:`clean`].filter(Boolean).join(` · `)})),...(l?.vibeables??[]).map(e=>({key:`vibeables:${e.slug}`,kind:`vibeables`,title:e.slug,href:`/vibeables/${Cy(e.slug)}`,updatedAt:e.updatedAt,broken:!!e.configError})),...(u?.presentations??[]).map(e=>({key:`presentations:${e.project??``}:${e.name}`,kind:`presentations`,title:e.title,href:e.project?`/projects/${Cy(e.project)}/presentations/${Cy(e.name)}`:`/presentations/${Cy(e.name)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.error})),...(d?.boards??[]).map(e=>({key:`boards:${e.project??``}:${e.board}`,kind:`boards`,title:e.title,href:e.project?`/projects/${Cy(e.project)}/boards/${Cy(e.board)}`:`/boards/${Cy(e.board)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError})),...(f?.tasks??[]).map(e=>({key:`tasks:${e.project??``}:${e.board}:${e.slug}`,kind:`tasks`,title:e.title,href:`${Kl({project:e.project,board:e.board})}/${Cy(e.slug)}`,project:e.project,updatedAt:e.updatedAt,broken:!!e.configError,sub:[`#${e.number}`,e.boardTitle,e.column].filter(Boolean).join(` · `)})),...[[`contacts`,p],[`places`,m],[`events`,h]].flatMap(([e,t])=>(t?.items??[]).map(t=>{let n=t;return{key:`${e}:${t.slug}`,kind:e,title:t.title||t.slug,href:`/${e}/${Cy(t.slug)}`,updatedAt:t.updatedAt,broken:!!t.configError,lat:n.lat,lng:n.lng,start:n.start,end:n.end}}))].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``)),loading:!t&&!r&&!i&&!o&&!a&&!s&&!c&&!l&&!u&&!d&&!p&&!m&&!h,projectTitle:_}}function ky(){let e=Te(),t=Sy.filter(t=>wy(e,t.id)),{kind:n,open:r}=Ey(),i=e=>H(Dy({kind:e,open:e===`all`||r?.startsWith(`${e}:`)?r:void 0}),{replace:!0}),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),{items:l,loading:u,projectTitle:d}=Oy(),f=a.trim().toLowerCase(),p=l.filter(e=>(n===`all`||e.kind===n)&&(!f||`${e.title} ${d(e.project)??``}`.toLowerCase().includes(f))),m=t.length>0&&u,h=e=>e.live===`waiting`?0:e.live===`working`?1:2,g=[...p].sort((e,t)=>h(e)-h(t)),_=g.filter(e=>e.live).length;return(0,I.jsxs)(`div`,{className:`artifacts-screen mx-auto flex w-full max-w-[920px] flex-col gap-6 px-6 pt-8 pb-12 max-[800px]:px-4`,children:[(0,I.jsx)(`h1`,{className:`m-0 text-3xl font-semibold tracking-[-0.02em] text-fg`,children:`Home`}),t.length>0&&(0,I.jsx)(`section`,{className:`flex flex-col gap-4`,"aria-label":`kinds`,children:xy.filter(e=>t.some(t=>t.group===e.id)).map(e=>(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.label,className:`flex flex-col gap-2`,children:[(0,I.jsx)(nt,{children:e.label}),(0,I.jsx)(`div`,{className:`grid grid-cols-6 gap-3 max-[900px]:grid-cols-4 max-[600px]:grid-cols-3`,children:t.filter(t=>t.group===e.id).map(e=>{let t=n===e.id;return(0,I.jsxs)(`div`,{className:`relative flex flex-col gap-1.5 text-fg`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,"aria-label":`show only ${e.label.toLowerCase()}`,title:t?`show everything`:`show only ${e.label.toLowerCase()}`,className:P(`grid h-[60px] cursor-pointer place-items-center rounded-2xl outline-offset-2 transition-[filter,box-shadow] hover:brightness-95`,t&&`shadow-[0_0_0_2px_currentColor]`,n!==`all`&&!t&&`opacity-55`),style:{background:`color-mix(in srgb, ${e.hue} 20%, var(--color-surface))`,color:e.hue},onClick:()=>i(t?`all`:e.id),children:(0,I.jsx)(R,{name:e.icon,className:`text-[28px]`})}),(0,I.jsx)(U,{href:e.newHref,"aria-label":`new ${e.one.toLowerCase()}`,title:e.newTitle??`new ${e.one.toLowerCase()}`,className:`absolute top-1 right-1 grid size-6 place-items-center rounded-full no-underline opacity-70 hover:bg-surface hover:opacity-100`,style:{color:e.hue},children:(0,I.jsx)(R,{name:`add`,className:`ms-sm`})}),(0,I.jsx)(`span`,{className:P(`truncate text-center text-xs`,t&&`font-medium`),children:e.label})]},e.id)})})]},e.id))}),(0,I.jsxs)(`div`,{className:`-mb-3 flex items-center gap-2`,children:[(0,I.jsx)(`h2`,{className:`m-0 flex-1 text-sm font-normal text-fg-2`,children:n===`all`?`Everything`:Ty(n).label}),s?(0,I.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`search home`,placeholder:`Search`,value:a,onChange:e=>o(e.target.value),onBlur:()=>!a&&c(!1),className:`w-56 rounded-full border border-line bg-surface px-3 py-1.5 text-sm text-fg outline-none focus:border-accent`}):(0,I.jsx)(`button`,{type:`button`,"aria-label":`search home`,className:`grid size-8 cursor-pointer place-items-center rounded-full text-fg-2 hover:bg-surface-2 hover:text-fg`,onClick:()=>c(!0),children:(0,I.jsx)(R,{name:`search`})})]}),(0,I.jsxs)(`section`,{className:`flex flex-col`,"aria-label":`everything`,children:[t.length===0&&(0,I.jsxs)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:[`Nothing to list yet: turn on apps, presentations, boards, contacts, places or events in `,(0,I.jsx)(U,{href:`/settings`,className:`text-accent`,children:`settings`}),`.`]}),!m&&t.length>0&&p.length===0&&(0,I.jsx)(`p`,{className:`m-0 py-3 text-sm text-fg-2`,children:f?`Nothing matches “${a.trim()}”.`:`Nothing here yet — make something above.`}),g.map((e,t)=>{let i=Ty(e.kind),a=d(e.project),o=_===0?void 0:t===0?`Now`:t===_?`Earlier`:void 0;return(0,I.jsxs)(v.Fragment,{children:[o&&(0,I.jsx)(nt,{className:P(`block px-2 pb-1`,t>0&&`pt-4`),children:o}),(0,I.jsxs)(U,{"data-live":e.live,href:Dy({kind:n,open:e.key}),"data-artifact":e.kind,"aria-current":r===e.key?`true`:void 0,className:`artifact-row flex items-center gap-3 rounded-xl px-2 py-2.5 text-fg no-underline hover:bg-surface-2 aria-[current=true]:bg-surface-2`,children:[(0,I.jsx)(`span`,{className:`grid size-9 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${i.hue} 16%, var(--color-surface))`,color:i.hue},title:i.one,children:(0,I.jsx)(R,{name:i.icon,className:`ms-sm`})}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:P(`truncate text-[15px]`,e.broken&&`text-on-bad-soft`),children:e.title}),(0,I.jsxs)(`span`,{className:`truncate text-xs text-fg-2`,children:[i.one,e.sub?` · ${e.sub}`:``,a?` · 📁 ${a}`:``,e.broken&&e.kind!==`runs`?e.kind===`routines`?` · last run failed`:` · unreadable`:``]})]}),e.live?(0,I.jsxs)(`span`,{className:P(`flex flex-none items-center gap-1.5 text-sm tabular-nums`,e.live===`waiting`?`text-accent`:`text-fg-2`),children:[(0,I.jsx)($e,{tone:e.live===`waiting`?`ask`:`working`}),e.when,e.since&&(0,I.jsx)(Ke,{since:e.since})]}):e.when?(0,I.jsx)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.kind===`routines`?e.updatedAt?`last run ${e.updatedAt}`:`never ran`:e.updatedAt,children:e.when}):e.updatedAt&&(0,I.jsxs)(`span`,{className:`flex-none text-sm text-fg-2 tabular-nums`,title:e.updatedAt,children:[`Edited `,W(e.updatedAt)]})]})]},e.key)})]})]})}function Ay(){let{kind:e,open:t}=Ey(),{items:n,loading:r}=Oy(),i=`routines:_:new`,a=t===i?{key:i,kind:`routines`,title:`New routine`}:t?n.find(e=>e.key===t):void 0,o=a?Ty(a.kind):void 0,[,s=``,c=``,l=``]=(t??``).split(`:`),u=e===`places`||a?.kind===`places`,d=n.filter(e=>e.kind===`places`),f=d.flatMap(e=>e.lat!==void 0&&e.lng!==void 0?[{slug:e.key.slice(7),title:e.title,lat:e.lat,lng:e.lng}]:[]),p=d.length-f.length,m=Dy({kind:e}),h=e===`events`||a?.kind===`events`,g=n.flatMap(e=>e.kind===`events`&&e.start?[{slug:e.key.slice(7),title:e.title,start:String(e.start),end:e.end?String(e.end):void 0}]:[]),_=a&&o&&(0,I.jsxs)(`div`,{className:`flex flex-none items-center gap-2.5 border-b border-line px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg`,style:{background:`color-mix(in srgb, ${o.hue} 16%, var(--color-surface))`,color:o.hue},title:o.one,children:(0,I.jsx)(R,{name:o.icon,className:`ms-sm`})}),(0,I.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 truncate text-base font-semibold text-fg`,title:a.title,children:a.title}),a.href&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:a.href,title:`open the ${o.one.toLowerCase()} where it lives`,children:`open`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`close`,href:m,"aria-label":`close the preview`})]});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`}),(0,I.jsx)(`aside`,{className:`ctx artifact-preview`,"aria-label":`Preview`,"data-open":a?.key,children:h?(0,I.jsxs)(I.Fragment,{children:[_,(0,I.jsx)(`div`,{className:P(`flex min-h-0 flex-col p-3`,a?`h-[52%] flex-none`:`flex-1`),children:(0,I.jsx)(wl,{events:g,selected:a?s:void 0,onPick:t=>H(Dy({kind:e,open:`events:${t}`}))})}),a?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,I.jsx)(vv,{kind:`events`,slug:s})},a.key):(0,I.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick an event on the left or in the calendar to see its details.`})]}):u?(0,I.jsxs)(I.Fragment,{children:[_,(0,I.jsxs)(`div`,{className:P(`flex min-h-0 flex-col gap-1.5 p-3`,a?`h-[48%] flex-none`:`flex-1`),children:[(0,I.jsx)(yl,{places:f,selected:a?s:void 0,onPick:t=>H(Dy({kind:e,open:`places:${t}`}))}),(p>0||a&&a.lat===void 0)&&(0,I.jsx)(`p`,{className:`m-0 text-xs text-fg-2`,children:a&&a.lat===void 0?`This place has no coordinates yet: add latitude and longitude below to put it on the map.`:`${p} of ${d.length} places have no coordinates and are not on the map.`})]}),a?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed border-t border-line`,children:(0,I.jsx)(vv,{kind:`places`,slug:s})},a.key):(0,I.jsx)(`p`,{className:`m-0 flex-none px-3 pb-3 text-sm text-fg-2`,children:`Pick a place on the left or a dot on the map to zoom in and see its details.`})]}):!a||!o?(0,I.jsx)(Y,{icon:`preview`,className:`my-auto`,children:t&&!r?`That one is gone.`:`Pick something on the left to see it here.`}):(0,I.jsxs)(I.Fragment,{children:[_,a.kind===`chats`?(0,I.jsx)(`div`,{className:`artifact-chat flex min-h-0 flex-1 flex-col overflow-hidden px-5 pb-3`,children:(0,I.jsx)(Ko,{id:s},a.key)}):a.kind===`vibeables`?(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,I.jsx)(Na,{slug:s},a.key)}):(0,I.jsxs)(`div`,{className:`ctx-body ctx-embed`,children:[a.kind===`workflows`&&(0,I.jsx)(jy,{slug:s}),a.kind===`runs`&&(0,I.jsx)(`div`,{className:`p-3`,children:(0,I.jsx)(fc,{id:s})}),a.kind===`routines`&&(0,I.jsx)(by,{owner:s,id:c,onOpen:t=>H(Dy({kind:e,open:t}),{replace:!0})}),a.kind===`knowledge`&&(0,I.jsx)(Ny,{name:s}),a.kind===`skills`&&(0,I.jsx)(py,{name:s}),a.kind===`repos`&&(0,I.jsx)(sy,{slug:s,embedded:!0}),a.kind===`presentations`&&(0,I.jsx)(av,{project:s||void 0,name:c}),a.kind===`boards`&&(0,I.jsx)(My,{project:s||void 0,board:c,kind:e}),a.kind===`tasks`&&(0,I.jsx)(`div`,{className:`p-3`,children:(0,I.jsx)(au,{project:s||void 0,board:c,task:l})}),a.kind===`contacts`&&(0,I.jsx)(vv,{kind:a.kind,slug:s})]},a.key)]})})]})}function jy({slug:e}){let[t,n]=(0,v.useState)(`overview`),r=`/workflows/${Cy(e)}`;return(0,I.jsx)(he.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t===`details`||t===`runs`?t:`overview`),!0},children:(0,I.jsx)(qc,{slug:e,tab:t},e)})}function My({project:e,board:t,kind:n}){let r=`${Kl({project:e,board:t})}/`;return(0,I.jsx)(he.Provider,{value:i=>{let a=i.startsWith(r)?i.slice(r.length):``;return!a||a.includes(`/`)||a===`settings`?!1:(H(Dy({kind:n===`boards`?`all`:n,open:`tasks:${e??``}:${t}:${decodeURIComponent(a)}`})),!0)},children:(0,I.jsx)(du,{project:e,board:t})})}function Ny({name:e}){let[t,n]=(0,v.useState)(void 0),r=`/knowledge/${Cy(e)}`;return(0,I.jsx)(he.Provider,{value:e=>{if(e!==r&&!e.startsWith(`${r}/`))return!1;let t=e.slice(r.length+1);return n(t?t.split(`/`).map(decodeURIComponent).join(`/`):void 0),!0},children:(0,I.jsx)(kv,{name:e,conceptId:t},e)})}var Py=function(e,t){let n=e,r=Iy[t],i=null,a=0,o=null,s=[],c={},l=function(e,t){a=n*4+17,i=function(e){let t=Array(e);for(let n=0;n<e;n+=1){t[n]=Array(e);for(let r=0;r<e;r+=1)t[n][r]=null}return t}(a),u(0,0),u(a-7,0),u(0,a-7),p(),f(),h(e,t),n>=7&&m(e),o??=v(n,r,s),g(o,t)},u=function(e,t){for(let n=-1;n<=7;n+=1)if(!(e+n<=-1||a<=e+n))for(let r=-1;r<=7;r+=1)t+r<=-1||a<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?i[e+n][t+r]=!0:i[e+n][t+r]=!1)},d=function(){let e=0,t=0;for(let n=0;n<8;n+=1){l(!0,n);let r=Ry.getLostPoint(c);(n==0||e>r)&&(e=r,t=n)}return t},f=function(){for(let e=8;e<a-8;e+=1)i[e][6]??(i[e][6]=e%2==0);for(let e=8;e<a-8;e+=1)i[6][e]??(i[6][e]=e%2==0)},p=function(){let e=Ry.getPatternPosition(n);for(let t=0;t<e.length;t+=1)for(let n=0;n<e.length;n+=1){let r=e[t],a=e[n];if(i[r][a]==null)for(let e=-2;e<=2;e+=1)for(let t=-2;t<=2;t+=1)e==-2||e==2||t==-2||t==2||e==0&&t==0?i[r+e][a+t]=!0:i[r+e][a+t]=!1}},m=function(e){let t=Ry.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[Math.floor(n/3)][n%3+a-8-3]=r}for(let n=0;n<18;n+=1){let r=!e&&(t>>n&1)==1;i[n%3+a-8-3][Math.floor(n/3)]=r}},h=function(e,t){let n=r<<3|t,o=Ry.getBCHTypeInfo(n);for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<6?i[t][8]=n:t<8?i[t+1][8]=n:i[a-15+t][8]=n}for(let t=0;t<15;t+=1){let n=!e&&(o>>t&1)==1;t<8?i[8][a-t-1]=n:t<9?i[8][15-t-1+1]=n:i[8][15-t-1]=n}i[a-8][8]=!e},g=function(e,t){let n=-1,r=a-1,o=7,s=0,c=Ry.getMaskFunction(t);for(let t=a-1;t>0;t-=2)for(t==6&&--t;;){for(let n=0;n<2;n+=1)if(i[r][t-n]==null){let a=!1;s<e.length&&(a=(e[s]>>>o&1)==1),c(r,t-n)&&(a=!a),i[r][t-n]=a,--o,o==-1&&(s+=1,o=7)}if(r+=n,r<0||a<=r){r-=n,n=-n;break}}},_=function(e,t){let n=0,r=0,i=0,a=Array(t.length),o=Array(t.length);for(let s=0;s<t.length;s+=1){let c=t[s].dataCount,l=t[s].totalCount-c;r=Math.max(r,c),i=Math.max(i,l),a[s]=Array(c);for(let t=0;t<a[s].length;t+=1)a[s][t]=255&e.getBuffer()[t+n];n+=c;let u=Ry.getErrorCorrectPolynomial(l),d=By(a[s],u.getLength()-1).mod(u);o[s]=Array(u.getLength()-1);for(let e=0;e<o[s].length;e+=1){let t=e+d.getLength()-o[s].length;o[s][e]=t>=0?d.getAt(t):0}}let s=0;for(let e=0;e<t.length;e+=1)s+=t[e].totalCount;let c=Array(s),l=0;for(let e=0;e<r;e+=1)for(let n=0;n<t.length;n+=1)e<a[n].length&&(c[l]=a[n][e],l+=1);for(let e=0;e<i;e+=1)for(let n=0;n<t.length;n+=1)e<o[n].length&&(c[l]=o[n][e],l+=1);return c},v=function(e,t,n){let r=Vy.getRSBlocks(e,t),i=Hy();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),Ry.getLengthInBits(r.getMode(),e)),r.write(i)}let a=0;for(let e=0;e<r.length;e+=1)a+=r[e].dataCount;if(i.getLengthInBits()>a*8)throw`code length overflow. (`+i.getLengthInBits()+`>`+a*8+`)`;for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(236,8),i.getLengthInBits()>=a*8));)i.put(17,8);return _(i,r)};c.addData=function(e,t){t||=`Byte`;let n=null;switch(t){case`Numeric`:n=Uy(e);break;case`Alphanumeric`:n=Wy(e);break;case`Byte`:n=Gy(e);break;case`Kanji`:n=Ky(e);break;default:throw`mode:`+t}s.push(n),o=null},c.isDark=function(e,t){if(e<0||a<=e||t<0||a<=t)throw e+`,`+t;return i[e][t]},c.getModuleCount=function(){return a},c.make=function(){if(n<1){let e=1;for(;e<40;e++){let t=Vy.getRSBlocks(e,r),n=Hy();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),Ry.getLengthInBits(r.getMode(),e)),r.write(n)}let i=0;for(let e=0;e<t.length;e++)i+=t[e].dataCount;if(n.getLengthInBits()<=i*8)break}n=e}l(!1,d())},c.createTableTag=function(e,t){e||=2,t=t===void 0?e*4:t;let n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(let t=0;t<c.getModuleCount();t+=1){n+=`<tr>`;for(let r=0;r<c.getModuleCount();r+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=c.isDark(t,r)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},c.createSvgTag=function(e,t,n,r){let i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e||=2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;let a=c.getModuleCount()*e+t*2,o,s,l,u,d=``,f;for(f=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `,d+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,d+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,d+=` viewBox="0 0 `+a+` `+a+`" `,d+=` preserveAspectRatio="xMinYMin meet"`,d+=r.text||n.text?` role="img" aria-labelledby="`+y([r.id,n.id].join(` `).trim())+`"`:``,d+=`>`,d+=r.text?`<title id="`+y(r.id)+`">`+y(r.text)+`</title>`:``,d+=n.text?`<description id="`+y(n.id)+`">`+y(n.text)+`</description>`:``,d+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,d+=`<path d="`,l=0;l<c.getModuleCount();l+=1)for(u=l*e+t,o=0;o<c.getModuleCount();o+=1)c.isDark(l,o)&&(s=o*e+t,d+=`M`+s+`,`+u+f);return d+=`" stroke="transparent" fill="black"/>`,d+=`</svg>`,d},c.createDataURL=function(e,t){e||=2,t=t===void 0?e*4:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t;return Zy(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){let i=Math.floor((t-r)/e),a=Math.floor((n-r)/e);return+!c.isDark(a,i)}return 1})},c.createImgTag=function(e,t,n){e||=2,t=t===void 0?e*4:t;let r=c.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=c.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=y(n),i+=`"`),i+=`/>`,i};let y=function(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r}}return t},b=function(e){e=e===void 0?2:e;let t=c.getModuleCount()*1+e*2,n=e,r=t-e,i,a,o,s,l,u={"██":`█`,"█ ":`▀`," █":`▄`," ":` `},d={"██":`▀`,"█ ":`▀`," █":` `," ":` `},f=``;for(i=0;i<t;i+=2){for(o=Math.floor((i-n)/1),s=Math.floor((i+1-n)/1),a=0;a<t;a+=1)l=`█`,n<=a&&a<r&&n<=i&&i<r&&c.isDark(o,Math.floor((a-n)/1))&&(l=` `),n<=a&&a<r&&n<=i+1&&i+1<r&&c.isDark(s,Math.floor((a-n)/1))?l+=` `:l+=`█`,f+=e<1&&i+1>=r?d[l]:u[l];f+=`
481
+ `}return t%2&&e>0?f.substring(0,f.length-t-1)+Array(t+1).join(`▀`):f.substring(0,f.length-1)};return c.createASCII=function(e,t){if(e||=1,e<2)return b(t);--e,t=t===void 0?e*2:t;let n=c.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,l,u=Array(e+1).join(`██`),d=Array(e+1).join(` `),f=``,p=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),p=``,o=0;o<n;o+=1)l=1,r<=o&&o<i&&r<=a&&a<i&&c.isDark(s,Math.floor((o-r)/e))&&(l=0),p+=l?u:d;for(s=0;s<e;s+=1)f+=p+`
482
+ `}return f.substring(0,f.length-1)},c.renderTo2dContext=function(e,t){t||=2;let n=c.getModuleCount();for(let r=0;r<n;r++)for(let i=0;i<n;i++)e.fillStyle=c.isDark(r,i)?`black`:`white`,e.fillRect(i*t,r*t,t,t)},c};Py.stringToBytes=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t.push(r&255)}return t},Py.createStringToBytes=function(e,t){let n=function(){let n=Yy(e),r=function(){let e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};for(;;){let e=n.read();if(e==-1)break;let t=r(),o=r(),s=r(),c=String.fromCharCode(e<<8|t);a[c]=o<<8|s,i+=1}if(i!=t)throw i+` != `+t;return a}();return function(e){let t=[];for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i<128)t.push(i);else{let i=n[e.charAt(r)];typeof i==`number`?(i&255)==i?t.push(i):(t.push(i>>>8),t.push(i&255)):t.push(63)}}return t}};var Fy={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Iy={L:1,M:0,Q:3,H:2},Ly={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ry=function(){let e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r={},i=function(e){let t=0;for(;e!=0;)t+=1,e>>>=1;return t};return r.getBCHTypeInfo=function(e){let n=e<<10;for(;i(n)-i(t)>=0;)n^=t<<i(n)-i(t);return(e<<10|n)^21522},r.getBCHTypeNumber=function(e){let t=e<<12;for(;i(t)-i(n)>=0;)t^=n<<i(t)-i(n);return e<<12|t},r.getPatternPosition=function(t){return e[t-1]},r.getMaskFunction=function(e){switch(e){case Ly.PATTERN000:return function(e,t){return(e+t)%2==0};case Ly.PATTERN001:return function(e,t){return e%2==0};case Ly.PATTERN010:return function(e,t){return t%3==0};case Ly.PATTERN011:return function(e,t){return(e+t)%3==0};case Ly.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case Ly.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case Ly.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case Ly.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},r.getErrorCorrectPolynomial=function(e){let t=By([1],0);for(let n=0;n<e;n+=1)t=t.multiply(By([1,zy.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case Fy.MODE_NUMBER:return 10;case Fy.MODE_ALPHA_NUM:return 9;case Fy.MODE_8BIT_BYTE:return 8;case Fy.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case Fy.MODE_NUMBER:return 12;case Fy.MODE_ALPHA_NUM:return 11;case Fy.MODE_8BIT_BYTE:return 16;case Fy.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case Fy.MODE_NUMBER:return 14;case Fy.MODE_ALPHA_NUM:return 13;case Fy.MODE_8BIT_BYTE:return 16;case Fy.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+t},r.getLostPoint=function(e){let t=e.getModuleCount(),n=0;for(let r=0;r<t;r+=1)for(let i=0;i<t;i+=1){let a=0,o=e.isDark(r,i);for(let n=-1;n<=1;n+=1)if(!(r+n<0||t<=r+n))for(let s=-1;s<=1;s+=1)i+s<0||t<=i+s||(n!=0||s!=0)&&o==e.isDark(r+n,i+s)&&(a+=1);a>5&&(n+=3+a-5)}for(let r=0;r<t-1;r+=1)for(let i=0;i<t-1;i+=1){let t=0;e.isDark(r,i)&&(t+=1),e.isDark(r+1,i)&&(t+=1),e.isDark(r,i+1)&&(t+=1),e.isDark(r+1,i+1)&&(t+=1),(t==0||t==4)&&(n+=3)}for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(let r=0;r<t;r+=1)for(let i=0;i<t-6;i+=1)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(n+=40);let r=0;for(let n=0;n<t;n+=1)for(let i=0;i<t;i+=1)e.isDark(i,n)&&(r+=1);let i=Math.abs(100*r/t/t-50)/5;return n+=i*10,n},r}(),zy=function(){let e=Array(256),t=Array(256);for(let t=0;t<8;t+=1)e[t]=1<<t;for(let t=8;t<256;t+=1)e[t]=e[t-4]^e[t-5]^e[t-6]^e[t-8];for(let n=0;n<255;n+=1)t[e[n]]=n;let n={};return n.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},n.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},n}(),By=function(e,t){if(e.length===void 0)throw e.length+`/`+t;let n=function(){let n=0;for(;n<e.length&&e[n]==0;)n+=1;let r=Array(e.length-n+t);for(let t=0;t<e.length-n;t+=1)r[t]=e[t+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){let t=Array(r.getLength()+e.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let i=0;i<e.getLength();i+=1)t[n+i]^=zy.gexp(zy.glog(r.getAt(n))+zy.glog(e.getAt(i)));return By(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=zy.glog(r.getAt(0))-zy.glog(e.getAt(0)),n=Array(r.getLength());for(let e=0;e<r.getLength();e+=1)n[e]=r.getAt(e);for(let r=0;r<e.getLength();r+=1)n[r]^=zy.gexp(zy.glog(e.getAt(r))+t);return By(n,0).mod(e)},r},Vy=function(){let e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){let n={};return n.totalCount=e,n.dataCount=t,n},n={},r=function(t,n){switch(n){case Iy.L:return e[(t-1)*4+0];case Iy.M:return e[(t-1)*4+1];case Iy.Q:return e[(t-1)*4+2];case Iy.H:return e[(t-1)*4+3];default:return}};return n.getRSBlocks=function(e,n){let i=r(e,n);if(i===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;let a=i.length/3,o=[];for(let e=0;e<a;e+=1){let n=i[e*3+0],r=i[e*3+1],a=i[e*3+2];for(let e=0;e<n;e+=1)o.push(t(r,a))}return o},n}(),Hy=function(){let e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){let n=Math.floor(t/8);return(e[n]>>>7-t%8&1)==1},n.put=function(e,t){for(let r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){let r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},Uy=function(e){let t=Fy.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+2<t.length;)e.put(i(t.substring(r,r+3)),10),r+=3;r<t.length&&(t.length-r==1?e.put(i(t.substring(r,r+1)),4):t.length-r==2&&e.put(i(t.substring(r,r+2)),7))};let i=function(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*10+a(e.charAt(n));return t},a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return r},Wy=function(e){let t=Fy.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){let t=n,r=0;for(;r+1<t.length;)e.put(i(t.charAt(r))*45+i(t.charAt(r+1)),11),r+=2;r<t.length&&e.put(i(t.charAt(r)),6)};let i=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return r},Gy=function(e){let t=Fy.MODE_8BIT_BYTE,n=Py.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(e){return n.length},r.write=function(e){for(let t=0;t<n.length;t+=1)e.put(n[t],8)},r},Ky=function(e){let t=Fy.MODE_KANJI,n=Py.stringToBytes;(function(e,t){let r=n(e);if(r.length!=2||(r[0]<<8|r[1])!=t)throw`sjis not supported.`})(`友`,38726);let r=n(e),i={};return i.getMode=function(){return t},i.getLength=function(e){return~~(r.length/2)},i.write=function(e){let t=r,n=0;for(;n+1<t.length;){let r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},i},qy=function(){let e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n||=0,r||=e.length;for(let i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(let n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){let t=``;t+=`[`;for(let n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},Jy=function(){let e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(e<0)throw`n:`+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){let e=3-n%3;for(let t=0;t<e;t+=1)r+=`=`}},i.toString=function(){return r},i},Yy=function(e){let t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}let e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}let e=r>>>i-8&255;return i-=8,e};let o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},Xy=function(e,t){let n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);let t=s(2);e.writeByte(2);let i=0;for(;t.length-i>255;)e.writeByte(255),e.writeBytes(t,i,255),i+=255;e.writeByte(t.length-i),e.writeBytes(t,i,t.length-i),e.writeByte(0),e.writeString(`;`)};let o=function(e){let t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){let t=1<<e,n=(1<<e)+1,r=e+1,a=c();for(let e=0;e<t;e+=1)a.add(String.fromCharCode(e));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));let s=qy(),l=o(s);l.write(t,r);let u=0,d=String.fromCharCode(i[u]);for(u+=1;u<i.length;){let e=String.fromCharCode(i[u]);u+=1,a.contains(d+e)?d+=e:(l.write(a.indexOf(d),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(d+e)),d=e)}return l.write(a.indexOf(d),r),l.write(n,r),l.flush(),s.toByteArray()},c=function(){let e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},Zy=function(e,t,n){let r=Xy(e,t);for(let i=0;i<t;i+=1)for(let t=0;t<e;t+=1)r.setPixel(t,i,n(t,i));let i=qy();r.write(i);let a=Jy(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};Py.stringToBytes;function Qy(){let e=navigator.userAgent,t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Mac/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`,n=/Edg\//.test(e)?`Edge`:/Firefox\//.test(e)?`Firefox`:/Chrome\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n?`${t} · ${n}`:t}function $y(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(Qy),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{a(!0),s(``);let t=await A.request(`devices.pair`,{body:{code:e,name:n}}).catch(()=>null);if(t?.ok)return location.reload();a(!1),s(t?M(t):`could not reach kraftwerk`)};return(0,I.jsxs)(`main`,{className:`mx-auto flex min-h-screen w-full max-w-[420px] flex-col justify-center gap-5 px-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(R,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,I.jsx)(it,{size:`lg`,children:`Pair this device`}),(0,I.jsxs)(`p`,{className:`m-0 text-sm leading-relaxed text-fg-2`,children:[`This kraftwerk runs on another machine. On that machine, run `,(0,I.jsx)(`code`,{children:`kraftwerk devices pair`}),` or open settings → devices, and enter the code here. You pair once; it stays paired until it is removed there.`]})]}),(0,I.jsxs)(`form`,{className:`flex flex-col gap-3.5`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,I.jsx)(Q,{label:`pairing code`,children:(0,I.jsx)(Z,{value:e,onChange:e=>t(e.target.value.toUpperCase()),placeholder:`ABCD-EF23`,autoFocus:!0,autoComplete:`one-time-code`,autoCapitalize:`characters`,"aria-label":`pairing code`,className:`font-mono tracking-widest`})}),(0,I.jsx)(Q,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,I.jsx)(Z,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o}),(0,I.jsx)(G,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function eb({children:e}){return O()?(0,I.jsx)($y,{}):(0,I.jsx)(I.Fragment,{children:e})}function tb({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=Py(0,`M`);t.addData(e),t.make();let n=t.getModuleCount(),r=``;for(let e=0;e<n;e++)for(let i=0;i<n;i++)t.isDark(e,i)&&(r+=`M${i+4} ${e+4}h1v1h-1z`);return{d:r,n:n+8}},[e]);return(0,I.jsx)(`svg`,{viewBox:`0 0 ${n.n} ${n.n}`,width:t,height:t,role:`img`,"aria-label":`pairing QR code`,className:`rounded-lg bg-white text-black`,shapeRendering:`crispEdges`,children:(0,I.jsx)(`path`,{d:n.d,fill:`currentColor`})})}function nb({onError:e}){let t=N(`devices.relay`,{},{interval:1e4}),[n,r]=(0,v.useState)(!1);if(!t)return null;let i=async()=>{r(!0);let n=await A.request(`devices.setRelay`,{body:{enabled:!t.enabled}}).catch(()=>null);r(!1),n&&!n.ok&&e(M(n))},a=t.enabled?t.daemon?t.state===`connected`?`connected${t.clients?` · ${t.clients} device${t.clients===1?``:`s`} now`:``}`:t.state===`error`?`not connected: ${t.error??`unknown error`}`:`connecting…`:"on — the daemon connects it (this kraftwerk is not the daemon: `kraftwerk daemon`)":`off — devices reach this machine on your network only`;return(0,I.jsx)(ut,{children:(0,I.jsx)(lt,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,I.jsx)(G,{size:`sm`,busy:n,variant:t.enabled?void 0:`primary`,onClick:()=>void i(),children:t.enabled?`turn off`:`turn on`}),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[a,t.enabled&&t.fingerprint&&(0,I.jsxs)(I.Fragment,{children:[` · machine key `,(0,I.jsx)(`code`,{children:t.fingerprint})]}),` — through the kraftwerk relay, end to end encrypted: it cannot read along`]})})})}function rb(){let e=N(`devices.self`,{},{interval:6e4}),t=e?.trust===`local`,n=N(`devices.list`,t?{}:null,{interval:15e3}),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``);if(!e)return null;if(!t)return(0,I.jsx)(X,{title:`devices`,children:(0,I.jsx)(ut,{children:(0,I.jsx)(lt,{icon:`phonelink_lock`,title:`this browser is paired as “${e.device?.name}”`,children:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`devices are managed on the machine kraftwerk runs on`})})})});let s=async()=>{o(``);let e=await A.request(`devices.code`).catch(()=>null);e?.ok?i(e.data):o(e?M(e):`could not make a code`)},c=async(e,t)=>{if(!window.confirm(`Unpair “${t}”? It loses access at once.`))return;let n=await A.request(`devices.revoke`,{id:e}).catch(()=>null);n&&!n.ok&&o(M(n))};return(0,I.jsxs)(X,{title:`devices`,actions:(0,I.jsx)(G,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,I.jsxs)(xt,{className:`border-b border-line`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-3`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[22px] font-semibold tracking-widest text-fg`,"aria-label":`pairing code`,children:r.code}),(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`once, until `,new Date(r.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]})]}),r.remote&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsx)(tb,{text:r.remote}),(0,I.jsxs)(`span`,{className:`max-w-[28ch] text-sm text-fg-2`,children:[`From anywhere: scan this with the phone's camera, or open `,(0,I.jsx)(`a`,{href:r.remote,target:`_blank`,rel:`noreferrer`,children:`the pairing link`}),` on it. It carries the code — treat it like a password.`]})]}),r.urls.length?(0,I.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`On the device, open `,r.urls.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&` or `,(0,I.jsx)(`code`,{children:e})]},e)),` and enter the code.`]}):r.remote?null:(0,I.jsxs)(`span`,{className:`text-sm text-fg-2`,children:[`This kraftwerk only listens on this machine. Restart it with `,(0,I.jsx)(`code`,{children:`kraftwerk ui --lan`}),` to reach it from your network (or use a tunnel), then enter the code on the device — or turn on “reach this machine from anywhere”.`]})]}),(0,I.jsx)(nb,{onError:o}),a&&(0,I.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,I.jsx)(tt,{tone:`bad`,children:a})}),n&&n.devices.length===0&&!r&&(0,I.jsx)(Y,{icon:`devices`,children:`no paired devices — a phone or another computer can use this kraftwerk once paired`}),n&&n.devices.length>0&&(0,I.jsx)(ut,{children:n.devices.map(e=>(0,I.jsx)(lt,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`link_off`,onClick:()=>void c(e.id,e.name),"aria-label":`unpair ${e.name}`,children:`unpair`}),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`paired `,W(e.createdAt),` · `,e.lastSeenAt?`last seen ${W(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var ib={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function ab(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??ib.remote,branch:t.branch??``,interval:String(t.interval??ib.interval),autosync:t.autosync??ib.autosync}:ib}var ob={enabled:!1,root:``};function sb(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:ob}function cb(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:ob}function lb(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:ob}function ub(e){let t=e.config.boards;return t?{enabled:t.enabled!==!1,root:t.root??``}:ob}function db(e){let t=e.config.presentations;return t?{enabled:t.enabled!==!1,root:t.root??``}:ob}var fb=[`contacts`,`places`,`events`],pb={contacts:ob,places:ob,events:ob};function mb(e){let t=t=>{let n=e.config[t];return n?{enabled:n.enabled!==!1,root:n.root??``}:ob};return{contacts:t(`contacts`),places:t(`places`),events:t(`events`)}}var hb={contacts:{icon:`person`,what:`keep people and organisations as contacts, referenced as contact:<slug> from projects, events and text`,files:`one Markdown file per contact (frontmatter: role, org, email, phone, place, records; notes below)`},places:{icon:`location_on`,what:`keep addresses and points of interest as places, referenced as place:<slug>; a Google Maps link derives from coordinates or the address`,files:`one Markdown file per place (frontmatter: address, lat, lng, url, records; notes below)`},events:{icon:`event`,what:`keep dated one-off entries as events with a place, contacts and a project, referenced as event:<slug>`,files:`one Markdown file per event, named by its date (frontmatter: start, end, place, contacts, project, records; notes below)`}};function gb(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{let e=!0,n=()=>A.call(`meta.get`).then(n=>e&&n.cloud&&t(n.cloud)).catch(()=>{});n();let r=setInterval(n,1e4);return()=>{e=!1,clearInterval(r)}},[]),(0,v.useEffect)(()=>{if(!i)return;if(e?.account)return void a(!1);let n=setInterval(()=>{A.call(`cloud.sync`).then(e=>{t(t=>t&&{...t,...e}),e.account&&a(!1)}).catch(()=>{})},2e3),r=setTimeout(()=>a(!1),6e5);return()=>{clearInterval(n),clearTimeout(r)}},[i,e?.account]),!e)return null;let o=e.state===`connected`?e.account?`claimed`:`unclaimed`:e.state,s=e.state===`connected`&&e.account?`ok`:e.state===`error`?`bad`:`neutral`;return(0,I.jsx)(X,{title:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`cloud `,(0,I.jsx)(q,{tone:s,children:o})]}),actions:e.url&&(0,I.jsxs)(`a`,{className:Ze(`secondary`,`sm`),href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,I.jsx)(R,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,I.jsxs)(xt,{children:[e.state===`off`&&(0,I.jsxs)(J,{children:[`Off — `,e.reason??`turned off for this machine`,`. The daemon registers the machine with the kraftwerk cloud, so its owner sees its workspaces running from anywhere; `,(0,I.jsx)(`code`,{children:`kraftwerk cloud on`}),` and `,(0,I.jsx)(`code`,{children:`kraftwerk login`}),` in a terminal turn it on and claim it.`]}),e.state===`connecting`&&(0,I.jsxs)(J,{children:[`Registering with `,e.url,` …`]}),e.state===`error`&&(0,I.jsxs)(J,{children:[`Could not reach `,e.url,`: `,e.error,`. Retrying every `,e.interval??60,`s — the UI works as before meanwhile.`]}),e.state===`connected`&&e.account&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(J,{children:[`This machine`,e.machine?(0,I.jsxs)(I.Fragment,{children:[` (`,(0,I.jsx)(`code`,{children:e.machine}),`)`]}):null,` is registered at `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),` under `,(0,I.jsx)(`strong`,{children:e.account}),`. Last heartbeat `,e.lastSeen?new Date(e.lastSeen).toLocaleTimeString():`pending`,`.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(G,{size:`sm`,variant:`secondary`,icon:`logout`,onClick:()=>{confirm(`Sign this machine out of ${e.account}? It stays registered, unclaimed, and sends no folder paths until claimed again.`)&&A.call(`cloud.unlink`).then(e=>t(t=>t&&{...t,...e,account:null})).catch(()=>{})},children:`sign out`})})]}),e.state===`connected`&&!e.account&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(J,{children:[`This machine is registered at `,(0,I.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),`, not yet under an account (no folder paths are sent until it is). Sign in there and enter this code — or open the link, or run `,(0,I.jsx)(`code`,{children:`kraftwerk login`}),`:`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,I.jsx)(`code`,{className:`rounded-control border border-line bg-surface-2 px-3 py-1.5 font-mono text-lg tracking-[0.12em] text-fg`,children:e.claimCode??`…`}),e.claimCode&&(0,I.jsx)(G,{size:`sm`,icon:`content_copy`,onClick:()=>{navigator.clipboard.writeText(e.claimCode),r(!0),setTimeout(()=>r(!1),1500)},children:n?`copied`:`copy`}),e.claimUrl&&(0,I.jsxs)(`a`,{className:Ze(`primary`,`sm`),href:e.claimUrl,target:`_blank`,rel:`noreferrer`,onClick:()=>a(!0),children:[(0,I.jsx)(R,{name:`link`,className:`ms-sm`}),` sign in & claim`]}),i&&(0,I.jsx)(`span`,{className:`text-fg-dim text-sm`,children:`waiting for the claim …`})]}),(0,I.jsxs)(J,{children:[`A claim made there reaches this machine with the next heartbeat (every `,e.interval??60,`s). To keep this workspace out of the cloud, set `,(0,I.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]}),e.state!==`off`&&e.included===!1&&(0,I.jsxs)(J,{children:[`This workspace is left out of the machine's record: `,(0,I.jsx)(`code`,{children:`cloud.enabled: false`}),` in kraftwerk.yml.`]})]})})}function _b(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)([]),[u,d]=(0,v.useState)(ib),[f,p]=(0,v.useState)(ob),[m,h]=(0,v.useState)(ob),[g,_]=(0,v.useState)(ob),[y,b]=(0,v.useState)(ob),[x,S]=(0,v.useState)(ob),[C,w]=(0,v.useState)(pb),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),[k,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(``),P=N(`identity.get`,{},{interval:6e4});(0,v.useEffect)(()=>{A.call(`settings.get`).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(ab(e)),p(sb(e)),h(cb(e)),_(lb(e)),b(ub(e)),S(db(e)),w(mb(e))}).catch(()=>M(`could not load settings`))},[]);let F=()=>{E(!0),ee(!1),M(``)};async function te(){O(!0),M(``);try{let e=await A.request(`settings.save`,{body:{name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g,boards:y,presentations:x,...C}});if(!e.ok)throw Error(e.error||`save failed`);let r=e.data;t(r),l(r.config.switcher??[]),d(ab(r)),p(sb(r)),h(cb(r)),_(lb(r)),b(ub(r)),S(db(r)),w(mb(r)),E(!1),ee(!0)}catch(e){M(e.message)}finally{O(!1)}}let z=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),F()},ne=e=>{d(t=>({...t,...e})),F()},re=e=>{p(t=>({...t,...e})),F()},ie=e=>{h(t=>({...t,...e})),F()},ae=e=>{_(t=>({...t,...e})),F()},oe=e=>{b(t=>({...t,...e})),F()},se=e=>{S(t=>({...t,...e})),F()},ce=(e,t)=>{w(n=>({...n,[e]:{...n[e],...t}})),F()};if(!e)return(0,I.jsx)(Y,{children:j||`loading…`});let le=[[`identity`,P?.identity??`…`,`this machine — the runner routines name in runs_on (kraftwerk whoami to rename)`],[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,I.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[860px] flex-col gap-4`,children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`settings`,className:`text-[28px] text-fg-2`}),title:`Settings`,actions:(0,I.jsxs)(I.Fragment,{children:[j&&(0,I.jsx)(tt,{tone:`bad`,children:j}),k&&!T&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm`}),` saved`]}),(0,I.jsx)(G,{variant:`primary`,busy:D,disabled:!T,onClick:()=>void te(),children:D?`saving…`:`save changes`})]})}),(0,I.jsx)(X,{title:`workspace`,children:(0,I.jsxs)(xt,{children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`icon`,className:`w-[90px]`,children:(0,I.jsx)(Z,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),F()}})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-40 flex-1`,children:(0,I.jsx)(Z,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),F()}})}),(0,I.jsxs)(`label`,{className:`flex w-[130px] flex-col gap-1.5`,title:`Accent in the workspace switcher; empty = derived from the folder`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:`color`}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`input`,{type:`color`,"aria-label":`pick a color`,className:`h-9 w-10 flex-none cursor-pointer rounded-control border border-line bg-surface p-0.5`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),F()}}),(0,I.jsx)(Z,{className:`min-w-0 px-2`,value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),F()}})]})]})]}),(0,I.jsx)(J,{children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})}),(0,I.jsx)(X,{title:`workspace switcher`,actions:(0,I.jsx)(G,{size:`sm`,icon:`add`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),F()},children:`add entry`}),children:(0,I.jsxs)(xt,{children:[c.length===0&&(0,I.jsx)(J,{children:`No manual entries.`}),c.map((e,t)=>(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`icon`,className:`w-[70px]`,children:(0,I.jsx)(Z,{value:e.icon??``,placeholder:`•`,onChange:e=>z(t,{icon:e.target.value})})}),(0,I.jsx)(Q,{label:`name`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:e.name,placeholder:`other workspace`,onChange:e=>z(t,{name:e.target.value})})}),(0,I.jsx)(Q,{label:`url`,className:`min-w-40 flex-[1.4]`,children:(0,I.jsx)(Z,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>z(t,{url:e.target.value})})}),(0,I.jsx)(K,{icon:`close`,label:`remove entry`,className:`mb-0.5`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),F()}})]},t)),(0,I.jsx)(J,{children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})}),(0,I.jsx)(X,{title:`git sync`,actions:(0,I.jsx)(G,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:u.enabled,onChange:e=>ne({enabled:e}),children:`sync workflows, knowledge, agents and skills with a git remote`}),u.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(Q,{label:`remote`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:u.remote,placeholder:`origin`,onChange:e=>ne({remote:e.target.value})})}),(0,I.jsx)(Q,{label:`branch`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Z,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>ne({branch:e.target.value})})}),(0,I.jsx)(Q,{label:`interval (s)`,className:`w-[120px]`,children:(0,I.jsx)(Z,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>ne({interval:e.target.value})})}),(0,I.jsx)(Q,{label:`autosync`,className:`w-[150px]`,children:(0,I.jsxs)(bt,{value:u.autosync,onChange:e=>ne({autosync:e.target.value}),children:[(0,I.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,I.jsx)(`option`,{value:`off`,children:`fetch only`})]})})]}),(0,I.jsx)(J,{children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})}),(0,I.jsx)(X,{title:`repositories`,actions:(0,I.jsx)(G,{size:`sm`,icon:`source`,href:`/repos`,children:`open repositories`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:f.enabled,onChange:e=>re({enabled:e}),children:`keep git repositories the agents work on under one folder`}),f.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`repos root`,children:(0,I.jsx)(Z,{value:f.root,placeholder:`repos`,onChange:e=>re({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,I.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})}),(0,I.jsx)(X,{title:`apps (vibeables)`,actions:(0,I.jsx)(G,{size:`sm`,icon:`web`,href:`/vibeables`,children:`open apps`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:m.enabled,onChange:e=>ie({enabled:e}),children:`build small apps live in a chat, with a preview pane next to the thread`}),m.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`vibeables root`,children:(0,I.jsx)(Z,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>ie({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,I.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})}),(0,I.jsx)(X,{title:`projects`,actions:(0,I.jsx)(G,{size:`sm`,icon:`folder_special`,href:`/projects`,children:`open projects`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:g.enabled,onChange:e=>ae({enabled:e}),children:`gather a goal, its brief, systems of record and links in one folder, and chat inside it`}),g.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`projects root`,children:(0,I.jsx)(Z,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>ae({root:e.target.value})})}),(0,I.jsx)(J,{children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})}),(0,I.jsx)(X,{title:`boards`,actions:(0,I.jsx)(G,{size:`sm`,icon:`view_kanban`,href:`/boards`,children:`open boards`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:y.enabled,onChange:e=>oe({enabled:e}),children:`keep the work as boards of tasks — columns Draft, Todo, In progress, Review, Done; each task a folder with task.md, log.md and its files, per project and workspace-wide; agents are woken when a task is assigned to them`}),y.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`boards root`,children:(0,I.jsx)(Z,{value:y.root,placeholder:`kraftwerk-data/boards`,onChange:e=>oe({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per board under the root (workspace boards); a project's boards live in `,(0,I.jsx)(`code`,{children:`projects/<slug>/boards/`}),`. Part of the workspace: versioned with it on the git screen. Agents read and write them with `,(0,I.jsx)(`code`,{children:`kraftwerk tasks`}),`.`]})]})]})}),(0,I.jsx)(X,{title:`presentations`,actions:(0,I.jsx)(G,{size:`sm`,icon:`slideshow`,href:`/presentations`,children:`open presentations`}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:x.enabled,onChange:e=>se({enabled:e}),children:`make slide decks — each a folder with a deck.md (markdown slides on a template's layouts) and its pictures, per project and workspace-wide; previewed, presented and exported as PowerPoint or PDF from the same render`}),x.enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`presentations root`,children:(0,I.jsx)(Z,{value:x.root,placeholder:`kraftwerk-data/presentations`,onChange:e=>se({root:e.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, one folder per deck under the root (workspace decks) and `,(0,I.jsx)(`code`,{children:`templates/<slug>/template.yml`}),` for your own templates; a project's decks live in`,` `,(0,I.jsx)(`code`,{children:`projects/<slug>/presentations/`}),`. Part of the workspace: versioned with it on the git screen. Agents write and render them with `,(0,I.jsx)(`code`,{children:`kraftwerk presentations`}),`.`]})]})]})}),fb.map(e=>(0,I.jsx)(X,{title:e,actions:(0,I.jsxs)(G,{size:`sm`,icon:hb[e].icon,href:`/${e}`,children:[`open `,e]}),children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:C[e].enabled,onChange:t=>ce(e,{enabled:t}),children:hb[e].what}),C[e].enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Q,{label:`${e} root`,children:(0,I.jsx)(Z,{value:C[e].root,placeholder:`kraftwerk-data/${e}`,onChange:t=>ce(e,{root:t.target.value})})}),(0,I.jsxs)(J,{children:[`Relative to the project root, `,hb[e].files,`. Part of the workspace: versioned with it on the git screen. Agents read and write them with `,(0,I.jsxs)(`code`,{children:[`kraftwerk `,e]}),`.`]})]})]})},e)),(0,I.jsx)(gb,{}),(0,I.jsx)(rb,{}),(0,I.jsxs)(X,{title:`paths & port`,actions:(0,I.jsx)(`code`,{className:`max-w-[60%] truncate text-2xs text-fg-2`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`}),children:[(0,I.jsx)(`div`,{className:`flex flex-col pt-1.5 pb-2.5`,children:le.map(([e,t,n])=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[110px_1fr] items-baseline gap-x-3.5 gap-y-px border-line/55 px-[18px] py-2 [&+&]:border-t`,children:[(0,I.jsx)(nt,{children:e}),(0,I.jsx)(`code`,{className:`text-xs break-all`,children:t}),(0,I.jsx)(`span`,{className:`col-start-2 text-2xs text-fg-2`,children:n})]},e))}),(0,I.jsxs)(J,{className:`px-[18px] pb-3.5`,children:[`Read-only here — edit `,(0,I.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var vb={agents:{label:`agents`,icon:`smart_toy`},"agent-skills":{label:`agent skills`,icon:`extension`},projects:{label:`projects`,icon:`folder`},boards:{label:`boards`,icon:`view_kanban`},tasks:{label:`tasks`,icon:`task`},presentations:{label:`presentations`,icon:`slideshow`},workflows:{label:`workflows`,icon:`account_tree`},knowledge:{label:`knowledge bundles`,icon:`menu_book`},vibeables:{label:`apps`,icon:`web`},channels:{label:`channels`,icon:`forum`},repos:{label:`repositories`,icon:`source`},chats:{label:`chats`,icon:`chat`},runs:{label:`runs`,icon:`play_circle`}};function yb(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=(0,v.useCallback)(async()=>{let e=await A.request(`trash.list`).catch(()=>null);e?.ok?t(e.data):r(e?.status===404?`this server has no trash yet — restart it after updating`:`could not load the trash`)},[]);(0,v.useEffect)(()=>{c()},[c]);let l=async(e,t)=>{a(t),r(``),s(null);try{let n=e===`empty`?(await A.request(`trash.empty`)).error:M(await A.request(`trash.${e}`,{body:{id:t}}));if(n)throw Error(n)}catch(e){r(e.message)}finally{a(null),c()}},u=e?.entries??[],d=[...new Set(u.map(e=>e.kind))].sort((e,t)=>Object.keys(vb).indexOf(e)-Object.keys(vb).indexOf(t));return(0,I.jsxs)(ot,{className:`px-6 py-6`,children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`delete`,className:`text-[28px] text-fg-2`}),title:`Trash`,sub:e?`${u.length} item${u.length===1?``:`s`}`:void 0,actions:u.length>0&&(o===`*`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,I.jsx)(G,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(G,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,I.jsx)(tt,{tone:`bad`,children:n}),!e&&!n&&(0,I.jsx)(X,{children:(0,I.jsx)(Y,{children:`loading…`})}),e&&u.length===0&&(0,I.jsx)(X,{children:(0,I.jsx)(Y,{icon:`delete`,children:`The trash is empty. What you delete lands here first.`})}),d.map(e=>(0,I.jsx)(X,{title:vb[e]?.label??e,actions:(0,I.jsxs)(`code`,{className:`text-xs text-fg-2`,children:[`trash/`,e,`/`]}),children:(0,I.jsx)(`div`,{className:`p-1.5`,children:u.filter(t=>t.kind===e).map(t=>(0,I.jsx)(mt,{className:`trash-row`,leading:(0,I.jsx)(R,{name:vb[e]?.icon??`draft`,className:`ms-sm`}),title:t.name,sub:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:t.from}),` · `,(0,I.jsxs)(`span`,{title:t.trashedAt,children:[`deleted `,W(t.trashedAt)]})]}),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(G,{size:`sm`,variant:`secondary`,icon:`restore_from_trash`,busy:i===t.id,disabled:!!i,onClick:()=>void l(`restore`,t.id),title:`Put it back at ${t.from}`,children:`restore`}),o===t.id?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(t.id),children:`delete`})]})},t.id))})},e)),e&&(0,I.jsxs)(`p`,{className:`m-0 text-sm text-fg-2`,children:[`The trash lives in `,(0,I.jsx)(`code`,{children:e.root}),`, kept out of the workspace git. From the terminal:`,` `,(0,I.jsx)(`code`,{children:`kraftwerk trash`}),`, `,(0,I.jsx)(`code`,{children:`kraftwerk trash restore <id>`}),`, `,(0,I.jsx)(`code`,{children:`kraftwerk trash empty`}),`.`]})]})}function bb(){let[e,t]=(0,v.useState)(`overview`),[n,r]=(0,v.useState)(!0);return(0,I.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col gap-4 p-6`,children:[(0,I.jsx)(at,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,I.jsx)(G,{variant:`primary`,icon:`add`,children:`primary`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsxs)(X,{title:`Buttons`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-4`,children:[(0,I.jsx)(G,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,I.jsx)(G,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,I.jsx)(G,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,I.jsx)(G,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,I.jsx)(G,{variant:`primary`,busy:!0,children:`Saving`}),(0,I.jsx)(G,{variant:`secondary`,disabled:!0,children:`Disabled`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 pb-4`,children:[(0,I.jsx)(G,{size:`sm`,variant:`primary`,children:`small`}),(0,I.jsx)(G,{size:`sm`,variant:`secondary`,children:`small`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,children:`small`}),(0,I.jsx)(K,{icon:`edit`,label:`Rename`}),(0,I.jsx)(K,{icon:`download`,label:`Download`}),(0,I.jsx)(K,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,I.jsx)(K,{icon:`close`,label:`Close`,size:`sm`})]})]}),(0,I.jsxs)(X,{title:`Status`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,I.jsx)(Qe,{n:3}),` `,(0,I.jsx)(Qe,{n:12,tone:`neutral`}),(0,I.jsx)($e,{tone:`ok`}),` `,(0,I.jsx)($e,{tone:`bad`}),` `,(0,I.jsx)($e,{tone:`ask`}),` `,(0,I.jsx)($e,{tone:`live`}),` `,(0,I.jsx)($e,{tone:`working`}),` `,(0,I.jsx)($e,{tone:`idle`}),(0,I.jsx)(q,{children:`static`}),` `,(0,I.jsx)(q,{tone:`ok`,children:`done`}),` `,(0,I.jsx)(q,{tone:`bad`,children:`failed`}),` `,(0,I.jsx)(q,{tone:`ask`,children:`needs approval`}),` `,(0,I.jsx)(q,{tone:`accent`,children:`running`})]}),(0,I.jsx)(tt,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,I.jsx)(tt,{children:`uploading 2 of 3…`})]}),(0,I.jsx)(X,{title:`Rows`,count:1,actions:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,I.jsxs)(`div`,{className:`p-1.5`,children:[(0,I.jsx)(mt,{leading:`🐻`,title:`Max`,sub:`waiting for you · Set up the build`,subTone:`bad`,titleExtra:(0,I.jsx)(Qe,{n:1}),href:`/ui`}),(0,I.jsx)(mt,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,I.jsx)(mt,{leading:(0,I.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,I.jsx)(K,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,I.jsx)(mt,{leading:(0,I.jsx)($e,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,I.jsx)(mt,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,I.jsxs)(X,{title:`Tabs and sections`,children:[(0,I.jsx)(ht,{items:[{id:`overview`,label:`overview`},{id:`files`,label:`files`,count:4},{id:`knowledge`,label:`knowledge`,count:0}],value:e,onChange:t}),(0,I.jsxs)(`div`,{className:`p-2`,children:[(0,I.jsx)(rt,{size:`lg`,title:`needs you`,count:2,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,I.jsx)(mt,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,I.jsx)(rt,{title:`team`,children:(0,I.jsx)(mt,{leading:`🦊`,title:`Lisa`,sub:`Research`})})]})]}),(0,I.jsx)(X,{title:`Fields`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,I.jsx)(Q,{label:`Name`,hint:`Shown in the rail.`,children:(0,I.jsx)(Z,{placeholder:`e.g. Max`})}),(0,I.jsx)(Q,{label:`Harness`,children:(0,I.jsxs)(bt,{defaultValue:`claude`,children:[(0,I.jsx)(`option`,{children:`claude`}),(0,I.jsx)(`option`,{children:`codex`}),(0,I.jsx)(`option`,{children:`pi`})]})}),(0,I.jsx)(Q,{label:`Role`,children:(0,I.jsx)(yt,{rows:3,placeholder:`What this agent does`})})]})}),(0,I.jsxs)(X,{title:`Empty and menus`,children:[(0,I.jsx)(Y,{icon:`upload_file`,action:(0,I.jsx)(G,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsx)(At,{trigger:({toggle:e})=>(0,I.jsx)(G,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(mt,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,I.jsx)(mt,{leading:`🗑`,title:`Trash`,onClick:e,size:`sm`})]})})})]}),(0,I.jsx)(X,{title:`Sidebar parts`,children:(0,I.jsxs)(`div`,{className:`w-[300px] border-r border-line`,children:[(0,I.jsx)(Et,{title:`workflows`,count:3,action:(0,I.jsx)(G,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,I.jsx)(Dt,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,I.jsxs)(Ot,{children:[(0,I.jsx)(mt,{leading:(0,I.jsx)($e,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,I.jsx)(kt,{children:`no workflow matches “x”`})]})]})}),(0,I.jsx)(X,{title:`Choices`,children:(0,I.jsxs)(xt,{children:[(0,I.jsx)($,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,I.jsx)($,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,I.jsxs)(St,{children:[(0,I.jsx)(wt,{checked:n,onChange:r,label:`routine enabled`}),(0,I.jsxs)(J,{children:[`Hint: a small explaining line. Keys look like `,(0,I.jsx)(et,{children:`⌘K`}),`.`]})]}),(0,I.jsx)(Tt,{label:`Docker sandbox`,hint:`Docker is not running`,checked:n,onChange:r})]})}),(0,I.jsxs)(X,{title:`Page parts`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(st,{children:`🐻`}),(0,I.jsx)(it,{size:`lg`,children:`Max`}),(0,I.jsx)(q,{href:`#/ui`,children:`linked tag`})]}),(0,I.jsx)(ht,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,I.jsxs)(ut,{children:[(0,I.jsx)(lt,{icon:`account_tree`,title:`workflows`,action:(0,I.jsx)(G,{size:`sm`,children:`edit`}),children:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,I.jsx)(lt,{icon:`menu_book`,title:`knowledge`})]}),(0,I.jsxs)(ft,{children:[(0,I.jsx)(pt,{label:`source`,children:`workspace`}),(0,I.jsx)(pt,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var xb={running:{label:`running`},stopped:{label:`stopped`},died:{label:`died`,note:`was killed or crashed`},missing:{label:`missing`,note:`folder is gone`},orphaned:{label:`orphaned`,note:`no kraftwerk.yml any more`}},Sb={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},Cb={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function wb(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),u=(0,v.useCallback)(async()=>{try{let e=await A.request(`workspaces.list`);if(e.ok){t(e.data),r(``);return}r(e.status===404?`This workspace runs a kraftwerk without the workspaces API. Update it and restart its UI.`:`Could not load the workspace registry (HTTP ${e.status}).`)}catch(e){r(e.message||`Could not reach this workspace's server.`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await u(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]);let d=e=>e.root??e.url,f=async(e,t)=>{let n=d(e);a(e=>({...e,[n]:t})),s(e=>({...e,[n]:``})),l(null);try{let n=t===`stop`?{root:e.root,url:e.url}:{root:e.root},r=await A.request(`workspaces.${t}`,{body:n});if(!r.ok)throw Error(M(r));if(!r.data.ok)throw Error(`failed`)}catch(e){s(t=>({...t,[n]:e.message}))}finally{a(e=>{let t={...e};return delete t[n],t}),u()}},p=e?.filter(e=>e.live).length??0,m=new Map;for(let t of e??[])t.icon&&m.set(t.icon,(m.get(t.icon)??0)+1);let h=e=>!!e&&(m.get(e)??0)>1;return(0,I.jsxs)(ot,{children:[(0,I.jsx)(at,{icon:(0,I.jsx)(R,{name:`hub`,className:`text-[28px] text-fg-2`}),title:`Workspaces`,actions:(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,I.jsx)(tt,{tone:`bad`,children:n})]})}),(0,I.jsxs)(X,{title:`workspaces on this machine`,actions:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`registry: `,(0,I.jsx)(`code`,{className:`text-2xs`,children:`~/.kraftwerk/workspaces`})]}),children:[!e&&!n&&(0,I.jsx)(Y,{className:`py-6`,children:`loading…`}),!e&&n&&(0,I.jsx)(`div`,{className:`px-[18px] py-4`,children:(0,I.jsx)(tt,{tone:`bad`,children:n})}),e&&e.length===0&&(0,I.jsx)(Y,{className:`py-6`,children:`No workspaces known yet.`}),e?.map(e=>{let t=d(e),n=i[t],r=!e.live&&!!e.root&&(e.exists===!1||e.hasConfig===!1),a=P(`text-md font-semibold text-fg`,e.named===!1&&`italic text-fg-2`);return(0,I.jsxs)(`div`,{className:P(`grid grid-cols-[40px_minmax(0,1fr)_auto] items-start gap-3.5 px-[18px] py-3.5 [&+&]:border-t [&+&]:border-line/55`,e.state===`died`&&`bg-ask-soft/30`),children:[(0,I.jsx)(ze,{className:P(`size-10`,Cb[e.state]),icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[3px]`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[e.live&&!e.current?(0,I.jsx)(`a`,{href:pe(e),className:P(a,`no-underline hover:underline`),children:e.name}):(0,I.jsx)(`span`,{className:a,children:e.name}),e.current&&(0,I.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.4px] text-fg-2 uppercase`,children:`current`}),(0,I.jsxs)(`span`,{className:P(`inline-flex items-center gap-1.5 text-2xs font-semibold tracking-[0.4px] uppercase`,Sb[e.state]),children:[e.live&&(0,I.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),xb[e.state].label]}),xb[e.state].note&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:xb[e.state].note})]}),(0,I.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.root,children:e.rootLabel??(0,I.jsx)(`span`,{className:`font-sans opacity-70`,children:`no root recorded (started by an older version)`})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-3.5 gap-y-1 text-xs text-fg-2`,children:[e.state!==`missing`&&e.state!==`orphaned`&&(0,I.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,I.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,I.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,I.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,I.jsxs)(`span`,{title:e.lastStarted,children:[`started `,W(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,I.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,W(e.lastStopped)]}),e.startCount!=null&&(0,I.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,I.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,W(e.firstSeen)]})]}),o[t]&&(0,I.jsx)(tt,{tone:`bad`,children:o[t]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e.live&&!e.current&&(0,I.jsxs)(`a`,{className:Ze(`secondary`,`sm`),href:pe(e),title:`Open this workspace`,children:[(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,I.jsx)(G,{size:`sm`,variant:`primary`,icon:`play_arrow`,busy:n===`start`,disabled:!!n,onClick:()=>void f(e,`start`),children:n===`start`?`starting…`:`start`}),e.live&&!e.current&&(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`stop`,busy:n===`stop`,disabled:!!n,onClick:()=>void f(e,`stop`),children:n===`stop`?`stopping…`:`stop`}),r&&c!==t&&(0,I.jsx)(G,{size:`sm`,icon:`delete`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:`remove`}),r&&c===t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,I.jsx)(G,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,I.jsxs)(`p`,{className:`m-0 text-xs text-fg-2 [&_code]:text-2xs`,children:[`Start launches `,(0,I.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,I.jsx)(`code`,{children:`~/.kraftwerk/logs`}),`). Stop sends SIGTERM to the running server. Remove is offered only for records whose root no longer holds a `,(0,I.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,I.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}var Tb=40,Eb=/Mac|iPhone|iPad/.test(navigator.platform),Db=null,Ob=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`})),...(e.entities??[]).map(t=>({kind:`entity`,entity:t,ws:e,key:`${e.url}|${t.kind}|${t.slug}`})),...(e.current?e.tasks??[]:[]).map(t=>({kind:`task`,task:t,ws:e,key:`${e.url}|task|${t.project??``}|${t.board}|${t.slug}`})),...(e.current?e.decks??[]:[]).map(t=>({kind:`deck`,deck:t,ws:e,key:`${e.url}|deck|${t.project??``}|${t.name}`}))]),kb=e=>e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.kind===`entity`?e.entity.title:e.kind===`task`?e.task.title:e.kind===`deck`?e.deck.title:e.channel.name,Ab=e=>e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.kind===`entity`?e.entity.detail:e.kind===`task`?`${e.task.project?`${e.task.project} · `:``}${e.task.board} · ${e.task.status}`:e.kind===`deck`?`${e.deck.project?`${e.deck.project} · `:``}${e.deck.slides} ${e.deck.slides===1?`slide`:`slides`}`:e.channel.purpose,jb=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:e.kind===`entity`?`/${e.entity.kind}/${encodeURIComponent(e.entity.slug)}`:e.kind===`task`?e.task.href:e.kind===`deck`?e.deck.href:`/channels/${encodeURIComponent(e.channel.slug)}`,Mb={contacts:`contact`,places:`place`,events:`event`},Nb={contacts:`person`,places:`location_on`,events:`event`},Pb={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},Fb=e=>e.kind===`agent`?e.agent.emoji:e.kind===`project`?Pb[e.project.status]:e.kind===`entity`?(0,I.jsx)(R,{name:Nb[e.entity.kind],className:`text-[18px] text-fg-2`}):e.kind===`task`?(0,I.jsx)(R,{name:`task`,className:`text-[18px] text-fg-2`}):e.kind===`deck`?(0,I.jsx)(R,{name:`slideshow`,className:`text-[18px] text-fg-2`}):(0,I.jsx)(R,{name:`forum`,className:`text-[18px] text-fg-2`}),Ib=`flex-none rounded-full border border-line px-1.5 py-px text-[10px] font-semibold tracking-[0.4px] uppercase`;function Lb(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=kb(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:t.kind===`entity`?[t.entity.slug,t.entity.detail??``,Mb[t.entity.kind],`${Mb[t.entity.kind]}:${t.entity.slug}`]:t.kind===`task`?[t.task.slug,`task:${t.task.slug}`,t.task.board,t.task.project??``,t.task.status,`task`]:t.kind===`deck`?[t.deck.name,`presentation:${t.deck.name}`,t.deck.project??``,`presentation`,`deck`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function Rb(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function zb(e){let t=jb(e);if(e.ws.current)return H(t);let n=e.ws.live||!e.ws.root?pe(e.ws):await me(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function Bb(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex flex-none cursor-pointer items-center gap-1.5 rounded-xl border-0 bg-transparent py-1 pr-2 pl-1.5 text-fg-2 transition-colors hover:bg-surface-2 hover:text-fg active:scale-96`,onClick:()=>t(!0),title:`jump to an agent, project or channel`,"aria-label":`search`,children:[(0,I.jsx)(R,{name:`search`}),(0,I.jsx)(et,{className:`max-[1100px]:hidden`,children:Eb?`⌘K`:`Ctrl K`})]}),e&&(0,I.jsx)(Vb,{onClose:()=>t(!1)})]})}function Vb({onClose:e}){let[t,n]=(0,v.useState)(Db),[r,i]=(0,v.useState)(Db===null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return A.call(`search.agents`).then(t=>{Db=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Ob(t),[t]),_=(0,v.useMemo)(()=>Lb(g,s).slice(0,Tb),[g,s]),y=(0,v.useMemo)(()=>Rb(_),[_]),b=Math.min(l,Math.max(_.length-1,0));(0,v.useEffect)(()=>{h.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[b,_]);let x=t=>{d||(t.ws.current||t.ws.live?(e(),zb(t)):(f(t.key),m(``),zb(t).catch(e=>{f(null),m(`${t.ws.name}: ${e.message}`)})))},S=t=>{if(t.key===`ArrowDown`)t.preventDefault(),u(_.length?(b+1)%_.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),u(_.length?(b-1+_.length)%_.length:0);else if(t.key===`Enter`){t.preventDefault();let e=_[b];e&&x(e)}else t.key===`Escape`&&(t.preventDefault(),e())},C=`px-4 py-7 text-center text-sm text-fg-2 [&_a]:underline`,w;if(_.length>0){let e=-1;w=(0,I.jsx)(`ul`,{className:`m-0 list-none overflow-y-auto overscroll-contain p-1.5`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:h,children:y.map(t=>(0,I.jsxs)(v.Fragment,{children:[(0,I.jsxs)(`li`,{className:`palette-group flex items-center gap-1.5 px-2.5 pt-3 pb-1 text-2xs font-semibold tracking-[0.4px] text-fg-2 uppercase first:pt-1.5`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,I.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,I.jsx)(`span`,{className:`truncate`,children:t.ws.name}),t.ws.current?(0,I.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:`this workspace`}):t.ws.live?(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}):(0,I.jsx)(`span`,{className:Ib,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,I.jsxs)(`li`,{role:`option`,"aria-selected":n===b,className:P(`flex cursor-pointer items-center gap-2.5 rounded-xl px-2.5 py-2`,n===b&&`bg-surface-2`),onMouseMove:()=>n!==b&&u(n),onClick:()=>x(t),children:[(0,I.jsx)(`span`,{className:`w-6 flex-none text-center text-[18px] leading-none`,"aria-hidden":!0,children:Fb(t)}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-fg`,children:kb(t)}),Ab(t)&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:Ab(t)})]}),d===t.key?(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}):t.kind!==`agent`&&(0,I.jsx)(`span`,{className:P(Ib,`text-fg-2`),children:t.kind===`entity`?Mb[t.entity.kind]:t.kind===`deck`?`presentation`:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else w=a?(0,I.jsx)(`div`,{className:C,children:`could not load the agents, projects and channels`}):r?(0,I.jsx)(`div`,{className:C,children:`looking for agents, projects and channels…`}):g.length===0?(0,I.jsxs)(`div`,{className:C,children:[`no agents yet — `,(0,I.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,I.jsxs)(`div`,{className:C,children:[`no agent, project or channel matches “`,s,`”`]});return(0,I.jsx)(`div`,{className:`palette-backdrop fixed inset-0 z-50 flex animate-fade items-start justify-center bg-black/35 px-4 pt-[12vh] pb-4`,onMouseDown:e,children:(0,I.jsxs)(`div`,{className:`flex max-h-[min(70dvh,560px)] w-[min(620px,100%)] animate-modal flex-col overflow-hidden rounded-2xl border border-line bg-surface shadow-modal`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:S,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3 text-fg-2`,children:[(0,I.jsx)(R,{name:`search`}),(0,I.jsx)(`input`,{autoFocus:!0,className:`min-w-0 flex-1 border-0 bg-transparent p-0 font-sans text-[16px] text-fg outline-none`,value:s,onChange:e=>{c(e.target.value),u(0)},placeholder:`jump to an agent, project, channel, task, presentation, contact, place or event…`,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),r&&t&&(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),(0,I.jsx)(et,{children:`esc`})]}),w,(0,I.jsxs)(`div`,{className:`flex items-center gap-3.5 border-t border-line px-3.5 py-2 text-2xs text-fg-2 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(et,{children:`↑`}),(0,I.jsx)(et,{children:`↓`}),` move`]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(et,{children:`↵`}),` open`]}),d&&(0,I.jsxs)(`span`,{className:`ml-auto`,children:[(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),p&&(0,I.jsxs)(`span`,{className:`ml-auto max-w-[60%] truncate text-bad`,title:p,children:[(0,I.jsx)(R,{name:`warning`,className:`ms-sm`}),` `,p]})]})]})})}var Hb=1296e5;function Ub(e){if(e<6e4)return`just now`;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Wb(e,t){let n=new Date(e),r=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),i=Math.round((new Date(n).setHours(0,0,0,0)-new Date(t).setHours(0,0,0,0))/864e5);return i<=0?r:i===1?`tomorrow ${r}`:`${n.toLocaleDateString([],{weekday:`short`})} ${r}`}function Gb(e,t=``,n=new Date){if(!e)return t?{text:t,tone:`plain`}:null;let r=e=>`${e[0].title||`a session`}${e.length>1?` +${e.length-1}`:``}`;if(e.waiting.length)return{text:`waiting for you · ${r(e.waiting)}`,tone:`waiting`};if(e.working.length){let t=e.working[0].since,i=t?Ub(Math.max(0,n.getTime()-Date.parse(t))):``;return{text:`working · ${r(e.working)}${i&&i!==`just now`?` · ${i}`:``}`,tone:`working`}}if(e.nextRoutine&&Date.parse(e.nextRoutine.at)-n.getTime()<Hb)return{text:`next: ${e.nextRoutine.name} · ${Wb(e.nextRoutine.at,n)}`,tone:`plain`};if(e.lastActiveAt){let t=Ub(Math.max(0,n.getTime()-Date.parse(e.lastActiveAt)));return{text:t===`just now`?`last active just now`:`last active ${t} ago`,tone:`plain`}}return{text:t||`no sessions yet`,tone:`plain`}}var Kb=e=>`section`in e;function qb(e){return[...e.top.map(e=>({slug:e})),...e.sections.flatMap(e=>[{section:e.name},...e.projects.map(e=>({slug:e}))])]}function Jb(e){let t={top:[],sections:[]};for(let n of e)Kb(n)?t.sections.push({name:n.section,projects:[]}):(t.sections.at(-1)?.projects??t.top).push(n.slug);return t}var Yb=(e,t)=>Kb(e)?`section`in t&&e.section===t.section:`slug`in t&&e.slug===t.slug;function Xb(e,t,n){let r=e.findIndex(e=>Yb(e,t));if(r<0)return e;let i=r+1;if(`section`in t)for(;i<e.length&&!Kb(e[i]);)i++;if(n>=r&&n<=i)return e;let a=e.slice(r,i),o=[...e.slice(0,r),...e.slice(i)],s=n>r?n-a.length:n;return[...o.slice(0,s),...a,...o.slice(s)]}function Zb({layout:e,visible:t,render:n,onSave:r,collapsed:i,onCollapse:a,editing:o,onEdited:s}){let[c,l]=(0,v.useState)(null),u=c??qb(e);(0,v.useEffect)(()=>l(null),[JSON.stringify(e)]);let[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(o);(0,v.useEffect)(()=>g(o),[o]);let _=async e=>{l(e),await r(Jb(e))||l(null)},y=()=>{f(null),m(null)},b=(e,t)=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientY>n.top+n.height/2,i=u[t];if(d&&`slug`in d&&Kb(i))return t+1;if(d&&`section`in d){let e=t;for(;e>=0&&!Kb(u[e]);)e--;if(e<0)return u.findIndex(Kb)<0?u.length:u.findIndex(Kb);if(!r&&e===t)return e;let n=e+1;for(;n<u.length&&!Kb(u[n]);)n++;return n}return r?t+1:t},x=e=>({onDragOver:t=>{if(!d)return;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`;let n=e===void 0?u.length:b(t,e);n!==p&&m(n)},onDrop:t=>{if(!d)return;t.preventDefault(),t.stopPropagation();let n=Xb(u,d,e===void 0?u.length:b(t,e));y(),n!==u&&_(n)}}),S=e=>({draggable:!0,onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,`slug`in e?e.slug:e.section),f(e)},onDragEnd:y}),C=e=>t=>{if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=u.findIndex(t=>!Kb(t)&&t.slug===e),r=t.key===`ArrowUp`?n-1:n+2;r<0||r>u.length||_(Xb(u,{slug:e},r))},w=e=>d&&p===e?(0,I.jsx)(`div`,{className:`relative h-0`,"aria-hidden":!0,children:(0,I.jsx)(`div`,{className:`absolute inset-x-2 -top-px h-0.5 rounded-full bg-accent`})}):null,T=[],E;return u.forEach((e,r)=>{if(T.push((0,I.jsx)(v.Fragment,{children:w(r)},`line:${r}`)),Kb(e)){E=e.section;let t=e.section,n=i(t),o=0;for(let e=r+1;e<u.length&&!Kb(u[e]);e++)o++;T.push((0,I.jsx)(`div`,{...x(r),...h===t?{}:S({section:t}),className:P(`group/sec mt-2 flex items-center gap-0.5 rounded-control pl-1 pr-1`,d&&`section`in d&&d.section===t&&`opacity-40`),"data-section":t,children:h===t?(0,I.jsx)(Qb,{name:t,taken:u.filter(Kb).map(e=>e.section).filter(e=>e!==t),onDone:e=>{g(void 0),s(),e&&e!==t&&_(u.map(n=>Kb(n)&&n.section===t?{section:e}:n))}}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-0 bg-transparent px-1 py-1 text-left font-[inherit] text-xs font-semibold text-fg-2 hover:text-fg`,"aria-expanded":!n,title:n?`show the projects in ${t}`:`fold ${t}`,onClick:()=>a(t),children:[(0,I.jsx)(R,{name:`chevron_right`,className:P(`ms-sm flex-none text-[15px] transition-transform`,!n&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,I.jsx)(`span`,{className:`font-normal tabular-nums opacity-70`,children:o})]}),(0,I.jsxs)(`span`,{className:`flex items-center opacity-0 transition-opacity group-hover/sec:opacity-100 group-focus-within/sec:opacity-100 pointer-coarse:opacity-100`,children:[(0,I.jsx)(K,{size:`sm`,icon:`edit`,label:`rename section ${t}`,onClick:()=>g(t)}),(0,I.jsx)(K,{size:`sm`,icon:`close`,label:`remove section ${t}`,title:`remove the section; its projects move up`,onClick:()=>void _(u.filter(e=>!(Kb(e)&&e.section===t)))})]})]})},`section:${t}`))}else E&&i(E)&&!t(e.slug)||T.push((0,I.jsx)(`div`,{...x(r),...S({slug:e.slug}),onKeyDown:C(e.slug),className:P(`flex flex-col gap-0.5`,d&&`slug`in d&&d.slug===e.slug&&`opacity-40`),"data-sort":e.slug,children:n(e.slug)},e.slug))}),T.push((0,I.jsx)(v.Fragment,{children:w(u.length)},`line:end`)),d&&T.push((0,I.jsx)(`div`,{className:`h-4`,...x()},`drop:end`)),(0,I.jsx)(I.Fragment,{children:T})}function Qb({name:e,taken:t,onDone:n}){let[r,i]=(0,v.useState)(e),a=(0,v.useRef)(null);(0,v.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let o=r.trim().slice(0,60),s=!!o&&!t.includes(o);return(0,I.jsx)(`input`,{ref:a,value:r,"aria-label":`section name`,maxLength:60,className:P(`min-w-0 flex-1 rounded-control border bg-surface px-2 py-1 font-[inherit] text-xs font-semibold text-fg outline-none`,s?`border-line focus:border-accent`:`border-bad`),onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n(s?o:void 0),e.key===`Escape`&&n()},onBlur:()=>n(s?o:void 0)})}function $b(e){let t=new Set(e.sections.map(e=>e.name)),n=`New section`;for(let e=2;t.has(n);e++)n=`New section ${e}`;return n}function ex({chatPath:e}){let t=Te(),n=be(),r=N(`agents.list`,{},{interval:15e3}),i=N(`projects.list`,t.projects?{}:null,{interval:15e3}),a=N(`agents.status`,{},{interval:5e3}),o=e.split(`/`).filter(Boolean),s=(e,t)=>o[0]===e&&(t===void 0||(o[1]?decodeURIComponent(o[1]):void 0)===t),c=o[0]===`agents`&&o[1]===`chats`,[l,u]=ix(),d=Lt()??[],f=new Map((r?.agents??[]).filter(e=>!e.archived).map(e=>[e.slug,e])),p=i?.projects??[],m=e=>(e.agents??[]).map(e=>f.get(e)).filter(e=>!!e),h=e=>s(`projects`,e.slug),g=new Map(p.map(e=>[e.slug,e])),_=i?.layout?[...i.layout.top,...i.layout.sections.flatMap(e=>e.projects)].map(e=>g.get(e)).filter(e=>!!e):p,y=async e=>!!(await A.request(`projects.saveLayout`,{body:e}).catch(()=>null))?.ok,[b,x]=(0,v.useState)(),S=async()=>{if(!i?.layout)return;let e=$b(i.layout);await y({...i.layout,sections:[...i.layout.sections,{name:e,projects:[]}]})&&x(e)},C=e=>{let t=m(e).map(e=>a?.[e.slug]).filter(e=>!!e).some(e=>e.working.length&&!e.waiting.length);return(0,I.jsx)(mt,{size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:s(`projects`,e.slug),innerProps:{"data-project":e.slug,title:e.goal?`${e.title}: ${e.goal}`:e.title},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),title:e.title,titleExtra:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qe,{n:Rt.project(d,e.slug,e.agents).length,title:`waiting for you`}),t&&(0,I.jsx)($e,{tone:`working`,title:`an agent is working`})]}),titleLines:2})};return(0,I.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-2 pb-4`,children:[(0,I.jsx)(mt,{href:`/`,active:e===`/`,leading:(0,I.jsx)(R,{name:`home`}),title:`Home`,innerProps:{title:`Everything here: chats, workflows, routines and what they made`}}),(0,I.jsx)(mt,{href:`/agents/chats`,active:c,leading:(0,I.jsx)(R,{name:`chat`}),title:`Chats`,titleExtra:(0,I.jsx)(Qe,{n:Rt.general(d).length,title:`waiting for you`}),innerProps:{title:`Every chat with Ralv and in the projects; start a new one with Ralv, the chief of staff`}}),(0,I.jsx)(mt,{href:`/today`,active:e===`/today`,leading:(0,I.jsx)(R,{name:`today`}),title:`Today`,innerProps:{title:`Today: what needs you, what happened`}}),t.projects&&(0,I.jsxs)(tx,{label:`projects`,href:`/projects`,add:i?.enabled?{href:`/projects/new`,label:`new project`}:void 0,badge:l.all?(0,I.jsx)(Qe,{n:new Set(p.filter(e=>!h(e)).flatMap(e=>Rt.project(d,e.slug,e.agents).map(e=>e.id))).size,title:`waiting in the projects folded away`}):void 0,fold:p.length>0?(0,I.jsxs)(I.Fragment,{children:[!l.all&&i?.layout&&(0,I.jsx)(K,{size:`sm`,icon:`create_new_folder`,label:`new section`,title:`new section: drag projects into it`,onClick:()=>void S()}),(0,I.jsx)(K,{size:`sm`,icon:l.all?`chevron_right`:`expand_more`,label:l.all?`show all projects`:`collapse projects`,"aria-expanded":!l.all,onClick:()=>u(e=>({...e,all:!e.all}))})]}):void 0,children:[l.all||!i?.layout?_.filter(e=>!l.all||h(e)).map(e=>(0,I.jsx)(v.Fragment,{children:C(e)},e.slug)):(0,I.jsx)(Zb,{layout:i.layout,visible:e=>!!g.get(e)&&h(g.get(e)),render:e=>g.get(e)?C(g.get(e)):null,onSave:y,collapsed:e=>!!l.sections[e],onCollapse:e=>u(t=>({...t,sections:{...t.sections,[e]:!t.sections[e]}})),editing:b,onEdited:()=>x(void 0)}),l.all&&p.length>0&&(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,icon:`expand_more`,className:`justify-start`,onClick:()=>u(e=>({...e,all:!1})),children:[p.filter(e=>!h(e)).length,` more`]})]}),(0,I.jsx)(tx,{label:`agents`,href:`/agents`,add:n?{href:`/agents/new`,label:`new agent`}:void 0,children:(r?.agents??[]).filter(e=>!e.archived).map(e=>{let t=Gb(a?.[e.slug],e.description);return(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,active:s(`agents`,e.slug)||s(`team`,e.slug),innerProps:{title:e.description||void 0},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,titleExtra:(0,I.jsx)(nx,{n:Rt.agent(d,e.slug).length,st:a?.[e.slug]}),sub:t?(0,I.jsx)(`span`,{className:`rail-status${t.tone===`plain`?``:` ${t.tone}`}`,children:t.text}):void 0,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})]})})}function tx({label:e,href:t,add:n,badge:r,fold:i,children:a}){return(0,I.jsxs)(`div`,{className:`mt-3 flex flex-col gap-0.5`,role:`group`,"aria-label":e[0].toUpperCase()+e.slice(1),children:[(0,I.jsxs)(`div`,{className:`group/head flex items-center gap-1 pl-2.5 pr-1`,children:[(0,I.jsx)(U,{href:t,className:`flex-1 px-0 py-1 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-2 no-underline hover:text-fg`,children:e}),r,(0,I.jsxs)(`span`,{className:`flex items-center gap-1 opacity-0 transition-opacity group-hover/head:opacity-100 group-focus-within/head:opacity-100 pointer-coarse:opacity-100`,children:[n&&(0,I.jsx)(K,{size:`sm`,icon:`add`,label:n.label,href:n.href}),i]})]}),a]})}function nx({n:e,st:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qe,{n:e,title:`waiting for you`}),!e&&t?.working.length&&!t.waiting.length?(0,I.jsx)($e,{tone:`working`,title:`working`}):null]})}var rx=`kw-rail-fold`;function ix(){let[e,t]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(rx)??`null`),t=e=>e&&typeof e==`object`?e:{};return{all:!!e?.all,open:t(e?.open),sections:t(e?.sections)}}catch{return{all:!1,open:{},sections:{}}}});return[e,e=>t(t=>{let n=e(t);try{localStorage.setItem(rx,JSON.stringify(n))}catch{}return n})]}function ax({path:e}){let t=be(),n=Te(),r=e.split(`/`).filter(Boolean)[0]??``;if(!t)return null;let i=[{id:`workflows`,href:`/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,href:`/knowledge`,label:`knowledge`,icon:`menu_book`},{id:`files`,href:`/files`,label:`files`,icon:`folder_open`},...n.presentations?[{id:`presentations`,href:`/presentations`,label:`presentations`,icon:`slideshow`}]:[],...n.vibeables?[{id:`vibeables`,href:`/vibeables`,label:`apps`,icon:`web`}]:[],{id:`skills`,href:`/skills`,label:`skills`,icon:`extension`},...n.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`}]:[],...n.contacts?[{id:`contacts`,href:`/contacts`,label:`contacts`,icon:`person`}]:[],...n.places?[{id:`places`,href:`/places`,label:`places`,icon:`location_on`}]:[],...n.events?[{id:`events`,href:`/events`,label:`events`,icon:`event`}]:[],...n.git?[{id:`git`,href:`/git`,label:`git`,icon:`cloud_sync`,badge:(0,I.jsx)(ox,{})}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`},{id:`trash`,href:`/trash`,label:`trash`,icon:`delete`}],a=e=>r===e||e===`workflows`&&r===`runs`;return(0,I.jsx)(`nav`,{className:`global-nav flex min-w-0 flex-[0_1_auto] justify-start gap-0.5 overflow-x-auto [scrollbar-width:none] max-[1199px]:[mask-image:linear-gradient(to_right,#000_calc(100%-24px),transparent)] max-[800px]:hidden`,"aria-label":`Workspace`,children:i.map(e=>{let t=a(e.id);return(0,I.jsxs)(`a`,{href:`#${e.href}`,className:P(`inline-flex flex-none items-center gap-1.5 rounded-full px-3 py-1.5 text-[13.5px] font-semibold no-underline transition-colors`,`[&_.ms]:text-[18px] max-[1520px]:gap-[5px] max-[1520px]:[&_.ms]:text-[17px]`,t?`bg-surface text-accent shadow-[inset_0_0_0_1px_var(--line)]`:`text-fg-2 hover:bg-surface-2 hover:text-fg`),"aria-current":t?`page`:void 0,children:[(0,I.jsx)(R,{name:e.icon,fill:t}),` `,e.label,e.badge]},e.id)})})}function ox(){let e=N(`git.status`,{},{interval:15e3}),t=e?.files?.filter(e=>e.syncable).length??0,n=`ml-[5px] rounded-full bg-surface-2 px-1.5 py-px text-[10.5px] font-semibold tabular-nums`;return(0,I.jsxs)(I.Fragment,{children:[!!e?.behind&&(0,I.jsxs)(`span`,{className:P(n,`text-accent`),children:[e.behind,`↓`]}),!!e?.ahead&&(0,I.jsxs)(`span`,{className:P(n,`text-ok`),children:[e.ahead,`↑`]}),!e?.ahead&&!e?.behind&&!!t&&(0,I.jsx)(`span`,{className:n,children:t})]})}var sx=e=>e.replace(/^# .*\n+/,``).replace(/\(human:user\)/g,`(you)`),cx=`flex flex-col gap-1.5 px-1.5 pb-6 pt-3`,lx=`m-0 px-2.5 pb-0.5 text-md leading-[1.45] text-fg`,ux=`m-0 px-2.5 py-0.5 text-sm text-fg-2`,dx=`md-body px-2.5 text-sm leading-normal`,fx=e=>Da.sanitize(Jr.parse(sx(e),{async:!1}));function px(e,t){let n=[],r=``;for(let i of e.split(`
483
+ `)){let e=/^## (.+)$/.exec(i.trim());if(e?r=e[1]:/^[-*] /.test(i)&&n.push({day:r,text:i.replace(/^[-*] /,``)}),n.length>=t)break}return n}function mx({items:e}){return e.length===0?null:(0,I.jsx)(rt,{size:`lg`,title:`needs you`,count:e.length,children:e.map(e=>(0,I.jsx)(mt,{onClick:()=>Gt(e),leading:(0,I.jsx)(R,{name:zt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${e.owner.agent?`${e.owner.agent.emoji??``} ${e.owner.agent.name} · `:``}${Bt(e.kind)} · ${W(e.since)}`},e.id))})}function hx({slugs:e,agents:t,status:n,title:r=`team`}){let i=e.map(e=>t.find(t=>t.slug===e)).filter(e=>!!e);return i.length===0?null:(0,I.jsx)(rt,{size:`lg`,title:r,children:i.map(e=>{let t=Gb(n?.[e.slug],e.description);return(0,I.jsx)(mt,{href:`/agents/${encodeURIComponent(e.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:e.emoji||`🤖`}),title:e.name,sub:t?.text,subTone:t?.tone===`waiting`?`bad`:t?.tone===`working`?`accent`:`plain`},e.slug)})})}function gx({scope:e}){let t=N(`files.recent`,{query:{scope:e}},{interval:2e4});return!t||t.count===0?null:(0,I.jsx)(rt,{size:`lg`,title:`files`,count:t.count,action:(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,href:El(e),children:[`all `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]}),children:t.recent.map(t=>{let n=t.path.includes(`/`)?t.path.slice(0,t.path.lastIndexOf(`/`)):``;return(0,I.jsx)(mt,{href:El(e,n,t.path),leading:(0,I.jsx)(R,{name:`draft`,className:`ms-sm`}),title:t.path.split(`/`).pop(),sub:`${n?`${n}/ · `:``}${W(t.at)}`},t.path)})})}function _x({of:e}){let t=Lt()??[],n=N(`agents.list`,{},{interval:15e3})?.agents??[],r=N(`agents.status`,{},{interval:5e3})??void 0;if(e.kind===`project`){let i=e.project,a=i.links.agents.map(e=>e.slug),o=px(i.log,5);return(0,I.jsxs)(`div`,{className:cx,children:[(0,I.jsx)(rt,{size:`lg`,title:`goal`,children:(0,I.jsxs)(`p`,{className:lx,children:[i.goal||(0,I.jsx)(`span`,{className:`text-fg-2`,children:`No goal written yet.`}),i.status!==`active`&&(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[` · `,i.status]})]})}),o.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`lately`,children:o.map((e,t)=>(0,I.jsxs)(`div`,{className:`grid grid-cols-[74px_minmax(0,1fr)] gap-2 px-2.5 py-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`pt-px text-xs tabular-nums text-fg-2`,children:e.day}),(0,I.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Da.sanitize(Jr.parseInline(sx(e.text),{async:!1}))}})]},t))}),(0,I.jsx)(mx,{items:Rt.project(t,i.slug,a)}),(0,I.jsx)(hx,{slugs:a,agents:n,status:r}),(0,I.jsx)(rt,{size:`lg`,title:`where it stands`,children:i.state.trim()?(0,I.jsx)(`div`,{className:dx,dangerouslySetInnerHTML:{__html:fx(i.state)}}):(0,I.jsx)(`p`,{className:ux,children:`Nothing recorded yet: the project's chat writes this down at the end of a session that changed something.`})}),(0,I.jsx)(gx,{scope:`project:${i.slug}`}),i.records.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`systems of record`,children:i.records.map((e,t)=>(0,I.jsx)(mt,{onClick:()=>e.url&&window.open(e.url,`_blank`,`noopener`),leading:(0,I.jsx)(R,{name:`open_in_new`,className:`ms-sm`}),title:e.title||e.kind,sub:e.note},t))})]})}if(e.kind===`agent`)return(0,I.jsx)(vx,{agent:e.agent,journal:e.journal,waiting:t,status:r});if(e.kind===`channel`){let i=e.channel;return(0,I.jsxs)(`div`,{className:cx,children:[(0,I.jsx)(`p`,{className:lx,children:i.purpose||(0,I.jsxs)(`span`,{className:`text-fg-2`,children:[`A group chat with `,i.members.length,` agent`,i.members.length===1?``:`s`,`.`]})}),(0,I.jsx)(mx,{items:Rt.channel(t,i.slug)}),(0,I.jsx)(hx,{slugs:i.members,agents:n,status:r,title:`in this channel`})]})}return(0,I.jsx)(yx,{waiting:t,agents:n,status:r})}function vx({agent:e,journal:t,waiting:n,status:r}){let i=N(`projects.list`,{},{interval:3e4})?.projects??[],a=N(`agents.routines`,{slug:e.slug},{interval:3e4})?.routines??[],[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=Gb(r?.[e.slug],e.description),l=i.filter(t=>t.agents.includes(e.slug));return(0,I.jsxs)(`div`,{className:cx,children:[(0,I.jsx)(`p`,{className:lx,children:e.description||(0,I.jsx)(`span`,{className:`text-fg-2`,children:`No description yet.`})}),c&&c.text!==e.description&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 text-sm ${c.tone===`waiting`?`text-bad`:c.tone===`working`?`text-accent`:`text-fg-2`}`,children:c.text}),(0,I.jsx)(mx,{items:Rt.agent(n,e.slug)}),l.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`works on`,children:l.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(e.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:e.title,sub:e.goal||void 0},e.slug))}),a.length>0&&(0,I.jsx)(rt,{size:`lg`,title:`schedule`,children:a.map(e=>(0,I.jsx)(mt,{leading:(0,I.jsx)(R,{name:`schedule`,className:`ms-sm`}),title:e.name,sub:`${e.enabled?e.nextRunAt?`next ${new Date(e.nextRunAt).toLocaleString([],{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}`:e.schedule:`paused`}${e.lastRunAt?` · last ${W(e.lastRunAt)}`:``}`},e.id))}),(0,I.jsxs)(rt,{size:`lg`,title:`journal`,children:[(0,I.jsx)(bx,{slug:e.slug,onAdded:s}),(0,I.jsx)(`div`,{className:dx,dangerouslySetInnerHTML:{__html:fx(sx(o)||`_Nothing yet: the agent notes what it learns, decides and promises here, and reads it back at the start of every session._`)}})]})]})}function yx({waiting:e,agents:t,status:n}){let r=N(`projects.list`,{},{interval:3e4}),i=(r?.projects??[]).filter(e=>e.status===`active`);return(0,I.jsxs)(`div`,{className:cx,children:[(0,I.jsx)(mx,{items:e}),r?.enabled&&(0,I.jsxs)(rt,{size:`lg`,title:`projects`,count:i.length,children:[i.length===0&&(0,I.jsx)(`p`,{className:ux,children:`No active projects.`}),i.map(t=>{let n=Rt.project(e,t.slug,t.agents).length;return(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(t.slug)}`,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`}),title:t.title,sub:n?`${n} waiting for you`:t.goal||`no goal yet`,subTone:n?`bad`:`plain`},t.slug)})]}),(0,I.jsx)(hx,{slugs:t.filter(e=>!e.archived).map(e=>e.slug),agents:t,status:n,title:`agents`}),(0,I.jsx)(gx,{scope:`workspace`})]})}function bx({slug:e,onAdded:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=async()=>{if(!n.trim())return;a(!0),s(``);let i=await A.request(`agents.addJournal`,{slug:e,body:{entry:n,kind:`note`}}).then(e=>e.ok?{error:void 0,journal:e.data?.journal}:{error:M(e),journal:void 0}).catch(e=>({error:e.message,journal:void 0}));if(a(!1),i.error||i.journal===void 0)return s(i.error??`could not save`);r(``),t(i.journal)};return(0,I.jsxs)(`div`,{className:`px-2.5 pb-1.5 pt-0.5`,children:[(0,I.jsx)(Z,{className:`h-8 text-sm`,value:n,placeholder:`add a note for the agent to remember`,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&void c(),disabled:i}),o&&(0,I.jsx)(tt,{tone:`bad`,children:o})]})}var xx=[{id:`contacts`,icon:`person`},{id:`places`,icon:`location_on`},{id:`events`,icon:`event`}];function Sx(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}function Cx(e){let t=new Date(e),n=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),i=Math.round((r(t)-r(new Date))/864e5);return i===0?`today ${n}`:i===1?`tomorrow ${n}`:i>1&&i<7?`${t.toLocaleDateString([],{weekday:`short`})} ${n}`:`${t.toLocaleDateString([],{day:`numeric`,month:`short`})} ${n}`}var wx=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function Tx({chatPath:e,workspace:t}){let n=Sx(e),r=e.split(`/`).filter(Boolean),i=r[0]===`agents`&&r[1]===`chats`,a=r[0]===`agents`&&n.kind===`agent`,o=(r[0]===`projects`||a)&&r[2]===`chat`&&r[3]&&r[3]!==`new`?r[3]:i&&r[2]&&r[2]!==`new`?r[2]:void 0,s=n.kind===`project`?`/projects/${encodeURIComponent(n.slug)}`:a?`/agents/${encodeURIComponent(n.slug)}`:i?`/agents/chats`:void 0,c=`${n.kind}:${`slug`in n?n.slug:``}`,l=Te(),u=be(),[d,f]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:u?[`/settings`,`workspace settings`]:[void 0,``],p=N(`workflows.list`,{},{interval:15e3}),m=N(`runs.list`,{},{interval:6e3}),h=N(`routines.list`,{},{interval:3e4}),[g,_]=(0,v.useState)(null),y=N(`knowledge.list`,{},{interval:15e3}),b=N(`vibeables.list`,l.vibeables?{}:null,{interval:15e3}),x=N(`boards.list`,l.boards&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),S=n.kind===`project`?x?.boards??[]:[],C=N(`presentations.list`,l.presentations&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),w=n.kind===`project`?C?.presentations??[]:[],[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(0),[k,ee]=(0,v.useState)(()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`overview`}catch{return`overview`}}),[j,M]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>P(`browser`);return window.addEventListener(po,e),()=>window.removeEventListener(po,e)},[]);let P=e=>{ee(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}},[F,te]=(0,v.useState)({});(0,v.useEffect)(()=>te(H.current?{vibeables:`/vibeables/${encodeURIComponent(H.current.slug)}`}:{}),[c]);let[ne,re]=(0,v.useState)(!1);(0,v.useEffect)(()=>re(!1),[c]);let ie=z(),ae=n.kind===`project`?new URLSearchParams(ie.split(`?`)[1]??``).get(`app`):null;(0,v.useEffect)(()=>{ae&&(P(`vibeables`),te(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(ae)}`})),re(!0))},[ae,c]);let oe=e=>te(t=>({...t,[_e]:e})),[se,ce]=(0,v.useState)({dir:``});(0,v.useEffect)(()=>ce({dir:``}),[c]);let le=async(e,t,n)=>{(await A.request(`projects.link`,{slug:e,body:{kind:`vibeables`,target:t,remove:n}}).catch(()=>null))?.ok&&O(e=>e+1)},ue=()=>{re(!1),te(e=>({...e,[_e]:null}))},de=e=>t=>t.startsWith(e)?(te(e=>({...e,[_e]:t})),!0):!1,[B,V]=(0,v.useState)(null),H=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;H.current=t,V(t),t?(P(`vibeables`),te(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):te(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(ka,e),()=>window.removeEventListener(ka,e)},[]);let pe=l.repos&&!!T?.repos,me=n.kind===`project`?`project:${n.slug}`:T?.channel?.project?`project:${T.channel.project}`:`workspace`,ge=[{id:`overview`,label:`overview`},{id:`files`,label:`files`,allHref:`/files/${encodeURIComponent(me)}`},{id:`knowledge`,label:`knowledge`,count:T?.knowledge.length,allHref:`/knowledge`},...l.vibeables?[{id:`vibeables`,label:`apps`,count:T?.all?b?.vibeables.length:T?.vibeables?.length??0,allHref:`/vibeables`}]:[],{id:`workflows`,label:`workflows`,count:T?.workflows.length,allHref:`/workflows`},...l.boards&&n.kind===`project`?[{id:`board`,label:`boards`,count:S.reduce((e,t)=>e+t.review,0)||void 0,allHref:`/projects/${encodeURIComponent(n.slug)}/boards`}]:[],...l.presentations&&n.kind===`project`?[{id:`presentations`,label:`presentations`,count:w.length,allHref:`/projects/${encodeURIComponent(n.slug)}/presentations`}]:[],...u&&pe?[{id:`repos`,label:`repositories`,count:T?.repos?.length,allHref:`/repos`}]:[],...xx.filter(e=>l[e.id]&&T?.[e.id]).map(e=>({id:e.id,label:e.id,count:T?.[e.id]?.length,allHref:`/${e.id}`})),...j>0||k===`browser`?[{id:`browser`,label:`browser`,count:j}]:[]],_e=ge.some(e=>e.id===k)?k:`overview`,ve=ge.find(e=>e.id===_e),ye=F[_e]??null,xe=!!B&&_e===`vibeables`&&ye===`/vibeables/${encodeURIComponent(B.slug)}`,Se=_e===`vibeables`&&!!ye,Ce=ne&&Se,we=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),oe(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>O(e=>e+1),15e3);return()=>clearInterval(e)},[]);let Ee=fe(ie),De=(0,v.useRef)(Ee);(0,v.useEffect)(()=>{De.current&&!Ee&&O(e=>e+1),De.current=Ee},[Ee]),(0,v.useEffect)(()=>{let e=!0,r=new Set((p?.workflows??[]).map(e=>e.slug)),i=new Set((y?.bundles??[]).map(e=>e.name)),a=new Set((b?.vibeables??[]).map(e=>e.slug));return(async()=>{let o=null;if(n.kind===`agent`){let e=await A.call(`agents.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,agent:e,workflows:wx(e.workflows,r),knowledge:wx(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=wx(e.vibeables,a)),o.journal=(await A.call(`agents.journal`,{slug:n.slug}).catch(()=>null))?.journal??``)}else if(n.kind===`project`){let e=await A.call(`projects.get`,{slug:n.slug}).catch(()=>null);e&&(o={title:`📁 ${e.title}`,project:e,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,contacts:e.links.contacts,places:e.links.places,events:e.links.events,records:e.records,state:e.state,log:e.log,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await A.call(`channels.list`).catch(()=>null))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>A.call(`agents.get`,{slug:e}).catch(()=>null)))).filter(e=>!!e),s=e=>[...new Set(t.flatMap(e))],c=s(e=>e.vibeables??[]);o={title:`#${e.slug}`,channel:e,workflows:wx(s(e=>e.workflows),r),knowledge:wx(s(e=>e.knowledge),i),...c.length>0?{vibeables:wx(c,a)}:{},agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else o={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:wx([...r],r),knowledge:wx([...i],i),all:!0};e&&E(o)})(),()=>{e=!1}},[c,D,p,y,b,t.name,t.icon]);let Oe=e=>p?.workflows.find(t=>t.slug===e),ke=e=>e?m?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,Ae=e=>y?.bundles.find(t=>t.name===e),je=e=>b?.vibeables.find(t=>t.slug===e),Me=e=>(0,I.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[T?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,T?.editHref&&u&&!T.all&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(U,{href:T.editHref,className:`text-accent`,children:`Edit the links`}),`.`]})]});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-title flex min-w-0 items-center gap-2 px-1`,children:[s?(0,I.jsx)(U,{href:s,className:`project-home-link min-w-0 truncate rounded-control text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg no-underline animate-fade hover:text-accent max-[800px]:text-lg`,title:`${T?.title??``} · all sessions`,children:T?T.title:`…`},T?.title??``):(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[22px] leading-[1.15] font-[750] tracking-[-0.015em] text-fg animate-fade max-[800px]:text-lg`,title:T?.title,children:T?T.title:`…`},T?.title??``),d&&(0,I.jsx)(U,{href:d,className:`ctx-edit inline-grid size-7 flex-none place-items-center rounded-full text-fg-2 no-underline transition-colors hover:bg-surface-2 hover:text-accent active:scale-96 [&_.ms]:text-[18px]`,title:f,"aria-label":f,children:(0,I.jsx)(R,{name:`edit`,className:`ms-sm`})}),o&&s&&(0,I.jsx)(eo,{id:o,fallbackTitle:i||a?`new chat`:`new session`,backHref:s},o)]}),(0,I.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,"data-full":Ce||void 0,children:[(0,I.jsx)(ht,{className:`flex-none gap-y-0.5 pt-2`,label:`Categories`,items:ge,value:_e,onChange:P}),ye&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2`,children:[(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`arrow_back`,onClick:ue,"aria-label":`Back to the list`,children:ve?.label}),(0,I.jsx)(`span`,{className:`flex-1`}),Se&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:Ce?`close_fullscreen`:`open_in_full`,onClick:()=>re(!Ce),title:Ce?`back beside the chat`:`full size, in place of the chat`,children:Ce?`beside the chat`:`full size`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:ye,title:`Open as a page`,children:`page`})]}),ye&&_e===`knowledge`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(he.Provider,{value:de(`/knowledge/`),children:(()=>{let e=ye.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,I.jsx)(kv,{name:t,conceptId:n},t)})()})}),ye&&_e===`workflows`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(he.Provider,{value:de(`/workflows/`),children:(()=>{let e=ye.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,I.jsx)(qc,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),ye&&_e===`vibeables`&&!xe&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,I.jsx)(Na,{slug:decodeURIComponent(ye.split(`/`).filter(Boolean)[1]??``)},ye)}),(0,I.jsx)(`div`,{id:Aa,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!xe}),(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:_e!==`browser`,children:(0,I.jsx)(bo,{storeKey:c,onTabs:M},c)}),(0,I.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:_e===`browser`||!!ye&&[`knowledge`,`workflows`,`vibeables`].includes(_e),children:[ve?.allHref&&(0,I.jsx)(`div`,{className:`flex justify-end px-1 pb-1`,children:(0,I.jsxs)(G,{variant:`quiet`,size:`sm`,href:ve.allHref,children:[`all `,ve.label,` `,(0,I.jsx)(R,{name:`arrow_forward`,className:`ms-sm`})]})}),_e===`workflows`&&(0,I.jsxs)(I.Fragment,{children:[T&&T.workflows.length===0&&Me(`workflows`),T?.workflows.map(({slug:e,found:t})=>{let n=Oe(e),r=ke(n),i=t&&!!n&&!n.error,a=(h?.routines??[]).filter(t=>t.workflows.includes(e));return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(mt,{href:`/workflows/${encodeURIComponent(e)}`,onClick:t?we(`/workflows/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)($e,{tone:!t||n?.error?`bad`:Dx(r?.status)}),title:n?.name??e,sub:t?n?.error?`broken`:r?`${r.status} · ${W(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`,actionsAlways:!0,actions:i?(0,I.jsx)(K,{size:`sm`,icon:g===e?`close`:`play_arrow`,label:g===e?`close the launcher of ${n.name??e}`:`run ${n.name??e}`,"aria-expanded":g===e,onClick:()=>_(g===e?null:e)}):void 0}),a.map(e=>(0,I.jsxs)(U,{href:e.owner===`_`?`/?kind=routines&open=${encodeURIComponent(`routines:_:${e.id}`)}`:`/agents/${encodeURIComponent(e.owner)}/info`,className:`routine-line flex min-w-0 items-center gap-1.5 pt-0.5 pb-2 pl-[46px] pr-3 text-xs text-fg-2 no-underline hover:text-fg`,title:`${e.agent?`${e.agent.name}'s routine`:`The routine`} "${e.name}" (${e.schedule}) runs this workflow: ${e.prompt}`,children:[(0,I.jsx)(R,{name:`schedule`,className:`ms-sm flex-none text-[14px]`}),(0,I.jsxs)(`span`,{className:`min-w-0 truncate`,children:[my(e),` · `,e.name,` · `,e.enabled?e.nextRunAt?`next ${Cx(e.nextRunAt)}`:e.schedule:`paused`]})]},`${e.owner}/${e.id}`)),g===e&&n&&(0,I.jsx)(`div`,{className:`mx-1 mb-2 rounded-card border border-line bg-surface [&>div]:px-3 [&>div]:pt-3`,children:(0,I.jsx)(Ic,{slug:e,usesRequest:n.usesRequest,onLaunched:()=>{_(null),oe(`/workflows/${encodeURIComponent(e)}`)}})})]},e)})]}),_e===`knowledge`&&(0,I.jsxs)(I.Fragment,{children:[T&&T.knowledge.length===0&&Me(`knowledge`),T?.knowledge.map(({slug:e,found:t})=>{let n=Ae(e);return(0,I.jsx)(mt,{href:`/knowledge/${encodeURIComponent(e)}`,onClick:t?we(`/knowledge/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(R,{name:`menu_book`,className:`ms-sm`}),title:e,sub:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${W(n.updatedAt)}`:``}`:void 0:`not in this workspace`},e)})]}),_e===`vibeables`&&T&&(0,I.jsxs)(I.Fragment,{children:[(T.all?(b?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):T.vibeables??[]).map(({slug:e,found:t})=>{let r=je(e);return(0,I.jsx)(mt,{href:`/vibeables/${encodeURIComponent(e)}`,onClick:t?we(`/vibeables/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(R,{name:`web`,className:`ms-sm`}),title:e,sub:t?r?.updatedAt?`changed ${W(r.updatedAt)}`:void 0:`not in this workspace`,actions:n.kind===`project`?(0,I.jsx)(K,{icon:`keep_off`,size:`sm`,label:`unpin ${e}`,onClick:()=>void le(n.slug,e,!0)}):void 0},e)}),n.kind===`project`&&b&&(0,I.jsx)(Ex,{options:b.vibeables.map(e=>e.slug).filter(e=>!T.vibeables?.some(t=>t.slug===e)),onPin:e=>void le(n.slug,e,!1)}),T.all&&b&&b.vibeables.length===0&&Me(`vibeables`),!T.all&&T.vibeables?.length===0&&Me(`vibeables`)]}),xx.map(e=>_e===e.id&&T?.[e.id]&&(0,I.jsxs)(v.Fragment,{children:[T[e.id].length===0&&Me(e.id),T[e.id].map(({slug:t,found:n,label:r})=>(0,I.jsx)(mt,{href:`/${e.id}/${encodeURIComponent(t)}`,dim:!n,leading:(0,I.jsx)(R,{name:e.icon,className:`ms-sm`}),title:n&&r?r:t,sub:n?r?t:void 0:`not in this workspace`},t))]},e.id)),_e===`board`&&n.kind===`project`&&(0,I.jsxs)(I.Fragment,{children:[x&&x.enabled&&S.length===0&&(0,I.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[`No board yet. `,(0,I.jsx)(U,{href:`/projects/${encodeURIComponent(n.slug)}/boards`,className:`text-accent`,children:`Open the tasks board`}),` — it is created on first use.`]}),x&&!x.enabled&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:x.error}),S.map(e=>(0,I.jsx)(du,{project:n.slug,board:e.board},e.board))]}),_e===`presentations`&&n.kind===`project`&&(0,I.jsxs)(I.Fragment,{children:[C&&!C.enabled&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:C.error}),C?.enabled&&w.length===0&&Me(`presentations`),w.map(e=>(0,I.jsx)(mt,{href:`/projects/${encodeURIComponent(n.slug)}/presentations/${encodeURIComponent(e.name)}`,innerProps:{"data-deck":e.name},leading:(0,I.jsx)(R,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`}${e.updatedAt?` · ${W(e.updatedAt)}`:``}`,subTone:e.error?`bad`:`plain`},e.name)),C?.enabled&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`add`,className:`justify-start`,href:`/projects/${encodeURIComponent(n.slug)}/presentations/new`,children:`new presentation`})]}),_e===`repos`&&T?.repos&&(0,I.jsxs)(I.Fragment,{children:[T.repos.length===0&&Me(`repositories`),T.repos.map(({slug:e,found:t})=>(0,I.jsx)(mt,{href:`/repos/${encodeURIComponent(e)}`,dim:!t,leading:(0,I.jsx)(R,{name:`source`,className:`ms-sm`}),title:e,sub:t?void 0:`not in this workspace`},e))]}),_e===`overview`&&T&&(0,I.jsx)(_x,{of:T.project?{kind:`project`,project:T.project}:T.agent?{kind:`agent`,agent:T.agent,journal:T.journal??``}:T.channel?{kind:`channel`,channel:T.channel}:{kind:`workspace`}},c),_e===`files`&&(0,I.jsx)(Nl,{compact:!0,scope:me,dir:se.dir,file:se.file,onOpen:(e,t)=>ce({dir:e,file:t})},me)]},_e)]})]})}function Ex({options:e,onPin:t}){return e.length===0?null:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-2 text-fg-2`,children:[(0,I.jsx)(R,{name:`keep`,className:`ms-sm`}),(0,I.jsxs)(bt,{className:`h-8 text-sm`,value:``,onChange:e=>e.target.value&&t(e.target.value),"aria-label":`pin an app to this project`,children:[(0,I.jsx)(`option`,{value:``,children:`pin an app to this project…`}),e.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]})]})}function Dx(e){return e===`ok`?`ok`:e===`failed`?`bad`:e===`running`?`working`:`idle`}var Ox=`kw-chat-path`,kx=`kw-ctx-w`,Ax=()=>{try{let e=Number(localStorage.getItem(kx));return e>0?e:null}catch{return null}};function jx({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,I.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for half and half`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var Mx=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},Nx=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function Px(){let e=z();Jt();let[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=ue(t),y=de(t),b=le.has(n[0]??``)&&!_&&!y,x=n.length===0||n[0]===`artifacts`,S=n[0]===`today`,C=x||S,[w,T]=(0,v.useState)(()=>Mx(Ox,`/agents/chats`)),E=b?ec(t):null,D=b&&!E?t:w,[O,k]=(0,v.useState)(`chat`),[A,ee]=(0,v.useState)(Ax),j=e=>{ee(e);try{e===null?localStorage.removeItem(kx):localStorage.setItem(kx,String(e))}catch{}};(0,v.useEffect)(()=>{k(e=>e===`side`?`chat`:e)},[e]),(0,v.useEffect)(()=>{b&&!ec(t)&&(T(t),Nx(Ox,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;B(t)===`chat`?(T(t),Nx(Ox,t)):window.location.replace(`#${t}`)};return window.addEventListener(V,e),()=>window.removeEventListener(V,e)},[]);let M=N(`meta.get`,{},{interval:3e4});(0,v.useEffect)(()=>{let e=M;e&&(i(e.workspaceName??``),o(e.workspaceIcon??``),c(e.workspaceColor??``),u(e.workspaceNamed!==!1),f(e.workspaceRootLabel??``),m(e.workspaceRoot??``),we({git:!!e.git,repos:!!e.repos,vibeables:!!e.vibeables,projects:!!e.projects,contacts:!!e.contacts,places:!!e.places,events:!!e.events,boards:!!e.boards,presentations:!!e.presentations}),g(Array.isArray(e.switcher)?e.switcher:[]))},[M]),(0,v.useEffect)(()=>{if(se(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let P=D.split(`/`).filter(Boolean),F=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=P[0]===`chats`?(0,I.jsx)($s,{seg:P}):P[0]===`projects`?(0,I.jsx)(ds,{seg:P.slice(1)}):P[0]===`channels`?(0,I.jsx)(Wa,{seg:P.slice(1)}):(0,I.jsx)($s,{seg:P.slice(1)});let ne=null;return _?ne=(0,I.jsx)(su,{seg:n.slice(3),project:decodeURIComponent(n[1])}):y?ne=(0,I.jsx)(L_,{seg:n.slice(3),project:decodeURIComponent(n[1])}):n[0]===`runs`&&n[1]?ne=(0,I.jsx)(uc,{id:n[1],workflow:F}):n[0]===`runs`?ne=(0,I.jsx)(Wx,{}):n[0]===`workflows`?ne=(0,I.jsx)(nl,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?ne=(0,I.jsx)(Ha,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?ne=(0,I.jsx)(Sv,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?ne=(0,I.jsx)(dy,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?ne=(0,I.jsx)(_b,{}):n[0]===`trash`?ne=(0,I.jsx)(yb,{}):n[0]===`ui`?ne=(0,I.jsx)(bb,{}):n[0]===`files`?ne=(0,I.jsx)(jl,{scope:n[1]?decodeURIComponent(n[1]):`workspace`,dir:n.slice(2).map(decodeURIComponent).join(`/`),file:new URLSearchParams(e.split(`?`)[1]??``).get(`file`)??void 0}):n[0]===`workspaces`?ne=(0,I.jsx)(wb,{}):n[0]===`git`?ne=(0,I.jsx)(Jv,{}):n[0]===`repos`?ne=(0,I.jsx)(oy,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`contacts`||n[0]===`places`||n[0]===`events`?ne=(0,I.jsx)(hv,{kind:n[0],slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`boards`?ne=(0,I.jsx)(su,{seg:n.slice(1)}):n[0]===`presentations`&&(ne=(0,I.jsx)(L_,{seg:n.slice(1)})),(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?Le(De(s,t)):null;if(!n)delete e.dataset.wsAccent;else{for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``}},[s,p,r]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`topbar sticky top-0 z-10 flex h-[var(--topbar-h)] items-center gap-3.5 bg-bg px-5 shadow-[inset_0_-1px_0_var(--line)] max-[1520px]:gap-2.5 max-[800px]:gap-1.5 max-[800px]:px-3`,style:{"--ws-c":De(s,p||r)},children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-none items-center gap-2.5 max-[800px]:flex-[0_1_auto] max-[800px]:gap-1`,children:[(0,I.jsx)(`a`,{href:`#/`,className:`grid size-8 place-items-center rounded-full text-[15px] leading-none transition-shadow hover:shadow-[0_0_0_4px_color-mix(in_srgb,var(--ws-c,var(--text))_16%,transparent)]`,title:`Home`,children:r?(0,I.jsx)(ze,{size:`sm`,icon:a,name:r,color:s,seed:p||r}):(0,I.jsx)(R,{name:`home`})}),r&&(0,I.jsx)(Ux,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,I.jsx)(ax,{path:t}),(0,I.jsx)(`span`,{className:`flex-[1_1_8px]`}),(0,I.jsx)(Bb,{}),(0,I.jsx)(K,{icon:`settings`,label:`settings`,href:`/settings`,"aria-current":n[0]===`settings`?`page`:void 0}),(0,I.jsx)(qx,{}),(0,I.jsx)(qt,{}),(0,I.jsx)(Xx,{}),(0,I.jsx)(Kx,{})]}),ne&&(0,I.jsx)(`main`,{className:`shell shell-global`,children:ne}),(0,I.jsxs)(`main`,{className:`shell three${C?` home`:``}`,"data-focus":O,hidden:!!ne,style:A?{"--ctx-w":`${A}px`}:void 0,children:[(0,I.jsx)(ex,{chatPath:x?`/`:S?`/today`:D}),(0,I.jsxs)(`section`,{className:`col-chat`,"aria-label":x?`Home`:S?`Today`:`Conversation`,children:[x?(0,I.jsx)(ky,{}):S?(0,I.jsx)(cl,{}):te,(0,I.jsx)(jx,{onResize:j})]}),x?(0,I.jsx)(Ay,{}):(0,I.jsx)(Tx,{chatPath:C?`/`:D,workspace:{name:r,icon:a}}),E&&(0,I.jsx)(tc,{back:D,children:E})]}),!ne&&(0,I.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,I.jsxs)(`button`,{className:O===`side`?`active`:``,onClick:()=>k(`side`),children:[(0,I.jsx)(R,{name:`menu`}),` list`]}),(0,I.jsxs)(`button`,{className:O===`chat`?`active`:``,onClick:()=>k(`chat`),children:[(0,I.jsx)(R,{name:`forum`}),` chat`]}),(0,I.jsxs)(`button`,{className:O===`context`?`active`:``,onClick:()=>k(`context`),children:[(0,I.jsx)(R,{name:`account_tree`}),` context`]})]})]})}function Fx(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}var Ix=`truncate text-sm text-fg-2 group-aria-[current=true]/ws:text-on-accent-soft group-aria-[current=true]/ws:opacity-80`,Lx=`group/ws relative flex min-h-[60px] items-center gap-3.5 px-4 py-2.5 text-fg no-underline transition-colors`;function Rx({label:e}){return e?(0,I.jsx)(`span`,{className:P(Ix,`[direction:rtl] text-left`),title:e,children:(0,I.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})}):null}function zx({name:e,named:t}){let n=t===!1;return(0,I.jsx)(`span`,{className:P(`truncate text-md tracking-[0.2px]`,n&&`italic text-fg-2`,`group-data-[missing]/ws:line-through group-data-[stopped]/ws:text-fg-2`),title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function Bx({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await me(e.root))}catch(e){r(`error`),a(e.message)}};return(0,I.jsxs)(`span`,{className:P(Lx,`cursor-default`),role:`menuitem`,"data-stopped":``,"data-missing":o?``:void 0,style:{"--ws-c":De(e.color,e.root??e.url)},children:[(0,I.jsx)(ze,{className:`opacity-60 grayscale-50`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(zx,{name:e.name,named:e.named}),n===`error`?(0,I.jsx)(`span`,{className:P(Ix,`text-bad`),title:i,children:i}):o?(0,I.jsx)(`span`,{className:Ix,children:`folder missing`}):(0,I.jsx)(Rx,{label:e.rootLabel})]}),(0,I.jsxs)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:[(0,I.jsx)(Vx,{entry:e}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`play_arrow`,busy:n===`starting`,className:`text-accent hover:text-accent`,disabled:o,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:n===`starting`?`starting`:`start`})]})]})}function Vx({entry:e}){return(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-2xs font-medium tracking-[0.5px] text-fg-2`,children:[e.live&&(0,I.jsx)($e,{tone:`ok`,title:`running`}),!e.here&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:Fx(e.url)})]})}function Hx({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,I.jsxs)(`a`,{className:P(Lx,`hover:bg-surface-2 active:bg-surface-2`),role:`menuitem`,href:pe(e),style:{"--ws-c":De(e.color,n)},children:[(0,I.jsx)(ze,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(zx,{name:e.name,named:e.named}),(0,I.jsx)(Rx,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,I.jsx)(Vx,{entry:e})})]})}function Ux({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=be();(0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`[data-switcher]`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]);let u=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&u.set(e,(u.get(e)??0)+1);let d=e=>!!e&&(u.get(e)??0)>1,f=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),p=a||e;return(0,I.jsxs)(`span`,{className:`relative inline-flex min-w-0`,"data-switcher":``,children:[(0,I.jsxs)(`button`,{type:`button`,className:`env-switch inline-flex max-w-[220px] min-w-0 cursor-pointer items-center gap-[5px] rounded-xl border-0 bg-transparent px-2 py-1 font-[inherit] text-[15px] font-bold tracking-[0.02em] whitespace-nowrap text-fg transition-colors hover:bg-surface-2 max-[1520px]:max-w-[250px]`,title:i?`${i} — workspace menu`:`Workspace menu`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,I.jsx)(R,{name:`expand_more`,className:`flex-none opacity-55`})]}),s&&(0,I.jsxs)(`div`,{className:`absolute top-[calc(100%+8px)] left-0 z-20 max-h-[calc(100dvh-120px)] max-w-[min(480px,92vw)] min-w-[360px] max-[800px]:fixed max-[800px]:inset-x-2 max-[800px]:top-[calc(var(--topbar-h)-4px)] max-[800px]:max-w-none max-[800px]:min-w-0 overflow-y-auto overscroll-contain rounded-card border border-line bg-surface py-2 shadow-pop`,role:`menu`,children:[o.length>0&&(0,I.jsx)(nt,{className:`block px-4 pt-1 pb-2`,children:`workspaces`}),(0,I.jsxs)(`span`,{className:P(Lx,`cursor-default bg-accent-soft text-on-accent-soft`),"aria-current":`true`,style:{"--ws-c":De(n,p)},children:[(0,I.jsx)(ze,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(zx,{name:e,named:r}),i?(0,I.jsx)(Rx,{label:i}):(0,I.jsx)(`span`,{className:Ix,children:`this workspace`})]}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,I.jsx)(R,{name:`check`,className:`text-[24px] text-on-accent-soft`})})]}),f.map(e=>(0,I.jsxs)(`div`,{className:`mt-2 border-t border-line pt-1`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(nt,{className:`block px-4 pt-2 pb-1`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,I.jsx)(Bx,{entry:e,ambiguous:d(e.icon)},e.root):(0,I.jsx)(Hx,{entry:e,ambiguous:d(e.icon)},e.root??e.url))]},e.key)),l&&o.length>0&&(0,I.jsxs)(`a`,{className:`mt-2 flex min-h-12 items-center gap-4 border-t border-line px-4 text-md text-fg no-underline transition-colors hover:bg-surface-2`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,I.jsx)(R,{name:`hub`,className:`text-[22px] text-fg-2`}),` manage workspaces`]}),(0,I.jsx)($x,{onClose:()=>c(!1)})]})]})}function Wx(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return A.call(`runs.list`).then(n=>{e&&(n.runs.length>0?H(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,I.jsxs)(Y,{icon:`play_circle`,children:[`No runs found in `,(0,I.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,I.jsx)(`a`,{href:`#/workflows`,className:`text-accent`,children:`workflows`}),` list or with `,(0,I.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,I.jsx)(Y,{children:`loading…`})}async function Gx(e){await A.request(`server.restart`).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await A.call(`meta.get`)).version===e)break}catch{}}location.reload()}function Kx(){let e=N(`meta.get`,{},{interval:3e4}),[t,n]=(0,v.useState)(!1),r=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function i(){r&&(n(!0),await Gx(r))}return!r&&!t?null:(0,I.jsx)(`button`,{type:`button`,className:`mr-2.5 inline-flex flex-none cursor-pointer items-center gap-1 rounded-full border border-accent bg-accent/10 px-3 py-1 font-[inherit] text-xs text-accent hover:bg-accent/18 disabled:cursor-default disabled:opacity-70`,disabled:t,title:`v${r} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void i(),children:t?`relaunching…`:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(R,{name:`restart_alt`,className:`ms-sm`}),` v`,r,` ready — relaunch`]})})}function qx(){let e=be();return(0,I.jsxs)(`button`,{type:`button`,className:P(`expert-toggle inline-flex cursor-pointer items-center gap-[7px] rounded-full border-0 bg-transparent px-2 py-1 font-mono text-2xs tracking-[0.5px] transition-colors hover:text-fg`,e?`text-fg`:`text-fg-2`),title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>ye(!e),children:[(0,I.jsx)(`span`,{className:P(`relative h-[15px] w-[26px] rounded-full transition-colors`,e?`bg-accent`:`bg-fg/14`),children:(0,I.jsx)(`span`,{className:P(`absolute top-0.5 size-[11px] rounded-full transition-[left,background-color]`,e?`left-[13px] bg-on-accent`:`left-0.5 bg-surface`)})}),(0,I.jsx)(`span`,{className:`max-[640px]:hidden`,children:`expert`})]})}var Jx={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`,task_woken:`view_kanban`,task_wake_failed:`view_kanban`},Yx=`kw.notif.toast.dismissed`;function Xx(){let[e,t]=(0,v.useState)(!1),n=N(`notifications.list`,{},{interval:5e3}),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(Yx)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=(c??n)?.items??[],p=Lt()??[],m=new Set(p.map(e=>e.notificationId).filter(Boolean)),h=f.filter(e=>e.kind!==`approval`&&!m.has(e.id)),g=h.filter(e=>!e.readAt).length,_=p.length;(0,v.useEffect)(()=>oe(p.length),[p.length]),(0,v.useEffect)(()=>{if(n){if(!s.current)s.current=new Set(f.map(e=>e.id));else for(let e of f)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),S(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`[data-bell]`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function y(e){try{let t=await e;if(!t.ok)return;let n=t.data;l(`items`in n?n:{items:[],unread:0})}catch{}}let b=e=>y(A.request(`notifications.read`,{body:{ids:e}})),x=()=>y(A.request(`notifications.clear`));function S(e){t(!1),e.readAt||b([e.id]),H(e.href)}async function C(e){d(e.id);try{let n=await A.request(`notifications.diagnose`,{id:e.id});n.ok?(t(!1),H(n.data.href)):n.error&&alert(n.error)}catch{}d(null)}async function w(){typeof Notification<`u`&&i(await Notification.requestPermission())}function T(){o(!0);try{localStorage.setItem(Yx,`1`)}catch{}}let E=r==="default"&&!a;return(0,I.jsxs)(`span`,{className:`relative inline-flex`,"data-bell":``,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(`relative grid size-8 cursor-pointer place-items-center rounded-full border-0 bg-transparent transition-colors hover:bg-surface-2 hover:text-fg`,_?`text-fg`:`text-fg-2`),title:_?`${_} thing${_===1?``:`s`} waiting for you`:g?`${g} update${g===1?``:`s`}`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,I.jsx)(R,{name:_?`notifications_active`:`notifications`}),g>0&&(0,I.jsx)(`span`,{className:`absolute top-1.5 right-1.5 size-[7px] rounded-full bg-accent`})]}),e&&(0,I.jsxs)(`div`,{className:`notif-pop absolute right-0 top-[calc(100%+8px)] z-50 flex max-h-[min(80dvh,640px)] w-[min(460px,92vw)] flex-col overflow-hidden rounded-card border border-line bg-surface shadow-pop`,role:`menu`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-line px-4 py-2`,children:[(0,I.jsx)(nt,{className:`text-fg`,children:`notifications`}),(0,I.jsx)(`span`,{className:`flex-1`}),g>0&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:()=>void b(h.filter(e=>!e.readAt).map(e=>e.id)),children:`mark updates read`}),f.length>0&&(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:()=>void x(),children:`clear`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain pb-1.5`,children:[E&&(0,I.jsxs)(`div`,{className:`m-2 flex flex-col gap-2 rounded-control bg-surface-2 p-3 text-sm`,children:[(0,I.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,I.jsxs)(`span`,{className:`flex gap-2`,children:[(0,I.jsx)(G,{variant:`primary`,size:`sm`,onClick:()=>void w(),children:`enable`}),(0,I.jsx)(G,{variant:`quiet`,size:`sm`,onClick:T,children:`not now`})]})]}),r===`denied`&&(0,I.jsx)(`p`,{className:`m-0 px-4 pt-2 text-xs text-fg-2`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),(0,I.jsx)(rt,{title:`needs you`,count:p.length||void 0,className:`px-1.5 pt-1.5`,children:p.length===0?(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`nothing is waiting for you`}):Qx(p).map(([e,n])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`notif-owner px-2.5 pb-0.5 pt-2 text-xs font-semibold text-fg`,children:e}),n.map(e=>{let n=e.notificationId?f.find(t=>t.id===e.notificationId):void 0;return(0,I.jsx)(mt,{className:`notif-row need`,onClick:()=>{t(!1),Gt(e)},leading:(0,I.jsx)(R,{name:zt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${Bt(e.kind)}${e.chatTitle?` · in ${e.chatTitle}`:``}`,meta:W(e.since),actionsAlways:!0,actions:n?.diagnose?(0,I.jsx)(Zx,{busy:u===n.id,onClick:()=>void C(n)}):void 0},e.id)})]},e))}),(0,I.jsx)(rt,{title:`updates`,className:`px-1.5 pt-1.5`,children:h.length===0?(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-fg-2`,children:`no updates`}):h.slice(0,50).map(e=>(0,I.jsx)(mt,{className:P(`notif-row`,!e.readAt&&`bg-accent/5`),onClick:()=>S(e),leading:(0,I.jsx)(R,{name:Jx[e.kind],className:P(`ms-sm`,e.kind.endsWith(`failed`)?`text-bad`:e.kind.endsWith(`done`)?`text-ok`:``)}),title:e.title,sub:e.body,meta:W(e.at),actionsAlways:!0,actions:e.diagnose?(0,I.jsx)(Zx,{busy:u===e.id,onClick:()=>void C(e)}):void 0},e.id))})]})]})]})}function Zx({busy:e,onClick:t}){return(0,I.jsx)(G,{variant:`secondary`,size:`sm`,icon:`troubleshoot`,busy:e,title:`Open a chat that finds the cause and proposes the fix`,onClick:e=>{e.stopPropagation(),t()},children:e?`starting…`:`diagnose`})}function Qx(e){let t=new Map;for(let n of e){let e=Vt(n.owner);t.set(e,[...t.get(e)??[],n])}return[...t.entries()]}function $x({onClose:e}){let t=be(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``);return(0,v.useEffect)(()=>{A.call(`meta.get`).then(e=>s(e.version)).catch(()=>{}),t&&(A.call(`runs.list`).then(r).catch(()=>{}),A.call(`workflows.list`).then(a).catch(()=>{}))},[t]),(0,I.jsxs)(`div`,{className:`ws-menu mt-1.5 flex flex-col gap-0.5 border-t border-line px-1.5 pb-1 pt-2`,children:[(0,I.jsx)(eS,{label:`Theme`,children:(0,I.jsx)(aS,{})}),(0,I.jsx)(`div`,{className:`flex gap-1 px-1`,children:(0,I.jsx)(G,{variant:`quiet`,size:`sm`,icon:`delete`,href:`/trash`,onClick:e,children:`trash`})}),t&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(nt,{children:`Workflows`}),` `,i?`${i.workflows.length} discovered`:`…`,` `,(0,I.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:i?.root,children:i?.root??``})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(nt,{children:`Runs`}),` `,n?`${n.runs.length} total`:`…`,` `,(0,I.jsx)(`code`,{className:`block break-all text-2xs text-fg-2`,title:n?.outputDir,children:n?.outputDir??``})]})]}),(0,I.jsx)(eS,{label:(0,I.jsx)(`span`,{className:`font-mono`,children:o?`kraftwerk ${o}`:`…`}),children:(0,I.jsx)(nS,{})})]})}function eS({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2.5 py-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm text-fg-2`,children:e}),t]})}function tS(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function nS(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await A.call(`update.check`);if(!e.latest)throw Error();r(e),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await A.call(`update.status`);if(!e)return;a(t)}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await A.request(`update.start`,{body:{version:n.latest}});e.ok?a(e.data):s(e.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,I.jsxs)(`span`,{className:P(rS,`basis-full flex-wrap`),children:[(0,I.jsx)(R,{name:`progress_activity`,className:`ms-sm`}),` installing v`,n.latest,`…`,e&&(0,I.jsx)(`code`,{className:`max-w-full truncate text-2xs text-fg-2`,title:i.log.join(`
484
+ `),children:e})]}):i.state===`done`?(0,I.jsxs)(`span`,{className:P(rS,iS),children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,I.jsx)(G,{size:`sm`,icon:`restart_alt`,busy:c,onClick:()=>{l(!0),Gx(n.latest)},children:c?`relaunching…`:`relaunch`}):(0,I.jsxs)(I.Fragment,{children:[`restart `,(0,I.jsx)(`code`,{children:`kraftwerk ui`}),` to use it`]})]}):(0,I.jsxs)(`span`,{className:P(rS,`basis-full flex-wrap text-bad`),title:i.log.join(`
485
+ `),children:[(0,I.jsx)(R,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,I.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?tS(n.current,n.latest)?(0,I.jsxs)(`span`,{className:P(rS,iS),children:[`v`,n.latest,` available —`,` `,o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`font-normal text-fg-2`,title:o,children:o}),` · `,(0,I.jsxs)(`code`,{className:`text-2xs`,children:[`npm i -g `,n.name,`@latest`]})]}):(0,I.jsx)(G,{size:`sm`,icon:`download`,onClick:()=>void f(),children:`update now`})]}):(0,I.jsxs)(`span`,{className:rS,children:[(0,I.jsx)(R,{name:`check`,className:`ms-sm text-ok`}),` up to date`]}):(0,I.jsx)(G,{size:`sm`,icon:e===`busy`||e===`err`?void 0:`sync`,disabled:e===`busy`,onClick:()=>void u(),children:e===`busy`?`checking…`:e===`err`?`npm unreachable — retry`:`check for updates`})}var rS=`inline-flex items-center gap-[5px] text-xs text-fg-2`,iS=`basis-full flex-wrap font-medium text-accent`;function aS(){return(0,I.jsx)(G,{size:`sm`,icon:`contrast`,onClick:()=>{let e=document.documentElement,t=e.dataset.theme===`light`?`dark`:`light`;e.dataset.theme=t;try{localStorage.setItem(`kw-theme`,t)}catch{}},children:`day / night`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(eb,{children:(0,I.jsx)(Px,{})})}));export{o as a,d as i,te as n,s as o,h as r,l as s,Vl as t};