@netnodeag/kraftwerk 0.81.0 → 0.83.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 (104) hide show
  1. package/README.md +227 -0
  2. package/dist/cli/boards.d.ts +2 -0
  3. package/dist/cli/boards.js +486 -0
  4. package/dist/cli/init.js +2 -0
  5. package/dist/cli/kraftwerk.js +6 -0
  6. package/dist/cli/presentations.d.ts +2 -0
  7. package/dist/cli/presentations.js +261 -0
  8. package/dist/client/routes.d.ts +32 -0
  9. package/dist/client/routes.js +32 -0
  10. package/dist/config.d.ts +35 -0
  11. package/dist/config.js +33 -2
  12. package/dist/core/attention.d.ts +2 -2
  13. package/dist/core/attention.js +22 -2
  14. package/dist/core/board-wake.d.ts +21 -0
  15. package/dist/core/board-wake.js +221 -0
  16. package/dist/core/boards.d.ts +269 -0
  17. package/dist/core/boards.js +969 -0
  18. package/dist/core/chat/acp.d.ts +1 -1
  19. package/dist/core/chat/acp.js +2 -1
  20. package/dist/core/chat/backend.d.ts +11 -0
  21. package/dist/core/chat/backend.js +9 -1
  22. package/dist/core/chat/context.js +25 -4
  23. package/dist/core/chat/pi.d.ts +1 -1
  24. package/dist/core/chat/pi.js +2 -1
  25. package/dist/core/chat/seats.js +3 -2
  26. package/dist/core/chat/sessions.d.ts +2 -0
  27. package/dist/core/chat/sessions.js +1 -0
  28. package/dist/core/chat/state.js +1 -1
  29. package/dist/core/chat/types.d.ts +11 -1
  30. package/dist/core/files.d.ts +1 -1
  31. package/dist/core/files.js +19 -1
  32. package/dist/core/git.js +5 -1
  33. package/dist/core/notifications.d.ts +1 -1
  34. package/dist/core/presentations/browser.d.ts +43 -0
  35. package/dist/core/presentations/browser.js +53 -0
  36. package/dist/core/presentations/builtin.d.ts +3 -0
  37. package/dist/core/presentations/builtin.js +142 -0
  38. package/dist/core/presentations/chart.d.ts +34 -0
  39. package/dist/core/presentations/chart.js +159 -0
  40. package/dist/core/presentations/deck.d.ts +63 -0
  41. package/dist/core/presentations/deck.js +198 -0
  42. package/dist/core/presentations/export.d.ts +21 -0
  43. package/dist/core/presentations/export.js +75 -0
  44. package/dist/core/presentations/html.d.ts +135 -0
  45. package/dist/core/presentations/html.js +389 -0
  46. package/dist/core/presentations/index.d.ts +252 -0
  47. package/dist/core/presentations/index.js +753 -0
  48. package/dist/core/presentations/layout.d.ts +47 -0
  49. package/dist/core/presentations/layout.js +147 -0
  50. package/dist/core/presentations/markdown.d.ts +49 -0
  51. package/dist/core/presentations/markdown.js +158 -0
  52. package/dist/core/presentations/merge.d.ts +26 -0
  53. package/dist/core/presentations/merge.js +28 -0
  54. package/dist/core/presentations/presence.d.ts +31 -0
  55. package/dist/core/presentations/presence.js +131 -0
  56. package/dist/core/presentations/render.d.ts +33 -0
  57. package/dist/core/presentations/render.js +318 -0
  58. package/dist/core/presentations/slots.d.ts +33 -0
  59. package/dist/core/presentations/slots.js +114 -0
  60. package/dist/core/presentations/template.d.ts +253 -0
  61. package/dist/core/presentations/template.js +141 -0
  62. package/dist/core/presentations/versions.d.ts +30 -0
  63. package/dist/core/presentations/versions.js +75 -0
  64. package/dist/core/refs.d.ts +1 -1
  65. package/dist/core/refs.js +33 -1
  66. package/dist/core/search.d.ts +22 -0
  67. package/dist/core/search.js +25 -0
  68. package/dist/core/settings.d.ts +4 -0
  69. package/dist/core/settings.js +24 -1
  70. package/dist/core/trash.d.ts +1 -1
  71. package/dist/server/api/boards.d.ts +105 -0
  72. package/dist/server/api/boards.js +160 -0
  73. package/dist/server/api/chats.d.ts +2 -0
  74. package/dist/server/api/chats.js +9 -3
  75. package/dist/server/api/index.d.ts +167 -3
  76. package/dist/server/api/index.js +4 -0
  77. package/dist/server/api/presentations.d.ts +66 -0
  78. package/dist/server/api/presentations.js +185 -0
  79. package/dist/server/api/socket.js +24 -1
  80. package/dist/server/api/workspace.d.ts +10 -0
  81. package/dist/server/api/workspace.js +4 -0
  82. package/dist/server/push.js +1 -1
  83. package/dist/server/server.js +3 -0
  84. package/package.json +6 -2
  85. package/schema/kraftwerk.schema.json +57 -0
  86. package/web/dist/assets/{dist-Ba6WSVOB.js → dist-5-ibIscm.js} +1 -1
  87. package/web/dist/assets/{dist-ENZYo2jZ.js → dist-5lgY5B-M.js} +1 -1
  88. package/web/dist/assets/{dist-BiU4F98O.js → dist-BJaPgnhj.js} +1 -1
  89. package/web/dist/assets/{dist-Dy1SvhKC.js → dist-Bar1_NBq.js} +1 -1
  90. package/web/dist/assets/{dist-AhnSw4hy.js → dist-BxCxboU8.js} +1 -1
  91. package/web/dist/assets/dist-CDitSY16.js +1 -0
  92. package/web/dist/assets/{dist-FfKYtQxT.js → dist-CRXT8IL6.js} +1 -1
  93. package/web/dist/assets/{dist-BK0VhAPQ.js → dist-CXRjiHpl.js} +1 -1
  94. package/web/dist/assets/{dist-Dx3aajX1.js → dist-CpnB7MfK.js} +1 -1
  95. package/web/dist/assets/{dist-8IOFzZx-.js → dist-D1VK1YdB.js} +1 -1
  96. package/web/dist/assets/{dist-cewmjxFi.js → dist-D52LvyO8.js} +1 -1
  97. package/web/dist/assets/{editor-CZMrhTTL.css → editor-C0_Snnzk.css} +1 -1
  98. package/web/dist/assets/{editor-CaRa1NMC.js → editor-HCNTXWWs.js} +3 -3
  99. package/web/dist/assets/index-Dnlu16AL.css +2 -0
  100. package/web/dist/assets/index-kwWnQOhD.js +473 -0
  101. package/web/dist/index.html +2 -2
  102. package/web/dist/assets/dist-lgUK2Fjt.js +0 -1
  103. package/web/dist/assets/index-Dpzux3OC.js +0 -231
  104. package/web/dist/assets/index-Dvt-vE1h.css +0 -2
@@ -0,0 +1,473 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-HCNTXWWs.js","assets/dist-CYzOYk_e.js","assets/dist-D1VK1YdB.js","assets/dist-5lgY5B-M.js","assets/dist-D52LvyO8.js","assets/dist-BdZ5cNRp.js","assets/editor-C0_Snnzk.css"])))=>i.map(i=>d[i]);
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),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 j=/\/+/g;function ee(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===``?`.`+ee(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),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(j,`$&/`)+`/`)+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+ee(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+ee(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 L(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(L.bind(null,e))}var R={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=R,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=L,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.0`})),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&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),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.0`})),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`),j=Symbol.for(`react.fragment`),ee=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`),L=Symbol.for(`react.memo`),R=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 j:return`Fragment`;case M:return`Profiler`;case ee: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 L:return t=e.displayName||null,t===null?ue(e.type)||`Memo`:t;case R:t=e._payload,e=e._init;try{return ue(e(t))}catch{}}return null}var z=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,de={pending:!1,data:null,method:null,action:null},H=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=H[fe],H[fe]=null,fe--)}function U(e,t){fe++,H[fe]=e.current,e.current=t}var he=pe(null),ge=pe(null),_e=pe(null),ve=pe(null);function ye(e,t){switch(U(_e,t),U(ge,e),U(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(he),U(he,e)}function be(){me(he),me(ge),me(_e)}function xe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,U(ve,e)),t=he.current;var n=dp(t,e.type);t!==n&&(U(ge,e),U(he,n))}function Se(e){ge.current===e&&(me(he),me(ge)),ve.current===e&&(me(ve),sh._currentValue=de)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+Ce+e+we}var Ee=!1;function De(e,t){if(!e||Ee)return``;Ee=!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(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
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{Ee=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Te(n):``}function Oe(e,t){switch(e.tag){case 26:case 27:case 5:return Te(e.type);case 16:return Te(`Lazy`);case 13:return e.child!==t&&t!==null?Te(`Suspense Fallback`):Te(`Suspense`);case 19:return Te(`SuspenseList`);case 0:case 15:return De(e.type,!1);case 11:return De(e.type.render,!1);case 1:return De(e.type,!0);case 31:return Te(`Activity`);case 30:return Te(`ViewTransition`);default:return``}}function ke(e){try{var t=``,n=null;do t+=Oe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var Ae=Object.prototype.hasOwnProperty,je=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,Ne=t.unstable_shouldYield,Pe=t.unstable_requestPaint,Fe=t.unstable_now,Ie=t.unstable_getCurrentPriorityLevel,Le=t.unstable_ImmediatePriority,Re=t.unstable_UserBlockingPriority,ze=t.unstable_NormalPriority,Be=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,He=t.log,Ue=t.unstable_setDisableYieldValue,We=null,Ge=null;function Ke(e){if(typeof He==`function`&&Ue(e),Ge&&typeof Ge.setStrictMode==`function`)try{Ge.setStrictMode(We,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,W=262144,G=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 K(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 $e(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=G;return G<<=1,!(G&62914560)&&(G=4194304),e}function et(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function tt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function nt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-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 rt(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 it(e,t){var n=t&-t;return n=n&42?1:at(n),(n&(e.suspendedLanes|t))===0?n:0}function at(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 ot(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function st(){var e=V.p;return e===0?(e=window.event,e===void 0?32:Ch(e.type)):e}function ct(e,t){var n=V.p;try{return V.p=e,t()}finally{V.p=n}}var lt=Math.random().toString(36).slice(2),ut=`__reactFiber$`+lt,dt=`__reactProps$`+lt,ft=`__reactContainer$`+lt,Z=`__reactEvents$`+lt,pt=`__reactListeners$`+lt,mt=`__reactHandles$`+lt,ht=`__reactResources$`+lt,gt=`__reactMarker$`+lt,Q=`__reactLoad$`+lt;function _t(e){delete e[ut],delete e[dt],delete e[pt],delete e[mt]}function vt(e){var t;if(t=e[ut])return t;for(var n=e.parentNode;n;){if(t=n[ft]||n[ut]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=fm(e);e!==null;){if(n=e[ut])return n;e=fm(e)}return t}e=n,n=e.parentNode}return null}function $(e){if(e=e[ut]||e[ft]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function yt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function bt(e){var t=e[ht];return t||=e[ht]={hoistableStyles:new Map,hoistableScripts:new Map},t}function xt(e){e[gt]=!0}function St(e){e[Q]=void 0}var Ct=new Set,wt={};function Tt(e,t){Et(e,t),Et(e+`Capture`,t)}function Et(e,t){for(wt[e]=t,e=0;e<t.length;e++)Ct.add(t[e])}var Dt=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]*$`),Ot={},kt={};function At(e){return Ae.call(kt,e)?!0:Ae.call(Ot,e)?!1:Dt.test(e)?kt[e]=!0:(Ot[e]=!0,!1)}var jt=!1;function Mt(){var e=jt;return jt=!1,e}function Nt(e,t,n){if(At(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 Pt(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 Ft(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 It(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Lt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Rt(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 zt(e){if(!e._valueTracker){var t=Lt(e)?`checked`:`value`;e._valueTracker=Rt(e,t,``+e[t])}}function Bt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Lt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var Vt=/[\n"\\]/g;function Ht(e){return e.replace(Vt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Ut(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=``+It(t)):e.value!==``+It(t)&&(e.value=``+It(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Gt(e,It(n)):o===`number`&&e.value==t?Gt(e,It(e.value)):Gt(e,It(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=``+It(s):e.removeAttribute(`name`)}function Wt(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)){zt(e);return}n=n==null?``:``+It(n),t=t==null?n:``+It(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),zt(e)}function Gt(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function Kt(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=``+It(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 qt(e,t,n){if(t!=null&&(t=``+It(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+It(n)}function Jt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(z(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=It(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),zt(e)}function Yt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Xt=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 Zt(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||Xt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Qt(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]=``,jt=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(Zt(e,a,r),jt=!0)}else for(var o in t)t.hasOwnProperty(o)&&Zt(e,o,t[o])}function $t(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 en=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`]]),tn=/^[\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 nn(e){return tn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function rn(){}var an=null;function on(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sn=null,cn=null;function ln(e){var t=$(e);if(t&&(e=t.stateNode)){var n=e[dt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Ut(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="`+Ht(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[dt]||null;if(!a)throw Error(i(90));Ut(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&&Bt(r)}break a;case`textarea`:qt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Kt(e,!!n.multiple,t,!1)}}}var un=!1;function dn(e,t,n){if(un)return e(t,n);un=!0;try{return e(t)}finally{if(un=!1,(sn!==null||cn!==null)&&(Id(),sn&&(t=sn,e=cn,cn=sn=null,ln(t),e)))for(t=0;t<e.length;t++)ln(e[t])}}function fn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[dt]||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 pn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,mn=!1;if(pn)try{var hn={};Object.defineProperty(hn,"passive",{get:function(){mn=!0}}),window.addEventListener(`test`,hn,hn),window.removeEventListener(`test`,hn,hn)}catch{mn=!1}var gn=null,_n=null,vn=null;function yn(){if(vn)return vn;var e,t=_n,n=t.length,r,i=`value`in gn?gn.value:gn.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 vn=i.slice(e,1<r?1-r:void 0)}function bn(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 xn(){return!0}function Sn(){return!1}function Cn(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)?xn:Sn,this.isPropagationStopped=Sn,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=xn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=xn)},persist:function(){},isPersistent:xn}),t}var wn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Tn=Cn(wn),En=D({},wn,{view:0,detail:0}),Dn=Cn(En),On,kn,An,jn=D({},En,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hn,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!==An&&(An&&e.type===`mousemove`?(On=e.screenX-An.screenX,kn=e.screenY-An.screenY):kn=On=0,An=e),On)},movementY:function(e){return`movementY`in e?e.movementY:kn}}),Mn=Cn(jn),Nn=Cn(D({},jn,{dataTransfer:0})),Pn=Cn(D({},En,{relatedTarget:0})),Fn=Cn(D({},wn,{animationName:0,elapsedTime:0,pseudoElement:0})),In=Cn(D({},wn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Ln=Cn(D({},wn,{data:0})),Rn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},zn={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`},Bn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Vn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Bn[e])?!!t[e]:!1}function Hn(){return Vn}var Un=Cn(D({},En,{key:function(e){if(e.key){var t=Rn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=bn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?zn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hn,charCode:function(e){return e.type===`keypress`?bn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?bn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Wn=Cn(D({},jn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Gn=Cn(D({},wn,{submitter:0})),Kn=Cn(D({},En,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hn})),qn=Cn(D({},wn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Jn=Cn(D({},jn,{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})),Yn=Cn(D({},wn,{newState:0,oldState:0,source:0})),Xn=[9,13,27,32],Zn=pn&&`CompositionEvent`in window,Qn=null;pn&&`documentMode`in document&&(Qn=document.documentMode);var $n=pn&&`TextEvent`in window&&!Qn,er=pn&&(!Zn||Qn&&8<Qn&&11>=Qn),tr=` `,nr=!1;function rr(e,t){switch(e){case`keyup`:return Xn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function ir(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ar=!1;function or(e,t){switch(e){case`compositionend`:return ir(t);case`keypress`:return t.which===32?(nr=!0,tr):null;case`textInput`:return e=t.data,e===tr&&nr?null:e;default:return null}}function sr(e,t){if(ar)return e===`compositionend`||!Zn&&rr(e,t)?(e=yn(),vn=_n=gn=null,ar=!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 er&&t.locale!==`ko`?null:t.data;default:return null}}var cr={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 lr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!cr[e.type]:t===`textarea`}function ur(e,t,n,r){sn?cn?cn.push(r):cn=[r]:sn=r,t=qf(t,`onChange`),0<t.length&&(n=new Tn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var dr=null,fr=null;function pr(e){zf(e,0)}function mr(e){if(Bt(yt(e)))return e}function hr(e,t){if(e===`change`)return t}var gr=!1;if(pn){var _r;if(pn){var vr=`oninput`in document;if(!vr){var yr=document.createElement(`div`);yr.setAttribute(`oninput`,`return;`),vr=typeof yr.oninput==`function`}_r=vr}else _r=!1;gr=_r&&(!document.documentMode||9<document.documentMode)}function br(){dr&&(dr.detachEvent(`onpropertychange`,xr),fr=dr=null)}function xr(e){if(e.propertyName===`value`&&mr(fr)){var t=[];ur(t,fr,e,on(e)),dn(pr,t)}}function Sr(e,t,n){e===`focusin`?(br(),dr=t,fr=n,dr.attachEvent(`onpropertychange`,xr)):e===`focusout`&&br()}function Cr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return mr(fr)}function wr(e,t){if(e===`click`)return mr(t)}function Tr(e,t){if(e===`input`||e===`change`)return mr(t)}function Er(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Dr=typeof Object.is==`function`?Object.is:Er;function Or(e,t){if(Dr(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(!Ae.call(t,i)||!Dr(e[i],t[i]))return!1}return!0}function kr(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 Ar(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function jr(e,t){var n=Ar(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=Ar(n)}}function Mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Nr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=kr(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=kr(e.document)}return t}function Pr(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 Fr=pn&&`documentMode`in document&&11>=document.documentMode,Ir=null,Lr=null,Rr=null,zr=!1;function Br(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;zr||Ir==null||Ir!==kr(r)||(r=Ir,`selectionStart`in r&&Pr(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}),Rr&&Or(Rr,r)||(Rr=r,r=qf(Lr,`onSelect`),0<r.length&&(t=new Tn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Ir)))}function Vr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Hr={animationend:Vr(`Animation`,`AnimationEnd`),animationiteration:Vr(`Animation`,`AnimationIteration`),animationstart:Vr(`Animation`,`AnimationStart`),transitionrun:Vr(`Transition`,`TransitionRun`),transitionstart:Vr(`Transition`,`TransitionStart`),transitioncancel:Vr(`Transition`,`TransitionCancel`),transitionend:Vr(`Transition`,`TransitionEnd`)},Ur={},Wr={};pn&&(Wr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Hr.animationend.animation,delete Hr.animationiteration.animation,delete Hr.animationstart.animation),`TransitionEvent`in window||delete Hr.transitionend.transition);function Gr(e){if(Ur[e])return Ur[e];if(!Hr[e])return e;var t=Hr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Wr)return Ur[e]=t[n];return e}var Kr=Gr(`animationend`),qr=Gr(`animationiteration`),Jr=Gr(`animationstart`),Yr=Gr(`transitionrun`),Xr=Gr(`transitionstart`),Zr=Gr(`transitioncancel`),Qr=Gr(`transitionend`),$r=new Map,ei=`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(` `);ei.push(`scrollEnd`);function ti(e,t){$r.set(e,t),Tt(t,[e])}var ni=0;function ri(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=_d.identifierPrefix;var n=ni++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function ii(e){if(e==null||typeof e==`string`)return e;var t=null,n=Td;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 ai(e,t){return e=ii(e),t=ii(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var oi=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)},si=[],ci=0,li=0;function ui(){for(var e=ci,t=li=ci=0;t<e;){var n=si[t];si[t++]=null;var r=si[t];si[t++]=null;var i=si[t];si[t++]=null;var a=si[t];if(si[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&&mi(n,i,a)}}function di(e,t,n,r){si[ci++]=e,si[ci++]=t,si[ci++]=n,si[ci++]=r,li|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function fi(e,t,n,r){return di(e,t,n,r),hi(e)}function pi(e,t){return di(e,null,null,t),hi(e)}function mi(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 hi(e){if(50<Ed)throw Ed=0,Dd=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var gi={};function _i(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 vi(e,t,n,r){return new _i(e,t,n,r)}function yi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bi(e,t){var n=e.alternate;return n===null?(n=vi(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 xi(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 Si(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)yi(r)&&(s=1);else if(typeof r==`string`)s=qm(e,n,he.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ne:return e=vi(31,n,t,a),e.elementType=ne,e.lanes=o,e;case j:return Ci(n.children,a,o,t);case ee:s=8,a|=24;break;case M:return e=vi(12,n,t,a|2),e.elementType=M,e.lanes=o,e;case te:return e=vi(13,n,t,a),e.elementType=te,e.lanes=o,e;case I:return e=vi(19,n,t,a),e.elementType=I,e.lanes=o,e;case re:case ae:return e=a|32,e=vi(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 L:s=14;break a;case R:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=vi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Ci(e,t,n,r){return e=vi(7,e,r,t),e.lanes=n,e}function wi(e,t,n){return e=vi(6,e,null,t),e.lanes=n,e}function Ti(e){var t=vi(18,null,null,0);return t.stateNode=e,t}function Ei(e,t,n){return t=vi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Di=new WeakMap;function Oi(e,t){if(typeof e==`object`&&e){var n=Di.get(e);return n===void 0?(t={value:e,source:t,stack:ke(t)},Di.set(e,t),t):n}return{value:e,source:t,stack:ke(t)}}var ki=[],Ai=0,ji=null,Mi=0,Ni=[],Pi=0,Fi=null,Ii=1,Li=``;function Ri(e,t){ki[Ai++]=Mi,ki[Ai++]=ji,ji=e,Mi=t}function zi(e,t,n){Ni[Pi++]=Ii,Ni[Pi++]=Li,Ni[Pi++]=Fi,Fi=e;var r=Ii;e=Li;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,Ii=1<<32-qe(t)+i|n<<i|r,Li=a+e}else Ii=1<<a|n<<i|r,Li=e}function Bi(e){e.return!==null&&(Ri(e,1),zi(e,1,0))}function Vi(e){for(;e===ji;)ji=ki[--Ai],ki[Ai]=null,Mi=ki[--Ai],ki[Ai]=null;for(;e===Fi;)Fi=Ni[--Pi],Ni[Pi]=null,Li=Ni[--Pi],Ni[Pi]=null,Ii=Ni[--Pi],Ni[Pi]=null}function Hi(e,t){Ni[Pi++]=Ii,Ni[Pi++]=Li,Ni[Pi++]=Fi,Ii=t.id,Li=t.overflow,Fi=e}var Ui=null,Wi=null,Gi=!1,Ki=null,qi=!1,Ji=Error(i(519));function Yi(e){throw ta(Oi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ji}function Xi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ut]=e,t[dt]=r,n){case`dialog`:Bf(`cancel`,t),Bf(`close`,t);break;case`iframe`:case`object`:case`embed`:Bf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Lf.length;n++)Bf(Lf[n],t);break;case`source`:Bf(`error`,t);break;case`img`:case`image`:case`link`:Bf(`error`,t),Bf(`load`,t);break;case`details`:Bf(`toggle`,t);break;case`input`:Bf(`invalid`,t),Wt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Bf(`invalid`,t);break;case`textarea`:Bf(`invalid`,t),Jt(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||$f(t.textContent,n)?(r.popover!=null&&(Bf(`beforetoggle`,t),Bf(`toggle`,t)),r.onScroll!=null&&Bf(`scroll`,t),r.onScrollEnd!=null&&Bf(`scrollend`,t),r.onClick!=null&&(t.onclick=rn),t=!0):t=!1,t||Yi(e,!0)}function Zi(e){for(Ui=e.return;Ui;)switch(Ui.tag){case 5:case 31:case 13:qi=!1;return;case 27:case 3:qi=!0;return;default:Ui=Ui.return}}function Qi(e){if(e!==Ui)return!1;if(!Gi)return Zi(e),Gi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||pp(e.type,e.memoizedProps)),n=!n),n&&Wi&&Yi(e),Zi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Wi=dm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Wi=dm(e)}else t===27?(t=Wi,Sp(e.type)?(e=um,um=null,Wi=e):Wi=t):Wi=Ui?lm(e.stateNode.nextSibling):null;return!0}function $i(){Wi=Ui=null,Gi=!1}function ea(){var e=Ki;return e!==null&&(ld===null?ld=e:ld.push.apply(ld,e),Ki=null),e}function ta(e){Ki===null?Ki=[e]:Ki.push(e)}var na=pe(null),ra=null,ia=null;function aa(e,t,n){U(na,t._currentValue),t._currentValue=n}function oa(e){e._currentValue=na.current,me(na)}function sa(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 ca(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),sa(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),sa(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),sa(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 la(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;Dr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ve.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sh]:e.push(sh))}a=a.return}return e!==null&&ca(t,e,n,r),t.flags|=262144,e!==null}function ua(e){for(e=e.firstContext;e!==null;){if(!Dr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function da(e){ra=e,ia=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function fa(e){return ma(ra,e)}function pa(e,t){return ra===null&&da(e),ma(e,t)}function ma(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ia===null){if(e===null)throw Error(i(308));ia=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ia=ia.next=t;return n}var ha=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()})}},ga=t.unstable_scheduleCallback,_a=t.unstable_NormalPriority,va={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ya(){return{controller:new ha,data:new Map,refCount:0}}function ba(e){e.refCount--,e.refCount===0&&ga(_a,function(){e.controller.abort()})}function xa(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 Sa=null;function Ca(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var wa=null,Ta=0,Ea=0,Da=null;function Oa(e,t){if(wa===null){var n=wa=[];Ta=0,Ea=Mf(),Da={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ta++,t.then(ka,ka),t}function ka(){if(--Ta===0&&(Sa=null,wa!==null)){Da!==null&&(Da.status=`fulfilled`);var e=wa;wa=null,Ea=0,Da=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Aa(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 ja=B.S;B.S=function(e,t){if(fd=Fe(),typeof t==`object`&&t&&typeof t.then==`function`&&Oa(e,t),Sa!==null)for(var n=vf;n!==null;)xa(n,Sa),n=n.next;if(n=e.types,n!==null){for(var r=vf;r!==null;)xa(r,n),r=r.next;if(Ea!==0){r=Sa,r===null&&(r=Sa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}ja!==null&&ja(e,t)};var Ma=pe(null);function Na(){var e=Ma.current;return e===null?qu.pooledCache:e}function Pa(e,t){t===null?U(Ma,Ma.current):U(Ma,t.pool)}function Fa(){var e=Na();return e===null?null:{parent:va._currentValue,pool:e}}var Ia=Error(i(460)),La=Error(i(474)),Ra=Error(i(542)),za={then:function(){}};function Ba(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Va(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(rn,rn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ga(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(rn,rn);else{if(e=qu,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,Ga(e),e}throw Ua=t,Ia}}function Ha(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ua=e,Ia):e}}var Ua=null;function Wa(){if(Ua===null)throw Error(i(459));var e=Ua;return Ua=null,e}function Ga(e){if(e===Ia||e===Ra)throw Error(i(483))}var Ka=null,qa=0;function Ja(e){var t=qa;return qa+=1,Ka===null&&(Ka=[]),Va(Ka,e,t)}function Ya(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Xa(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 Za(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=bi(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=wi(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===j?(e=d(e,t,n.props.children,r,n.key),Ya(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===R&&Ha(i)===t.type)?(t=a(t,n.props),Ya(t,n),t.return=e,t):(t=Si(n.type,n.key,n.props,null,e.mode,r),Ya(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=Ei(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=Ci(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=wi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Si(t.type,t.key,t.props,null,e.mode,n),Ya(n,t),n.return=e,n;case A:return t=Ei(t,e.mode,n),t.return=e,t;case R:return t=Ha(t),f(e,t,n)}if(z(t)||ce(t))return t=Ci(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ja(t),n);if(t.$$typeof===P)return f(e,pa(e,t),n);Xa(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 R:return n=Ha(n),p(e,t,n,r)}if(z(n)||ce(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ja(n),r);if(n.$$typeof===P)return p(e,t,pa(e,n),r);Xa(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 R:return r=Ha(r),m(e,t,n,r,i)}if(z(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,Ja(r),i);if(r.$$typeof===P)return m(e,t,n,pa(t,r),i);Xa(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),Gi&&Ri(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 Gi&&Ri(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)}),Gi&&Ri(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),Gi&&Ri(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 Gi&&Ri(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)}),Gi&&Ri(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===j&&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===j){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),Ya(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===R&&Ha(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ya(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=Ci(o.props.children,e.mode,c,o.key),Ya(c,o),c.return=e,e=c):(c=Si(o.type,o.key,o.props,null,e.mode,c),Ya(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=Ei(o,e.mode,c),c.return=e,e=c}return s(e);case R:return o=Ha(o),_(e,r,o,c)}if(z(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,Ja(o),c);if(o.$$typeof===P)return _(e,r,pa(e,o),c);Xa(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=wi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{qa=0;var i=_(e,t,n,r);return Ka=null,i}catch(t){if(t===Ia||t===Ra)throw t;var a=vi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Qa=Za(!0),$a=Za(!1),eo=!1;function to(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function no(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 ro(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function io(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ku&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=hi(e),mi(e,null,n),t}return di(e,r,t,n),hi(e)}function ao(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,rt(e,n)}}function oo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var so=!1;function co(){if(so){var e=Da;if(e!==null)throw e}}function lo(e,t,n,r){so=!1;var i=e.updateQueue;eo=!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?(Yu&f)===f:(r&f)===f){f!==0&&f===Ea&&(so=!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:eo=!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),rd|=o,e.lanes=o,e.memoizedState=d}}function uo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function fo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)uo(n[e],t)}var po=pe(null),mo=pe(0);function ho(e,t){e=td,U(mo,e),U(po,t),td=e|t.baseLanes}function go(){U(mo,td),U(po,po.current)}function _o(){td=mo.current,me(po),me(mo)}var vo=pe(null),yo=null;function bo(e){var t=e.alternate;U(To,To.current&1),U(vo,e),yo===null&&(t===null||po.current!==null||t.memoizedState!==null)&&(yo=e)}function xo(e){U(To,To.current),U(vo,e),yo===null&&(yo=e)}function So(e){e.tag===22?(U(To,To.current),U(vo,e),yo===null&&(yo=e)):Co()}function Co(){U(To,To.current),U(vo,vo.current)}function wo(e){me(vo),yo===e&&(yo=null),me(To)}var To=pe(0);function Eo(e,t){U(vo,vo.current),U(To,t)}function Do(e){me(To),me(vo),yo===e&&(yo=null)}function Oo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||om(n)||sm(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 ko=0,Ao=null,jo=null,Mo=null,No=!1,Po=!1,Fo=!1,Io=0,Lo=0,Ro=null,zo=0;function Bo(){throw Error(i(321))}function Vo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Dr(e[n],t[n]))return!1;return!0}function Ho(e,t,n,r,i,a){return ko=a,Ao=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,B.H=e===null||e.memoizedState===null?ac:oc,Fo=!1,a=n(r,i),Fo=!1,Po&&(a=Wo(t,n,r,i)),Uo(e),a}function Uo(e){B.H=ic;var t=jo!==null&&jo.next!==null;if(ko=0,Mo=jo=Ao=null,No=!1,Lo=0,Ro=null,t)throw Error(i(300));e===null||Cc||(e=e.dependencies,e!==null&&ua(e)&&(Cc=!0))}function Wo(e,t,n,r){Ao=e;var a=0;do{if(Po&&(Ro=null),Lo=0,Po=!1,25<=a)throw Error(i(301));if(a+=1,Mo=jo=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=sc,o=t(n,r)}while(Po);return o}function Go(){var e=B.H,t=e.useState()[0];return t=typeof t.then==`function`?Qo(t):t,e=e.useState()[0],(jo===null?null:jo.memoizedState)!==e&&(Ao.flags|=1024),t}function Ko(){var e=Io!==0;return Io=0,e}function qo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Jo(e){if(No){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}No=!1}ko=0,Mo=jo=Ao=null,Po=!1,Lo=Io=0,Ro=null}function Yo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mo===null?Ao.memoizedState=Mo=e:Mo=Mo.next=e,Mo}function Xo(){if(jo===null){var e=Ao.alternate;e=e===null?null:e.memoizedState}else e=jo.next;var t=Mo===null?Ao.memoizedState:Mo.next;if(t!==null)Mo=t,jo=e;else{if(e===null)throw Ao.alternate===null?Error(i(467)):Error(i(310));jo=e,e={memoizedState:jo.memoizedState,baseState:jo.baseState,baseQueue:jo.baseQueue,queue:jo.queue,next:null},Mo===null?Ao.memoizedState=Mo=e:Mo=Mo.next=e}return Mo}function Zo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Qo(e){var t=Lo;return Lo+=1,Ro===null&&(Ro=[]),e=Va(Ro,e,t),t=Ao,(Mo===null?t.memoizedState:Mo.next)===null&&(t=t.alternate,B.H=t===null||t.memoizedState===null?ac:oc),e}function $o(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Qo(e);if(e.$$typeof===oe)return;if(e.$$typeof===P)return fa(e)}throw Error(i(438,String(e)))}function es(e){var t=null,n=Ao.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Ao.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=Zo(),Ao.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 ts(e,t){return typeof t==`function`?t(e):t}function ns(e){return rs(Xo(),jo,e)}function rs(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?(ko&f)===f:(Yu&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===Ea&&(d=!0);else if((ko&p)===p){u=u.next,p===Ea&&(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,Ao.lanes|=p,rd|=p;f=u.action,Fo&&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,Ao.lanes|=f,rd|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Dr(o,e.memoizedState)&&(Cc=!0,d&&(n=Da,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 is(e){var t=Xo(),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);Dr(o,t.memoizedState)||(Cc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function as(e,t,n){var r=Ao,a=Xo(),o=Gi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Dr((jo||a).memoizedState,n);if(s&&(a.memoizedState=n,Cc=!0),a=a.queue,As(cs.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Mo!==null&&!!(Mo.memoizedState.tag&1),Ts(e?9:8,{destroy:void 0},ss.bind(null,r,a,n,t),null),e){if(r.flags|=2048,qu===null)throw Error(i(349));o||ko&127||os(r,t,n)}return n}function os(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ao.updateQueue,t===null?(t=Zo(),Ao.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ss(e,t,n,r){t.value=n,t.getSnapshot=r,ls(t)&&us(e)}function cs(e,t,n){return n(function(){ls(t)&&us(e)})}function ls(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dr(e,n)}catch{return!0}}function us(e){var t=pi(e,2);t!==null&&jd(t,e,2)}function ds(e){var t=Yo();if(typeof e==`function`){var n=e;if(e=n(),Fo){Ke(!0);try{n()}finally{Ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:e},t}function fs(e,t,n,r){return e.baseState=n,rs(e,jo,typeof r==`function`?r:ts)}function ps(e,t,n,r,a){if(tc(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,ms(t,o)):(o.next=n.next,t.pending=n.next=o)}}function ms(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),hs(e,t,s)}catch(n){_s(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),B.T=a}}else try{a=n(i,r),hs(e,t,a)}catch(n){_s(e,t,n)}}function hs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){gs(e,t,n)},function(n){return _s(e,t,n)}):gs(e,t,n)}function gs(e,t,n){t.status=`fulfilled`,t.value=n,vs(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,ms(e,n)))}function _s(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,vs(t),t=t.next;while(t!==r)}e.action=null}function vs(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ys(e,t){return t}function bs(e,t){if(Gi){var n=qu.formState;if(n!==null){a:{var r=Ao;if(Gi){if(Wi){b:{for(var i=Wi,a=qi;i.nodeType!==8;){if(!a){i=null;break b}if(i=lm(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Wi=lm(i.nextSibling),r=i.data===`F!`;break a}}Yi(r)}r=!1}r&&(t=n[0])}}return n=Yo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ys,lastRenderedState:t},n.queue=r,n=Qs.bind(null,Ao,r),r.dispatch=n,r=ds(!1),a=ec.bind(null,Ao,!1,r.queue),r=Yo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ps.bind(null,Ao,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function xs(e){return Ss(Xo(),jo,e)}function Ss(e,t,n){if(t=rs(e,t,ys)[0],e=ns(ts)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Qo(t)}catch(e){throw e===Ia?Ra:e}else r=t;t=Xo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Ao.flags|=2048,Ts(9,{destroy:void 0},Cs.bind(null,i,n),null)),[r,a,e]}function Cs(e,t){e.action=t}function ws(e){var t=Xo(),n=jo;if(n!==null)return Ss(t,n,e);Xo(),t=t.memoizedState,n=Xo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Ts(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Ao.updateQueue,t===null&&(t=Zo(),Ao.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 Es(){return Xo().memoizedState}function Ds(e,t,n,r){var i=Yo();Ao.flags|=e,i.memoizedState=Ts(1|t,{destroy:void 0},n,r===void 0?null:r)}function Os(e,t,n,r){var i=Xo();r=r===void 0?null:r;var a=i.memoizedState.inst;jo!==null&&r!==null&&Vo(r,jo.memoizedState.deps)?i.memoizedState=Ts(t,a,n,r):(Ao.flags|=e,i.memoizedState=Ts(1|t,a,n,r))}function ks(e,t){Ds(8390656,8,e,t)}function As(e,t){Os(2048,8,e,t)}function js(e){Ao.flags|=4;var t=Ao.updateQueue;if(t===null)t=Zo(),Ao.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ms(e){var t=Xo().memoizedState;return js({ref:t,nextImpl:e}),function(){if(Ku&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ns(e,t){return Os(4,2,e,t)}function Ps(e,t){return Os(4,4,e,t)}function Fs(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 Is(e,t,n){n=n==null?null:n.concat([e]),Os(4,4,Fs.bind(null,t,e),n)}function Ls(){}function Rs(e,t){var n=Xo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Vo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function zs(e,t){var n=Xo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Vo(t,r[1]))return r[0];if(r=e(),Fo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r}function Bs(e,t,n){return n===void 0||ko&1073741824&&!(Yu&261930)?e.memoizedState=t:(e.memoizedState=n,e=kd(),Ao.lanes|=e,rd|=e,n)}function Vs(e,t,n,r){return Dr(n,t)?n:po.current===null?!(ko&106)||ko&1073741824&&!(Yu&261930)?(Cc=!0,e.memoizedState=n):(e=kd(),Ao.lanes|=e,rd|=e,t):(e=Bs(e,n,r),Dr(e,t)||(Cc=!0),e)}function Hs(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,ec(e,!1,t,n);try{var c=i(),l=B.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?$s(e,t,Aa(c,r),Od(e)):$s(e,t,r,Od(e))}catch(n){$s(e,t,{then:function(){},status:`rejected`,reason:n},Od())}finally{V.p=a,o!==null&&s.types!==null&&(o.types=s.types),B.T=o}}function Us(){}function Ws(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Gs(e).queue;Hs(e,a,t,de,n===null?Us:function(){return Ks(e),n(r)})}function Gs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:de},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ks(e){var t=Gs(e);t.next===null&&(t=e.alternate.memoizedState),$s(e,t.next.queue,{},Od())}function qs(){return fa(sh)}function Js(){return Xo().memoizedState}function Ys(){return Xo().memoizedState}function Xs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Od();e=ro(n);var r=io(t,e,n);r!==null&&(jd(r,t,n),ao(r,t,n)),t={cache:ya()},e.payload=t;return}t=t.return}}function Zs(e,t,n){var r=Od();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},tc(e)?nc(t,n):(n=fi(e,t,n,r),n!==null&&(jd(n,e,r),rc(n,t,r)))}function Qs(e,t,n){$s(e,t,n,Od())}function $s(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(tc(e))nc(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,Dr(s,o))return di(e,t,i,0),qu===null&&ui(),!1}catch{}if(n=fi(e,t,i,r),n!==null)return jd(n,e,r),rc(n,t,r),!0}return!1}function ec(e,t,n,r){if(r={lane:2,revertLane:Mf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},tc(e)){if(t)throw Error(i(479))}else t=fi(e,n,r,2),t!==null&&jd(t,e,2)}function tc(e){var t=e.alternate;return e===Ao||t!==null&&t===Ao}function nc(e,t){Po=No=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function rc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rt(e,n)}}var ic={readContext:fa,use:$o,useCallback:Bo,useContext:Bo,useEffect:Bo,useImperativeHandle:Bo,useLayoutEffect:Bo,useInsertionEffect:Bo,useMemo:Bo,useReducer:Bo,useRef:Bo,useState:Bo,useDebugValue:Bo,useDeferredValue:Bo,useTransition:Bo,useSyncExternalStore:Bo,useId:Bo,useHostTransitionStatus:Bo,useFormState:Bo,useActionState:Bo,useOptimistic:Bo,useMemoCache:Bo,useCacheRefresh:Bo,useEffectEvent:Bo},ac={readContext:fa,use:$o,useCallback:function(e,t){return Yo().memoizedState=[e,t===void 0?null:t],e},useContext:fa,useEffect:ks,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ds(4194308,4,Fs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ds(4194308,4,e,t)},useInsertionEffect:function(e,t){Ds(4,2,e,t)},useMemo:function(e,t){var n=Yo();t=t===void 0?null:t;var r=e();if(Fo){Ke(!0);try{e()}finally{Ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Yo();if(n!==void 0){var i=n(t);if(Fo){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=Zs.bind(null,Ao,e),[r.memoizedState,e]},useRef:function(e){var t=Yo();return e={current:e},t.memoizedState=e},useState:function(e){e=ds(e);var t=e.queue,n=Qs.bind(null,Ao,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ls,useDeferredValue:function(e,t){return Bs(Yo(),e,t)},useTransition:function(){var e=ds(!1);return e=Hs.bind(null,Ao,e.queue,!0,!1),Yo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ao,a=Yo();if(Gi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),qu===null)throw Error(i(349));Yu&127||os(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ks(cs.bind(null,r,o,e),[e]),r.flags|=2048,Ts(9,{destroy:void 0},ss.bind(null,r,o,n,t),null),n},useId:function(){var e=Yo(),t=qu.identifierPrefix;if(Gi){var n=Li,r=Ii;n=(r&~(1<<32-qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Io++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=zo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:qs,useFormState:bs,useActionState:bs,useOptimistic:function(e){var t=Yo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ec.bind(null,Ao,!0,n),n.dispatch=t,[e,t]},useMemoCache:es,useCacheRefresh:function(){return Yo().memoizedState=Xs.bind(null,Ao)},useEffectEvent:function(e){var t=Yo(),n={impl:e};return t.memoizedState=n,function(){if(Ku&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},oc={readContext:fa,use:$o,useCallback:Rs,useContext:fa,useEffect:As,useImperativeHandle:Is,useInsertionEffect:Ns,useLayoutEffect:Ps,useMemo:zs,useReducer:ns,useRef:Es,useState:function(){return ns(ts)},useDebugValue:Ls,useDeferredValue:function(e,t){return Vs(Xo(),jo.memoizedState,e,t)},useTransition:function(){var e=ns(ts)[0],t=Xo().memoizedState;return[typeof e==`boolean`?e:Qo(e),t]},useSyncExternalStore:as,useId:Js,useHostTransitionStatus:qs,useFormState:xs,useActionState:xs,useOptimistic:function(e,t){return fs(Xo(),jo,e,t)},useMemoCache:es,useCacheRefresh:Ys,useEffectEvent:Ms},sc={readContext:fa,use:$o,useCallback:Rs,useContext:fa,useEffect:As,useImperativeHandle:Is,useInsertionEffect:Ns,useLayoutEffect:Ps,useMemo:zs,useReducer:is,useRef:Es,useState:function(){return is(ts)},useDebugValue:Ls,useDeferredValue:function(e,t){var n=Xo();return jo===null?Bs(n,e,t):Vs(n,jo.memoizedState,e,t)},useTransition:function(){var e=is(ts)[0],t=Xo().memoizedState;return[typeof e==`boolean`?e:Qo(e),t]},useSyncExternalStore:as,useId:Js,useHostTransitionStatus:qs,useFormState:ws,useActionState:ws,useOptimistic:function(e,t){var n=Xo();return jo===null?(n.baseState=e,[e,n.queue.dispatch]):fs(n,jo,e,t)},useMemoCache:es,useCacheRefresh:Ys,useEffectEvent:Ms};function cc(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 lc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Od(),i=ro(r);i.payload=t,n!=null&&(i.callback=n),t=io(e,i,r),t!==null&&(jd(t,e,r),ao(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Od(),i=ro(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=io(e,i,r),t!==null&&(jd(t,e,r),ao(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Od(),r=ro(n);r.tag=2,t!=null&&(r.callback=t),t=io(e,r,n),t!==null&&(jd(t,e,n),ao(t,e,n))}};function uc(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?!Or(n,r)||!Or(i,a):!0}function dc(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&&lc.enqueueReplaceState(t,t.state,null)}function fc(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 pc(e){oi(e)}function mc(e){console.error(e)}function hc(e){oi(e)}function gc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function _c(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 vc(e,t,n){return n=ro(n),n.tag=3,n.payload={element:null},n.callback=function(){gc(e,t)},n}function yc(e){return e=ro(e),e.tag=3,e}function bc(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(){_c(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){_c(t,n,r),typeof i!=`function`&&(hd===null?hd=new Set([this]):hd.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function xc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&la(t,n,a,!0),n=vo.current,n!==null){switch(n.tag){case 31:case 13:case 19:return yo===null?Ud():n.alternate===null&&nd===0&&(nd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===za?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ff(e,r,a)),!1;case 22:return n.flags|=65536,r===za?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)),ff(e,r,a)),!1}throw Error(i(435,n.tag))}return ff(e,r,a),Ud(),!1}if(Gi)return t=vo.current,t===null?(r!==Ji&&(t=Error(i(423),{cause:r}),ta(Oi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Oi(r,n),a=vc(e.stateNode,r,a),oo(e,a),nd!==4&&(nd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ji&&(e=Error(i(422),{cause:r}),ta(Oi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Oi(o,n),cd===null?cd=[o]:cd.push(o),nd!==4&&(nd=2),t===null)return!0;r=Oi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=vc(n.stateNode,r,e),oo(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`&&(hd===null||!hd.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=yc(a),bc(a,e,n,r),oo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Sc=Error(i(461)),Cc=!1;function wc(e,t,n,r){t.child=e===null?$a(t,null,n,r):Qa(t,e.child,n,r)}function Tc(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 da(t),r=Ho(e,t,n,o,a,i),s=Ko(),e!==null&&!Cc?(qo(e,t,i),$c(e,t,i)):(Gi&&s&&Bi(t),t.flags|=1,wc(e,t,r,i),t.child)}function Ec(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!yi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Dc(e,t,a,r,i)):(e=Si(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!el(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Or:n,n(o,r)&&e.ref===t.ref)return $c(e,t,i)}return t.flags|=1,e=bi(a,r),e.ref=t.ref,e.return=t,t.child=e}function Dc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Or(a,r)&&e.ref===t.ref){if(Cc=!1,t.pendingProps=r=a,el(e,i))e.flags&131072&&(Cc=!0);else return t.lanes=e.lanes,$c(e,t,i)}}return Fc(e,t,n,r,i)}function Oc(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 Ac(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Pa(t,a===null?null:a.cachePool),a===null?go():ho(t,a),So(t);else return r=t.lanes=536870912,Ac(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Pa(t,null),go(),Co()):(Pa(t,a.cachePool),ho(t,a),Co(),t.memoizedState=null);return wc(e,t,i,n),t.child}function kc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Ac(e,t,n,r,i){var a=Na();return a=a===null?null:{parent:va._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Pa(t,null),go(),So(t),e!==null&&la(e,t,r,!0),t.childLanes=i,null}function jc(e,t){return t=Wc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Mc(e,t,n){return Qa(t,e.child,null,n),e=jc(t,t.pendingProps),e.flags|=2,wo(t),t.memoizedState=null,e}function Nc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(Gi){if(r.mode===`hidden`)return e=jc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},kc(null,e);if(xo(t),(e=Wi)?(e=am(e,qi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Fi===null?null:{id:Ii,overflow:Li},retryLane:536870912,hydrationErrors:null},n=Ti(e),n.return=t,t.child=n,Ui=t,Wi=null)):e=null,e===null)throw Yi(t);return t.lanes=536870912,null}return jc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(xo(t),a){if(t.flags&256)t.flags&=-257,t=Mc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Cc||la(e,t,n,!1),a=(n&e.childLanes)!==0,Cc||a){if(po.current===null){if(r=qu,r!==null&&(s=it(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,pi(e,s),jd(r,e,s),Sc;Ud()}t=Mc(e,t,n)}else e=o.treeContext,Wi=lm(s.nextSibling),Ui=t,Gi=!0,Ki=null,qi=!1,e!==null&&Hi(t,e),t=jc(t,r),t.flags|=134221824;return t}return e=bi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Pc(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 Fc(e,t,n,r,i){return da(t),n=Ho(e,t,n,r,void 0,i),r=Ko(),e!==null&&!Cc?(qo(e,t,i),$c(e,t,i)):(Gi&&r&&Bi(t),t.flags|=1,wc(e,t,n,i),t.child)}function Ic(e,t,n,r,i,a){return da(t),t.updateQueue=null,n=Wo(t,r,n,i),Uo(e),r=Ko(),e!==null&&!Cc?(qo(e,t,a),$c(e,t,a)):(Gi&&r&&Bi(t),t.flags|=1,wc(e,t,n,a),t.child)}function Lc(e,t,n,r,i){if(da(t),t.stateNode===null){var a=gi,o=n.contextType;typeof o==`object`&&o&&(a=fa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=lc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},to(t),o=n.contextType,a.context=typeof o==`object`&&o?fa(o):gi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(cc(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&&lc.enqueueReplaceState(a,a.state,null),lo(t,r,a,i),co(),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=fc(n,s);a.props=c;var l=a.context,u=n.contextType;o=gi,typeof u==`object`&&u&&(o=fa(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)&&dc(t,a,r,o),eo=!1;var f=t.memoizedState;a.state=f,lo(t,r,a,i),co(),l=t.memoizedState,s||f!==l||eo?(typeof d==`function`&&(cc(t,n,d,r),l=t.memoizedState),(c=eo||uc(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,no(e,t),o=t.memoizedProps,u=fc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=gi,typeof l==`object`&&l&&(c=fa(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)&&dc(t,a,r,c),eo=!1,f=t.memoizedState,a.state=f,lo(t,r,a,i),co();var p=t.memoizedState;o!==d||f!==p||eo||e!==null&&e.dependencies!==null&&ua(e.dependencies)?(typeof s==`function`&&(cc(t,n,s,r),p=t.memoizedState),(u=eo||uc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ua(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,Pc(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=Qa(t,e.child,null,i),t.child=Qa(t,null,n,i)):wc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=$c(e,t,i),e}function Rc(e,t,n,r){return $i(),t.flags|=256,wc(e,t,n,r),t.child}var zc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bc(e){return{baseLanes:e,cachePool:Fa()}}function Vc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=od),e}function Hc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(To.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(Gi){if(i?bo(t):Co(),(e=Wi)?(e=am(e,qi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Fi===null?null:{id:Ii,overflow:Li},retryLane:536870912,hydrationErrors:null},n=Ti(e),n.return=t,t.child=n,Ui=t,Wi=null)):e=null,e===null)throw Yi(t);return t.lanes=sm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Co(),i=t.mode,a=Wc({mode:`hidden`,children:a},i),r=Ci(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Bc(n),r.childLanes=Vc(e,o,n),t.memoizedState=zc,kc(null,r)):(bo(t),Uc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Kc(e,t,a,o,r,c,s,n)}return i?(Co(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=bi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Ci(i,a,n,null),i.flags|=2):i=bi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,kc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Bc(n):(a=i.cachePool,a===null?a=Fa():(s=va._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Vc(e,o,n),t.memoizedState=zc,kc(e.child,r)):(bo(t),n=e.child,e=n.sibling,n=bi(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 Uc(e,t){return t=Wc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Wc(e,t){return e=vi(22,e,null,t),e.lanes=0,e}function Gc(e,t,n){return Qa(t,e.child,null,n),e=Uc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Kc(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(bo(t),t.flags&=-257,Gc(e,t,c)):t.memoizedState===null?(Co(),o=a.fallback,s=t.mode,a=Wc({mode:`visible`,children:a.children},s),o=Ci(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,Qa(t,e.child,null,c),a=t.child,a.memoizedState=Bc(c),a.childLanes=Vc(e,r,c),t.memoizedState=zc,kc(null,a)):(Co(),t.child=e.child,t.flags|=128,null);if(bo(t),sm(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,ta({value:a,source:null,stack:null})),Gc(e,t,c)}if(Cc||la(e,t,c,!1),r=(c&e.childLanes)!==0,Cc||r){if(po.current!==null)return Gc(e,t,c);if(r=qu,r!==null&&(a=it(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,pi(e,a),jd(r,e,a),Sc;return om(o)||Ud(),Gc(e,t,c)}return om(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,Wi=lm(o.nextSibling),Ui=t,Gi=!0,Ki=null,qi=!1,e!==null&&Hi(t,e),t=Uc(t,a.children),t.flags|=134221824,t)}function qc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),sa(e.return,t,n)}function Jc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Oo(n)===null&&(t=e),e=e.sibling}return t}function Yc(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 Xc(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 Zc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=To.current;if(t.flags&128)return Eo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Eo(t,o),i===`backwards`&&e!==null?(Xc(e),wc(e,t,r,n),Xc(e)):wc(e,t,r,n),r=Gi?Mi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&qc(e,n,t);else if(e.tag===19)qc(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=Jc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,Xc(t)),Yc(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&&Oo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Yc(t,!0,n,null,a,r);break;case`together`:Yc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Jc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Yc(t,!1,i,n,a,r)}return t.child}function Qc(e,t,n){var r=t.pendingProps;return aa(t,t.type,r.value),wc(e,t,r.children,n),t.child}function $c(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),rd|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(la(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=bi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=bi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function el(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ua(e)))}function tl(e,t,n){switch(t.tag){case 3:ye(t,t.stateNode.containerInfo),aa(t,va,e.memoizedState.cache),$i();break;case 27:case 5:xe(t);break;case 4:ye(t,t.stateNode.containerInfo);break;case 10:aa(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,xo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return bo(t),t.flags|=128,null;r=la(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Hc(e,t,n):(bo(t),e=$c(e,t,n),e===null?null:e.sibling)}bo(t);break;case 19:if(t.flags&128)return Zc(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(la(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Zc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Eo(t,To.current),r)break;return null;case 22:return t.lanes=0,Oc(e,t,n,t.pendingProps);case 24:aa(t,va,e.memoizedState.cache)}return $c(e,t,n)}function nl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Cc=!0;else{if(!el(e,n)&&!(t.flags&128))return Cc=!1,tl(e,t,n);Cc=!!(e.flags&131072)}}else Cc=!1,Gi&&t.flags&1048576&&zi(t,Mi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ha(t.elementType),t.type=e,typeof e==`function`)yi(e)?(r=fc(e,r),t.tag=1,t=Lc(null,t,e,r,n)):(t.tag=0,t=Fc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===F){t.tag=11,t=Tc(null,t,e,r,n);break a}if(a===L){t.tag=14,t=Ec(null,t,e,r,n);break a}if(a===P){t.tag=10,t.type=e,t=Qc(null,t,n);break a}}throw t=ue(e)||e,Error(i(306,t,``))}}return t;case 0:return Fc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=fc(r,t.pendingProps),Lc(e,t,r,a,n);case 3:a:{if(ye(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,no(e,t),lo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,aa(t,va,r),r!==o.cache&&ca(t,[va],n,!0),co(),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=Rc(e,t,r,n);break a}if(r!==a){a=Oi(Error(i(424)),t),ta(a),t=Rc(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(Wi=lm(e.firstChild),Ui=t,Gi=!0,Ki=null,qi=!0,n=$a(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if($i(),r===a){t=$c(e,t,n);break a}wc(e,t,r,n)}t=t.child}return t;case 26:return Pc(e,t),e===null?(n=Nm(t.type,null,t.pendingProps,null))?t.memoizedState=n:Gi||(t.stateNode=fp(t.type,t.pendingProps,_e.current,t)):t.memoizedState=Nm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&Gi&&(r=t.stateNode=hm(t.type,t.pendingProps,_e.current),Ui=t,qi=!0,a=Wi,Sp(t.type)?(um=a,Wi=lm(r.firstChild)):Wi=a),wc(e,t,t.pendingProps.children,n),Pc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Gi&&((a=r=Wi)&&(r=rm(r,t.type,t.pendingProps,qi),r===null?a=!1:(t.stateNode=r,Ui=t,Wi=lm(r.firstChild),qi=!1,a=!0)),a||Yi(t)),xe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,pp(a,o)?r=null:s!==null&&pp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Ho(e,t,Go,null,null,n),sh._currentValue=a),Pc(e,t),wc(e,t,r,n),t.child;case 6:return e===null&&Gi&&((e=n=Wi)&&(n=im(n,t.pendingProps,qi),n===null?e=!1:(t.stateNode=n,Ui=t,Wi=null,e=!0)),e||Yi(t)),null;case 13:return Hc(e,t,n);case 4:return ye(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Qa(t,null,r,n):wc(e,t,r,n),t.child;case 11:return Tc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Pc(e,t),wc(e,t,r,n),t.child;case 8:return wc(e,t,t.pendingProps.children,n),t.child;case 12:return wc(e,t,t.pendingProps.children,n),t.child;case 10:return Qc(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,da(t),a=fa(a),r=r(a),t.flags|=1,wc(e,t,r,n),t.child;case 14:return Ec(e,t,t.type,t.pendingProps,n);case 15:return Dc(e,t,t.type,t.pendingProps,n);case 19:return Zc(e,t,n);case 31:return Nc(e,t,n);case 22:return Oc(e,t,n,t.pendingProps);case 24:return da(t),r=fa(va),e===null?(a=Na(),a===null&&(a=qu,o=ya(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},to(t),aa(t,va,a)):((e.lanes&n)!==0&&(no(e,t),lo(t,null,null,n),co()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,aa(t,va,r),r!==a.cache&&ca(t,[va],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),aa(t,va,r))),wc(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:Gi&&Bi(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Pc(e,t),wc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function rl(e){e.flags|=4}function il(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Jm(t,r):Jm(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(Bd())e.flags|=8192;else throw Ua=za,La}}else e.flags&=-16777217}function al(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Ym(t)){if(Bd())e.flags|=8192;else throw Ua=za,La}}function ol(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Y(),e.lanes|=t,sd|=t)}function sl(e,t){if(!Gi)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 cl(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 ll(e,t,n){var r=t.pendingProps;switch(Vi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cl(t),null;case 1:return cl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),oa(va),be(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Qi(t)?rl(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ea())),cl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(rl(t),o===null?(cl(t),il(t,a,null,r,n)):(cl(t),al(t,o))):o?o===e.memoizedState?(cl(t),t.flags&=-16777217):(rl(t),cl(t),al(t,o)):(e=e.memoizedProps,e!==r&&rl(t),cl(t),il(t,a,e,r,n)),null;case 27:if(Se(t),n=_e.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&rl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return cl(t),t.subtreeFlags&=-33554433,null}e=he.current,Qi(t)?Xi(t,e):(e=hm(a,r,n),t.stateNode=e,rl(t))}return cl(t),t.subtreeFlags&=-33554433,null;case 5:if(Se(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&rl(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return cl(t),t.subtreeFlags&=-33554433,null}if(o=he.current,Qi(t))Xi(t,o);else{var s=lp(_e.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[ut]=t,o[dt]=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(np(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&&rl(t)}}return cl(t),t.subtreeFlags&=-33554433,il(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&rl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=_e.current,Qi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ui,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ut]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||Yi(t,!0)}else e=lp(e).createTextNode(r),e[ut]=t,t.stateNode=e}return cl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Qi(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[ut]=t}else $i(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;cl(t),e=!1}else n=ea(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(wo(t),t):(wo(t),null);if(t.flags&128)throw Error(i(558))}return cl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Qi(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[ut]=t}else $i(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;cl(t),a=!1}else a=ea(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(wo(t),t):(wo(t),null)}return wo(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),ol(t,t.updateQueue),cl(t),null);case 4:return be(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,cl(t),null;case 10:return oa(t.type),cl(t),null;case 19:if(Do(t),r=t.memoizedState,r===null)return cl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)sl(r,!1);else{if(nd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Oo(e),o!==null){for(t.flags|=128,sl(r,!1),e=o.updateQueue,t.updateQueue=e,ol(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)xi(n,e),n=n.sibling;return Eo(t,To.current&1|2),Gi&&Ri(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Fe()>pd&&(t.flags|=128,a=!0,sl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Oo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,ol(t,e),sl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!Gi)return cl(t),null}else 2*Fe()-r.renderingStartTime>pd&&n!==536870912&&(t.flags|=128,a=!0,sl(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=Fe(),e.sibling=null,o=To.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||Gi?Eo(t,o):(n=o,U(vo,t),U(To,n),yo===null&&(yo=t)),Gi&&Ri(t,r.treeForkCount),e}return cl(t),null;case 22:case 23:return wo(t),_o(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(cl(t),t.subtreeFlags&6&&(t.flags|=8192)):cl(t),n=t.updateQueue,n!==null&&ol(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&&me(Ma),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),oa(va),cl(t),null;case 25:return null;case 30:return t.flags|=33554432,cl(t),null}throw Error(i(156,t.tag))}function ul(e,t){switch(Vi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return oa(va),be(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Se(t),null;case 31:if(t.memoizedState!==null){if(wo(t),t.alternate===null)throw Error(i(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(wo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Do(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 be(),null;case 10:return oa(t.type),null;case 22:case 23:return wo(t),_o(),e!==null&&me(Ma),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return oa(va),null;case 25:return null;default:return null}}function dl(e,t){switch(Vi(t),t.tag){case 3:oa(va),be();break;case 26:case 27:case 5:Se(t);break;case 4:be();break;case 31:t.memoizedState!==null&&wo(t);break;case 13:wo(t);break;case 19:Do(t);break;case 10:oa(t.type);break;case 22:case 23:wo(t),_o(),e!==null&&me(Ma);break;case 24:oa(va)}}function fl(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){df(t,t.return,e)}}function pl(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){df(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){df(t,t.return,e)}}function ml(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{fo(t,n)}catch(t){df(e,e.return,t)}}}function hl(e,t,n){n.props=fc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){df(e,t,n)}}function gl(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=ri(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);m(e.child,!1,Qp,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){df(e,t,n)}}function _l(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){df(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){df(e,t,n)}else n.current=null}}function vl(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++)em(e.stateNode,t[n])}function yl(e){for(var t=e.return;t!==null&&(Sl(t)&&em(e.stateNode,t.stateNode),!xl(t));)t=t.return}function bl(e){for(var t=e.return;t!==null&&(Sl(t)&&tm(e.stateNode,t.stateNode),!xl(t));)t=t.return}function xl(e){return e.tag===5||e.tag===3||e.tag===27}function Sl(e){return e&&e.tag===7&&e.stateNode!==null}function Cl(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){df(e,e.return,t)}}function wl(e,t,n){try{var r=e.stateNode;ip(r,e.type,n,t),r[dt]=t}catch(t){df(e,e.return,t)}}function Tl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Sp(e.type)||e.tag===4}function El(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Tl(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&&Sp(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 Dl(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=rn)),vl(e,r),jt=!0;else if(i!==4&&(i===27&&(vl(e,r),r=null,Sp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Dl(e,t,n,r),e=e.sibling;e!==null;)Dl(e,t,n,r),e=e.sibling}function Ol(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),vl(e,r),jt=!0;else if(i!==4&&(i===27&&(vl(e,r),r=null,Sp(e.type)&&(n=e.stateNode)),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){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);np(t,r,n),t[ut]=e,t[dt]=n}catch(t){df(e,e.return,t)}}var Al=!1,jl=null;function Ml(e){(e.tag===30||e.subtreeFlags&33554432)&&(Al=!0)}var Nl=null;function Pl(){var e=Nl;return Nl=null,e}var Fl=0;function Il(e,t,n,r,i){return Fl=0,Ll(e.child,t,n,r,i)}function Ll(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Op(o);r.push(s),s.view&&(a=!0)}else a||Op(o).view&&(a=!0);Al=!0,Tp(o,Fl===0?t:t+`_`+Fl,n),Fl++}else(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&i||Ll(e.child,t,n,r,i)&&(a=!0));e=e.sibling}return a}function Rl(e,t){for(;e!==null;)e.tag===5?Ep(e.stateNode,e.memoizedProps):(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&t||Rl(e.child,t)),e=e.sibling}function zl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(zl(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=ai(t.default,t.share),t!==`none`&&(Il(e,n,t,null,!1)||Rl(e.child,!1))}e=e.sibling}}function Bl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=ri(r,n),a=ai(r.default,n.paired?r.share:r.enter);a===`none`?zl(e):Il(e,i,a,null,!1)?(zl(e),n.paired||t||Ad(e,r.onEnter)):Rl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Bl(e,t),e=e.sibling;else zl(e)}function Vl(e){if(jl!==null&&jl.size!==0){var t=jl;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=ai(n.default,n.share);if(a!==`none`&&(Il(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Ad(e,n.onShare)):Rl(e.child,!1)),t.delete(r),t.size===0)break}}}Vl(e)}e=e.sibling}}}function Hl(e){if(e.tag===30){var t=e.memoizedProps,n=ri(t,e.stateNode),r=jl===null?void 0:jl.get(n),i=ai(t.default,r===void 0?t.exit:t.share);i!==`none`&&(Il(e,n,i,null,!1)?r===void 0?Ad(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,jl.delete(n),Ad(e,t.onShare)):Rl(e.child,!1)),jl!==null&&Vl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Hl(e),e=e.sibling;else jl!==null&&Vl(e)}function Ul(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=ri(t,e.stateNode);t=ai(t.default,t.update),e.flags&=-5,t!==`none`&&Il(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Ul(e);e=e.sibling}}function Wl(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,Rl(e.child,!1))}Wl(e)}e=e.sibling}}function Gl(e){if(e.tag===30)e.stateNode.paired=null,Rl(e.child,!1),Wl(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Gl(e),e=e.sibling;else Wl(e)}function Kl(e){for(e=e.child;e!==null;)e.tag===30?Rl(e.child,!1):e.subtreeFlags&33554432&&Kl(e),e=e.sibling}function ql(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Fl<a.length){var l=a[Fl],u=Op(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&&Tp(c,Fl===0?n:n+`_`+Fl,i),s&&e.flags&4||(Nl===null&&(Nl=[]),Nl.push(c,Fl===0?r:r+`_`+Fl,t.memoizedProps)),Fl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:ql(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Jl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=ri(n,r),a=ai(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(kp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Fl=0,i=ql(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Ad(e,n.onUpdate))}else e.subtreeFlags&33554432&&Jl(e,t);e=e.sibling}}var Yl=!1,Xl=!1,Zl=!1,Ql=!1,$l=typeof WeakSet==`function`?WeakSet:Set,eu=null,tu=!1,nu=!1,ru=!1,iu=!1;function au(e,t,n){if(e=e.containerInfo,sp=gh,e=Nr(e),Pr(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(cp={focusedElem:e,selectionRange:r},gh=!1,n=(n&335544064)===n,eu=t,t=n?9270:1024;eu!==null;){if(e=eu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Hl(r[a]);if(e.alternate===null&&e.flags&2)n&&Ml(e),ou(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Hl(r),ou(n);continue}if(r!==null&&r.memoizedState!==null){n&&Ml(e),ou(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,eu=r):(n&&Ul(e),ou(n))}}jl=null}function ou(e){for(;eu!==null;){var t=eu,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=fc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){df(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)nm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:nm(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=ri(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=ai(a.default,a.update),a!==`none`&&Il(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,eu=r;break}eu=t.return}}function su(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Du(e,n),r&4&&fl(5,n);break;case 1:if(Du(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){df(n,n.return,e)}else{var i=fc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){df(n,n.return,e)}}}r&64&&ml(n),r&512&&gl(n,n.return);break;case 3:if(Du(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{fo(e,t)}catch(e){df(n,n.return,e)}}break;case 27:t===null&&r&4&&kl(n);case 26:case 5:Du(e,n),t===null&&r&4&&Cl(n),r&512&&gl(n,n.return);break;case 12:Du(e,n);break;case 31:Du(e,n),r&4&&gu(e,n);break;case 13:Du(e,n),r&4&&_u(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=hf.bind(null,n),cm(e,n))));break;case 22:if(r=n.memoizedState!==null||Yl,!r){var a=t!==null&&t.memoizedState!==null||Xl;t=Yl,i=Xl,Yl=r,(Xl=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),ku(e,n,r)):Du(e,n),Yl=t,Xl=i}break;case 30:Du(e,n),r&512&&gl(n,n.return);break;case 7:r&512&&gl(n,n.return);default:Du(e,n)}}function cu(e,t){for(e=e.child;e!==null;)lu(e,t),e=e.sibling}function lu(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){df(e,e.return,t)}uu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,jt=!0}catch(t){df(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?wp(s,!0):wp(e.stateNode,!1)}catch(t){df(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&cu(e,t);break;default:cu(e,t)}}function uu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:lu(n,r);break a;case 22:n.memoizedState===null&&uu(n,r);break a;default:uu(n,r)}}e=e.sibling}}function du(e){var t=e.alternate;t!==null&&(e.alternate=null,du(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&_t(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 fu=null,pu=!1;function mu(e,t,n){for(n=n.child;n!==null;)hu(e,t,n),n=n.sibling}function hu(e,t,n){if(Ge&&typeof Ge.onCommitFiberUnmount==`function`)try{Ge.onCommitFiberUnmount(We,n)}catch{}switch(n.tag){case 26:Xl||_l(n,t),mu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Xl&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Xl||_l(n,t),bl(n);var r=fu,i=pu;Sp(n.type)&&(fu=n.stateNode,pu=!1),mu(e,t,n),gm(n.stateNode,n.type,n.memoizedProps),fu=r,pu=i;break;case 5:Xl||_l(n,t),bl(n);case 6:if(n.tag===6&&bl(n),r=fu,i=pu,fu=null,mu(e,t,n),fu=r,pu=i,fu!==null){if(pu)try{(fu.nodeType===9?fu.body:fu.nodeName===`HTML`?fu.ownerDocument.body:fu).removeChild(n.stateNode),jt=!0}catch(e){df(n,t,e)}else try{fu.removeChild(n.stateNode),jt=!0}catch(e){df(n,t,e)}}break;case 18:fu!==null&&(pu?(e=fu,Cp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hh(e)):Cp(fu,n.stateNode));break;case 4:r=fu,i=pu,fu=n.stateNode.containerInfo,pu=!0,mu(e,t,n),fu=r,pu=i;break;case 0:case 11:case 14:case 15:pl(2,n,t),Xl||pl(4,n,t),mu(e,t,n);break;case 1:Xl||(_l(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&hl(n,t,r)),mu(e,t,n);break;case 21:mu(e,t,n);break;case 22:Xl=(r=Xl)||n.memoizedState!==null,mu(e,t,n),Xl=r;break;case 30:_l(n,t),mu(e,t,n);break;case 7:Xl||_l(n,t),mu(e,t,n);break;default:mu(e,t,n)}}function gu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hh(e)}catch(e){df(t,t.return,e)}}}function _u(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hh(e)}catch(e){df(t,t.return,e)}}function vu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new $l),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new $l),t;default:throw Error(i(435,e.tag))}}function yu(e,t){var n=vu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=gf.bind(null,e,t);t.then(r,r)}})}function bu(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(Sp(l.type)){fu=l.stateNode,pu=!1;break a}break;case 5:fu=l.stateNode,pu=!1;break a;case 3:case 4:fu=l.stateNode.containerInfo,pu=!0;break a}l=l.return}if(fu===null)throw Error(i(160));hu(s,c,o),fu=null,pu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Su(t,e,n),t=t.sibling}var xu=null;function Su(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}bu(t,e,n),Cu(e),a&4&&(pl(3,e,e.return),fl(3,e),pl(5,e,e.return));break;case 1:bu(t,e,n),Cu(e),a&512&&(Xl||r===null||_l(r,r.return)),a&64&&Yl&&(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=xu,bu(t,e,n),Cu(e),a&512&&(Xl||r===null||_l(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(Yl)e.stateNode=fp(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[gt]||r[ut]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),np(r,t,n),r[ut]=e,xt(r),t=r;break a;case`link`:if(o=Gm(`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),np(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=Gm(`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),np(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[ut]=e,xt(r),t=r}e.stateNode=t}}else Yl||Km(o,e.type,e.stateNode)}else e.stateNode=Bm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&wl(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||Xl||t.parentNode.removeChild(t)):a.count--,n===null?Yl||Km(o,e.type,e.stateNode):Bm(o,n,e.memoizedProps))}break;case 27:bu(t,e,n),Cu(e),a&512&&(Xl||r===null||_l(r,r.return)),r!==null&&a&4&&wl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=Zl,Zl=!1,bu(t,e,n),Zl=o,Cu(e),a&512&&(Xl||r===null||_l(r,r.return)),e.flags&32){t=e.stateNode;try{Yt(t,``),jt=!0}catch(t){df(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,wl(e,t,r===null?t:r.memoizedProps)),a&1024&&(Ql=!0);break;case 6:if(bu(t,e,n),Cu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,jt=!0}catch(t){df(e,e.return,t)}}break;case 3:if(jt=!1,Wm=null,o=xu,xu=bm(t.containerInfo),bu(t,e,n),xu=o,Cu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){df(e,e.return,t)}Ql&&(Ql=!1,wu(e)),jt=!1;break;case 4:a=Zl,Zl=Yl,r=Mt(),o=xu,xu=bm(e.stateNode.containerInfo),bu(t,e,n),Cu(e),xu=o,jt&&nu&&(ru=!0),jt=r,Zl=a;break;case 12:bu(t,e,n),Cu(e);break;case 31:bu(t,e,n),Cu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,yu(e,t)));break;case 13:bu(t,e,n),Cu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(dd=Fe()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,yu(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Yl,l=Xl,u=Zl;Yl=c||o,Zl=u||o,Xl=l||s,bu(t,e,n),Xl=l,Zl=u,Yl=c,Cu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||Yl||Xl||(t=s||Xl,n=Yl,r=Xl,Yl=o||Yl,Xl=t,Ou(e,2),Yl=n,Xl=r),!o&&Zl||cu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,yu(e,n))));break;case 19:bu(t,e,n),Cu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,yu(e,t)));break;case 30:a&512&&(Xl||r===null||_l(r,r.return)),a=Mt(),o=nu,s=(n&335544064)===n,c=e.memoizedProps,nu=s&&ai(c.default,c.update)!==`none`,bu(t,e,n),Cu(e),s&&r!==null&&jt&&(e.flags|=4),nu=o,jt=a;break;case 21:break;case 7:a&512&&(Xl||r===null||_l(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:bu(t,e,n),Cu(e)}}function Cu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Tl(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Sl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(xl(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;Ol(e,El(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(Yt(l,``),n.flags&=-33),Ol(e,El(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Dl(e,El(e),u,s);break;default:throw Error(i(161))}}catch(t){df(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;wu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,gh=!0,t.reset(),gh=!1),e=e.sibling}}function Tu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Eu(t,e),t=t.sibling;else Jl(t,!1)}function Eu(e,t){var n=e.alternate;if(n===null)Bl(e,!1);else switch(e.tag){case 3:if(iu=tu=!1,Pl(),Tu(t,e),!tu&&!ru){if(e=Nl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Ep(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`})),iu=!0}Nl=null;break;case 5:Tu(t,e);break;case 4:r=tu,tu=!1,Tu(t,e),tu&&(ru=!0),tu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Tu(t,e):Bl(e,!1));break;case 30:r=tu,i=Pl(),tu=!1,Tu(t,e),tu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=ri(a,o),o=ri(n.memoizedProps,o);var s=ai(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Fl=0,t=ql(e,n,t,o,s,a,!0),Fl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Ad(e,e.memoizedProps.onUpdate),Nl=i):i!==null&&(i.push.apply(i,Nl),Nl=i),tu=e.flags&32?!0:r;break;default:Tu(t,e)}}function Du(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)su(e,t.alternate,t),t=t.sibling}function Ou(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:pl(4,n,n.return),Ou(n,r);break;case 1:_l(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&hl(n,n.return,i),Ou(n,r);break;case 27:r&2&&gm(n.stateNode,n.type,n.memoizedProps);case 5:_l(n,n.return),n.tag!==5&&n.tag!==27||bl(n),Ou(n,r);break;case 6:bl(n);break;case 26:_l(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Xl||i.parentNode.removeChild(i),Ou(n,r);break;case 22:n.memoizedState===null&&Ou(n,r);break;case 30:_l(n,n.return),Ou(n,r);break;case 7:_l(n,n.return);default:Ou(n,r)}e=e.sibling}}function ku(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:ku(i,a,n),fl(4,a);break;case 1:if(ku(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){df(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++)uo(l[i],c)}catch(e){df(r,r.return,e)}}s&&o&64&&ml(a),gl(a,a.return);break;case 27:n&2&&kl(a);case 5:a.tag!==5&&a.tag!==27||yl(a),ku(i,a,n),s&&r===null&&o&4&&Cl(a),gl(a,a.return);break;case 6:yl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Yl||Km(bm(c.ownerDocument),a.type,c),ku(i,a,n),s&&r===null&&o&4&&Cl(a),gl(a,a.return);break;case 12:ku(i,a,n);break;case 31:ku(i,a,n),s&&o&4&&gu(i,a);break;case 13:ku(i,a,n),s&&o&4&&_u(i,a);break;case 22:a.memoizedState===null&&ku(i,a,n),gl(a,a.return);break;case 30:ku(i,a,n),gl(a,a.return);break;case 7:gl(a,a.return);default:ku(i,a,n)}t=t.sibling}}function Au(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&&ba(n))}function ju(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ba(e))}function Mu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Nu(e,t,n,r),t=t.sibling;else i&&Kl(t)}function Nu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Gl(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Mu(e,t,n,r),a&2048&&fl(9,t);break;case 1:Mu(e,t,n,r);break;case 3:Mu(e,t,n,r),i&&iu&&(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&&ba(a)));break;case 12:if(a&2048){Mu(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){df(t,t.return,e)}}else Mu(e,t,n,r);break;case 31:Mu(e,t,n,r);break;case 13:Mu(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&&Gl(t),o._visibility&2?Mu(e,t,n,r):(o._visibility|=2,Pu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Gl(s),o._visibility&2?Mu(e,t,n,r):Fu(e,t)),a&2048&&Au(s,t);break;case 24:Mu(e,t,n,r),a&2048&&ju(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Rl(a.child,!0),Rl(t.child,!0))),Mu(e,t,n,r);break;default:Mu(e,t,n,r)}}function Pu(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:Pu(a,o,s,c,i),fl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Pu(a,o,s,c,i)):u._visibility&2?Pu(a,o,s,c,i):Fu(a,o),i&&l&2048&&Au(o.alternate,o);break;case 24:Pu(a,o,s,c,i),i&&l&2048&&ju(o.alternate,o);break;default:Pu(a,o,s,c,i)}t=t.sibling}}function Fu(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:Fu(n,r),i&2048&&Au(r.alternate,r);break;case 24:Fu(n,r),i&2048&&ju(r.alternate,r);break;default:Fu(n,r)}t=t.sibling}}var Iu=8192;function Lu(e,t,n){if(e.subtreeFlags&Iu)for(e=e.child;e!==null;)Ru(e,t,n),e=e.sibling}function Ru(e,t,n){switch(e.tag){case 26:Lu(e,t,n),e.flags&Iu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&Zm(n,e)):Qm(n,xu,e.memoizedState,e.memoizedProps));break;case 5:Lu(e,t,n),e.flags&Iu&&(e=e.stateNode,(t&335544128)===t&&Zm(n,e));break;case 3:case 4:var r=xu;xu=bm(e.stateNode.containerInfo),Lu(e,t,n),xu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Iu,Iu=16777216,Lu(e,t,n),Iu=r):Lu(e,t,n));break;case 30:if((e.flags&Iu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,jl===null&&(jl=new Map),jl.set(r,i)}Lu(e,t,n);break;default:Lu(e,t,n)}}function zu(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 Bu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];eu=r,Uu(r,e)}zu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Vu(e),e=e.sibling}function Vu(e){switch(e.tag){case 0:case 11:case 15:Bu(e),e.flags&2048&&pl(9,e,e.return);break;case 3:Bu(e);break;case 12:Bu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Hu(e)):Bu(e);break;default:Bu(e)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];eu=r,Uu(r,e)}zu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:pl(8,t,t.return),Hu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Hu(t));break;default:Hu(t)}e=e.sibling}}function Uu(e,t){for(;eu!==null;){var n=eu;switch(n.tag){case 0:case 11:case 15:pl(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:ba(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,eu=r;else a:for(n=e;eu!==null;){r=eu;var i=r.sibling,a=r.return;if(du(r),r===n){eu=null;break a}if(i!==null){i.return=a,eu=i;break a}eu=a}}}var Wu={getCacheForType:function(e){var t=fa(va),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return fa(va).controller.signal}},Gu=typeof WeakMap==`function`?WeakMap:Map,Ku=0,qu=null,Ju=null,Yu=0,Xu=0,Zu=null,Qu=!1,$u=!1,ed=!1,td=0,nd=0,rd=0,id=0,ad=0,od=0,sd=0,cd=null,ld=null,ud=!1,dd=0,fd=0,pd=1/0,md=null,hd=null,gd=0,_d=null,vd=null,yd=0,bd=0,xd=null,Sd=null,Cd=null,wd=null,Td=null,Ed=0,Dd=null;function Od(){return Ku&2&&Yu!==0?Yu&-Yu:B.T===null?st():Mf()}function kd(){if(od===0){if(!(Yu&536870912)||Gi){var e=W;W<<=1,!(W&3932160)&&(W=262144),od=e}else od=536870912}return e=vo.current,e!==null&&(e.flags|=32),od}function Ad(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Pp(ri(e.memoizedProps,n))),wd===null&&(wd=[]),wd.push(t.bind(null,r))}}function jd(e,t,n){(e===qu&&(Xu===2||Xu===9)||e.cancelPendingCommit!==null)&&(Rd(e,0),Fd(e,Yu,od,!1)),tt(e,n),(!(Ku&2)||e!==qu)&&(e===qu&&(!(Ku&2)&&(id|=n),nd===4&&Fd(e,Yu,od,!1)),wf(e))}function Md(e,t,n){if(Ku&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||q(e,t),a=r?Kd(e,t):Wd(e,t,!0),o=r;do{if(a===0){$u&&!r&&Fd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Pd(n)){a=Wd(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=cd;var l=c.current.memoizedState.isDehydrated;if(l&&(Rd(c,s).flags|=256),s=Wd(c,s,!1),s!==2&&s!==6){if(ed&&!l){c.errorRecoveryDisabledLanes|=o,id|=o,a=4;break a}o=ld,ld=a,o!==null&&(ld===null?ld=o:ld.push.apply(ld,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Rd(e,0),Fd(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:Fd(r,t,od,!Qu);break a;case 2:ld=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=dd+300-Fe(),10<a)){if(Fd(r,t,od,!Qu),K(r,0,!0)!==0)break a;yd=t,r.timeoutHandle=gp(Nd.bind(null,r,n,ld,md,ud,t,od,id,sd,Qu,o,`Throttled`,-0,0),a);break a}Nd(r,n,ld,md,ud,t,od,id,sd,Qu,o,null,-0,0)}break}while(1);wf(e)}function Nd(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;if(d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:rn},jl=null,Ru(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=nh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?dd-Fe():(a&4194048)===a?fd-Fe():0,m=eh(d,m),m!==null)){yd=a,e.cancelPendingCommit=m($d.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Fd(e,a,o,!l);return}$d(e,t,a,n,r,i,o,s,c,l,u,d)}function Pd(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(!Dr(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 Fd(e,t,n,r){t=$e(e,t),t&=~ad,t&=~id,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 Id(){return Ku&6?!0:(Tf(0,!1),!1)}function Ld(){if(Ju!==null){if(Xu===0)var e=Ju.return;else e=Ju,ia=ra=null,Jo(e),Ka=null,qa=0,e=Ju;for(;e!==null;)dl(e.alternate,e),e=e.return;Ju=null}}function Rd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,_p(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),yd=0,Ld(),qu=e,Ju=n=bi(e.current,null),Yu=t,Xu=0,Zu=null,Qu=!1,$u=q(e,t),ed=!1,sd=od=ad=id=rd=nd=0,ld=cd=null,ud=!1,td=$e(e,t),ui(),n}function zd(e,t){Ao=null,B.H=ic,t===Ia||t===Ra?(t=Wa(),Xu=3):t===La?(t=Wa(),Xu=4):Xu=t===Sc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Zu=t,Ju===null&&(nd=1,gc(e,Oi(t,e.current)))}function Bd(){var e=vo.current;return e===null?!0:(Yu&4194048)===Yu?yo===null:(Yu&62914560)===Yu||Yu&536870912?e===yo:!1}function Vd(){var e=B.H;return B.H=ic,e===null?ic:e}function Hd(){var e=B.A;return B.A=Wu,e}function Ud(){nd=4,Qu||(Yu&4194048)!==Yu&&vo.current!==null||($u=!0),!(rd&134217727)&&!(id&134217727)||qu===null||Fd(qu,Yu,od,!1)}function Wd(e,t,n){var r=Ku;Ku|=2;var i=Vd(),a=Hd();(qu!==e||Yu!==t)&&(md=null,Rd(e,t)),t=!1;var o=nd;a:do try{if(Xu!==0&&Ju!==null){var s=Ju,c=Zu;switch(Xu){case 8:Ld(),o=6;break a;case 3:case 2:case 9:case 6:vo.current===null&&(t=!0);var l=Xu;if(Xu=0,Zu=null,Xd(e,s,c,l),n&&$u){o=0;break a}break;default:l=Xu,Xu=0,Zu=null,Xd(e,s,c,l)}}Gd(),o=nd;break}catch(t){zd(e,t)}while(1);return t&&e.shellSuspendCounter++,ia=ra=null,Ku=r,B.H=i,B.A=a,Ju===null&&(qu=null,Yu=0,ui()),o}function Gd(){for(;Ju!==null;)Jd(Ju)}function Kd(e,t){var n=Ku;Ku|=2;var r=Vd(),a=Hd();qu!==e||Yu!==t?(md=null,pd=Fe()+500,Rd(e,t)):$u=q(e,t);a:do try{if(Xu!==0&&Ju!==null){t=Ju;var o=Zu;b:switch(Xu){case 1:Xu=0,Zu=null,Xd(e,t,o,1);break;case 2:case 9:if(Ba(o)){Xu=0,Zu=null,Yd(t);break}t=function(){Xu!==2&&Xu!==9||qu!==e||(Xu=7),wf(e)},o.then(t,t);break a;case 3:Xu=7;break a;case 4:Xu=5;break a;case 7:Ba(o)?(Xu=0,Zu=null,Yd(t)):(Xu=0,Zu=null,Xd(e,t,o,7));break;case 5:var s=null;switch(Ju.tag){case 26:s=Ju.memoizedState;case 5:case 27:var c=Ju;if(s?Ym(s):c.stateNode.complete){Xu=0,Zu=null;var l=c.sibling;if(l!==null)Ju=l;else{var u=c.return;u===null?Ju=null:(Ju=u,Zd(u))}break b}}Xu=0,Zu=null,Xd(e,t,o,5);break;case 6:Xu=0,Zu=null,Xd(e,t,o,6);break;case 8:Ld(),nd=6;break a;default:throw Error(i(462))}}qd();break}catch(t){zd(e,t)}while(1);return ia=ra=null,B.H=r,B.A=a,Ku=n,Ju===null?(qu=null,Yu=0,ui(),nd):0}function qd(){for(;Ju!==null&&!Ne();)Jd(Ju)}function Jd(e){var t=nl(e.alternate,e,td);e.memoizedProps=e.pendingProps,t===null?Zd(e):Ju=t}function Yd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Ic(n,t,t.pendingProps,t.type,void 0,Yu);break;case 11:t=Ic(n,t,t.pendingProps,t.type.render,t.ref,Yu);break;case 5:Jo(t);var r=t;r===Ui&&(Gi?(Zi(r),r.tag===5&&r.stateNode!=null&&(Wi=r.stateNode)):(Zi(r),Gi=!0));default:dl(n,t),t=Ju=xi(t,td),t=nl(n,t,td)}e.memoizedProps=e.pendingProps,t===null?Zd(e):Ju=t}function Xd(e,t,n,r){ia=ra=null,Jo(t),Ka=null,qa=0;var i=t.return;try{if(xc(e,i,t,n,Yu)){nd=1,gc(e,Oi(n,e.current)),Ju=null;return}}catch(t){if(i!==null)throw Ju=i,t;nd=1,gc(e,Oi(n,e.current)),Ju=null;return}t.flags&32768?(Gi||r===1?e=!0:$u||Yu&536870912?e=!1:(Qu=e=!0,(r===2||r===9||r===3||r===6)&&(r=vo.current,r!==null&&r.tag===13&&(r.flags|=16384))),Qd(t,e)):Zd(t)}function Zd(e){var t=e;do{if(t.flags&32768){Qd(t,Qu);return}e=t.return;var n=ll(t.alternate,t,td);if(n!==null){Ju=n;return}if(t=t.sibling,t!==null){Ju=t;return}Ju=t=e}while(t!==null);nd===0&&(nd=5)}function Qd(e,t){do{var n=ul(e.alternate,e);if(n!==null){n.flags&=32767,Ju=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ju=e;return}Ju=e=n}while(e!==null);nd=6,Ju=null}function $d(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do cf();while(gd!==0);if(Ku&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===qu&&(Ju=qu=null,Yu=0),vd=t,_d=e,yd=n,xd=a,Sd=r,ef(e,t,n,s,c,l,f)}}function ef(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(bd=s,s|=li,nt(e,n,s,r,i,a),wd=null,(n&335544064)===n?(Td=Ca(e),r=10262):(Td=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,_f(ze,function(){return lf(),null})):(e.callbackNode=null,e.callbackPriority=0),Al=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=B.T,B.T=null,i=V.p,V.p=2,a=Ku,Ku|=4;try{au(e,t,n)}finally{Ku=a,V.p=i,B.T=r}}gd=1,Al?Cd=Mp(o,e.containerInfo,Td,rf,af,nf,of,lf,tf,null,null):(rf(),af(),of())}function tf(e){if(gd!==0){var t=_d.onRecoverableError;t(e,{componentStack:null})}}function nf(){gd===3&&(gd=0,Eu(vd,_d),gd=4)}function rf(){if(gd===1){gd=0;var e=_d,t=vd,n=yd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=B.T,B.T=null;var i=V.p;V.p=2;var a=Ku;Ku|=4;try{nu=ru=!1,Su(t,e,n),n=cp;var o=Nr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Mr(s.ownerDocument.documentElement,s)){if(c!==null&&Pr(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 _=jr(s,h),v=jr(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}}gh=!!sp,cp=sp=null}finally{Ku=a,V.p=i,B.T=r}}e.current=t,gd=2}}function af(){if(gd===2){gd=0;var e=_d,t=vd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=B.T,B.T=null;var r=V.p;V.p=2;var i=Ku;Ku|=4;try{su(e,t.alternate,t)}finally{Ku=i,V.p=r,B.T=n}}gd=3}}function of(){if(gd===4||gd===3){gd=0;var e=Cd;Cd=null,Pe();var t=_d,n=vd,r=yd,i=Sd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?gd=5:(gd=0,vd=_d=null,sf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(hd=null),ot(r),n=n.stateNode,Ge&&typeof Ge.onCommitFiberRoot==`function`)try{Ge.onCommitFiberRoot(We,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=wd,o=Td,Td=null,i!==null&&(wd=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);yd&3&&cf(),wf(t),a=t.pendingLanes,r&261930&&a&42?t===Dd?Ed++:(Ed=0,Dd=t):(Ed=0,Dd=null),Tf(0,!1)}}function sf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ba(t)))}function cf(){return Cd!==null&&(Cd.skipTransition(),Cd=null),rf(),af(),of(),lf()}function lf(){if(gd!==5)return!1;var e=_d,t=bd;bd=0;var n=ot(yd),r=B.T,a=V.p;try{V.p=32>n?32:n,B.T=null,n=xd,xd=null;var o=_d,s=yd;if(gd=0,vd=_d=null,yd=0,Ku&6)throw Error(i(331));var c=Ku;if(Ku|=4,Vu(o.current),Nu(o,o.current,s,n),Ku=c,Tf(0,!1),Ge&&typeof Ge.onPostCommitFiberRoot==`function`)try{Ge.onPostCommitFiberRoot(We,o)}catch{}return!0}finally{V.p=a,B.T=r,sf(e,t)}}function uf(e,t,n){t=Oi(n,t),t=vc(e.stateNode,t,2),e=io(e,t,2),e!==null&&(tt(e,2),wf(e))}function df(e,t,n){if(e.tag===3)uf(e,e,n);else for(;t!==null;){if(t.tag===3){uf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(hd===null||!hd.has(r))){e=Oi(n,e),n=yc(2),r=io(t,n,2),r!==null&&(bc(n,r,t,e),tt(r,2),wf(r));break}}t=t.return}}function ff(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Gu;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)||(ed=!0,i.add(n),e=pf.bind(null,e,t,n),t.then(e,e))}function pf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,qu===e&&(Yu&n)===n&&(nd===4||nd===3&&(Yu&62914560)===Yu&&300>Fe()-dd?Ku&2?ad|=n:Rd(e,0):ad|=n,sd===Yu&&(sd=0)),wf(e)}function mf(e,t){t===0&&(t=Y()),e=pi(e,t),e!==null&&(tt(e,t),wf(e))}function hf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),mf(e,n)}function gf(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),mf(e,n)}function _f(e,t){return je(e,t)}var vf=null,yf=null,bf=!1,xf=!1,Sf=!1,Cf=0;function wf(e){e!==yf&&e.next===null&&(yf===null?vf=yf=e:yf=yf.next=e),xf=!0,bf||(bf=!0,jf())}function Tf(e,t){if(!Sf&&xf){Sf=!0;do for(var n=!1,r=vf;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,Af(r,a))}else a=Yu,a=K(r,r===qu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||q(r,a)||(n=!0,Af(r,a))}r=r.next}while(n);Sf=!1}}function Ef(){Df()}function Df(){xf=bf=!1;var e=0;Cf!==0&&hp()&&(e=Cf);for(var t=Fe(),n=null,r=vf;r!==null;){var i=r.next,a=Of(r,t);a===0?(r.next=null,n===null?vf=i:n.next=i,i===null&&(yf=n)):(n=r,(e!==0||a&3)&&(xf=!0)),r=i}gd!==0&&gd!==5||Tf(e,!1),Cf!==0&&(Cf=0)}function Of(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=qu,n=Yu,n=K(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Xu===2||Xu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Me(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&&Me(r),ot(n)){case 2:case 8:n=Re;break;case 32:n=ze;break;case 268435456:n=Ve;break;default:n=ze}return r=kf.bind(null,e),n=je(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Me(r),e.callbackPriority=2,e.callbackNode=null,2}function kf(e,t){if(gd!==0&&gd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(cf()&&e.callbackNode!==n)return null;var r=Yu;return r=K(e,e===qu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Md(e,r,t),Of(e,Fe()),e.callbackNode!=null&&e.callbackNode===n?kf.bind(null,e):null)}function Af(e,t){if(cf())return null;Md(e,t,!0)}function jf(){bp(function(){Ku&6?je(Le,Ef):Df()})}function Mf(){if(Cf===0){var e=Ea;e===0&&(e=Ze,Ze<<=1,!(Ze&261888)&&(Ze=256)),Cf=e}return Cf}function Nf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:nn(e)}function Pf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Nf((i[dt]||null).action),o=r.submitter;o&&(t=(t=o[dt]||null)?Nf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Tn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Cf!==0){var e=new FormData(i,o);Ws(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Ws(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Ff=0;Ff<ei.length;Ff++){var If=ei[Ff];ti(If.toLowerCase(),`on`+(If[0].toUpperCase()+If.slice(1)))}ti(Kr,`onAnimationEnd`),ti(qr,`onAnimationIteration`),ti(Jr,`onAnimationStart`),ti(`dblclick`,`onDoubleClick`),ti(`focusin`,`onFocus`),ti(`focusout`,`onBlur`),ti(Yr,`onTransitionRun`),ti(Xr,`onTransitionStart`),ti(Zr,`onTransitionCancel`),ti(Qr,`onTransitionEnd`),Et(`onMouseEnter`,[`mouseout`,`mouseover`]),Et(`onMouseLeave`,[`mouseout`,`mouseover`]),Et(`onPointerEnter`,[`pointerout`,`pointerover`]),Et(`onPointerLeave`,[`pointerout`,`pointerover`]),Tt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Tt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Tt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Tt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Lf=`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(` `),Rf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Lf));function zf(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){oi(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){oi(e)}i.currentTarget=null,a=c}}}}function Bf(e,t){var n=t[Z];n===void 0&&(n=t[Z]=new Set);var r=e+`__bubble`;n.has(r)||(Wf(t,e,2,!1),n.add(r))}function Vf(e,t,n){var r=0;t&&(r|=4),Wf(n,e,r,t)}var Hf=`_reactListening`+Math.random().toString(36).slice(2);function Uf(e){if(!e[Hf]){e[Hf]=!0,Ct.forEach(function(t){t!==`selectionchange`&&(Rf.has(t)||Vf(t,!1,e),Vf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Hf]||(t[Hf]=!0,Vf(`selectionchange`,!1,t))}}function Wf(e,t,n,r){switch(Ch(t)){case 2:var i=_h;break;case 8:i=vh;break;default:i=yh}n=i.bind(null,t,n,e),i=void 0,!mn||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 Gf(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=vt(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}dn(function(){var r=a,i=on(n),s=[];a:{var c=$r.get(e);if(c!==void 0){var l=Tn,u=e;switch(e){case`keypress`:if(bn(n)===0)break a;case`keydown`:case`keyup`:l=Un;break;case`focusin`:u=`focus`,l=Pn;break;case`focusout`:u=`blur`,l=Pn;break;case`beforeblur`:case`afterblur`:l=Pn;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=Mn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Nn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Kn;break;case Kr:case qr:case Jr:l=Fn;break;case Qr:l=qn;break;case`scroll`:case`scrollend`:l=Dn;break;case`wheel`:l=Jn;break;case`copy`:case`cut`:case`paste`:l=In;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Wn;break;case`submit`:l=Gn;break;case`toggle`:case`beforetoggle`:l=Yn}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=fn(m,p),g!=null&&d.push(Kf(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!==an&&(u=n.relatedTarget||n.fromElement)&&(vt(u)||u[ft]))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?vt(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=Mn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Wn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:yt(c),h=l==null?u:yt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,vt(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,Jf):null,c!==null&&Yf(s,u,c,d,!1),l!==null&&f!==null&&Yf(s,f,l,d,!0)))}a:{if(c=r?yt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=hr;else if(lr(c)){if(gr)_=Tr;else{_=Cr;var v=Sr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&$t(r.elementType)&&(_=hr):_=wr;if(_&&=_(e,r)){ur(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?yt(r):window,e){case`focusin`:(lr(v)||v.contentEditable===`true`)&&(Ir=v,Lr=r,Rr=null);break;case`focusout`:Rr=Lr=Ir=null;break;case`mousedown`:zr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:zr=!1,Br(s,n,i);break;case`selectionchange`:if(Fr)break;case`keydown`:case`keyup`:Br(s,n,i)}var y;if(Zn)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 ar?rr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(er&&n.locale!==`ko`&&(ar||b!==`onCompositionStart`?b===`onCompositionEnd`&&ar&&(y=yn()):(gn=i,_n=`value`in gn?gn.value:gn.textContent,ar=!0)),v=qf(r,b),0<v.length&&(b=new Ln(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=ir(n),y!==null&&(b.data=y)))),(y=$n?or(e,n):sr(e,n))&&(b=qf(r,`onBeforeInput`),0<b.length&&(v=new Ln(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Pf(s,e,r,n,i)}zf(s,t)})}function Kf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qf(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=fn(e,n),i!=null&&r.unshift(Kf(e,i,a)),i=fn(e,t),i!=null&&r.push(Kf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Jf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yf(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=fn(n,a),l!=null&&o.unshift(Kf(n,l,c))):i||(l=fn(n,a),l!=null&&o.push(Kf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Xf=/\r\n?/g,Zf=/\u0000|\uFFFD/g;function Qf(e){return(typeof e==`string`?e:``+e).replace(Xf,`
10
+ `).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||Yt(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&Yt(e,``+r);else return;break;case`className`:Pt(e,`class`,r);break;case`tabIndex`:Pt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Pt(e,n,r);break;case`style`:Qt(e,r,o);return;case`data`:if(t!==`object`){Pt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=nn(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`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=nn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=rn);return;case`onScroll`:r!=null&&Bf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Bf(`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=nn(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`:Bf(`beforetoggle`,e),Bf(`toggle`,e),Nt(e,`popover`,r);break;case`xlinkActuate`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ft(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ft(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Nt(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=en.get(n)||n,Nt(e,n,r);else return}jt=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:Qt(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`)Yt(e,r);else if(typeof r==`number`||typeof r==`bigint`)Yt(e,``+r);else return;break;case`onScroll`:r!=null&&Bf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Bf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=rn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!wt.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[dt]||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}jt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Nt(e,n,r)}return}jt=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Bf(`error`,e),Bf(`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:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:Bf(`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:ep(e,t,r,d,n,null)}}Wt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Bf(`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:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Kt(e,!!r,n,!0):Kt(e,!!r,t,!1);return;case`textarea`:for(s in Bf(`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:ep(e,t,s,c,n,null)}Jt(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:ep(e,t,l,r,n,null)}return;case`dialog`:Bf(`beforetoggle`,e),Bf(`toggle`,e),Bf(`cancel`,e),Bf(`close`,e);break;case`iframe`:case`object`:Bf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Lf.length;r++)Bf(Lf[r],e);break;case`image`:Bf(`error`,e),Bf(`load`,e);break;case`details`:Bf(`toggle`,e);break;case`embed`:case`source`:case`link`:Bf(`error`,e),Bf(`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:ep(e,t,u,r,n,null)}return;default:if($t(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(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)||ep(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&&(jt=!0),o=m;break;case`name`:m!==f&&(jt=!0),a=m;break;case`checked`:m!==f&&(jt=!0),u=m;break;case`defaultChecked`:m!==f&&(jt=!0),d=m;break;case`value`:m!==f&&(jt=!0),s=m;break;case`defaultValue`:m!==f&&(jt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}Ut(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)||ep(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&&(jt=!0),p=o;break;case`defaultValue`:o!==l&&(jt=!0),c=o;break;case`multiple`:o!==l&&(jt=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Kt(e,!!n,n?[]:``,!1):Kt(e,!!n,t,!0)):Kt(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:ep(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&&(jt=!0),p=a;break;case`defaultValue`:a!==o&&(jt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}qt(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:ep(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&&(jt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(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)&&ep(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:ep(e,t,u,p,r,m)}return;default:if($t(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(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||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(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||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){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&&ap(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&&ap(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 sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(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 dp(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 fp(e,t,n,r){return n=lp(n).createElement(e),n[ut]=r,n[dt]=t,np(n,e,t),xt(n),n}function pp(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 mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(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),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[gt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(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 Tp(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 Ep(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 Dp(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 Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(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`&&(Ap(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+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.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 Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.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},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.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(Bp(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=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),m(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),m(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.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,Rp(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,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){m(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=b(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];m(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=lp(e).activeElement,e!==null&&m(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),m(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag!==6&&(e=b(e),t.observe(e),!1)}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),m(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag!==6&&(e=b(e),t.unobserve(e),!1)}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return m(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(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}Fp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];m(this._fragmentFiber.child,!1,Hp,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||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=vt(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 Zp(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)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];m(this._fragmentFiber.child,!1,Hp,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),Zp(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),Zp(a,n)):b(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=b(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(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,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,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.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(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`:nm(n),_t(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(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[gt])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=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(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 lm(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 um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(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 pm(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 mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(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 gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===rn&&(e.onclick=null),_t(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);_t(e)}var vm=new Map,ym=new Set;function bm(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 xm=V.d;V.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Id();return e||t}function Cm(e){var t=$(e);t!==null&&t.tag===5&&t.type===`form`?Ks(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=Ht(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ht(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ht(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ht(n.imageSizes)+`"]`)):i+=`[href="`+Ht(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Q]=!0,o.onload=o.onerror=function(){St(o)}),xt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ht(r)+`"][href="`+Ht(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),xt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=bt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);xt(c),np(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,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=D({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),xt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),xt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=_e.current)?bm(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=Pm(n.href),t=bt(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=Pm(n.href);var o=bt(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(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.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},vm.set(e,o)),Lm(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=Rm(n),t=bt(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 Pm(e){return`href="`+Ht(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Q]){r.loading=1;return}}else t=e.createElement(`link`),t[Q]=!0,t.onload=t.onerror=St.bind(null,t),np(t,`link`,n),xt(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 Rm(e){return`[src="`+Ht(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ht(n.href)+`"]`);if(r)return t.instance=r,xt(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`),xt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,xt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),xt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,xt(a),a):(r=n,(a=vm.get(o))&&(r=D({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),xt(a),np(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,Vm(r,n.precedence,e));return t.instance}function Vm(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 Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,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[gt]||a[ut]||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 Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(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 Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(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=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,xt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),xt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(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=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.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=nh.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 sh={$$typeof:P,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0),this.hiddenUpdates=et(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=vi(3,null,null,t),e.current=a,a.stateNode=e,t=ya(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},to(a),e}function uh(e){return e?(e=gi,e):gi}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=ro(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=io(e,r,t),n!==null&&(jd(n,e,t),ao(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=pi(e,67108864);t!==null&&jd(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=Od();t=at(t);var n=pi(e,t);n!==null&&jd(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=2,yh(e,t,n,r)}finally{V.p=a,B.T=i}}function vh(e,t,n,r){var i=B.T;B.T=null;var a=V.p;try{V.p=8,yh(e,t,n,r)}finally{V.p=a,B.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=$(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}wf(a),!(Ku&6)&&(pd=Fe()+500,Tf(0,!1))}}break;case 31:case 13:s=pi(a,2),s!==null&&jd(s,a,2),Id(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=on(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=vt(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 xh=e,null}function Ch(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(Ie()){case Le:return 2;case Re:return 8;case ze:case Be:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`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 Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(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=$(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=vt(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,ct(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ct(e.priority,function(){hh(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 Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);an=r,n.target.dispatchEvent(r),an=null}else return t=$(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=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(Sh(r||n)===null)continue;break}var a=$(n);a!==null&&(e.splice(t,3),t-=3,Ws(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.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[dt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[dt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){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 Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,Od(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Id(),t[ft]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=st();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.0`)throw Error(i(527,Kh,`19.3.0`));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 qh={bundleType:0,version:`19.3.0`,rendererPackageName:`react-dom`,currentDispatcherRef:B,reconcilerVersion:`19.3.0`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{We=Jh.inject(qh),Ge=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=pc,s=mc,c=hc;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=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[ft]=t.current,Uf(e),new Wh(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()}}}),j=e=>e.startsWith(`/`)?A.baseUrl+e:e,ee=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 ee.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 L({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 R(){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`},z=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)&&!z(e)?`chat`:`side`,V=`kw-column-path`;function de(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)||`/`;if(t?.replace&&(B(e)!==B(n)||de(n)&&!de(e)&&B(e)===`chat`)){window.dispatchEvent(new CustomEvent(V,{detail:e}));return}t?.replace?window.location.replace(`#${e}`):window.location.hash=e}function fe(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 pe(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 fe({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 fe(t)}catch{}}throw Error(`started, but the UI did not answer yet — see ~/.kraftwerk/logs`)}var me=(0,v.createContext)(null);function U({href:e,onClick:t,...n}){let r=(0,v.useContext)(me);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 he=`kw-expert`,ge=(()=>{try{return localStorage.getItem(he)!==`off`}catch{return!0}})(),_e=new Set;document.documentElement.dataset.expert=ge?`on`:`off`;function ve(e){ge=e,document.documentElement.dataset.expert=e?`on`:`off`;try{localStorage.setItem(he,e?`on`:`off`)}catch{}_e.forEach(e=>e())}function ye(){return(0,v.useSyncExternalStore)(e=>(_e.add(e),()=>_e.delete(e)),()=>ge)}var be=[`git`,`repos`,`vibeables`,`projects`,`contacts`,`places`,`events`,`boards`,`presentations`],xe={git:!1,repos:!1,vibeables:!1,projects:!1,contacts:!1,places:!1,events:!1,boards:!1,presentations:!1},Se=new Set;function Ce(e){be.every(t=>e[t]===xe[t])||(xe=e,Se.forEach(e=>e()))}function we(){return(0,v.useSyncExternalStore)(e=>(Se.add(e),()=>Se.delete(e)),()=>xe)}function Te(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 Ee(e,t){return e||`hsl(${Te(t)} 58% 46%)`}function De(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 Oe=(e,t,n)=>e.map((e,r)=>Math.round(e+(t[r]-e)*n)),ke=e=>`#`+e.map(e=>e.toString(16).padStart(2,`0`)).join(``);function Ae([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 je(e,t){let n=Ae(e),r=Ae(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Me(e,t,n,r){let i=e;for(let a=0;a<=1&&je(i,t)<n;a+=.04)i=Oe(e,r,a);return i}var Ne=[255,255,255],Pe=[0,0,0],Fe=[38,37,35];function Ie(e){let t=De(e);if(!t)return null;let n=Me(t,Ne,4.5,Pe),r=Oe(t,Ne,.84),i=Oe(t,Ne,.88),a=Me(Oe(t,Ne,.4),Fe,4.5,Ne),o=Oe(t,Pe,.42),s=Oe(t,Pe,.6);return{"--wsp-l-primary":ke(n),"--wsp-l-on-primary":ke(Ne),"--wsp-l-primary-container":ke(r),"--wsp-l-on-primary-container":ke(Me(Oe(t,Pe,.6),r,4.5,Pe)),"--wsp-l-secondary-container":ke(i),"--wsp-l-on-secondary-container":ke(Me(Oe(t,Pe,.65),i,4.5,Pe)),"--wsp-d-primary":ke(a),"--wsp-d-on-primary":ke(Me(Oe(t,Pe,.7),a,4.5,Pe)),"--wsp-d-primary-container":ke(o),"--wsp-d-on-primary-container":ke(Me(Oe(t,Ne,.8),o,4.5,Ne)),"--wsp-d-secondary-container":ke(s),"--wsp-d-on-secondary-container":ke(Me(Oe(t,Ne,.85),s,4.5,Ne))}}function Le(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 Re({icon:e,name:t,color:n,seed:r,ambiguous:i,size:a=`md`,className:o}){let s={"--ws-c":Ee(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||Le(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:Le(t)})]})}var ze={emoji:`🧭`,name:`Assistant`};function Be(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 Ve(e){return e==null?`—`:`$${e.toFixed(2)}`}function He(e){return e?e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function Ue(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} K`:`${(e/1024/1024).toFixed(1)} M`}function We(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 Ge(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:Be(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 W({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)(L,{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 G({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)(L,{name:e,className:`ms-sm`})}):(0,I.jsx)(`button`,{type:`button`,className:s,title:t,"aria-label":t,...o,children:(0,I.jsx)(L,{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 K({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 $e({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)(L,{name:e,className:`text-[32px] opacity-70`}),(0,I.jsx)(`div`,{children:t}),n]})}function et({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)(L,{name:`error`,className:`ms-sm`}),t]})}function tt({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 nt({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)(tt,{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)(tt,{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 rt({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 it({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)(L,{name:r,className:`text-[26px] text-fg-2`}):r,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(rt,{children:e}),t&&(0,I.jsx)(`div`,{className:`text-sm text-fg-2`,children:t})]}),(0,I.jsx)(`span`,{className:`flex-1`}),n]})}function at({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 ot({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 st({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)(L,{name:e,className:`text-[17px]`})})}function ct({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)(st,{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 lt({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col divide-y divide-line py-1`,t),children:e})}var ut=(0,v.createContext)(!1);function dt({compact:e=!1,children:t}){return(0,I.jsx)(ut.Provider,{value:e,children:(0,I.jsx)(`div`,{className:`py-1 [&>*+*]:border-t [&>*+*]:border-line`,children:t})})}function ft({label:e,dim:t,mono:n,children:r}){let i=(0,v.useContext)(ut);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)(tt,{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 Z({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 pt({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 mt=`rounded-control border border-line bg-surface text-fg placeholder:text-fg-2 focus:border-accent focus:outline-none disabled:opacity-60`,ht=[[/^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 gt(e,t){let n=(t??``).split(/\s+/).filter(Boolean);return P(mt,...e.split(` `).filter(e=>{let t=ht.find(([t])=>t.test(e));return!t||!n.some(e=>t[1].test(e))}),t)}var Q=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`input`,{ref:n,className:gt(`w-full h-9 px-3 font-sans text-base`,e),...t})}),_t=(0,v.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(`textarea`,{ref:n,className:gt(`w-full px-3 py-2 font-sans text-base leading-normal`,e),...t})});function vt({className:e,children:t,...n}){return(0,I.jsx)(`select`,{className:gt(`w-full h-9 cursor-pointer px-3 pr-8 font-sans text-base`,e),...n,children:t})}function $({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 yt({children:e,className:t}){return(0,I.jsx)(`div`,{className:P(`flex flex-col gap-3.5 p-[18px]`,t),children:e})}function bt({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 xt({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 St({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 Ct({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)(St,{checked:e})})}function wt({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)(St,{checked:n})]})}function Tt({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)(G,{icon:`arrow_back`,label:n.label,size:`sm`,href:n.href,className:`-ml-1.5`}),(0,I.jsx)(tt,{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 Et({icon:e=`search`,...t}){return(0,I.jsxs)(`label`,{className:`relative mx-2 mt-1 mb-1 block`,children:[(0,I.jsx)(L,{name:e,className:`ms-sm pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-fg-2`}),(0,I.jsx)(Q,{type:`search`,className:`h-8 rounded-full pl-8 text-sm`,...t})]})}function Dt({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 Ot({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 kt({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 At=null,jt=new Set,Mt;async function Nt(){try{let e=await A.request(`attention.list`);if(e.ok){At=e.data.items;for(let e of jt)e()}}catch{}Mt=setTimeout(()=>void Nt(),3e3)}function Pt(e){return jt.add(e),jt.size===1&&Nt(),()=>{jt.delete(e),jt.size===0&&Mt&&clearTimeout(Mt)}}function Ft(){Mt&&clearTimeout(Mt),Nt()}function It(){return(0,v.useSyncExternalStore)(Pt,()=>At)}var Lt={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)},Rt=e=>e===`approval`?`front_hand`:e===`question`?`help`:e===`runner`?`event_busy`:e===`review`?`rate_review`:`error`,zt=e=>e===`approval`?`needs approval`:e===`question`?`asks you`:e===`runner`?`no runner`:e===`review`?`for review`:`failed`;function Bt(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 Vt=e=>new URLSearchParams(e.split(`?`)[1]??``).get(`focus`),Ht=e=>e.split(`?`)[0];function Ut(e,t){if(e.length!==0)return e[(e.findIndex(e=>e.href===t||Vt(t)===null&&Ht(e.href)===t)+1)%e.length]}function Wt(e){e.notificationId&&A.request(`notifications.read`,{body:{ids:[e.notificationId]}}).then(()=>Ft()).catch(()=>{}),(window.location.hash.slice(1)||`/`)===e.href?window.dispatchEvent(new Event(Gt)):H(e.href)}var Gt=`kw-refocus`;function Kt(){let e=It()??[],t=Ut(e,R());return(0,v.useEffect)(()=>{let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.code!==`KeyN`)return;let t=Ut(At??[],window.location.hash.slice(1)||`/`);t&&(e.preventDefault(),Wt(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:()=>Wt(t),title:`next: ${Bt(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)(L,{name:`arrow_forward`,className:`ms-sm`})]}),(0,I.jsx)($e,{className:`mr-1 max-[800px]:hidden`,"aria-hidden":!0,children:`⌥N`})]}):null}function qt(){let e=R(),t=Vt(e),[n,r]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>r(e=>e+1);return window.addEventListener(Gt,e),()=>window.removeEventListener(Gt,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 Jt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Yt=Jt();function Xt(e){Yt=e}var Zt={exec:()=>null};function Qt(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 $t(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(tn.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var en=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),tn={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,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}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,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}));/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:Qt(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Qt(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Qt(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Qt(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Qt(e=>RegExp(`^ {0,${e}}(?:</?(?:${_n})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:Qt(e=>RegExp(`^ {0,${e}}>`))},nn=/^(?:[ \t]*(?:\n|$))+/,rn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,an=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,on=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,cn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ln=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,un=$t(ln).replace(/bull/g,cn).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(),dn=$t(ln).replace(/bull/g,cn).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(),fn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,pn=/^[^\n]+/,mn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,hn=$t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,mn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gn=$t(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,cn).getRegex(),_n=`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`,vn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,yn=$t(`^ {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)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,vn).replace(`tag`,_n).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),bn=e=>$t(fn).replace(`hr`,on).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_n).getRegex(),xn=bn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Sn=bn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Cn={blockquote:$t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Sn).getRegex(),code:rn,def:hn,fences:an,heading:sn,hr:on,html:yn,lheading:un,list:gn,newline:nn,paragraph:xn,table:Zt,text:pn},wn=$t(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,on).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_n).getRegex(),Tn={...Cn,lheading:dn,table:wn,paragraph:$t(fn).replace(`hr`,on).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,wn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_n).getRegex()},En={...Cn,html:$t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,vn).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:Zt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$t(fn).replace(`hr`,on).replace(`heading`,` *#{1,6} *[^
11
+ ]`).replace(`lheading`,un).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Dn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,On=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,kn=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,An=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,jn=/[\p{P}\p{S}]/u,Mn=/[\s\p{P}\p{S}]/u,Nn=/[^\s\p{P}\p{S}]/u,Pn=$t(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Mn).getRegex(),Fn=/[\p{Pi}\p{Ps}"']/u,In=/(?!~)[\p{P}\p{S}]/u,Ln=/(?!~)[\s\p{P}\p{S}]/u,Rn=/(?:[^\s\p{P}\p{S}]|~)/u,zn=$t(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,en?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Bn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Vn=$t(Bn,`u`).replace(/punct/g,jn).getRegex(),Hn=$t(Bn,`u`).replace(/punct/g,In).getRegex(),Un=$t(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Fn).replace(/punct/g,jn).getRegex(),Wn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Gn=$t(Wn,`gu`).replace(/notPunctSpace/g,Nn).replace(/punctSpace/g,Mn).replace(/punct/g,jn).getRegex(),Kn=$t(Wn,`gu`).replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Ln).replace(/punct/g,In).getRegex(),qn=$t(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Nn).replace(/punctSpace/g,Mn).replace(/punct/g,jn).getRegex(),Jn=$t(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Nn).replace(/punctSpace/g,Mn).replace(/punct/g,jn).getRegex(),Yn=$t(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Nn).replace(/punctSpace/g,Mn).replace(/punct/g,jn).getRegex(),Xn=$t(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,jn).getRegex(),Zn=$t(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Nn).replace(/punctSpace/g,Mn).replace(/punct/g,jn).getRegex(),Qn=$t(/\\(punct)/,`gu`).replace(/punct/g,jn).getRegex(),$n=$t(/^<(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(),er=$t(vn).replace(`(?:-->|$)`,`-->`).getRegex(),tr=$t(`^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`,er).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),nr=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,rr=$t(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,nr).getRegex(),ir=$t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,rr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ar=$t(/^!?\[(label)\]\[(ref)\]/).replace(`label`,rr).replace(`ref`,mn).getRegex(),or=$t(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,mn).getRegex(),sr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,cr=$t(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,nr).getRegex(),lr=$t(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,$t(/^!?\[(label)\]\[(ref)\]/).replace(`label`,cr).replace(`ref`,sr).getRegex()).replace(`nolink`,$t(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,sr).getRegex()).getRegex(),ur=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,dr=$t(/(?: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(),fr={_backpedal:Zt,anyPunctuation:Qn,autolink:$n,blockSkip:zn,br:kn,code:On,del:Zt,delLDelim:Zt,delRDelim:Zt,emStrongLDelim:Vn,emStrongRDelimAst:Gn,emStrongRDelimUnd:Jn,escape:Dn,link:ir,nolink:or,punctuation:Pn,reflink:ar,reflinkSearch:lr,tag:tr,text:An,url:Zt},pr={...fr,emStrongLDelim:Un,emStrongRDelimAst:qn,emStrongRDelimUnd:Yn,link:$t(/^!?\[(label)\]\((.*?)\)/).replace(`label`,rr).getRegex(),reflink:$t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,rr).getRegex()},mr={...fr,emStrongRDelimAst:Kn,emStrongLDelim:Hn,delLDelim:Xn,delRDelim:Zn,url:$t(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,dr).replace(`protocol`,ur).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:$t(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,ur).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},hr={...mr,br:$t(kn).replace(`{2,}`,`*`).getRegex(),text:$t(mr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},gr={normal:Cn,gfm:Tn,pedantic:En},_r={normal:fr,gfm:mr,breaks:hr,pedantic:pr},vr={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},yr=e=>vr[e];function br(e,t){if(t){if(tn.escapeTest.test(e))return e.replace(tn.escapeReplace,yr)}else if(tn.escapeTestNoEncode.test(e))return e.replace(tn.escapeReplaceNoEncode,yr);return e}function xr(e){return e.replace(tn.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function Sr(e){try{e=encodeURI(e).replace(tn.percentDecode,`%`)}catch{return null}return e}function Cr(e,t){let n=e.replace(tn.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(tn.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(tn.slashPipe,`|`);return n}function wr(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 Tr(e){let t=e.split(`
12
+ `),n=t.length-1;for(;n>=0&&tn.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
13
+ `)}function Er(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function Dr(e,t){if(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}function Or(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function kr(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function Ar(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
14
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
15
+ `)}function jr(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var Mr=class{options;rules;lexer;constructor(e){this.options=e||Yt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Tr(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Ar(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=wr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:wr(t[0],`
16
+ `),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:wr(t[0],`
17
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=wr(t[0],`
18
+ `).split(`
19
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
20
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
21
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
22
+ ${s}`:s,r=r?`${r}
23
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
24
+ `),o=t.raw+`
25
+ `+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
26
+ `).length:0,d=l?e.slice(0,-l):e;d.length>0&&(n=`${n}
27
+ ${d.join(`
28
+ `)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
29
+ `+e.join(`
30
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
31
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
32
+ `,1)[0],l=t[1].length,u=this.options.pedantic?Or(c,l):c.replace(this.rules.other.leadingSpaceTab,e=>Or(e,l)),d=e.split(`
33
+ `,1)[0],f=!u.trim(),p=0;if(this.options.pedantic?(p=2,s=u.trimStart()):f?p=l+1:(p=u.search(this.rules.other.nonSpaceChar),p=p>4?1:p,s=u.slice(p),p+=l),f&&this.rules.other.blankLine.test(d)&&(r+=d+`
34
+ `,e=e.substring(d.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),i=this.rules.other.fencesBeginRegex(p),a=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),c=this.rules.other.blockquoteBeginRegex(p);for(;e;){let l=e.split(`
35
+ `,1)[0],m;if(d=l,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting,` `),m=d):m=d.replace(this.rules.other.leadingSpaceTab,e=>e.replace(this.rules.other.tabCharGlobal,` `)),i.test(d)||a.test(d)||o.test(d)||c.test(d)||t.test(d)||n.test(d))break;if(m.search(this.rules.other.nonSpaceChar)>=p||!d.trim())s+=`
36
+ `+m.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(u)||a.test(u)||n.test(u))break;s+=`
37
+ `+d}f=!d.trim(),r+=l+`
38
+ `,e=e.substring(l.length+1),u=m.slice(p)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Tr(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=Er(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:wr(t[0],`
39
+ `),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Cr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
40
+ `):[],a={type:`table`,raw:wr(t[0],`
41
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Cr(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:wr(t[0],`
42
+ `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
43
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&jr(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=wr(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=Dr(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),kr(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&jr(e,n[1],r,this.rules))return;let i=t[Er((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return kr(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:xr(t[0]),escaped:e}}}},Nr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Yt,this.options.tokenizer=this.options.tokenizer||new Mr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:tn,block:gr.normal,inline:_r.normal};this.options.pedantic?(t.block=gr.pedantic,t.inline=_r.pedantic):this.options.gfm&&(t.block=gr.gfm,t.inline=this.options.breaks?_r.breaks:_r.gfm),this.tokenizer.rules=t}static get rules(){return{block:gr,inline:_r}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(tn.carriageReturn,`
44
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(tn.tabCharGlobal,` `).replace(tn.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
45
+ `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
46
+ `)?``:`
47
+ `)+i.raw,n.text+=`
48
+ `+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
49
+ `)?``:`
50
+ `)+i.raw,n.text+=`
51
+ `+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
52
+ `)?``:`
53
+ `)+i.raw,r.text+=`
54
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
55
+ `)?``:`
56
+ `)+i.raw,n.text+=`
57
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,Er(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Er(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Pr=class{options;parser;constructor(e){this.options=e||Yt}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(tn.notSpaceStart)?.[0],i=e?e.replace(tn.endingNewline,``)+`
58
+ `:``;return r?`<pre><code class="language-`+br(r)+`">`+(n?i:br(i,!0))+`</code></pre>
59
+ `:`<pre><code>`+(n?i:br(i,!0))+`</code></pre>
60
+ `}blockquote({tokens:e}){return`<blockquote>
61
+ ${this.parser.parse(e)}</blockquote>
62
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
63
+ `}hr(e){return`<hr>
64
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
65
+ `+r+`</`+i+`>
66
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
67
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
68
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
69
+ <thead>
70
+ `+t+`</thead>
71
+ `+r+`</table>
72
+ `}tablerow({text:e}){return`<tr>
73
+ ${e}</tr>
74
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
75
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${br(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?br(n,!0):this.parser.parseInline(r),o=Sr(e);if(o===null)return a;e=br(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+br(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Sr(e);if(i===null)return br(n);e=i;let a=`<img src="${br(e)}" alt="${br(n)}"`;return t&&(a+=` title="${br(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:br(e.text)}},Fr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Ir=class e{options;renderer;textRenderer;constructor(e){this.options=e||Yt,this.options.renderer=this.options.renderer||new Pr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fr}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Lr=class{options;block;constructor(e){this.options=e||Yt}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Nr.lex:Nr.lexInline}provideParser(e=this.block){return e?Ir.parse:Ir.parseInline}},Rr=new class{defaults=Jt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ir;Renderer=Pr;TextRenderer=Fr;Lexer=Nr;Tokenizer=Mr;Hooks=Lr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Pr(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Mr(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Lr;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Lr.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Lr.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Nr.lex(e,t??this.defaults)}parser(e,t){return Ir.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Nr.lex:Nr.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Ir.parse:Ir.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Nr.lex:Nr.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Ir.parse:Ir.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
76
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+br(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function zr(e,t){return Rr.parse(e,t)}zr.options=zr.setOptions=function(e){return Rr.setOptions(e),zr.defaults=Rr.defaults,Xt(zr.defaults),zr},zr.getDefaults=Jt,zr.defaults=Yt;function Br(...e){return Rr.use(...e),zr.defaults=Rr.defaults,Xt(zr.defaults),zr}zr.use=Br,zr.walkTokens=function(e,t){return Rr.walkTokens(e,t)},zr.parseInline=Rr.parseInline,zr.Parser=Ir,zr.parser=Ir.parse,zr.Renderer=Pr,zr.TextRenderer=Fr,zr.Lexer=Nr,zr.lexer=Nr.lex,zr.Tokenizer=Mr,zr.Hooks=Lr,zr.parse=zr,zr.options,zr.setOptions,zr.walkTokens,zr.parseInline,Ir.parse,Nr.lex;function Vr(e,t){this.v=e,this.k=t}function Hr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ur(e){if(Array.isArray(e))return e}function Wr(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Gr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
77
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kr(e,t){return Ur(e)||Wr(e,t)||qr(e,t)||Gr()}function qr(e,t){if(e){if(typeof e==`string`)return Hr(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hr(e,t):void 0}}function Jr(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Vr;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Jr.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Jr.prototype.next=function(e){return this._invoke(`next`,e)},Jr.prototype.throw=function(e){return this._invoke(`throw`,e)},Jr.prototype.return=function(e){return this._invoke(`return`,e)};var Yr=Object.entries,Xr=Object.setPrototypeOf,Zr=Object.isFrozen,Qr=Object.getPrototypeOf,$r=Object.getOwnPropertyDescriptor,ei=Object.freeze,ti=Object.seal,ni=Object.create,ri=typeof Reflect<`u`&&Reflect,ii=ri.apply,ai=ri.construct;ei||=function(e){return e},ti||=function(e){return e},ii||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ai||=function(e){return new e(...[...arguments].slice(1))};var oi=Ei(Array.prototype.forEach);Array.prototype.indexOf;var si=Ei(Array.prototype.lastIndexOf),ci=Ei(Array.prototype.pop),li=Ei(Array.prototype.push);Array.prototype.slice;var ui=Ei(Array.prototype.splice),di=Array.isArray,fi=Ei(String.prototype.toLowerCase),pi=Ei(String.prototype.toString),mi=Ei(String.prototype.match),hi=Ei(String.prototype.replace),gi=Ei(String.prototype.indexOf),_i=Ei(String.prototype.trim),vi=Ei(Number.prototype.toString),yi=Ei(Boolean.prototype.toString),bi=typeof BigInt>`u`?null:Ei(BigInt.prototype.toString),xi=typeof Symbol>`u`?null:Ei(Symbol.prototype.toString),Si=Ei(Object.prototype.hasOwnProperty),Ci=Ei(Object.prototype.toString),wi=Ei(RegExp.prototype.test),Ti=Di(TypeError);function Ei(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ii(e,t,n)}}function Di(e){return function(){return ai(e,[...arguments])}}function Oi(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:fi;if(Xr&&Xr(e,null),!di(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Zr(t)||(t[r]=e),i=e)}e[i]=!0}return e}function ki(e){for(let t=0;t<e.length;t++)Si(e,t)||(e[t]=null);return e}function Ai(e){let t=ni(null);for(let r of Yr(e)){var n=Kr(r,2);let i=n[0],a=n[1];Si(e,i)&&(t[i]=di(a)?ki(a):a&&typeof a==`object`&&a.constructor===Object?Ai(a):a)}return t}function ji(e){switch(typeof e){case`string`:return e;case`number`:return vi(e);case`boolean`:return yi(e);case`bigint`:return bi?bi(e):`0`;case`symbol`:return xi?xi(e):`Symbol()`;case`undefined`:return Ci(e);case`function`:case`object`:{if(e===null)return Ci(e);let t=e,n=Mi(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ci(e)}return Ci(e)}default:return Ci(e)}}function Mi(e,t){for(;e!==null;){let n=$r(e,t);if(n){if(n.get)return Ei(n.get);if(typeof n.value==`function`)return Ei(n.value)}e=Qr(e)}function n(){return null}return n}function Ni(e){try{return wi(e,``),!0}catch{return!1}}var Pi=ei(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Fi=ei(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ii=ei([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Li=ei([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ri=ei(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),zi=ei([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Bi=ei([`#text`]),Vi=ei(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Hi=ei(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ui=ei(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Wi=ei([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Gi=ti(/{{[\w\W]*|^[\w\W]*}}/g),Ki=ti(/<%[\w\W]*|^[\w\W]*%>/g),qi=ti(/\${[\w\W]*/g),Ji=ti(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yi=ti(/^aria-[\-\w]+$/),Xi=ti(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zi=ti(/^(?:\w+script|data):/i),Qi=ti(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$i=ti(/^html$/i),ea=ti(/^[a-z][.\w]*(-[.\w]+)+$/i),ta=ti(/<[/\w!]/g),na=ti(/<[/\w]/g),ra=ti(/<\/no(script|embed|frames)/i),ia=ti(/\/>/i),aa={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},oa=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],sa=ei(Oi({},oa)),ca=function(){let e={};return oi(oa,t=>{e[t]=ti(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),ei(e)}(),la=function(){return typeof window>`u`?null:window},ua=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},da=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},fa=function(e,t,n,r){return Si(e,t)&&di(e[t])?Oi(r.base?Ai(r.base):{},e[t],r.transform):n},pa=function(e,t,n){let r=Si(e,t)?e[t]:void 0;return r&&typeof r==`object`?Ai(r):n()};function ma(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:la(),t=e=>ma(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==aa.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Mi(d,`cloneNode`),p=Mi(d,`remove`),m=Mi(d,`removeAttributeNode`),h=Mi(d,`nextSibling`),g=Mi(d,`childNodes`),_=Mi(d,`parentNode`),v=Mi(d,`shadowRoot`),y=Mi(d,`attributes`),b=o&&o.prototype?Mi(o.prototype,`nodeType`):null,x=o&&o.prototype?Mi(o.prototype,`nodeName`):null,S=o&&o.prototype?Mi(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,O=!1,k=0,A=function(){if(k>0)throw Ti(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},j=function(e){A(),k++;try{return T.createHTML(e)}finally{k--}},ee=function(e){A(),k++;try{return T.createScriptURL(e)}finally{k--}},M=function(){return O||=(D=ua(u,i),!0),D},N=n,P=N.implementation,F=N.createNodeIterator,te=N.createDocumentFragment,I=N.getElementsByTagName,L=r.importNode,R=da();t.isSupported=typeof Yr==`function`&&typeof _==`function`&&P&&P.createHTMLDocument!==void 0;let ne=Gi,re=Ki,ie=qi,ae=Ji,oe=Yi,se=Zi,ce=Qi,le=ea,ue=Xi,z=null,B=Oi({},[...Pi,...Fi,...Ii,...Ri,...Bi]),V=null,de=Oi({},[...Vi,...Hi,...Ui,...Wi]),H=Object.seal(ni(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),fe=null,pe=null,me=Object.seal(ni(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),U=!0,he=!0,ge=!1,_e=!0,ve=!1,ye=!0,be=!1,xe=!1,Se=null,Ce=null,we=!1,Te=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},Pe=null,Fe=Oi({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ie=null,Le=Oi({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Re=null,ze=Oi({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Be=`http://www.w3.org/1998/Math/MathML`,Ve=`http://www.w3.org/2000/svg`,He=`http://www.w3.org/1999/xhtml`,Ue=He,We=!1,Ge=null,Ke=Oi({},[Be,Ve,He],pi),qe=ei([`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=Oi({},qe),Ye=ei([`annotation-xml`]),Xe=Oi({},Ye),Ze=Oi({},[`title`,`style`,`font`,`a`,`script`]),W=null,G=[`application/xhtml+xml`,`text/html`],Qe=null,K=null,q=n.createElement(`form`),$e=function(e){return e instanceof RegExp||e instanceof Function},J=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(K&&K===e)return;(!e||typeof e!=`object`)&&(e={}),e=Ai(e),W=G.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Qe=W===`application/xhtml+xml`?pi:fi,z=fa(e,`ALLOWED_TAGS`,B,{transform:Qe}),V=fa(e,`ALLOWED_ATTR`,de,{transform:Qe}),Ge=fa(e,`ALLOWED_NAMESPACES`,Ke,{transform:pi}),Re=fa(e,`ADD_URI_SAFE_ATTR`,ze,{transform:Qe,base:ze}),Ie=fa(e,`ADD_DATA_URI_TAGS`,Le,{transform:Qe,base:Le}),Pe=fa(e,`FORBID_CONTENTS`,Fe,{transform:Qe}),fe=fa(e,`FORBID_TAGS`,Ai({}),{transform:Qe}),pe=fa(e,`FORBID_ATTR`,Ai({}),{transform:Qe}),Ne=Si(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Ai(e.USE_PROFILES):e.USE_PROFILES:!1,U=e.ALLOW_ARIA_ATTR!==!1,he=e.ALLOW_DATA_ATTR!==!1,ge=e.ALLOW_UNKNOWN_PROTOCOLS||!1,_e=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ve=e.SAFE_FOR_TEMPLATES||!1,ye=e.SAFE_FOR_XML!==!1,be=e.WHOLE_DOCUMENT||!1,Te=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,ue=Ni(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Xi,Ue=typeof e.NAMESPACE==`string`?e.NAMESPACE:He,Je=pa(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Oi({},qe)),Xe=pa(e,`HTML_INTEGRATION_POINTS`,()=>Oi({},Ye));let t=pa(e,`CUSTOM_ELEMENT_HANDLING`,()=>ni(null));if(H=ni(null),Si(t,`tagNameCheck`)&&$e(t.tagNameCheck)&&(H.tagNameCheck=t.tagNameCheck),Si(t,`attributeNameCheck`)&&$e(t.attributeNameCheck)&&(H.attributeNameCheck=t.attributeNameCheck),Si(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(H.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ti(H),ve&&(he=!1),Ee&&(Te=!0),Ne&&(z=Oi({},Bi),V=ni(null),Ne.html===!0&&(Oi(z,Pi),Oi(V,Vi)),Ne.svg===!0&&(Oi(z,Fi),Oi(V,Hi),Oi(V,Wi)),Ne.svgFilters===!0&&(Oi(z,Ii),Oi(V,Hi),Oi(V,Wi)),Ne.mathMl===!0&&(Oi(z,Ri),Oi(V,Ui),Oi(V,Wi))),me.tagCheck=null,me.attributeCheck=null,Si(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?me.tagCheck=e.ADD_TAGS:di(e.ADD_TAGS)&&(z===B&&(z=Ai(z)),Oi(z,e.ADD_TAGS,Qe))),Si(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?me.attributeCheck=e.ADD_ATTR:di(e.ADD_ATTR)&&(V===de&&(V=Ai(V)),Oi(V,e.ADD_ATTR,Qe))),Si(e,`ADD_FORBID_CONTENTS`)&&di(e.ADD_FORBID_CONTENTS)&&(Pe===Fe&&(Pe=Ai(Pe)),Oi(Pe,e.ADD_FORBID_CONTENTS,Qe)),je&&(z[`#text`]=!0),be&&Oi(z,[`html`,`head`,`body`]),z.table&&(Oi(z,[`tbody`]),delete fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ti(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ti(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=j(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=M()),T&&typeof E==`string`&&(E=j(``)));ei&&ei(e),K=e},Y=Oi({},[...Fi,...Ii,...Li]),et=Oi({},[...Ri,...zi]),tt=function(e,t,n){return t.namespaceURI===He?e===`svg`:t.namespaceURI===Be?e===`svg`&&(n===`annotation-xml`||Je[n]):!!Y[e]},nt=function(e,t,n){return t.namespaceURI===He?e===`math`:t.namespaceURI===Ve?e===`math`&&Xe[n]:!!et[e]},X=function(e,t,n){return t.namespaceURI===Ve&&!Xe[n]||t.namespaceURI===Be&&!Je[n]?!1:!et[e]&&(Ze[e]||!Y[e])},rt=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=fi(e.tagName),r=fi(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===Ve?tt(n,t,r):e.namespaceURI===Be?nt(n,t,r):e.namespaceURI===He?X(n,t,r):!!(W===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},it=function(e){li(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Ti(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},at=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},ot=function(e){lt(e);let t=g(e);if(t){let e=[];oi(t,t=>{li(e,t)}),oi(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&at(e,r,i)}},st=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}li(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Te||Ee)try{it(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},ct=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||V[Qe(i)]||at(e,r,i)}},lt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===aa.element&&ct(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ut=function(e,t){return ye?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},dt=function(e){if(!ye)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===aa.processingInstruction||n===aa.comment&&wi(na,e.data)){try{p(e)}catch{}continue}if(n===aa.element){let t=e,n=Qe(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&ut(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},ft=function(e){let t=null,r=null;if(we)e=`<remove></remove>`+e;else{let t=mi(e,/^[\r\n\t ]+/);r=t&&t[0]}W===`application/xhtml+xml`&&Ue===He&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?j(e):e;if(Ue===He)try{t=new l().parseFromString(i,W)}catch{}if(!t||!t.documentElement){t=P.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===He?I.call(t,be?`html`:`body`)[0]:be?t.documentElement:a},Z=function(e){let t=S?S(e):e.ownerDocument;return F.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},pt=function(e){return e=hi(e,ne,` `),e=hi(e,re,` `),e=hi(e,ie,` `),e},mt=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=F.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=pt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&oi(i,e=>{gt(e.content)&&mt(e.content)})},ht=function(e){let t=x?x(e):null;return typeof t!=`string`||Qe(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},gt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===aa.documentFragment}catch{return!1}},Q=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function _t(e,n,r){e.length!==0&&oi(e,e=>{e.call(t,n,r,K)})}let vt=function(e,t){return!!(ye&&e.hasChildNodes()&&!Q(e.firstElementChild)&&wi(ta,e.textContent)&&wi(ta,e.innerHTML)||ye&&e.namespaceURI===He&&sa[t]&&(Q(e.firstElementChild)||typeof e.textContent==`string`&&wi(ca[t],e.textContent))||e.nodeType===aa.processingInstruction||ye&&e.nodeType===aa.comment&&wi(na,e.data))},$=function(e,t){return e instanceof RegExp?wi(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},yt=function(e,t,n){if(!fe[t]&&Tt(t)&&$(H.tagNameCheck,t))return!1;if(je&&!Pe[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return it(e),!0},bt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Ai(t):t},xt=function(e,t){return e===t||_(e)!==null?!1:(Me&&lt(e),!0)},St=function(e,n){if(_t(R.beforeSanitizeElements,e,null),xt(e,n))return!0;if(ht(e))return it(e),!0;let r=Qe(w(e));if(z=bt(R.uponSanitizeElement,z,B,Se),_t(R.uponSanitizeElement,e,{tagName:r,allowedTags:z}),xt(e,n))return!0;if(vt(e,r))return it(e),!0;if(fe[r]||!(me.tagCheck instanceof Function&&me.tagCheck(r))&&!z[r]){let t=yt(e,r,n);return t===!1&&(_t(R.afterSanitizeElements,e,null),xt(e,n))?!0:t}if(C(e)===aa.element&&!rt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&wi(ra,e.innerHTML))return it(e),!0;if(ve&&e.nodeType===aa.text){let n=pt(e.textContent);e.textContent!==n&&(li(t.removed,{element:e.cloneNode()}),e.textContent=n)}return _t(R.afterSanitizeElements,e,null),xt(e,n)},Ct=function(e,t,r){if(pe[t]||ut(t,e)||Oe&&(t===`id`||t===`name`)&&(r in n||r in q))return!1;let i=V[t]||me.attributeCheck instanceof Function&&me.attributeCheck(t,e);return he&&wi(ae,t)||U&&wi(oe,t)?!0:i?Re[t]||wi(ue,hi(r,ce,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&gi(r,`data:`)===0&&Ie[e]||ge&&!wi(se,hi(r,ce,``))?!0:!r:Tt(e)&&$(H.tagNameCheck,e)&&$(H.attributeNameCheck,t,e)||t===`is`&&H.allowCustomizedBuiltInElements&&$(H.tagNameCheck,r)},wt=Oi({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Tt=function(e){return!wt[fi(e)]&&wi(le,e)},Et=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return j(r);case`TrustedScriptURL`:return ee(r)}return r},Dt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!ht(e)||(it(e),!1)}catch{return st(t,e),!1}},Ot=function(e,n){if(_t(R.beforeSanitizeAttributes,e,null),xt(e,n))return;let r=e.attributes;if(!r||ht(e))return;V=bt(R.uponSanitizeAttribute,V,de,Ce);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0},a=r.length,o=Qe(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=Qe(s),d=l,f=s===`value`?d:_i(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,_t(R.uponSanitizeAttribute,e,i),f=i.attrValue,ke&&(u===`id`||u===`name`)&&gi(f,Ae)!==0&&(st(s,e,n),f=Ae+f,p=!0),ye&&wi(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){st(s,e,n);continue}if(u===`attributename`&&mi(f,`href`)){st(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){st(s,e,n);continue}if(!_e&&wi(ia,f)){st(s,e,n);continue}if(ve&&(f=pt(f)),!Ct(o,u,f)){st(s,e,n);continue}f=Et(o,u,c,f),f!==d&&Dt(e,s,c,f)&&p&&ci(t.removed)}}_t(R.afterSanitizeAttributes,e,null),xt(e,n)},kt=function(e){let t=null,n=Z(e);for(_t(R.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(_t(R.uponSanitizeShadowNode,t,null),St(t,e),Ot(t,e),gt(t.content)&&kt(t.content),C(t)===aa.element){let e=v(t);gt(e)&&(At(e),kt(e))}_t(R.afterSanitizeShadowDOM,e,null)},At=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){kt(e.shadow);continue}let n=e.node,r=C(n)===aa.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&Qe(e)===`template`){let e=n.content;gt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);gt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!Q(e)&&(e=ji(e),typeof e!=`string`))throw Ti(`dirty is not a string, aborting`);if(!t.isSupported)return e;xe?(z=Se,V=Ce):J(n),(R.uponSanitizeElement.length>0||R.uponSanitizeAttribute.length>0)&&(z=Ai(z)),R.uponSanitizeAttribute.length>0&&(V=Ai(V)),t.removed=[];let c=Me&&typeof e!=`string`&&Q(e);if(c){dt(e);let t=w(e);if(typeof t==`string`){let n=Qe(t);if(!z[n]||fe[n])throw ot(e),Ti(`root node is forbidden and cannot be sanitized in-place`)}if(ht(e))throw ot(e),Ti(`root node is clobbered and cannot be sanitized in-place`);try{At(e)}catch(t){throw ot(e),t}}else if(Q(e))i=ft(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===aa.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),At(i);else{if(!Te&&!ve&&!be&&e.indexOf(`<`)===-1)return T&&De?j(e):e;if(i=ft(e),!i)return Te?null:De?E:``}i&&we&&it(i.firstChild);let l=c?e:i;try{let e=Z(l);for(;o=e.nextNode();)St(o,l),Ot(o,l),gt(o.content)&&kt(o.content)}catch(n){throw c&&(ot(e),oi(t.removed,e=>{e.element&&lt(e.element)})),n}if(c){let n=!1;if(oi(t.removed,t=>{t.element&&(t.element===e&&(n=!0),lt(t.element))}),n)throw Ti(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return ve&&mt(e),e}if(Te){if(ve&&mt(i),Ee)for(s=te.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(V.shadowroot||V.shadowrootmode)&&(s=L.call(r,s,!0)),s}let u=be?i.outerHTML:i.innerHTML;return be&&z[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&wi($i,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
78
+ `+u),ve&&(u=pt(u)),T&&De?j(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};J(e),xe=!0,Se=z,Ce=V},t.clearConfig=function(){K=null,xe=!1,Se=null,Ce=null,T=D,E=``},t.isValidAttribute=function(e,t,n){K||J({});let r=Qe(e),i=Qe(t);return Ct(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Si(R,e)&&li(R[e],t)},t.removeHook=function(e,t){if(Si(R,e)){if(t!==void 0){let n=si(R[e],t);return n===-1?void 0:ui(R[e],n,1)[0]}return ci(R[e])}},t.removeHooks=function(e){Si(R,e)&&(R[e]=[])},t.removeAllHooks=function(){R=da()},t}var ha=ma(),ga=l(h(),1),_a=`kw-vibeable`,va=`kw-vibe-slot`;function ya(e){window.dispatchEvent(new CustomEvent(_a,{detail:e}))}async function ba(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 xa({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=ee.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?`${j(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 ba(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:Ca,"data-vibe":t,children:[(0,I.jsxs)(`div`,{className:wa,children:[(0,I.jsx)(L,{name:`web`,className:`text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate text-base font-medium`,title:i?.path,children:t}),(0,I.jsx)(Ea,{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)(L,{name:`bolt`,className:`ms-sm`}),` reloaded`]}),(0,I.jsx)(`span`,{className:`flex-1`}),i?.config.dev&&(w?.running?(0,I.jsx)(G,{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)(G,{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)(G,{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)(G,{icon:`refresh`,label:`reload preview`,title:`Reload the preview`,onClick:x}),(0,I.jsx)(G,{icon:`open_in_new`,label:`open in new tab`,title:`Open in a new tab`,onClick:()=>window.open(i?j(i.url):``,`_blank`,`noopener`),disabled:!i}),e&&r&&(0,I.jsx)(G,{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:Ta,children:[(0,I.jsx)(`span`,{className:`flex-1`,children:u||i?.configError}),u&&(0,I.jsx)(G,{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(`
79
+ `):`(no output yet)`})]})}var Sa=`vibeable-pane flex flex-col overflow-hidden rounded-2xl bg-surface-2`,Ca=`${Sa} min-h-0 min-w-0 flex-1`,wa=`flex min-h-11 flex-none items-center gap-2 border-b border-line py-1.5 pr-2 pl-3.5`,Ta=`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 Ea({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)(K,{tone:e}),n]})}function Da({chatId:e,slug:t,onClosed:n}){let[r,i]=(0,v.useState)(``);return(0,I.jsxs)(`aside`,{className:P(Sa,`max-w-[420px] min-w-[320px] flex-none self-start`),"data-vibe":t,children:[(0,I.jsxs)(`div`,{className:wa,children:[(0,I.jsx)(L,{name:`web`,className:`text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate text-base font-medium`,children:t}),(0,I.jsx)(Ea,{tone:`bad`,children:`vibeables are off`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{icon:`close`,label:`close preview`,title:`Detach the app from this chat`,onClick:()=>ba(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:Ta,children:(0,I.jsx)(`span`,{className:`flex-1`,children:r})})]})}var Oa=`kw-vibeable-agent`;async function ka(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 ba(r.id,e),H(`/agents/chats/${r.id}`)}function Aa({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(Oa);return e===`codex`||e===`pi`?e:`claude`}catch{return`claude`}}),_=ye(),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`)}}},j=async e=>{E(e,`open`);try{await ka(e,h)}catch(t){O(e,t),D(e)}},ee=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(Oa,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)(et,{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)(Q,{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)(W,{type:`submit`,variant:`primary`,icon:`add`,busy:!!l.__new,disabled:!a.trim(),children:l.__new?`creating…`:`new app`})]}),d.__new&&(0,I.jsx)(et,{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)(K,{tone:t.tone}),(0,I.jsx)(rt,{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 `,Ge(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)(vt,{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)(W,{variant:`primary`,icon:`chat`,busy:n===`open`,disabled:!!n,onClick:()=>void j(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)(W,{variant:`danger`,icon:`delete`,onClick:()=>void ee(e.slug),children:`confirm remove`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>m(!1),children:`cancel`})]}):(0,I.jsx)(W,{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)(et,{tone:`bad`,children:e.configError||d[e.slug]}),(0,I.jsx)(xa,{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)(Tt,{title:`apps`,count:t?.enabled?b.length:void 0,action:t?.enabled&&(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/vibeables/new`,children:`new`})}),(0,I.jsx)(Et,{icon:`filter_list`,value:s,placeholder:`search apps`,"aria-label":`search apps`,onChange:e=>c(e.target.value)}),(0,I.jsxs)(Dt,{children:[S.map(t=>{let n=P(t);return(0,I.jsx)(`div`,{className:`vibeable-row`,"data-vibeable":t.slug,children:(0,I.jsx)(Z,{href:`/vibeables/${encodeURIComponent(t.slug)}`,active:t.slug===e,size:`sm`,leading:(0,I.jsx)(K,{tone:n.tone}),title:t.slug,sub:`${n.label}${t.dev?` · ${t.dev}`:``}`,meta:t.updatedAt&&(0,I.jsx)(`span`,{title:t.updatedAt,children:Ge(t.updatedAt)})})},t.slug)}),t&&b.length===0&&(0,I.jsx)(Ot,{children:`nothing built yet`}),t&&b.length>0&&S.length===0&&(0,I.jsx)(Ot,{children:`no vibeable matches`}),r&&(0,I.jsx)(et,{tone:`bad`,children:r})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:F})]})}function ja({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)(Fa,{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)(Fa,{agents:n?.agents??[]})}function Ma({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)(Fa,{agents:i?.agents??[]}):n===`edit`&&o?(0,I.jsx)(Fa,{channel:o,agents:i?.agents??[]},o.slug):n===`channel`&&o?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Vo,{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)(Na,{}),(0,I.jsxs)(`div`,{className:`runs-screen channels-screen`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Tt,{title:`channels`,action:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/channels/new`,children:`new`})}),(0,I.jsxs)(Dt,{children:[a.map(e=>(0,I.jsx)(Z,{href:`/channels/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,leading:(0,I.jsx)(K,{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:We(e.updatedAt)},e.slug)),r&&a.length===0&&(0,I.jsx)(Ot,{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 Na(){return(0,I.jsx)(Y,{className:`m-auto`,action:(0,I.jsx)(W,{variant:`primary`,icon:`add`,href:`/channels/new`,children:`new channel`}),children:null})}function Pa({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)(xt,{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 Fa({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)(at,{width:`narrow`,children:(0,I.jsx)(X,{title:e?`edit #${e.slug}`:`new channel`,actions:e&&(0,I.jsx)(W,{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)($,{label:`name`,children:(0,I.jsx)(Q,{value:n,placeholder:`e.g. Website relaunch`,onChange:e=>r(e.target.value),autoFocus:!0})}),(0,I.jsx)($,{label:`purpose — one line the agents read`,children:(0,I.jsx)(Q,{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)(Pa,{agents:m,checked:o,onToggle:h,none:`no agents yet — create one on the agents screen first`})]}),(0,I.jsx)($,{label:`responder — answers when a message mentions nobody`,children:(0,I.jsxs)(vt,{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)(et,{tone:`bad`,children:f}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(W,{variant:`primary`,busy:u,disabled:!n.trim()||o.length===0,onClick:()=>void g(),children:u?`saving…`:e?`save`:`create channel`}),(0,I.jsx)(W,{variant:`quiet`,href:e?`/channels/${encodeURIComponent(e.slug)}`:`/channels`,children:`cancel`})]})]})})})}function Ia({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)(tt,{className:`text-fg`,children:`add a coworker`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{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)($,{label:`channel name`,children:(0,I.jsx)(Q,{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)(Pa,{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)(et,{tone:`bad`,children:m}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(W,{variant:`primary`,busy:f,disabled:!c.trim()||u.length===0,onClick:()=>void g(),children:f?`creating…`:`create channel`}),(0,I.jsx)(W,{variant:`quiet`,onClick:i,children:`cancel`})]})]})]})})}var La=`kw-sessions-list`,Ra=(()=>{try{return localStorage.getItem(La)===`open`}catch{return!1}})(),za=new Set;function Ba(e){Ra=e;try{localStorage.setItem(La,e?`open`:`hidden`)}catch{}za.forEach(e=>e())}function Va({busy:e,onClick:t,href:n}){return(0,I.jsx)(G,{icon:e?`progress_activity`:`add`,label:`new chat`,size:`sm`,className:`mb-1 ml-1 rounded-full`,disabled:e,onClick:t,href:n})}function Ha(){return(0,v.useSyncExternalStore)(e=>(za.add(e),()=>za.delete(e)),()=>Ra)}var Ua=e=>`kw-tabs:${e}`,Wa=e=>{try{let t=JSON.parse(localStorage.getItem(Ua(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},Ga=(e,t)=>{try{localStorage.setItem(Ua(e),JSON.stringify(t))}catch{}};function Ka({name:e,onDone:t}){let[n,r]=(0,v.useState)(e),i=n.replace(/\s+/g,` `).trim().slice(0,80);return(0,I.jsx)(`input`,{autoFocus:!0,value:n,"aria-label":`chat name`,maxLength:80,className:`-mb-px w-[220px] flex-none self-end rounded-t-[10px] border border-b-0 border-accent bg-surface px-3 py-[7px] font-[inherit] text-sm font-medium text-fg outline-none`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onKeyDown:n=>{n.key===`Enter`&&t(i&&i!==e?i:void 0),n.key===`Escape`&&t()},onBlur:()=>t(i&&i!==e?i:void 0)})}var qa=`kw-strip-end`;function Ja({children:e}){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=document.getElementById(qa);e!==t&&n(e)}),t?(0,ga.createPortal)(e,t):null}function Ya({storeKey:e,label:t,fallbackTitle:n,chatId:r,filter:i,hrefOf:a,closeHref:o,subOf:s,actions:c}){let l=N(`chats.list`,{},{refresh:r}),u=(0,v.useMemo)(()=>i(l?.chats??[]),[l,i]),d=(0,v.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]),f=Ha(),[p,m]=(0,v.useState)(()=>Wa(e)),[h,g]=(0,v.useState)(!1),_=t=>{m(t),Ga(e,t)};(0,v.useEffect)(()=>{r&&!p.includes(r)&&_([...p,r])},[r]),(0,v.useEffect)(()=>{if(!l)return;let e=p.filter(e=>d.has(e));e.length!==p.length&&_(e)},[l]);let y=e=>{let t=p.indexOf(e),n=p.filter(t=>t!==e);if(_(n),e!==r)return;let i=d.get(n[Math.min(Math.max(t,0),n.length-1)]??``);H(i?a(i):o)},b=async e=>{window.confirm(`Delete ${t===`chats`?`chat`:`session`} "${e.title||e.id}"?`)&&(await A.request(`chats.delete`,{id:e.id}).catch(()=>{}),p.includes(e.id)&&y(e.id))},[x,S]=(0,v.useState)(null),C=async(e,t)=>{S(null),await A.request(`chats.rename`,{id:e,body:{title:t}}).catch(()=>null)},w=l?p.filter(e=>d.has(e)):[],T=e=>e.scope.kind===`channel`?e.title||`#${e.scope.slug}`:e.title||n;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`nav`,{className:`order-first col-span-full flex min-w-0 items-end gap-1 border-b border-line bg-surface-2 pt-1.5 pr-2 pl-1.5`,"aria-label":`open chats`,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(`mb-1 inline-flex flex-none cursor-pointer items-center gap-1 self-center rounded-control px-2 py-1 text-2xs transition-colors`,f?`bg-accent-soft text-on-accent-soft`:`text-fg-2 hover:bg-surface hover:text-fg`),onClick:()=>Ba(!f),title:f?`hide the ${t} list`:`show all ${t}`,"aria-label":`${t} list`,"aria-pressed":f,children:[(0,I.jsx)(L,{name:`view_list`,className:`ms-sm`}),l&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:u.length})]}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 overflow-x-auto [scrollbar-width:none]`,role:`tablist`,children:[w.map(e=>{let t=d.get(e),n=e===r;return x===e?(0,I.jsx)(Ka,{name:T(t),onDone:t=>t?void C(e,t):S(null)},e):(0,I.jsxs)(U,{href:a(t),className:P(`session-tab group/tab -mb-px inline-flex max-w-[220px] min-w-0 flex-none animate-tab-in items-center gap-1.5 self-end`,`rounded-t-[10px] border border-b-0 py-[7px] pr-1.5 pl-3 text-sm font-medium no-underline transition-colors`,n?`border-line bg-surface text-fg`:`border-transparent text-fg-2 hover:bg-surface`),role:`tab`,"aria-selected":n,title:`${T(t)} · double-click to rename`,onDoubleClick:t=>{t.preventDefault(),S(e)},children:[(t.busy||t.awaitingApproval)&&(0,I.jsx)(K,{tone:t.awaitingApproval?`bad`:`working`,title:t.awaitingApproval?`waiting for your approval`:`working`}),t.scope.kind===`channel`&&(0,I.jsx)(L,{name:`forum`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`truncate`,children:T(t)}),n&&(0,I.jsx)(`button`,{type:`button`,className:`inline-flex flex-none cursor-pointer rounded-md p-0.5 text-fg-2 opacity-0 transition-opacity group-hover/tab:opacity-100 hover:bg-surface-2 hover:text-fg focus-visible:opacity-100 pointer-coarse:opacity-100`,"aria-label":`rename ${T(t)}`,title:`rename`,onClick:t=>{t.preventDefault(),t.stopPropagation(),S(e)},children:(0,I.jsx)(L,{name:`edit`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(`inline-flex flex-none cursor-pointer rounded-md p-0.5 text-fg-2 transition-opacity hover:bg-surface-2 hover:text-fg focus-visible:opacity-100`,n?`opacity-100`:`opacity-0 group-hover/tab:opacity-100`),"aria-label":`close ${T(t)}`,title:`close tab`,onClick:t=>{t.preventDefault(),t.stopPropagation(),y(e)},children:(0,I.jsx)(L,{name:`close`,className:`ms-sm`})})]},e)}),c]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`span`,{id:qa,className:`mb-1 flex flex-none items-center gap-0.5 self-center`})]}),f&&(0,I.jsxs)(`aside`,{className:`runs-side sessions-side animate-slide-left`,children:[(0,I.jsx)(Tt,{title:t,action:(0,I.jsx)(G,{icon:`close`,label:`hide the list`,size:`sm`,onClick:()=>Ba(!1)})}),(0,I.jsxs)(Dt,{children:[u.map(e=>(0,I.jsx)(Z,{href:a(e),active:e.id===r,size:`sm`,leading:(0,I.jsx)(K,{tone:e.awaitingApproval?`bad`:e.busy?`working`:`idle`,title:e.awaitingApproval?`waiting for your approval`:void 0}),title:(0,I.jsxs)(I.Fragment,{children:[e.scope.kind===`channel`&&(0,I.jsx)(L,{name:`forum`,className:`ms-sm mr-1 align-[-3px]`}),T(e)]}),sub:(0,I.jsxs)(I.Fragment,{children:[s&&(0,I.jsxs)(I.Fragment,{children:[s(e),` · `]}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:We(e.updatedAt)})]}),actions:(0,I.jsx)(G,{icon:`close`,size:`sm`,label:t===`chats`?`delete chat`:`delete session`,disabled:h,onClick:()=>{g(!0),b(e).finally(()=>g(!1))}})},e.id)),l&&u.length===0&&(0,I.jsxs)(Ot,{children:[`no `,t,` yet`]})]})]})]})}var Xa=`kw-me`;function Za(){try{return localStorage.getItem(Xa)||``}catch{return``}}function Qa(e){try{localStorage.setItem(Xa,e)}catch{}}function $a(e,t){A.request(`chats.cancel`,{id:e,body:t?{agent:t}:{}}).catch(()=>{})}var eo=(e,t=90)=>{let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n};function to(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=eo(s.text));continue}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=eo(`${s.kind&&s.kind!==`other`?`${s.kind}: `:``}${s.title}`));break;case`text`:a&&(o+=s.text,(!i||i.startsWith(`says: `))&&(i=eo(`says: ${o}`)))}}return{task:r,now:i}}function no(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 ro=(0,v.createContext)(()=>`The agent`),io=()=>(0,v.useContext)(ro);function ao(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 oo(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`?`${ze.emoji} ${ze.name}`:`The assistant`}var so=`kw-browse`;function co(e){window.dispatchEvent(new CustomEvent(so,{detail:e}))}function lo(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 uo(e){let t=e.target.closest?.(`a.md-browse`);t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.button!==0||(e.preventDefault(),co(t.href)))}var fo=`kw-browser-tabs`;function po(e){try{return new URL(e).host.replace(/^www\./,``)}catch{return e}}function mo(e){let t=e.trim();return t?/^[a-z]+:\/\//i.test(t)?t:`https://${t}`:``}function ho({storeKey:e,onTabs:t}){let n=`${fo}:${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(so,e),()=>window.removeEventListener(so,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=mo(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:po(e.url)}),(0,I.jsx)(G,{icon:`close`,label:`Close ${po(e.url)}`,className:`size-6 text-inherit`,onClick:()=>m(e.id)})]},e.id)),(0,I.jsx)(G,{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)(L,{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)(L,{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)(L,{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:po(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)(L,{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)(L,{name:`open_in_new`,className:`ms-sm align-[-3px]`}),` next to a link in the chat.`]})]})]})]})}var go={knowledge:`knowledge`,vibeable:`vibeables`,repo:`repos`,workflow:`workflows`,agent:`agents`,project:`projects`,contact:`contacts`,place:`places`,event:`events`,presentation:`presentations`},_o=RegExp(`(?<![\\w/:.@-])(${Object.keys(go).join(`|`)}):([a-z0-9][a-z0-9-]{0,48})(?![\\w-])`,`g`),vo=e=>{let[t,n]=e.split(`:`);return`#/${go[t]}/${encodeURIComponent(n)}`},yo=`md-ref rounded-[5px] bg-surface-2 px-1 py-px font-mono text-[0.9em] text-accent no-underline hover:underline`;function bo(e){if(!_o.test(e))return e;_o.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(_o.lastIndex=0,!_o.test(t))continue;let n=document.createDocumentFragment(),r=0;_o.lastIndex=0;for(let e of t.matchAll(_o)){n.append(t.slice(r,e.index));let i=document.createElement(`a`);i.className=yo,i.href=vo(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 xo=(e,t)=>!e&&!t||!!e&&!!t&&e.kind===t.kind&&(e.kind===`human`?e.name===t.name:e.slug===t.slug);function So(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`&&xo(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`&&xo(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 Co({b:e,chatId:t}){let[n,r]=(0,v.useState)({}),[i,a]=(0,v.useState)(!1),o=io(),[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)(wo,{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)(W,{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)(W,{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)(Q,{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)(Q,{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)(W,{variant:`primary`,disabled:i||f,onClick:()=>u(`accept`),children:`answer`}),(0,I.jsx)(W,{disabled:i,onClick:()=>u(`decline`),children:`skip`})]})]}):(0,I.jsx)(To,{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 wo({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 To({children:e}){return(0,I.jsx)(`div`,{className:`mt-1.5 font-mono text-xs text-fg-2`,children:e})}function Eo({b:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=io(),[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)(wo,{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)(W,{variant:e.kind?.startsWith(`allow`)?`primary`:`secondary`,disabled:n,title:e.name,onClick:()=>c(e.optionId),children:Do(e)},e.optionId))}):(0,I.jsx)(To,{children:e.resolved?`→ ${(()=>{let t=e.options.find(t=>t.optionId===e.resolved);return t?Do(t):e.resolved})()}`:a?`→ ${a}`:`→ dismissed`})})}function Do(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 Oo=new Set([`tool`,`thought`,`subagent`,`task`,`files`]);function ko({id:e,events:t,busy:n,channel:r,agentMap:i,working:a,focus:o}){let s=ye(),c=(0,v.useMemo)(()=>{let e=So(o?t.filter(e=>e.from?.kind===`human`||e.from?.kind===`agent`&&e.from.slug===o):t);return s||o?e:e.filter(e=>!Oo.has(e.kind))},[t,s,o]),l=io(),u=(0,v.useMemo)(()=>ao(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:uo,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||!xo(a.from,t.from)||a.kind===`error`)?t.from:void 0;return(0,I.jsxs)(`div`,{className:`contents`,children:[o&&(0,I.jsx)(Ao,{from:o,agentMap:i}),(0,I.jsx)(Po,{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)(K,{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)(K,{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 Ao({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 jo({text:e,small:t}){let n=(0,v.useMemo)(()=>lo(bo(ha.sanitize(zr.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 Mo({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)(K,{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 No=(e,t=`working`)=>e===`completed`?`ok`:e===`failed`?`bad`:e===`running`||e===void 0?t:`idle`;function Po({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)(tt,{className:`mb-0.5 block text-[10px] opacity-70`,children:`steered in`}),e.by?.email&&(0,I.jsx)(tt,{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)(L,{name:`attach_file`,className:`ms-sm`}),` `,e.name]},e.name)})})]});case`agent`:return(0,I.jsx)(jo,{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)(Mo,{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?Lo(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)(Mo,{tone:No(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)(Po,{b:e,chatId:t,nested:!0},e.key))]})]});case`task`:return(0,I.jsxs)(Mo,{tone:No(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)(tt,{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)(L,{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)(Mo,{tone:`ok`,kind:`changed`,children:[e.paths.join(`
80
+ `),(!e.complete||e.note)&&(0,I.jsxs)(`span`,{className:`opacity-70`,children:[` · `,e.note??`list may be incomplete`]})]});case`question`:return(0,I.jsx)(Co,{b:e,chatId:t});case`permission`:return(0,I.jsx)(Eo,{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)(L,{name:`error`,className:`ms-sm`}),` `,e.text]});case`failure`:return(0,I.jsx)(Io,{b:e,chatId:t})}}var Fo={retry:`try again`,login:`sign in again`,new_session:`start a fresh session`};function Io({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.`);return}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)(L,{name:o.severity===`warning`?`warning`:`error`,className:`ms-sm`}),(0,I.jsx)(tt,{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)(W,{size:`sm`,disabled:n,className:`border-current text-inherit`,onClick:()=>c(e),children:Fo[e]},e))})]})}function Lo(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 Ro({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=io()().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)(Za),[k,j]=(0,v.useState)(!1),ee=(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 R=/^\/([\w-]*)$/.exec(c)?.[1],ne=R!==void 0&&!T?x.filter(e=>e.name.toLowerCase().startsWith(R.toLowerCase())):[],re=new Set(x.map(e=>e.name.toLowerCase())),ie=R!==void 0&&!T?a.filter(e=>e.name.toLowerCase().startsWith(R.toLowerCase())&&!re.has(e.name.toLowerCase())):[],ae=ee.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=we(),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}),z=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=ee.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}})),...z.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=ee.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}))].slice(0,15),V=B.length>0,de=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:zo,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)(L,{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)(L,{name:`close`,className:`ms-sm`})})]},e.name)),h>0&&(0,I.jsx)(`span`,{className:zo,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)(Q,{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:()=>{Qa(D.trim()),j(!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:()=>j(!0),title:`change your name`,children:[D||`you`,` `,(0,I.jsx)(L,{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===de?`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)(et,{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:ee,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(`
81
+ `).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((de+1)%B.length);if(e.key===`ArrowUp`)return e.preventDefault(),w((de-1+B.length)%B.length);if(e.key===`Tab`||e.key===`Enter`)return e.preventDefault(),B[de].pick();if(e.key===`Escape`)return e.preventDefault(),E(!0)}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}}),t&&(0,I.jsx)(W,{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)(G,{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)(L,{name:F?`alt_route`:`send`,className:`text-[19px]`})})]})]})}var zo=`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 Bo({id:e,live:t}){let n=ye(),[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)(L,{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)(vt,{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 Vo({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=we(),C=ye(),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?(ya({chatId:e,slug:T}),D(document.getElementById(va)),()=>ya(null)):D(null),[e,T]);let O=(0,v.useMemo)(()=>no(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=ee.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]),j=(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)(K,{tone:j?`working`:`ok`}),(0,I.jsxs)(rt,{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)(W,{size:`sm`,variant:`danger`,icon:`stop`,title:`interrupt every agent working in this channel`,onClick:()=>$a(e),children:[`stop all (`,k.length,`)`]}),(0,I.jsx)(W,{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=to(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)(K,{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)(tt,{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)(tt,{className:`mr-1`,children:`last`}),` `,a.task]})})]})]}),i&&(0,I.jsx)(G,{icon:`stop`,label:`interrupt @${t}`,variant:`danger`,size:`sm`,className:`size-6`,onClick:()=>$a(e,t)}),(0,I.jsx)(G,{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)(W,{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)(W,{size:`sm`,variant:`danger`,icon:`stop`,onClick:()=>$a(e,b),children:[`stop @`,b]})]}),(0,I.jsxs)(ro.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)(ko,{id:e,events:l,busy:j,channel:r,agentMap:F,working:k,focus:b??void 0}),(0,I.jsx)(Ro,{id:e,busy:j,scope:o.scope,channel:r,agentMap:F})]})]});let te=o.scope.kind===`agent`&&!o.scope.routine||o.scope.kind===`project`,L=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)(Ja,{children:(0,I.jsx)(Uo,{id:e,project:o.project,onFiled:e=>s(t=>t&&{...t,project:e})})}),te&&(0,I.jsx)(Ja,{children:(0,I.jsx)(G,{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:j})}),(C||L)&&(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)(W,{size:`sm`,variant:`quiet`,icon:`call_split`,busy:h,className:o.agent===`codex`?`opacity-50`:void 0,disabled:j,"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)(Bo,{id:e,live:O}),C&&o.scope.kind===`run`&&(0,I.jsx)(Ho,{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)(Ho,{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)(Ho,{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)(Da,{chatId:e,slug:o.vibeable,onClosed:s}),(0,I.jsxs)(ro.Provider,{value:()=>oo(o.scope,w,t),children:[(0,I.jsx)(ko,{id:e,events:l,busy:j}),(0,I.jsx)(Ro,{id:e,busy:j,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,ga.createPortal)((0,I.jsx)(xa,{chatId:e,slug:T,agentBusy:j,onClosed:s},T),E),p&&o.scope.kind===`agent`&&(0,I.jsx)(Ia,{chatId:e,agentSlug:o.scope.slug,title:M,onClose:()=>m(!1)}),p&&o.scope.kind===`project`&&(0,I.jsx)(Ia,{chatId:e,project:o.scope.slug,title:M||t||``,onClose:()=>m(!1),onCreated:a})]})}function Ho({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 Uo({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)(L,{name:`folder`,className:`ms-sm`}),(0,I.jsxs)(vt,{"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))]})]})}var Wo=[{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`}];async function Go(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 Ko(){let[e,t]=(0,v.useState)(`claude`),[n,r]=(0,v.useState)(!0),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(null);return(0,v.useEffect)(()=>s(null),[e]),(0,I.jsxs)(at,{width:`narrow`,children:[(0,I.jsx)(rt,{children:`new chat`}),(0,I.jsxs)(X,{title:`agent`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5 p-4 max-[940px]:grid-cols-1`,children:Wo.map(n=>{let r=e===n.id;return(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:P(`flex cursor-pointer flex-col gap-0.5 rounded-card border px-3.5 py-3 text-left transition-colors`,r?`border-transparent bg-accent-soft text-on-accent-soft`:`border-line bg-transparent text-fg hover:bg-surface-2`),onClick:()=>t(n.id),children:[(0,I.jsx)(`b`,{className:`text-base font-medium`,children:n.label}),(0,I.jsx)(`span`,{className:P(`text-xs`,r?`text-on-accent-soft`:`text-fg-2`),children:n.hint})]},n.id)})}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-4 pb-3.5 text-sm text-fg-2`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`size-[15px] accent-accent`,checked:n,onChange:e=>r(e.target.checked)}),(0,I.jsx)(`span`,{className:`text-fg`,children:`kraftwerk-aware`}),` — agent gets workflows + recent runs as context`]}),(0,I.jsx)(`div`,{className:`px-4 pb-4`,children:(0,I.jsx)(W,{variant:`primary`,busy:i,onClick:async()=>{a(!0),await Go(e,{kind:n?`kraftwerk`:`general`}),a(!1)},children:i?`starting…`:`start chat`})})]}),e!==`pi`&&(0,I.jsxs)(X,{title:`continue a session`,actions:o===null&&(0,I.jsxs)(W,{size:`sm`,variant:`quiet`,icon:`history`,onClick:async()=>{s(`loading`);let t=await A.call(`agents.sessions`,{query:{agent:e}}).catch(()=>({sessions:[]}));s((t.sessions??[]).slice(0,20))},children:[`list `,e,` sessions`]}),children:[o===null&&(0,I.jsxs)(Y,{className:`py-6`,children:[`Pick up a `,e,` session started outside kraftwerk.`]}),o===`loading`&&(0,I.jsxs)(Y,{className:`py-6`,children:[`asking `,e,`…`]}),Array.isArray(o)&&o.length===0&&(0,I.jsxs)(Y,{className:`py-6`,children:[`no `,e,` sessions in this project`]}),Array.isArray(o)&&o.length>0&&(0,I.jsx)(`div`,{className:`flex flex-col p-1.5`,children:o.map(t=>(0,I.jsx)(Z,{size:`sm`,title:t.title||t.sessionId.slice(0,8),meta:t.updatedAt&&new Date(t.updatedAt).toLocaleString(),innerProps:{title:t.sessionId},onClick:async()=>{i||(a(!0),await Go(e,{kind:n?`kraftwerk`:`general`},t.sessionId),a(!1))}},t.sessionId))})]})]})}var qo=[`active`,`paused`,`done`,`archived`],Jo={active:`working`,paused:`idle`,done:`ok`,archived:`idle`},Yo={active:`accent`,paused:`neutral`,done:`ok`,archived:`neutral`},Xo={"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`},Zo=e=>Xo[e]??e,Qo=[{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`}],$o=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),es=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),ts=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function ns(e,t){let n=await A.request(`projects.save`,{slug:e,body:t});if(!n.ok)throw Error(M(n));return n.data}function rs({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=ye(),l=Ha(),u=(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 u(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]),(0,v.useEffect)(()=>{u()},[t,n,u]);let d=i?.projects??[],f=t?d.find(e=>e.slug===t):void 0,p=[...d].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&p&&H(`/projects/${encodeURIComponent(p)}`,{replace:!0})},[n,p]);let m;return m=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`&&d.length===0?(0,I.jsx)(as,{root:i.root,onCreated:u}):n===`home`?(0,I.jsx)(Y,{children:`loading…`}):t&&!f?(0,I.jsxs)(Y,{icon:`folder_off`,children:[`no project named `,t]}):n===`chat`&&t&&r===`new`?(0,I.jsx)(ss,{slug:t,title:f?.title??t},t):n===`chat`&&t&&r?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(cs,{chatId:r,title:f?.title??t,goal:f?.goal},r)}):n===`info`&&t?(0,I.jsx)(ds,{slug:t,onChanged:u},t):t?(0,I.jsx)(os,{slug:t,title:f?.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&&f?`has-tabs`:``} ${t&&f&&l?`has-sessions`:``}`,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Tt,{title:`projects`,count:i?.enabled?d.length:void 0,action:i?.enabled&&(c||d.length===0)&&(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/projects/new`,children:`new`})}),(0,I.jsxs)(Dt,{children:[d.map(e=>(0,I.jsx)(Z,{href:`/projects/${encodeURIComponent(e.slug)}`,active:e.slug===t,size:`sm`,innerProps:{"data-project":e.slug},leading:(0,I.jsx)(K,{tone:e.configError?`bad`:Jo[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:Ge(e.updatedAt)})},e.slug)),i&&i.enabled&&d.length===0&&(0,I.jsx)(Ot,{children:`no projects yet`}),o&&(0,I.jsx)(et,{tone:`bad`,children:o})]})]}),t&&f&&(0,I.jsx)(ls,{slug:t,chatId:r===`new`?void 0:r}),(0,I.jsx)(`div`,{className:`runs-main`,children:m})]})}function is(){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)(as,{root:e?.root,onCreated:async()=>{}})}function as({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)(rt,{size:`lg`,children:`new project`}),(0,I.jsx)(X,{children:(0,I.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,I.jsx)($,{label:`title`,children:(0,I.jsx)(Q,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})}),(0,I.jsx)($,{label:`goal (one line)`,children:(0,I.jsx)(Q,{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)(W,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim(),children:o?`creating…`:`create project`})}),c&&(0,I.jsx)(et,{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 os({slug:e,title:t}){let[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=!0;return r(!1),A.call(`chats.list`).then(n=>{if(!t)return;let i=n.chats.find(t=>t.scope.kind===`project`&&t.scope.slug===e);i?H(`/projects/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,I.jsx)(ss,{slug:e,title:t}):(0,I.jsx)(Y,{children:`loading…`})}function ss({slug:e,title:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&r(e)).catch(()=>{}),()=>{t=!1}},[e]);let o=Qo.find(e=>e.id===n?.harness)??Qo[0],s=N(`agents.list`,{}),c=(n?.links.agents??[]).flatMap(e=>s?.agents.filter(t=>t.slug===e.slug)??[]),[l,u]=(0,v.useState)(null);return(0,I.jsxs)(at,{width:`narrow`,children:[(0,I.jsxs)(rt,{size:`lg`,children:[ze.emoji,` `,ze.name,` · `,t]}),(0,I.jsxs)(X,{title:`runs on`,children:[(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded-card border border-transparent bg-accent-soft px-3.5 py-3 text-left text-on-accent-soft transition-[filter] hover:enabled:brightness-[0.97] disabled:cursor-default disabled:opacity-60`,disabled:i||!n,onClick:async()=>{a(!0),await Go(o.id,{kind:`project`,slug:e}),a(!1)},children:[(0,I.jsx)(`b`,{className:`text-base font-medium`,children:i?`starting…`:`start chat`}),(0,I.jsx)(`span`,{className:`text-xs`,children:n?`${$o(n)} — ${o.hint}`:`…`})]})}),(0,I.jsxs)(J,{className:`px-[18px] pb-3.5`,children:[`The chat starts with the project's brief, state, systems of record and links as context. Harness, model and effort are set on the `,(0,I.jsx)(U,{href:`/projects/${encodeURIComponent(e)}/info`,children:`project page`}),`, like an agent's.`]})]}),c.length>0&&(0,I.jsxs)(X,{title:`or with an agent of the project`,children:[(0,I.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:c.map(t=>(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-2.5 rounded-card border border-line bg-transparent px-3.5 py-2.5 text-left text-fg transition-colors hover:enabled:bg-surface-2 disabled:cursor-default disabled:opacity-60`,disabled:l!==null,onClick:async()=>{u(t.slug),await Go(`claude`,{kind:`agent`,slug:t.slug},void 0,e),u(null)},children:[(0,I.jsx)(`span`,{className:`text-lg`,children:t.emoji||`🤖`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,I.jsx)(`b`,{className:`text-base font-medium`,children:l===t.slug?`starting…`:t.name}),t.description&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:t.description})]})]},t.slug))}),(0,I.jsx)(J,{className:`px-[18px] pb-3.5`,children:`The agent works with its own instructions and the project's context; the chat is listed here and with the agent.`})]})]})}function cs({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)(Vo,{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)(Vo,{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)(Vo,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}function ls({slug:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useCallback)(t=>es(t,e),[e]),a=(0,v.useCallback)(t=>ts(t,e),[e]),o=N(`agents.list`,{},{interval:3e4}),s=e=>{let t=o?.agents.find(t=>t.slug===e);return t?`${t.emoji||`🤖`} ${t.name}`:e};return(0,I.jsx)(Ya,{storeKey:`project:${e}`,label:`chats`,fallbackTitle:`new chat`,chatId:t,filter:i,hrefOf:a,closeHref:`/projects/${encodeURIComponent(e)}/chat/new`,subOf:e=>e.scope.kind===`channel`?`with coworkers · #${e.scope.slug}`:e.scope.kind===`agent`?`with ${s(e.scope.slug)}`:e.agent,actions:(0,I.jsx)(Va,{busy:n,onClick:async()=>{r(!0),await Go(`claude`,{kind:`project`,slug:e}),r(!1)}})})}var us=[{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 ds({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,j]=(0,v.useState)(``),[ee,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),F=ye(),te=we(),L=e=>{r(e),h(e.title),_(e.goal),b(e.status),S(e.harness),w(e.model??``),E(e.effort??``),O(e.brief),j(e.state),M(!1)};(0,v.useEffect)(()=>{let t=!0;return A.call(`projects.get`,{slug:e}).then(e=>t&&L(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let R=()=>{M(!0),d(!1),s(``)},ne=async(n,i={})=>{l(!0),s(``);try{let a=await ns(e,n);i.keepEdits?r(a):L(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)(ot,{children:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`📁`})}),(0,I.jsx)(rt,{size:`lg`,children:n.title}),(0,I.jsx)(q,{tone:Yo[n.status],children:n.status}),(0,I.jsx)(q,{title:`harness · model · effort every chat in this project runs on`,children:$o(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)(et,{tone:`bad`,children:[`project.yml: `,n.configError]}),(0,I.jsx)(X,{title:`project`,className:`flex-none`,actions:(0,I.jsxs)(I.Fragment,{children:[u&&!ee&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`saved`}),(0,I.jsx)(W,{variant:`primary`,size:`sm`,busy:c,disabled:!ee,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)(yt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Q,{value:m,"aria-label":`title`,onChange:e=>{h(e.target.value),R()}})}),(0,I.jsx)($,{label:`status`,children:(0,I.jsx)(vt,{value:y,"aria-label":`status`,onChange:e=>{b(e.target.value),R()},children:qo.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})})]}),(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`harness`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(vt,{value:x,"aria-label":`harness`,onChange:e=>{S(e.target.value),R()},children:Qo.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),(0,I.jsx)($,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Q,{value:C,"aria-label":`model`,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>{w(e.target.value),R()}})}),(0,I.jsx)($,{label:`effort`,className:`w-[140px] max-[940px]:w-auto`,children:(0,I.jsx)(vt,{value:T,"aria-label":`effort`,onChange:e=>{E(e.target.value),R()},children:qe.map(e=>(0,I.jsx)(`option`,{value:e,children:e||`default`},e))})})]}),(0,I.jsx)($,{label:`goal (one line)`,children:(0,I.jsx)(Q,{value:g,"aria-label":`goal`,placeholder:`what the project is for`,onChange:e=>{_(e.target.value),R()}})}),(0,I.jsx)($,{label:`brief.md — what done looks like, constraints, stakeholders`,children:(0,I.jsx)(_t,{rows:10,className:`resize-y font-mono text-sm`,value:D,"aria-label":`brief`,onChange:e=>{O(e.target.value),R()}})}),(0,I.jsx)($,{label:`state.md — current state, rewritten at the end of a session`,children:(0,I.jsx)(_t,{rows:6,className:`resize-y font-mono text-sm`,value:k,"aria-label":`state`,onChange:e=>{j(e.target.value),R()}})}),o&&(0,I.jsx)(et,{tone:`bad`,children:o})]})}),(0,I.jsx)(gs,{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)(lt,{children:us.filter(e=>e.kind!==`contacts`&&e.kind!==`places`&&e.kind!==`events`||te[e.kind]).map(i=>(0,I.jsx)(ms,{kind:i.kind,label:i.label,icon:i.icon,href:i.href,links:n.links[i.kind],saving:c,onChange:(n,a)=>void fs(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)(yt,{className:`max-w-[680px]`,children:(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`new entry — a decision, a milestone`,className:`flex-1`,children:(0,I.jsx)(Q,{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)(W,{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:ha.sanitize(zr.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)(W,{size:`sm`,variant:`danger`,icon:`delete`,disabled:c,onClick:()=>void re(),children:`confirm delete`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>p(!1),children:`cancel`})]}):(0,I.jsx)(W,{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 fs(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 ps(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 ms({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 ps(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)(ct,{icon:n,title:t,"data-link-kind":e,action:!s&&(0,I.jsx)(W,{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)(L,{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)(vt,{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)(W,{disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>c(!1),children:`cancel`})]})})]})}var hs={kind:`url`};function gs({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??hs,...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)(W,{size:`sm`,icon:`add`,onClick:()=>i({...hs}),children:`add`})]}),children:(0,I.jsxs)(lt,{children:[e.map((r,i)=>(0,I.jsx)(ct,{"data-record-kind":r.kind,icon:`database`,title:(0,I.jsxs)(I.Fragment,{children:[Zo(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)(G,{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)(yt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`kind`,children:a?(0,I.jsx)(Q,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,I.jsxs)(vt,{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(Xo).map(([e,t])=>(0,I.jsx)(`option`,{value:e,children:t},e)),(0,I.jsx)(`option`,{value:`__other`,children:`other…`})]})}),(0,I.jsx)($,{label:`title`,className:`flex-1`,children:(0,I.jsx)(Q,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})}),(0,I.jsx)($,{label:`workspace / id`,children:(0,I.jsx)(Q,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})})]}),(0,I.jsx)($,{label:`url`,children:(0,I.jsx)(Q,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})}),(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`note — what lives there and how it is usually reached`,className:`flex-1`,children:(0,I.jsx)(Q,{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)(W,{disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})})}async function _s(e,t){let n=window.open(``,`_blank`);if(!n)return;let r=t?`${e}/${t}`:e;n.document.write(`<title>${xs(r)}</title><body style="font-family:system-ui;padding:40px;color:#555">preparing ${xs(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}=ys(vs(e.body??``,null)),i=!e.title||e.title===e.id||e.title===e.id.split(`/`).pop(),{html:a,title:s}=bs(ha.sanitize(zr.parse(n,{async:!1})),{title:e.title||e.id,meta:t,titleIsFallback:i});return o.push(s),`<article>
82
+ ${a}
83
+ ${r.length?`<ol class="notes">${r.map(e=>`<li id="fn-${xs(e.id)}">${ha.sanitize(zr.parseInline(e.text,{async:!1}))}</li>`).join(``)}</ol>`:``}
84
+ </article>`}).join(`
85
+ `),c=new Date().toISOString().slice(0,10),l=a?`${xs(a)} · ${xs(e)}`:xs(e),u=t?o[0]||r:e,d=t?``:`<h1 class="cover">${xs(e)}</h1>
86
+ <div class="cover-sub">${a?`${xs(a)} · `:``}knowledge bundle · ${i.length} concept${i.length===1?``:`s`} · exported ${c}</div>`,f=`<!doctype html>
87
+ <html>
88
+ <head>
89
+ <meta charset="utf-8">
90
+ <title>${xs(u)}</title>
91
+ <style>
92
+ :root { color-scheme: light; }
93
+ /* Page margins live in the sheet itself (repeating thead/tfoot cells +
94
+ cell padding), not in @page — print dialogs that override or drop CSS
95
+ page margins (macOS system dialog, "Margins: None") then still print
96
+ the intended layout. Top 14mm, right 48mm (notes), bottom 16mm, left 20mm. */
97
+ @page { size: A4; margin: 0; }
98
+ * { box-sizing: border-box; }
99
+ body {
100
+ margin: 0; background: #e9e5df;
101
+ font: 10pt/1.5 -apple-system, "Segoe UI", system-ui, sans-serif; color: #1c1b19;
102
+ font-feature-settings: "kern", "liga", "tnum";
103
+ -webkit-print-color-adjust: exact; print-color-adjust: exact;
104
+ }
105
+ .no-print {
106
+ position: sticky; top: 0; z-index: 1; display: flex; gap: 12px; align-items: center;
107
+ padding: 10px 24px; background: #f4efea; border-bottom: 1px solid #ded6cb; font-size: 13px;
108
+ }
109
+ .no-print button {
110
+ font: inherit; font-weight: 600; padding: 6px 16px; cursor: pointer;
111
+ background: #191919; color: #fff; border: none; border-radius: 999px;
112
+ }
113
+ /* Screen preview mimics the printed page incl. the note gutter. */
114
+ .sheet {
115
+ width: 210mm; margin: 24px auto; background: #fff;
116
+ border-collapse: separate; border-spacing: 0; box-shadow: 0 2px 12px rgba(0,0,0,.12);
117
+ }
118
+ .sheet > thead > tr > td { padding: 14mm 48mm 0 20mm; vertical-align: top; }
119
+ .sheet > tbody > tr > td { padding: 0 48mm 0 20mm; vertical-align: top; }
120
+ .sheet > tfoot > tr > td { padding: 16mm 0 0; }
121
+
122
+ /* Running header */
123
+ .runhead {
124
+ display: flex; justify-content: space-between; gap: 16px;
125
+ font-size: 7.5pt; line-height: 1; color: #6b6660; letter-spacing: 0.08em; text-transform: uppercase;
126
+ padding-bottom: 6px; border-bottom: 0.5pt solid #1c1b19; margin-bottom: 30px;
127
+ }
128
+
129
+ /* Cover */
130
+ .cover { margin: 0 0 3px; font-size: 22pt; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
131
+ .cover-sub { color: #6b6660; font-size: 8.5pt; margin-bottom: 26px; }
132
+
133
+ /* Concept */
134
+ article { margin-top: 36px; }
135
+ article:first-of-type { margin-top: 0; }
136
+ article header { break-inside: avoid; break-after: avoid; margin-bottom: 12px; }
137
+ article h1 { font-size: 16pt; font-weight: 700; margin: 0 0 3px; letter-spacing: -0.015em; line-height: 1.2; }
138
+ article .meta { color: #6b6660; font-size: 8pt; letter-spacing: 0.01em; }
139
+
140
+ /* Type scale for body headings (concept body starts at h2 after demotion) */
141
+ h2 { font-size: 13pt; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; margin: 22px 0 6px; break-after: avoid; }
142
+ h3 { font-size: 11pt; font-weight: 650; line-height: 1.3; margin: 18px 0 4px; break-after: avoid; }
143
+ h4 { font-size: 9.5pt; font-weight: 650; color: #3d3a36; margin: 14px 0 2px; break-after: avoid; }
144
+ h5, h6 { font-size: 10pt; font-weight: 650; margin: 12px 0 2px; }
145
+ h2 + h3, h3 + h4 { margin-top: 6px; }
146
+ .keep { break-inside: avoid; }
147
+
148
+ /* Copy */
149
+ p, ul, ol { margin: 0 0 8px; orphans: 3; widows: 3; }
150
+ ul, ol { padding-left: 16px; }
151
+ li { margin: 0 0 3px; padding-left: 2px; }
152
+ li > p { margin: 0; }
153
+ li::marker { color: #8a857e; }
154
+ ul ul, ol ol, ul ol, ol ul { margin: 2px 0 0; }
155
+ strong { font-weight: 650; }
156
+ em { font-style: italic; }
157
+ a { color: inherit; text-decoration-color: #b8b2aa; text-decoration-thickness: 0.5pt; text-underline-offset: 2px; }
158
+ hr { border: 0; border-top: 0.5pt solid #ded6cb; margin: 14px 0; }
159
+ code { font: 8.5pt/1.4 ui-monospace, "SF Mono", Menlo, monospace; background: #f2ede7; padding: 0 3px; border-radius: 3px; }
160
+ pre { background: #f2ede7; padding: 8px 10px; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; margin: 4px 0 10px; }
161
+ pre code { background: none; padding: 0; }
162
+ blockquote { margin: 6px 0 10px; padding: 1px 0 1px 12px; border-left: 2px solid #c9c2b8; color: #4d4944; }
163
+ img { max-width: 100%; }
164
+ li:has(> input[type="checkbox"]) { list-style: none; margin-left: -16px; }
165
+ input[type="checkbox"] { width: 9px; height: 9px; margin: 0 6px 0 0; vertical-align: -0.5px; }
166
+ pre, blockquote, table, img { break-inside: avoid; }
167
+
168
+ /* Tables: hairline rules, tabular figures, tight leading */
169
+ table.md { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 8.75pt; line-height: 1.35; }
170
+ table.md th, table.md td { padding: 4px 10px 4px 0; text-align: left; vertical-align: top; border-bottom: 0.5pt solid #ded6cb; }
171
+ table.md th:last-child, table.md td:last-child { padding-right: 0; }
172
+ table.md th { font-weight: 650; padding-bottom: 5px; border-top: 0.5pt solid #1c1b19; border-bottom: 0.5pt solid #1c1b19; color: #1c1b19; }
173
+ table.md tr:last-child td { border-bottom: 0.5pt solid #1c1b19; }
174
+ table.md .nw { white-space: nowrap; }
175
+
176
+ /* Footnotes */
177
+ .fnref { font-size: 6.5pt; line-height: 0; margin-left: 1px; color: #6b6660; }
178
+ .fnref + .fnref::before { content: ","; }
179
+ .notes { margin: 14px 0 0; padding: 8px 0 0 14px; border-top: 0.5pt solid #ded6cb; font-size: 8pt; line-height: 1.4; color: #6b6660; }
180
+ .notes li { margin: 0 0 2px; }
181
+ @media print {
182
+ body { background: #fff; }
183
+ .no-print { display: none; }
184
+ .sheet { width: 100%; margin: 0; box-shadow: none; }
185
+ .runhead { margin-bottom: 24px; }
186
+ }
187
+ </style>
188
+ </head>
189
+ <body>
190
+ <div class="no-print">
191
+ <span>Use “Save as PDF” in the print dialog.</span>
192
+ <button onclick="window.print()">print / save as PDF</button>
193
+ </div>
194
+ <table class="sheet">
195
+ <thead><tr><td>
196
+ <div class="runhead"><span>${l}</span><span>${c}</span></div>
197
+ </td></tr></thead>
198
+ <tbody><tr><td>
199
+ ${d}
200
+ ${s}
201
+ </td></tr></tbody>
202
+ <tfoot><tr><td></td></tr></tfoot>
203
+ </table>
204
+ <script>setTimeout(() => window.print(), 400);<\/script>
205
+ </body>
206
+ </html>`;n.location.href=URL.createObjectURL(new Blob([f],{type:`text/html`}))}function vs(e,t){return e.split(/(```[\s\S]*?```|`[^`]*`)/).map((e,n)=>n%2==1?e:e.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,n,r)=>{let i=n.trim().replace(/\.md$/,``),a=(r??i).trim();return t===null?a:`[${a}](#/knowledge/${encodeURIComponent(t)}/${i})`})).join(``)}function ys(e){let t=[];return{md:e.replace(/^\[\^([^\]]+)\]:[ \t]*(.+)$/gm,(e,n,r)=>(t.push({id:n,text:r.trim()}),``)).replace(/\[\^([^\]]+)\]/g,(e,n)=>{let r=t.findIndex(e=>e.id===n);return r>=0?`<sup class="fnref">${r+1}</sup>`:``}),notes:t}}function bs(e,t){let n=new DOMParser().parseFromString(e,`text/html`),r=t.title,i=n.body.firstElementChild;t.titleIsFallback&&i?.tagName===`H1`&&(r=i.textContent?.trim()||r,i.remove());let a=n.createElement(`header`);a.innerHTML=`<h1>${xs(r)}</h1><div class="meta">${xs(t.meta)}</div>`,n.body.prepend(a);for(let e of n.querySelectorAll(`table`)){e.classList.add(`md`);for(let t of e.querySelectorAll(`th, td`))(t.textContent??``).trim().length<=14&&t.classList.add(`nw`)}for(let e of[5,4,3,2,1])for(let t of Array.from(n.body.querySelectorAll(`:scope > h${e}`))){let r=n.createElement(`h${e+1}`);r.innerHTML=t.innerHTML,t.replaceWith(r)}for(let e of Array.from(n.body.querySelectorAll(`:scope > header, :scope > h2, :scope > h3, :scope > h4`))){let t=e.nextElementSibling;if(!t||/^H[1-6]$/.test(t.tagName))continue;let r=n.createElement(`div`);r.className=`keep`,e.replaceWith(r),r.append(e,t)}return{html:n.body.innerHTML,title:r}}function xs(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var Ss=`text-xs leading-[1.5] text-fg-2 [&_a]:text-inherit [&_code]:text-2xs`;function Cs({children:e}){return(0,I.jsx)(`span`,{className:`mt-[3px] flex flex-wrap gap-1.5`,children:e})}function ws({children:e}){return(0,I.jsx)(`div`,{className:`flex flex-col gap-[7px] py-1`,children:e})}var Ts=`resize-y font-mono text-[12.5px] leading-[1.65]`;function Es({bundles:e,onHide:t,onResize:n}){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``);(0,v.useEffect)(()=>{i({});let t=!0,n,r=async()=>{await Promise.all(e.map(async e=>{try{let n=await A.request(`knowledge.get`,{bundle:e}),r=n.ok?n.data:null;t&&i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})}catch{t&&i(t=>e in t?t:{...t,[e]:null})}})),t&&(n=setTimeout(r,6e3))};return r(),()=>{t=!1,clearTimeout(n)}},[e.join(`,`)]),(0,v.useEffect)(()=>{if(!a||d===a)return;let e=a.indexOf(`::`),t=a.slice(0,e),n=a.slice(e+2),r=!0,i,o=async()=>{try{let e=await A.request(`knowledge.concept`,{bundle:t,query:{id:n}}),i=e.ok?e.data:null;r&&c(e=>JSON.stringify(e[a])===JSON.stringify(i)?e:{...e,[a]:i})}catch{r&&c(e=>a in e?e:{...e,[a]:null})}r&&(i=setTimeout(o,6e3))};return o(),()=>{r=!1,clearTimeout(i)}},[a,d]);function b(e,t){let n=`${e}::${t}`;o(a===n?null:n)}async function x(e,t){let n=`${e}::${t}`;g(!0),y(``);try{let r=await A.request(`knowledge.putConcept`,{bundle:e,body:{id:t,content:p}});if(!r.ok)y(M(r));else if(r.data.error)y(r.data.error);else{let e=r.data;c(t=>({...t,[n]:e})),f(null)}}catch(e){y(e.message)}g(!1)}return(0,I.jsxs)(`aside`,{className:`runs-side knowledge-side`,children:[(0,I.jsx)(`div`,{className:`absolute inset-y-0 -left-[3px] z-4 w-[7px] cursor-col-resize hover:bg-accent/25`,title:`Drag to resize`,onMouseDown:e=>{e.preventDefault();let t=e.clientX,r=e.currentTarget.parentElement.offsetWidth,i=e=>n(Math.min(900,Math.max(280,r+(t-e.clientX)))),a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4 py-3.5`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,I.jsx)(tt,{children:`knowledge`}),(0,I.jsx)(`span`,{className:`truncate text-[10.5px] text-fg-2`,children:`read & kept current by this agent`})]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsxs)(W,{size:`sm`,variant:`quiet`,onClick:t,title:`Hide knowledge sidebar`,children:[`hide `,(0,I.jsx)(L,{name:`close`,className:`ms-sm`})]})]}),(0,I.jsx)(`div`,{className:`flex-1 divide-y divide-line overflow-y-auto p-1.5`,children:e.map(e=>{let t=r[e],n=l[e]===!0;return(0,I.jsxs)(`div`,{className:`px-2 pt-1.5 pb-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-0.5 py-0.5`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-[7px] rounded-xl border-0 bg-transparent px-2 py-1.5 text-left hover:bg-surface-2`,"aria-expanded":!n,onClick:()=>u({...l,[e]:!n}),children:[(0,I.jsx)(Ds,{open:!n}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-fg`,children:e}),t&&(0,I.jsx)(`span`,{className:`flex-none rounded-full bg-surface-2 px-[7px] text-[10.5px] leading-[17px] tabular-nums text-fg-2`,children:t.concepts.length})]}),(0,I.jsx)(G,{icon:`picture_as_pdf`,label:`Export this bundle as PDF`,size:`sm`,onClick:()=>void _s(e)}),(0,I.jsx)(G,{icon:`arrow_outward`,label:`Open this bundle on the knowledge screen`,size:`sm`,href:`/knowledge/${encodeURIComponent(e)}`})]}),!n&&t===null&&(0,I.jsx)(J,{className:`px-[18px] py-1.5`,children:`bundle not found`}),!n&&t?.concepts.map(t=>{let n=`${e}::${t.id}`,r=a===n,i=`/knowledge/${encodeURIComponent(e)}/${t.id.split(`/`).map(encodeURIComponent).join(`/`)}`;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,className:P(`flex w-full cursor-pointer items-center gap-[7px] rounded-xl border-0 py-1.5 pr-2 pl-[18px] text-left text-xs`,r?`bg-accent-soft font-medium text-on-accent-soft`:`bg-transparent text-fg-2 hover:bg-surface-2 hover:text-fg`),"aria-expanded":r,title:t.description||void 0,onClick:()=>b(e,t.id),children:[(0,I.jsx)(Ds,{open:r}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title||t.id}),t.stale&&(0,I.jsx)(`span`,{className:`cursor-help`,title:`Past its stale-after date — ask the agent to re-verify it`,children:(0,I.jsx)(q,{tone:`bad`,children:`stale`})})]}),r&&(0,I.jsx)(`div`,{className:`mt-1 mb-2.5 ml-[18px] overflow-hidden rounded-xl border border-line bg-surface-2`,ref:e=>e?.scrollIntoView({block:`nearest`}),children:s[n]===void 0?(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`loading…`}):s[n]===null?(0,I.jsx)(J,{className:`px-[18px] py-3`,children:`could not load concept`}):d===n?(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5`,children:[(0,I.jsx)(_t,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`concept`,value:p,rows:Math.min(28,Math.max(10,p.split(`
207
+ `).length+2)),onChange:e=>m(e.target.value),spellCheck:!1}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,I.jsx)(W,{size:`sm`,variant:`quiet`,disabled:h,onClick:()=>f(null),children:`cancel`}),(0,I.jsx)(W,{size:`sm`,variant:`primary`,icon:`check`,busy:h,onClick:()=>x(e,t.id),children:h?`saving…`:`save`})]}),_&&(0,I.jsx)(et,{tone:`bad`,children:_})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-[7px]`,children:[t.type&&(0,I.jsx)(q,{children:t.type}),Os(t)&&(0,I.jsxs)(`span`,{className:`text-[10.5px] tabular-nums text-fg-2`,children:[`updated `,We(Os(t))]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`edit`,onClick:()=>{m(s[n].raw),f(n),y(``)},children:`edit`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`open_in_new`,href:`/knowledge/${encodeURIComponent(e)}/${t.id}`,title:`The page in the knowledge section`,children:`page`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,href:i,children:`open ↗`})]}),(0,I.jsx)(`div`,{className:`md-body h-auto overflow-visible px-3.5 pt-3 pb-3.5 text-xs`,dangerouslySetInnerHTML:{__html:ha.sanitize(zr.parse(s[n].body??``,{async:!1}))}})]})})]},t.id)}),!n&&t&&t.concepts.length===0&&(0,I.jsx)(J,{className:`px-[18px] py-1.5`,children:`no concepts yet`})]},e)})})]})}function Ds({open:e}){return(0,I.jsx)(`span`,{className:P(`inline-grid w-[15px] flex-none text-fg-2 transition-transform`,e&&`rotate-90`),"aria-hidden":!0,children:(0,I.jsx)(L,{name:`chevron_right`,className:`text-[15px]`})})}function Os(e){return[e.generated?.at,...e.verified.map(e=>e.at)].filter(e=>typeof e==`string`&&e.length>0).sort().pop()}function ks({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=!0;return r(!1),A.call(`chats.list`).then(n=>{if(!t)return;let i=n.chats.find(t=>t.scope.kind===`agent`&&t.scope.slug===e);i?H(`/agents/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,I.jsx)(As,{slug:e,name:t}):(0,I.jsx)(Y,{children:`loading…`})}function As({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,I.jsxs)(at,{width:`narrow`,children:[(0,I.jsxs)(rt,{children:[`new session with `,t??e]}),(0,I.jsx)(X,{children:(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer flex-col gap-0.5 rounded-card border border-transparent bg-accent-soft px-3.5 py-3 text-left text-on-accent-soft transition-colors hover:brightness-[0.98] disabled:cursor-default disabled:opacity-60`,disabled:n,onClick:async()=>{r(!0),await Go(`claude`,{kind:`agent`,slug:e}),r(!1)},children:[(0,I.jsx)(`b`,{className:`text-base font-medium`,children:n?`starting…`:`start chat`}),(0,I.jsx)(`span`,{className:`text-xs`,children:`on the agent's harness, with its role, knowledge and skills`})]})})})]})}function js(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=!0;return A.call(`chats.list`).then(n=>{if(!e)return;let r=n.chats.find(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`);r?H(`/agents/chats/${r.id}`,{replace:!0}):t(!0)}).catch(()=>e&&t(!0)),()=>{e=!1}},[]),e?(0,I.jsx)(Ko,{}):(0,I.jsx)(Y,{children:`loading…`})}function Ms({slug:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useCallback)(t=>t.filter(t=>t.scope.kind===`agent`&&t.scope.slug===e),[e]),a=(0,v.useCallback)(t=>`/agents/${encodeURIComponent(e)}/chat/${t.id}`,[e]),o=N(`projects.list`,{},{interval:6e4}),s=e=>o?.projects.find(t=>t.slug===e)?.title??e;return(0,I.jsx)(Ya,{storeKey:`agent:${e}`,label:`chats`,fallbackTitle:`new chat`,chatId:t,filter:i,hrefOf:a,closeHref:`/agents/${encodeURIComponent(e)}/chat/new`,subOf:e=>e.project?`📁 ${s(e.project)}`:e.agent,actions:(0,I.jsx)(Va,{busy:n,onClick:async()=>{r(!0),await Go(`claude`,{kind:`agent`,slug:e}),r(!1)}})})}var Ns=e=>e.filter(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`),Ps=e=>`/agents/chats/${e.id}`;function Fs({chatId:e}){return(0,I.jsx)(Ya,{storeKey:`general`,label:`chats`,fallbackTitle:`new chat`,chatId:e,filter:Ns,hrefOf:Ps,closeHref:`/agents/chats/new`,subOf:e=>(0,I.jsxs)(I.Fragment,{children:[e.agent,e.scope.kind===`run`?` · ${e.scope.runId}`:e.scope.kind===`kraftwerk`?` · kraftwerk`:e.scope.kind===`knowledge`?` · knowledge${e.scope.bundle?`:${e.scope.bundle}`:``}`:``]}),actions:(0,I.jsx)(Va,{href:`/agents/chats/new`})})}function Is({agents:e}){return(0,v.useEffect)(()=>{let t=!0,n=()=>H(`/agents/${encodeURIComponent(e[0].slug)}`,{replace:!0});return A.call(`chats.list`).then(r=>{if(!t)return;let i=new Set(e.map(e=>e.slug)),a=r.chats.find(e=>e.scope.kind===`agent`&&i.has(e.scope.slug));a&&a.scope.kind===`agent`?H(`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`,{replace:!0}):n()}).catch(()=>t&&n()),()=>{t=!1}},[e.map(e=>e.slug).join(`,`)]),(0,I.jsx)(Y,{children:`loading…`})}function Ls(){let e=ye();return(0,I.jsx)(`div`,{className:`empty-action flex justify-center py-16 text-center text-sm text-fg-2`,children:e?(0,I.jsx)(W,{variant:`primary`,icon:`add`,onClick:()=>H(`/agents/new`),children:`create your first agent`}):(0,I.jsx)(`span`,{children:`Creating agents needs expert mode — flip the switch in the top bar.`})})}var Rs=`---
208
+ description: What this skill is for (one line)
209
+ ---
210
+
211
+ Instructions this agent follows when the skill applies or is invoked with /<name>.
212
+ `;function zs({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)(W,{size:`sm`,icon:`add`,onClick:()=>{r({name:``,content:Rs,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)(lt,{children:t.map(e=>(0,I.jsx)(ct,{icon:`extension`,title:`/${e.name}`,action:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{size:`sm`,icon:`edit`,onClick:()=>void c(e.name),children:`edit`}),(0,I.jsx)(G,{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)(yt,{className:`max-w-[680px]`,children:[(0,I.jsx)($,{label:`name — invoked as /<name>`,children:(0,I.jsx)(Q,{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)($,{label:`SKILL.md — frontmatter (description) + the instructions`,children:(0,I.jsx)(_t,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,rows:Math.min(28,Math.max(12,n.content.split(`
213
+ `).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)(W,{variant:`primary`,busy:i,disabled:!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,I.jsx)(W,{variant:`quiet`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:(0,I.jsx)(et,{tone:`bad`,children:o})})]})}function Bs(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 Vs({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 Hs({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=(It()??[]).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=Bs(e);d(t.note),l(t.error),n(e=>e+1),Ft()}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)(W,{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)(ct,{icon:`event_busy`,title:`${b} routine${b===1?` fires`:`s fire`} nowhere`,action:(0,I.jsx)(W,{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)(lt,{children:a.map(t=>(0,I.jsx)(ct,{icon:`schedule`,title:(0,I.jsxs)(I.Fragment,{children:[t.name,(0,I.jsx)(Vs,{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)(W,{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)(W,{size:`sm`,icon:`play_arrow`,busy:f===t.id,onClick:()=>C(t.id),children:f===t.id?`starting…`:`run`}),(0,I.jsx)(W,{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)(W,{size:`sm`,variant:`danger`,onClick:()=>void D(t.id),children:`delete`}),(0,I.jsx)(Ct,{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 ${We(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,I.jsxs)(U,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,We(t.lastRunAt)]}):`never ran`]})},t.id))}),o&&(0,I.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`name`,className:`flex-1`,children:(0,I.jsx)(Q,{value:o.name,placeholder:`e.g. Morning report`,onChange:e=>s({...o,name:e.target.value})})}),(0,I.jsx)($,{label:`schedule (cron)`,className:`w-[200px] max-[900px]:w-auto`,children:(0,I.jsx)(Q,{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)($,{label:`prompt — what to ask this agent on each run`,children:(0,I.jsx)(_t,{rows:5,value:o.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>s({...o,prompt:e.target.value})})}),(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`runs on — the one machine that fires it`,className:`flex-1`,children:(0,I.jsx)(Q,{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)(W,{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)(W,{variant:`quiet`,onClick:()=>(s(null),l(``)),children:`cancel`})]})]}),(c||u)&&(0,I.jsx)(`div`,{className:`px-[18px] pb-3`,children:c?(0,I.jsx)(et,{tone:`bad`,children:c}):(0,I.jsx)(et,{children:u})})]})}function Us({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=we(),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)(W,{variant:`primary`,busy:h,onClick:()=>void T(e),children:h?`saving…`:`save`}),(0,I.jsx)(W,{variant:`quiet`,disabled:h,onClick:()=>(c(``),y(``)),children:`cancel`})]}),k=e=>(0,I.jsx)(W,{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)(ot,{children:(0,I.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,I.jsx)(rt,{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)(L,{name:`inventory_2`,className:`ms-sm mr-1`}),` archived`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(W,{href:`/agents/${encodeURIComponent(e)}/edit`,children:`edit`}),t.archived?(0,I.jsx)(W,{variant:`primary`,icon:`unarchive`,busy:h,onClick:()=>void D(!1),children:h?`…`:`unarchive`}):(0,I.jsx)(W,{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)(lt,{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)(st,{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(`
214
+ `)[0]||`empty — expand to give this agent a role`})]}),(0,I.jsx)(L,{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)(W,{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)(_t,{className:`resize-y font-mono text-[12.5px] leading-[1.65]`,"aria-label":`role`,rows:Math.min(24,Math.max(8,l.split(`
215
+ `).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)(ct,{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)(ws,{children:[(x?.workflows??[]).map(e=>(0,I.jsx)(xt,{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:Ss,children:`none connected — the agent can run any workflow you connect`}):(0,I.jsx)(Cs,{children:t.workflows.map(e=>(0,I.jsx)(q,{href:`/workflows/${encodeURIComponent(e)}`,children:e},e))})}),(0,I.jsx)(ct,{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)(ws,{children:[(S?.bundles??[]).map(e=>(0,I.jsx)(xt,{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:Ss,children:`none connected — connected bundles are read and kept current by the agent`}):(0,I.jsx)(Cs,{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)(ct,{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)(ws,{children:[(C?.vibeables??[]).map(e=>(0,I.jsx)(xt,{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)(xt,{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)(Cs,{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)(ct,{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)(ws,{children:[(0,I.jsx)(xt,{checked:p,onChange:m,hint:`every discovered skill, including future ones`,mono:!0,children:`all skills`}),!p&&(w?.skills??[]).map(e=>(0,I.jsx)(xt,{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:Ss,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,I.jsx)(`span`,{className:Ss,children:`none — this agent runs without skills`}):(0,I.jsx)(Cs,{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)(et,{tone:`bad`,children:_})})]}),(0,I.jsx)(zs,{slug:e}),(0,I.jsx)(Hs,{slug:e})]})}var Ws=[`🤖`,`🧑‍💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function Gs({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=we(),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)(at,{width:`narrow`,children:[(0,I.jsx)(rt,{children:e?`edit ${e}`:`new agent`}),(0,I.jsx)(X,{children:(0,I.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`name`,className:`flex-1`,children:(0,I.jsx)(Q,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})}),(0,I.jsx)($,{label:`emoji`,className:`w-[90px] max-[900px]:w-auto`,children:(0,I.jsx)(Q,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ws.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)(bt,{children:[(0,I.jsx)($,{label:`description`,className:`flex-1`,children:(0,I.jsx)(Q,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})}),(0,I.jsx)($,{label:`group`,className:`w-[180px] max-[900px]:w-auto`,children:(0,I.jsx)(Q,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})})]}),(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`harness`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsxs)(vt,{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)($,{label:`model`,className:`flex-1`,children:(0,I.jsx)(Q,{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)($,{label:`effort`,className:`w-[140px] max-[900px]:w-auto`,children:(0,I.jsx)(vt,{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)($,{label:`system prompt — the agent's role`,children:(0,I.jsx)(_t,{className:Ts,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)(Ks,{label:`connected workflows — autoloaded into the agent's context; it can run them`,children:[s.map(e=>(0,I.jsx)(xt,{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)(Ks,{label:`connected knowledge — OKF bundles the agent consults and maintains`,children:[c.map(e=>(0,I.jsx)(xt,{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)(Ks,{label:`apps — small apps the agent builds and maintains`,linkKind:`vibeables`,children:[u.map(e=>(0,I.jsx)(xt,{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)(xt,{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)(Ks,{label:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`,children:[(0,I.jsx)(xt,{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)(xt,{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)(et,{tone:`bad`,children:r}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,I.jsx)(W,{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)(W,{variant:`danger`,icon:`delete`,onClick:m,children:`delete agent`})]})]})})]})}function Ks({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)(ws,{children:n})]})}var qs=`bg-accent/7 outline-[1.5px] -outline-offset-[1.5px] outline-accent outline-dashed`,Js=`px-2.5 pt-1.5 pb-2 text-2xs text-fg-2`;function Ys({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=ye(),s=Ha(),[c,l]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)({}),T=(a?.agents??[]).map(e=>C[e.slug]===void 0?e:{...e,group:C[e.slug]||void 0});(0,v.useEffect)(()=>{w(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 E=T.filter(e=>!e.archived),D=T.filter(e=>e.archived),[O,k]=(0,v.useState)(!1),j=[...new Set([...E.map(e=>e.group??``).filter(Boolean),...c])].sort((e,t)=>e.localeCompare(t)),ee=E.filter(e=>!e.group);function M(e){l(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function F(){let e=f.trim();d(!1),p(``),e&&!j.includes(e)&&M([...c,e])}function te(e,t){h(null);let n=t.trim();if(n&&n!==e){for(let t of T.filter(t=>t.group===e))R(t.slug,n);c.includes(e)&&M([...new Set(c.map(t=>t===e?n:t))])}}async function R(e,t){if((T.find(t=>t.slug===e)?.group??``)!==t){w(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{w(t=>{let n={...t};return delete n[e],n})}}}let ne=e=>o?{onDragOver:t=>{y!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,x!==e&&S(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||y;n&&R(n,e),b(null),S(null)}}:{},re=e=>(0,I.jsx)(`div`,{className:y===e.slug?`opacity-40`:void 0,onDragStart:t=>{if(!o)return t.preventDefault();t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,b(e.slug)},onDragEnd:()=>{b(null),S(null)},children:(0,I.jsx)(Z,{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),ie=e=>(0,I.jsx)(Z,{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),ae;ae=n===`new`?(0,I.jsx)(Gs,{},`new`):n===`edit`&&t?(0,I.jsx)(Gs,{slug:t},t):n===`chat`&&t&&i===`new`?(0,I.jsx)(As,{slug:t,name:T.find(e=>e.slug===t)?.name},t):n===`chat`&&t&&i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Vo,{id:i,agentName:T.find(e=>e.slug===t)?.name??t,agentDescription:T.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,I.jsx)(`div`,{className:`chat-main`,children:(0,I.jsx)(Vo,{id:i},i)}):r?(0,I.jsx)(Ko,{}):(0,I.jsx)(js,{}):n===`info`&&t?(0,I.jsx)(Us,{slug:t},t):t?(0,I.jsx)(ks,{slug:t,name:T.find(e=>e.slug===t)?.name},t):a?E.length?(0,I.jsx)(Is,{agents:E}):(0,I.jsx)(Ls,{}):(0,I.jsx)(Y,{children:`loading…`});let oe=(n===`agent`||n===`info`||n===`chat`)&&t?T.find(e=>e.slug===t)?.knowledge??[]:[],[se,ce]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[le,ue]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),z=oe.length>0&&se;function B(e){ce(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function V(e){ue(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,I.jsxs)(`div`,{className:`runs-screen agents-screen ${t||n===`chats`?`has-tabs`:``} ${(t||n===`chats`)&&s?`has-sessions`:``} ${z?`has-knowledge`:``}`,style:z?{"--kside-w":`${le}px`}:void 0,children:[(0,I.jsxs)(`aside`,{className:`runs-side`,children:[(0,I.jsx)(Tt,{title:`agents`,action:o&&(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/agents/new`,children:`new`})}),(0,I.jsxs)(Dt,{children:[(0,I.jsx)(`div`,{className:`mb-1.5 border-b border-line pb-1.5`,children:(0,I.jsx)(Z,{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`,y&&x===``&&qs),...ne(``),children:[ee.map(re),y!=null&&ee.length===0&&(0,I.jsx)(`div`,{className:Js,children:`no group — drop here`})]}),j.map(e=>{let t=E.filter(t=>t.group===e);return(0,I.jsxs)(`div`,{className:P(`group/grp mt-3 rounded-xl`,y&&x===e&&qs),...ne(e),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 pt-1.5 pb-0.5`,children:[m===e?(0,I.jsx)(Q,{className:`h-7 min-w-0 flex-1 text-2xs`,autoFocus:!0,"aria-label":`group name`,value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&te(e,g),t.key===`Escape`&&h(null)},onBlur:()=>te(e,g)}):(0,I.jsx)(tt,{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&&m!==e&&(0,I.jsx)(G,{icon:`edit`,label:`Rename group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>{h(e),_(e)}}),o&&t.length===0&&c.includes(e)&&(0,I.jsx)(G,{icon:`close`,label:`Remove empty group`,size:`sm`,className:`size-6 opacity-0 group-hover/grp:opacity-100 focus-visible:opacity-100`,onClick:()=>M(c.filter(t=>t!==e))})]}),t.map(re),t.length===0&&(0,I.jsx)(`div`,{className:Js,children:o?`drag agents here`:`no agents`})]},e)}),D.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":O,onClick:()=>k(e=>!e),children:[(0,I.jsx)(tt,{className:`group-hover/arch:text-fg`,children:`archived`}),(0,I.jsx)(`span`,{className:`text-[10px] tabular-nums`,children:D.length}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(L,{name:O?`expand_less`:`expand_more`,className:`ms-sm`})]}),O&&D.map(ie)]}),a&&T.length===0&&(0,I.jsx)(J,{className:`py-1.5 px-2.5`,children:`no agents yet`}),o&&(u?(0,I.jsx)(`div`,{className:`px-2.5 pt-2.5 pb-1`,children:(0,I.jsx)(Q,{className:`h-8 text-sm`,autoFocus:!0,"aria-label":`new group`,value:f,placeholder:`group name, e.g. Team Content`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&F(),e.key===`Escape`&&(d(!1),p(``))},onBlur:F})}):(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:()=>d(!0),children:[(0,I.jsx)(L,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),t&&(0,I.jsx)(Ms,{slug:t,chatId:i===`new`?void 0:i}),n===`chats`&&(0,I.jsx)(Fs,{chatId:i}),(0,I.jsx)(`div`,{className:`runs-main`,children:ae}),z&&(0,I.jsx)(Es,{bundles:oe,onHide:()=>B(!1),onResize:V}),oe.length>0&&!se&&(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:()=>B(!0),title:`Show knowledge sidebar`,children:[(0,I.jsx)(L,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function Xs(e){if(!de(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)(is,{},`new-project`):r?(0,I.jsx)(Gs,{},`new-agent`):(0,I.jsx)(ja,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,I.jsx)(ds,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,I.jsx)(Us,{slug:n},n):r&&t[2]===`edit`?(0,I.jsx)(Gs,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,I.jsx)(ja,{slug:n},n):null}function Zs({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)(G,{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 Qs({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($s,`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:ec,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:We(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($s,`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)(K,{tone:`working`}),(0,I.jsx)(`div`,{className:ec,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)(W,{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)(Q,{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)(et,{tone:`bad`,children:u}),(0,I.jsx)(`div`,{className:`flex gap-2`,children:(0,I.jsx)(W,{variant:`primary`,onClick:m,disabled:!p,busy:c,children:c?`Saving…`:`Submit decision`})})]})})}var $s=`mb-[18px] overflow-hidden rounded-card border border-line bg-surface`,ec=`text-[16px] font-medium text-fg`;function tc(e){return e===`ok`?`ok`:e===`running`?`working`:e===`failed`||e===`blocked`?`bad`:`idle`}function nc({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 rc(){return(0,I.jsx)(`span`,{"data-ui":`decision`,className:`inline-flex`,children:(0,I.jsx)(q,{tone:`accent`,children:`decision needed`})})}function ic({label:e,children:t,className:n}){return(0,I.jsxs)(`div`,{className:n,children:[(0,I.jsx)(tt,{className:`mb-px block`,children:e}),(0,I.jsx)(`div`,{className:`font-mono text-md font-medium tabular-nums text-fg`,children:t})]})}var ac=`mb-[22px] flex flex-wrap gap-[26px]`;function oc({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)(Tt,{title:`runs`,back:{href:`/workflows`,label:`back to workflows`},count:i?`${o.length} / ${r.length}`:r.length}),(0,I.jsx)(Et,{icon:`filter_list`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Dt,{label:`runs list`,children:[o.map(t=>(0,I.jsx)(sc,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,I.jsx)(Ot,{children:`no runs yet`}),r.length>0&&o.length===0&&(0,I.jsxs)(Ot,{children:[`no run matches “`,i,`”`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:(0,I.jsx)(cc,{id:e},e)})]})}function sc({r:e,active:t}){return(0,I.jsx)(Z,{href:`/runs/${e.id}`,active:t,size:`sm`,leading:(0,I.jsx)(K,{tone:tc(e.status),title:e.status}),title:e.workflow??`unknown`,meta:We(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}):Be(e.durationMs)})]})})}function cc({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=ye();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=>!hc(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);if(n?.ok){H(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`);return}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)(K,{tone:tc(t.status),title:t.status}),(0,I.jsx)(rt,{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)(nc,{status:t.status}),u&&(0,I.jsxs)(q,{children:[(0,I.jsx)(L,{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)(W,{size:`sm`,variant:`danger`,icon:`stop`,busy:a,onClick:p,children:a?`stopping…`:`stop`}):(0,I.jsx)(W,{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)(W,{size:`sm`,variant:`quiet`,title:`chat with an agent about this run`,onClick:()=>void Go(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,I.jsx)(pt,{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)(lc,{run:t,live:n}):(0,I.jsx)(_c,{id:e,files:t.files,live:n})]})}function lc({run:e,live:t}){return(0,I.jsxs)(`div`,{className:`max-w-[1080px]`,children:[e.decision&&(0,I.jsx)(Qs,{runId:e.id,decision:e.decision}),(0,I.jsxs)(`div`,{className:ac,children:[(0,I.jsxs)(ic,{label:`phases`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]}),(0,I.jsx)(ic,{label:`duration`,children:t?(0,I.jsx)(Ke,{since:e.startedAt}):Be(e.durationMs)}),(0,I.jsx)(ic,{label:`cost`,children:Ve(e.costUsd??dc(e.phases))}),(0,I.jsxs)(ic,{label:`tokens in / out`,children:[He(uc(e.phases,`tokensIn`)),` / `,He(uc(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)(K,{tone:`working`}),` live · polling`]}),children:(0,I.jsx)(`div`,{className:`py-1.5`,children:e.phases.map(e=>(0,I.jsx)(pc,{p:e},e.phase))})})]})}function uc(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function dc(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}var fc=`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 pc({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,I.jsxs)(`div`,{className:P(fc,`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)(K,{tone:tc(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)(nc,{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:Be(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,I.jsxs)(`span`,{children:[He(e.tokensIn),` / `,He(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:Ve(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)(L,{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 mc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function hc(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function gc(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)||mc.has(t)?0:hc(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function _c({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=ye(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!hc(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&hc(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(gc(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:Ue(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:vc,href:A.url(`runs.file`,{id:e,query:{name:r,raw:!0}}),target:`_blank`,children:`open raw ↗`}),children:r?(0,I.jsx)(Cc,{id:e,name:r,live:n}):(0,I.jsx)(Y,{className:`flex-1 justify-center`,children:`select a file`})})]})}var vc=`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`,yc=`flex min-h-0 flex-1 flex-col`,bc=`min-h-0 flex-1`,xc=`m-0 h-full overflow-auto px-[18px] py-3.5 text-xs leading-[1.55] break-words whitespace-pre-wrap text-fg-2`,Sc=`block h-full min-h-[560px] w-full border-0 bg-white`;function Cc({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:yc,children:(0,I.jsx)(`div`,{className:bc,children:(0,I.jsx)(`iframe`,{className:Sc,src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,I.jsx)(`div`,{className:yc,children:(0,I.jsx)(`div`,{className:bc,children:(0,I.jsx)(`iframe`,{className:Sc,src:i,title:t})})}):mc.has(r)?(0,I.jsx)(`div`,{className:yc,children:(0,I.jsx)(`div`,{className:bc,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)(Tc,{id:e,name:t,live:n}):(0,I.jsx)(Ec,{id:e,name:t,live:n})}var wc=`flex items-center gap-3 border-b border-line/55 px-[18px] py-1.5 text-2xs text-fg-2`;function Tc({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?ha.sanitize(zr.parse(a.content,{async:!1})):``,[a?.content]);return(0,I.jsxs)(`div`,{className:yc,children:[(0,I.jsxs)(`div`,{className:wc,children:[(0,I.jsx)(pt,{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 `,Ue(4e5)]})]}),(0,I.jsx)(`div`,{className:P(bc,`overflow-auto`),children:a?r===`rendered`?(0,I.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,I.jsx)(`pre`,{className:xc,children:a.content||`(empty)`}):(0,I.jsx)(`pre`,{className:xc,children:`loading…`})})]})}function Ec({id:e,name:t,live:n}){let r=N(`runs.fileText`,{id:e,query:{name:t}},{fast:n});return(0,I.jsxs)(`div`,{className:yc,children:[r?.truncated&&(0,I.jsxs)(`div`,{className:wc,children:[`large file — showing the last `,Ue(4e5)]}),(0,I.jsx)(`div`,{className:bc,children:(0,I.jsx)(`pre`,{className:xc,children:r?r.content||`(empty)`:`loading…`})})]})}function Dc(){return N(`workflows.runner`,{slug:`any`},{interval:15e3})}var Oc=e=>!!e?.available&&!!e?.image;function kc(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function Ac(e,t){return(await A.call(`workflows.run`,{slug:e,body:t})).runId}function jc(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=Dc();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!Oc(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||Oc(m));async function g(){if(h){d(!0),p(null);try{let t=await Ac(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 Mc({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=jc(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)(Q,{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)(W,{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)(wt,{label:`Docker sandbox`,hint:kc(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,I.jsx)(wt,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,I.jsx)(et,{tone:`bad`,children:i.error})]})}var Nc=`\0done`,Pc=5;function Fc(e,t){return e.status===`ok`?Nc:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Nc}var Ic=[`var(--accent)`,`#4fb8a8`,`#a78bfa`,`#e5793b`];function Lc(e){return e==null?`var(--text-2)`:Ic[e%Ic.length]}function Rc({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 zc({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Nc].map(e=>[e,[]]));for(let e of t)a.get(Fc(e,i)).push(e);let o=a.get(Nc)??[];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)(Bc,{step:e.name,index:(0,I.jsx)(Rc,{small:!0,colour:Lc(e.agent?n.get(e.agent)??0:null),children:t+1}),count:i.length,children:(0,I.jsx)(Vc,{cards:i,moreHref:r})},e.name)}),(0,I.jsx)(Bc,{step:`done`,name:`done`,done:!0,index:(0,I.jsx)(Rc,{small:!0,colour:`var(--ok)`,children:`✓`}),count:o.length,children:(0,I.jsx)(Vc,{cards:o,moreHref:r})})]})}function Bc({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 Vc({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,Pc).map(e=>(0,I.jsx)(Hc,{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>Pc&&(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-Pc,` more ↗`]})]})}function Hc({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)(K,{tone:tc(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:We(e.startedAt)}),(0,I.jsx)(`span`,{children:e.status===`running`?(0,I.jsx)(Ke,{since:e.startedAt}):Be(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,I.jsx)(`span`,{children:Ve(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)(rc,{}),(e.status===`failed`||e.status===`aborted`)&&(0,I.jsx)(nc,{status:e.status})]})]})}function Uc({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)(Gc,{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)(rt,{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)(pt,{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)(Mc,{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)(W,{size:`sm`,variant:`quiet`,href:`${u}/runs`,className:`in-[.ctx-embed]:hidden`,children:`all runs ↗`}),children:(0,I.jsx)(zc,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})})]}),t===`details`&&(0,I.jsx)(Wc,{wf:n,agentIdx:c}),t===`runs`&&(0,I.jsx)(Kc,{runs:l})]})}function Wc({wf:e,agentIdx:t}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:ac,children:[(0,I.jsx)(ic,{label:`agents`,children:e.agents.length}),(0,I.jsxs)(ic,{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)(ic,{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)(Jc,{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)(Yc,{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)(Gc,{slug:e.slug})})]})}function Gc({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)(W,{variant:`danger`,icon:`delete`,busy:r,onClick:()=>void s(),children:`confirm delete`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>n(!1),children:`cancel`}),(0,I.jsx)(J,{children:`its runs stay; the trash can put it back`})]}):(0,I.jsx)(W,{variant:`danger`,icon:`delete`,onClick:()=>n(!0),title:`Move the workflow's folder to the trash`,children:`delete workflow`})}),a&&(0,I.jsx)(et,{tone:`bad`,children:a})]})}function Kc({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)(K,{tone:tc(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)(rc,{}),(0,I.jsx)(nc,{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}):Be(e.durationMs)}),(0,I.jsx)(`span`,{children:Ve(e.costUsd)}),(0,I.jsx)(`span`,{children:We(e.startedAt)})]})]},e.id)})})}var qc=`border-line/55`;function Jc({a:e,idx:t}){return(0,I.jsxs)(`div`,{className:P(`agent-card border-r border-b px-[18px] py-3.5`,qc),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:Lc(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 Yc({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]`,fc),children:[(0,I.jsx)(Rc,{colour:Lc(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:Lc(n??0),borderColor:`color-mix(in srgb, ${Lc(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 Xc(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function Zc(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function Qc({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:Xc(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)(Tt,{title:`workflows`,count:n?o.length:void 0,action:(0,I.jsxs)(W,{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)(Et,{icon:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Dt,{children:[c.map(t=>{let n=Xc(s,t);return(0,I.jsx)(Z,{className:`wf-row`,href:`/workflows/${encodeURIComponent(t.slug)}`,active:t.slug===e,leading:(0,I.jsx)(K,{tone:tc(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&&Ge(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(Zc(n.last,t)),children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,I.jsx)(nc,{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)(Ot,{className:`wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,I.jsx)(Ot,{children:`no workflows yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(Uc,{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 $c=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,el=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function tl(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 nl(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 rl(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function il(){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=ye(),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)(fl,{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)(sl,{projectTitle:u,runs:d,chats:f,bundles:p,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function al(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 ol=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function sl({projectTitle:e,runs:t,chats:n,bundles:r,agents:i,workflows:a,filter:o,setFilter:s}){let c=ye(),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:$c(e.status),status:el(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} · ${nl(t,i,e)}`:nl(t,i,e),href:tl(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:[ol.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)(L,{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=al(e),n=t===u?null:t;return u=t,(0,I.jsxs)(`div`,{children:[n&&(0,I.jsx)(tt,{className:`block px-2.5 pt-3 pb-1`,children:n}),(0,I.jsx)(Z,{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)(K,{tone:`working`})})]}),title:rl(e.title),titleExtra:(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:(0,I.jsx)(q,{tone:cl[e.kind],children:e.kind===`session`?`chat`:e.kind})}),sub:e.sub&&rl(e.sub),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.status&&(0,I.jsx)(q,{tone:ll[e.lamp]??`neutral`,children:e.status}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:Ge(e.at)}),(0,I.jsx)(L,{name:`chevron_right`,className:`ms-sm max-[800px]:hidden`})]})})]},`${e.kind}:${e.href}:${e.at}`)})})})}var cl={run:`accent`,session:`ask`,knowledge:`ok`},ll={ok:`ok`,failed:`bad`,blocked:`bad`,running:`accent`,aborted:`neutral`};function ul(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 dl=e=>new Date(e).toDateString()===new Date().toDateString();function fl({runs:e,chats:t,bundles:n,agents:r,workflows:i,projectTitle:a,loaded:o}){let s=It()??[],c=R(),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:nl(e,r,a),title:rl(e.title||`new chat`),meta:`working${d.get(e.id)?` · ${ul(d.get(e.id))}`:``}`,href:tl(e),tone:`working`})),...e.filter(e=>e.status===`running`).map(e=>({key:`r:${e.id}`,owner:`⚙️ ${u(e.workflow)}`,title:rl(e.request??``),meta:`running`,href:`/runs/${e.id}`,tone:`working`}))],p=[...t.filter(e=>!e.busy&&!e.awaitingApproval&&dl(e.updatedAt)&&e.title).map(e=>({key:`c:${e.id}`,at:e.updatedAt,owner:nl(e,r,a),title:rl(e.title),meta:Ge(e.updatedAt),href:tl(e)})),...e.filter(e=>e.status!==`running`&&dl(e.updatedAt)).map(e=>({key:`r:${e.id}`,at:e.updatedAt,owner:`⚙️ ${u(e.workflow)}`,title:rl(e.request??``),meta:`${e.status===`ok`?`done`:e.status===`aborted`?`stopped`:`failed`} · ${Ge(e.updatedAt)}`,href:`/runs/${e.id}`})),...n.filter(e=>e.updatedAt&&dl(e.updatedAt)).map(e=>({key:`k:${e.name}`,at:e.updatedAt,owner:`📚 ${e.name}`,title:`knowledge updated`,meta:Ge(e.updatedAt),href:`/knowledge/${encodeURIComponent(e.name)}`}))].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,12),m=Ut(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)(W,{variant:`primary`,size:`sm`,onClick:()=>Wt(m),className:`bg-bad text-on-bad hover:bg-bad`,children:[`start `,(0,I.jsx)(L,{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)(Z,{className:`today-row waiting`,onClick:()=>Wt(e),over:Bt(e.owner),title:e.title,meta:(0,I.jsxs)(`span`,{className:`font-semibold text-bad`,children:[zt(e.kind),` · `,Ge(e.since)]})},e.id))}),h&&(0,I.jsx)(`div`,{className:`px-[18px] pb-4`,children:(0,I.jsx)(W,{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)(pl,{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)(pl,{r:e},e.key))})})]})}function pl({r:e}){return(0,I.jsx)(Z,{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)(K,{tone:`working`}),e.meta]})})}var ml=`modulepreload`,hl=function(e){return`/`+e},gl={},_l=function(e){return e.pathname.endsWith(`.css`)},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=hl(t,n);let r=s(t);if(r.href in gl)return;gl[r.href]=!0;let i=_l(r);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 o=document.createElement(`link`);if(o.rel=i?`stylesheet`:ml,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yl=(0,v.lazy)(()=>vl(()=>import(`./editor-HCNTXWWs.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),bl=()=>vl(()=>import(`./editor-HCNTXWWs.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function xl({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)(Tt,{title:`bundles`,action:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/knowledge/new`,children:`new`})}),(0,I.jsxs)(Dt,{children:[a.map(t=>(0,I.jsx)(Z,{href:`/knowledge/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)(K,{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)(Ot,{children:`no bundles yet`})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e&&!o?(0,I.jsx)(Ol,{name:e,conceptId:t,onRemoved:()=>{i(t=>[...t,e]),H(`/knowledge`,{replace:!0})}},e):o||n&&!s?(0,I.jsx)(Sl,{}):(0,I.jsx)(Y,{children:`loading…`})})]})}function Sl(){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)(Q,{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)(W,{variant:`primary`,icon:`add`,busy:i,disabled:!e.trim(),onClick:o,children:i?`creating…`:`new bundle`})]}),n&&(0,I.jsx)(et,{tone:`bad`,children:n})]})}function Cl({tier:e}){return(0,I.jsx)(q,{tone:e===`human-reviewed`?`ok`:e===`machine-confirmed`?`accent`:`neutral`,children:e})}var wl=e=>e===`deprecated`||e===`stale`?`bad`:e===`draft`?`accent`:`neutral`,Tl=()=>(0,v.useContext)(me)!==null,El=`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`,Dl=`@activity`;function Ol({name:e,conceptId:t,onRemoved:n}){let r=N(`knowledge.get`,{bundle:e}),i=Tl(),[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);if(!t?.ok){c(t?.error??`delete failed`),o(!1);return}n?n():H(`/knowledge`,{replace:!0})}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===Dl?`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)(rt,{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)(pt,{bare:!0,className:`self-end`,label:`bundle views`,value:u,items:[{id:`pages`,href:p,label:`pages`},{id:`activity`,href:`${p}/${Dl}`,label:`activity`}]}),(0,I.jsx)(`span`,{className:`flex-1`}),!i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void _s(e),children:`export PDF`}),a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void l(),children:`move to trash`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>o(!1),children:`cancel`})]}):(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`delete`,onClick:()=>o(!0),title:`Move the bundle to the trash`,children:`delete`}),(0,I.jsx)(W,{variant:`primary`,onClick:()=>void Go(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]})]}),s&&(0,I.jsx)(et,{tone:`bad`,children:s}),u===`activity`?r.log?(0,I.jsx)(jl,{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)(Nl,{concepts:d,base:p,selected:f})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:f&&(0,I.jsx)(Fl,{bundle:e,conceptId:f},f)})]})]})}function kl(e){let t=[];for(let n of e.split(`
216
+ `)){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 Al(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 jl({name:e,log:t}){let n=kl(t),[r,i]=(0,v.useState)(!1);return(0,I.jsx)(X,{title:`activity`,actions:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>i(!r),children:r?`timeline`:`raw log`}),children:r||n.length===0?(0,I.jsx)(`pre`,{className:El,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:Al(e,t.text)})]},n))]},t.date))})})}function Ml(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 Nl({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>Ml(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=Tl();return(0,I.jsx)(Pl,{folder:r,base:t,selected:n,closed:i,toggle:o,embedded:s})}function Pl({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)(L,{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)(Pl,{folder:e,base:t,selected:n,closed:r,toggle:i,embedded:a})})]},e.path)})]})}function Fl({bundle:e,conceptId:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),c=Tl(),[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),j=()=>{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 bl().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 ee(){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(`
217
+ `)?``:`
218
+ `}${n.replace(/^\n+/,`
219
+ `)}`: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 bl()).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 ee(),1e3))}(0,v.useEffect)(()=>{let e=()=>{D.current!==null&&ee()};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&&ee()}},[]);async function F(){s(!0),await A.request(`knowledge.verify`,{bundle:e,body:{id:t}}).catch(()=>{}),s(!1),j()}function te(){n&&(f(n.raw),g(``),u(`markdown`))}async function L(){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 R=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)(rt,{size:c?`md`:`lg`,children:n.title}),n.type&&(0,I.jsx)(q,{children:n.type}),(0,I.jsx)(Cl,{tier:n.trustTier}),n.status!==`stable`&&(0,I.jsx)(q,{tone:wl(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)(W,{size:`sm`,variant:`quiet`,icon:`picture_as_pdf`,onClick:()=>void _s(e,n.id),children:`export PDF`}),(0,I.jsx)(W,{variant:`primary`,size:c?`sm`:`md`,icon:`check`,busy:o,onClick:F,children:o?`verifying…`:`verify (human)`})]}),n.error&&(0,I.jsx)(et,{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)(W,{size:`sm`,variant:`quiet`,onClick:()=>{u(`document`),g(``)},children:`cancel`}),(0,I.jsx)(W,{size:`sm`,icon:`check`,busy:p,onClick:()=>void L(),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:R}),(0,I.jsx)(W,{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(`
220
+ `).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)(yl,{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)(et,{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)(dt,{compact:c,children:[(0,I.jsx)(ft,{label:`trust`,children:(0,I.jsx)(Cl,{tier:n.trustTier})}),(0,I.jsx)(ft,{label:`generated`,dim:!n.generated,children:n.generated?`${n.generated.by??`?`} · ${(n.generated.at??`?`).slice(0,10)}`:`not stamped`}),(0,I.jsx)(ft,{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)(ft,{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)(ft,{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)(dt,{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 Il={workspace:`workspace`,project:`.claude`,user:`global`,agent:`agent`};function Ll(e){return(0,I.jsx)(q,{tone:e===`workspace`?`ok`:e===`agent`?`accent`:`neutral`,children:Il[e]})}function Rl({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)(Z,{href:`/skills/${encodeURIComponent(t.name)}`,active:t.name===e,size:`sm`,leading:(0,I.jsx)(K,{tone:t.source===`workspace`?`ok`:`idle`}),title:`/${t.name}`,titleExtra:t.source!==`workspace`&&Ll(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)(Tt,{title:`workspace skills`}),(0,I.jsxs)(Dt,{children:[r.map(o),t&&r.length===0&&(0,I.jsx)(Ot,{children:`no workspace skills yet`}),i.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Tt,{title:`local (this machine / repo)`,divided:!0}),i.map(o)]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:e?(0,I.jsx)(Bl,{name:e},e):t&&!a?(0,I.jsx)(zl,{root:t.root}):(0,I.jsx)(Y,{children:`loading…`})})]})}function zl({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 Bl({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?ha.sanitize(zr.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)(rt,{size:`lg`,children:[`/`,t.name]}),Ll(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)(pt,{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)(dt,{children:[(0,I.jsx)(ft,{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)(ft,{label:`path`,mono:!0,children:(0,I.jsx)(`span`,{title:t.path,children:t.path})}),(0,I.jsx)(ft,{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)(ft,{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 Vl=function(e,t){let n=e,r=Ul[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=Gl.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=Gl.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=Gl.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=Gl.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=Gl.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=Gl.getErrorCorrectPolynomial(l),d=ql(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=Jl.getRSBlocks(e,t),i=Yl();for(let t=0;t<n.length;t+=1){let r=n[t];i.put(r.getMode(),4),i.put(r.getLength(),Gl.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=Xl(e);break;case`Alphanumeric`:n=Zl(e);break;case`Byte`:n=Ql(e);break;case`Kanji`:n=$l(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=Jl.getRSBlocks(e,r),n=Yl();for(let t=0;t<s.length;t++){let r=s[t];n.put(r.getMode(),4),n.put(r.getLength(),Gl.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 iu(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+=`
221
+ `}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+`
222
+ `}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};Vl.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},Vl.createStringToBytes=function(e,t){let n=function(){let n=nu(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 Hl={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Ul={L:1,M:0,Q:3,H:2},Wl={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Gl=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 Wl.PATTERN000:return function(e,t){return(e+t)%2==0};case Wl.PATTERN001:return function(e,t){return e%2==0};case Wl.PATTERN010:return function(e,t){return t%3==0};case Wl.PATTERN011:return function(e,t){return(e+t)%3==0};case Wl.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case Wl.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case Wl.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case Wl.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=ql([1],0);for(let n=0;n<e;n+=1)t=t.multiply(ql([1,Kl.gexp(n)],0));return t},r.getLengthInBits=function(e,t){if(1<=t&&t<10)switch(e){case Hl.MODE_NUMBER:return 10;case Hl.MODE_ALPHA_NUM:return 9;case Hl.MODE_8BIT_BYTE:return 8;case Hl.MODE_KANJI:return 8;default:throw`mode:`+e}else if(t<27)switch(e){case Hl.MODE_NUMBER:return 12;case Hl.MODE_ALPHA_NUM:return 11;case Hl.MODE_8BIT_BYTE:return 16;case Hl.MODE_KANJI:return 10;default:throw`mode:`+e}else if(t<41)switch(e){case Hl.MODE_NUMBER:return 14;case Hl.MODE_ALPHA_NUM:return 13;case Hl.MODE_8BIT_BYTE:return 16;case Hl.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}(),Kl=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}(),ql=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]^=Kl.gexp(Kl.glog(r.getAt(n))+Kl.glog(e.getAt(i)));return ql(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;let t=Kl.glog(r.getAt(0))-Kl.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]^=Kl.gexp(Kl.glog(e.getAt(r))+t);return ql(n,0).mod(e)},r},Jl=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 Ul.L:return e[(t-1)*4+0];case Ul.M:return e[(t-1)*4+1];case Ul.Q:return e[(t-1)*4+2];case Ul.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}(),Yl=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},Xl=function(e){let t=Hl.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},Zl=function(e){let t=Hl.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},Ql=function(e){let t=Hl.MODE_8BIT_BYTE,n=Vl.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},$l=function(e){let t=Hl.MODE_KANJI,n=Vl.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},eu=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},tu=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},nu=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},ru=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=eu(),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},iu=function(e,t,n){let r=ru(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=eu();r.write(i);let a=tu(),o=i.toByteArray();for(let e=0;e<o.length;e+=1)a.writeByte(o[e]);return a.flush(),`data:image/gif;base64,`+a};Vl.stringToBytes;function au(){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 ou(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(au),[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)(L,{name:`phonelink_lock`,className:`text-[32px] text-fg-2`}),(0,I.jsx)(rt,{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)($,{label:`pairing code`,children:(0,I.jsx)(Q,{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)($,{label:`name of this device`,hint:`how it shows in the list of paired devices`,children:(0,I.jsx)(Q,{value:n,onChange:e=>r(e.target.value),"aria-label":`device name`})}),o&&(0,I.jsx)(et,{tone:`bad`,children:o}),(0,I.jsx)(W,{variant:`primary`,type:`submit`,busy:i,disabled:!e.trim(),children:`pair`})]})]})}function su({children:e}){return O()?(0,I.jsx)(ou,{}):(0,I.jsx)(I.Fragment,{children:e})}function cu({text:e,size:t=176}){let n=(0,v.useMemo)(()=>{let t=Vl(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 lu({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)(lt,{children:(0,I.jsx)(ct,{icon:t.enabled?`public`:`public_off`,title:`reach this machine from anywhere`,"data-relay":t.enabled?t.state:`off`,action:(0,I.jsx)(W,{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 uu(){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)(lt,{children:(0,I.jsx)(ct,{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)(W,{size:`sm`,icon:`add_link`,onClick:()=>void s(),children:`pair a device`}),children:[r&&(0,I.jsxs)(yt,{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)(cu,{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)(lu,{onError:o}),a&&(0,I.jsx)(`div`,{className:`px-[18px] pt-3`,children:(0,I.jsx)(et,{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)(lt,{children:n.devices.map(e=>(0,I.jsx)(ct,{icon:`devices`,title:e.name,"data-device":e.id,action:(0,I.jsx)(W,{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 `,Ge(e.createdAt),` · `,e.lastSeenAt?`last seen ${Ge(e.lastSeenAt)}`:`not used yet`]})},e.id))})]})}var du={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function fu(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??du.remote,branch:t.branch??``,interval:String(t.interval??du.interval),autosync:t.autosync??du.autosync}:du}var pu={enabled:!1,root:``};function mu(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:pu}function hu(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:pu}function gu(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:pu}function _u(e){let t=e.config.boards;return t?{enabled:t.enabled!==!1,root:t.root??``}:pu}function vu(e){let t=e.config.presentations;return t?{enabled:t.enabled!==!1,root:t.root??``}:pu}var yu=[`contacts`,`places`,`events`],bu={contacts:pu,places:pu,events:pu};function xu(e){let t=t=>{let n=e.config[t];return n?{enabled:n.enabled!==!1,root:n.root??``}:pu};return{contacts:t(`contacts`),places:t(`places`),events:t(`events`)}}var Su={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 Cu(){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)(L,{name:`cloud`,className:`ms-sm`}),` open the cloud`]}),children:(0,I.jsxs)(yt,{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)(W,{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)(W,{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)(L,{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 wu(){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)(du),[f,p]=(0,v.useState)(pu),[m,h]=(0,v.useState)(pu),[g,_]=(0,v.useState)(pu),[y,b]=(0,v.useState)(pu),[x,S]=(0,v.useState)(pu),[C,w]=(0,v.useState)(bu),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),[k,j]=(0,v.useState)(!1),[ee,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(fu(e)),p(mu(e)),h(hu(e)),_(gu(e)),b(_u(e)),S(vu(e)),w(xu(e))}).catch(()=>M(`could not load settings`))},[]);let F=()=>{E(!0),j(!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(fu(r)),p(mu(r)),h(hu(r)),_(gu(r)),b(_u(r)),S(vu(r)),w(xu(r)),E(!1),j(!0)}catch(e){M(e.message)}finally{O(!1)}}let R=(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:ee||`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)(it,{icon:(0,I.jsx)(L,{name:`settings`,className:`text-[28px] text-fg-2`}),title:`Settings`,actions:(0,I.jsxs)(I.Fragment,{children:[ee&&(0,I.jsx)(et,{tone:`bad`,children:ee}),k&&!T&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12.5px] text-ok`,children:[(0,I.jsx)(L,{name:`check`,className:`ms-sm`}),` saved`]}),(0,I.jsx)(W,{variant:`primary`,busy:D,disabled:!T,onClick:()=>void te(),children:D?`saving…`:`save changes`})]})}),(0,I.jsx)(X,{title:`workspace`,children:(0,I.jsxs)(yt,{children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`icon`,className:`w-[90px]`,children:(0,I.jsx)(Q,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),F()}})}),(0,I.jsx)($,{label:`name`,className:`min-w-40 flex-1`,children:(0,I.jsx)(Q,{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)(Q,{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)(W,{size:`sm`,icon:`add`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),F()},children:`add entry`}),children:(0,I.jsxs)(yt,{children:[c.length===0&&(0,I.jsx)(J,{children:`No manual entries.`}),c.map((e,t)=>(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`icon`,className:`w-[70px]`,children:(0,I.jsx)(Q,{value:e.icon??``,placeholder:`•`,onChange:e=>R(t,{icon:e.target.value})})}),(0,I.jsx)($,{label:`name`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Q,{value:e.name,placeholder:`other workspace`,onChange:e=>R(t,{name:e.target.value})})}),(0,I.jsx)($,{label:`url`,className:`min-w-40 flex-[1.4]`,children:(0,I.jsx)(Q,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>R(t,{url:e.target.value})})}),(0,I.jsx)(G,{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)(W,{size:`sm`,icon:`account_tree`,href:`/git`,children:`open git`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)(bt,{children:[(0,I.jsx)($,{label:`remote`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Q,{value:u.remote,placeholder:`origin`,onChange:e=>ne({remote:e.target.value})})}),(0,I.jsx)($,{label:`branch`,className:`min-w-32 flex-1`,children:(0,I.jsx)(Q,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>ne({branch:e.target.value})})}),(0,I.jsx)($,{label:`interval (s)`,className:`w-[120px]`,children:(0,I.jsx)(Q,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>ne({interval:e.target.value})})}),(0,I.jsx)($,{label:`autosync`,className:`w-[150px]`,children:(0,I.jsxs)(vt,{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)(W,{size:`sm`,icon:`source`,href:`/repos`,children:`open repositories`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)($,{label:`repos root`,children:(0,I.jsx)(Q,{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)(W,{size:`sm`,icon:`web`,href:`/vibeables`,children:`open apps`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)($,{label:`vibeables root`,children:(0,I.jsx)(Q,{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)(W,{size:`sm`,icon:`folder_special`,href:`/projects`,children:`open projects`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)($,{label:`projects root`,children:(0,I.jsx)(Q,{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)(W,{size:`sm`,icon:`view_kanban`,href:`/boards`,children:`open boards`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)($,{label:`boards root`,children:(0,I.jsx)(Q,{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)(W,{size:`sm`,icon:`slideshow`,href:`/presentations`,children:`open presentations`}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{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)($,{label:`presentations root`,children:(0,I.jsx)(Q,{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`}),`.`]})]})]})}),yu.map(e=>(0,I.jsx)(X,{title:e,actions:(0,I.jsxs)(W,{size:`sm`,icon:Su[e].icon,href:`/${e}`,children:[`open `,e]}),children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{checked:C[e].enabled,onChange:t=>ce(e,{enabled:t}),children:Su[e].what}),C[e].enabled&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)($,{label:`${e} root`,children:(0,I.jsx)(Q,{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, `,Su[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)(Cu,{}),(0,I.jsx)(uu,{}),(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)(tt,{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 Tu={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 Eu(){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(Tu).indexOf(e)-Object.keys(Tu).indexOf(t));return(0,I.jsxs)(at,{className:`px-6 py-6`,children:[(0,I.jsx)(it,{icon:(0,I.jsx)(L,{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)(W,{variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`empty`,`*`),children:[`delete all `,u.length,` for good`]}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(W,{variant:`danger`,icon:`delete_forever`,disabled:!!i,onClick:()=>s(`*`),children:`empty trash`}))}),n&&(0,I.jsx)(et,{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:Tu[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)(Z,{className:`trash-row`,leading:(0,I.jsx)(L,{name:Tu[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 `,Ge(t.trashedAt)]})]}),meta:(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(W,{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)(W,{size:`sm`,variant:`danger`,icon:`delete_forever`,onClick:()=>void l(`purge`,t.id),children:`delete for good`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>s(null),children:`cancel`})]}):(0,I.jsx)(W,{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`}),`.`]})]})}var Du=(e,t,n=!1)=>A.url(`files.raw`,{query:{scope:e,path:t,download:n}}),Ou=(e,t=``,n)=>`/files/${encodeURIComponent(e)}${t?`/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:``}${n?`?file=${encodeURIComponent(n)}`:``}`,ku=`inline-grid size-7 shrink-0 place-items-center rounded-control text-fg-2 no-underline hover:bg-surface-2 hover:text-fg`,Au=`whitespace-nowrap border-b border-line px-2.5 py-1.5 text-left`;function ju({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 Mu(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 Nu({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)(Tt,{title:`files`}),(0,I.jsxs)(Dt,{children:[(r??[]).filter(e=>e.scope===`workspace`).map(t=>(0,I.jsx)(Pu,{s:t,active:e===t.scope,icon:`home_storage`},t.scope)),s.length>0&&(0,I.jsx)(Tt,{title:`projects`,divided:!0}),s.map(t=>(0,I.jsx)(Pu,{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)(Fu,{scope:e,dir:t,file:n,onOpen:(t,n)=>H(Ou(e,t,n)),onChanged:()=>o(e=>e+1)},e)})]})}function Pu({s:e,active:t,icon:n}){return(0,I.jsx)(Z,{href:Ou(e.scope),active:t,size:`sm`,leading:(0,I.jsx)(L,{name:n,className:`ms-sm`}),title:e.label,sub:(0,I.jsxs)(`span`,{className:`font-mono`,children:[e.root,`/`]}),meta:e.count})}function Fu({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);if(!n?.ok||!n.data||typeof n.data!=`object`){l(n?.error??`could not load the folder`),s(null);return}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,j=!(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:[j&&(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)(ju,{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)(L,{name:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(ju,{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)(G,{icon:`create_new_folder`,label:`New folder`,size:`sm`,onClick:()=>h(``)}),(0,I.jsx)(G,{icon:`upload`,label:`Upload files`,size:`sm`,onClick:()=>x.current?.click()})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{variant:`quiet`,size:`sm`,icon:`create_new_folder`,onClick:()=>h(``),title:`New folder`,children:`folder`}),(0,I.jsx)(W,{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)(et,{children:u}),c&&(0,I.jsx)(et,{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)(L,{name:`create_new_folder`,className:`text-[20px] text-fg-2`}),(0,I.jsx)(Q,{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)(L,{name:Mu(i),className:`text-[20px] text-fg-2`}),(0,I.jsx)(Q,{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)(Z,{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)(L,{name:Mu(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`}`:Ue(i.size??0),!a&&` · ${Ge(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:Du(e,i.path,!0),title:`Download`,"aria-label":`Download ${i.name}`,children:(0,I.jsx)(L,{name:`download`,className:`ms-sm`})}),(0,I.jsx)(G,{icon:`edit`,size:`sm`,label:`Rename ${i.name}`,onClick:()=>_({path:i.path,name:i.name})}),y===i.path?(0,I.jsx)(W,{variant:`danger`,size:`sm`,autoFocus:!0,onClick:()=>void D(i.path),onBlur:()=>b(null),children:`move to trash`}):(0,I.jsx)(G,{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)(Iu,{scope:e,path:n,entry:k,onClose:()=>r(t),compact:a})]})}function Iu({scope:e,path:t,entry:n,onClose:r,compact:i}){let a=n?.mime??``,o=t.split(`/`).pop()??t,s=Du(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:ha.sanitize(zr.parse(l,{async:!1}))}}):/csv|tab-separated/.test(a)?(0,I.jsx)(Lu,{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:Mu(n),action:(0,I.jsx)(W,{variant:`primary`,size:`sm`,icon:`download`,href:void 0,onClick:()=>window.location.href=Du(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)(G,{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:Ue(n.size)}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`a`,{className:ku,href:s,target:`_blank`,rel:`noopener`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,I.jsx)(L,{name:`open_in_new`,className:`ms-sm`})}),(0,I.jsx)(`a`,{className:ku,href:Du(e,t,!0),title:`Download`,"aria-label":`Download`,children:(0,I.jsx)(L,{name:`download`,className:`ms-sm`})}),!i&&(0,I.jsx)(G,{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 Lu({text:e,tab:t}){let n=t?` `:e.split(`
223
+ `)[0].includes(`;`)&&!e.split(`
224
+ `)[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(Au,`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:Au,children:e},t))},t))})]})})}function Ru(){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)(it,{title:`Components`,sub:`src/ui — what every screen is built from`,actions:(0,I.jsx)(W,{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)(W,{variant:`primary`,icon:`play_arrow`,children:`Run`}),(0,I.jsx)(W,{variant:`secondary`,icon:`upload`,children:`Upload`}),(0,I.jsx)(W,{variant:`quiet`,icon:`create_new_folder`,children:`Folder`}),(0,I.jsx)(W,{variant:`danger`,icon:`delete`,children:`Move to trash`}),(0,I.jsx)(W,{variant:`primary`,busy:!0,children:`Saving`}),(0,I.jsx)(W,{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)(W,{size:`sm`,variant:`primary`,children:`small`}),(0,I.jsx)(W,{size:`sm`,variant:`secondary`,children:`small`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,children:`small`}),(0,I.jsx)(G,{icon:`edit`,label:`Rename`}),(0,I.jsx)(G,{icon:`download`,label:`Download`}),(0,I.jsx)(G,{icon:`delete`,label:`Delete`,variant:`danger`}),(0,I.jsx)(G,{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)(K,{tone:`ok`}),` `,(0,I.jsx)(K,{tone:`bad`}),` `,(0,I.jsx)(K,{tone:`ask`}),` `,(0,I.jsx)(K,{tone:`live`}),` `,(0,I.jsx)(K,{tone:`working`}),` `,(0,I.jsx)(K,{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)(et,{tone:`bad`,children:`Could not upload brief.pdf`}),(0,I.jsx)(et,{children:`uploading 2 of 3…`})]}),(0,I.jsx)(X,{title:`Rows`,count:1,actions:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`arrow_forward`,children:`all`}),children:(0,I.jsxs)(`div`,{className:`p-1.5`,children:[(0,I.jsx)(Z,{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)(Z,{leading:`🦊`,title:`Lisa`,sub:`last active 2h ago`,href:`/ui`,active:!0}),(0,I.jsx)(Z,{leading:(0,I.jsx)(`span`,{className:`ms material-symbols-rounded ms-sm`,children:`folder`}),title:`briefing`,meta:`3 files`,onClick:()=>{},actions:(0,I.jsx)(G,{icon:`edit`,label:`Rename`,size:`sm`})}),(0,I.jsx)(Z,{leading:(0,I.jsx)(K,{tone:`working`}),title:`website-check`,sub:`https://netnode.ch`,meta:`running`,size:`sm`}),(0,I.jsx)(Z,{leading:`📁`,title:`Gone project`,sub:`not in this workspace`,dim:!0})]})}),(0,I.jsxs)(X,{title:`Tabs and sections`,children:[(0,I.jsx)(pt,{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)(nt,{size:`lg`,title:`needs you`,count:2,action:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,children:`all`}),children:(0,I.jsx)(Z,{leading:`✋`,title:`Run npm install`,sub:`🐻 Max · needs approval · 4m ago`,onClick:()=>{}})}),(0,I.jsx)(nt,{title:`team`,children:(0,I.jsx)(Z,{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)($,{label:`Name`,hint:`Shown in the rail.`,children:(0,I.jsx)(Q,{placeholder:`e.g. Max`})}),(0,I.jsx)($,{label:`Harness`,children:(0,I.jsxs)(vt,{defaultValue:`claude`,children:[(0,I.jsx)(`option`,{children:`claude`}),(0,I.jsx)(`option`,{children:`codex`}),(0,I.jsx)(`option`,{children:`pi`})]})}),(0,I.jsx)($,{label:`Role`,children:(0,I.jsx)(_t,{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)(W,{variant:`secondary`,size:`sm`,icon:`upload`,children:`choose files`}),children:`Drop files here.`}),(0,I.jsx)(`div`,{className:`p-4`,children:(0,I.jsx)(kt,{trigger:({toggle:e})=>(0,I.jsx)(W,{onClick:e,icon:`expand_more`,children:`menu`}),children:e=>(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(Z,{leading:`⚙️`,title:`Settings`,onClick:e,size:`sm`}),(0,I.jsx)(Z,{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)(Tt,{title:`workflows`,count:3,action:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,children:`new`})}),(0,I.jsx)(Et,{placeholder:`search workflows`,"aria-label":`search workflows`}),(0,I.jsxs)(Dt,{children:[(0,I.jsx)(Z,{leading:(0,I.jsx)(K,{tone:`ok`}),title:`triage`,sub:`checks, drafts, publishes`,size:`sm`,active:!0}),(0,I.jsx)(Ot,{children:`no workflow matches “x”`})]})]})}),(0,I.jsx)(X,{title:`Choices`,children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(xt,{checked:n,onChange:r,hint:`every discovered skill`,children:`all skills`}),(0,I.jsx)(xt,{checked:!n,onChange:e=>r(!e),hint:`0 concepts`,mono:!0,children:`brand-guide`}),(0,I.jsxs)(bt,{children:[(0,I.jsx)(Ct,{checked:n,onChange:r,label:`routine enabled`}),(0,I.jsxs)(J,{children:[`Hint: a small explaining line. Keys look like `,(0,I.jsx)($e,{children:`⌘K`}),`.`]})]}),(0,I.jsx)(wt,{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)(ot,{children:`🐻`}),(0,I.jsx)(rt,{size:`lg`,children:`Max`}),(0,I.jsx)(q,{href:`#/ui`,children:`linked tag`})]}),(0,I.jsx)(pt,{bare:!0,label:`link tabs`,value:`pages`,items:[{id:`pages`,label:`pages`,href:`/ui`},{id:`activity`,label:`activity`,href:`/ui`}]})]}),(0,I.jsxs)(lt,{children:[(0,I.jsx)(ct,{icon:`account_tree`,title:`workflows`,action:(0,I.jsx)(W,{size:`sm`,children:`edit`}),children:(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`none connected`})}),(0,I.jsx)(ct,{icon:`menu_book`,title:`knowledge`})]}),(0,I.jsxs)(dt,{children:[(0,I.jsx)(ft,{label:`source`,children:`workspace`}),(0,I.jsx)(ft,{label:`path`,mono:!0,children:`skills/release-notes/SKILL.md`})]})]})]})]})}var zu={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`}},Bu={running:`text-ok`,stopped:`text-fg-2`,died:`text-ask`,missing:`text-bad`,orphaned:`text-bad`},Vu={running:``,stopped:`opacity-65 grayscale-50`,died:`opacity-80`,missing:`opacity-45 grayscale-80`,orphaned:`opacity-45 grayscale-80`};function Hu(){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)(at,{children:[(0,I.jsx)(it,{icon:(0,I.jsx)(L,{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)(et,{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)(et,{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)(Re,{className:P(`size-10`,Vu[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:fe(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`,Bu[e.state]),children:[e.live&&(0,I.jsx)(`span`,{className:`inline-block size-2 rounded-full bg-ok`}),zu[e.state].label]}),zu[e.state].note&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:zu[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 `,Ge(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,I.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,Ge(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 `,Ge(e.firstSeen)]})]}),o[t]&&(0,I.jsx)(et,{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:fe(e),title:`Open this workspace`,children:[(0,I.jsx)(L,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,I.jsx)(W,{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)(W,{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)(W,{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)(W,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void f(e,`forget`),children:`confirm remove`}),(0,I.jsx)(W,{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 Uu(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 Wu=[[/^(\+\+\+|---|diff |index )/,`text-fg-2 opacity-80`],[/^@@/,`text-accent`],[/^\+/,`text-ok`],[/^-/,`text-bad`]],Gu=e=>Wu.find(([t])=>t.test(e))?.[1]??``;function Ku({file:e}){return(0,I.jsx)(Ju,{source:{route:`git.diff`,input:{query:{path:e}}}})}var qu=e=>(e.route===`git.diff`||e.route,A.request(e.route,e.input));function Ju({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(``),qu(e).then(e=>{if(t){if(!e.data||typeof e.data!=`object`)throw Error(`not json`);if(!e.ok){r(``),a(!1),s(e.error??``);return}r(e.data.diff??``),a(!!e.data.truncated),s(e.data.error??``)}}).catch(()=>t&&s(`could not load the diff`)),()=>{t=!1}},[c,t]),o?(0,I.jsx)(`div`,{className:P(Yu,`text-bad`),children:o}):n===null?(0,I.jsx)(`div`,{className:Yu,children:`loading…`}):n.trim()?(0,I.jsxs)(`pre`,{className:Yu,children:[n.split(`
225
+ `).map((e,t)=>(0,I.jsxs)(`span`,{className:Gu(e),children:[e||` `,`
226
+ `]},t)),i&&(0,I.jsxs)(`span`,{className:`text-fg-2 opacity-80`,children:[`… diff truncated, see the rest in a terminal`,`
227
+ `]})]}):(0,I.jsx)(`div`,{className:Yu,children:`no textual diff (binary or empty)`})}var Yu=`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`,Xu={modified:`text-accent`,added:`text-ok`,untracked:`text-ok`,deleted:`text-bad`,conflicted:`text-bad`};function Zu({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`:Xu[e]??`text-fg-2`),children:e})}var Qu=`text-xs text-fg-2`,$u=`m-0 p-[18px] text-sm text-fg-2`;function ed(){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)(at,{children:[(0,I.jsx)(it,{icon:`cloud_sync`,title:`Git sync`}),(0,I.jsx)(X,{children:(0,I.jsxs)(`p`,{className:$u,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)(at,{children:[(0,I.jsx)(it,{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)(L,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,I.jsx)(et,{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 `,Ge(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)(L,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
228
+ `)[0]]})]}),children:e.error?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 p-[18px] text-sm text-bad`,children:[(0,I.jsx)(L,{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)(L,{name:`account_tree`,className:`ms-sm`}),(0,I.jsx)(`strong`,{className:`font-mono`,children:e.branch}),(0,I.jsx)(`span`,{className:Qu,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)(W,{size:`sm`,icon:`refresh`,busy:c===`fetch`,disabled:!!c,onClick:()=>void g(`fetch`),children:`fetch`}),(0,I.jsx)(W,{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)(W,{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:Qu,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]`,td),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)(L,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Zu,{status:e.status}),(0,I.jsx)(`span`,{className:P(nd,`group-hover/file:underline`),children:e.path})]}),i.has(e.path)&&(0,I.jsx)(Ku,{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)(Q,{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)(W,{size:`sm`,disabled:n.size===y.length,onClick:()=>r(new Set(y.map(e=>e.path))),children:`select all`}),(0,I.jsxs)(W,{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`,td),children:[(0,I.jsx)(Zu,{status:e.status,muted:!0}),(0,I.jsx)(`span`,{className:nd,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`,td),children:(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),(0,I.jsxs)(`p`,{className:P(Qu,`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 ${Uu(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 td=`flex flex-wrap items-center gap-2.5 py-2 [&+&]:border-t [&+&]:border-line`,nd=`truncate font-mono text-[12.5px]`,rd=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),id=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 ad({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 od=`rounded-full border border-line px-[7px] py-px font-mono text-xs text-fg-2`,sd=`border-line px-[18px] py-2 [&+&]:border-t`,cd=`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`,ld=`min-w-0 truncate font-mono text-[12.5px] group-hover/item:underline`;function ud({title:e,children:t}){return(0,I.jsxs)(`header`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`arrow_back`,href:`/repos`,title:`all repositories`,children:`repositories`}),(0,I.jsx)(L,{name:`folder_data`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(rt,{children:e}),t]})}var dd=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function fd({slug:e}){return e?(0,I.jsx)(pd,{slug:e}):(0,I.jsx)(md,{})}function pd({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=ye(),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)(at,{className:`repo-page`,children:[(0,I.jsx)(ud,{title:e}),(0,I.jsx)(et,{tone:`bad`,children:r})]});if(!t)return(0,I.jsx)(Y,{children:`loading…`});let y=id(t),b=t.commits.filter(e=>e.local).length;return(0,I.jsxs)(at,{className:`repo-page`,children:[(0,I.jsxs)(ud,{title:t.slug,children:[t.branch&&(0,I.jsx)(`span`,{className:od,children:t.branch}),t.upstream&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:`upstream`,children:[`→ `,t.upstream]}),(0,I.jsx)(ad,{...y}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(W,{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(Qu,`flex flex-wrap gap-x-3.5 gap-y-1`),children:[t.url&&(0,I.jsx)(`span`,{title:t.url,children:rd(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?` · ${Ge(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 `,Ge(t.updatedAt)]})]}),(t.error||d||r)&&(0,I.jsx)(et,{tone:`bad`,children:t.error||d||r}),(0,I.jsxs)(X,{title:`changes · working tree against HEAD`,actions:(0,I.jsxs)(`span`,{className:Qu,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`,sd),"data-file":n.path,children:[(0,I.jsxs)(`button`,{type:`button`,className:cd,onClick:()=>o(a===n.path?null:n.path),children:[(0,I.jsx)(L,{name:a===n.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,I.jsx)(Zu,{status:n.status}),(0,I.jsx)(`span`,{className:ld,children:n.path})]}),a===n.path&&(0,I.jsx)(Ju,{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:Qu,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`,sd),"data-commit":t.short,children:[(0,I.jsxs)(`button`,{type:`button`,className:cd,onClick:()=>c(s===t.hash?null:t.hash),title:t.hash,children:[(0,I.jsx)(L,{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(Qu,`ml-auto flex-none`),children:[t.author,` · `,Ge(t.committedAt)]})]}),s===t.hash&&(0,I.jsx)(Ju,{source:{route:`repos.commit`,input:{slug:e,hash:t.hash}}})]},t.hash))]})]})}function md(){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=ye(),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)(at,{children:[(0,I.jsx)(it,{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)(et,{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)(et,{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)($,{label:`url`,className:`min-w-[240px] flex-[2]`,children:(0,I.jsx)(Q,{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)($,{label:`name`,className:`min-w-[140px] flex-1`,children:(0,I.jsx)(Q,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})}),(0,I.jsx)($,{label:`branch`,className:`w-[140px]`,children:(0,I.jsx)(Q,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})}),(0,I.jsx)(W,{type:`submit`,variant:`primary`,icon:`download`,busy:g,disabled:!u.trim(),children:g?`cloning…`:`clone`})]}),y&&(0,I.jsx)(et,{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=id(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)(L,{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:od,children:e.branch}),(0,I.jsx)(ad,{...n}),e.updatedAt&&(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,title:e.updatedAt,children:[`changed `,Ge(e.updatedAt)]})]}),e.url&&(0,I.jsx)(`div`,{className:`font-mono text-xs [overflow-wrap:anywhere] text-fg-2`,title:e.url,children:rd(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?` · ${Ge(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)(et,{tone:`bad`,children:o[e.slug]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,I.jsx)(W,{size:`sm`,icon:`difference`,href:`/repos/${encodeURIComponent(e.slug)}`,title:`changed files with diffs, recent commits`,children:`changes`}),(0,I.jsx)(W,{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)(W,{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)(W,{size:`sm`,variant:`danger`,icon:`delete`,onClick:()=>void C(e.slug,`remove`,dd(e)),children:e.dirty||e.ahead?`delete with local changes`:dd(e)?`delete anyway`:`confirm remove`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var hd=e=>e==null?``:String(e),gd={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=>[hd(e.role),hd(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=>hd(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=>`${hd(e.start).replace(`T`,` `)}${e.end?`–${hd(e.end).replace(`T`,` `)}`:``}`}},_d=(e,t)=>`${e}.${t}`,vd=(e,t)=>A.request(_d(e,`get`),{slug:t}),yd=(e,t,n)=>A.request(_d(e,`save`),{slug:t,body:n}),bd=(e,t)=>A.request(_d(e,`create`),{body:t}),xd=(e,t)=>A.request(_d(e,`delete`),{slug:t}),Sd=()=>new Date().toISOString().slice(0,10);function Cd(e,t){if(e!==`events`)return t;let n=Sd(),r=t.filter(e=>hd(e.end||e.start).slice(0,10)>=n),i=t.filter(e=>hd(e.end||e.start).slice(0,10)<n).reverse();return[...r,...i]}function wd({kind:e,slug:t}){let n=gd[e],r=N(_d(e,`list`),{}),[i,a]=(0,v.useState)(``),o=Cd(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=>hd(e.end||e.start).slice(0,10)<Sd()).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)(Tt,{title:e,count:r?.items.length,action:(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`/${e}/new`,children:`new`})}),o.length>6&&(0,I.jsx)(Et,{value:i,placeholder:`find a ${n.singular}…`,"aria-label":`find a ${n.singular}`,onChange:e=>a(e.target.value)}),(0,I.jsxs)(Dt,{label:e,children:[s.map(r=>(0,I.jsx)(Z,{href:`/${e}/${encodeURIComponent(r.slug)}`,active:r.slug===t,size:`sm`,dim:l.has(r.slug),leading:r.configError?(0,I.jsx)(K,{tone:`bad`,title:r.configError}):(0,I.jsx)(L,{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)(Ot,{children:r.error}),r?.enabled&&o.length===0&&(0,I.jsxs)(Ot,{children:[`no `,e,` yet`]})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:t&&!c?(0,I.jsx)(Dd,{kind:e,slug:t},`${e}/${t}`):c?(0,I.jsx)(Od,{kind:e}):(0,I.jsx)(Y,{icon:n.icon,action:r?.enabled?(0,I.jsxs)(W,{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 Td({field:e,value:t,onChange:n,disabled:r}){return(0,I.jsx)(Q,{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 Ed({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 Dd({kind:e,slug:t}){let n=gd[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(`, `):hd(e[t.name])]))),f(e.tags.join(`, `)),m(e.notes),g(!1)};(0,v.useEffect)(()=>{let n=!0;return vd(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 yd(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)}},j=()=>A({title:s,tags:d,notes:p,...Object.fromEntries(n.fields.map(e=>[e.name,l[e.name]??``]))}),ee=async()=>{let n=await xd(e,t);if(!n.ok)return C(M(n));H(`/${e}`,{replace:!0})},N=(0,v.useMemo)(()=>p.trim()?bo(ha.sanitize(zr.parse(p,{async:!1}))):``,[p]);if(a&&!r)return(0,I.jsxs)(at,{children:[(0,I.jsx)(it,{icon:n.icon,title:t}),(0,I.jsx)(et,{tone:`bad`,children:a})]});if(!r)return(0,I.jsx)(Y,{children:`loading…`});let P=e===`places`?hd(r.mapsUrl):``;return(0,I.jsxs)(at,{className:`${n.singular}-page`,children:[(0,I.jsx)(it,{icon:n.icon,title:(0,I.jsx)(Q,{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 `,Ge(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)(L,{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)(W,{variant:`primary`,icon:`save`,busy:_,disabled:!h||_||!s.trim(),onClick:()=>void j(),children:`save`}),w?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{variant:`danger`,onClick:()=>void ee(),children:`move to trash`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>T(!1),children:`cancel`})]}):(0,I.jsx)(W,{variant:`quiet`,icon:`delete`,title:`move to the trash`,onClick:()=>T(!0),children:`remove`})]})}),r.configError&&(0,I.jsxs)(et,{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)(yt,{className:`max-w-[760px]`,children:[n.fields.map(e=>(0,I.jsx)($,{label:`${e.label}${e.required?` *`:``}`,hint:e.type===`ref`||e.type===`refs`?(0,I.jsx)(Ed,{links:r.links[e.name],refKind:e.refKind}):void 0,children:(0,I.jsx)(Td,{field:e,value:l[e.name]??``,onChange:t=>{u(n=>({...n,[e.name]:t})),k()}})},e.name)),(0,I.jsx)(bt,{children:(0,I.jsx)($,{label:`tags`,className:`flex-1`,children:(0,I.jsx)(Q,{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)(W,{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)(yt,{children:(0,I.jsx)(_t,{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)(gs,{records:r.records,saving:_,onSave:e=>A({records:e},{keepEdits:!0})})]})}function Od({kind:e}){let t=gd[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 bd(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)(at,{children:[(0,I.jsx)(it,{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)(yt,{className:`max-w-[680px]`,children:[(0,I.jsx)($,{label:`title`,children:(0,I.jsx)(Q,{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)($,{label:`${e.label}${e.required?` *`:``}`,children:(0,I.jsx)(Td,{field:e,value:i[e.name]??``,onChange:t=>a(n=>({...n,[e.name]:t}))})},e.name)),(0,I.jsxs)(bt,{children:[(0,I.jsxs)(W,{variant:`primary`,type:`submit`,icon:`add`,busy:o,disabled:!n.trim()||o,children:[`create `,t.singular]}),(0,I.jsx)(W,{variant:`quiet`,href:`/${e}`,children:`cancel`}),c&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:c})]})]})})})]})}var kd=(0,v.lazy)(()=>vl(()=>import(`./editor-HCNTXWWs.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Ad=()=>vl(()=>import(`./editor-HCNTXWWs.js`),__vite__mapDeps([0,1,2,3,4,5,6])),jd=encodeURIComponent,Md=e=>e?{project:e}:{},Nd=e=>e.project?`/projects/${jd(e.project)}/boards/${jd(e.board)}`:`/boards/${jd(e.board)}`,Pd=(e,t)=>`${Nd(e)}/${jd(t)}`,Fd=(e,t)=>e.order-t.order||e.number-t.number,Id=e=>e.trim()?bo(ha.sanitize(zr.parse(e,{async:!1}))):``,Ld=()=>new Date().toISOString().slice(0,10),Rd=e=>e.find(e=>e.slug===`todo`)??e[1],zd=e=>e.find(e=>e.done);function Bd({project:e,board:t}){let n={project:e,board:t},r=Md(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),j=i?.columns??[],ee=new Set(j.map(e=>e.slug)),F=u.filter(e=>!ee.has(e.status)),te=[...j.map(e=>({col:e,tasks:u.filter(t=>t.status===e.slug).sort(Fd)})),...F.length?[{col:{slug:``,label:`No column`},tasks:F.sort(Fd)}]:[]],R=[...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)(()=>Id(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(Fd),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(Fd).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)},z=(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||!ee.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,de=async()=>{let n=await A.request(`boards.delete`,{board:t,query:r});if(!n.ok)return f(M(n));H(e?`/projects/${jd(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)(L,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(rt,{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)(W,{size:`sm`,variant:`quiet`,icon:p?`expand_less`:`gavel`,"aria-expanded":p,onClick:()=>m(e=>!e),children:`rules`}),(0,I.jsx)(G,{size:`sm`,icon:`settings`,label:`board settings: columns, default agent, rules`,href:`${Nd(n)}/settings`}),!e&&(h?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{size:`sm`,variant:`danger`,onClick:()=>void de(),children:`move to trash`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>g(!1),children:`cancel`})]}):(0,I.jsx)(G,{size:`sm`,icon:`delete`,label:`move the board, tasks and all, to the trash`,onClick:()=>g(!0)}))]}),i.configError&&(0,I.jsxs)(et,{tone:`bad`,children:[`board.md: `,i.configError,` — the columns show defaults; fix the file by hand.`]}),d&&(0,I.jsx)(et,{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)(Q,{value:_,className:`h-8 w-auto min-w-[180px] text-sm`,placeholder:`filter tasks…`,"aria-label":`filter tasks`,onChange:e=>y(e.target.value)}),R.length>0&&(0,I.jsxs)(vt,{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`}),R.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),ne.length>0&&(0,I.jsxs)(vt,{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)(W,{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)(xt,{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)(tt,{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)(L,{name:`rate_review`,className:`ms-sm text-fg-2`}),e.done&&(0,I.jsx)(L,{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)(Vd,{at:n,task:r,agent:r.assignee?o(r.assignee):void 0,dragging:E===r.slug,...z(r,t)})]},r.slug)),V(e.slug,null),e.done&&!ie&&t.length>0&&(0,I.jsxs)(Ot,{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)(Hd,{at:n,status:e.slug,onError:f})]},e.slug||`~`)})})]}):(0,I.jsx)(Y,{children:`loading…`})}function Vd({at:e,task:t,agent:n,dragging:r,...i}){let a=!!t.due&&t.due.slice(0,10)<Ld();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:Pd(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)(L,{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)(L,{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)(L,{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)(L,{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 Hd({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:Md(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)(Q,{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)(G,{size:`sm`,icon:`close`,label:`close`,onClick:()=>{i(!1),o(``)}})]}):(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,className:`m-1 justify-start`,onClick:()=>i(!0),children:`task`})}var Ud={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 Wd({refs:e,busy:t,onChange:n}){let r=we(),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)($,{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)(L,{name:Ud[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)(G,{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)(vt,{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 Gd(e){let t=[],n=``;for(let r of e.split(`
229
+ `)){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 Kd({project:e,board:t,task:n}){let r={project:e,board:t},i=Md(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(``)},j=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(``)},ee=async()=>{let e=await A.request(`tasks.delete`,{board:t,task:n,query:i});if(!e.ok)return u(M(e));H(Nd(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/${jd(e)}/chat/${i}`:`/agents/chats/${i}`)},[te,R]=(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),z=a?.notes;(0,v.useEffect)(()=>{if(z===void 0||z===oe.current||se.current!==null||ue.current||ie!==null)return;let e=!0;return Ad().then(({unwrapParagraphs:t})=>{e&&(oe.current=z,ce.current=!1,R(e=>({key:(e?.key??0)+1,body:t(z)})))}),()=>{e=!1}},[z,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 de=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)},fe=(0,v.useMemo)(()=>Gd(a?.log??``),[a?.log]),pe=a?.sessions??[],me=e=>{let[t,n]=e.split(`/`);return pe.find(e=>e.agent===t)??(t===`kraftwerk-chat`&&n?pe.find(e=>e.agent===n):void 0)},he=(s?.agents??[]).filter(e=>!e.archived);if(!a)return(0,I.jsx)(Y,{children:`loading…`});let ge=Rd(c),_e=zd(c),ve=c.find(e=>e.slug===a.status),ye=(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)}}},be=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:Nd(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)(L,{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)(Q,{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:()=>ye(`title`,_),onKeyDown:be(()=>ye(`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 `,Ge(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`})]}),pe.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`}),pe.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`:Ge(e.updatedAt)]})]},e.id))]}),l&&(0,I.jsx)(et,{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)(yt,{className:`pb-3`,children:[(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{label:`status`,children:(0,I.jsxs)(vt,{value:ve?a.status:``,"aria-label":`status`,disabled:d||!c.length,onChange:e=>e.target.value&&void O({status:e.target.value}),children:[!ve&&(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)($,{label:`assignee`,children:(0,I.jsxs)(vt,{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&&!he.some(e=>e.slug===a.assignee)&&(0,I.jsx)(`option`,{value:a.assignee,children:a.assignee}),he.map(e=>(0,I.jsxs)(`option`,{value:e.slug,children:[e.emoji?`${e.emoji} `:``,e.name]},e.slug))]})}),(0,I.jsx)($,{label:`due`,children:(0,I.jsx)(Q,{type:`date`,value:b??a.due??``,"aria-label":`due date`,className:`w-auto`,onChange:e=>x(e.target.value),onBlur:()=>ye(`due`,b),onKeyDown:be(()=>ye(`due`,b))})}),(0,I.jsx)($,{label:`tags`,className:`flex-1`,children:(0,I.jsx)(Q,{value:S??a.tags.join(`, `),placeholder:`comma-separated`,"aria-label":`tags`,onChange:e=>C(e.target.value),onBlur:()=>ye(`tags`,S),onKeyDown:be(()=>ye(`tags`,S))})})]}),(0,I.jsx)(Wd,{refs:a.refs,busy:d,onChange:e=>void O({refs:e})}),(0,I.jsx)($,{label:`note for the log`,hint:`sent with the next status or assignee change`,children:(0,I.jsx)(Q,{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)(bt,{children:[(0,I.jsx)(W,{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`}),ge&&a.status!==ge.slug&&(0,I.jsxs)(W,{icon:`undo`,disabled:d,onClick:()=>{let e=h.trim()||(window.prompt(`Back to ${ge.label} — a line for the log (optional)`,``)??``);k(ge.slug,e.trim()||void 0)},children:[`back to `,ge.label]}),_e&&a.status!==_e.slug&&(0,I.jsx)(W,{icon:`check`,disabled:d,onClick:()=>void k(_e.slug,h.trim()||void 0),children:_e.label.toLowerCase()}),(0,I.jsx)(`span`,{className:`flex-1`}),p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W,{variant:`danger`,onClick:()=>void ee(),children:`move to trash`}),(0,I.jsx)(W,{variant:`quiet`,onClick:()=>m(!1),children:`cancel`})]}):(0,I.jsx)(W,{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)(kd,{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)(W,{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)(_t,{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)(W,{size:`sm`,variant:`primary`,busy:d,onClick:()=>void de(),children:`save`}),(0,I.jsx)(W,{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)(Fu,{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)(Q,{value:w,placeholder:`a comment, a question, what was done…`,"aria-label":`log entry`,disabled:d,onChange:e=>T(e.target.value),onKeyDown:be(()=>void j())}),(0,I.jsx)(W,{size:`sm`,icon:`send`,busy:d,disabled:!w.trim(),onClick:()=>void j(),children:`log`})]}),fe.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:fe.map((e,t)=>(0,I.jsxs)(v.Fragment,{children:[(t===0||fe[t-1].day!==e.day)&&(0,I.jsx)(tt,{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=me(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 qd({project:e,board:t}){let n={project:e,board:t},r=Md(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()},j=(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()},ee=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)(at,{className:`animate-none`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(U,{href:Nd(n),className:`inline-flex items-center gap-1 text-sm text-fg-2 no-underline hover:text-fg`,children:[(0,I.jsx)(L,{name:`arrow_back`,className:`ms-sm`}),` `,a.title]}),(0,I.jsx)(rt,{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)(W,{variant:`primary`,icon:`save`,busy:S,disabled:!b||S||!l.trim()||d.length===0,onClick:()=>void ee(),children:`save`})]}),a.configError&&(0,I.jsxs)(et,{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)(yt,{className:`max-w-[760px]`,children:[(0,I.jsx)($,{label:`title`,children:(0,I.jsx)(Q,{value:l,"aria-label":`board title`,onChange:e=>{u(e.target.value),O()}})}),(0,I.jsxs)(bt,{children:[(0,I.jsx)($,{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)(vt,{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)($,{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)(Q,{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)(W,{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)(Q,{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)(Q,{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)(Q,{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)(xt,{checked:e.review,onChange:e=>k(t,{review:e}),className:`text-xs`,children:`review`}),(0,I.jsx)(xt,{checked:e.done,onChange:e=>k(t,{done:e}),className:`text-xs`,children:`done`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{size:`sm`,icon:`arrow_upward`,label:`move column ${e.label||e.slug||t+1} up`,disabled:t===0,onClick:()=>j(t,-1)}),(0,I.jsx)(G,{size:`sm`,icon:`arrow_downward`,label:`move column ${e.label||e.slug||t+1} down`,disabled:t===d.length-1,onClick:()=>j(t,1)}),(0,I.jsx)(G,{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)(yt,{children:[(0,I.jsx)(_t,{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 Jd({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/${jd(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)(Xd,{root:a.root,project:t}):!n&&t?o.length===0?(0,I.jsx)(Zd,{slug:t}):(0,I.jsx)(Yd,{to:Nd(c(o[0].board))}):!n&&o.length===0?(0,I.jsx)(Xd,{root:a.root}):n&&i===`settings`?(0,I.jsx)(qd,{...c(n)},`${t??``}/${n}/settings`):n&&i?(0,I.jsx)(Kd,{...c(n),task:i},`${t??``}/${n}/${i}`):n?(0,I.jsx)(Bd,{...c(n)},`${t??``}/${n}`):(0,I.jsx)(Y,{icon:`view_kanban`,action:(0,I.jsx)(W,{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)(Tt,{title:t?`${t} · boards`:`boards`,count:a?.enabled?o.length:void 0,action:a?.enabled&&(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`${s}/new`,children:`new`})}),(0,I.jsxs)(Dt,{label:`boards`,children:[o.map(e=>(0,I.jsx)(Z,{href:Nd(c(e.board)),active:e.board===n,size:`sm`,leading:(0,I.jsx)(L,{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:Ge(e.updatedAt)})},e.board)),a&&!a.enabled&&(0,I.jsx)(Ot,{children:a.error}),a?.enabled&&o.length===0&&(0,I.jsxs)(Ot,{children:[`no `,t?``:`workspace `,`boards yet`]}),t&&(0,I.jsx)(Ot,{children:(0,I.jsx)(U,{href:`/projects/${jd(t)}`,className:`text-accent`,children:`← back to the project`})})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:l})]})}function Yd({to:e}){return(0,v.useEffect)(()=>H(e,{replace:!0}),[e]),(0,I.jsx)(Y,{children:`opening the board…`})}function Xd({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(Nd({...t?{project:t}:{},board:r.data.board}),{replace:!0})};return(0,I.jsxs)(at,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(L,{name:`view_kanban`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(rt,{children:`new board`})]}),(0,I.jsx)(X,{children:(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),c()},children:(0,I.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,I.jsx)($,{label:`title`,children:(0,I.jsx)(Q,{value:n,"aria-label":`board title`,autoFocus:!0,placeholder:`e.g. Marketing`,onChange:e=>r(e.target.value)})}),(0,I.jsxs)(bt,{children:[(0,I.jsx)(W,{variant:`primary`,type:`submit`,icon:`add`,busy:i,disabled:!n.trim()||i,children:`create board`}),(0,I.jsx)(W,{variant:`quiet`,href:t?`/projects/${jd(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 Zd({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/${jd(e)}/boards/${jd(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 Qd({project:e,board:t}){let n={project:e,board:t},r=N(`boards.get`,{board:t,query:Md(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(Fd)})),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)(Z,{href:Nd(n),size:`sm`,leading:(0,I.jsx)(L,{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`}`}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1 px-2.5`,"aria-label":`columns`,children:o.map(({col:e,tasks:t})=>{let r=e.limit!==void 0&&t.length>e.limit;return(0,I.jsxs)(U,{href:Nd(n),title:`${e.label}: ${t.length}${e.limit===void 0?``:` of ${e.limit}`}`,className:P(`inline-flex h-5 items-center gap-1 rounded-full px-2 text-2xs font-medium no-underline transition-colors`,t.length===0&&`bg-transparent text-fg-2 ring-1 ring-inset ring-line hover:text-fg`,t.length>0&&!e.review&&!r&&`bg-surface-2 text-fg hover:bg-accent-soft hover:text-on-accent-soft`,t.length>0&&e.review&&!r&&`bg-ask-soft text-on-ask-soft`,r&&`bg-bad-soft text-on-bad-soft`),children:[e.label,(0,I.jsx)(`span`,{className:`font-semibold tabular-nums`,children:t.length})]},e.slug||`~`)})}),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:Nd(n),className:`text-accent`,children:`Add a task`})]}),o.filter(({tasks:e})=>e.length>0).map(({col:e,tasks:t})=>{let r=e.done?3:8;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline gap-1.5 pt-0.5`,children:[(0,I.jsx)(tt,{className:P(e.review&&`text-on-ask-soft`),children:e.label}),(0,I.jsx)(`span`,{className:`text-2xs tabular-nums text-fg-2`,children:t.length})]}),t.slice(0,r).map(t=>{let r=t.assignee?s(t.assignee):void 0;return(0,I.jsxs)(U,{href:Pd(n,t.slug),className:P(`flex min-w-0 items-center gap-2 rounded-control border border-line bg-surface px-2 py-1.5 text-xs text-fg no-underline transition-colors hover:border-accent hover:bg-surface-2`,e.done&&`opacity-70`),children:[(0,I.jsxs)(`span`,{className:`flex-none font-mono text-2xs text-fg-2`,children:[`#`,t.number]}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:t.title}),t.due&&(0,I.jsx)(`span`,{className:`flex-none text-2xs tabular-nums text-fg-2`,children:t.due.slice(5)}),t.stale&&(0,I.jsx)(L,{name:`hourglass_bottom`,className:`ms-sm flex-none text-[13px] text-on-ask-soft`}),t.assignee&&(0,I.jsx)(`span`,{className:`flex-none text-2xs text-fg-2`,title:r?`${r.name} (${t.assignee})`:t.assignee,children:r?.emoji?r.emoji:t.assignee})]},t.slug)}),t.length>r&&(0,I.jsxs)(U,{href:Nd(n),className:`px-1 text-2xs text-fg-2 no-underline hover:text-fg`,children:[t.length-r,` more in `,e.label]})]},e.slug||`~`)})]})}function $d(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ef=$d();function tf(e){ef=e}var nf={exec:()=>null};function rf(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 af(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(sf.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var of=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),sf={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,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,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:rf(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:rf(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:rf(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:rf(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:rf(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:rf(e=>RegExp(`^ {0,${e}}>`))},cf=/^(?:[ \t]*(?:\n|$))+/,lf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,uf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,df=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ff=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pf=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,mf=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,hf=af(mf).replace(/bull/g,pf).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),gf=af(mf).replace(/bull/g,pf).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_f=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,vf=/^[^\n]+/,yf=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,bf=af(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,yf).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),xf=af(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,pf).getRegex(),Sf=`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`,Cf=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wf=af(`^ {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)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Cf).replace(`tag`,Sf).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Tf=e=>af(_f).replace(`hr`,df).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Sf).getRegex(),Ef=Tf(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Df=Tf(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Of={blockquote:af(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Df).getRegex(),code:lf,def:bf,fences:uf,heading:ff,hr:df,html:wf,lheading:hf,list:xf,newline:cf,paragraph:Ef,table:nf,text:vf},kf=af(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,df).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`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Sf).getRegex(),Af={...Of,lheading:gf,table:kf,paragraph:af(_f).replace(`hr`,df).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,kf).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Sf).getRegex()},jf={...Of,html:af(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Cf).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:nf,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:af(_f).replace(`hr`,df).replace(`heading`,` *#{1,6} *[^
230
+ ]`).replace(`lheading`,hf).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Mf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Nf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Pf=/^( {2,}|\\)\n(?!\s*$)/,Ff=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,If=/[\p{P}\p{S}]/u,Lf=/[\s\p{P}\p{S}]/u,Rf=/[^\s\p{P}\p{S}]/u,zf=af(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Lf).getRegex(),Bf=/[\p{Pi}\p{Ps}"']/u,Vf=/(?!~)[\p{P}\p{S}]/u,Hf=/(?!~)[\s\p{P}\p{S}]/u,Uf=/(?:[^\s\p{P}\p{S}]|~)/u,Wf=af(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,of?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Gf=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Kf=af(Gf,`u`).replace(/punct/g,If).getRegex(),qf=af(Gf,`u`).replace(/punct/g,Vf).getRegex(),Jf=af(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Bf).replace(/punct/g,If).getRegex(),Yf=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Xf=af(Yf,`gu`).replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,Lf).replace(/punct/g,If).getRegex(),Zf=af(Yf,`gu`).replace(/notPunctSpace/g,Uf).replace(/punctSpace/g,Hf).replace(/punct/g,Vf).getRegex(),Qf=af(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,Lf).replace(/punct/g,If).getRegex(),$f=af(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,Lf).replace(/punct/g,If).getRegex(),ep=af(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,Lf).replace(/punct/g,If).getRegex(),tp=af(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,If).getRegex(),np=af(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Rf).replace(/punctSpace/g,Lf).replace(/punct/g,If).getRegex(),rp=af(/\\(punct)/,`gu`).replace(/punct/g,If).getRegex(),ip=af(/^<(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(),ap=af(Cf).replace(`(?:-->|$)`,`-->`).getRegex(),op=af(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,ap).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),sp=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,cp=af(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,sp).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lp=af(/^!?\[(label)\]\[(ref)\]/).replace(`label`,sp).replace(`ref`,yf).getRegex(),up=af(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,yf).getRegex(),dp=af(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,lp).replace(`nolink`,up).getRegex(),fp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,pp={_backpedal:nf,anyPunctuation:rp,autolink:ip,blockSkip:Wf,br:Pf,code:Nf,del:nf,delLDelim:nf,delRDelim:nf,emStrongLDelim:Kf,emStrongRDelimAst:Xf,emStrongRDelimUnd:$f,escape:Mf,link:cp,nolink:up,punctuation:zf,reflink:lp,reflinkSearch:dp,tag:op,text:Ff,url:nf},mp={...pp,emStrongLDelim:Jf,emStrongRDelimAst:Qf,emStrongRDelimUnd:ep,link:af(/^!?\[(label)\]\((.*?)\)/).replace(`label`,sp).getRegex(),reflink:af(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,sp).getRegex()},hp={...pp,emStrongRDelimAst:Zf,emStrongLDelim:qf,delLDelim:tp,delRDelim:np,url:af(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,fp).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:af(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,fp).getRegex()},gp={...hp,br:af(Pf).replace(`{2,}`,`*`).getRegex(),text:af(hp.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},_p={normal:Of,gfm:Af,pedantic:jf},vp={normal:pp,gfm:hp,breaks:gp,pedantic:mp},yp={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},bp=e=>yp[e];function xp(e,t){if(t){if(sf.escapeTest.test(e))return e.replace(sf.escapeReplace,bp)}else if(sf.escapeTestNoEncode.test(e))return e.replace(sf.escapeReplaceNoEncode,bp);return e}function Sp(e){try{e=encodeURI(e).replace(sf.percentDecode,`%`)}catch{return null}return e}function Cp(e,t){let n=e.replace(sf.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(sf.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(sf.slashPipe,`|`);return n}function wp(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 Tp(e){let t=e.split(`
231
+ `),n=t.length-1;for(;n>=0&&sf.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
232
+ `)}function Ep(e,t){if(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}function Dp(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Op(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function kp(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
233
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
234
+ `)}var Ap=class{options;rules;lexer;constructor(e){this.options=e||ef}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Tp(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=kp(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=wp(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:wp(t[0],`
235
+ `),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:wp(t[0],`
236
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=wp(t[0],`
237
+ `).split(`
238
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
239
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
240
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
241
+ ${s}`:s,r=r?`${r}
242
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
243
+ `),o=t.raw+`
244
+ `+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
245
+ ${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
246
+ `+e.join(`
247
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
248
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Dp(t[2].split(`
249
+ `,1)[0],t[1].length),l=e.split(`
250
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
251
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
252
+ `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
253
+ `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
254
+ `+l}u=!l.trim(),r+=p+`
255
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Tp(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:wp(t[0],`
256
+ `),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Cp(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
257
+ `):[],a={type:`table`,raw:wp(t[0],`
258
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Cp(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:wp(t[0],`
259
+ `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
260
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=wp(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Ep(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Op(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Op(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},jp=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ef,this.options.tokenizer=this.options.tokenizer||new Ap,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:sf,block:_p.normal,inline:vp.normal};this.options.pedantic?(t.block=_p.pedantic,t.inline=vp.pedantic):this.options.gfm&&(t.block=_p.gfm,t.inline=this.options.breaks?vp.breaks:vp.gfm),this.tokenizer.rules=t}static get rules(){return{block:_p,inline:vp}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(sf.carriageReturn,`
261
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(sf.tabCharGlobal,` `).replace(sf.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
262
+ `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
263
+ `)?``:`
264
+ `)+i.raw,n.text+=`
265
+ `+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
266
+ `)?``:`
267
+ `)+i.raw,n.text+=`
268
+ `+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
269
+ `)?``:`
270
+ `)+i.raw,r.text+=`
271
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
272
+ `)?``:`
273
+ `)+i.raw,n.text+=`
274
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,e.slice(n+1,-1))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,n.slice(r+1,-1)))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Mp=class{options;parser;constructor(e){this.options=e||ef}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(sf.notSpaceStart)?.[0],i=e.replace(sf.endingNewline,``)+`
275
+ `;return r?`<pre><code class="language-`+xp(r)+`">`+(n?i:xp(i,!0))+`</code></pre>
276
+ `:`<pre><code>`+(n?i:xp(i,!0))+`</code></pre>
277
+ `}blockquote({tokens:e}){return`<blockquote>
278
+ ${this.parser.parse(e)}</blockquote>
279
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
280
+ `}hr(e){return`<hr>
281
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
282
+ `+r+`</`+i+`>
283
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
284
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
285
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
286
+ <thead>
287
+ `+t+`</thead>
288
+ `+r+`</table>
289
+ `}tablerow({text:e}){return`<tr>
290
+ ${e}</tr>
291
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
292
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${xp(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Sp(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+xp(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Sp(e);if(i===null)return xp(n);e=i;let a=`<img src="${e}" alt="${xp(n)}"`;return t&&(a+=` title="${xp(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:xp(e.text)}},Np=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Pp=class e{options;renderer;textRenderer;constructor(e){this.options=e||ef,this.options.renderer=this.options.renderer||new Mp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Np}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Fp=class{options;block;constructor(e){this.options=e||ef}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?jp.lex:jp.lexInline}provideParser(e=this.block){return e?Pp.parse:Pp.parseInline}},Ip=class{defaults=$d();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Pp;Renderer=Mp;TextRenderer=Np;Lexer=jp;Tokenizer=Ap;Hooks=Fp;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Mp(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Ap(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Fp;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Fp.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Fp.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return jp.lex(e,t??this.defaults)}parser(e,t){return Pp.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?jp.lex:jp.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Pp.parse:Pp.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?jp.lex:jp.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Pp.parse:Pp.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
293
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+xp(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Lp=new Ip;function Rp(e,t){return Lp.parse(e,t)}Rp.options=Rp.setOptions=function(e){return Lp.setOptions(e),Rp.defaults=Lp.defaults,tf(Rp.defaults),Rp},Rp.getDefaults=$d,Rp.defaults=ef;function zp(...e){return Lp.use(...e),Rp.defaults=Lp.defaults,tf(Rp.defaults),Rp}Rp.use=zp,Rp.walkTokens=function(e,t){return Lp.walkTokens(e,t)},Rp.parseInline=Lp.parseInline,Rp.Parser=Pp,Rp.parser=Pp.parse,Rp.Renderer=Mp,Rp.TextRenderer=Np,Rp.Lexer=jp,Rp.lexer=jp.lex,Rp.Tokenizer=Ap,Rp.Hooks=Fp,Rp.parse=Rp,Rp.options,Rp.setOptions,Rp.walkTokens,Rp.parseInline,Pp.parse,jp.lex;var Bp=Symbol.for(`yaml.alias`),Vp=Symbol.for(`yaml.document`),Hp=Symbol.for(`yaml.map`),Up=Symbol.for(`yaml.pair`),Wp=Symbol.for(`yaml.scalar`),Gp=Symbol.for(`yaml.seq`),Kp=Symbol.for(`yaml.node.type`),qp=e=>!!e&&typeof e==`object`&&e[Kp]===Bp,Jp=e=>!!e&&typeof e==`object`&&e[Kp]===Vp,Yp=e=>!!e&&typeof e==`object`&&e[Kp]===Hp,Xp=e=>!!e&&typeof e==`object`&&e[Kp]===Up,Zp=e=>!!e&&typeof e==`object`&&e[Kp]===Wp,Qp=e=>!!e&&typeof e==`object`&&e[Kp]===Gp;function $p(e){if(e&&typeof e==`object`)switch(e[Kp]){case Hp:case Gp:return!0}return!1}function em(e){if(e&&typeof e==`object`)switch(e[Kp]){case Bp:case Hp:case Wp:case Gp:return!0}return!1}var tm=e=>(Zp(e)||$p(e))&&!!e.anchor,nm=Symbol(`break visit`),rm=Symbol(`skip children`),im=Symbol(`remove node`);function am(e,t){let n=sm(t);Jp(e)?om(null,e.contents,n,Object.freeze([e]))===im&&(e.contents=null):om(null,e,n,Object.freeze([]))}am.BREAK=nm,am.SKIP=rm,am.REMOVE=im;function om(e,t,n,r){let i=cm(e,t,n,r);if(em(i)||Xp(i))return lm(e,r,i),om(e,i,n,r);if(typeof i!=`symbol`){if($p(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=om(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===nm)return nm;else i===im&&(t.items.splice(e,1),--e)}}else if(Xp(t)){r=Object.freeze(r.concat(t));let e=om(`key`,t.key,n,r);if(e===nm)return nm;e===im&&(t.key=null);let i=om(`value`,t.value,n,r);if(i===nm)return nm;i===im&&(t.value=null)}}return i}function sm(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function cm(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Yp(t))return n.Map?.(e,t,r);if(Qp(t))return n.Seq?.(e,t,r);if(Xp(t))return n.Pair?.(e,t,r);if(Zp(t))return n.Scalar?.(e,t,r);if(qp(t))return n.Alias?.(e,t,r)}function lm(e,t,n){let r=t[t.length-1];if($p(r))r.items[e]=n;else if(Xp(r))e===`key`?r.key=n:r.value=n;else if(Jp(r))r.contents=n;else{let e=qp(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var um={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},dm=e=>e.replace(/[!,[\]{}]/g,e=>um[e]),fm=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+dm(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&em(e.contents)){let t={};am(e.contents,(e,n)=>{em(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
294
+ `)}};fm.defaultYaml={explicit:!1,version:`1.2`},fm.defaultTags={"!!":`tag:yaml.org,2002:`};function pm(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function mm(e){let t=new Set;return am(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function hm(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function gm(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=mm(e);let a=hm(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Zp(t.node)||$p(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function _m(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=_m(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=_m(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=_m(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=_m(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function vm(e,t,n){if(Array.isArray(e))return e.map((e,t)=>vm(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!tm(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var ym=class{constructor(e){Object.defineProperty(this,Kp,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Jp(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=vm(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?_m(i,{"":o},``,o):o}},bm=class extends ym{constructor(e){super(Bp),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],am(e,{Node:(e,t)=>{(qp(t)||tm(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(vm(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=xm(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(pm(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function xm(e,t,n){if(qp(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if($p(t)){let r=0;for(let i of t.items){let t=xm(e,i,n);t>r&&(r=t)}return r}if(Xp(t)){let r=xm(e,t.key,n),i=xm(e,t.value,n);return Math.max(r,i)}return 1}var Sm=e=>!e||typeof e!=`function`&&typeof e!=`object`,Cm=class extends ym{constructor(e){super(Wp),this.value=e}toJSON(e,t){return t?.keep?this.value:vm(this.value,e,t)}toString(){return String(this.value)}};Cm.BLOCK_FOLDED=`BLOCK_FOLDED`,Cm.BLOCK_LITERAL=`BLOCK_LITERAL`,Cm.PLAIN=`PLAIN`,Cm.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Cm.QUOTE_SINGLE=`QUOTE_SINGLE`;var wm=`tag:yaml.org,2002:`;function Tm(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Em(e,t,n){if(Jp(e)&&(e=e.contents),em(e))return e;if(Xp(e)){let t=n.schema[Hp].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new bm(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=wm+t.slice(2));let l=Tm(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Cm(e);return c&&(c.node=t),t}l=e instanceof Map?o[Hp]:Symbol.iterator in Object(e)?o[Gp]:o[Hp]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Cm(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Dm(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Em(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Om=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,km=class extends ym{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>em(t)||Xp(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Om(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if($p(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Dm(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if($p(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Zp(i)?i.value:i:$p(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Xp(t))return!1;let n=t.value;return n==null||e&&Zp(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return $p(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if($p(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Dm(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Am=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function jm(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Mm=(e,t,n)=>e.endsWith(`
295
+ `)?jm(n,t):n.includes(`
296
+ `)?`
297
+ `+jm(n,t):(e.endsWith(` `)?``:` `)+n,Nm=`flow`,Pm=`block`,Fm=`quoted`;function Im(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Lm(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
298
+ `)n===`block`&&(h=Lm(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
299
+ `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
300
+ `&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Lm(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
301
+ `);r=t,i=t+1,a=e[i]}return r}var Rm=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),zm=e=>/^(%|---|\.\.\.)/m.test(e);function Bm(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
302
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Vm(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(zm(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
303
+
304
+ `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
305
+ `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Im(o,a,Fm,Rm(t,!1))}function Hm(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
306
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Vm(e,t);let n=t.indent||(zm(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Im(r,n,Nm,Rm(t,!1))}function Um(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Vm;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Hm:i&&!t?Vm:n?Hm:Vm}return r(e,t)}var Wm;try{Wm=RegExp(`(^|(?<!
307
+ ))
308
+ +(?!
309
+ |$)`,`g`)}catch{Wm=/\n+(?!\n|$)/g}function Gm({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Um(n,r);let l=r.indent||(r.forceBlockIndent||zm(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Cm.BLOCK_FOLDED?!1:t===Cm.BLOCK_LITERAL||!Bm(n,c,l.length);if(!n)return u?`|
310
+ `:`>
311
+ `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
312
+ `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
313
+ `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
314
+ `&&(p=p.slice(0,-1)),p.replace(Wm,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
315
+ `)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
316
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Rm(r,!0);o!==`folded`&&t!==Cm.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Im(`${v}${e}${p}`,l,Pm,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function Km(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
317
+ `)||u&&/[[\]{},]/.test(a))return Um(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
318
+ `)?Um(a,t):Gm(e,t,n,r);if(!s&&!u&&i!==Cm.PLAIN&&a.includes(`
319
+ `))return Gm(e,t,n,r);if(zm(a)){if(c===``)return t.forceBlockIndent=!0,Gm(e,t,n,r);if(s&&c===l)return Um(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Um(a,t)}return s?d:Im(d,c,Nm,Rm(t,!1))}function qm(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Cm.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Cm.QUOTE_DOUBLE);let c=e=>{switch(e){case Cm.BLOCK_FOLDED:case Cm.BLOCK_LITERAL:return i||a?Um(o.value,t):Gm(o,t,n,r);case Cm.QUOTE_DOUBLE:return Vm(o.value,t);case Cm.QUOTE_SINGLE:return Hm(o.value,t);case Cm.PLAIN:return Km(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Jm(e,t){let n=Object.assign({blockQuote:!0,commentString:Am,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Ym(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Zp(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Xm(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Zp(e)||$p(e))&&e.anchor;a&&pm(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Zm(e,t,n,r){if(Xp(e))return e.toString(t,n,r);if(qp(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=em(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=Ym(t.doc.schema.tags,a);let o=Xm(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Zp(a)?qm(a,t,n,r):a.toString(t,n,r);return o?Zp(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Qm({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=em(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if($p(e)||!em(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||$p(e)||(Zp(e)?e.type===Cm.BLOCK_FOLDED||e.type===Cm.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Zm(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Mm(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Mm(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Mm(g,n.indent,l(f))));let _,v,y;em(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Zp(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Qp(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Zm(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
320
+ `:``,v){let e=l(v);S+=`\n${jm(e,n.indent)}`}x===``&&!n.inFlow?S===`
321
+ `&&y&&(S=`
322
+
323
+ `):S+=`\n${n.indent}`}else if(!p&&$p(t)){let e=x[0],r=x.indexOf(`
324
+ `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
325
+ `)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Mm(g,n.indent,l(y)):h&&i&&i(),g}function $m(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var eh=`<<`,th={identify:e=>e===eh||typeof e==`symbol`&&e.description===eh,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Cm(Symbol(eh)),{addToJSMap:rh}),stringify:()=>eh},nh=(e,t)=>(th.identify(t)||Zp(t)&&(!t.type||t.type===Cm.PLAIN)&&th.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===th.tag&&e.default);function rh(e,t,n){let r=ah(e,n);if(Qp(r))for(let n of r.items)ih(e,t,n);else if(Array.isArray(r))for(let n of r)ih(e,t,n);else ih(e,t,r)}function ih(e,t,n){let r=ah(e,n);if(!Yp(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ah(e,t){return e&&qp(t)?t.resolve(e.doc,e):t}function oh(e,t,{key:n,value:r}){if(em(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(nh(e,n))rh(e,t,r);else{let i=vm(n,``,e);if(t instanceof Map)t.set(i,vm(r,i,e));else if(t instanceof Set)t.add(i);else{let a=sh(n,i,e),o=vm(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function sh(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(em(e)&&n?.doc){let t=Jm(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),$m(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function ch(e,t,n){return new lh(Em(e,void 0,n),Em(t,void 0,n))}var lh=class e{constructor(e,t=null){Object.defineProperty(this,Kp,{value:Up}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return em(n)&&(n=n.clone(t)),em(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return oh(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Qm(this,e,t,n):JSON.stringify(this)}};function uh(e,t,n){return(t.inFlow??e.flow?fh:dh)(e,t,n)}function dh({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(em(i))!d&&i.spaceBefore&&f.push(``),ph(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Xp(i)){let e=em(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),ph(n,f,e.commentBefore,d))}d=!1;let s=Zm(i,u,()=>o=null,()=>d=!0);o&&(s+=Mm(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
326
+ `}}return e?(p+=`
327
+ `+jm(l(e),c),s&&s()):d&&o&&o(),p}function fh({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(em(i))i.spaceBefore&&d.push(``),ph(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Xp(i)){let e=em(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),ph(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=em(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Zm(i,c,()=>a=null);l||=d.length>u||o.includes(`
328
+ `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Mm(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
329
+ `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function ph({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=jm(t(r),e);n.push(i.trimStart())}}function mh(e,t){let n=Zp(t)?t.value:t;for(let r of e)if(Xp(r)&&(r.key===t||r.key===n||Zp(r.key)&&r.key.value===n))return r}var hh=class extends km{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Hp,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(ch(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Xp(e)?e:!e||typeof e!=`object`||!(`key`in e)?new lh(e,e?.value):new lh(e.key,e.value);let r=mh(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Zp(r.value)&&Sm(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=mh(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=mh(this.items,e)?.value;return(!t&&Zp(n)?n.value:n)??void 0}has(e){return!!mh(this.items,e)}set(e,t){this.add(new lh(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)oh(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Xp(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),uh(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},gh={collection:`map`,default:!0,nodeClass:hh,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Yp(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>hh.from(e,t,n)},_h=class extends km{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Gp,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=vh(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=vh(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Zp(r)?r.value:r}has(e){let t=vh(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=vh(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];Zp(r)&&Sm(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(vm(e,String(r++),t));return n}toString(e,t,n){return e?uh(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Em(a,void 0,n))}}return i}};function vh(e){let t=Zp(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var yh={collection:`seq`,default:!0,nodeClass:_h,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Qp(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>_h.from(e,t,n)},bh={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),qm(e,t,n,r)}},xh={identify:e=>e==null,createNode:()=>new Cm(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Cm(null),stringify:({source:e},t)=>typeof e==`string`&&xh.test.test(e)?e:t.options.nullStr},Sh={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Cm(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&Sh.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function Ch({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var wh={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:Ch},Th={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ch(e)}},Eh={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Cm(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:Ch},Dh=e=>typeof e==`bigint`||Number.isInteger(e),Oh=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function kh(e,t,n){let{value:r}=e;return Dh(r)&&r>=0?n+r.toString(t):Ch(e)}var Ah={identify:e=>Dh(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Oh(e,2,8,n),stringify:e=>kh(e,8,`0o`)},jh={identify:Dh,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Oh(e,0,10,n),stringify:Ch},Mh={identify:e=>Dh(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Oh(e,2,16,n),stringify:e=>kh(e,16,`0x`)},Nh=[gh,yh,bh,xh,Sh,Ah,jh,Mh,wh,Th,Eh];function Ph(e){return typeof e==`bigint`||Number.isInteger(e)}var Fh=({value:e})=>JSON.stringify(e),Ih=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Fh},{identify:e=>e==null,createNode:()=>new Cm(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Fh},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Fh},{identify:Ph,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ph(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Fh}],Lh=[gh,yh].concat(Ih,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Rh={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=Cm.BLOCK_LITERAL,t!==Cm.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===Cm.BLOCK_LITERAL?`
330
+ `:` `)}return qm({comment:e,type:t,value:s},r,i,a)}};function zh(e,t){if(Qp(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Xp(r)){if(Yp(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new lh(new Cm(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Xp(r)?r:new lh(r)}}else t(`Expected a sequence for this tag`);return e}function Bh(e,t,n){let{replacer:r}=n,i=new _h(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(ch(o,s,n))}return i}var Vh={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:zh,createNode:Bh},Hh=class e extends _h{constructor(){super(),this.add=hh.prototype.add.bind(this),this.delete=hh.prototype.delete.bind(this),this.get=hh.prototype.get.bind(this),this.has=hh.prototype.has.bind(this),this.set=hh.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Xp(e)?(r=vm(e.key,``,t),i=vm(e.value,r,t)):r=vm(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Bh(e,t,n),i=new this;return i.items=r.items,i}};Hh.tag=`tag:yaml.org,2002:omap`;var Uh={collection:`seq`,identify:e=>e instanceof Map,nodeClass:Hh,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=zh(e,t),r=[];for(let{key:e}of n.items)Zp(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new Hh,n)},createNode:(e,t,n)=>Hh.from(e,t,n)};function Wh({value:e,source:t},n){return t&&(e?Gh:Kh).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Gh={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Cm(!0),stringify:Wh},Kh={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Cm(!1),stringify:Wh},qh={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:Ch},Jh={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ch(e)}},Yh={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Cm(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:Ch},Xh=e=>typeof e==`bigint`||Number.isInteger(e);function Zh(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function Qh(e,t,n){let{value:r}=e;if(Xh(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return Ch(e)}var $h={identify:Xh,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Zh(e,2,2,n),stringify:e=>Qh(e,2,`0b`)},eg={identify:Xh,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Zh(e,1,8,n),stringify:e=>Qh(e,8,`0`)},tg={identify:Xh,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Zh(e,0,10,n),stringify:Ch},ng={identify:Xh,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Zh(e,2,16,n),stringify:e=>Qh(e,16,`0x`)},rg=class e extends hh{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Xp(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new lh(e.key,null):new lh(e,null),mh(this.items,t.key)||this.items.push(t)}get(e,t){let n=mh(this.items,e);return!t&&Xp(n)?Zp(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=mh(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new lh(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(ch(e,null,n));return i}};rg.tag=`tag:yaml.org,2002:set`;var ig={collection:`map`,identify:e=>e instanceof Set,nodeClass:rg,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>rg.from(e,t,n),resolve(e,t){if(Yp(e)){if(e.hasAllNullValues(!0))return Object.assign(new rg,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function ag(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function og(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return Ch(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var sg={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>ag(e,n),stringify:og},cg={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ag(e,!1),stringify:og},lg={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(lg.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=ag(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},ug=[gh,yh,bh,xh,Gh,Kh,$h,eg,tg,ng,qh,Jh,Yh,Rh,th,Uh,Vh,ig,sg,cg,lg],dg=new Map([[`core`,Nh],[`failsafe`,[gh,yh,bh]],[`json`,Lh],[`yaml11`,ug],[`yaml-1.1`,ug]]),fg={binary:Rh,bool:Sh,float:Eh,floatExp:Th,floatNaN:wh,floatTime:cg,int:jh,intHex:Mh,intOct:Ah,intTime:sg,map:gh,merge:th,null:xh,omap:Uh,pairs:Vh,seq:yh,set:ig,timestamp:lg},pg={"tag:yaml.org,2002:binary":Rh,"tag:yaml.org,2002:merge":th,"tag:yaml.org,2002:omap":Uh,"tag:yaml.org,2002:pairs":Vh,"tag:yaml.org,2002:set":ig,"tag:yaml.org,2002:timestamp":lg};function mg(e,t,n){let r=dg.get(t);if(r&&!e)return n&&!r.includes(th)?r.concat(th):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(dg.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(th)),i.reduce((e,t)=>{let n=typeof t==`string`?fg[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(fg).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var hg=(e,t)=>e.key<t.key?-1:+(e.key>t.key),gg=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?mg(e,`compat`):e?mg(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?pg:{},this.tags=mg(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Hp,{value:gh}),Object.defineProperty(this,Wp,{value:bh}),Object.defineProperty(this,Gp,{value:yh}),this.sortMapEntries=typeof a==`function`?a:a===!0?hg:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function _g(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Jm(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(jm(t,``))}let o=!1,s=null;if(e.contents){if(em(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(jm(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Zm(e.contents,i,()=>s=null,t);s&&(c+=Mm(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Zm(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
331
+ `)?(n.push(`...`),n.push(jm(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(jm(a(t),``)))}return n.join(`
332
+ `)+`
333
+ `}var vg=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Kp,{value:Vp});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new fm({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Kp]:{value:Vp}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=em(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){yg(this.contents)&&this.contents.add(e)}addIn(e,t){yg(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=mm(this);e.anchor=!t||n.has(t)?hm(t||`a`,n):t}return new bm(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=gm(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Em(e,l,p);return o&&$p(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new lh(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return yg(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Om(e)?this.contents!=null&&(this.contents=null,!0):yg(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return $p(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Om(e)?!t&&Zp(this.contents)?this.contents.value:this.contents:$p(this.contents)?this.contents.getIn(e,t):void 0}has(e){return $p(this.contents)?this.contents.has(e):!1}hasIn(e){return Om(e)?this.contents!==void 0:$p(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Dm(this.schema,[e],t):yg(this.contents)&&this.contents.set(e,t)}setIn(e,t){Om(e)?this.contents=t:this.contents==null?this.contents=Dm(this.schema,Array.from(e),t):yg(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new fm({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new fm({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new gg(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=vm(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?_m(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return _g(this,e)}};function yg(e){if($p(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var bg=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},xg=class extends bg{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},Sg=class extends bg{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},Cg=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
334
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function wg(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function Tg(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
335
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(Tg(t.key)||Tg(t.value))return!0}return!1;default:return!0}}function Eg(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&Tg(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Dg(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||Zp(e)&&Zp(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var Og=`All mapping items must start at the same column`;function kg({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??hh)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=wg(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Og)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
336
+ `+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Tg(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Og);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Eg(r.indent,u,i),n.atKey=!1,Dg(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=wg(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&Eg(r.indent,f,i),s=c.range[2];let l=new lh(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
337
+ `+_.comment:g.comment=_.comment);let e=new lh(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function Ag({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??_h)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=wg(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&Eg(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function jg(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var Mg=`Block collections are not allowed within flow collections`,Ng=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function Pg({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?hh:_h))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=wg(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
338
+ `+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&Tg(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Xp(t)&&(t=t.value??t.key),t.comment?t.comment+=`
339
+ `+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],Ng(m)&&i(r.range,`BLOCK_IN_FLOW`,Mg)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Ng(f)&&i(g.range,`BLOCK_IN_FLOW`,Mg),n.atKey=!1;let _=wg(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?Ng(m)&&i(v.range,`BLOCK_IN_FLOW`,Mg):_.comment&&(g.comment?g.comment+=`
340
+ `+_.comment:g.comment=_.comment);let y=new lh(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Dg(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new hh(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=jg(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
341
+ `+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function Fg(e,t,n,r,i,a){let o=n.type===`block-map`?kg(e,t,n,r,a):n.type===`block-seq`?Ag(e,t,n,r,a):Pg(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function Ig(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===hh.tagName&&s===`map`||o===_h.tagName&&s===`seq`)return Fg(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),Fg(e,t,n,i,o)}let l=Fg(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=em(u)?u:new Cm(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function Lg(e,t,n){let r=t.offset,i=Rg(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?Cm.BLOCK_FOLDED:Cm.BLOCK_LITERAL,o=t.source?zg(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
342
+ `.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
343
+ `;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===Cm.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
344
+ `):t.length>c||r[0]===` `?(f===` `?f=`
345
+ `:!p&&f===`
346
+ `&&(f=`
347
+
348
+ `),d+=f+t.slice(c)+r,f=`
349
+ `,p=!0):r===``?f===`
350
+ `?d+=`
351
+ `:f=`
352
+ `:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
353
+ `+o[e][0].slice(c);d[d.length-1]!==`
354
+ `&&(d+=`
355
+ `);break;default:d+=`
356
+ `}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function Rg({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function zg(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function Bg(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=Cm.PLAIN,c=Vg(a,l);break;case`single-quoted-scalar`:s=Cm.QUOTE_SINGLE,c=Hg(a,l);break;case`double-quoted-scalar`:s=Cm.QUOTE_DOUBLE,c=Wg(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=jg(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Vg(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),Ug(e)}function Hg(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),Ug(e.slice(1,-1)).replace(/''/g,`'`)}function Ug(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
357
+ `?a+=o:o=`
358
+ `:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function Wg(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
359
+ `){if(i===`
360
+ `){let{fold:t,offset:i}=Gg(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=Kg[i];if(a)n+=a;else if(i===`
361
+ `)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
362
+ `)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=qg(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
363
+ `&&(a!==`\r`||e[r+2]!==`
364
+ `)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function Gg(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
365
+ `||r===`\r`)&&(r!==`\r`||e[t+2]===`
366
+ `);)r===`
367
+ `&&(n+=`
368
+ `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var Kg={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
369
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function qg(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function Jg(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?Lg(e,t,r):Bg(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[Wp]:c?Yg(e.schema,i,c,n,r):t.type===`scalar`?Xg(e,i,t,r):e.schema[Wp];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=Zp(a)?a:new Cm(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new Cm(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function Yg(e,t,n,r,i){if(n===`!`)return e[Wp];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Wp])}function Xg({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[Wp];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[Wp];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function Zg(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var Qg={composeNode:$g,composeEmptyNode:e_};function $g(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=t_(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=Jg(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=Ig(Qg,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=e_(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!Zp(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function e_(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=Jg(e,{type:`scalar`,offset:Zg(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function t_({options:e},{offset:t,source:n,end:r},i){let a=new bm(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=jg(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function n_(e,t,{offset:n,start:r,value:i,end:a},o){let s=new vg(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=wg(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?$g(c,i,l,o):e_(c,l.end,r,null,l,o);let u=s.contents.range[2],d=jg(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function r_(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function i_(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
370
+
371
+ `:`
372
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var a_=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=r_(e);r?this.warnings.push(new Sg(i,t,n)):this.errors.push(new xg(i,t,n))},this.directives=new fm({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=i_(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if($p(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Xp(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:i_(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=r_(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=n_(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new xg(r_(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new xg(r_(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=jg(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new xg(r_(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new vg(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},o_=Symbol(`break visit`),s_=Symbol(`skip children`),c_=Symbol(`remove item`);function l_(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),u_(Object.freeze([]),e,t)}l_.BREAK=o_,l_.SKIP=s_,l_.REMOVE=c_,l_.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},l_.parentCollection=(e,t)=>{let n=l_.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function u_(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=u_(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===o_)return o_;else r===c_&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function d_(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
373
+ `:case`\r
374
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function f_(e){switch(e){case void 0:case` `:case`
375
+ `:case`\r`:case` `:return!0;default:return!1}}var p_=new Set(`0123456789ABCDEFabcdef`),m_=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),h_=new Set(`,[]{}`),g_=new Set(` ,[]{}
376
+ \r `),__=e=>!e||g_.has(e),v_=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
377
+ `||t===`\r`&&this.buffer[e+1]===`
378
+ `}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
379
+ `||!t&&!this.atEnd)return e+n+1}return t===`
380
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&f_(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
381
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&f_(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!f_(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&f_(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(__),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&f_(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(__),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||f_(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
382
+ `,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
383
+ `,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>f_(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
384
+ `:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
385
+ `)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
386
+ `,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
387
+ `;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
388
+ `&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(f_(r)||e&&h_.has(r))break;t=n}else if(f_(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
389
+ `?(n+=1,r=`
390
+ `,i=this.buffer[n+1]):t=n),i===`#`||e&&h_.has(i))break;if(r===`
391
+ `){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&h_.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(__),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(f_(n)||t&&h_.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!f_(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(m_.has(t))t=this.buffer[++e];else if(t===`%`&&p_.has(this.buffer[e+1])&&p_.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
392
+ `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
393
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},y_=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function b_(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function x_(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function S_(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function C_(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function w_(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function T_(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function E_(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!b_(t.start,`explicit-key-ind`)&&!b_(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,S_(t.value)?t.value.end?T_(t.value.end,t.sep):t.value.end=t.sep:T_(t.start,t.sep),delete t.sep)}var D_=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new v_,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=d_(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&E_(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&x_(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:x_(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=w_(C_(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
394
+ `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
395
+ `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){T_(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(b_(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=w_(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(b_(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(S_(t.key)&&!b_(t.sep,`newline`)){let e=w_(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):b_(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!b_(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){T_(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||b_(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=w_(C_(t));E_(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
396
+ `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
397
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=w_(C_(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=w_(C_(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function O_(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new y_||null,prettyErrors:t}}function k_(e,t={}){let{lineCounter:n,prettyErrors:r}=O_(t),i=new D_(n?.addNewLine),a=new a_(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new xg(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Cg(e,n)),o.warnings.forEach(Cg(e,n))),o}function A_(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=k_(e,n);if(!i)return null;if(i.warnings.forEach(e=>$m(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var j_=e=>[e??`#0284C7`,`#F59E0B`,`#10B981`,`#8B5CF6`,`#EF4444`,`#64748B`,`#EC4899`],M_=[`column`,`bar`,`line`,`pie`,`doughnut`,`area`];function N_(e){let t=A_(e.replace(/^\s*```\s*chart\s*\n/,``).replace(/\n?```\s*$/,``));if(!t||typeof t!=`object`)throw Error(`chart block must be a YAML mapping (kind, categories, series)`);let n=String(t.kind??`column`);if(!M_.includes(n))throw Error(`chart kind "${n}" is not one of ${M_.join(`, `)}`);let r=Array.isArray(t.categories)?t.categories.map(String):[];if(!r.length)throw Error(`chart needs categories: [a, b, …]`);let i=Array.isArray(t.series)?t.series:[];if(!i.length)throw Error(`chart needs series: [{name, values}]`);return{kind:n,categories:r,series:i.map((e,t)=>{let n=e??{},i=Array.isArray(n.values)?n.values.map(Number):[];if(i.length!==r.length||i.some(e=>Number.isNaN(e)))throw Error(`series ${t+1}: values must be ${r.length} numbers`);return{name:String(n.name??`Series ${t+1}`),values:i}}),...typeof t.title==`string`&&t.title.trim()?{title:t.title.trim()}:{}}}var P_=e=>e.replace(/-?\d+\.\d{3,}/g,e=>String(Math.round(Number(e)*100)/100)),F_=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),I_=e=>Math.abs(e)>=1e3?e.toLocaleString(`en-US`).replace(/,/g,`'`):String(Math.round(e*100)/100);function L_(e,t){let n=Math.max(e-Math.min(0,t),1e-9)/5,r=10**Math.floor(Math.log10(n)),i=[1,2,2.5,5,10].map(e=>e*r).find(e=>e>=n)??r*10;return{lo:Math.min(0,Math.floor(t/i)*i),hi:Math.ceil(e/i)*i||i,step:i}}function R_(e,t,n,r){let i=r.fontSize,a=e=>r.palette[e%r.palette.length],o=[],s=4;e.title&&(o.push(`<text x="${t/2}" y="${i*1.1}" text-anchor="middle" font-weight="700" font-size="${i*1.1}" fill="${r.text}">${F_(e.title)}</text>`),s+=i*1.7);let c=e.series.length>1||e.kind===`pie`||e.kind===`doughnut`,l=e.kind===`pie`||e.kind===`doughnut`?e.categories:e.series.map(e=>e.name),u=c?i*1.8:0;if(c){let e=l.map(e=>e.length*i*.55+i*1.8),s=(t-e.reduce((e,t)=>e+t,0))/2,c=n-i*.5;l.forEach((t,n)=>{o.push(`<rect x="${s}" y="${c-i*.75}" width="${i*.8}" height="${i*.8}" rx="${i*.15}" fill="${a(n)}"/><text x="${s+i*1.1}" y="${c}" font-size="${i*.9}" fill="${r.muted}">${F_(t)}</text>`),s+=e[n]})}let d=n-s-u;if(e.kind===`pie`||e.kind===`doughnut`){let r=e.series[0].values.map(e=>Math.max(0,e)),c=r.reduce((e,t)=>e+t,0)||1,l=Math.max(10,Math.min(t,d)/2-4),u=t/2,f=s+d/2,p=-Math.PI/2;return r.forEach((t,n)=>{let r=p+t/c*Math.PI*2,s=+(r-p>Math.PI),d=(e,t)=>`${u+t*Math.cos(e)} ${f+t*Math.sin(e)}`;t/c>=.9999?o.push(`<circle cx="${u}" cy="${f}" r="${l}" fill="${a(n)}"/>`):o.push(`<path d="M ${u} ${f} L ${d(p,l)} A ${l} ${l} 0 ${s} 1 ${d(r,l)} Z" fill="${a(n)}" stroke="#fff" stroke-width="2"/>`);let m=(p+r)/2;t/c>.06&&o.push(`<text x="${u+l*(e.kind===`doughnut`?.78:.62)*Math.cos(m)}" y="${f+l*(e.kind===`doughnut`?.78:.62)*Math.sin(m)+i*.35}" text-anchor="middle" font-size="${i}" font-weight="700" fill="#fff">${Math.round(t/c*100)}%</text>`),p=r}),e.kind===`doughnut`&&o.push(`<circle cx="${u}" cy="${f}" r="${l*.55}" fill="var(--c-background, #fff)"/>`),P_(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${n}" width="100%" height="100%" font-family="inherit">${o.join(``)}</svg>`)}let f=e.series.flatMap(e=>e.values),{lo:p,hi:m,step:h}=L_(Math.max(...f,0),Math.min(...f,0)),g=e.kind===`bar`,_=g?Math.min(t*.3,Math.max(...e.categories.map(e=>e.length))*i*.55+i):Math.max(...[p,m].map(e=>I_(e).length))*i*.6+i*.6,v=t-i,y=s+d-(g?i*1.6:i*1.8),b=s+i*.6,x=[];for(let e=p;e<=m+h/2;e+=h)x.push(Math.round(e*1e6)/1e6);let S=e.categories.length;if(g){let s=e=>_+(e-p)/(m-p)*(v-_);for(let e of x)o.push(`<line x1="${s(e)}" x2="${s(e)}" y1="${b}" y2="${y}" stroke="${r.line}"/><text x="${s(e)}" y="${y+i*1.2}" text-anchor="middle" font-size="${i*.85}" fill="${r.muted}">${I_(e)}</text>`);let c=(y-b)/S,l=c*.7/e.series.length;return e.categories.forEach((t,n)=>{o.push(`<text x="${_-i*.5}" y="${b+c*(n+.5)+i*.35}" text-anchor="end" font-size="${i*.9}" fill="${r.text}">${F_(t)}</text>`),e.series.forEach((e,t)=>{let r=b+c*n+c*.15+l*t,i=s(Math.min(0,e.values[n]));o.push(`<rect x="${i}" y="${r}" width="${Math.abs(s(e.values[n])-s(0))}" height="${l*.92}" rx="2" fill="${a(t)}"/>`)})}),P_(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${n}" width="100%" height="100%" font-family="inherit">${o.join(``)}</svg>`)}let C=e=>y-(e-p)/(m-p)*(y-b);for(let e of x)o.push(`<line x1="${_}" x2="${v}" y1="${C(e)}" y2="${C(e)}" stroke="${r.line}"/><text x="${_-i*.4}" y="${C(e)+i*.32}" text-anchor="end" font-size="${i*.85}" fill="${r.muted}">${I_(e)}</text>`);let w=(v-_)/S;if(e.categories.forEach((e,t)=>o.push(`<text x="${_+w*(t+.5)}" y="${y+i*1.3}" text-anchor="middle" font-size="${i*.9}" fill="${r.text}">${F_(e)}</text>`)),e.kind===`column`){let t=w*.7/e.series.length;e.series.forEach((e,n)=>e.values.forEach((e,r)=>{let i=_+w*r+w*.15+t*n,s=Math.min(C(e),C(0));o.push(`<rect x="${i}" y="${s}" width="${t*.92}" height="${Math.abs(C(e)-C(0))}" rx="2" fill="${a(n)}"/>`)}))}else e.series.forEach((t,n)=>{let r=t.values.map((e,t)=>`${_+w*(t+.5)},${C(e)}`);e.kind===`area`&&o.push(`<polygon points="${_+w*.5},${C(Math.max(p,0))} ${r.join(` `)} ${_+w*(S-.5)},${C(Math.max(p,0))}" fill="${a(n)}" fill-opacity="0.22"/>`),o.push(`<polyline points="${r.join(` `)}" fill="none" stroke="${a(n)}" stroke-width="${Math.max(2,i*.18)}" stroke-linejoin="round" stroke-linecap="round"/>`),t.values.forEach((e,t)=>o.push(`<circle cx="${_+w*(t+.5)}" cy="${C(e)}" r="${Math.max(3,i*.22)}" fill="${a(n)}"/>`))});return o.push(`<line x1="${_}" x2="${v}" y1="${C(Math.max(p,0))}" y2="${C(Math.max(p,0))}" stroke="${r.muted}"/>`),P_(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${t} ${n}" width="100%" height="100%" font-family="inherit">${o.join(``)}</svg>`)}var z_=e=>/^[\p{L}\p{N}][\p{L}\p{N} ._%'()/&+-]*$/u.test(e)&&!/^(true|false|null|yes|no|on|off|~)$/i.test(e)&&!/^[\d.+-]+$/.test(e)?e:JSON.stringify(e);function B_(e,t){let n=[`kind: ${e.kind}`,...e.title?[`title: ${z_(e.title)}`]:[],`categories: [${e.categories.map(z_).join(`, `)}]`,`series:`];for(let t of e.series)n.push(` - name: ${z_(t.name)}`,` values: [${t.values.map(e=>String(Math.round(e*1e6)/1e6)).join(`, `)}]`);let r=n.join(`
398
+ `);return t?`\`\`\`chart\n${r}\n\`\`\``:r}var V_=[`text`,`markdown`,`image`,`chart`,`table`,`html`,`embed`],H_=1600;H_/10;var U_={background:`#F9F9F7`,surface:`#FFFFFF`,text:`#161310`,muted:`#6F6D67`,accent:`#0284C7`,onAccent:`#FFFFFF`,line:`#E1E0D9`};function W_(e,t){let n=t??e.default??(e.layouts.content?`content`:Object.keys(e.layouts)[0]),r=n?e.layouts[n]:void 0;return r?{name:n,layout:r}:null}function G_(e){if(e.default)return e.default;let t=Object.entries(e.slots).filter(([e])=>e!==`title`);return t.find(([,e])=>e.kind===`markdown`)?.[0]??t.find(([,e])=>e.required&&e.kind!==`text`)?.[0]??(t.length===1?t[0][0]:void 0)??t.find(([,e])=>e.kind===`text`)?.[0]}function K_(e,t,n=0){if(!t||n>4)return null;let r=t.trim();if(/^#?[0-9a-f]{6}$/i.test(r))return r.startsWith(`#`)?r.toUpperCase():`#${r.toUpperCase()}`;if(/^#[0-9a-f]{3}$/i.test(r))return`#${r.slice(1).split(``).map(e=>e+e).join(``)}`.toUpperCase();let i=e.colors[r]??U_[r];return i?K_(e,i,n+1):null}var q_={kind:`kind`,x:`number`,y:`number`,w:`positive`,h:`positive`,size:`positive`,bold:`boolean`,italic:`boolean`,color:`string`,font:`string`,align:`align`,valign:`valign`,fill:`string`,class:`string`,underline:`boolean`,strike:`boolean`,rotate:`number`,radius:`number`,border:`number`,borderColor:`string`,shadow:`boolean`,opacity:`number`,z:`number`,fit:`string`};function J_(e){if(e==null)return{patch:{}};if(typeof e!=`object`||Array.isArray(e))return{patch:{},problem:`must be a mapping`};let t={};for(let[n,r]of Object.entries(e)){let e=q_[n];if(!e)return{patch:{},problem:`unknown key "${n}" (one of ${Object.keys(q_).join(`, `)})`};if(!(e===`number`?typeof r==`number`&&Number.isFinite(r):e===`positive`?typeof r==`number`&&r>0:e===`boolean`?typeof r==`boolean`:e===`string`?typeof r==`string`:e===`kind`?V_.includes(r):e===`align`?[`left`,`center`,`right`].includes(r):[`top`,`middle`,`bottom`].includes(r)))return{patch:{},problem:`${n}: ${JSON.stringify(r)} is not valid`};t[n]=r}return{patch:t}}function Y_(e,t){let n={...e.slots},r=[];if(t==null)return{slots:n,problems:r};if(typeof t!=`object`||Array.isArray(t))return{slots:n,problems:["`slots` must be a mapping of slot name to its changes"]};for(let[i,a]of Object.entries(t)){if(!/^[a-z][a-z0-9_-]*$/i.test(i)){r.push(`slot name "${i}" is not valid`);continue}let{patch:t,problem:o}=J_(a);if(o){r.push(`slots.${i}: ${o}`);continue}let s=e.slots[i];s?n[i]={...s,...t,changed:!0}:t.x===void 0||t.y===void 0||t.w===void 0||t.h===void 0?r.push(`slots.${i}: a slot the layout does not have needs x, y, w and h`):n[i]={kind:t.kind??`text`,...t,own:!0}}return{slots:n,problems:r}}var X_=/^(`{3,}|~{3,})/,Z_=/^::([a-z][a-z0-9_-]*)::[ \t]*$/i,Q_=/^\s*#{1,6}[ \t]+(.+?)[ \t]*#*[ \t]*(?:\n|$)/,$_=e=>e.replace(/^\s*\n/,``).replace(/\s+$/,``);function ev(e){let t={},n=`_`,r=[],i=null,a=()=>{let e=$_(r.join(`
399
+ `));(n!==`_`||e!==``)&&(t[n]=t[n]?`${t[n]}\n${e}`:e),r=[]};for(let t of e.replace(/\r\n?/g,`
400
+ `).split(`
401
+ `)){let e=X_.exec(t);if(e){i?t.startsWith(i)&&(i=null):i=e[1],r.push(t);continue}let o=!i&&Z_.exec(t);if(o){a(),n=o[1].toLowerCase();continue}r.push(t)}return a(),t}function tv(e){let t=[];e._?.trim()&&t.push($_(e._));for(let[n,r]of Object.entries(e))n!==`_`&&t.push(`::${n}::\n${$_(r)}`);return t.join(`
402
+
403
+ `)}function nv(e){let t=e??``,n=Q_.exec(t);return n?{heading:n[1],rest:$_(t.slice(n[0].length))}:{heading:null,rest:$_(t)}}function rv(e,t,n){let r=ev(e);if(r[t]!==void 0)return r[t];let{heading:i,rest:a}=nv(r._);if(t===`title`)return i??void 0;if(t===n&&a)return a}function iv(e,t,n,r){let i=ev(e),a=$_(n),{heading:o,rest:s}=nv(i._),c=(e,t)=>{let n=[e?`# ${e}`:``,t].filter(Boolean);n.length?i._=n.join(`
404
+
405
+ `):delete i._};return i[t]===void 0?t===`title`?c(a?a.replace(/\n+/g,` `):null,s):t===r?c(o,a):a&&(i[t]=a):a?i[t]=a:delete i[t],tv(i)}var av=[`fade`,`slide`,`zoom`,`none`],ov=e=>av.includes(e??``)?e:`fade`,sv=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),cv=(e,t)=>e.replace(/(?<![\w-])(src=["']|url\(["']?)((?!https?:|data:|blob:|#|\/)[^"')\s]+)/g,(e,n,r)=>n+t(r)),lv=e=>e===`4:3`?1200:900,uv=e=>Math.round(e/72*160*100)/100;function dv(e,t,n){let r=new Ip({gfm:!0,breaks:!1});return r.use({renderer:{code(t){if((t.lang??``).trim().toLowerCase()===`chart`)try{let{w:r,h:i,size:a}=n();return R_(N_(t.text),r,i,fv(e,a))}catch(e){return`<p class="deck-error">chart: ${sv(e.message)}</p>`}return`<pre><code>${sv(t.text)}</code></pre>`},image(e){return`<img src="${sv(t.asset(e.href))}" data-src="${sv(e.href)}" alt="${sv(e.text??``)}"${e.title?` title="${sv(e.title)}"`:``}>`}}}),r}var fv=(e,t)=>({palette:j_(e.colors.accent),text:e.colors.text??`#161310`,muted:e.colors.muted??`#6F6D67`,line:e.colors.line??`#E1E0D9`,fontSize:uv(t)});function pv(e,t,n){let r=H_,i=lv(t.size),a=[],o=W_(t,e.layout)??W_(t,void 0),s=e.extra?.hidden===!0,c=n.numbers!==!1&&e.extra?.number!==!1,l=ov(e.transition);if(e.transition&&ov(e.transition)!==e.transition&&a.push(`transition "${e.transition}" is not one of ${av.join(`, `)}; fading`),!o)return{layout:``,transition:l,background:t.colors.background??`#fff`,hidden:s,numbered:c,shapes:[],slots:[],problems:[`the template has no layouts`],width:r,height:i};e.layout&&o.name!==e.layout&&a.push(`unknown layout "${e.layout}", using "${o.name}"`);let u=Y_(o.layout,e.extra?.slots);a.push(...u.problems);let d=G_(o.layout),f=ev(e.content);for(let e of Object.keys(f))e!==`_`&&!u.slots[e]&&a.push(`layout has no slot "${e}"`);!d&&nv(f._).rest&&a.push(`unmarked content has no slot to go to`);let p=(e,n)=>K_(t,e)??n,m=e.background?.trim(),h=m&&/\.(png|jpe?g|gif|webp|svg|avif)(\?.*)?$/i.test(m)?`url("${n.asset(m)}") center / cover no-repeat`:p(m??o.layout.background??`background`,`#FFFFFF`),g=(o.layout.shapes??[]).map(e=>({x:e.x,y:e.y,w:e.w,h:e.h,fill:p(e.fill??e.color??`accent`,`#000000`)})),_=Object.entries(u.slots).map(([r,i])=>{let a=rv(e.content,r,d),o=i,s={name:r,kind:o.kind,x:o.x,y:o.y,w:o.w,h:o.h,...o.size?{size:o.size}:{},...o.bold?{bold:!0}:{},...o.italic?{italic:!0}:{},...o.color?{color:o.color}:{},...o.font?{font:o.font}:{},...o.align?{align:o.align}:{},...o.valign?{valign:o.valign}:{},...o.fill?{fill:o.fill}:{},...o.class?{class:o.class}:{},...o.underline?{underline:!0}:{},...o.strike?{strike:!0}:{},...typeof o.rotate==`number`&&o.rotate?{rotate:o.rotate}:{},...typeof o.radius==`number`?{radius:o.radius}:{},...typeof o.border==`number`?{border:o.border}:{},...o.borderColor?{borderColor:o.borderColor}:{},...o.shadow?{shadow:!0}:{},...typeof o.opacity==`number`&&o.opacity<1?{opacity:o.opacity}:{},...typeof o.z==`number`?{z:o.z}:{},...o.fit?{fit:o.fit}:{},...o.required?{required:!0}:{},...o.placeholder?{placeholder:o.placeholder}:{},...o.own?{own:!0}:{},...o.changed?{changed:!0}:{},...a===void 0?{}:{md:a},html:``};if(a===void 0||a.trim()===``)return s;let c={w:o.w*160-32,h:o.h*160-16,size:o.size??14},l=dv(t,n,()=>c);try{switch(o.kind){case`text`:s.html=l.parseInline(a.replace(/\s*\n\s*/g,` `),{async:!1});break;case`image`:{let e=/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/.exec(a),t=e?e[2]:a.trim();s.html=`<img src="${sv(n.asset(t))}" data-src="${sv(t)}" alt="${sv(e?.[1]??``)}">`;break}case`chart`:s.html=R_(N_(a),c.w,c.h,fv(t,c.size));break;case`html`:s.html=cv(a,n.asset);break;case`embed`:{let e=a.trim();s.embed=/^https?:\/\/\S+$/i.test(e)?{src:e}:{srcdoc:e};break}default:s.html=cv(l.parse(a,{async:!1}),n.asset)}}catch(e){s.error=e.message,s.html=`<p class="deck-error">${sv(s.error)}</p>`}return s});return{layout:o.name,transition:l,background:h,hidden:s,numbered:c,shapes:g,slots:_,problems:a,width:r,height:i}}function mv(e,t){let n={left:`${hv(e.x)}px`,top:`${hv(e.y)}px`,width:`${hv(e.w)}px`,height:`${hv(e.h)}px`};e.size&&(n[`font-size`]=`${uv(e.size)}px`),e.bold&&(n[`font-weight`]=`700`),e.italic&&(n[`font-style`]=`italic`),e.color&&(n.color=K_(t,e.color)??e.color),e.font&&(n[`font-family`]=e.font===`heading`?`var(--font-heading)`:e.font===`body`?`var(--font-body)`:`"${e.font}", var(--font-body)`),e.align&&(n[`text-align`]=e.align),e.fill&&(n.background=K_(t,e.fill)??e.fill);let r=[e.underline&&`underline`,e.strike&&`line-through`].filter(Boolean).join(` `);return r&&(n[`text-decoration`]=r),e.rotate&&(n.transform=`rotate(${e.rotate}deg)`),e.radius&&(n[`border-radius`]=`${uv(e.radius)}px`),e.border&&(n.border=`${uv(e.border)}px solid ${K_(t,e.borderColor??`text`)??e.borderColor??`currentColor`}`),e.shadow&&(n[`box-shadow`]=`0 10px 30px rgb(0 0 0 / 0.18)`),typeof e.opacity==`number`&&e.opacity<1&&(n.opacity=String(e.opacity)),typeof e.z==`number`&&(n[`z-index`]=String(Math.round(e.z))),(e.radius||e.border)&&(n.overflow=`hidden`),n}var hv=e=>Math.round(e*160*100)/100,gv=e=>`${/^[\w -]+$/.test(e)&&!/^(system-ui|sans-serif|serif|monospace)$/.test(e)?`"${e}"`:e}, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif`,_v=/^@(font-face|import|charset|keyframes|-webkit-keyframes|property|namespace|layer\s*[\w.,\s]*;)/i;function vv(e){let t=[],n=0,r=0,i=null,a=e.replace(/\/\*[\s\S]*?\*\//g,``);for(let e=0;e<a.length;e++){let o=a[e];if(i){o===`\\`?e++:o===i&&(i=null);continue}o===`"`||o===`'`?i=o:o===`{`?n++:o===`}`?(n--,n===0&&(t.push(a.slice(r,e+1).trim()),r=e+1)):o===`;`&&n===0&&(t.push(a.slice(r,e+1).trim()),r=e+1)}let o=a.slice(r).trim();return o&&t.push(o),t.filter(Boolean)}var yv=e=>e.replace(/(^|[{};])([^{};@]*)(?=\{)/g,(e,t,n)=>t+n.replace(/(^|[\s,>+~(])(:root|html|body)(?=$|[\s,.:#[>+~)])/g,`$1&`));function bv(e,t=``){let n=`.deck-theme-${e.slug}`,r=Object.entries(e.colors).map(([e,t])=>`--c-${e}: ${t};`).join(` `),i=[],a=e=>vv(e).filter(e=>!_v.test(e)||(i.push(e),!1)).map(yv).join(`
406
+ `),o=a(e.css),s=a(t);return[...i,xv,`${n} { ${r} --font-heading: ${gv(e.fonts.heading)}; --font-body: ${gv(e.fonts.body)}; }`,o.trim()?`${n} {\n${o}\n}`:``,s.trim()?`${n}.deck-slide {\n${s}\n}`:``].filter(Boolean).join(`
407
+ `)}var xv=`
408
+ .deck-slide { position: relative; overflow: hidden; isolation: isolate; color: var(--c-text); font-family: var(--font-body); font-size: 28px; line-height: 1.3; text-align: left; letter-spacing: normal; -webkit-font-smoothing: antialiased; }
409
+ .deck-slide :where(*, *::before, *::after) { box-sizing: border-box; }
410
+ .deck-slide .deck-slot { position: absolute; display: flex; flex-direction: column; min-width: 0; padding: 8px 16px; overflow-wrap: break-word; }
411
+ .deck-slide .deck-slot[data-valign="middle"] { justify-content: center; }
412
+ .deck-slide .deck-slot[data-valign="bottom"] { justify-content: flex-end; }
413
+ .deck-slide .deck-content { min-height: 0; outline: none; }
414
+ .deck-slide .deck-shape { position: absolute; }
415
+ .deck-slide :where(h1, h2, h3, h4, h5, h6) { font-family: var(--font-heading); font-weight: 700; line-height: 1.1; letter-spacing: -0.015em; margin: 0; font-size: 1.15em; }
416
+ .deck-slide :where(p, ul, ol, blockquote, figure, table, pre, dl) { margin: 0; }
417
+ .deck-slide :where(p, ul, ol, table, pre, blockquote, figure, div, h1, h2, h3, h4) + :where(p, ul, ol, table, pre, blockquote, figure, h1, h2, h3, h4) { margin-top: 0.5em; }
418
+ .deck-slide :where(ul, ol) { padding-left: 1.15em; }
419
+ .deck-slide :where(ul) { list-style: disc; }
420
+ .deck-slide :where(ol) { list-style: decimal; }
421
+ .deck-slide :where(ul ul) { list-style: circle; }
422
+ .deck-slide :where(li + li) { margin-top: 0.25em; }
423
+ .deck-slide :where(li)::marker { color: var(--c-accent); }
424
+ .deck-slide :where(strong, b) { font-weight: 700; }
425
+ .deck-slide :where(em, i) { font-style: italic; }
426
+ .deck-slide :where(a) { color: var(--c-accent); text-decoration: underline; text-underline-offset: 0.12em; }
427
+ .deck-slide :where(code) { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; color: var(--c-accent); }
428
+ .deck-slide :where(pre) { font-size: 0.7em; line-height: 1.4; background: var(--c-surface); border: 1px solid var(--c-line); padding: 0.6em 0.8em; border-radius: 0.3em; white-space: pre-wrap; }
429
+ .deck-slide :where(pre code) { color: inherit; font-size: 1em; }
430
+ .deck-slide :where(blockquote) { border-left: 4px solid var(--c-accent); padding-left: 0.8em; color: var(--c-muted); }
431
+ .deck-slide :where(img, svg, video) { max-width: 100%; }
432
+ .deck-slide :where(table) { border-collapse: collapse; width: 100%; font-size: 0.95em; }
433
+ .deck-slide :where(th, td) { padding: 0.45em 0.65em; border-bottom: 1px solid var(--c-line); text-align: left; vertical-align: top; }
434
+ .deck-slide :where(th) { font-weight: 700; border-bottom: 2px solid var(--c-text); }
435
+ .deck-slide .kind-image .deck-content, .deck-slide .kind-chart .deck-content, .deck-slide .kind-embed .deck-content { flex: 1; display: flex; align-items: center; justify-content: center; }
436
+ .deck-slide .kind-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
437
+ .deck-slide .kind-image[data-fit="cover"] img { object-fit: cover; }
438
+ .deck-slide .kind-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
439
+ .deck-slide .kind-embed iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
440
+ .deck-slide .kind-image, .deck-slide .kind-chart, .deck-slide .kind-embed { padding: 0; }
441
+ .deck-slide .deck-error { color: #B91C1C; font-size: 0.6em; font-family: ui-monospace, Menlo, monospace; }
442
+ `,Sv=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Cv(e,t,n){let r=(e,t,n)=>Sv(t,e)?n:t,i={title:r(e.title,t.title,n.title),template:r(e.template,t.template,n.template),css:r(e.css,t.css,n.css),numbers:r(e.numbers,t.numbers,n.numbers)};if(Sv(e.slides,n.slides))return{draft:{...i,slides:t.slides},lost:[]};if(Sv(e.slides,t.slides))return{draft:{...i,slides:n.slides},lost:[]};let a=[];if(t.slides.length!==e.slides.length)return{draft:{...i,slides:n.slides},lost:t.slides.map((e,t)=>t+1)};let o=[...n.slides];return t.slides.forEach((t,n)=>{if(Sv(t,e.slides[n]))return;let r=o.findIndex(t=>Sv(t,e.slides[n]));r>=0?o[r]=t:a.push(n+1)}),{draft:{...i,slides:o},lost:a}}function wv(e){return ha.sanitize(e,{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ADD_ATTR:[`target`,`data-src`],FORBID_TAGS:[`script`,`iframe`,`object`,`embed`,`form`,`base`,`meta`,`link`]})}var Tv=e=>!e||!/```|~~~|<[a-z!][^>]*>|!\[/i.test(e),Ev=e=>e.replace(/\|/g,`\\|`);function Dv(e){let t=``;for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t+=(n.textContent??``).replace(/ /g,` `);continue}if(!(n instanceof HTMLElement))continue;let e=n.tagName;if(e===`UL`||e===`OL`)continue;let r=Dv(n),i=e=>{let t=/^(\s*)([\s\S]*?)(\s*)$/.exec(r);return t[2]?`${t[1]}${e}${t[2]}${e}${t[3]}`:r};e===`BR`?t+=`
443
+ `:e===`B`||e===`STRONG`||e===`SPAN`&&/bold|[6-9]00/.test(n.style.fontWeight)?t+=i(`**`):e===`I`||e===`EM`||e===`SPAN`&&n.style.fontStyle===`italic`?t+=i(`*`):e===`CODE`?t+=i("`"):e===`A`&&n.getAttribute(`href`)?t+=`[${r}](${n.getAttribute(`href`)})`:t+=e===`IMG`?`![${n.getAttribute(`alt`)??``}](${n.getAttribute(`data-src`)??n.getAttribute(`src`)??``})`:r}return t}function Ov(e,t){let n=[],r=0;for(let i of Array.from(e.children)){if(i.tagName!==`LI`)continue;r++;let a=Dv(i).replace(/\s*\n\s*/g,` `).trim();n.push(`${` `.repeat(t)}${e.tagName===`OL`?`${r}.`:`-`} ${a}`);for(let e of Array.from(i.children))(e.tagName===`UL`||e.tagName===`OL`)&&n.push(...Ov(e,t+1))}return n}function kv(e){let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.children).map(e=>Ev(Dv(e).replace(/\s*\n\s*/g,` `).trim())));if(!t.length)return``;let n=Math.max(...t.map(e=>e.length)),[r,...i]=t.map(e=>[...e,...Array(n-e.length).fill(``)]);return[`| ${r.join(` | `)} |`,`|${Array(n).fill(`---`).join(`|`)}|`,...i.map(e=>`| ${e.join(` | `)} |`)].join(`
444
+ `)}function Av(e,t){if(t)return Dv(e).replace(/\s*\n\s*/g,` `).trim();let n=[],r=``,i=()=>{r.trim()&&n.push(r.trim()),r=``};for(let t of Array.from(e.childNodes))if(t instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|TABLE|BLOCKQUOTE)$/.test(t.tagName)){if(i(),t.tagName===`UL`||t.tagName===`OL`)n.push(Ov(t,0).join(`
445
+ `));else if(t.tagName===`TABLE`)n.push(kv(t));else if(t.tagName===`BLOCKQUOTE`)n.push(`> ${Dv(t).trim().replace(/\n/g,`
446
+ > `)}`);else{let e=Array.from(t.children).filter(e=>e.tagName===`UL`||e.tagName===`OL`||e.tagName===`TABLE`),r=Dv(t).trim();r&&n.push(/^H[1-6]$/.test(t.tagName)?`${`#`.repeat(Number(t.tagName[1]))} ${r.replace(/\n/g,` `)}`:r);for(let t of e)n.push(t.tagName===`TABLE`?kv(t):Ov(t,0).join(`
447
+ `))}}else t.nodeType===Node.TEXT_NODE?r+=(t.textContent??``).replace(/ /g,` `):t instanceof HTMLElement&&(r+=t.tagName===`BR`?`
448
+ `:Dv(Object.assign(document.createElement(`span`),{innerHTML:t.outerHTML})));return i(),n.filter(Boolean).join(`
449
+
450
+ `)}var jv=e=>Math.round(e*100)/100;function Mv(e,t){let n=e.map(e=>`${e.slug}:${e.css.length}`).join(`|`)+`|${t??``}`;(0,v.useEffect)(()=>{let n=e.map((e,n)=>{let r=document.createElement(`style`);return r.dataset.deckTheme=e.slug,r.textContent=bv({...e,css:e.css.replaceAll(`{{base}}`,A.baseUrl)},n===0?t??``:``),document.head.appendChild(r),r});return()=>n.forEach(e=>e.remove())},[n])}var Nv=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),t]));function Pv({view:e,theme:t,width:n,thumb:r,number:i,editor:a,children:o}){let s=n/H_,c=lv(t.size),l=e.numbered?i:void 0;return(0,I.jsxs)(`div`,{className:`relative overflow-hidden`,style:{width:n,height:c*s},children:[(0,I.jsxs)(`div`,{className:`deck-slide deck-theme-${t.slug} layout-${e.layout}`,"data-n":l?.n,"data-nn":l?String(l.n).padStart(2,`0`):void 0,"data-of":l?.of,style:{position:`absolute`,left:0,top:0,width:H_,height:c,background:e.background,transform:`scale(${s})`,transformOrigin:`0 0`},onPointerDown:a?e=>e.target===e.currentTarget&&a.onBackgroundPointerDown(e):void 0,children:[e.shapes.map((e,t)=>(0,I.jsx)(`div`,{className:`deck-shape`,style:{left:e.x*160,top:e.y*160,width:e.w*160,height:e.h*160,background:e.fill},onPointerDown:a?e=>a.onBackgroundPointerDown(e):void 0},t)),e.slots.map(e=>{let n=a?.live[e.name],i=n?{...e,...n}:e,o=!e.html&&!e.embed;if(o&&!a)return null;let s=a?.editing===e.name;return(0,I.jsx)(`div`,{"data-slot":e.name,"data-valign":e.valign,"data-fit":e.fit,className:P(`deck-slot`,`kind-${e.kind}`,`slot-${e.name}`,e.class,a&&!s&&`cursor-move`),style:Nv(mv(i,t)),onPointerDown:a&&!s?t=>a.onSlotPointerDown(t,e):void 0,onDoubleClick:a&&!s?()=>a.onSlotDoubleClick(e):void 0,onContextMenu:a?t=>a.onSlotContextMenu(t,e):void 0,children:s&&a?a.richEditor(e):o?(0,I.jsx)(`div`,{className:`deck-content`,style:{opacity:.38,fontStyle:`italic`,fontWeight:400},children:e.kind===`image`?`Picture — double click to choose one`:e.kind===`chart`?`Chart — double click for its data`:e.kind===`html`?`HTML — double click`:e.kind===`embed`?`Embed — a URL or a page`:e.placeholder?.split(`
451
+ `)[0]??e.name}):e.embed?r?(0,I.jsx)(`div`,{className:`deck-content`,style:{background:`#eee`,color:`#999`,fontSize:24},children:`embed`}):(0,I.jsx)(`div`,{className:`deck-content`,children:(0,I.jsx)(`iframe`,{title:e.name,...e.embed.src?{src:e.embed.src}:{srcDoc:e.embed.srcdoc},sandbox:`allow-scripts allow-popups allow-forms`,style:a?{pointerEvents:`none`}:void 0})}):(0,I.jsx)(`div`,{className:`deck-content`,dangerouslySetInnerHTML:{__html:wv(e.html)}})},e.name)})]}),o]})}function Fv(e,t,n){return(0,v.useMemo)(()=>e&&t?pv(e,t,{asset:n}):null,[e,t,n])}function Iv({slide:e,theme:t,asset:n,width:r,number:i}){let a=Fv(e,t,n);return a?(0,I.jsx)(`div`,{"aria-hidden":!0,inert:!0,children:(0,I.jsx)(Pv,{view:a,theme:t,width:r,thumb:!0,number:i})}):null}var Lv=e=>{let t=e.extra?.slots;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}};function Rv(e,t){let n={...Lv(e)};for(let[e,r]of Object.entries(t))if(r===null)delete n[e];else{let t={...n[e]??{},...r};for(let[e,n]of Object.entries(t))n===void 0&&delete t[e];n[e]=t}let r={...e.extra};return Object.keys(n).length?r.slots=n:delete r.slots,{extra:r}}var zv=(e,t)=>e.layouts[t]?G_(e.layouts[t]):void 0,Bv=e=>e.kind===`html`||e.kind===`embed`||e.kind===`chart`||e.kind===`image`||(e.kind===`markdown`||e.kind===`table`)&&!Tv(e.md),Vv=[`Helvetica Neue`,`Arial`,`Avenir Next`,`Futura`,`Georgia`,`Times New Roman`,`Verdana`,`Trebuchet MS`,`Courier New`],Hv=[{icon:`compress`,label:`Shorten`,text:`Shorten it to the essentials; keep the meaning and the facts.`},{icon:`edit_note`,label:`Rewrite clearer`,text:`Rewrite it to be clearer and more direct, same length or shorter.`},{icon:`format_list_bulleted`,label:`Make it bullet points`,text:`Turn it into three to five short bullet points.`},{icon:`bar_chart`,label:`Make it a chart`,text:`Show its numbers as a chart (a chart block) or, without numbers, as one of the theme's pieces (cards, kpis, flow, timeline).`},{icon:`translate`,label:`Translate to English`,text:`Translate it to English.`},{icon:`translate`,label:`Translate to German`,text:`Translate it to German (Swiss spelling, ss not ß).`},{icon:`record_voice_over`,label:`Write speaker notes`,text:"Write speaker notes for this slide (`???` notes): what to say about this box in two or three sentences."}];function Uv({label:e,onClose:t,className:n,style:r,children:i}){let a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&!e.target.closest?.(`[aria-haspopup]`)&&t()},n=e=>e.key===`Escape`&&t();return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,n)}},[t]),(0,I.jsx)(`div`,{ref:a,role:`menu`,"aria-label":e,className:P(`z-50 max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface p-1 shadow-[var(--elev-pop)]`,n),style:r,children:i})}function Wv({icon:e,title:t,sub:n,keys:r,danger:i,disabled:a,onClick:o}){return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:a,className:P(`flex w-full items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-surface-2 disabled:opacity-40`,i&&`text-bad`),onClick:o,children:[e&&(0,I.jsx)(L,{name:e,className:`ms-sm mt-0.5 text-fg-2`}),(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm`,children:t}),n&&(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:n})]}),r&&(0,I.jsx)(`span`,{className:`pt-0.5 text-xs text-fg-2`,children:r})]})}var Gv=()=>(0,I.jsx)(`div`,{className:`my-1 border-t border-line`});function Kv(e){let{view:t,theme:n,slide:r,selected:i,editing:a}=e,o=(0,v.useRef)(null),[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=lv(n.size),x=H_/160,S=b/160;(0,v.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{let t=Math.min(e.clientWidth-18,Math.max(260,window.innerHeight-250)*H_/b);c(n=>n&&Math.abs(n-t)<20&&t<n+20?Math.min(n,e.clientWidth):t)},n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),t(),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[b]);let C=e.zoom?H_*e.zoom:s;(0,v.useEffect)(()=>e.onWidth?.(Math.min(C,s||C)),[C,s]);let w=C/H_*160,T=t.slots.filter(e=>i.includes(e.name)),E=T.length===1?T[0]:null,D=e=>!!(e.html||e.embed),O=(n,r,a)=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),y(null),document.activeElement?.blur();let o=i;if(a===`move`){if(n.shiftKey||n.metaKey){e.onSelect(i.includes(r.name)?i.filter(e=>e!==r.name):[...i,r.name]);return}i.includes(r.name)||(o=[r.name],e.onSelect(o))}let s=t.slots.filter(e=>a===`move`?o.includes(e.name):e.name===r.name),c=Object.fromEntries(s.map(e=>[e.name,{x:e.x,y:e.y,w:e.w,h:e.h,rotate:e.rotate??0}])),l=n.clientX,d=n.clientY,p=t.slots.filter(e=>!o.includes(e.name)&&D(e)),m=[0,x/2,x,...p.flatMap(e=>[e.x,e.x+e.w/2,e.x+e.w])],h=[0,S/2,S,...p.flatMap(e=>[e.y,e.y+e.h/2,e.y+e.h])],g=6/w,_=(e,t)=>{let n=null;for(let r of e)for(let e of t)Math.abs(e-r)<=g&&(!n||Math.abs(e-r)<Math.abs(n.delta))&&(n={delta:e-r,at:e});return n},v=n.currentTarget.closest(`[data-stage]`)?.getBoundingClientRect(),b=null,C=e=>{let t=(e.clientX-l)/w,n=(e.clientY-d)/w;if(!b&&Math.abs(e.clientX-l)<3&&Math.abs(e.clientY-d)<3)return;let i=[],o={};if(a===`move`){let a=c[r.name]??Object.values(c)[0],s=t,l=n;if(!e.altKey){let e={x:a.x+t,y:a.y+n,w:a.w,h:a.h},r=_([e.x,e.x+e.w/2,e.x+e.w],m),o=_([e.y,e.y+e.h/2,e.y+e.h],h);r&&(s+=r.delta,i.push({axis:`x`,at:r.at})),o&&(l+=o.delta,i.push({axis:`y`,at:o.at}))}for(let[e,t]of Object.entries(c))o[e]={x:jv(t.x+s),y:jv(t.y+l),w:t.w,h:t.h}}else if(a===`rotate`){let t=c[r.name];if(!v)return;let n=v.left+(t.x+t.w/2)*w,i=v.top+(t.y+t.h/2)*w,a=(e,t)=>Math.atan2(t-i,e-n)*180/Math.PI,s=(t.rotate??0)+a(e.clientX,e.clientY)-a(l,d);if(!e.altKey){let e=Math.round(s/15)*15;Math.abs(e-s)<4&&(s=e)}s=(Math.round(s)%360+360)%360,o[r.name]={...t,rotate:s>180?s-360:s}}else{let s=c[r.name],l={...s};if(a.includes(`e`)&&(l.w=Math.max(.2,s.w+t)),a.includes(`s`)&&(l.h=Math.max(.15,s.h+n)),a.includes(`w`)&&(l.w=Math.max(.2,s.w-t),l.x=s.x+s.w-l.w),a.includes(`n`)&&(l.h=Math.max(.15,s.h-n),l.y=s.y+s.h-l.h),e.shiftKey&&s.h>0){let e=s.w/s.h;l.w/l.h>e?l.w=l.h*e:l.h=l.w/e,a.includes(`w`)&&(l.x=s.x+s.w-l.w),a.includes(`n`)&&(l.y=s.y+s.h-l.h)}if(!e.altKey){let e=_([a.includes(`e`)?l.x+l.w:l.x],m);e&&(a.includes(`e`)?l.w+=e.delta:(l.x+=e.delta,l.w-=e.delta),i.push({axis:`x`,at:e.at}));let t=_([a.includes(`s`)?l.y+l.h:l.y],h);t&&(a.includes(`s`)?l.h+=t.delta:(l.y+=t.delta,l.h-=t.delta),i.push({axis:`y`,at:t.at}))}o[r.name]={x:jv(l.x),y:jv(l.y),w:jv(l.w),h:jv(l.h)}}b=o,u(o),f(i)},T=()=>{if(window.removeEventListener(`pointermove`,C),window.removeEventListener(`pointerup`,T),f([]),!b&&a===`move`&&o.length>1&&e.onSelect([r.name]),b){let t={};for(let[e,n]of Object.entries(b))t[e]=a===`rotate`?{rotate:n.rotate||void 0}:{x:n.x,y:n.y,w:n.w,h:n.h};e.onPatches(t)}u({})};window.addEventListener(`pointermove`,C),window.addEventListener(`pointerup`,T)},k=n=>{if(n.button!==0)return;y(null),document.activeElement?.blur();let r=n.currentTarget.closest(`[data-stage]`)?.getBoundingClientRect();if(!r)return;let a=e=>({x:(e.clientX-r.left)/w,y:(e.clientY-r.top)/w}),o=a(n),s=n.shiftKey||n.metaKey?i:[],c=!1,l=n=>{let r=a(n);if(!c&&Math.abs(r.x-o.x)*w<4&&Math.abs(r.y-o.y)*w<4)return;c=!0;let i={x:Math.min(o.x,r.x),y:Math.min(o.y,r.y),w:Math.abs(r.x-o.x),h:Math.abs(r.y-o.y)};m(i);let l=t.slots.filter(e=>e.x<i.x+i.w&&e.x+e.w>i.x&&e.y<i.y+i.h&&e.y+e.h>i.y&&(D(e)||e.own)).map(e=>e.name);e.onSelect([...new Set([...s,...l])])},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),m(null),c||e.onSelect(s)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},A=t=>{e.onSelect([t.name]),Bv(t)?e.onSource(t.name):e.onEditing(t.name)};(0,v.useEffect)(()=>{let n=n=>{let r=n.target;if(r&&(r.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(r.tagName))||a)return;let o=n.metaKey||n.ctrlKey;if(o&&n.key.toLowerCase()===`a`){n.preventDefault(),e.onSelect(t.slots.filter(e=>D(e)||e.own).map(e=>e.name));return}if(o&&n.key.toLowerCase()===`v`&&e.canPaste){n.preventDefault(),e.onPaste();return}if(!T.length)return;let s=n.shiftKey?.25:.05;if(n.key===`Escape`)e.onSelect([]);else if(n.key===`Enter`&&E)n.preventDefault(),A(E);else if(n.key===`Delete`||n.key===`Backspace`)n.preventDefault(),e.onRemove(T.map(e=>e.name));else if(o&&n.key.toLowerCase()===`d`)n.preventDefault(),e.onDuplicate(T.map(e=>e.name));else if(o&&n.key.toLowerCase()===`c`)n.preventDefault(),e.onCopy(T.map(e=>e.name));else if(o&&n.key.toLowerCase()===`x`)n.preventDefault(),e.onCopy(T.map(e=>e.name)),e.onRemove(T.map(e=>e.name));else if(n.key.startsWith(`Arrow`)){n.preventDefault();let t=n.key===`ArrowLeft`?-s:n.key===`ArrowRight`?s:0,r=n.key===`ArrowUp`?-s:n.key===`ArrowDown`?s:0;e.onPatches(Object.fromEntries(T.map(e=>[e.name,{x:jv(e.x+t),y:jv(e.y+r)}])),`nudge:${i.join(`,`)}`)}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)});let j=n=>{let r=t.slots.map((e,t)=>e.z??t),i=Math.max(...r),a=Math.min(...r);e.onPatches(Object.fromEntries(T.map(e=>{let r=e.z??t.slots.indexOf(e);return[e.name,{z:n===`front`?i+1:n===`back`?a-1:n===`forward`?r+1:r-1}]})))},ee=t=>{let n=T.length>1?T:[{x:0,y:0,w:x,h:S}],r=Math.min(...n.map(e=>e.x)),i=Math.max(...n.map(e=>e.x+e.w)),a=Math.min(...n.map(e=>e.y)),o=Math.max(...n.map(e=>e.y+e.h));e.onPatches(Object.fromEntries(T.map(e=>[e.name,t===`left`?{x:jv(r)}:t===`right`?{x:jv(i-e.w)}:t===`center`?{x:jv((r+i)/2-e.w/2)}:t===`top`?{y:jv(a)}:t===`bottom`?{y:jv(o-e.h)}:{y:jv((a+o)/2-e.h/2)}])))},M=e=>({...e,...l[e.name]??{}}),N=E?M(E):null,F=T.length>1?{x:Math.min(...T.map(e=>M(e).x)),y:Math.min(...T.map(e=>M(e).y)),w:0,h:0}:null;return(0,I.jsx)(`div`,{ref:o,className:P(`relative w-full`,e.zoom&&`overflow-auto`,h&&`outline-dashed outline-2 outline-accent`),style:e.zoom?{maxHeight:`calc(100vh - 230px)`}:void 0,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),g(!0))},onDragLeave:()=>g(!1),onDrop:t=>{let n=[...t.dataTransfer.files].find(e=>/^image\/(png|jpe?g|gif)$/.test(e.type));g(!1),n&&(t.preventDefault(),e.onDropFile(n))},children:(0,I.jsxs)(`div`,{className:`relative mx-auto my-6 rounded-md shadow-[0_2px_18px_rgb(0_0_0/0.22)]`,style:{width:C},role:`group`,"aria-label":`slide`,"data-stage":!0,children:[C>0&&(0,I.jsxs)(Pv,{view:t,theme:n,width:C,number:e.number,editor:{live:l,editing:a,onSlotPointerDown:(e,t)=>O(e,t,`move`),onSlotDoubleClick:A,onSlotContextMenu:(t,n)=>{t.preventDefault(),i.includes(n.name)||e.onSelect([n.name]);let r=t.currentTarget.closest(`[data-stage]`).getBoundingClientRect();y({x:t.clientX-r.left,y:t.clientY-r.top,slot:n.name})},onBackgroundPointerDown:k,richEditor:t=>(0,I.jsx)(Yv,{s:t,onCommit:n=>{n!==(t.md??``)&&e.onText(t.name,n),e.onEditing(null)},onCancel:()=>e.onEditing(null)},t.name)},children:[t.slots.map(e=>{let t=M(e),n=i.includes(e.name);return(0,I.jsx)(`div`,{"aria-hidden":!0,className:P(`pointer-events-none absolute rounded-[2px]`,n?`outline outline-2 outline-accent`:``),style:{left:t.x*w,top:t.y*w,width:t.w*w,height:t.h*w,transform:t.rotate?`rotate(${t.rotate}deg)`:void 0},"data-frame":e.name},e.name)}),d.map((e,t)=>e.axis===`x`?(0,I.jsx)(`div`,{className:`pointer-events-none absolute top-0 h-full w-px bg-[#ec4899]`,style:{left:e.at*w}},t):(0,I.jsx)(`div`,{className:`pointer-events-none absolute left-0 h-px w-full bg-[#ec4899]`,style:{top:e.at*w}},t)),Object.entries(e.pins??{}).map(([n,r])=>{let i=t.slots.find(e=>e.name===n),a=i?(i.x+i.w)*w-10:C-30,o=i?i.y*w-10:8;return(0,I.jsx)(`button`,{type:`button`,"aria-label":`${r} comment${r===1?``:`s`}${n?` on ${n}`:` on this slide`}`,className:`absolute z-20 grid h-5 min-w-5 place-items-center rounded-full rounded-bl-none bg-[#f59e0b] px-1 text-[11px] font-semibold text-black shadow`,style:{left:a,top:o},onPointerDown:e=>e.stopPropagation(),onClick:()=>e.onComments?.(n||void 0),children:r},`pin:${n}`)}),(e.others??[]).map(e=>{let n=t.slots.find(t=>t.name===e.slot);return n?(0,I.jsx)(`div`,{role:`note`,"aria-label":`${e.who} is on ${e.slot}`,className:`pointer-events-none absolute z-10 rounded-[2px]`,style:{left:n.x*w,top:n.y*w,width:n.w*w,height:n.h*w,outline:`2px solid ${e.color}`,transform:n.rotate?`rotate(${n.rotate}deg)`:void 0},children:(0,I.jsx)(`span`,{className:`absolute -top-[18px] right-0 whitespace-nowrap rounded-t px-1.5 text-[11px] font-semibold leading-[18px] text-white`,style:{background:e.color},children:e.who})},`other:${e.who}:${e.slot}`):null}),p&&(0,I.jsx)(`div`,{className:`pointer-events-none absolute border border-accent bg-accent/10`,style:{left:p.x*w,top:p.y*w,width:p.w*w,height:p.h*w}}),E&&N&&a!==E.name&&(0,I.jsxs)(I.Fragment,{children:[[`nw`,`ne`,`sw`,`se`].map(e=>(0,I.jsx)(`span`,{role:`presentation`,"aria-label":`resize ${E.name} ${e}`,className:P(`absolute size-2.5 rounded-full border-2 border-accent bg-white`,e===`nw`||e===`se`?`cursor-nwse-resize`:`cursor-nesw-resize`),style:{left:(e.includes(`w`)?N.x:N.x+N.w)*w-5,top:(e.includes(`n`)?N.y:N.y+N.h)*w-5},onPointerDown:t=>O(t,E,e)},e)),(0,I.jsx)(`span`,{role:`presentation`,"aria-label":`rotate ${E.name}`,title:`rotate (snaps to 15°; ⌥ for free)`,className:`absolute grid size-4 cursor-grab place-items-center rounded-full border-2 border-accent bg-white`,style:{left:(N.x+N.w/2)*w-8,top:(N.y+N.h)*w+10},onPointerDown:e=>O(e,E,`rotate`),children:(0,I.jsx)(L,{name:`rotate_right`,className:`text-[11px] leading-none text-accent`})})]})]}),E&&N&&!Object.keys(l).length&&!_&&(0,I.jsx)(Jv,{s:E,editing:a===E.name,theme:n,style:{left:Math.max(0,Math.min(N.x*w,C-640)),top:N.y*w-42},onPatch:t=>e.onPatches({[E.name]:t}),onReset:E.changed?()=>e.onPatches({[E.name]:null}):void 0,onEdit:()=>A(E),onRemove:()=>e.onRemove([E.name]),onDuplicate:()=>e.onDuplicate([E.name]),onAsk:t=>e.onAsk(E.name,t),onFormat:e.onFormat}),T.length>1&&F&&!Object.keys(l).length&&!_&&(0,I.jsxs)(`div`,{role:`toolbar`,"aria-label":`selection`,className:`absolute z-30 flex items-center gap-0.5 rounded-lg border border-line bg-surface px-1 py-0.5 text-xs shadow-[var(--elev-pop)]`,style:{left:Math.max(0,F.x*w),top:F.y*w-42},onPointerDown:e=>e.stopPropagation(),children:[(0,I.jsxs)(`span`,{className:`px-1.5 font-semibold`,children:[T.length,` boxes`]}),[`left`,`center`,`right`,`top`,`middle`,`bottom`].map(e=>(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`align ${e}`,title:`align ${e}`,onClick:()=>ee(e),children:(0,I.jsx)(L,{name:e===`left`?`align_horizontal_left`:e===`center`?`align_horizontal_center`:e===`right`?`align_horizontal_right`:e===`top`?`align_vertical_top`:e===`middle`?`align_vertical_center`:`align_vertical_bottom`,className:`ms-sm`})},e)),(0,I.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-line`}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`duplicate`,title:`duplicate (⌘D)`,onClick:()=>e.onDuplicate(T.map(e=>e.name)),children:(0,I.jsx)(L,{name:`content_copy`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`remove boxes`,title:`remove (Delete)`,onClick:()=>e.onRemove(T.map(e=>e.name)),children:(0,I.jsx)(L,{name:`delete`,className:`ms-sm`})})]}),_&&(0,I.jsx)(Uv,{label:`box`,onClose:()=>y(null),className:`absolute w-[240px]`,style:{left:Math.min(_.x,C-240),top:Math.max(0,Math.min(_.y,b/1600*C-360))},children:(()=>{let t=T.map(e=>e.name),n=e=>()=>{e(),y(null)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Wv,{icon:`content_copy`,title:`Copy`,keys:`⌘C`,onClick:n(()=>e.onCopy(t))}),(0,I.jsx)(Wv,{icon:`content_paste`,title:`Paste`,keys:`⌘V`,disabled:!e.canPaste,onClick:n(e.onPaste)}),(0,I.jsx)(Wv,{icon:`library_add`,title:`Duplicate`,keys:`⌘D`,onClick:n(()=>e.onDuplicate(t))}),(0,I.jsx)(Gv,{}),(0,I.jsx)(Wv,{icon:`flip_to_front`,title:`Bring to front`,onClick:n(()=>j(`front`))}),(0,I.jsx)(Wv,{icon:`arrow_upward`,title:`Bring forward`,onClick:n(()=>j(`forward`))}),(0,I.jsx)(Wv,{icon:`arrow_downward`,title:`Send backward`,onClick:n(()=>j(`backward`))}),(0,I.jsx)(Wv,{icon:`flip_to_back`,title:`Send to back`,onClick:n(()=>j(`back`))}),(0,I.jsx)(Gv,{}),(0,I.jsx)(Wv,{icon:`auto_awesome`,title:`Ask an agent about this…`,onClick:n(()=>e.onAsk(_.slot))}),e.onComments&&(0,I.jsx)(Wv,{icon:`add_comment`,title:`Comment…`,onClick:n(()=>e.onComments(_.slot))}),(0,I.jsx)(Wv,{icon:`tune`,title:`Format…`,onClick:n(e.onFormat)}),(0,I.jsx)(Gv,{}),(0,I.jsx)(Wv,{icon:`delete`,title:`Delete`,keys:`⌫`,danger:!0,onClick:n(()=>e.onRemove(t))})]})})()})]})})}var qv=`inline-grid size-7 place-items-center rounded-md text-fg-2 hover:bg-surface-2 hover:text-fg`;function Jv({s:e,editing:t,theme:n,style:r,onPatch:i,onReset:a,onEdit:o,onRemove:s,onDuplicate:c,onAsk:l,onFormat:u}){let[d,f]=(0,v.useState)(!1),p=e.kind===`text`||e.kind===`markdown`||e.kind===`table`||e.kind===`html`||e.kind===`chart`,m=`bg-accent-soft text-on-accent-soft`,h=e.size??18,g=e=>t=>{t.preventDefault(),document.execCommand(e)},_=Object.entries(n.colors).filter(([e])=>![`surface`,`line`,`onAccent`].includes(e));return(0,I.jsxs)(`div`,{role:`toolbar`,"aria-label":`${e.name} format`,className:`absolute z-30 flex items-center gap-0.5 whitespace-nowrap rounded-lg border border-line bg-surface px-1 py-0.5 text-xs text-fg shadow-[var(--elev-pop)]`,style:r,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>t&&e.preventDefault(),children:[(0,I.jsxs)(`span`,{className:`relative`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center gap-1 rounded-md px-1.5 text-fg-2 hover:bg-surface-2 hover:text-fg`,title:`ask an agent to change this box`,"aria-label":`ask an agent about this box`,"aria-haspopup":`menu`,"aria-expanded":d,onClick:()=>f(e=>!e),children:[(0,I.jsx)(L,{name:`auto_awesome`,className:`ms-sm`}),(0,I.jsx)(`span`,{children:`ask`}),(0,I.jsx)(L,{name:`expand_more`,className:`ms-sm`})]}),d&&(0,I.jsxs)(Uv,{label:`ask an agent`,onClose:()=>f(!1),className:`absolute left-0 top-[calc(100%+4px)] w-[240px]`,children:[Hv.map(e=>(0,I.jsx)(Wv,{icon:e.icon,title:e.label,onClick:()=>(f(!1),l(e.text))},e.label)),(0,I.jsx)(Gv,{}),(0,I.jsx)(Wv,{icon:`chat`,title:`Something else…`,onClick:()=>(f(!1),l())})]})]}),(0,I.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-line`}),t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`bold`,title:`bold (⌘B)`,onMouseDown:g(`bold`),children:(0,I.jsx)(L,{name:`format_bold`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`italic`,title:`italic (⌘I)`,onMouseDown:g(`italic`),children:(0,I.jsx)(L,{name:`format_italic`,className:`ms-sm`})}),e.kind!==`text`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`bulleted list`,title:`bulleted list`,onMouseDown:g(`insertUnorderedList`),children:(0,I.jsx)(L,{name:`format_list_bulleted`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`numbered list`,title:`numbered list`,onMouseDown:g(`insertOrderedList`),children:(0,I.jsx)(L,{name:`format_list_numbered`,className:`ms-sm`})})]}),(0,I.jsx)(`span`,{className:`px-1 text-fg-2`,children:`⌘↩ done · esc drop`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:qv,title:e.kind===`image`?`choose a picture`:Bv(e)?`edit the source`:`edit the text (double click)`,"aria-label":`edit`,onClick:o,children:(0,I.jsx)(L,{name:e.kind===`image`?`image`:Bv(e)?`code`:`edit`,className:`ms-sm`})}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`select`,{"aria-label":`font`,className:`h-7 max-w-[118px] cursor-pointer rounded-md border-0 bg-transparent px-1 text-xs text-fg outline-none hover:bg-surface-2`,value:e.font??`body`,onChange:e=>i({font:e.target.value===`body`?void 0:e.target.value}),children:[(0,I.jsxs)(`option`,{value:`body`,children:[n.fonts.body,` (body)`]}),(0,I.jsxs)(`option`,{value:`heading`,children:[n.fonts.heading,` (heading)`]}),Vv.filter(e=>e!==n.fonts.body&&e!==n.fonts.heading).map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`smaller`,title:`smaller`,onClick:()=>i({size:Math.max(6,h-(h>24?4:1))}),children:(0,I.jsx)(L,{name:`text_decrease`,className:`ms-sm`})}),(0,I.jsxs)(`span`,{className:`min-w-[2.6rem] text-center tabular-nums`,"aria-label":`font size`,children:[h,` pt`]}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`larger`,title:`larger`,onClick:()=>i({size:Math.min(160,h+(h>=24?4:1))}),children:(0,I.jsx)(L,{name:`text_increase`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(qv,e.bold&&m),"aria-label":`bold`,"aria-pressed":!!e.bold,title:`bold`,onClick:()=>i({bold:!e.bold}),children:(0,I.jsx)(L,{name:`format_bold`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(qv,e.italic&&m),"aria-label":`italic`,"aria-pressed":!!e.italic,title:`italic`,onClick:()=>i({italic:!e.italic}),children:(0,I.jsx)(L,{name:`format_italic`,className:`ms-sm`})}),[`left`,`center`,`right`].map(t=>(0,I.jsx)(`button`,{type:`button`,className:P(qv,(e.align??`left`)===t&&m),"aria-label":`align ${t}`,"aria-pressed":(e.align??`left`)===t,title:`align ${t}`,onClick:()=>i({align:t}),children:(0,I.jsx)(L,{name:`format_align_${t}`,className:`ms-sm`})},t)),(0,I.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-line`}),_.slice(0,5).map(([t,n])=>(0,I.jsx)(`button`,{type:`button`,"aria-label":`color ${t}`,title:t,"aria-pressed":(e.color??`text`)===t,className:P(`mx-0.5 size-4 rounded-full border`,(e.color??`text`)===t?`border-accent ring-2 ring-accent/40`:`border-line-strong`),style:{background:n},onClick:()=>i({color:t})},t))]}),(0,I.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-line`}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`format`,title:`everything about this box`,onClick:u,children:(0,I.jsx)(L,{name:`tune`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`duplicate`,title:`duplicate (⌘D)`,onClick:c,children:(0,I.jsx)(L,{name:`content_copy`,className:`ms-sm`})}),a&&(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`back to the layout`,title:`back to the layout's position and look`,onClick:a,children:(0,I.jsx)(L,{name:`restart_alt`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":e.own?`remove box`:`clear`,title:e.own?`remove this box (Delete)`:`clear this slot (Delete)`,onClick:s,children:(0,I.jsx)(L,{name:`delete`,className:`ms-sm`})})]})]})}function Yv({s:e,onCommit:t,onCancel:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(!1),a=e.kind===`text`;(0,v.useLayoutEffect)(()=>{let t=r.current;if(!t)return;t.innerHTML=e.html?wv(e.html):a?``:`<p><br></p>`,t.focus();let n=document.createRange();n.selectNodeContents(t),n.collapse(!1);let i=window.getSelection();i?.removeAllRanges(),i?.addRange(n)},[]);let o=e=>{i.current||(i.current=!0,e&&r.current?t(Av(r.current,a)):n())};return(0,I.jsx)(`div`,{ref:r,role:`textbox`,"aria-label":`${e.name} on the slide`,"aria-multiline":!a,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!0,className:`deck-content cursor-text select-text`,style:{outline:`none`,minHeight:`1.2em`},onPointerDown:e=>e.stopPropagation(),onBlur:()=>o(!0),onPaste:e=>{e.preventDefault(),document.execCommand(`insertText`,!1,e.clipboardData.getData(`text/plain`))},onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?(e.preventDefault(),o(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey||a)&&(e.preventDefault(),o(!0))}})}var Xv=e=>e.trim()===``||Number.isNaN(Number(e))?void 0:Number(e);function Zv({label:e,value:t,step:n=.05,min:r,max:i,onChange:a}){let[o,s]=(0,v.useState)(t===void 0?``:String(t));return(0,v.useEffect)(()=>s(t===void 0?``:String(t)),[t]),(0,I.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-1 rounded-md border border-line bg-bg px-1.5`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-fg-2`,children:e}),(0,I.jsx)(`input`,{"aria-label":e,type:`number`,value:o,step:n,min:r,max:i,className:`h-7 w-full min-w-0 border-0 bg-transparent text-xs tabular-nums text-fg outline-none`,onChange:e=>{s(e.target.value);let t=Xv(e.target.value);(t!==void 0||e.target.value===``)&&a(t)}})]})}function Qv({label:e,theme:t,value:n,allowNone:r,onChange:i}){let a=n&&/^#/.test(n)?n:void 0;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,role:`group`,"aria-label":e,children:[r&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`${e} none`,title:`none`,"aria-pressed":!n,className:P(`grid size-5 place-items-center rounded-full border text-fg-2`,n?`border-line-strong`:`border-accent ring-2 ring-accent/40`),onClick:()=>i(void 0),children:(0,I.jsx)(L,{name:`block`,className:`text-[13px]`})}),Object.entries(t.colors).map(([t,r])=>(0,I.jsx)(`button`,{type:`button`,"aria-label":`${e} ${t}`,title:t,"aria-pressed":n===t,className:P(`size-5 rounded-full border`,n===t?`border-accent ring-2 ring-accent/40`:`border-line-strong`),style:{background:r},onClick:()=>i(t)},t)),(0,I.jsx)(`label`,{className:P(`relative grid size-5 cursor-pointer place-items-center overflow-hidden rounded-full border`,a?`border-accent ring-2 ring-accent/40`:`border-line-strong`),title:`custom color`,style:{background:a??`conic-gradient(red, yellow, lime, aqua, blue, magenta, red)`},children:(0,I.jsx)(`input`,{type:`color`,"aria-label":`${e} custom`,className:`absolute inset-0 cursor-pointer opacity-0`,value:a??`#888888`,onChange:e=>i(e.target.value.toUpperCase())})})]})}var $v=({title:e,children:t})=>(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-line pt-2.5 first:border-t-0 first:pt-0`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wider text-fg-2`,children:e}),t]});function ey({theme:e,slide:t,view:n,selected:r,assets:i,onPatches:a,onSlide:o,numbers:s,onNumbers:c,onUpload:l,onClose:u}){let d=n.slots.filter(e=>r.includes(e.name)),f=d.length===1?d[0]:null,p=(e,t)=>a(Object.fromEntries(d.map(t=>[t.name,e])),t),m=H_/160,h=lv(e.size)/160,g=`inline-grid h-7 min-w-7 place-items-center rounded-md border border-line px-1 text-fg-2 hover:bg-surface-2 hover:text-fg`,_=`border-accent bg-accent-soft text-on-accent-soft`,y=(0,v.useRef)(null),b=!!t.background&&/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(t.background);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 text-sm`,role:`region`,"aria-label":`format`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(L,{name:`tune`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`font-semibold`,children:f?f.name:d.length>1?`${d.length} boxes`:`Slide`}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`close format`,onClick:u,children:(0,I.jsx)(L,{name:`close`,className:`ms-sm`})})]}),d.length===0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)($v,{title:`Background`,children:[(0,I.jsx)(Qv,{label:`background`,theme:e,value:b?void 0:t.background,allowNone:!0,onChange:e=>o({background:e})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,I.jsxs)(`select`,{"aria-label":`background picture`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1 text-xs text-fg`,value:b?t.background:``,onChange:e=>o({background:e.target.value||void 0}),children:[(0,I.jsx)(`option`,{value:``,children:`no picture`}),i.map(e=>(0,I.jsx)(`option`,{value:e,children:e.replace(/^assets\//,``)},e))]}),(0,I.jsx)(`button`,{type:`button`,className:g,title:`upload a picture as background`,onClick:()=>y.current?.click(),children:(0,I.jsx)(L,{name:`upload`,className:`ms-sm`})}),(0,I.jsx)(`input`,{ref:y,type:`file`,accept:`image/png,image/jpeg,image/gif`,className:`hidden`,"aria-label":`background picture file`,onChange:async e=>{let t=e.target.files?.[0];if(e.target.value=``,!t)return;let n=await l(t);n&&o({background:n})}})]})]}),(0,I.jsxs)($v,{title:`Slide`,children:[(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`hide slide`,checked:t.extra?.hidden===!0,onChange:e=>{let n={...t.extra};e.target.checked?n.hidden=!0:delete n.hidden,o({extra:n})}}),`hidden — kept in the deck, left out of present mode and the exports`]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`slide numbers`,checked:s,onChange:e=>c(e.target.checked)}),`slide numbers — on every slide of the deck`]}),(0,I.jsxs)(`label`,{className:P(`flex items-center gap-2 text-xs`,!s&&`opacity-50`),children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`number on this slide`,disabled:!s,checked:s&&t.extra?.number!==!1,onChange:e=>{let n={...t.extra};e.target.checked?delete n.number:n.number=!1,o({extra:n})}}),`number on this slide`]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`w-[70px] text-fg-2`,children:`transition`}),(0,I.jsxs)(`select`,{"aria-label":`transition`,className:`h-7 min-w-0 flex-1 rounded-md border border-line bg-bg px-1 text-xs text-fg`,value:t.transition??``,onChange:e=>o({transition:e.target.value||void 0}),children:[(0,I.jsx)(`option`,{value:``,children:`fade (default)`}),(0,I.jsx)(`option`,{value:`slide`,children:`slide in`}),(0,I.jsx)(`option`,{value:`zoom`,children:`zoom in`}),(0,I.jsx)(`option`,{value:`none`,children:`none (cut)`})]})]})]}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Select a box on the slide (⇧ or a frame for several) to format it.`})]}):(0,I.jsxs)(I.Fragment,{children:[f&&(0,I.jsxs)($v,{title:`Position`,children:[(0,I.jsxs)(`div`,{className:`flex gap-1`,children:[(0,I.jsx)(Zv,{label:`x`,value:f.x,onChange:e=>e!==void 0&&p({x:e},`pos`)}),(0,I.jsx)(Zv,{label:`y`,value:f.y,onChange:e=>e!==void 0&&p({y:e},`pos`)})]}),(0,I.jsxs)(`div`,{className:`flex gap-1`,children:[(0,I.jsx)(Zv,{label:`w`,value:f.w,min:.1,onChange:e=>e&&p({w:e},`pos`)}),(0,I.jsx)(Zv,{label:`h`,value:f.h,min:.1,onChange:e=>e&&p({h:e},`pos`)}),(0,I.jsx)(Zv,{label:`°`,value:f.rotate??0,step:1,onChange:e=>p({rotate:e||void 0},`rot`)})]}),(0,I.jsx)(`div`,{className:`flex gap-1`,role:`group`,"aria-label":`align to slide`,children:[[`left`,`align_horizontal_left`,{x:0}],[`center`,`align_horizontal_center`,{x:jv(m/2-f.w/2)}],[`right`,`align_horizontal_right`,{x:jv(m-f.w)}],[`top`,`align_vertical_top`,{y:0}],[`middle`,`align_vertical_center`,{y:jv(h/2-f.h/2)}],[`bottom`,`align_vertical_bottom`,{y:jv(h-f.h)}]].map(([e,t,n])=>(0,I.jsx)(`button`,{type:`button`,className:g,"aria-label":`to slide ${e}`,title:`to the slide's ${e}`,onClick:()=>p(n),children:(0,I.jsx)(L,{name:t,className:`ms-sm`})},e))})]}),d.some(e=>e.kind!==`image`&&e.kind!==`embed`)&&(0,I.jsxs)($v,{title:`Type`,children:[(0,I.jsxs)(`select`,{"aria-label":`font family`,className:`h-7 rounded-md border border-line bg-bg px-1 text-xs text-fg`,value:f?.font??`body`,onChange:e=>p({font:e.target.value===`body`?void 0:e.target.value}),children:[(0,I.jsxs)(`option`,{value:`body`,children:[e.fonts.body,` (body)`]}),(0,I.jsxs)(`option`,{value:`heading`,children:[e.fonts.heading,` (heading)`]}),Vv.filter(t=>t!==e.fonts.body&&t!==e.fonts.heading).map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,I.jsx)(Zv,{label:`pt`,value:f?.size??18,step:1,min:4,onChange:e=>e&&p({size:e},`size`)}),(0,I.jsx)(`button`,{type:`button`,className:P(g,f?.bold&&_),"aria-label":`bold`,"aria-pressed":!!f?.bold,onClick:()=>p({bold:!f?.bold||void 0}),children:(0,I.jsx)(L,{name:`format_bold`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(g,f?.italic&&_),"aria-label":`italic`,"aria-pressed":!!f?.italic,onClick:()=>p({italic:!f?.italic||void 0}),children:(0,I.jsx)(L,{name:`format_italic`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(g,f?.underline&&_),"aria-label":`underline`,"aria-pressed":!!f?.underline,onClick:()=>p({underline:!f?.underline||void 0}),children:(0,I.jsx)(L,{name:`format_underlined`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:P(g,f?.strike&&_),"aria-label":`strikethrough`,"aria-pressed":!!f?.strike,onClick:()=>p({strike:!f?.strike||void 0}),children:(0,I.jsx)(L,{name:`strikethrough_s`,className:`ms-sm`})})]}),(0,I.jsxs)(`div`,{className:`flex gap-1`,children:[[`left`,`center`,`right`].map(e=>(0,I.jsx)(`button`,{type:`button`,className:P(g,(f?.align??`left`)===e&&_),"aria-label":`text ${e}`,onClick:()=>p({align:e}),children:(0,I.jsx)(L,{name:`format_align_${e}`,className:`ms-sm`})},e)),(0,I.jsx)(`span`,{className:`w-2`}),[`top`,`middle`,`bottom`].map(e=>(0,I.jsx)(`button`,{type:`button`,className:P(g,(f?.valign??`top`)===e&&_),"aria-label":`text ${e}`,onClick:()=>p({valign:e}),children:(0,I.jsx)(L,{name:e===`top`?`vertical_align_top`:e===`middle`?`vertical_align_center`:`vertical_align_bottom`,className:`ms-sm`})},e))]}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Text color`}),(0,I.jsx)(Qv,{label:`text color`,theme:e,value:f?.color,onChange:e=>p({color:e})})]}),(0,I.jsxs)($v,{title:`Box`,children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Fill`}),(0,I.jsx)(Qv,{label:`fill`,theme:e,value:f?.fill,allowNone:!0,onChange:e=>p({fill:e})}),(0,I.jsxs)(`div`,{className:`flex gap-1`,children:[(0,I.jsx)(Zv,{label:`corners`,value:f?.radius,step:1,min:0,onChange:e=>p({radius:e||void 0},`radius`)}),(0,I.jsx)(Zv,{label:`border`,value:f?.border,step:.5,min:0,onChange:e=>p({border:e||void 0},`border`)})]}),!!f?.border&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:`Border color`}),(0,I.jsx)(Qv,{label:`border color`,theme:e,value:f?.borderColor,onChange:e=>p({borderColor:e})})]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`shadow`,checked:!!f?.shadow,onChange:e=>p({shadow:e.target.checked||void 0})}),`shadow`]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-fg-2`,children:`opacity`}),(0,I.jsx)(`input`,{type:`range`,"aria-label":`opacity`,min:.1,max:1,step:.05,value:f?.opacity??1,className:`flex-1`,onChange:e=>p({opacity:Number(e.target.value)>=1?void 0:Number(e.target.value)},`opacity`)}),(0,I.jsxs)(`span`,{className:`w-9 text-right tabular-nums`,children:[Math.round((f?.opacity??1)*100),`%`]})]}),d.some(e=>e.kind===`image`)&&(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-fg-2`,children:`picture`}),(0,I.jsxs)(`select`,{"aria-label":`picture fit`,className:`h-7 rounded-md border border-line bg-bg px-1 text-xs text-fg`,value:f?.fit??`contain`,onChange:e=>p({fit:e.target.value===`cover`?`cover`:void 0}),children:[(0,I.jsx)(`option`,{value:`contain`,children:`fits inside the box`}),(0,I.jsx)(`option`,{value:`cover`,children:`fills the box (cropped)`})]})]})]})]})]})}function ty({data:e,fenced:t,onChange:n}){let[r,i]=(0,v.useState)(e),a=e=>{i(e),n(B_(e,t))},o=`h-7 w-full min-w-0 rounded border border-transparent bg-transparent px-1.5 text-xs text-fg outline-none hover:border-line focus:border-accent`,s=(e,t,n)=>{let i=Number(n.replace(`,`,`.`));n.trim()===``||Number.isNaN(i)||a({...r,series:r.series.map((n,r)=>r===e?{...n,values:n.values.map((e,n)=>n===t?i:e)}:n)})};return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,role:`group`,"aria-label":`chart data`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`select`,{value:r.kind,"aria-label":`chart kind`,className:`h-8 rounded-md border border-line bg-bg px-1.5 text-xs text-fg`,onChange:e=>a({...r,kind:e.target.value}),children:M_.map(e=>(0,I.jsx)(`option`,{children:e},e))}),(0,I.jsx)(`input`,{value:r.title??``,"aria-label":`chart title`,placeholder:`title`,className:`h-8 min-w-0 flex-1 rounded-md border border-line bg-bg px-2 text-xs text-fg outline-none focus:border-accent`,onChange:e=>a({...r,title:e.target.value||void 0})})]}),(0,I.jsx)(`div`,{className:`max-h-[360px] overflow-auto rounded-md border border-line`,children:(0,I.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`bg-surface-2`,children:[(0,I.jsx)(`th`,{className:`w-[34%] p-0.5`}),r.series.map((e,t)=>(0,I.jsx)(`th`,{className:`p-0.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center`,children:[(0,I.jsx)(`input`,{value:e.name,"aria-label":`series ${t+1} name`,className:P(o,`font-semibold`),onChange:e=>a({...r,series:r.series.map((n,r)=>r===t?{...n,name:e.target.value}:n)})}),r.series.length>1&&(0,I.jsx)(`button`,{type:`button`,className:`text-fg-2 hover:text-bad`,"aria-label":`remove series ${t+1}`,onClick:()=>a({...r,series:r.series.filter((e,n)=>n!==t)}),children:(0,I.jsx)(L,{name:`close`,className:`ms-sm`})})]})},t)),(0,I.jsx)(`th`,{className:`w-7 p-0.5`,children:(0,I.jsx)(`button`,{type:`button`,className:`text-fg-2 hover:text-fg`,"aria-label":`add series`,onClick:()=>a({...r,series:[...r.series,{name:`Series ${r.series.length+1}`,values:r.categories.map(()=>0)}]}),children:(0,I.jsx)(L,{name:`add`,className:`ms-sm`})})})]})}),(0,I.jsx)(`tbody`,{children:r.categories.map((e,t)=>(0,I.jsxs)(`tr`,{className:`border-t border-line`,children:[(0,I.jsx)(`td`,{className:`p-0.5`,children:(0,I.jsx)(`input`,{value:e,"aria-label":`category ${t+1}`,className:o,onChange:e=>a({...r,categories:r.categories.map((n,r)=>r===t?e.target.value:n)})})}),r.series.map((n,r)=>(0,I.jsx)(`td`,{className:`p-0.5`,children:(0,I.jsx)(`input`,{defaultValue:String(n.values[t]),inputMode:`decimal`,"aria-label":`${n.name||`series ${r+1}`} · ${e||`row ${t+1}`}`,className:P(o,`text-right tabular-nums`),onChange:e=>s(r,t,e.target.value)})},r)),(0,I.jsx)(`td`,{className:`p-0.5 text-center`,children:r.categories.length>1&&(0,I.jsx)(`button`,{type:`button`,className:`text-fg-2 hover:text-bad`,"aria-label":`remove row ${t+1}`,onClick:()=>a({...r,categories:r.categories.filter((e,n)=>n!==t),series:r.series.map(e=>({...e,values:e.values.filter((e,n)=>n!==t)}))}),children:(0,I.jsx)(L,{name:`close`,className:`ms-sm`})})})]},t))})]})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex w-fit items-center gap-1 text-xs text-fg-2 hover:text-fg`,"aria-label":`add row`,onClick:()=>a({...r,categories:[...r.categories,`Item ${r.categories.length+1}`],series:r.series.map(e=>({...e,values:[...e.values,0]}))}),children:[(0,I.jsx)(L,{name:`add`,className:`ms-sm`}),`row`]})]})}function ny({s:e,onChange:t,onClose:n}){let[r,i]=(0,v.useState)(e.md??``),a=()=>{if(e.kind!==`chart`)return null;try{return N_(e.md??``)}catch{return null}},[o,s]=(0,v.useState)(()=>a()?`data`:`source`),c=(0,v.useMemo)(a,[e.kind,o]),l=e.kind===`chart`?`chart data (YAML)`:e.kind===`embed`?`embed: a URL, or a whole page (scripts run, sandboxed)`:e.kind===`html`?`HTML`:`markdown (with HTML)`;return(0,I.jsxs)(`div`,{className:`sticky top-3 flex flex-col gap-2 rounded-xl border border-line bg-surface p-3`,role:`region`,"aria-label":`${e.name} source`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(L,{name:e.kind===`chart`?`bar_chart`:e.kind===`embed`?`public`:`code`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:l}),(0,I.jsx)(`span`,{className:`flex-1`}),e.kind===`chart`&&(0,I.jsx)(`div`,{className:`flex rounded-md border border-line p-0.5 text-xs`,role:`tablist`,"aria-label":`chart editor`,children:[`data`,`source`].map(t=>(0,I.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===t,className:P(`rounded px-2 py-0.5`,o===t?`bg-surface-2 text-fg`:`text-fg-2`),onClick:()=>(t===`source`&&i(e.md??``),s(t)),children:t},t))}),(0,I.jsx)(`button`,{type:`button`,className:qv,"aria-label":`close source`,onClick:n,children:(0,I.jsx)(L,{name:`close`,className:`ms-sm`})})]}),c&&o===`data`?(0,I.jsx)(ty,{data:c,fenced:/^\s*```/.test(e.md??``),onChange:e=>(i(e),t(e))}):(0,I.jsx)(`textarea`,{value:r,"aria-label":`${e.name} source text`,spellCheck:!1,autoFocus:!0,className:`min-h-[340px] resize-y rounded-md border border-line bg-bg p-2 font-mono text-[12.5px] leading-5 text-fg outline-none focus:border-accent`,onChange:e=>{i(e.target.value),t(e.target.value)},onKeyDown:e=>{if(e.key===`Escape`&&n(),e.key===`Tab`){e.preventDefault();let n=e.currentTarget,a=n.selectionStart,o=`${r.slice(0,a)} ${r.slice(n.selectionEnd)}`;i(o),t(o),requestAnimationFrame(()=>n.setSelectionRange(a+2,a+2))}}}),e.error&&(0,I.jsx)(`span`,{className:`text-xs text-bad`,children:e.error}),(0,I.jsx)(`span`,{className:`text-xs text-fg-2`,children:e.kind===`chart`?`kind: column, bar, line, area, pie or doughnut · categories · series with name and values`:e.kind===`html`?`Use the theme's classes (cards, kpis, flow, timeline, callout, compare, cols) or inline styles; SVG works.`:e.kind===`embed`?`A page of your own runs in a sandbox: no access to kraftwerk.`:`Markdown and HTML mixed.`})]})}var ry=encodeURIComponent,iy=e=>e?{project:e}:void 0,ay=e=>e.project?`/projects/${ry(e.project)}/presentations/${ry(e.name)}`:`/presentations/${ry(e.name)}`,oy=(e,t)=>j(`/api/presentations/${ry(e.name)}/export?format=${t}${e.project?`&project=${ry(e.project)}`:``}`),sy=(e,t)=>n=>/^(https?:|data:|blob:|\/)/i.test(n)?n:j(`/api/presentations/${ry(e.name)}/file?path=${ry(n.replace(/^\.\//,``))}${e.project?`&project=${ry(e.project)}`:``}&v=${ry(t)}`),cy=e=>`kw-deck-chat:${e.project??``}/${e.name}`;function ly({seg:e,project:t}){let n=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,r=e[0]===`new`,i=e[1]===`present`||e[1]===`presenter`,a=N(`presentations.list`,t?{query:{project:t}}:{},{interval:1e4}),o=a?.presentations??[],s=t?`/projects/${ry(t)}/presentations`:`/presentations`,c=e=>({...t?{project:t}:{},name:e}),l=!t&&!!n&&!!a?.enabled&&!o.some(e=>e.name===n),u=N(`presentations.list`,l?{query:{all:`1`}}:null,{interval:6e4}),d=l?u?.presentations.find(e=>e.name===n&&e.project):void 0,f=e.slice(1).map(e=>`/${e}`).join(``);if((0,v.useEffect)(()=>{d?.project&&H(`/projects/${ry(d.project)}/presentations/${ry(d.name)}${f}`,{replace:!0})},[d?.project,d?.name,f]),d)return(0,I.jsx)(Y,{icon:`slideshow`,children:`opening the deck…`});if(n&&i)return(0,I.jsx)(Ay,{...c(n),presenter:e[1]===`presenter`,start:Number(e[2])||1},`${t??``}/${n}`);if(n&&a?.enabled&&!a.error)return(0,I.jsx)(`div`,{className:`runs-screen`,style:{gridTemplateColumns:`minmax(0, 1fr)`},children:(0,I.jsx)(`div`,{className:`runs-main`,style:{padding:`14px 18px 24px`},children:(0,I.jsx)(Sy,{...c(n)},`${t??``}/${n}`)})});let p;return p=a&&!a.enabled?(0,I.jsx)(Y,{icon:`slideshow`,children:a.error&&!/are off/.test(a.error)?(0,I.jsx)(`span`,{className:`text-bad`,children:a.error}):(0,I.jsxs)(I.Fragment,{children:[`Presentations are off. Turn them on in `,(0,I.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,I.jsx)(`code`,{children:`presentations:`}),` block to kraftwerk.yml.`]})}):a?a.error?(0,I.jsx)(Y,{icon:`slideshow`,children:(0,I.jsx)(`span`,{className:`text-bad`,children:a.error})}):r?(0,I.jsx)(uy,{root:a.root,project:t}):(0,I.jsx)(Y,{icon:`slideshow`,action:(0,I.jsx)(W,{variant:`primary`,icon:`add`,href:`${s}/new`,children:`new presentation`}),children:t?`The project's slide decks: each a folder with a deck.md and its pictures.`:`Workspace presentations: decks that belong to no project. A project's decks 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)(Tt,{title:t?`${t} · presentations`:`presentations`,count:a?.enabled?o.length:void 0,action:a?.enabled&&(0,I.jsx)(W,{size:`sm`,variant:`quiet`,icon:`add`,href:`${s}/new`,children:`new`})}),(0,I.jsxs)(Dt,{label:`presentations`,children:[o.map(e=>(0,I.jsx)(Z,{href:ay(c(e.name)),active:e.name===n,size:`sm`,leading:(0,I.jsx)(L,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`} · ${e.template}`,subTone:e.error?`bad`:`plain`,meta:e.updatedAt&&(0,I.jsx)(`span`,{title:e.updatedAt,children:Ge(e.updatedAt)})},e.name)),a&&!a.enabled&&(0,I.jsx)(Ot,{children:a.error}),a?.enabled&&o.length===0&&(0,I.jsxs)(Ot,{children:[`no `,t?``:`workspace `,`presentations yet`]}),t&&(0,I.jsx)(Ot,{children:(0,I.jsx)(U,{href:`/projects/${ry(t)}`,className:`text-accent`,children:`← back to the project`})})]})]}),(0,I.jsx)(`div`,{className:`runs-main`,children:p})]})}function uy({root:e,project:t}){let n=N(`presentations.templates`,{},{interval:6e4}),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(`default`),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),p=async e=>{for(let t of[...e??[]]){if(t.size>4e5||!/^text\/|json|csv|xml|markdown/.test(t.type||`text/plain`)&&!/\.(md|txt|csv|json|html?|ya?ml)$/i.test(t.name)){f(`${t.name}: only text files (md, txt, csv, json, html, yaml) up to 400 KB go into the brief`);continue}let e=await t.text();c(n=>`${n.trim()?`${n.trim()}\n\n`:``}--- ${t.name} ---\n${e.trim()}\n`),r.trim()||i(t.name.replace(/\.[^.]+$/,``).replace(/[-_]+/g,` `))}},m=async()=>{let e=r.trim();if(!e||l)return;u(!0),f(``);let n=await A.request(`presentations.create`,{body:{title:e,template:a,...t?{project:t}:{}}});if(u(!1),!n.ok)return f(M(n));let i={...t?{project:t}:{},name:n.data.name};if(s.trim())try{sessionStorage.setItem(dy(i),s.trim())}catch{}H(ay(i),{replace:!0})};return(0,I.jsxs)(at,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(L,{name:`slideshow`,className:`text-[26px] text-fg-2`}),(0,I.jsx)(rt,{children:`new presentation`})]}),(0,I.jsx)(X,{children:(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),m()},children:(0,I.jsxs)(yt,{className:`max-w-[680px]`,children:[(0,I.jsx)($,{label:`title`,children:(0,I.jsx)(Q,{value:r,"aria-label":`presentation title`,autoFocus:!0,placeholder:`e.g. Quarterly review`,onChange:e=>i(e.target.value)})}),(0,I.jsx)($,{label:`template`,children:(0,I.jsx)(vt,{value:a,"aria-label":`template`,onChange:e=>o(e.target.value),children:(n?.templates??[{slug:`default`,name:`Default`,layouts:[]}]).map(e=>(0,I.jsxs)(`option`,{value:e.slug,disabled:`error`in e&&!!e.error,children:[e.name,` (`,e.slug,`layouts`in e&&e.layouts.length?`, ${e.layouts.length} layouts`:``,`)`]},e.slug))})}),(0,I.jsx)($,{label:`what it is about (optional)`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,I.jsx)(_t,{value:s,"aria-label":`brief`,rows:6,placeholder:`Who it is for, what it should get across, the points, numbers and sources — or drop notes here.
452
+ An agent writes the outline and the slides in the theme while you watch.`,onChange:e=>c(e.target.value),onDragOver:e=>e.preventDefault(),onDrop:e=>(e.preventDefault(),void p(e.dataTransfer.files))}),(0,I.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-1 text-xs text-fg-2 hover:text-fg`,children:[(0,I.jsx)(L,{name:`attach_file`,className:`ms-sm`}),`add notes from text files`,(0,I.jsx)(`input`,{type:`file`,multiple:!0,accept:`.md,.txt,.csv,.json,.html,.htm,.yml,.yaml,text/*`,"aria-label":`notes files`,className:`hidden`,onChange:e=>void p(e.target.files)})]})]})}),(0,I.jsxs)(bt,{children:[(0,I.jsx)(W,{variant:`primary`,type:`submit`,icon:s.trim()?`auto_awesome`:`add`,busy:l,disabled:!r.trim()||l,children:s.trim()?`create with an agent`:`create presentation`}),(0,I.jsx)(W,{variant:`quiet`,href:t?`/projects/${ry(t)}/presentations`:`/presentations`,children:`cancel`}),d&&(0,I.jsx)(`span`,{className:`text-sm text-bad`,children:d})]}),(0,I.jsxs)(J,{children:[`One folder `,t?(0,I.jsxs)(I.Fragment,{children:[`under the project's `,(0,I.jsx)(`code`,{children:`presentations/`})]}):(0,I.jsxs)(I.Fragment,{children:[`under `,(0,I.jsx)(`code`,{title:e,children:e??`the presentations root`})]}),` with deck.md and an assets/ folder for pictures; it starts with a title slide and one content slide.`]})]})})})]})}var dy=e=>`kw-deck-brief:${e.project??``}/${e.name}`,fy=e=>`Build this presentation from my brief below. First answer with the outline (one line per slide), then write the slides into deck.md: replace the starter slides, use the theme's layouts and pieces (cards, kpis, flow, timeline, compare, charts, tables) where they fit the content, one idea per slide, and speaker notes for each. Keep the deck's title and theme.\n\nBrief:\n${e}`,py=e=>({title:e.title,template:e.template,css:e.deck.css??``,numbers:e.deck.numbers!==!1,slides:e.deck.slides.map(e=>({...e,extra:{...e.extra}}))}),my=e=>e.content.split(`
453
+ `).find(e=>e.trim()&&!/^::.*::$/.test(e.trim()))?.replace(/^#+\s*/,``).replace(/[*_`]/g,``)??``,hy=e=>e.extra?.hidden===!0,gy=`\`\`\`chart
454
+ kind: column
455
+ title: Chart title
456
+ categories: [A, B, C]
457
+ series:
458
+ - name: Series 1
459
+ values: [3, 5, 4]
460
+ \`\`\``,_y=`| Item | Value |
461
+ |---|---|
462
+ | First | 1 |
463
+ | Second | 2 |`,vy=`<div class="callout"><strong>HTML:</strong> anything the browser can show — the theme's classes apply.</div>`,yy=`<!doctype html>
464
+ <html><body style="margin:0;display:grid;place-items:center;height:100vh;font:40px system-ui">
465
+ <div id=n>0</div>
466
+ <script>let i=0;setInterval(()=>n.textContent=++i,1000)<\/script>
467
+ </body></html>`,by=[{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`}}],xy=[];function Sy({project:e,name:t}){let n={project:e,name:t},r=iy(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,j]=(0,v.useState)(!1),[ee,F]=(0,v.useState)(null),[te,R]=(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,z]=(0,v.useState)(null),[B,V]=(0,v.useState)(0),[de,fe]=(0,v.useState)(0),[pe,me]=(0,v.useState)(()=>{try{return localStorage.getItem(cy(n))}catch{return null}}),[he,ge]=(0,v.useState)(``),[_e,ve]=(0,v.useState)(0),ye=(0,v.useRef)(null),be=(0,v.useRef)(void 0),xe=(0,v.useRef)(null),Se=(0,v.useRef)(null),Ce=(0,v.useRef)(null),we=(0,v.useRef)([]),Te=(0,v.useRef)([]),Ee=(0,v.useRef)(null);Ee.current=o;let De=(0,v.useRef)(null);(0,v.useEffect)(()=>{i&&!c&&!y&&i.updatedAt!==be.current&&(be.current=i.updatedAt,De.current=py(i),s(py(i)),(ee===null||C!==`source`)&&F(i.source))},[i,c,C,ee,y]);let Oe=(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,...be.current?{base:be.current}:{}}});if(d(!1),!n.ok&&n.status===409){let n=await A.call(`presentations.get`,{name:t,query:r}).catch(()=>null);if(!n||!De.current)return p(`the deck changed elsewhere; reload to see it`);let{draft:i,lost:a}=Cv(De.current,e,py(n));be.current=n.updatedAt,De.current=py(n),Ee.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.`),Oe(i);return}if(!n.ok)return p(M(n));if(De.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(`
468
+ `).map(e=>` ${e}`).join(`
469
+ `)}`:``}\n---\n`),o=await A.request(`presentations.save`,{name:t,query:r,body:{source:a}});if(!o.ok)return p(M(o));be.current=o.data.updatedAt,F(o.data.source)}else be.current=n.data.updatedAt,F(n.data.source);l(!1)},[t,e]),ke=(e,t)=>{let n=Ee.current;if(!n)return;let r=e(n),i=we.current[we.current.length-1];t&&i?.mark===t&&Date.now()-i.at<1500?i.at=Date.now():we.current.push({draft:n,mark:t,at:Date.now()}),we.current.length>200&&we.current.shift(),Te.current=[],Ee.current=r,s(r),l(!0),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>void Oe(r),600)},Ae=e=>{Ee.current=e,s(e),l(!0),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>void Oe(e),600)},je=()=>{let e=we.current.pop();e&&Ee.current&&(Te.current.push(Ee.current),Ae(e.draft))},Me=()=>{let e=Te.current.pop();e&&Ee.current&&(we.current.push({draft:Ee.current,at:Date.now()}),Ae(e))};(0,v.useEffect)(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);let Ne=i?.themes??[],Pe=(o&&Ne.find(e=>e.slug===o.template))??i?.theme;Mv(Pe?[Pe,...Ne.filter(e=>e.slug!==Pe.slug)]:[],o?.css);let Fe=`${i?.updatedAt??``}-${B}`,Ie=(0,v.useMemo)(()=>sy(n,Fe),[t,e,Fe]),Le=o?.slides??[],Re=Math.min(m,Math.max(0,Le.length-1)),ze=Le[Re],Be=Fv(ze,Pe,Ie),Ve=Le.filter(e=>!hy(e)).length,He=e=>o?.numbers===!1?void 0:{n:Le.slice(0,e+1).filter(e=>!hy(e)).length,of:Ve},Ue=(e,t)=>ke(t=>({...t,slides:t.slides.map((t,n)=>n===Re?{...t,...e}:t)}),t),We=(e,t,n)=>{ze&&Be&&Pe&&Ue({content:iv(ze.content,e,t,zv(Pe,Be.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?Me():je()):r&&e.key.toLowerCase()===`y`&&!n?(e.preventDefault(),Me()):!n&&e.key===`PageDown`?h(e=>Math.min(e+1,Le.length-1)):!n&&e.key===`PageUp`&&h(e=>Math.max(0,e-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let Ke=Ey(n,Re+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(dy(n)),e&&sessionStorage.removeItem(dy(n))}catch{}e&&qe.current?.(fy(e))},[Je]),!i||!o||!Pe)return(0,I.jsx)(Y,{children:`loading…`});let Ye=Object.entries(Pe.layouts),Xe=i.warnings.filter(e=>e.slide===0),Ze=e=>i.warnings.filter(t=>t.slide===e),Qe=e?`/projects/${ry(e)}/presentations`:`/presentations`,K=e=>{h(e),_([]),b(null),S(null)},q=e=>{ke(t=>({...t,slides:[...t.slides.slice(0,Re+1),{layout:e,extra:{},content:``},...t.slides.slice(Re+1)]})),K(Re+1),ae(`none`)},$e=e=>{let t=e=>{let t=structuredClone(e.extra??{});return delete t.id,{...e,extra:t}};ke(n=>({...n,slides:[...n.slides.slice(0,e+1),t(n.slides[e]),...n.slides.slice(e+1)]})),K(e+1)},tt=e=>{Le.length<=1||(ke(t=>({...t,slides:t.slides.filter((t,n)=>n!==e)})),K(Math.max(0,e<=Re?Re-1:Re)))},nt=e=>ke(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}})})),rt=(e,t)=>{e===t||t<0||t>=Le.length||(ke(n=>{let r=[...n.slides],[i]=r.splice(e,1);return r.splice(t,0,i),{...n,slides:r}}),K(t))},it=(e,t)=>{let n=1;for(;t.has(`${e}${n}`);)n++;return t.add(`${e}${n}`),`${e}${n}`},at=(e,t,n,r,i,a,o={})=>{if(!ze||!Be)return;let s=it(t,new Set(Be.slots.map(e=>e.name))),c=H_/160,l=lv(Pe.size)/160,u={x:jv((c-r)/2),y:jv((l-i)/2),w:r,h:i};Ue({...Rv(ze,{[s]:{kind:e,...u,...e===`markdown`||e===`text`?{size:18}:e===`table`||e===`chart`?{size:13}:e===`html`?{size:15}:{},...o}}),content:iv(ze.content,s,n,zv(Pe,Be.layout))}),_([s]),b(a===`edit`?s:null),S(a===`source`?s:null),ae(`none`)},ot=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)},st=async(e,t)=>{if(!ze||!Be)return;let n=await ot(e);if(!n)return;let r=`![${e.name.replace(/\.[^.]+$/,``)}](${n})`,i=t&&Be.slots.find(e=>e.name===t)||Be.slots.find(e=>e.kind===`image`&&!e.md);i?(We(i.name,r),_([i.name])):at(`image`,`image`,r,4,3,`none`)},ct=e=>{if(!ze||!Be)return;let t=zv(Pe,Be.layout),n=ze.content,r={};for(let i of e){let e=Be.slots.find(e=>e.name===i);e&&(n=iv(n,i,``,t),e.own&&(r[i]=null))}Ue({...Rv(ze,r),content:n}),_([]),x&&e.includes(x)&&S(null)},lt=e=>{ze&&Be&&(xy=Be.slots.filter(t=>e.includes(t.name)).map(e=>{let t=Lv(ze)[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}:{}}}}),ve(e=>e+1))},ut=(e=.2)=>{if(!ze||!Be||!xy.length)return;let t=new Set(Be.slots.map(e=>e.name)),n={},r=ze.content,i=[];for(let a of xy){let o=it(a.base,t);n[o]={...a.patch,x:jv((a.patch.x??0)+e),y:jv((a.patch.y??0)+e)},r=iv(r,o,a.md,zv(Pe,Be.layout)),i.push(o)}Ue({...Rv(ze,n),content:r}),_(i)},dt=e=>{lt(e),ut()},ft=(e,t)=>{if(t)return void $(`In the box "${e}" on slide ${Re+1}: ${t}`);ge(`In the box "${e}" on slide ${Re+1}: `),requestAnimationFrame(()=>Ce.current?.focus())},Z=i.comments??[],pt=Z.filter(e=>!e.resolved),mt=e=>pt.filter(t=>t.n===e).length,ht={};for(let e of pt)e.n===Re+1&&(ht[e.slot??``]=(ht[e.slot??``]??0)+1);let gt=e=>{S(null),E(e),w(`comments`)},Q=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`)},vt=async e=>{let t=`${location.origin}${location.pathname}#${ay(n)}${e===`present`?`/present`:``}`;try{await navigator.clipboard.writeText(t),O(`Link copied: ${t}`)}catch{O(t)}ae(`none`)},$=async r=>{let a=(r??he).trim();if(!a)return;p(``);let s=e?` --project ${e}`:``,c=pe,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,me(c);try{localStorage.setItem(cy(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 ${Re+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 ${Re+1}) ${a}`,d=await A.request(`chats.message`,{id:c,body:{text:u}});if(!d.ok)return p(M(d));r===void 0&&ge(``),w(`chat`),S(null)};qe.current=e=>void $(e);let xt=e=>{S(null),w(t=>t===e?`none`:e)},St=Be?.slots.find(e=>e.name===x)??null,Ct=`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`,wt=`relative flex items-center gap-0.5 rounded-full border border-line bg-surface px-1.5 py-1`,Tt=St||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:wt,children:[(0,I.jsx)(G,{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=>ke(t=>({...t,title:e.target.value}),`title`)})]}),(0,I.jsxs)(`div`,{className:wt,children:[(0,I.jsxs)(`button`,{type:`button`,className:Ct,"aria-haspopup":`menu`,"aria-expanded":ie===`slide`,onClick:()=>ae(e=>e===`slide`?`none`:`slide`),children:[(0,I.jsx)(L,{name:`add_to_photos`,className:`ms-sm`}),`slide`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,title:`a text box on this slide`,onClick:()=>at(`markdown`,`text`,`Text`,4,.9,`edit`),children:[(0,I.jsx)(L,{name:`title`,className:`ms-sm`}),`text`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,title:`a picture on this slide (png, jpg, gif) — or drop one onto the slide`,onClick:()=>{Se.current=null,xe.current?.click()},children:[(0,I.jsx)(L,{name:`image`,className:`ms-sm`}),`picture`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,title:`a chart on this slide`,onClick:()=>at(`chart`,`chart`,gy,6,3.2,`source`),children:[(0,I.jsx)(L,{name:`bar_chart`,className:`ms-sm`}),`chart`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,title:`a table on this slide`,onClick:()=>at(`table`,`table`,_y,6,1.6,`none`),children:[(0,I.jsx)(L,{name:`table`,className:`ms-sm`}),`table`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,"aria-haspopup":`menu`,"aria-expanded":ie===`shapes`,title:`rectangles, circles, lines, arrows`,onClick:()=>ae(e=>e===`shapes`?`none`:`shapes`),children:[(0,I.jsx)(L,{name:`category`,className:`ms-sm`}),`shapes`]}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,"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)(L,{name:`widgets`,className:`ms-sm`}),`more`]}),ie===`slide`&&(0,I.jsx)(Uv,{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)(Iv,{slide:{layout:e,extra:{},content:``},theme:Pe,asset:Ie,width:152}),(0,I.jsx)(`span`,{className:`text-xs text-fg`,children:e})]},e))})}),ie===`shapes`&&(0,I.jsx)(Uv,{label:`shapes`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[240px]`,children:by.map(e=>(0,I.jsx)(Wv,{icon:e.icon,title:e.name,onClick:()=>at(`html`,e.name.toLowerCase(),e.html,e.w,e.h,`none`,e.patch)},e.name))}),ie===`insert`&&(0,I.jsxs)(Uv,{label:`insert`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[340px]`,children:[(0,I.jsx)(Wv,{icon:`code`,title:`HTML`,sub:`any markup; the theme's classes apply`,onClick:()=>at(`html`,`html`,vy,6,1.2,`source`)}),(0,I.jsx)(Wv,{icon:`public`,title:`Embed`,sub:`a web page by URL, or a page of your own with scripts`,onClick:()=>at(`embed`,`embed`,yy,4,2.4,`source`)}),Pe.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`}),Pe.snippets.map(e=>(0,I.jsx)(Wv,{icon:`dashboard_customize`,title:e.name,sub:e.description,onClick:()=>at(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:xe,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&&st(t,Se.current)}})]}),ze&&!ce&&(0,I.jsxs)(`div`,{className:wt,children:[(0,I.jsx)(`span`,{className:`pl-1.5 text-xs text-fg-2`,children:`layout`}),(0,I.jsx)(`select`,{value:Be?.layout??ze.layout??``,"aria-label":`layout`,className:`h-8 cursor-pointer border-0 bg-transparent pr-1 text-sm text-fg outline-none`,onChange:e=>Ue({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:wt,children:[(0,I.jsx)(`button`,{type:`button`,className:Ct,disabled:!we.current.length,title:`undo (⌘Z)`,"aria-label":`undo`,onClick:je,children:(0,I.jsx)(L,{name:`undo`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:Ct,disabled:!Te.current.length,title:`redo (⇧⌘Z)`,"aria-label":`redo`,onClick:Me,children:(0,I.jsx)(L,{name:`redo`,className:`ms-sm`})}),(0,I.jsxs)(`button`,{type:`button`,className:Ct,"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)(L,{name:`expand_more`,className:`ms-sm`})]}),(0,I.jsx)(`button`,{type:`button`,className:P(Ct,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)(L,{name:`grid_view`,className:`ms-sm`})}),ie===`zoom`&&(0,I.jsx)(Uv,{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)(Wv,{title:e?`${e*100}%`:`fit`,onClick:()=>{z(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:()=>K(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 ${Ge(i.updatedAt)}`:``}),(0,I.jsxs)(`div`,{className:wt,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`format`&&`bg-surface-2 text-fg`),"aria-pressed":C===`format`,onClick:()=>xt(`format`),children:[(0,I.jsx)(L,{name:`tune`,className:`ms-sm`}),`format`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`design`&&`bg-surface-2 text-fg`),"aria-pressed":C===`design`,onClick:()=>xt(`design`),children:[(0,I.jsx)(L,{name:`palette`,className:`ms-sm`}),`design`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`chat`&&`bg-surface-2 text-fg`),"aria-pressed":C===`chat`,onClick:()=>xt(`chat`),children:[(0,I.jsx)(L,{name:`forum`,className:`ms-sm`}),`chat`]}),(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`comments`&&`bg-surface-2 text-fg`),"aria-pressed":C===`comments`,"aria-label":`comments`,onClick:()=>C===`comments`?w(`none`):gt(g.length===1?g[0]:void 0),children:[(0,I.jsx)(L,{name:`comment`,className:`ms-sm`}),pt.length>0&&(0,I.jsx)(`span`,{className:`rounded-full bg-[#f59e0b] px-1.5 text-[11px] font-semibold text-black`,children:pt.length})]}),(0,I.jsx)(`button`,{type:`button`,className:P(Ct,C===`history`&&`bg-surface-2 text-fg`),"aria-pressed":C===`history`,"aria-label":`version history`,title:`version history`,onClick:()=>xt(`history`),children:(0,I.jsx)(L,{name:`history`,className:`ms-sm`})}),(0,I.jsx)(`button`,{type:`button`,className:Ct,"aria-haspopup":`menu`,"aria-expanded":ie===`share`,"aria-label":`share`,onClick:()=>ae(e=>e===`share`?`none`:`share`),children:(0,I.jsx)(L,{name:`share`,className:`ms-sm`})}),ie===`share`&&(0,I.jsxs)(Uv,{label:`share`,onClose:()=>ae(`none`),className:`absolute right-0 top-[calc(100%+6px)] w-[280px]`,children:[(0,I.jsx)(Wv,{icon:`link`,title:`Copy link to the editor`,sub:`for anyone with this workspace (paired devices, members)`,onClick:()=>void vt(`edit`)}),(0,I.jsx)(Wv,{icon:`slideshow`,title:`Copy link to present mode`,onClick:()=>void vt(`present`)}),(0,I.jsx)(Wv,{icon:`html`,title:`Download as one HTML file`,sub:`opens anywhere, no kraftwerk needed`,onClick:()=>(ae(`none`),window.location.href=oy(n,`html`))}),(0,I.jsx)(Wv,{icon:`alternate_email`,title:`Copy reference`,sub:`presentation:${t} — paste into a chat, a task or a note`,onClick:()=>void Q()}),(0,I.jsx)(Gv,{}),(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)(Wv,{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:wt,children:[(0,I.jsxs)(U,{href:`${ay(n)}/present`,className:P(Ct,`font-semibold text-fg no-underline`),"aria-label":`present`,children:[(0,I.jsx)(L,{name:`play_arrow`,className:`ms-sm`}),`present`]}),(0,I.jsx)(`button`,{type:`button`,className:P(Ct,`px-1`),"aria-haspopup":`menu`,"aria-expanded":ie===`present`,"aria-label":`present options`,onClick:()=>ae(e=>e===`present`?`none`:`present`),children:(0,I.jsx)(L,{name:`expand_more`,className:`ms-sm`})}),(0,I.jsxs)(`a`,{className:P(Ct,`no-underline`),href:oy(n,`pptx`),download:!0,title:`download as PowerPoint`,"aria-label":`pptx`,children:[(0,I.jsx)(L,{name:`download`,className:`ms-sm`}),`pptx`]}),(0,I.jsx)(`a`,{className:P(Ct,`no-underline`),href:oy(n,`pdf`),download:!0,title:`download as PDF`,"aria-label":`pdf`,children:(0,I.jsx)(L,{name:`picture_as_pdf`,className:`ms-sm`})}),(0,I.jsx)(`a`,{className:P(Ct,`no-underline`),href:oy(n,`html`),download:!0,title:`download as one HTML file`,"aria-label":`html`,children:(0,I.jsx)(L,{name:`html`,className:`ms-sm`})}),ie===`present`&&(0,I.jsxs)(Uv,{label:`present`,onClose:()=>ae(`none`),className:`absolute left-0 top-[calc(100%+6px)] w-[230px]`,children:[(0,I.jsx)(Wv,{icon:`play_arrow`,title:`From the start`,onClick:()=>H(`${ay(n)}/present`)}),(0,I.jsx)(Wv,{icon:`slideshow`,title:`From slide ${Re+1}`,onClick:()=>H(`${ay(n)}/present/${Re+1}`)}),(0,I.jsx)(Wv,{icon:`co_present`,title:`With notes (presenter view)`,sub:`current and next slide, notes, a clock`,onClick:()=>H(`${ay(n)}/presenter/${Re+1}`)})]})]}),(0,I.jsxs)(`div`,{className:wt,children:[(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`markdown`&&`bg-surface-2 text-fg`),"aria-pressed":C===`markdown`,title:`this slide's markdown`,onClick:()=>xt(`markdown`),children:[(0,I.jsx)(L,{name:`notes`,className:`ms-sm`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`markdown`})]}),(0,I.jsxs)(`button`,{type:`button`,className:P(Ct,C===`source`&&`bg-surface-2 text-fg`),"aria-pressed":C===`source`,title:`the whole deck.md`,onClick:()=>xt(`source`),children:[(0,I.jsx)(L,{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)(W,{size:`sm`,variant:`danger`,onClick:()=>void Dt(),children:`move to trash`}),(0,I.jsx)(W,{size:`sm`,variant:`quiet`,onClick:()=>R(!1),children:`keep`})]}):(0,I.jsx)(G,{icon:`delete`,label:`remove presentation`,size:`sm`,onClick:()=>R(!0)})]})]}),f&&(0,I.jsx)(et,{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)(L,{name:`info`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:D}),(0,I.jsx)(G,{icon:`close`,label:`dismiss`,size:`sm`,onClick:()=>O(``)})]}),Xe.length>0&&(0,I.jsx)(ky,{items:Xe}),C===`source`?(0,I.jsx)(X,{title:`deck.md`,children:(0,I.jsxs)(yt,{children:[(0,I.jsx)(_t,{value:ee??``,"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)(bt,{children:[(0,I.jsx)(W,{variant:`primary`,icon:`save`,busy:u,disabled:!c||u,onClick:()=>void Et(),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`,Tt?`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:[Le.length,` `,Le.length===1?`slide`:`slides`]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{icon:`add`,label:`add slide`,size:`sm`,onClick:()=>q(Be?.layout&&Be.layout!==`title`?Be.layout:Pe.default??`content`)})]}),(0,I.jsx)(`div`,{className:`flex flex-col gap-2`,role:`list`,"aria-label":`slides`,children:Le.map((e,t)=>(0,I.jsxs)(`div`,{role:`listitem`,"aria-current":t===Re,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&&rt(ne,t),re(null)},onDragEnd:()=>re(null),onContextMenu:e=>{e.preventDefault(),K(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===Re?`font-semibold text-fg`:`text-fg-2`),children:t+1}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`slide ${t+1}${hy(e)?` (hidden)`:``}`,className:P(`min-w-0 flex-1 overflow-hidden rounded-md border-2`,t===Re?`border-accent`:`border-transparent hover:border-line-strong`,hy(e)&&`opacity-45`),title:my(e),onClick:()=>K(t),onKeyDown:e=>{e.key===`Backspace`||e.key===`Delete`?(e.preventDefault(),tt(t)):e.key===`ArrowDown`&&e.altKey?rt(t,t+1):e.key===`ArrowUp`&&e.altKey&&rt(t,t-1)},children:(0,I.jsx)(Iv,{slide:e,theme:Pe,asset:Ie,width:136,number:He(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))}),mt(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":`${mt(t+1)} open comments`,children:mt(t+1)}),hy(e)&&(0,I.jsx)(L,{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)(L,{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)(G,{icon:`content_copy`,label:`duplicate slide ${t+1}`,size:`sm`,onClick:()=>$e(t)}),(0,I.jsx)(G,{icon:`delete`,label:`remove slide ${t+1}`,size:`sm`,disabled:Le.length<=1,onClick:()=>tt(t)})]})]},t))})]}),oe&&(0,I.jsxs)(Uv,{label:`slide actions`,onClose:()=>se(null),className:`fixed w-[220px]`,style:{left:oe.x,top:oe.y},children:[(0,I.jsx)(Wv,{icon:`library_add`,title:`Duplicate`,onClick:()=>($e(oe.i),se(null))}),(0,I.jsx)(Wv,{icon:hy(Le[oe.i])?`visibility`:`visibility_off`,title:hy(Le[oe.i])?`Show`:`Hide`,sub:`hidden slides stay out of present mode and the exports`,onClick:()=>(nt(oe.i),se(null))}),(0,I.jsx)(Wv,{icon:`arrow_upward`,title:`Move up`,keys:`⌥↑`,disabled:oe.i===0,onClick:()=>(rt(oe.i,oe.i-1),se(null))}),(0,I.jsx)(Wv,{icon:`arrow_downward`,title:`Move down`,keys:`⌥↓`,disabled:oe.i>=Le.length-1,onClick:()=>(rt(oe.i,oe.i+1),se(null))}),(0,I.jsx)(Gv,{}),(0,I.jsx)(Wv,{icon:`delete`,title:`Delete`,keys:`⌫`,danger:!0,disabled:Le.length<=1,onClick:()=>(tt(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:Le.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===Re&&`ring-2 ring-accent`,hy(e)&&`opacity-45`),onClick:()=>{K(t),le(!1)},children:[(0,I.jsx)(Iv,{slide:e,theme:Pe,asset:Ie,width:280,number:He(t)}),(0,I.jsxs)(`span`,{className:`text-xs text-fg-2`,children:[t+1,` · `,my(e)||e.layout,hy(e)?` · hidden`:``]})]},t))}):ze&&Be&&(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,I.jsx)(Kv,{view:Be,theme:Pe,slide:ze,number:He(Re),zoom:ue,selected:g,editing:y,onSelect:e=>{_(e),x&&!e.includes(x)&&S(null)},onEditing:b,onSource:e=>{Be.slots.find(t=>t.name===e)?.kind===`image`?(Se.current=e,xe.current?.click()):S(e)},onPatches:(e,t)=>Ue(Rv(ze,e),t),onText:(e,t)=>We(e,t),onRemove:ct,onDuplicate:dt,onCopy:lt,onPaste:()=>ut(),canPaste:_e>=0&&xy.length>0,onAsk:ft,onFormat:()=>{S(null),w(`format`)},onDropFile:e=>void st(e),onWidth:fe,pins:ht,others:Ke.filter(e=>e.slide===Re+1&&e.slot).map(e=>({slot:e.slot,who:e.who,color:e.color})),onComments:gt}),(0,I.jsxs)(`div`,{className:`flex w-full items-start gap-3`,style:{maxWidth:de||void 0},children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:Ze(Re+1).length>0?(0,I.jsx)(ky,{items:Ze(Re+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:()=>j(e=>!e),children:[(0,I.jsx)(L,{name:k?`expand_less`:`expand_more`,className:`ms-sm`}),`speaker notes`,ze.notes?.trim()?` ·`:``]})]}),(0,I.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,style:{maxWidth:de||void 0},children:[k&&(0,I.jsx)(_t,{value:ze.notes??``,"aria-label":`speaker notes`,rows:3,placeholder:`what you say on this slide`,onChange:e=>Ue({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(),$()},children:[(0,I.jsx)(L,{name:`auto_awesome`,className:`ms-sm text-fg-2`}),(0,I.jsx)(`input`,{ref:Ce,value:he,"aria-label":`ask an agent`,placeholder:`ask an agent to change slide ${Re+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=>ge(e.target.value)}),(0,I.jsx)(G,{icon:`arrow_upward`,label:`send to an agent`,size:`sm`,disabled:!he.trim(),onClick:()=>void $()})]})]})]}),St&&ze?(0,I.jsx)(ny,{s:St,onChange:e=>We(St.name,e,`src:${St.name}`),onClose:()=>S(null)},`${Re}:${St.name}`):C===`format`&&ze&&Be?(0,I.jsx)(ey,{theme:Pe,slide:ze,view:Be,selected:g,assets:i.assets,onPatches:(e,t)=>Ue(Rv(ze,e),t),onSlide:e=>Ue(e),numbers:o.numbers!==!1,onNumbers:e=>ke(t=>({...t,numbers:e})),onUpload:ot,onClose:()=>w(`none`)}):C===`design`?(0,I.jsx)(Cy,{themes:Ne,current:o.template,css:o.css,slide:ze,asset:Ie,onTemplate:e=>ke(t=>({...t,template:e})),onCss:e=>ke(t=>({...t,css:e}),`css`)}):C===`history`?(0,I.jsx)(Dy,{at:n,theme:Pe,asset:Ie,onRestore:e=>{ke(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)(Oy,{at:n,comments:Z,slide:Re+1,slot:T,onSlot:E,onGo:(e,t)=>(K(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)(L,{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`}),pe&&(0,I.jsx)(G,{icon:`add_comment`,label:`new chat`,size:`sm`,onClick:()=>{me(null);try{localStorage.removeItem(cy(n))}catch{}}}),(0,I.jsx)(G,{icon:`close`,label:`close chat`,size:`sm`,onClick:()=>w(`none`)})]}),pe?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,I.jsx)(Vo,{id:pe},pe)}):(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`&&ze?(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:`,Be?.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)(_t,{value:ze.content,"aria-label":`slide content`,spellCheck:!1,className:`min-h-[380px] font-mono text-[13px] leading-5`,onChange:e=>Ue({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 Et(){if(ee===null)return;d(!0),p(``);let e=await A.request(`presentations.save`,{name:t,query:r,body:{source:ee}});if(d(!1),!e.ok)return p(M(e));be.current=e.data.updatedAt,we.current.push({draft:Ee.current,at:Date.now()}),s(py(e.data)),F(e.data.source),l(!1)}async function Dt(){let e=await A.request(`presentations.delete`,{name:t,query:r});if(!e.ok)return p(M(e));H(Qe,{replace:!0})}}function Cy({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)(Iv,{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); }
470
+ .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 wy=[`#e11d48`,`#7c3aed`,`#059669`,`#d97706`,`#0891b2`,`#db2777`,`#4f46e5`,`#65a30d`],Ty=e=>wy[[...e].reduce((e,t)=>e*31+t.charCodeAt(0)>>>0,7)%wy.length];function Ey(e,t,n,r){let i=(0,v.useMemo)(()=>`t${Math.random().toString(36).slice(2,10)}`,[]),[a,o]=(0,v.useState)([]),s=iy(e.project),c=e.project?`${e.project}/${e.name}`:e.name;return(0,v.useEffect)(()=>ee.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:Ty(e.client)}))}function Dy({at:e,theme:t,asset:n,onRestore:r,onClose:i}){let a=iy(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)(L,{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)(G,{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:[Ge(e.at),` · `,e.title,` · `,e.slides,` slide`,e.slides===1?``:`s`]})]}),(0,I.jsx)(L,{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)(Iv,{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)(W,{size:`sm`,variant:`primary`,icon:`restore`,onClick:()=>r(u),children:`restore this version`})]})]},e.id))})]})}function Oy({at:e,comments:t,slide:n,slot:r,onSlot:i,onGo:a,onClose:o}){let s=iy(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)(L,{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)(G,{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)(W,{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:[`· `,Ge(e.at)]}),(0,I.jsx)(`span`,{className:`flex-1`}),(0,I.jsx)(G,{icon:e.resolved?`replay`:`check_circle`,label:e.resolved?`reopen`:`resolve`,size:`sm`,onClick:()=>void _(e.id,{resolved:!e.resolved})}),(0,I.jsx)(G,{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}),` · `,Ge(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 ky({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)(L,{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 Ay({project:e,name:t,presenter:n,start:r}){let i={project:e,name:t},a=N(`presentations.get`,{name:t,query:iy(e)},{interval:1e4}),o=(a?.deck.slides??[]).map((e,t)=>({s:e,i:t})).filter(e=>!hy(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=ay(i),x=e=>l(Math.min(Math.max(1,e),Math.max(1,_))),S=a?.theme;Mv(S?[S]:[],a?.deck.css);let C=(0,v.useMemo)(()=>sy(i,a?.updatedAt??``),[t,e,a?.updatedAt]),w=o[c-1]?.s,T=o[c]?.s,E=Fv(w,S,C),D=Fv(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?lv(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)*H_/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)(Pv,{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)(Pv,{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 j=f.h-36-(u?Math.min(f.h*.3,180):0),ee=Math.min(f.w,j*H_/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)(Pv,{view:E,theme:S,width:ee,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)`})]})]})}var jy=40,My=/Mac|iPhone|iPad/.test(navigator.platform),Ny=null,Py=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}`}))]),Fy=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,Iy=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,Ly=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)}`,Ry={contacts:`contact`,places:`place`,events:`event`},zy={contacts:`person`,places:`location_on`,events:`event`},By={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},Vy=e=>e.kind===`agent`?e.agent.emoji:e.kind===`project`?By[e.project.status]:e.kind===`entity`?(0,I.jsx)(L,{name:zy[e.entity.kind],className:`text-[18px] text-fg-2`}):e.kind===`task`?(0,I.jsx)(L,{name:`task`,className:`text-[18px] text-fg-2`}):e.kind===`deck`?(0,I.jsx)(L,{name:`slideshow`,className:`text-[18px] text-fg-2`}):(0,I.jsx)(L,{name:`forum`,className:`text-[18px] text-fg-2`}),Hy=`flex-none rounded-full border border-line px-1.5 py-px text-[10px] font-semibold tracking-[0.4px] uppercase`;function Uy(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=Fy(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??``,Ry[t.entity.kind],`${Ry[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 Wy(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 Gy(e){let t=Ly(e);if(e.ws.current)return H(t);let n=e.ws.live||!e.ws.root?fe(e.ws):await pe(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function Ky(){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)(L,{name:`search`}),(0,I.jsx)($e,{className:`max-[1100px]:hidden`,children:My?`⌘K`:`Ctrl K`})]}),e&&(0,I.jsx)(qy,{onClose:()=>t(!1)})]})}function qy({onClose:e}){let[t,n]=(0,v.useState)(Ny),[r,i]=(0,v.useState)(Ny===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=>{Ny=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Py(t),[t]),_=(0,v.useMemo)(()=>Uy(g,s).slice(0,jy),[g,s]),y=(0,v.useMemo)(()=>Wy(_),[_]),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=>{if(!d){if(t.ws.current||t.ws.live){e(),Gy(t);return}f(t.key),m(``),Gy(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)(L,{name:`open_in_new`,className:`ms-sm`}):(0,I.jsx)(`span`,{className:Hy,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:Vy(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:Fy(t)}),Iy(t)&&(0,I.jsx)(`span`,{className:`truncate text-xs text-fg-2`,children:Iy(t)})]}),d===t.key?(0,I.jsx)(L,{name:`progress_activity`,className:`ms-sm`}):t.kind!==`agent`&&(0,I.jsx)(`span`,{className:P(Hy,`text-fg-2`),children:t.kind===`entity`?Ry[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)(L,{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)(L,{name:`progress_activity`,className:`ms-sm`}),(0,I.jsx)($e,{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)($e,{children:`↑`}),(0,I.jsx)($e,{children:`↓`}),` move`]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)($e,{children:`↵`}),` open`]}),d&&(0,I.jsxs)(`span`,{className:`ml-auto`,children:[(0,I.jsx)(L,{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)(L,{name:`warning`,className:`ms-sm`}),` `,p]})]})]})})}var Jy=1296e5;function Yy(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 Xy(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 Zy(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?Yy(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()<Jy)return{text:`next: ${e.nextRoutine.name} · ${Xy(e.nextRoutine.at,n)}`,tone:`plain`};if(e.lastActiveAt){let t=Yy(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 Qy=e=>`section`in e;function $y(e){return[...e.top.map(e=>({slug:e})),...e.sections.flatMap(e=>[{section:e.name},...e.projects.map(e=>({slug:e}))])]}function eb(e){let t={top:[],sections:[]};for(let n of e)Qy(n)?t.sections.push({name:n.section,projects:[]}):(t.sections.at(-1)?.projects??t.top).push(n.slug);return t}var tb=(e,t)=>Qy(e)?`section`in t&&e.section===t.section:`slug`in t&&e.slug===t.slug;function nb(e,t,n){let r=e.findIndex(e=>tb(e,t));if(r<0)return e;let i=r+1;if(`section`in t)for(;i<e.length&&!Qy(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 rb({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??$y(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(eb(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&&Qy(i))return t+1;if(d&&`section`in d){let e=t;for(;e>=0&&!Qy(u[e]);)e--;if(e<0)return u.findIndex(Qy)<0?u.length:u.findIndex(Qy);if(!r&&e===t)return e;let n=e+1;for(;n<u.length&&!Qy(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=nb(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=>!Qy(t)&&t.slug===e),r=t.key===`ArrowUp`?n-1:n+2;r<0||r>u.length||_(nb(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}`)),Qy(e)){E=e.section;let t=e.section,n=i(t),o=0;for(let e=r+1;e<u.length&&!Qy(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)(ib,{name:t,taken:u.filter(Qy).map(e=>e.section).filter(e=>e!==t),onDone:e=>{g(void 0),s(),e&&e!==t&&_(u.map(n=>Qy(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)(L,{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)(G,{size:`sm`,icon:`edit`,label:`rename section ${t}`,onClick:()=>g(t)}),(0,I.jsx)(G,{size:`sm`,icon:`close`,label:`remove section ${t}`,title:`remove the section; its projects move up`,onClick:()=>void _(u.filter(e=>!(Qy(e)&&e.section===t)))})]})]})},`section:${t}`));return}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 ib({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 ab(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 ob({chatPath:e}){let t=we(),n=ye(),r=N(`agents.list`,{},{interval:15e3}),i=N(`channels.list`,{},{interval:6e3}),a=N(`projects.list`,t.projects?{}:null,{interval:15e3}),o=N(`agents.status`,{},{interval:5e3}),s=N(`vibeables.list`,t.vibeables?{}:null,{interval:15e3}),c=new Set((s?.vibeables??[]).map(e=>e.slug)),l=N(`boards.list`,t.boards?{query:{all:`1`}}:null,{interval:15e3}),u=l?.boards??[],d=e=>u.filter(t=>t.project===e),f=u.filter(e=>!e.project),p=N(`presentations.list`,t.presentations?{query:{all:`1`}}:null,{interval:15e3}),m=p?.presentations??[],h=e=>m.filter(t=>t.project===e),g=m.filter(e=>!e.project),_=e.split(`/`).filter(Boolean),y=(e,t)=>_[0]===e&&(t===void 0||(_[1]?decodeURIComponent(_[1]):void 0)===t),b=_[0]===`agents`&&_[1]===`chats`,[x,S]=db(),[C,w]=(0,v.useState)(),T=_[0]===`projects`&&_[1]&&_[1]!==`new`?decodeURIComponent(_[1]):void 0;(0,v.useEffect)(()=>{T&&w(T)},[T]);let E=It()??[],D=new Map((r?.agents??[]).filter(e=>!e.archived).map(e=>[e.slug,e])),O=a?.projects??[],k=e=>(e.agents??[]).map(e=>D.get(e)).filter(e=>!!e),j=e=>y(`projects`,e.slug)||e.slug===C&&k(e).some(e=>y(`agents`,e.slug)),ee=new Map(O.map(e=>[e.slug,e])),M=a?.layout?[...a.layout.top,...a.layout.sections.flatMap(e=>e.projects)].map(e=>ee.get(e)).filter(e=>!!e):O,P=async e=>!!(await A.request(`projects.saveLayout`,{body:e}).catch(()=>null))?.ok,[F,te]=(0,v.useState)(),R=async()=>{if(!a?.layout)return;let e=ab(a.layout);await P({...a.layout,sections:[...a.layout.sections,{name:e,projects:[]}]})&&te(e)},ne=e=>{let n=k(e),r=t.vibeables?(e.vibeables??[]).filter(e=>c.has(e)):[],i=x.open[e.slug]??e.slug===(T??C),a=n.map(e=>o?.[e.slug]).filter(e=>!!e),s=!i&&a.some(e=>e.working.length&&!e.waiting.length);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Z,{size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:y(`projects`,e.slug)&&!i,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:Lt.project(E,e.slug,e.agents).length,title:`waiting for you`}),s&&(0,I.jsx)(K,{tone:`working`,title:`an agent is working`})]}),titleLines:2,actionsAlways:i,actions:(0,I.jsx)(G,{size:`sm`,icon:i?`expand_more`:`chevron_right`,label:`${i?`collapse`:`expand`} ${e.title}`,"aria-expanded":i,title:i?`hide its assistant, agents and apps`:[`the assistant`,n.length&&`${n.length} agent${n.length===1?``:`s`}`,r.length&&`${r.length} app${r.length===1?``:`s`}`].filter(Boolean).join(`, `),onClick:()=>S(t=>({...t,open:{...t.open,[e.slug]:!i}}))})}),i&&(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}`,active:y(`projects`,e.slug),innerProps:{title:`${e.title}'s assistant: knows its brief, state and links`,"data-nested":`assistant`},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:ze.emoji}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:ze.name}),titleExtra:(0,I.jsx)(Qe,{n:E.filter(t=>t.owner.project?.slug===e.slug&&!t.owner.agent).length,title:`waiting for you`})}),i&&n.map(t=>(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/agents/${encodeURIComponent(t.slug)}`,active:y(`agents`,t.slug),onClick:()=>w(e.slug),innerProps:{title:t.description||t.name,"data-nested":`agent`},leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:t.emoji||`🤖`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:t.name}),titleExtra:(0,I.jsx)(lb,{n:Lt.agent(E,t.slug).length,st:o?.[t.slug]})},t.slug)),i&&t.boards&&(d(e.slug).length>0?d(e.slug).map(t=>(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}/boards/${encodeURIComponent(t.board)}`,active:y(`projects`,e.slug)&&_[2]===`boards`&&(_[3]?decodeURIComponent(_[3]):void 0)===t.board,onClick:()=>w(e.slug),innerProps:{title:`${t.title}: ${t.tasks} ${t.tasks===1?`task`:`tasks`}${t.review?`, ${t.review} for review`:``}`,"data-nested":`board`},leading:(0,I.jsx)(L,{name:`view_kanban`,className:`ms-sm`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:t.title}),titleExtra:(0,I.jsx)(Qe,{n:t.review,title:`waiting for review`})},`board:${t.board}`)):(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}/boards`,active:y(`projects`,e.slug)&&_[2]===`boards`,onClick:()=>w(e.slug),innerProps:{title:`the project's tasks as a board, created on first use`,"data-nested":`board`},leading:(0,I.jsx)(L,{name:`view_kanban`,className:`ms-sm`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:`tasks`})})),i&&t.presentations&&(h(e.slug).length>0?h(e.slug).map(t=>(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}/presentations/${encodeURIComponent(t.name)}`,active:y(`projects`,e.slug)&&_[2]===`presentations`&&(_[3]?decodeURIComponent(_[3]):void 0)===t.name,onClick:()=>w(e.slug),innerProps:{title:`${t.title}: ${t.slides} ${t.slides===1?`slide`:`slides`}`,"data-nested":`presentation`},leading:(0,I.jsx)(L,{name:`slideshow`,className:`ms-sm`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:t.title})},`deck:${t.name}`)):(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}/presentations`,active:y(`projects`,e.slug)&&_[2]===`presentations`,onClick:()=>w(e.slug),innerProps:{title:`the project's slide decks`,"data-nested":`presentation`},leading:(0,I.jsx)(L,{name:`slideshow`,className:`ms-sm`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:`presentations`})})),i&&r.map(t=>(0,I.jsx)(Z,{className:sb,size:`sm`,href:`/projects/${encodeURIComponent(e.slug)}?app=${encodeURIComponent(t)}`,onClick:()=>w(e.slug),innerProps:{title:`open ${t} beside the project's chat`,"data-nested":`app`},leading:(0,I.jsx)(L,{name:`web`,className:`ms-sm`}),title:(0,I.jsx)(`span`,{className:`font-medium`,children:t})},`app:${t}`))]})};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)(Z,{href:`/`,active:e===`/`,leading:(0,I.jsx)(L,{name:`home`}),title:`Home`,innerProps:{title:`Today: what needs you, what happened`}}),(0,I.jsx)(Z,{href:`/agents/chats`,active:b,leading:(0,I.jsx)(`span`,{"aria-hidden":!0,children:`🎩`}),title:`Ralv`,titleExtra:(0,I.jsx)(Qe,{n:Lt.general(E).length,title:`waiting for you`}),innerProps:{title:`Chief of staff: knows the workspace, advises, launches things`}}),t.projects&&(0,I.jsxs)(cb,{label:`projects`,href:`/projects`,add:a?.enabled?{href:`/projects/new`,label:`new project`}:void 0,badge:x.all?(0,I.jsx)(Qe,{n:new Set(O.filter(e=>!j(e)).flatMap(e=>Lt.project(E,e.slug,e.agents).map(e=>e.id))).size,title:`waiting in the projects folded away`}):void 0,fold:O.length>0?(0,I.jsxs)(I.Fragment,{children:[!x.all&&a?.layout&&(0,I.jsx)(G,{size:`sm`,icon:`create_new_folder`,label:`new section`,title:`new section: drag projects into it`,onClick:()=>void R()}),(0,I.jsx)(G,{size:`sm`,icon:x.all?`chevron_right`:`expand_more`,label:x.all?`show all projects`:`collapse projects`,"aria-expanded":!x.all,onClick:()=>S(e=>({...e,all:!e.all}))})]}):void 0,children:[x.all||!a?.layout?M.filter(e=>!x.all||j(e)).map(e=>(0,I.jsx)(v.Fragment,{children:ne(e)},e.slug)):(0,I.jsx)(rb,{layout:a.layout,visible:e=>!!ee.get(e)&&j(ee.get(e)),render:e=>ee.get(e)?ne(ee.get(e)):null,onSave:P,collapsed:e=>!!x.sections[e],onCollapse:e=>S(t=>({...t,sections:{...t.sections,[e]:!t.sections[e]}})),editing:F,onEdited:()=>te(void 0)}),x.all&&O.length>0&&(0,I.jsxs)(W,{variant:`quiet`,size:`sm`,icon:`expand_more`,className:`justify-start`,onClick:()=>S(e=>({...e,all:!1})),children:[O.filter(e=>!j(e)).length,` more`]})]}),(0,I.jsx)(cb,{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=Zy(o?.[e.slug],e.description);return(0,I.jsx)(Z,{href:`/agents/${encodeURIComponent(e.slug)}`,active:y(`agents`,e.slug)||y(`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)(lb,{n:Lt.agent(E,e.slug).length,st:o?.[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)})}),t.boards&&(0,I.jsx)(cb,{label:`boards`,href:`/boards`,add:l?.enabled?{href:`/boards/new`,label:`new board`}:void 0,children:f.map(e=>(0,I.jsx)(Z,{href:`/boards/${encodeURIComponent(e.board)}`,active:y(`boards`,e.board),innerProps:{title:`${e.tasks} ${e.tasks===1?`task`:`tasks`}${e.review?`, ${e.review} for review`:``}`},leading:(0,I.jsx)(L,{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`},e.board))}),t.presentations&&(0,I.jsx)(cb,{label:`presentations`,href:`/presentations`,add:p?.enabled?{href:`/presentations/new`,label:`new presentation`}:void 0,children:g.map(e=>(0,I.jsx)(Z,{href:`/presentations/${encodeURIComponent(e.name)}`,active:y(`presentations`,e.name),innerProps:{title:`${e.slides} ${e.slides===1?`slide`:`slides`}`},leading:(0,I.jsx)(L,{name:`slideshow`,className:`ms-sm`}),title:e.title,sub:e.error?`unreadable deck.md`:`${e.slides} ${e.slides===1?`slide`:`slides`}`,subTone:e.error?`bad`:`plain`},e.name))}),(0,I.jsx)(cb,{label:`channels`,href:`/channels`,add:{href:`/channels/new`,label:`new channel`},children:(i?.channels??[]).map(e=>(0,I.jsx)(Z,{href:`/channels/${encodeURIComponent(e.slug)}`,active:y(`channels`,e.slug),leading:(0,I.jsx)(`span`,{"aria-hidden":!0,className:`font-semibold`,children:`#`}),title:e.name,titleExtra:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Qe,{n:Lt.channel(E,e.slug).length,title:`waiting for you`}),e.busy&&!e.awaitingApproval&&(0,I.jsx)(K,{tone:`working`,title:`an agent is working`})]}),sub:e.purpose||(e.members.length?`with ${e.members.map(e=>`@${e}`).join(` `)}`:`no agents yet`)},e.slug))})]})})}var sb=`ml-5 rounded-l-none border-l border-line`;function cb({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)(G,{size:`sm`,icon:`add`,label:n.label,href:n.href}),i]})]}),a]})}function lb({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)(K,{tone:`working`,title:`working`}):null]})}var ub=`kw-rail-fold`;function db(){let[e,t]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(ub)??`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(ub,JSON.stringify(n))}catch{}return n})]}function fb({path:e}){let t=ye(),n=we(),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)(pb,{})}]:[],{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)(L,{name:e.icon,fill:t}),` `,e.label,e.badge]},e.id)})})}function pb(){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 mb=e=>e.replace(/^# .*\n+/,``).replace(/\(human:user\)/g,`(you)`),hb=`flex flex-col gap-1.5 px-1.5 pb-6 pt-3`,gb=`m-0 px-2.5 pb-0.5 text-md leading-[1.45] text-fg`,_b=`m-0 px-2.5 py-0.5 text-sm text-fg-2`,vb=`md-body px-2.5 text-sm leading-normal`,yb=e=>ha.sanitize(zr.parse(mb(e),{async:!1}));function bb(e,t){let n=[],r=``;for(let i of e.split(`
471
+ `)){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 xb({items:e}){return e.length===0?null:(0,I.jsx)(nt,{size:`lg`,title:`needs you`,count:e.length,children:e.map(e=>(0,I.jsx)(Z,{onClick:()=>Wt(e),leading:(0,I.jsx)(L,{name:Rt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${e.owner.agent?`${e.owner.agent.emoji??``} ${e.owner.agent.name} · `:``}${zt(e.kind)} · ${Ge(e.since)}`},e.id))})}function Sb({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)(nt,{size:`lg`,title:r,children:i.map(e=>{let t=Zy(n?.[e.slug],e.description);return(0,I.jsx)(Z,{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 Cb({scope:e}){let t=N(`files.recent`,{query:{scope:e}},{interval:2e4});return!t||t.count===0?null:(0,I.jsx)(nt,{size:`lg`,title:`files`,count:t.count,action:(0,I.jsxs)(W,{variant:`quiet`,size:`sm`,href:Ou(e),children:[`all `,(0,I.jsx)(L,{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)(Z,{href:Ou(e,n,t.path),leading:(0,I.jsx)(L,{name:`draft`,className:`ms-sm`}),title:t.path.split(`/`).pop(),sub:`${n?`${n}/ · `:``}${Ge(t.at)}`},t.path)})})}function wb({of:e}){let t=It()??[],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=bb(i.log,5);return(0,I.jsxs)(`div`,{className:hb,children:[(0,I.jsx)(nt,{size:`lg`,title:`goal`,children:(0,I.jsxs)(`p`,{className:gb,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)(nt,{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:ha.sanitize(zr.parseInline(mb(e.text),{async:!1}))}})]},t))}),(0,I.jsx)(xb,{items:Lt.project(t,i.slug,a)}),(0,I.jsx)(Sb,{slugs:a,agents:n,status:r}),(0,I.jsx)(nt,{size:`lg`,title:`where it stands`,children:i.state.trim()?(0,I.jsx)(`div`,{className:vb,dangerouslySetInnerHTML:{__html:yb(i.state)}}):(0,I.jsx)(`p`,{className:_b,children:`Nothing recorded yet: the project's chat writes this down at the end of a session that changed something.`})}),(0,I.jsx)(Cb,{scope:`project:${i.slug}`}),i.records.length>0&&(0,I.jsx)(nt,{size:`lg`,title:`systems of record`,children:i.records.map((e,t)=>(0,I.jsx)(Z,{onClick:()=>e.url&&window.open(e.url,`_blank`,`noopener`),leading:(0,I.jsx)(L,{name:`open_in_new`,className:`ms-sm`}),title:e.title||e.kind,sub:e.note},t))})]})}if(e.kind===`agent`)return(0,I.jsx)(Tb,{agent:e.agent,journal:e.journal,waiting:t,status:r});if(e.kind===`channel`){let i=e.channel;return(0,I.jsxs)(`div`,{className:hb,children:[(0,I.jsx)(`p`,{className:gb,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)(xb,{items:Lt.channel(t,i.slug)}),(0,I.jsx)(Sb,{slugs:i.members,agents:n,status:r,title:`in this channel`})]})}return(0,I.jsx)(Eb,{waiting:t,agents:n,status:r})}function Tb({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=Zy(r?.[e.slug],e.description),l=i.filter(t=>t.agents.includes(e.slug));return(0,I.jsxs)(`div`,{className:hb,children:[(0,I.jsx)(`p`,{className:gb,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)(xb,{items:Lt.agent(n,e.slug)}),l.length>0&&(0,I.jsx)(nt,{size:`lg`,title:`works on`,children:l.map(e=>(0,I.jsx)(Z,{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)(nt,{size:`lg`,title:`schedule`,children:a.map(e=>(0,I.jsx)(Z,{leading:(0,I.jsx)(L,{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 ${Ge(e.lastRunAt)}`:``}`},e.id))}),(0,I.jsxs)(nt,{size:`lg`,title:`journal`,children:[(0,I.jsx)(Db,{slug:e.slug,onAdded:s}),(0,I.jsx)(`div`,{className:vb,dangerouslySetInnerHTML:{__html:yb(mb(o)||`_Nothing yet: the agent notes what it learns, decides and promises here, and reads it back at the start of every session._`)}})]})]})}function Eb({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:hb,children:[(0,I.jsx)(xb,{items:e}),r?.enabled&&(0,I.jsxs)(nt,{size:`lg`,title:`projects`,count:i.length,children:[i.length===0&&(0,I.jsx)(`p`,{className:_b,children:`No active projects.`}),i.map(t=>{let n=Lt.project(e,t.slug,t.agents).length;return(0,I.jsx)(Z,{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)(Sb,{slugs:t.filter(e=>!e.archived).map(e=>e.slug),agents:t,status:n,title:`agents`}),(0,I.jsx)(Cb,{scope:`workspace`})]})}function Db({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)(Q,{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)(et,{tone:`bad`,children:o})]})}var Ob=[{id:`contacts`,icon:`person`},{id:`places`,icon:`location_on`},{id:`events`,icon:`event`}];function kb(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 Ab(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 jb=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function Mb({chatPath:e,workspace:t}){let n=kb(e),r=`${n.kind}:${`slug`in n?n.slug:``}`,i=we(),a=ye(),[o,s]=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`]:a?[`/settings`,`workspace settings`]:[void 0,``],c=N(`workflows.list`,{},{interval:15e3}),l=N(`runs.list`,{},{interval:6e3}),u=N(`routines.list`,{},{interval:3e4}),[d,f]=(0,v.useState)(null),p=N(`knowledge.list`,{},{interval:15e3}),m=N(`vibeables.list`,i.vibeables?{}:null,{interval:15e3}),h=N(`boards.list`,i.boards&&n.kind===`project`?{query:{project:n.slug}}:null,{interval:15e3}),g=n.kind===`project`?h?.boards??[]:[],[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`overview`}catch{return`overview`}}),[w,T]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>E(`browser`);return window.addEventListener(so,e),()=>window.removeEventListener(so,e)},[]);let E=e=>{C(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}},[D,O]=(0,v.useState)({});(0,v.useEffect)(()=>O(se.current?{vibeables:`/vibeables/${encodeURIComponent(se.current.slug)}`}:{}),[r]);let[k,j]=(0,v.useState)(!1);(0,v.useEffect)(()=>j(!1),[r]);let ee=R(),M=n.kind===`project`?new URLSearchParams(ee.split(`?`)[1]??``).get(`app`):null;(0,v.useEffect)(()=>{M&&(E(`vibeables`),O(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(M)}`})),j(!0))},[M,r]);let P=e=>O(t=>({...t,[z]:e})),[F,te]=(0,v.useState)({dir:``});(0,v.useEffect)(()=>te({dir:``}),[r]);let ne=async(e,t,n)=>{(await A.request(`projects.link`,{slug:e,body:{kind:`vibeables`,target:t,remove:n}}).catch(()=>null))?.ok&&x(e=>e+1)},re=()=>{j(!1),O(e=>({...e,[z]:null}))},ie=e=>t=>t.startsWith(e)?(O(e=>({...e,[z]:t})),!0):!1,[ae,oe]=(0,v.useState)(null),se=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;se.current=t,oe(t),t?(E(`vibeables`),O(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):O(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(_a,e),()=>window.removeEventListener(_a,e)},[]);let ce=i.repos&&!!_?.repos,le=n.kind===`project`?`project:${n.slug}`:_?.channel?.project?`project:${_.channel.project}`:`workspace`,ue=[{id:`overview`,label:`overview`},{id:`files`,label:`files`,allHref:`/files/${encodeURIComponent(le)}`},{id:`knowledge`,label:`knowledge`,count:_?.knowledge.length,allHref:`/knowledge`},...i.vibeables?[{id:`vibeables`,label:`apps`,count:_?.all?m?.vibeables.length:_?.vibeables?.length??0,allHref:`/vibeables`}]:[],{id:`workflows`,label:`workflows`,count:_?.workflows.length,allHref:`/workflows`},...i.boards&&n.kind===`project`?[{id:`board`,label:`boards`,count:g.reduce((e,t)=>e+t.review,0)||void 0,allHref:`/projects/${encodeURIComponent(n.slug)}/boards`}]:[],...a&&ce?[{id:`repos`,label:`repositories`,count:_?.repos?.length,allHref:`/repos`}]:[],...Ob.filter(e=>i[e.id]&&_?.[e.id]).map(e=>({id:e.id,label:e.id,count:_?.[e.id]?.length,allHref:`/${e.id}`})),...w>0||S===`browser`?[{id:`browser`,label:`browser`,count:w}]:[]],z=ue.some(e=>e.id===S)?S:`overview`,B=ue.find(e=>e.id===z),V=D[z]??null,H=!!ae&&z===`vibeables`&&V===`/vibeables/${encodeURIComponent(ae.slug)}`,fe=z===`vibeables`&&!!V,pe=k&&fe,he=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),P(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>x(e=>e+1),15e3);return()=>clearInterval(e)},[]);let ge=de(ee),_e=(0,v.useRef)(ge);(0,v.useEffect)(()=>{_e.current&&!ge&&x(e=>e+1),_e.current=ge},[ge]),(0,v.useEffect)(()=>{let e=!0,r=new Set((c?.workflows??[]).map(e=>e.slug)),i=new Set((p?.bundles??[]).map(e=>e.name)),a=new Set((m?.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:jb(e.workflows,r),knowledge:jb(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=jb(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:jb(s(e=>e.workflows),r),knowledge:jb(s(e=>e.knowledge),i),...c.length>0?{vibeables:jb(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:jb([...r],r),knowledge:jb([...i],i),all:!0};e&&y(o)})(),()=>{e=!1}},[r,b,c,p,m,t.name,t.icon]);let ve=e=>c?.workflows.find(t=>t.slug===e),be=e=>e?l?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,xe=e=>p?.bundles.find(t=>t.name===e),Se=e=>m?.vibeables.find(t=>t.slug===e),Ce=e=>(0,I.jsxs)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:[_?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,_?.editHref&&a&&!_.all&&(0,I.jsxs)(I.Fragment,{children:[` `,(0,I.jsx)(U,{href:_.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:[(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:_?.title,children:_?_.title:`…`},_?.title??``),o&&(0,I.jsx)(U,{href:o,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:s,"aria-label":s,children:(0,I.jsx)(L,{name:`edit`,className:`ms-sm`})})]}),(0,I.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,"data-full":pe||void 0,children:[(0,I.jsx)(pt,{className:`flex-none gap-y-0.5 pt-2`,label:`Categories`,items:ue,value:z,onChange:E}),V&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2`,children:[(0,I.jsx)(W,{variant:`quiet`,size:`sm`,icon:`arrow_back`,onClick:re,"aria-label":`Back to the list`,children:B?.label}),(0,I.jsx)(`span`,{className:`flex-1`}),fe&&(0,I.jsx)(W,{variant:`quiet`,size:`sm`,icon:pe?`close_fullscreen`:`open_in_full`,onClick:()=>j(!pe),title:pe?`back beside the chat`:`full size, in place of the chat`,children:pe?`beside the chat`:`full size`}),(0,I.jsx)(W,{variant:`quiet`,size:`sm`,icon:`open_in_new`,href:V,title:`Open as a page`,children:`page`})]}),V&&z===`knowledge`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(me.Provider,{value:ie(`/knowledge/`),children:(()=>{let e=V.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,I.jsx)(Ol,{name:t,conceptId:n},t)})()})}),V&&z===`workflows`&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,I.jsx)(me.Provider,{value:ie(`/workflows/`),children:(()=>{let e=V.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,I.jsx)(Uc,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),V&&z===`vibeables`&&!H&&(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,I.jsx)(xa,{slug:decodeURIComponent(V.split(`/`).filter(Boolean)[1]??``)},V)}),(0,I.jsx)(`div`,{id:va,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!H}),(0,I.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:z!==`browser`,children:(0,I.jsx)(ho,{storeKey:r,onTabs:T},r)}),(0,I.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:z===`browser`||!!V&&[`knowledge`,`workflows`,`vibeables`].includes(z),children:[B?.allHref&&(0,I.jsx)(`div`,{className:`flex justify-end px-1 pb-1`,children:(0,I.jsxs)(W,{variant:`quiet`,size:`sm`,href:B.allHref,children:[`all `,B.label,` `,(0,I.jsx)(L,{name:`arrow_forward`,className:`ms-sm`})]})}),z===`workflows`&&(0,I.jsxs)(I.Fragment,{children:[_&&_.workflows.length===0&&Ce(`workflows`),_?.workflows.map(({slug:e,found:t})=>{let n=ve(e),r=be(n),i=t&&!!n&&!n.error,a=(u?.routines??[]).filter(t=>t.workflows.includes(e));return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(Z,{href:`/workflows/${encodeURIComponent(e)}`,onClick:t?he(`/workflows/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(K,{tone:!t||n?.error?`bad`:Pb(r?.status)}),title:n?.name??e,sub:t?n?.error?`broken`:r?`${r.status} · ${Ge(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`,actionsAlways:!0,actions:i?(0,I.jsx)(G,{size:`sm`,icon:d===e?`close`:`play_arrow`,label:d===e?`close the launcher of ${n.name??e}`:`run ${n.name??e}`,"aria-expanded":d===e,onClick:()=>f(d===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)(L,{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 ${Ab(e.nextRunAt)}`:e.schedule:`paused`]})]},`${e.agent.slug}/${e.id}`)),d===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)(Mc,{slug:e,usesRequest:n.usesRequest,onLaunched:()=>{f(null),P(`/workflows/${encodeURIComponent(e)}`)}})})]},e)})]}),z===`knowledge`&&(0,I.jsxs)(I.Fragment,{children:[_&&_.knowledge.length===0&&Ce(`knowledge`),_?.knowledge.map(({slug:e,found:t})=>{let n=xe(e);return(0,I.jsx)(Z,{href:`/knowledge/${encodeURIComponent(e)}`,onClick:t?he(`/knowledge/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(L,{name:`menu_book`,className:`ms-sm`}),title:e,sub:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${Ge(n.updatedAt)}`:``}`:void 0:`not in this workspace`},e)})]}),z===`vibeables`&&_&&(0,I.jsxs)(I.Fragment,{children:[(_.all?(m?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):_.vibeables??[]).map(({slug:e,found:t})=>{let r=Se(e);return(0,I.jsx)(Z,{href:`/vibeables/${encodeURIComponent(e)}`,onClick:t?he(`/vibeables/${encodeURIComponent(e)}`):void 0,dim:!t,leading:(0,I.jsx)(L,{name:`web`,className:`ms-sm`}),title:e,sub:t?r?.updatedAt?`changed ${Ge(r.updatedAt)}`:void 0:`not in this workspace`,actions:n.kind===`project`?(0,I.jsx)(G,{icon:`keep_off`,size:`sm`,label:`unpin ${e}`,onClick:()=>void ne(n.slug,e,!0)}):void 0},e)}),n.kind===`project`&&m&&(0,I.jsx)(Nb,{options:m.vibeables.map(e=>e.slug).filter(e=>!_.vibeables?.some(t=>t.slug===e)),onPin:e=>void ne(n.slug,e,!1)}),_.all&&m&&m.vibeables.length===0&&Ce(`vibeables`),!_.all&&_.vibeables?.length===0&&Ce(`vibeables`)]}),Ob.map(e=>z===e.id&&_?.[e.id]&&(0,I.jsxs)(v.Fragment,{children:[_[e.id].length===0&&Ce(e.id),_[e.id].map(({slug:t,found:n,label:r})=>(0,I.jsx)(Z,{href:`/${e.id}/${encodeURIComponent(t)}`,dim:!n,leading:(0,I.jsx)(L,{name:e.icon,className:`ms-sm`}),title:n&&r?r:t,sub:n?r?t:void 0:`not in this workspace`},t))]},e.id)),z===`board`&&n.kind===`project`&&(0,I.jsxs)(I.Fragment,{children:[h&&h.enabled&&g.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.`]}),h&&!h.enabled&&(0,I.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-fg-2`,children:h.error}),g.map(e=>(0,I.jsx)(Qd,{project:n.slug,board:e.board},e.board))]}),z===`repos`&&_?.repos&&(0,I.jsxs)(I.Fragment,{children:[_.repos.length===0&&Ce(`repositories`),_.repos.map(({slug:e,found:t})=>(0,I.jsx)(Z,{href:`/repos/${encodeURIComponent(e)}`,dim:!t,leading:(0,I.jsx)(L,{name:`source`,className:`ms-sm`}),title:e,sub:t?void 0:`not in this workspace`},e))]}),z===`overview`&&_&&(0,I.jsx)(wb,{of:_.project?{kind:`project`,project:_.project}:_.agent?{kind:`agent`,agent:_.agent,journal:_.journal??``}:_.channel?{kind:`channel`,channel:_.channel}:{kind:`workspace`}},r),z===`files`&&(0,I.jsx)(Fu,{compact:!0,scope:le,dir:F.dir,file:F.file,onOpen:(e,t)=>te({dir:e,file:t})},le)]},z)]})]})}function Nb({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)(L,{name:`keep`,className:`ms-sm`}),(0,I.jsxs)(vt,{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 Pb(e){return e===`ok`?`ok`:e===`failed`?`bad`:e===`running`?`working`:`idle`}var Fb=`kw-chat-path`,Ib=`kw-ctx-w`,Lb=()=>{try{let e=Number(localStorage.getItem(Ib));return e>0?e:null}catch{return null}};function Rb({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 zb=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},Bb=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function Vb(){let e=R();qt();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=z(t),b=le.has(n[0]??``)&&!_&&!y,x=n.length===0,[S,C]=(0,v.useState)(()=>zb(Fb,`/agents/chats`)),w=b?Xs(t):null,T=b&&!w?t:S,[E,D]=(0,v.useState)(`chat`),[O,k]=(0,v.useState)(Lb),A=e=>{k(e);try{e===null?localStorage.removeItem(Ib):localStorage.setItem(Ib,String(e))}catch{}};(0,v.useEffect)(()=>{D(e=>e===`side`?`chat`:e)},[e]),(0,v.useEffect)(()=>{b&&!Xs(t)&&(C(t),Bb(Fb,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;B(t)===`chat`?(C(t),Bb(Fb,t)):window.location.replace(`#${t}`)};return window.addEventListener(V,e),()=>window.removeEventListener(V,e)},[]);let j=N(`meta.get`,{},{interval:3e4});(0,v.useEffect)(()=>{let e=j;e&&(i(e.workspaceName??``),o(e.workspaceIcon??``),c(e.workspaceColor??``),u(e.workspaceNamed!==!1),f(e.workspaceRootLabel??``),m(e.workspaceRoot??``),Ce({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:[]))},[j]),(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 ee=T.split(`/`).filter(Boolean),M=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,P;P=ee[0]===`chats`?(0,I.jsx)(Ys,{seg:ee}):ee[0]===`projects`?(0,I.jsx)(rs,{seg:ee.slice(1)}):ee[0]===`channels`?(0,I.jsx)(Ma,{seg:ee.slice(1)}):(0,I.jsx)(Ys,{seg:ee.slice(1)});let F=null;return _?F=(0,I.jsx)(Jd,{seg:n.slice(3),project:decodeURIComponent(n[1])}):y?F=(0,I.jsx)(ly,{seg:n.slice(3),project:decodeURIComponent(n[1])}):n[0]===`runs`&&n[1]?F=(0,I.jsx)(oc,{id:n[1],workflow:M}):n[0]===`runs`?F=(0,I.jsx)(Zb,{}):n[0]===`workflows`?F=(0,I.jsx)(Qc,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?F=(0,I.jsx)(Aa,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?F=(0,I.jsx)(xl,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?F=(0,I.jsx)(Rl,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?F=(0,I.jsx)(wu,{}):n[0]===`trash`?F=(0,I.jsx)(Eu,{}):n[0]===`ui`?F=(0,I.jsx)(Ru,{}):n[0]===`files`?F=(0,I.jsx)(Nu,{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`?F=(0,I.jsx)(Hu,{}):n[0]===`git`?F=(0,I.jsx)(ed,{}):n[0]===`repos`?F=(0,I.jsx)(fd,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`contacts`||n[0]===`places`||n[0]===`events`?F=(0,I.jsx)(wd,{kind:n[0],slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`boards`?F=(0,I.jsx)(Jd,{seg:n.slice(1)}):n[0]===`presentations`&&(F=(0,I.jsx)(ly,{seg:n.slice(1)})),(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?Ie(Ee(s,t)):null;if(!n){delete e.dataset.wsAccent;return}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":Ee(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)(Re,{size:`sm`,icon:a,name:r,color:s,seed:p||r}):(0,I.jsx)(L,{name:`home`})}),r&&(0,I.jsx)(Xb,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,I.jsx)(fb,{path:t}),(0,I.jsx)(`span`,{className:`flex-[1_1_8px]`}),(0,I.jsx)(Ky,{}),(0,I.jsx)(G,{icon:`settings`,label:`settings`,href:`/settings`,"aria-current":n[0]===`settings`?`page`:void 0}),(0,I.jsx)(ex,{}),(0,I.jsx)(Kt,{}),(0,I.jsx)(rx,{}),(0,I.jsx)($b,{})]}),F&&(0,I.jsx)(`main`,{className:`shell shell-global`,children:F}),(0,I.jsxs)(`main`,{className:`shell three${x?` home`:``}`,"data-focus":E,hidden:!!F,style:O?{"--ctx-w":`${O}px`}:void 0,children:[(0,I.jsx)(ob,{chatPath:x?`/`:T}),(0,I.jsxs)(`section`,{className:`col-chat`,"aria-label":x?`Dashboard`:`Conversation`,children:[x?(0,I.jsx)(il,{}):P,(0,I.jsx)(Rb,{onResize:A})]}),(0,I.jsx)(Mb,{chatPath:x?`/`:T,workspace:{name:r,icon:a}}),w&&(0,I.jsx)(Zs,{back:T,children:w})]}),!F&&(0,I.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,I.jsxs)(`button`,{className:E===`side`?`active`:``,onClick:()=>D(`side`),children:[(0,I.jsx)(L,{name:`menu`}),` list`]}),(0,I.jsxs)(`button`,{className:E===`chat`?`active`:``,onClick:()=>D(`chat`),children:[(0,I.jsx)(L,{name:`forum`}),` chat`]}),(0,I.jsxs)(`button`,{className:E===`context`?`active`:``,onClick:()=>D(`context`),children:[(0,I.jsx)(L,{name:`account_tree`}),` context`]})]})]})}function Hb(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 Ub=`truncate text-sm text-fg-2 group-aria-[current=true]/ws:text-on-accent-soft group-aria-[current=true]/ws:opacity-80`,Wb=`group/ws relative flex min-h-[60px] items-center gap-3.5 px-4 py-2.5 text-fg no-underline transition-colors`;function Gb({label:e}){return e?(0,I.jsx)(`span`,{className:P(Ub,`[direction:rtl] text-left`),title:e,children:(0,I.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})}):null}function Kb({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 qb({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 pe(e.root))}catch(e){r(`error`),a(e.message)}};return(0,I.jsxs)(`span`,{className:P(Wb,`cursor-default`),role:`menuitem`,"data-stopped":``,"data-missing":o?``:void 0,style:{"--ws-c":Ee(e.color,e.root??e.url)},children:[(0,I.jsx)(Re,{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)(Kb,{name:e.name,named:e.named}),n===`error`?(0,I.jsx)(`span`,{className:P(Ub,`text-bad`),title:i,children:i}):o?(0,I.jsx)(`span`,{className:Ub,children:`folder missing`}):(0,I.jsx)(Gb,{label:e.rootLabel})]}),(0,I.jsxs)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:[(0,I.jsx)(Jb,{entry:e}),(0,I.jsx)(W,{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 Jb({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)(K,{tone:`ok`,title:`running`}),!e.here&&(0,I.jsx)(`span`,{className:`max-[800px]:hidden`,children:Hb(e.url)})]})}function Yb({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,I.jsxs)(`a`,{className:P(Wb,`hover:bg-surface-2 active:bg-surface-2`),role:`menuitem`,href:fe(e),style:{"--ws-c":Ee(e.color,n)},children:[(0,I.jsx)(Re,{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)(Kb,{name:e.name,named:e.named}),(0,I.jsx)(Gb,{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)(Jb,{entry:e})})]})}function Xb({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=ye();(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)(L,{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)(tt,{className:`block px-4 pt-1 pb-2`,children:`workspaces`}),(0,I.jsxs)(`span`,{className:P(Wb,`cursor-default bg-accent-soft text-on-accent-soft`),"aria-current":`true`,style:{"--ws-c":Ee(n,p)},children:[(0,I.jsx)(Re,{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)(Kb,{name:e,named:r}),i?(0,I.jsx)(Gb,{label:i}):(0,I.jsx)(`span`,{className:Ub,children:`this workspace`})]}),(0,I.jsx)(`span`,{className:`ml-auto inline-flex flex-none items-center gap-3`,children:(0,I.jsx)(L,{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)(tt,{className:`block px-4 pt-2 pb-1`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,I.jsx)(qb,{entry:e,ambiguous:d(e.icon)},e.root):(0,I.jsx)(Yb,{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)(L,{name:`hub`,className:`text-[22px] text-fg-2`}),` manage workspaces`]}),(0,I.jsx)(ox,{onClose:()=>c(!1)})]})]})}function Zb(){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 Qb(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 $b(){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 Qb(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)(L,{name:`restart_alt`,className:`ms-sm`}),` v`,r,` ready — relaunch`]})})}function ex(){let e=ye();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:()=>ve(!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 tx={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`},nx=`kw.notif.toast.dismissed`;function rx(){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(nx)===`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=It()??[],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));return}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(nx,`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)(L,{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)(tt,{className:`text-fg`,children:`notifications`}),(0,I.jsx)(`span`,{className:`flex-1`}),g>0&&(0,I.jsx)(W,{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)(W,{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)(W,{variant:`primary`,size:`sm`,onClick:()=>void w(),children:`enable`}),(0,I.jsx)(W,{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)(nt,{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`}):ax(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)(Z,{className:`notif-row need`,onClick:()=>{t(!1),Wt(e)},leading:(0,I.jsx)(L,{name:Rt(e.kind),className:`ms-sm text-bad`}),title:e.title,sub:`${zt(e.kind)}${e.chatTitle?` · in ${e.chatTitle}`:``}`,meta:Ge(e.since),actionsAlways:!0,actions:n?.diagnose?(0,I.jsx)(ix,{busy:u===n.id,onClick:()=>void C(n)}):void 0},e.id)})]},e))}),(0,I.jsx)(nt,{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)(Z,{className:P(`notif-row`,!e.readAt&&`bg-accent/5`),onClick:()=>S(e),leading:(0,I.jsx)(L,{name:tx[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:Ge(e.at),actionsAlways:!0,actions:e.diagnose?(0,I.jsx)(ix,{busy:u===e.id,onClick:()=>void C(e)}):void 0},e.id))})]})]})]})}function ix({busy:e,onClick:t}){return(0,I.jsx)(W,{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 ax(e){let t=new Map;for(let n of e){let e=Bt(n.owner);t.set(e,[...t.get(e)??[],n])}return[...t.entries()]}function ox({onClose:e}){let t=ye(),[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)(sx,{label:`Theme`,children:(0,I.jsx)(fx,{})}),(0,I.jsx)(`div`,{className:`flex gap-1 px-1`,children:(0,I.jsx)(W,{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)(tt,{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)(tt,{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)(sx,{label:(0,I.jsx)(`span`,{className:`font-mono`,children:o?`kraftwerk ${o}`:`…`}),children:(0,I.jsx)(lx,{})})]})}function sx({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 cx(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 lx(){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(ux,`basis-full flex-wrap`),children:[(0,I.jsx)(L,{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(`
472
+ `),children:e})]}):i.state===`done`?(0,I.jsxs)(`span`,{className:P(ux,dx),children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,I.jsx)(W,{size:`sm`,icon:`restart_alt`,busy:c,onClick:()=>{l(!0),Qb(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(ux,`basis-full flex-wrap text-bad`),title:i.log.join(`
473
+ `),children:[(0,I.jsx)(L,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,I.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?cx(n.current,n.latest)?(0,I.jsxs)(`span`,{className:P(ux,dx),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)(W,{size:`sm`,icon:`download`,onClick:()=>void f(),children:`update now`})]}):(0,I.jsxs)(`span`,{className:ux,children:[(0,I.jsx)(L,{name:`check`,className:`ms-sm text-ok`}),` up to date`]}):(0,I.jsx)(W,{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 ux=`inline-flex items-center gap-[5px] text-xs text-fg-2`,dx=`basis-full flex-wrap font-medium text-accent`;function fx(){return(0,I.jsx)(W,{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)(su,{children:(0,I.jsx)(Vb,{})})}));export{o as a,d as i,te as n,s as o,h as r,l as s,vl as t};