stageflow 0.27.0 → 0.30.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.
- package/README.md +4 -0
- package/builtin-skills/browser/SKILL.md +42 -0
- package/dist/agent/claudeAdapter.js +2 -2
- package/dist/agent/cursorProvider.d.ts +2 -0
- package/dist/agent/cursorProvider.js +30 -5
- package/dist/agent/fakeAgent.d.ts +1 -0
- package/dist/agent/fakeAgent.js +13 -0
- package/dist/agent/piAdapter.d.ts +3 -24
- package/dist/agent/piAdapter.js +49 -47
- package/dist/agent/piSessionFactory.d.ts +38 -0
- package/dist/agent/piSessionFactory.js +60 -0
- package/dist/agent/port.d.ts +2 -0
- package/dist/agent/streamLogRedact.d.ts +6 -0
- package/dist/agent/streamLogRedact.js +23 -1
- package/dist/browser/anchor.d.ts +27 -0
- package/dist/browser/anchor.js +127 -0
- package/dist/browser/auditSink.d.ts +38 -0
- package/dist/browser/auditSink.js +34 -0
- package/dist/browser/browserHost.d.ts +86 -0
- package/dist/browser/browserHost.js +7 -0
- package/dist/browser/browserSweep.d.ts +14 -0
- package/dist/browser/browserSweep.js +54 -0
- package/dist/browser/browserTeardown.d.ts +56 -0
- package/dist/browser/browserTeardown.js +235 -0
- package/dist/browser/fakeRemoteBrowserHost.d.ts +2 -0
- package/dist/browser/fakeRemoteBrowserHost.js +34 -0
- package/dist/browser/gateHandoff.d.ts +25 -0
- package/dist/browser/gateHandoff.js +83 -0
- package/dist/browser/humanLogin.d.ts +18 -0
- package/dist/browser/humanLogin.js +34 -0
- package/dist/browser/keyProvider.d.ts +10 -0
- package/dist/browser/keyProvider.js +39 -0
- package/dist/browser/localBrowserHost.d.ts +10 -0
- package/dist/browser/localBrowserHost.js +152 -0
- package/dist/browser/localProfileLock.d.ts +2 -0
- package/dist/browser/localProfileLock.js +218 -0
- package/dist/browser/localProfileStore.d.ts +5 -0
- package/dist/browser/localProfileStore.js +91 -0
- package/dist/browser/loginCheck.d.ts +53 -0
- package/dist/browser/loginCheck.js +147 -0
- package/dist/browser/memoryProfileLock.d.ts +2 -0
- package/dist/browser/memoryProfileLock.js +53 -0
- package/dist/browser/memoryProfileStore.d.ts +2 -0
- package/dist/browser/memoryProfileStore.js +31 -0
- package/dist/browser/navigationAudit.d.ts +16 -0
- package/dist/browser/navigationAudit.js +53 -0
- package/dist/browser/persistedEnv.d.ts +3 -0
- package/dist/browser/persistedEnv.js +15 -0
- package/dist/browser/profileLock.d.ts +40 -0
- package/dist/browser/profileLock.js +10 -0
- package/dist/browser/profileStore.d.ts +23 -0
- package/dist/browser/profileStore.js +39 -0
- package/dist/browser/runLiveness.d.ts +13 -0
- package/dist/browser/runLiveness.js +39 -0
- package/dist/browser/sitePolicy.d.ts +10 -0
- package/dist/browser/sitePolicy.js +61 -0
- package/dist/browser/stageBrowserEnv.d.ts +22 -0
- package/dist/browser/stageBrowserEnv.js +147 -0
- package/dist/browser/stageProfileLock.d.ts +17 -0
- package/dist/browser/stageProfileLock.js +39 -0
- package/dist/cli/browserCommand.d.ts +44 -0
- package/dist/cli/browserCommand.js +472 -0
- package/dist/cli/hostClient.d.ts +20 -0
- package/dist/cli/hostClient.js +36 -2
- package/dist/cli/initCommand.d.ts +1 -0
- package/dist/cli/initCommand.js +23 -7
- package/dist/cli/initTemplates.d.ts +5 -2
- package/dist/cli/initTemplates.js +25 -2
- package/dist/cli/runsCommand.js +6 -2
- package/dist/cli/triggerCommand.d.ts +12 -0
- package/dist/cli/triggerCommand.js +183 -0
- package/dist/cli/validateCommand.d.ts +1 -1
- package/dist/cli/validateCommand.js +23 -6
- package/dist/cli.js +31 -2
- package/dist/config/browseCatalog.d.ts +1 -0
- package/dist/config/browseCatalog.js +5 -4
- package/dist/config/builtinSkills.d.ts +4 -0
- package/dist/config/builtinSkills.js +23 -0
- package/dist/config/catalogRelativePath.d.ts +1 -0
- package/dist/config/catalogRelativePath.js +10 -2
- package/dist/config/createTrigger.d.ts +27 -0
- package/dist/config/createTrigger.js +232 -0
- package/dist/config/draftPackage.d.ts +117 -0
- package/dist/config/draftPackage.js +550 -0
- package/dist/config/ensureCatalogScanRoot.d.ts +16 -0
- package/dist/config/ensureCatalogScanRoot.js +73 -0
- package/dist/config/hostConfig.d.ts +2 -0
- package/dist/config/hostConfig.js +27 -0
- package/dist/config/listSkills.d.ts +2 -2
- package/dist/config/listSkills.js +17 -3
- package/dist/config/loadOutcome.d.ts +6 -0
- package/dist/config/loadPipeline.js +16 -0
- package/dist/config/loadStage.js +7 -0
- package/dist/config/loadStageflowManifest.js +25 -0
- package/dist/config/loadTrigger.d.ts +9 -0
- package/dist/config/loadTrigger.js +120 -0
- package/dist/config/multiProjectCatalog.d.ts +2 -0
- package/dist/config/multiProjectCatalog.js +26 -18
- package/dist/config/normalizePipelineStageEntry.js +8 -1
- package/dist/config/parseCompletionContract.js +6 -0
- package/dist/config/pipelineStageKeys.js +1 -0
- package/dist/config/publishDraftPackage.d.ts +7 -0
- package/dist/config/publishDraftPackage.js +25 -0
- package/dist/config/resolveCatalogContext.js +1 -1
- package/dist/config/resolvePipelineDag.js +1 -1
- package/dist/config/scanCatalogPaths.d.ts +1 -1
- package/dist/config/scanCatalogPaths.js +6 -2
- package/dist/config/stageBrowser.d.ts +12 -0
- package/dist/config/stageBrowser.js +118 -0
- package/dist/config/triggerCatalog.d.ts +10 -0
- package/dist/config/triggerCatalog.js +37 -0
- package/dist/config/validateCatalog.d.ts +13 -3
- package/dist/config/validateCatalog.js +83 -2
- package/dist/config/validateCompletionContract.js +8 -0
- package/dist/envelope/preEmitChecks.d.ts +1 -1
- package/dist/envelope/preEmitChecks.js +8 -0
- package/dist/logging/redact.d.ts +4 -0
- package/dist/logging/redact.js +17 -0
- package/dist/mcp/catalogTools.js +43 -8
- package/dist/mcp/controlTools.js +3 -1
- package/dist/mcp/deps.d.ts +2 -0
- package/dist/mcp/server.js +1 -0
- package/dist/mcp/tools.js +2 -0
- package/dist/mcp/triggerTools.d.ts +3 -0
- package/dist/mcp/triggerTools.js +176 -0
- package/dist/operatorAgent/docsRetrieval.d.ts +40 -0
- package/dist/operatorAgent/docsRetrieval.js +269 -0
- package/dist/operatorAgent/draftContext.d.ts +16 -0
- package/dist/operatorAgent/draftContext.js +68 -0
- package/dist/operatorAgent/fakeHost.d.ts +39 -0
- package/dist/operatorAgent/fakeHost.js +92 -0
- package/dist/operatorAgent/host.d.ts +40 -0
- package/dist/operatorAgent/host.js +179 -0
- package/dist/operatorAgent/index.d.ts +9 -0
- package/dist/operatorAgent/index.js +8 -0
- package/dist/operatorAgent/piModel.d.ts +80 -0
- package/dist/operatorAgent/piModel.js +528 -0
- package/dist/operatorAgent/profiles/workshopAuthor.d.ts +23 -0
- package/dist/operatorAgent/profiles/workshopAuthor.js +338 -0
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.d.ts +6 -0
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.js +103 -0
- package/dist/operatorAgent/profiles/workshopAuthorTools.d.ts +57 -0
- package/dist/operatorAgent/profiles/workshopAuthorTools.js +623 -0
- package/dist/operatorAgent/proposals.d.ts +32 -0
- package/dist/operatorAgent/proposals.js +144 -0
- package/dist/operatorAgent/types.d.ts +128 -0
- package/dist/operatorAgent/types.js +1 -0
- package/dist/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/project/findManifestRoot.d.ts +3 -0
- package/dist/project/findManifestRoot.js +35 -0
- package/dist/project/resolveStageflowContext.d.ts +7 -0
- package/dist/project/resolveStageflowContext.js +44 -28
- package/dist/runstore/assertTmpdir.js +6 -2
- package/dist/runstore/port.d.ts +28 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +8 -1
- package/dist/runstore/sqlite/SqliteRunStore.js +90 -0
- package/dist/runstore/sqlite/migrations/008-triggers-table.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/008-triggers-table.js +19 -0
- package/dist/runstore/sqlite/migrations/009-trigger-next-run.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/009-trigger-next-run.js +19 -0
- package/dist/runstore/sqlite/migrations/010-trigger-adapter-state.d.ts +7 -0
- package/dist/runstore/sqlite/migrations/010-trigger-adapter-state.js +17 -0
- package/dist/runstore/sqlite/migrations/index.js +6 -0
- package/dist/runtime/answerResume.d.ts +1 -0
- package/dist/runtime/answerResume.js +3 -1
- package/dist/runtime/completionCheckRunner.d.ts +12 -1
- package/dist/runtime/completionCheckRunner.js +22 -0
- package/dist/runtime/credentialBinding.d.ts +2 -0
- package/dist/runtime/credentialBinding.js +3 -0
- package/dist/runtime/emailSource.d.ts +72 -0
- package/dist/runtime/emailSource.js +304 -0
- package/dist/runtime/githubPollSource.d.ts +86 -0
- package/dist/runtime/githubPollSource.js +284 -0
- package/dist/runtime/pipelineRunner.d.ts +4 -0
- package/dist/runtime/pipelineRunner.js +3 -0
- package/dist/runtime/pipelineScheduler.d.ts +2 -0
- package/dist/runtime/pipelineScheduler.js +85 -1
- package/dist/runtime/repositoryMaterialize.d.ts +1 -1
- package/dist/runtime/runManager.d.ts +11 -0
- package/dist/runtime/runManager.js +149 -1
- package/dist/runtime/runRetryCoordinator.d.ts +2 -0
- package/dist/runtime/runRetryCoordinator.js +1 -0
- package/dist/runtime/scheduleSource.d.ts +38 -0
- package/dist/runtime/scheduleSource.js +119 -0
- package/dist/runtime/settingsFile.d.ts +5 -0
- package/dist/runtime/settingsFile.js +61 -54
- package/dist/runtime/stageAttemptBootstrap.js +55 -3
- package/dist/runtime/stageEnvironment.js +1 -0
- package/dist/runtime/stageHitl.d.ts +1 -0
- package/dist/runtime/stageHitl.js +5 -1
- package/dist/runtime/stageProcessLauncher.d.ts +2 -0
- package/dist/runtime/stageProcessLauncher.js +44 -5
- package/dist/runtime/stageRunner.d.ts +5 -0
- package/dist/runtime/stageRunner.js +30 -6
- package/dist/runtime/stageStreamLog.d.ts +1 -0
- package/dist/runtime/stageStreamLog.js +2 -1
- package/dist/runtime/triggerCatalog.d.ts +6 -0
- package/dist/runtime/triggerCatalog.js +24 -0
- package/dist/runtime/triggerEventMatch.d.ts +2 -0
- package/dist/runtime/triggerEventMatch.js +6 -0
- package/dist/runtime/triggerPort.d.ts +14 -0
- package/dist/runtime/triggerPort.js +1 -0
- package/dist/runtime/triggerRunner.d.ts +17 -0
- package/dist/runtime/triggerRunner.js +89 -0
- package/dist/runtime/verifiedStageExecution.d.ts +7 -0
- package/dist/runtime/verifiedStageExecution.js +14 -0
- package/dist/runtime/webhookSignature.d.ts +1 -0
- package/dist/runtime/webhookSignature.js +12 -0
- package/dist/server/bootstrap.d.ts +6 -0
- package/dist/server/bootstrap.js +64 -0
- package/dist/server/controlToken.js +13 -0
- package/dist/server/createHttpHost.js +3 -0
- package/dist/server/healthSurfaces.js +31 -6
- package/dist/server/http.d.ts +15 -0
- package/dist/server/http.js +1251 -74
- package/dist/server/requestAuthContext.d.ts +1 -1
- package/dist/server/triggerRoutes.d.ts +15 -0
- package/dist/server/triggerRoutes.js +268 -0
- package/dist/tools/askOperator.d.ts +3 -2
- package/dist/types/completion.d.ts +3 -0
- package/dist/types/pipeline.d.ts +3 -1
- package/dist/types/preEmitCheck.d.ts +7 -0
- package/dist/types/stage.d.ts +14 -0
- package/dist/types/stageflowManifest.d.ts +3 -0
- package/dist/types/trigger.d.ts +18 -0
- package/dist/types/trigger.js +1 -0
- package/dist/ui/assets/{index-CSsDued1.css → index-Bv4p1aPK.css} +1 -1
- package/dist/ui/assets/index-CntB4bZR.js +133 -0
- package/dist/ui/index.html +2 -2
- package/dist/workshop/autosave.d.ts +58 -0
- package/dist/workshop/autosave.js +222 -0
- package/dist/workshop/buildStore.d.ts +79 -0
- package/dist/workshop/buildStore.js +326 -0
- package/dist/workshop/chatTurn.d.ts +232 -0
- package/dist/workshop/chatTurn.js +475 -0
- package/dist/workshop/modelSettings.d.ts +18 -0
- package/dist/workshop/modelSettings.js +44 -0
- package/dist/workshop/sessionStore.d.ts +61 -0
- package/dist/workshop/sessionStore.js +254 -0
- package/dist/workshop/workshopPin.d.ts +72 -0
- package/dist/workshop/workshopPin.js +193 -0
- package/examples/README.md +2 -1
- package/examples/browser-session/README.md +77 -0
- package/examples/browser-session/browser-session.pipeline.yaml +50 -0
- package/examples/browser-session/browser-session.task.yaml +6 -0
- package/examples/browser-session/check-login.yaml +22 -0
- package/examples/browser-session/fixture-server.mjs +64 -0
- package/examples/browser-session/human-login.yaml +31 -0
- package/examples/browser-session/merge.yaml +36 -0
- package/examples/browser-session/work-a.yaml +41 -0
- package/examples/browser-session/work-b.yaml +41 -0
- package/examples/stage-mcp/README.md +3 -2
- package/examples/stageflow.yaml +51 -0
- package/package.json +5 -1
- package/skills/stageflow/references/control-surface.md +3 -1
- package/skills/stageflow-author/references/stage-prompt-template.md +4 -4
- package/skills/stageflow-run/SKILL.md +2 -0
- package/skills/stageflow-run/references/task-and-pipeline-selection.md +3 -1
- package/skills/stageflow-setup/SKILL.md +11 -0
- package/dist/ui/assets/index-B6hlSXXn.js +0 -120
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
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.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=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)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),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}}}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`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),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){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function 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}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},z=[],B=-1;function V(e){return{current:e}}function H(e){0>B||(e.current=z[B],z[B]=null,B--)}function U(e,t){B++,z[B]=e.current,e.current=t}var W=V(null),ee=V(null),te=V(null),ne=V(null);function re(e,t){switch(U(te,t),U(ee,e),U(W,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ud(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ud(t),e=Wd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(W),U(W,e)}function ie(){H(W),H(ee),H(te)}function ae(e){e.memoizedState!==null&&U(ne,e);var t=W.current,n=Wd(t,e.type);t!==n&&(U(ee,e),U(W,n))}function oe(e){ee.current===e&&(H(W),H(ee)),ne.current===e&&(H(ne),ep._currentValue=R)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ue=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function fe(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`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 le(`Activity`);default:return``}}function pe(e){try{var t=``,n=null;do t+=fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var me=Object.prototype.hasOwnProperty,he=t.unstable_scheduleCallback,ge=t.unstable_cancelCallback,_e=t.unstable_shouldYield,ve=t.unstable_requestPaint,ye=t.unstable_now,be=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,Ce=t.unstable_NormalPriority,we=t.unstable_LowPriority,Te=t.unstable_IdlePriority,Ee=t.log,De=t.unstable_setDisableYieldValue,Oe=null,ke=null;function G(e){if(typeof Ee==`function`&&De(e),ke&&typeof ke.setStrictMode==`function`)try{ke.setStrictMode(Oe,e)}catch{}}var Ae=Math.clz32?Math.clz32:Ne,je=Math.log,Me=Math.LN2;function Ne(e){return e>>>=0,e===0?32:31-(je(e)/Me|0)|0}var Pe=256,Fe=262144,K=4194304;function Ie(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Le(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=Ie(n))):i=Ie(o):i=Ie(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ie(n))):i=Ie(o)):i=Ie(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 Re(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ze(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 Be(){var e=K;return K<<=1,!(K&62914560)&&(K=4194304),e}function Ve(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(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-Ae(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&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ae(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ae(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(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 Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=L.p;return e===0?(e=window.event,e===void 0?32:gp(e.type)):e}function Xe(e,t){var n=L.p;try{return L.p=e,t()}finally{L.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,rt=`__reactHandles$`+Ze,it=`__reactResources$`+Ze,at=`__reactMarker$`+Ze;function ot(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[rt]}function st(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=pf(e);e!==null;){if(n=e[Qe])return n;e=pf(e)}return t}e=n,n=e.parentNode}return null}function ct(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function lt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function ut(e){var t=e[it];return t||=e[it]={hoistableStyles:new Map,hoistableScripts:new Map},t}function dt(e){e[at]=!0}var ft=new Set,pt={};function mt(e,t){ht(e,t),ht(e+`Capture`,t)}function ht(e,t){for(pt[e]=t,e=0;e<t.length;e++)ft.add(t[e])}var gt=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]*$`),_t={},q={};function vt(e){return me.call(q,e)?!0:me.call(_t,e)?!1:gt.test(e)?q[e]=!0:(_t[e]=!0,!1)}function yt(e,t,n){if(vt(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 bt(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 xt(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 St(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ct(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function wt(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 Tt(e){if(!e._valueTracker){var t=Ct(e)?`checked`:`value`;e._valueTracker=wt(e,t,``+e[t])}}function Et(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ct(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function Dt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Ot=/[\n"\\]/g;function kt(e){return e.replace(Ot,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function At(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=``+St(t)):e.value!==``+St(t)&&(e.value=``+St(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Mt(e,o,St(n)):Mt(e,o,St(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=``+St(s):e.removeAttribute(`name`)}function jt(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)){Tt(e);return}n=n==null?``:``+St(n),t=t==null?n:``+St(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),Tt(e)}function Mt(e,t,n){t===`number`&&Dt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Nt(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=``+St(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 Pt(e,t,n){if(t!=null&&(t=``+St(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+St(n)}function Ft(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(F(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=St(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Tt(e)}function It(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Lt=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 Rt(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||Lt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function zt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Rt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Rt(e,o,t[o])}function Bt(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 Vt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Ht=/^[\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 Ut(e){return Ht.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Wt(){}var Gt=null;function Kt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var qt=null,Jt=null;function Yt(e){var t=ct(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(At(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="`+kt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));At(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&&Et(r)}break a;case`textarea`:Pt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Nt(e,!!n.multiple,t,!1)}}}var Xt=!1;function Zt(e,t,n){if(Xt)return e(t,n);Xt=!0;try{return e(t)}finally{if(Xt=!1,(qt!==null||Jt!==null)&&(yu(),qt&&(t=qt,e=Jt,Jt=qt=null,Yt(t),e)))for(t=0;t<e.length;t++)Yt(e[t])}}function Qt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||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 $t=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),en=!1;if($t)try{var tn={};Object.defineProperty(tn,"passive",{get:function(){en=!0}}),window.addEventListener(`test`,tn,tn),window.removeEventListener(`test`,tn,tn)}catch{en=!1}var nn=null,rn=null,an=null;function on(){if(an)return an;var e,t=rn,n=t.length,r,i=`value`in nn?nn.value:nn.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 an=i.slice(e,1<r?1-r:void 0)}function sn(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 cn(){return!0}function ln(){return!1}function un(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)?cn:ln,this.isPropagationStopped=ln,this}return m(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=cn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=cn)},persist:function(){},isPersistent:cn}),t}var dn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fn=un(dn),pn=m({},dn,{view:0,detail:0}),mn=un(pn),hn,gn,_n,vn=m({},pn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kn,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!==_n&&(_n&&e.type===`mousemove`?(hn=e.screenX-_n.screenX,gn=e.screenY-_n.screenY):gn=hn=0,_n=e),hn)},movementY:function(e){return`movementY`in e?e.movementY:gn}}),yn=un(vn),bn=un(m({},vn,{dataTransfer:0})),xn=un(m({},pn,{relatedTarget:0})),Sn=un(m({},dn,{animationName:0,elapsedTime:0,pseudoElement:0})),Cn=un(m({},dn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),wn=un(m({},dn,{data:0})),Tn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},En={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`},Dn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function On(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Dn[e])?!!t[e]:!1}function kn(){return On}var An=un(m({},pn,{key:function(e){if(e.key){var t=Tn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=sn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?En[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kn,charCode:function(e){return e.type===`keypress`?sn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?sn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),jn=un(m({},vn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Mn=un(m({},pn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kn})),Nn=un(m({},dn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Pn=un(m({},vn,{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})),Fn=un(m({},dn,{newState:0,oldState:0})),In=[9,13,27,32],Ln=$t&&`CompositionEvent`in window,Rn=null;$t&&`documentMode`in document&&(Rn=document.documentMode);var zn=$t&&`TextEvent`in window&&!Rn,Bn=$t&&(!Ln||Rn&&8<Rn&&11>=Rn),Vn=` `,Hn=!1;function Un(e,t){switch(e){case`keyup`:return In.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Wn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Gn=!1;function Kn(e,t){switch(e){case`compositionend`:return Wn(t);case`keypress`:return t.which===32?(Hn=!0,Vn):null;case`textInput`:return e=t.data,e===Vn&&Hn?null:e;default:return null}}function qn(e,t){if(Gn)return e===`compositionend`||!Ln&&Un(e,t)?(e=on(),an=rn=nn=null,Gn=!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 Bn&&t.locale!==`ko`?null:t.data;default:return null}}var Jn={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 Yn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Jn[e.type]:t===`textarea`}function Xn(e,t,n,r){qt?Jt?Jt.push(r):Jt=[r]:qt=r,t=Dd(t,`onChange`),0<t.length&&(n=new fn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Zn=null,Qn=null;function $n(e){yd(e,0)}function er(e){if(Et(lt(e)))return e}function tr(e,t){if(e===`change`)return t}var nr=!1;if($t){var rr;if($t){var ir=`oninput`in document;if(!ir){var ar=document.createElement(`div`);ar.setAttribute(`oninput`,`return;`),ir=typeof ar.oninput==`function`}rr=ir}else rr=!1;nr=rr&&(!document.documentMode||9<document.documentMode)}function or(){Zn&&(Zn.detachEvent(`onpropertychange`,sr),Qn=Zn=null)}function sr(e){if(e.propertyName===`value`&&er(Qn)){var t=[];Xn(t,Qn,e,Kt(e)),Zt($n,t)}}function cr(e,t,n){e===`focusin`?(or(),Zn=t,Qn=n,Zn.attachEvent(`onpropertychange`,sr)):e===`focusout`&&or()}function lr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return er(Qn)}function ur(e,t){if(e===`click`)return er(t)}function dr(e,t){if(e===`input`||e===`change`)return er(t)}function fr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var pr=typeof Object.is==`function`?Object.is:fr;function mr(e,t){if(pr(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(!me.call(t,i)||!pr(e[i],t[i]))return!1}return!0}function hr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function gr(e,t){var n=hr(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=hr(n)}}function _r(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_r(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function vr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Dt(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=Dt(e.document)}return t}function yr(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 br=$t&&`documentMode`in document&&11>=document.documentMode,xr=null,Sr=null,Cr=null,wr=!1;function Tr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;wr||xr==null||xr!==Dt(r)||(r=xr,`selectionStart`in r&&yr(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}),Cr&&mr(Cr,r)||(Cr=r,r=Dd(Sr,`onSelect`),0<r.length&&(t=new fn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=xr)))}function Er(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Dr={animationend:Er(`Animation`,`AnimationEnd`),animationiteration:Er(`Animation`,`AnimationIteration`),animationstart:Er(`Animation`,`AnimationStart`),transitionrun:Er(`Transition`,`TransitionRun`),transitionstart:Er(`Transition`,`TransitionStart`),transitioncancel:Er(`Transition`,`TransitionCancel`),transitionend:Er(`Transition`,`TransitionEnd`)},Or={},kr={};$t&&(kr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Dr.animationend.animation,delete Dr.animationiteration.animation,delete Dr.animationstart.animation),`TransitionEvent`in window||delete Dr.transitionend.transition);function Ar(e){if(Or[e])return Or[e];if(!Dr[e])return e;var t=Dr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in kr)return Or[e]=t[n];return e}var jr=Ar(`animationend`),Mr=Ar(`animationiteration`),Nr=Ar(`animationstart`),Pr=Ar(`transitionrun`),Fr=Ar(`transitionstart`),Ir=Ar(`transitioncancel`),Lr=Ar(`transitionend`),Rr=new Map,zr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);zr.push(`scrollEnd`);function Br(e,t){Rr.set(e,t),mt(t,[e])}var Vr=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)},Hr=[],Ur=0,Wr=0;function Gr(){for(var e=Ur,t=Wr=Ur=0;t<e;){var n=Hr[t];Hr[t++]=null;var r=Hr[t];Hr[t++]=null;var i=Hr[t];Hr[t++]=null;var a=Hr[t];if(Hr[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&&Yr(n,i,a)}}function Kr(e,t,n,r){Hr[Ur++]=e,Hr[Ur++]=t,Hr[Ur++]=n,Hr[Ur++]=r,Wr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function qr(e,t,n,r){return Kr(e,t,n,r),Xr(e)}function Jr(e,t){return Kr(e,null,null,t),Xr(e)}function Yr(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-Ae(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Xr(e){if(50<uu)throw uu=0,du=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Zr={};function Qr(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 $r(e,t,n,r){return new Qr(e,t,n,r)}function ei(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ti(e,t){var n=e.alternate;return n===null?(n=$r(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ni(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ri(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ei(e)&&(s=1);else if(typeof e==`string`)s=Gf(e,n,W.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=$r(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return ii(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=$r(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=$r(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=$r(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=$r(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function ii(e,t,n,r){return e=$r(7,e,r,t),e.lanes=n,e}function ai(e,t,n){return e=$r(6,e,null,t),e.lanes=n,e}function oi(e){var t=$r(18,null,null,0);return t.stateNode=e,t}function si(e,t,n){return t=$r(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ci=new WeakMap;function li(e,t){if(typeof e==`object`&&e){var n=ci.get(e);return n===void 0?(t={value:e,source:t,stack:pe(t)},ci.set(e,t),t):n}return{value:e,source:t,stack:pe(t)}}var ui=[],di=0,fi=null,pi=0,mi=[],hi=0,gi=null,_i=1,vi=``;function yi(e,t){ui[di++]=pi,ui[di++]=fi,fi=e,pi=t}function bi(e,t,n){mi[hi++]=_i,mi[hi++]=vi,mi[hi++]=gi,gi=e;var r=_i;e=vi;var i=32-Ae(r)-1;r&=~(1<<i),n+=1;var a=32-Ae(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,_i=1<<32-Ae(t)+i|n<<i|r,vi=a+e}else _i=1<<a|n<<i|r,vi=e}function xi(e){e.return!==null&&(yi(e,1),bi(e,1,0))}function Si(e){for(;e===fi;)fi=ui[--di],ui[di]=null,pi=ui[--di],ui[di]=null;for(;e===gi;)gi=mi[--hi],mi[hi]=null,vi=mi[--hi],mi[hi]=null,_i=mi[--hi],mi[hi]=null}function Ci(e,t){mi[hi++]=_i,mi[hi++]=vi,mi[hi++]=gi,_i=t.id,vi=t.overflow,gi=e}var wi=null,Ti=null,J=!1,Ei=null,Di=!1,Oi=Error(i(519));function ki(e){throw Pi(li(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Oi}function Ai(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:bd(`cancel`,t),bd(`close`,t);break;case`iframe`:case`object`:case`embed`:bd(`load`,t);break;case`video`:case`audio`:for(n=0;n<_d.length;n++)bd(_d[n],t);break;case`source`:bd(`error`,t);break;case`img`:case`image`:case`link`:bd(`error`,t),bd(`load`,t);break;case`details`:bd(`toggle`,t);break;case`input`:bd(`invalid`,t),jt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:bd(`invalid`,t);break;case`textarea`:bd(`invalid`,t),Ft(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||Nd(t.textContent,n)?(r.popover!=null&&(bd(`beforetoggle`,t),bd(`toggle`,t)),r.onScroll!=null&&bd(`scroll`,t),r.onScrollEnd!=null&&bd(`scrollend`,t),r.onClick!=null&&(t.onclick=Wt),t=!0):t=!1,t||ki(e,!0)}function Y(e){for(wi=e.return;wi;)switch(wi.tag){case 5:case 31:case 13:Di=!1;return;case 27:case 3:Di=!0;return;default:wi=wi.return}}function ji(e){if(e!==wi)return!1;if(!J)return Y(e),J=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||Gd(e.type,e.memoizedProps)),n=!n),n&&Ti&&ki(e),Y(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ti=ff(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ti=ff(e)}else t===27?(t=Ti,$d(e.type)?(e=df,df=null,Ti=e):Ti=t):Ti=wi?uf(e.stateNode.nextSibling):null;return!0}function Mi(){Ti=wi=null,J=!1}function Ni(){var e=Ei;return e!==null&&(Xl===null?Xl=e:Xl.push.apply(Xl,e),Ei=null),e}function Pi(e){Ei===null?Ei=[e]:Ei.push(e)}var Fi=V(null),Ii=null,Li=null;function Ri(e,t,n){U(Fi,t._currentValue),t._currentValue=n}function zi(e){e._currentValue=Fi.current,H(Fi)}function Bi(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 Vi(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),Bi(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),Bi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Hi(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;pr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ne.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[ep]:e.push(ep))}a=a.return}e!==null&&Vi(t,e,n,r),t.flags|=262144}function Ui(e){for(e=e.firstContext;e!==null;){if(!pr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Wi(e){Ii=e,Li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gi(e){return qi(Ii,e)}function Ki(e,t){return Ii===null&&Wi(e),qi(e,t)}function qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Li===null){if(e===null)throw Error(i(308));Li=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Li=Li.next=t;return n}var Ji=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()})}},Yi=t.unstable_scheduleCallback,Xi=t.unstable_NormalPriority,Zi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qi(){return{controller:new Ji,data:new Map,refCount:0}}function $i(e){e.refCount--,e.refCount===0&&Yi(Xi,function(){e.controller.abort()})}var ea=null,ta=0,na=0,ra=null;function ia(e,t){if(ea===null){var n=ea=[];ta=0,na=dd(),ra={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ta++,t.then(aa,aa),t}function aa(){if(--ta===0&&ea!==null){ra!==null&&(ra.status=`fulfilled`);var e=ea;ea=null,na=0,ra=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function oa(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 sa=I.S;I.S=function(e,t){$l=ye(),typeof t==`object`&&t&&typeof t.then==`function`&&ia(e,t),sa!==null&&sa(e,t)};var ca=V(null);function la(){var e=ca.current;return e===null?Fl.pooledCache:e}function ua(e,t){t===null?U(ca,ca.current):U(ca,t.pool)}function da(){var e=la();return e===null?null:{parent:Zi._currentValue,pool:e}}var fa=Error(i(460)),pa=Error(i(474)),ma=Error(i(542)),ha={then:function(){}};function ga(e){return e=e.status,e===`fulfilled`||e===`rejected`}function _a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Wt,Wt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,xa(e),e;default:if(typeof t.status==`string`)t.then(Wt,Wt);else{if(e=Fl,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,xa(e),e}throw ya=t,fa}}function va(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ya=e,fa):e}}var ya=null;function ba(){if(ya===null)throw Error(i(459));var e=ya;return ya=null,e}function xa(e){if(e===fa||e===ma)throw Error(i(483))}var Sa=null,Ca=0;function wa(e){var t=Ca;return Ca+=1,Sa===null&&(Sa=[]),_a(Sa,e,t)}function Ta(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ea(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Da(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=ti(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ai(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===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&va(i)===t.type)?(t=a(t,n.props),Ta(t,n),t.return=e,t):(t=ri(n.type,n.key,n.props,null,e.mode,r),Ta(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=si(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=ii(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=ai(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=ri(t.type,t.key,t.props,null,e.mode,n),Ta(n,t),n.return=e,n;case v:return t=si(t,e.mode,n),t.return=e,t;case O:return t=va(t),f(e,t,n)}if(F(t)||M(t))return t=ii(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,wa(t),n);if(t.$$typeof===C)return f(e,Ki(e,t),n);Ea(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 _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=va(n),p(e,t,n,r)}if(F(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,wa(n),r);if(n.$$typeof===C)return p(e,t,Ki(e,n),r);Ea(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 _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=va(r),m(e,t,n,r,i)}if(F(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,wa(r),i);if(r.$$typeof===C)return m(e,t,n,Ki(t,r),i);Ea(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),J&&yi(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 J&&yi(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(g.key===null?h:g.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)}),J&&yi(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),J&&yi(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 J&&yi(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(v.key===null?g:v.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)}),J&&yi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&va(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ta(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===y?(c=ii(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ri(o.type,o.key,o.props,null,e.mode,c),Ta(c,o),c.return=e,e=c)}return s(e);case v: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=si(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=va(o),b(e,r,o,c)}if(F(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,wa(o),c);if(o.$$typeof===C)return b(e,r,Ki(e,o),c);Ea(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=ai(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ca=0;var i=b(e,t,n,r);return Sa=null,i}catch(t){if(t===fa||t===ma)throw t;var a=$r(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Oa=Da(!0),ka=Da(!1),Aa=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ma(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 Na(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Pa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Pl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Xr(e),Yr(e,null,n),t}return Kr(e,r,t,n),Xr(e)}function Fa(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,Ge(e,n)}}function Ia(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 La=!1;function Ra(){if(La){var e=ra;if(e!==null)throw e}}function za(e,t,n,r){La=!1;var i=e.updateQueue;Aa=!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?(Il&f)===f:(r&f)===f){f!==0&&f===na&&(La=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Aa=!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),Wl|=o,e.lanes=o,e.memoizedState=d}}function Ba(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Va(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ba(n[e],t)}var Ha=V(null),Ua=V(0);function Wa(e,t){e=Hl,U(Ua,e),U(Ha,t),Hl=e|t.baseLanes}function Ga(){U(Ua,Hl),U(Ha,Ha.current)}function Ka(){Hl=Ua.current,H(Ha),H(Ua)}var qa=V(null),Ja=null;function Ya(e){var t=e.alternate;U(eo,eo.current&1),U(qa,e),Ja===null&&(t===null||Ha.current!==null||t.memoizedState!==null)&&(Ja=e)}function Xa(e){U(eo,eo.current),U(qa,e),Ja===null&&(Ja=e)}function Za(e){e.tag===22?(U(eo,eo.current),U(qa,e),Ja===null&&(Ja=e)):Qa(e)}function Qa(){U(eo,eo.current),U(qa,qa.current)}function $a(e){H(qa),Ja===e&&(Ja=null),H(eo)}var eo=V(0);function to(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||sf(n)||cf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var no=0,X=null,ro=null,io=null,ao=!1,oo=!1,so=!1,co=0,lo=0,uo=null,fo=0;function po(){throw Error(i(321))}function mo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!pr(e[n],t[n]))return!1;return!0}function ho(e,t,n,r,i,a){return no=a,X=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?Ms:Ns,so=!1,a=n(r,i),so=!1,oo&&(a=_o(t,n,r,i)),go(e),a}function go(e){I.H=js;var t=ro!==null&&ro.next!==null;if(no=0,io=ro=X=null,ao=!1,lo=0,uo=null,t)throw Error(i(300));e===null||Xs||(e=e.dependencies,e!==null&&Ui(e)&&(Xs=!0))}function _o(e,t,n,r){X=e;var a=0;do{if(oo&&(uo=null),lo=0,oo=!1,25<=a)throw Error(i(301));if(a+=1,io=ro=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}I.H=Ps,o=t(n,r)}while(oo);return o}function vo(){var e=I.H,t=e.useState()[0];return t=typeof t.then==`function`?To(t):t,e=e.useState()[0],(ro===null?null:ro.memoizedState)!==e&&(X.flags|=1024),t}function yo(){var e=co!==0;return co=0,e}function bo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function xo(e){if(ao){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ao=!1}no=0,io=ro=X=null,oo=!1,lo=co=0,uo=null}function So(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return io===null?X.memoizedState=io=e:io=io.next=e,io}function Co(){if(ro===null){var e=X.alternate;e=e===null?null:e.memoizedState}else e=ro.next;var t=io===null?X.memoizedState:io.next;if(t!==null)io=t,ro=e;else{if(e===null)throw X.alternate===null?Error(i(467)):Error(i(310));ro=e,e={memoizedState:ro.memoizedState,baseState:ro.baseState,baseQueue:ro.baseQueue,queue:ro.queue,next:null},io===null?X.memoizedState=io=e:io=io.next=e}return io}function wo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function To(e){var t=lo;return lo+=1,uo===null&&(uo=[]),e=_a(uo,e,t),t=X,(io===null?t.memoizedState:io.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?Ms:Ns),e}function Eo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return To(e);if(e.$$typeof===C)return Gi(e)}throw Error(i(438,String(e)))}function Do(e){var t=null,n=X.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=X.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=wo(),X.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]=A;return t.index++,n}function Oo(e,t){return typeof t==`function`?t(e):t}function ko(e){return Ao(Co(),ro,e)}function Ao(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?(no&f)===f:(Il&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===na&&(d=!0);else if((no&p)===p){u=u.next,p===na&&(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,X.lanes|=p,Wl|=p;f=u.action,so&&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,X.lanes|=f,Wl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!pr(o,e.memoizedState)&&(Xs=!0,d&&(n=ra,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 jo(e){var t=Co(),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);pr(o,t.memoizedState)||(Xs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Mo(e,t,n){var r=X,a=Co(),o=J;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!pr((ro||a).memoizedState,n);if(s&&(a.memoizedState=n,Xs=!0),a=a.queue,rs(Fo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||io!==null&&io.memoizedState.tag&1){if(r.flags|=2048,Qo(9,{destroy:void 0},Po.bind(null,r,a,n,t),null),Fl===null)throw Error(i(349));o||no&127||No(r,t,n)}return n}function No(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=X.updateQueue,t===null?(t=wo(),X.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Po(e,t,n,r){t.value=n,t.getSnapshot=r,Io(t)&&Lo(e)}function Fo(e,t,n){return n(function(){Io(t)&&Lo(e)})}function Io(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!pr(e,n)}catch{return!0}}function Lo(e){var t=Jr(e,2);t!==null&&mu(t,e,2)}function Ro(e){var t=So();if(typeof e==`function`){var n=e;if(e=n(),so){G(!0);try{n()}finally{G(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:e},t}function zo(e,t,n,r){return e.baseState=n,Ao(e,ro,typeof r==`function`?r:Oo)}function Bo(e,t,n,r,a){if(Os(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)}};I.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Vo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Vo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=I.T,o={};I.T=o;try{var s=n(i,r),c=I.S;c!==null&&c(o,s),Ho(e,t,s)}catch(n){Wo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),I.T=a}}else try{a=n(i,r),Ho(e,t,a)}catch(n){Wo(e,t,n)}}function Ho(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Uo(e,t,n)},function(n){return Wo(e,t,n)}):Uo(e,t,n)}function Uo(e,t,n){t.status=`fulfilled`,t.value=n,Go(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Vo(e,n)))}function Wo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Go(t),t=t.next;while(t!==r)}e.action=null}function Go(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ko(e,t){return t}function qo(e,t){if(J){var n=Fl.formState;if(n!==null){a:{var r=X;if(J){if(Ti){b:{for(var i=Ti,a=Di;i.nodeType!==8;){if(!a){i=null;break b}if(i=uf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ti=uf(i.nextSibling),r=i.data===`F!`;break a}}ki(r)}r=!1}r&&(t=n[0])}}return n=So(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ko,lastRenderedState:t},n.queue=r,n=Ts.bind(null,X,r),r.dispatch=n,r=Ro(!1),a=Ds.bind(null,X,!1,r.queue),r=So(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Bo.bind(null,X,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Jo(e){return Yo(Co(),ro,e)}function Yo(e,t,n){if(t=Ao(e,t,Ko)[0],e=ko(Oo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=To(t)}catch(e){throw e===fa?ma:e}else r=t;t=Co();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(X.flags|=2048,Qo(9,{destroy:void 0},Xo.bind(null,i,n),null)),[r,a,e]}function Xo(e,t){e.action=t}function Zo(e){var t=Co(),n=ro;if(n!==null)return Yo(t,n,e);Co(),t=t.memoizedState,n=Co();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Qo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=X.updateQueue,t===null&&(t=wo(),X.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 $o(){return Co().memoizedState}function es(e,t,n,r){var i=So();X.flags|=e,i.memoizedState=Qo(1|t,{destroy:void 0},n,r===void 0?null:r)}function ts(e,t,n,r){var i=Co();r=r===void 0?null:r;var a=i.memoizedState.inst;ro!==null&&r!==null&&mo(r,ro.memoizedState.deps)?i.memoizedState=Qo(t,a,n,r):(X.flags|=e,i.memoizedState=Qo(1|t,a,n,r))}function ns(e,t){es(8390656,8,e,t)}function rs(e,t){ts(2048,8,e,t)}function is(e){X.flags|=4;var t=X.updateQueue;if(t===null)t=wo(),X.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function as(e){var t=Co().memoizedState;return is({ref:t,nextImpl:e}),function(){if(Pl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function os(e,t){return ts(4,2,e,t)}function ss(e,t){return ts(4,4,e,t)}function cs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ls(e,t,n){n=n==null?null:n.concat([e]),ts(4,4,cs.bind(null,t,e),n)}function us(){}function ds(e,t){var n=Co();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&mo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function fs(e,t){var n=Co();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&mo(t,r[1]))return r[0];if(r=e(),so){G(!0);try{e()}finally{G(!1)}}return n.memoizedState=[r,t],r}function ps(e,t,n){return n===void 0||no&1073741824&&!(Il&261930)?e.memoizedState=t:(e.memoizedState=n,e=pu(),X.lanes|=e,Wl|=e,n)}function ms(e,t,n,r){return pr(n,t)?n:Ha.current===null?!(no&42)||no&1073741824&&!(Il&261930)?(Xs=!0,e.memoizedState=n):(e=pu(),X.lanes|=e,Wl|=e,t):(e=ps(e,n,r),pr(e,t)||(Xs=!0),e)}function hs(e,t,n,r,i){var a=L.p;L.p=a!==0&&8>a?a:8;var o=I.T,s={};I.T=s,Ds(e,!1,t,n);try{var c=i(),l=I.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Es(e,t,oa(c,r),fu(e)):Es(e,t,r,fu(e))}catch(n){Es(e,t,{then:function(){},status:`rejected`,reason:n},fu())}finally{L.p=a,o!==null&&s.types!==null&&(o.types=s.types),I.T=o}}function gs(){}function _s(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=vs(e).queue;hs(e,a,t,R,n===null?gs:function(){return ys(e),n(r)})}function vs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:R},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ys(e){var t=vs(e);t.next===null&&(t=e.alternate.memoizedState),Es(e,t.next.queue,{},fu())}function bs(){return Gi(ep)}function xs(){return Co().memoizedState}function Ss(){return Co().memoizedState}function Cs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=fu();e=Na(n);var r=Pa(t,e,n);r!==null&&(mu(r,t,n),Fa(r,t,n)),t={cache:Qi()},e.payload=t;return}t=t.return}}function ws(e,t,n){var r=fu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Os(e)?ks(t,n):(n=qr(e,t,n,r),n!==null&&(mu(n,e,r),As(n,t,r)))}function Ts(e,t,n){Es(e,t,n,fu())}function Es(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Os(e))ks(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,pr(s,o))return Kr(e,t,i,0),Fl===null&&Gr(),!1}catch{}if(n=qr(e,t,i,r),n!==null)return mu(n,e,r),As(n,t,r),!0}return!1}function Ds(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Os(e)){if(t)throw Error(i(479))}else t=qr(e,n,r,2),t!==null&&mu(t,e,2)}function Os(e){var t=e.alternate;return e===X||t!==null&&t===X}function ks(e,t){oo=ao=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function As(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var js={readContext:Gi,use:Eo,useCallback:po,useContext:po,useEffect:po,useImperativeHandle:po,useLayoutEffect:po,useInsertionEffect:po,useMemo:po,useReducer:po,useRef:po,useState:po,useDebugValue:po,useDeferredValue:po,useTransition:po,useSyncExternalStore:po,useId:po,useHostTransitionStatus:po,useFormState:po,useActionState:po,useOptimistic:po,useMemoCache:po,useCacheRefresh:po};js.useEffectEvent=po;var Ms={readContext:Gi,use:Eo,useCallback:function(e,t){return So().memoizedState=[e,t===void 0?null:t],e},useContext:Gi,useEffect:ns,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),es(4194308,4,cs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return es(4194308,4,e,t)},useInsertionEffect:function(e,t){es(4,2,e,t)},useMemo:function(e,t){var n=So();t=t===void 0?null:t;var r=e();if(so){G(!0);try{e()}finally{G(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=So();if(n!==void 0){var i=n(t);if(so){G(!0);try{n(t)}finally{G(!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=ws.bind(null,X,e),[r.memoizedState,e]},useRef:function(e){var t=So();return e={current:e},t.memoizedState=e},useState:function(e){e=Ro(e);var t=e.queue,n=Ts.bind(null,X,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:us,useDeferredValue:function(e,t){return ps(So(),e,t)},useTransition:function(){var e=Ro(!1);return e=hs.bind(null,X,e.queue,!0,!1),So().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=X,a=So();if(J){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Fl===null)throw Error(i(349));Il&127||No(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ns(Fo.bind(null,r,o,e),[e]),r.flags|=2048,Qo(9,{destroy:void 0},Po.bind(null,r,o,n,t),null),n},useId:function(){var e=So(),t=Fl.identifierPrefix;if(J){var n=vi,r=_i;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=co++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=fo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:bs,useFormState:qo,useActionState:qo,useOptimistic:function(e){var t=So();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ds.bind(null,X,!0,n),n.dispatch=t,[e,t]},useMemoCache:Do,useCacheRefresh:function(){return So().memoizedState=Cs.bind(null,X)},useEffectEvent:function(e){var t=So(),n={impl:e};return t.memoizedState=n,function(){if(Pl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ns={readContext:Gi,use:Eo,useCallback:ds,useContext:Gi,useEffect:rs,useImperativeHandle:ls,useInsertionEffect:os,useLayoutEffect:ss,useMemo:fs,useReducer:ko,useRef:$o,useState:function(){return ko(Oo)},useDebugValue:us,useDeferredValue:function(e,t){return ms(Co(),ro.memoizedState,e,t)},useTransition:function(){var e=ko(Oo)[0],t=Co().memoizedState;return[typeof e==`boolean`?e:To(e),t]},useSyncExternalStore:Mo,useId:xs,useHostTransitionStatus:bs,useFormState:Jo,useActionState:Jo,useOptimistic:function(e,t){return zo(Co(),ro,e,t)},useMemoCache:Do,useCacheRefresh:Ss};Ns.useEffectEvent=as;var Ps={readContext:Gi,use:Eo,useCallback:ds,useContext:Gi,useEffect:rs,useImperativeHandle:ls,useInsertionEffect:os,useLayoutEffect:ss,useMemo:fs,useReducer:jo,useRef:$o,useState:function(){return jo(Oo)},useDebugValue:us,useDeferredValue:function(e,t){var n=Co();return ro===null?ps(n,e,t):ms(n,ro.memoizedState,e,t)},useTransition:function(){var e=jo(Oo)[0],t=Co().memoizedState;return[typeof e==`boolean`?e:To(e),t]},useSyncExternalStore:Mo,useId:xs,useHostTransitionStatus:bs,useFormState:Zo,useActionState:Zo,useOptimistic:function(e,t){var n=Co();return ro===null?(n.baseState=e,[e,n.queue.dispatch]):zo(n,ro,e,t)},useMemoCache:Do,useCacheRefresh:Ss};Ps.useEffectEvent=as;function Fs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Is={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=fu(),i=Na(r);i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(mu(t,e,r),Fa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=fu(),i=Na(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Pa(e,i,r),t!==null&&(mu(t,e,r),Fa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=fu(),r=Na(n);r.tag=2,t!=null&&(r.callback=t),t=Pa(e,r,n),t!==null&&(mu(t,e,n),Fa(t,e,n))}};function Ls(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?!mr(n,r)||!mr(i,a):!0}function Rs(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&&Is.enqueueReplaceState(t,t.state,null)}function zs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Bs(e){Vr(e)}function Vs(e){console.error(e)}function Hs(e){Vr(e)}function Us(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Ws(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 Gs(e,t,n){return n=Na(n),n.tag=3,n.payload={element:null},n.callback=function(){Us(e,t)},n}function Ks(e){return e=Na(e),e.tag=3,e}function qs(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(){Ws(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Ws(t,n,r),typeof i!=`function`&&(nu===null?nu=new Set([this]):nu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Js(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Hi(t,n,a,!0),n=qa.current,n!==null){switch(n.tag){case 31:case 13:return Ja===null?Eu():n.alternate===null&&Ul===0&&(Ul=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ha?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Gu(e,r,a)),!1;case 22:return n.flags|=65536,r===ha?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)),Gu(e,r,a)),!1}throw Error(i(435,n.tag))}return Gu(e,r,a),Eu(),!1}if(J)return t=qa.current,t===null?(r!==Oi&&(t=Error(i(423),{cause:r}),Pi(li(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=li(r,n),a=Gs(e.stateNode,r,a),Ia(e,a),Ul!==4&&(Ul=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Oi&&(e=Error(i(422),{cause:r}),Pi(li(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=li(o,n),Yl===null?Yl=[o]:Yl.push(o),Ul!==4&&(Ul=2),t===null)return!0;r=li(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Gs(n.stateNode,r,e),Ia(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`&&(nu===null||!nu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Ks(a),qs(a,e,n,r),Ia(n,a),!1}n=n.return}while(n!==null);return!1}var Ys=Error(i(461)),Xs=!1;function Zs(e,t,n,r){t.child=e===null?ka(t,null,n,r):Oa(t,e.child,n,r)}function Qs(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 Wi(t),r=ho(e,t,n,o,a,i),s=yo(),e!==null&&!Xs?(bo(e,t,i),Sc(e,t,i)):(J&&s&&xi(t),t.flags|=1,Zs(e,t,r,i),t.child)}function $s(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ei(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,ec(e,t,a,r,i)):(e=ri(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Cc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?mr:n,n(o,r)&&e.ref===t.ref)return Sc(e,t,i)}return t.flags|=1,e=ti(a,r),e.ref=t.ref,e.return=t,t.child=e}function ec(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(mr(a,r)&&e.ref===t.ref){if(Xs=!1,t.pendingProps=r=a,Cc(e,i))e.flags&131072&&(Xs=!0);else return t.lanes=e.lanes,Sc(e,t,i)}}return cc(e,t,n,r,i)}function tc(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 rc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ua(t,a===null?null:a.cachePool),a===null?Ga():Wa(t,a),Za(t);else return r=t.lanes=536870912,rc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ua(t,null),Ga(),Qa(t)):(ua(t,a.cachePool),Wa(t,a),Qa(t),t.memoizedState=null);return Zs(e,t,i,n),t.child}function nc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function rc(e,t,n,r,i){var a=la();return a=a===null?null:{parent:Zi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ua(t,null),Ga(),Za(t),e!==null&&Hi(e,t,r,!0),t.childLanes=i,null}function ic(e,t){return t=_c({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ac(e,t,n){return Oa(t,e.child,null,n),e=ic(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function oc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(J){if(r.mode===`hidden`)return e=ic(t,r),t.lanes=536870912,nc(null,e);if(Xa(t),(e=Ti)?(e=of(e,Di),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:gi===null?null:{id:_i,overflow:vi},retryLane:536870912,hydrationErrors:null},n=oi(e),n.return=t,t.child=n,wi=t,Ti=null)):e=null,e===null)throw ki(t);return t.lanes=536870912,null}return ic(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Xa(t),a){if(t.flags&256)t.flags&=-257,t=ac(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Xs||Hi(e,t,n,!1),a=(n&e.childLanes)!==0,Xs||a){if(r=Fl,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Jr(e,s),mu(r,e,s),Ys;Eu(),t=ac(e,t,n)}else e=o.treeContext,Ti=uf(s.nextSibling),wi=t,J=!0,Ei=null,Di=!1,e!==null&&Ci(t,e),t=ic(t,r),t.flags|=4096;return t}return e=ti(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function sc(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 cc(e,t,n,r,i){return Wi(t),n=ho(e,t,n,r,void 0,i),r=yo(),e!==null&&!Xs?(bo(e,t,i),Sc(e,t,i)):(J&&r&&xi(t),t.flags|=1,Zs(e,t,n,i),t.child)}function lc(e,t,n,r,i,a){return Wi(t),t.updateQueue=null,n=_o(t,r,n,i),go(e),r=yo(),e!==null&&!Xs?(bo(e,t,a),Sc(e,t,a)):(J&&r&&xi(t),t.flags|=1,Zs(e,t,n,a),t.child)}function uc(e,t,n,r,i){if(Wi(t),t.stateNode===null){var a=Zr,o=n.contextType;typeof o==`object`&&o&&(a=Gi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Is,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ja(t),o=n.contextType,a.context=typeof o==`object`&&o?Gi(o):Zr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Fs(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&&Is.enqueueReplaceState(a,a.state,null),za(t,r,a,i),Ra(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=zs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Zr,typeof u==`object`&&u&&(o=Gi(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)&&Rs(t,a,r,o),Aa=!1;var f=t.memoizedState;a.state=f,za(t,r,a,i),Ra(),l=t.memoizedState,s||f!==l||Aa?(typeof d==`function`&&(Fs(t,n,d,r),l=t.memoizedState),(c=Aa||Ls(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,Ma(e,t),o=t.memoizedProps,u=zs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Zr,typeof l==`object`&&l&&(c=Gi(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)&&Rs(t,a,r,c),Aa=!1,f=t.memoizedState,a.state=f,za(t,r,a,i),Ra();var p=t.memoizedState;o!==d||f!==p||Aa||e!==null&&e.dependencies!==null&&Ui(e.dependencies)?(typeof s==`function`&&(Fs(t,n,s,r),p=t.memoizedState),(u=Aa||Ls(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ui(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,sc(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=Oa(t,e.child,null,i),t.child=Oa(t,null,n,i)):Zs(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Sc(e,t,i),e}function dc(e,t,n,r){return Mi(),t.flags|=256,Zs(e,t,n,r),t.child}var fc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function pc(e){return{baseLanes:e,cachePool:da()}}function mc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ql),e}function hc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(eo.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(J){if(a?Ya(t):Qa(t),(e=Ti)?(e=of(e,Di),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:gi===null?null:{id:_i,overflow:vi},retryLane:536870912,hydrationErrors:null},n=oi(e),n.return=t,t.child=n,wi=t,Ti=null)):e=null,e===null)throw ki(t);return cf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Qa(t),a=t.mode,c=_c({mode:`hidden`,children:c},a),r=ii(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=pc(n),r.childLanes=mc(e,s,n),t.memoizedState=fc,nc(null,r)):(Ya(t),gc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ya(t),t.flags&=-257,t=vc(e,t,n)):t.memoizedState===null?(Qa(t),c=r.fallback,a=t.mode,r=_c({mode:`visible`,children:r.children},a),c=ii(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Oa(t,e.child,null,n),r=t.child,r.memoizedState=pc(n),r.childLanes=mc(e,s,n),t.memoizedState=fc,t=nc(null,r)):(Qa(t),t.child=e.child,t.flags|=128,t=null);else if(Ya(t),cf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Pi({value:r,source:null,stack:null}),t=vc(e,t,n)}else if(Xs||Hi(e,t,n,!1),s=(n&e.childLanes)!==0,Xs||s){if(s=Fl,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Jr(e,r),mu(s,e,r),Ys;sf(c)||Eu(),t=vc(e,t,n)}else sf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ti=uf(c.nextSibling),wi=t,J=!0,Ei=null,Di=!1,e!==null&&Ci(t,e),t=gc(t,r.children),t.flags|=4096);return t}return a?(Qa(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ti(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ii(c,a,n,null),c.flags|=2):c=ti(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,nc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=pc(n):(a=c.cachePool,a===null?a=da():(l=Zi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=mc(e,s,n),t.memoizedState=fc,nc(e.child,r)):(Ya(t),n=e.child,e=n.sibling,n=ti(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function gc(e,t){return t=_c({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function _c(e,t){return e=$r(22,e,null,t),e.lanes=0,e}function vc(e,t,n){return Oa(t,e.child,null,n),e=gc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function yc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Bi(e.return,t,n)}function bc(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,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=eo.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,U(eo,o),Zs(e,t,r,n),r=J?pi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&yc(e,n,t);else if(e.tag===19)yc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&to(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),bc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&to(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}bc(t,!0,n,null,a,r);break;case`together`:bc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Sc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Wl|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Hi(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=ti(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ti(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Cc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ui(e)))}function wc(e,t,n){switch(t.tag){case 3:re(t,t.stateNode.containerInfo),Ri(t,Zi,e.memoizedState.cache),Mi();break;case 27:case 5:ae(t);break;case 4:re(t,t.stateNode.containerInfo);break;case 10:Ri(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Xa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ya(t),e=Sc(e,t,n),e===null?null:e.sibling):hc(e,t,n):(Ya(t),t.flags|=128,null);Ya(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(Hi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return xc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),U(eo,eo.current),r)break;return null;case 22:return t.lanes=0,tc(e,t,n,t.pendingProps);case 24:Ri(t,Zi,e.memoizedState.cache)}return Sc(e,t,n)}function Tc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Xs=!0;else{if(!Cc(e,n)&&!(t.flags&128))return Xs=!1,wc(e,t,n);Xs=!!(e.flags&131072)}}else Xs=!1,J&&t.flags&1048576&&bi(t,pi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=va(t.elementType),t.type=e,typeof e==`function`)ei(e)?(r=zs(e,r),t.tag=1,t=uc(null,t,e,r,n)):(t.tag=0,t=cc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Qs(null,t,e,r,n);break a}if(a===D){t.tag=14,t=$s(null,t,e,r,n);break a}}throw t=P(e)||e,Error(i(306,t,``))}}return t;case 0:return cc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=zs(r,t.pendingProps),uc(e,t,r,a,n);case 3:a:{if(re(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ma(e,t),za(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ri(t,Zi,r),r!==o.cache&&Vi(t,[Zi],n,!0),Ra(),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=dc(e,t,r,n);break a}if(r!==a){a=li(Error(i(424)),t),Pi(a),t=dc(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(Ti=uf(e.firstChild),wi=t,J=!0,Ei=null,Di=!0,n=ka(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Mi(),r===a){t=Sc(e,t,n);break a}Zs(e,t,r,n)}t=t.child}return t;case 26:return sc(e,t),e===null?(n=jf(t.type,null,t.pendingProps,null))?t.memoizedState=n:J||(n=t.type,e=t.pendingProps,r=Hd(te.current).createElement(n),r[Qe]=t,r[$e]=e,Id(r,n,e),dt(r),t.stateNode=r):t.memoizedState=jf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ae(t),e===null&&J&&(r=t.stateNode=mf(t.type,t.pendingProps,te.current),wi=t,Di=!0,a=Ti,$d(t.type)?(df=a,Ti=uf(r.firstChild)):Ti=a),Zs(e,t,t.pendingProps.children,n),sc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&J&&((a=r=Ti)&&(r=rf(r,t.type,t.pendingProps,Di),r===null?a=!1:(t.stateNode=r,wi=t,Ti=uf(r.firstChild),Di=!1,a=!0)),a||ki(t)),ae(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Gd(a,o)?r=null:s!==null&&Gd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=ho(e,t,vo,null,null,n),ep._currentValue=a),sc(e,t),Zs(e,t,r,n),t.child;case 6:return e===null&&J&&((e=n=Ti)&&(n=af(n,t.pendingProps,Di),n===null?e=!1:(t.stateNode=n,wi=t,Ti=null,e=!0)),e||ki(t)),null;case 13:return hc(e,t,n);case 4:return re(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Oa(t,null,r,n):Zs(e,t,r,n),t.child;case 11:return Qs(e,t,t.type,t.pendingProps,n);case 7:return Zs(e,t,t.pendingProps,n),t.child;case 8:return Zs(e,t,t.pendingProps.children,n),t.child;case 12:return Zs(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ri(t,t.type,r.value),Zs(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Wi(t),a=Gi(a),r=r(a),t.flags|=1,Zs(e,t,r,n),t.child;case 14:return $s(e,t,t.type,t.pendingProps,n);case 15:return ec(e,t,t.type,t.pendingProps,n);case 19:return xc(e,t,n);case 31:return oc(e,t,n);case 22:return tc(e,t,n,t.pendingProps);case 24:return Wi(t),r=Gi(Zi),e===null?(a=la(),a===null&&(a=Fl,o=Qi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},ja(t),Ri(t,Zi,a)):((e.lanes&n)!==0&&(Ma(e,t),za(t,null,null,n),Ra()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ri(t,Zi,r),r!==a.cache&&Vi(t,[Zi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ri(t,Zi,r))),Zs(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Ec(e){e.flags|=4}function Dc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Cu())e.flags|=8192;else throw ya=ha,pa}}else e.flags&=-16777217}function Oc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Kf(t)){if(Cu())e.flags|=8192;else throw ya=ha,pa}}function kc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Be(),e.lanes|=t,Jl|=t)}function Ac(e,t){if(!J)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function jc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Mc(e,t,n){var r=t.pendingProps;switch(Si(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jc(t),null;case 1:return jc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),zi(Zi),ie(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ji(t)?Ec(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ni())),jc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Ec(t),o===null?(jc(t),Dc(t,a,null,r,n)):(jc(t),Oc(t,o))):o?o===e.memoizedState?(jc(t),t.flags&=-16777217):(Ec(t),jc(t),Oc(t,o)):(e=e.memoizedProps,e!==r&&Ec(t),jc(t),Dc(t,a,e,r,n)),null;case 27:if(oe(t),n=te.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return jc(t),null}e=W.current,ji(t)?Ai(t,e):(e=mf(a,r,n),t.stateNode=e,Ec(t))}return jc(t),null;case 5:if(oe(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return jc(t),null}if(o=W.current,ji(t))Ai(t,o);else{var s=Hd(te.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[Qe]=t,o[$e]=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(Id(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&&Ec(t)}}return jc(t),Dc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Ec(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=te.current,ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=wi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Nd(e.nodeValue,n)),e||ki(t,!0)}else e=Hd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return jc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ji(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[Qe]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jc(t),e=!1}else n=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if(t.flags&128)throw Error(i(558))}return jc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ji(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[Qe]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jc(t),a=!1}else a=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?($a(t),t):($a(t),null)}return $a(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),kc(t,t.updateQueue),jc(t),null);case 4:return ie(),e===null&&Cd(t.stateNode.containerInfo),jc(t),null;case 10:return zi(t.type),jc(t),null;case 19:if(H(eo),r=t.memoizedState,r===null)return jc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Ac(r,!1);else{if(Ul!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=to(e),o!==null){for(t.flags|=128,Ac(r,!1),e=o.updateQueue,t.updateQueue=e,kc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ni(n,e),n=n.sibling;return U(eo,eo.current&1|2),J&&yi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ye()>eu&&(t.flags|=128,a=!0,Ac(r,!1),t.lanes=4194304)}}else{if(!a){if(e=to(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,kc(t,e),Ac(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!J)return jc(t),null}else 2*ye()-r.renderingStartTime>eu&&n!==536870912&&(t.flags|=128,a=!0,Ac(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(jc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ye(),e.sibling=null,n=eo.current,U(eo,a?n&1|2:n&1),J&&yi(t,r.treeForkCount),e);case 22:case 23:return $a(t),Ka(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(jc(t),t.subtreeFlags&6&&(t.flags|=8192)):jc(t),n=t.updateQueue,n!==null&&kc(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&&H(ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zi(Zi),jc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Nc(e,t){switch(Si(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zi(Zi),ie(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return oe(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(eo),null;case 4:return ie(),null;case 10:return zi(t.type),null;case 22:case 23:return $a(t),Ka(),e!==null&&H(ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zi(Zi),null;case 25:return null;default:return null}}function Pc(e,t){switch(Si(t),t.tag){case 3:zi(Zi),ie();break;case 26:case 27:case 5:oe(t);break;case 4:ie();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:H(eo);break;case 10:zi(t.type);break;case 22:case 23:$a(t),Ka(),e!==null&&H(ca);break;case 24:zi(Zi)}}function Fc(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){Wu(t,t.return,e)}}function Ic(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){Wu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Wu(t,t.return,e)}}function Lc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Va(t,n)}catch(t){Wu(e,e.return,t)}}}function Rc(e,t,n){n.props=zs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Wu(e,t,n)}}function zc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Wu(e,t,n)}}function Bc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Wu(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){Wu(e,t,n)}else n.current=null}}function Vc(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){Wu(e,e.return,t)}}function Hc(e,t,n){try{var r=e.stateNode;Ld(r,e.type,n,t),r[$e]=t}catch(t){Wu(e,e.return,t)}}function Uc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&$d(e.type)||e.tag===4}function Wc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Uc(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&&$d(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 Gc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Wt));else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Gc(e,t,n),e=e.sibling;e!==null;)Gc(e,t,n),e=e.sibling}function Kc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&$d(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Kc(e,t,n),e=e.sibling;e!==null;)Kc(e,t,n),e=e.sibling}function qc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Id(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Wu(e,e.return,t)}}var Jc=!1,Yc=!1,Xc=!1,Zc=typeof WeakSet==`function`?WeakSet:Set,Qc=null;function $c(e,t){if(e=e.containerInfo,Bd=lp,e=vr(e),yr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Vd={focusedElem:e,selectionRange:n},lp=!1,Qc=t;Qc!==null;)if(t=Qc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Qc=e;else for(;Qc!==null;){switch(t=Qc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=zs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Wu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)nf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:nf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Qc=e;break}Qc=t.return}}function el(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:hl(e,n),r&4&&Fc(5,n);break;case 1:if(hl(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Wu(n,n.return,e)}else{var i=zs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Wu(n,n.return,e)}}}r&64&&Lc(n),r&512&&zc(n,n.return);break;case 3:if(hl(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{Va(e,t)}catch(e){Wu(n,n.return,e)}}break;case 27:t===null&&r&4&&qc(n);case 26:case 5:hl(e,n),t===null&&r&4&&Vc(n),r&512&&zc(n,n.return);break;case 12:hl(e,n);break;case 31:hl(e,n),r&4&&ol(e,n);break;case 13:hl(e,n),r&4&&sl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ju.bind(null,n),lf(e,n))));break;case 22:if(r=n.memoizedState!==null||Jc,!r){t=t!==null&&t.memoizedState!==null||Yc,i=Jc;var a=Yc;Jc=r,(Yc=t)&&!a?_l(e,n,!!(n.subtreeFlags&8772)):hl(e,n),Jc=i,Yc=a}break;case 30:break;default:hl(e,n)}}function tl(e){var t=e.alternate;t!==null&&(e.alternate=null,tl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ot(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 nl=null,rl=!1;function il(e,t,n){for(n=n.child;n!==null;)al(e,t,n),n=n.sibling}function al(e,t,n){if(ke&&typeof ke.onCommitFiberUnmount==`function`)try{ke.onCommitFiberUnmount(Oe,n)}catch{}switch(n.tag){case 26:Yc||Bc(n,t),il(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Yc||Bc(n,t);var r=nl,i=rl;$d(n.type)&&(nl=n.stateNode,rl=!1),il(e,t,n),hf(n.stateNode),nl=r,rl=i;break;case 5:Yc||Bc(n,t);case 6:if(r=nl,i=rl,nl=null,il(e,t,n),nl=r,rl=i,nl!==null){if(rl)try{(nl.nodeType===9?nl.body:nl.nodeName===`HTML`?nl.ownerDocument.body:nl).removeChild(n.stateNode)}catch(e){Wu(n,t,e)}else try{nl.removeChild(n.stateNode)}catch(e){Wu(n,t,e)}}break;case 18:nl!==null&&(rl?(e=nl,ef(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Fp(e)):ef(nl,n.stateNode));break;case 4:r=nl,i=rl,nl=n.stateNode.containerInfo,rl=!0,il(e,t,n),nl=r,rl=i;break;case 0:case 11:case 14:case 15:Ic(2,n,t),Yc||Ic(4,n,t),il(e,t,n);break;case 1:Yc||(Bc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Rc(n,t,r)),il(e,t,n);break;case 21:il(e,t,n);break;case 22:Yc=(r=Yc)||n.memoizedState!==null,il(e,t,n),Yc=r;break;default:il(e,t,n)}}function ol(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Fp(e)}catch(e){Wu(t,t.return,e)}}}function sl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Fp(e)}catch(e){Wu(t,t.return,e)}}function cl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Zc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Zc),t;default:throw Error(i(435,e.tag))}}function ll(e,t){var n=cl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Yu.bind(null,e,t);t.then(r,r)}})}function ul(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if($d(c.type)){nl=c.stateNode,rl=!1;break a}break;case 5:nl=c.stateNode,rl=!1;break a;case 3:case 4:nl=c.stateNode.containerInfo,rl=!0;break a}c=c.return}if(nl===null)throw Error(i(160));al(o,s,a),nl=null,rl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)fl(t,e),t=t.sibling}var dl=null;function fl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ul(t,e),pl(e),r&4&&(Ic(3,e,e.return),Fc(3,e),Ic(5,e,e.return));break;case 1:ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),r&64&&Jc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=dl;if(ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null){if(r===null){if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[at]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Id(o,r,n),o[Qe]=e,dt(o),r=o;break a;case`link`:var s=Uf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Uf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Id(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,dt(o),r=o}e.stateNode=r}else Wf(a,e.type,e.stateNode)}else e.stateNode=Rf(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&Hc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Wf(a,e.type,e.stateNode):Rf(a,r,e.memoizedProps))}break;case 27:ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),n!==null&&r&4&&Hc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ul(t,e),pl(e),r&512&&(Yc||n===null||Bc(n,n.return)),e.flags&32){a=e.stateNode;try{It(a,``)}catch(t){Wu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Hc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Xc=!0);break;case 6:if(ul(t,e),pl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Wu(e,e.return,t)}}break;case 3:if(Hf=null,a=dl,dl=vf(t.containerInfo),ul(t,e),dl=a,pl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Fp(t.containerInfo)}catch(t){Wu(e,e.return,t)}Xc&&(Xc=!1,ml(e));break;case 4:r=dl,dl=vf(e.stateNode.containerInfo),ul(t,e),pl(e),dl=r;break;case 12:ul(t,e),pl(e);break;case 31:ul(t,e),pl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 13:ul(t,e),pl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Ql=ye()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Jc,d=Yc;if(Jc=u||a,Yc=d||l,ul(t,e),Yc=d,Jc=u,pl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Jc||Yc||gl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Wu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Wu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?tf(m,!0):tf(l.stateNode,!1)}catch(e){Wu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ll(e,n))));break;case 19:ul(t,e),pl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ll(e,r)));break;case 30:break;case 21:break;default:ul(t,e),pl(e)}}function pl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Uc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Kc(e,Wc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(It(o,``),n.flags&=-33),Kc(e,Wc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Gc(e,Wc(e),s);break;default:throw Error(i(161))}}catch(t){Wu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ml(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;ml(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function hl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)el(e,t.alternate,t),t=t.sibling}function gl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Ic(4,t,t.return),gl(t);break;case 1:Bc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Rc(t,t.return,n),gl(t);break;case 27:hf(t.stateNode);case 26:case 5:Bc(t,t.return),gl(t);break;case 22:t.memoizedState===null&&gl(t);break;case 30:gl(t);break;default:gl(t)}e=e.sibling}}function _l(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:_l(i,a,n),Fc(4,a);break;case 1:if(_l(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Wu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ba(c[i],s)}catch(e){Wu(r,r.return,e)}}n&&o&64&&Lc(a),zc(a,a.return);break;case 27:qc(a);case 26:case 5:_l(i,a,n),n&&r===null&&o&4&&Vc(a),zc(a,a.return);break;case 12:_l(i,a,n);break;case 31:_l(i,a,n),n&&o&4&&ol(i,a);break;case 13:_l(i,a,n),n&&o&4&&sl(i,a);break;case 22:a.memoizedState===null&&_l(i,a,n),zc(a,a.return);break;case 30:break;default:_l(i,a,n)}t=t.sibling}}function vl(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&&$i(n))}function yl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e))}function bl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)xl(e,t,n,r),t=t.sibling}function xl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:bl(e,t,n,r),i&2048&&Fc(9,t);break;case 1:bl(e,t,n,r);break;case 3:bl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&$i(e)));break;case 12:if(i&2048){bl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Wu(t,t.return,e)}}else bl(e,t,n,r);break;case 31:bl(e,t,n,r);break;case 13:bl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?bl(e,t,n,r):(a._visibility|=2,Sl(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?bl(e,t,n,r):Cl(e,t),i&2048&&vl(o,t);break;case 24:bl(e,t,n,r),i&2048&&yl(t.alternate,t);break;default:bl(e,t,n,r)}}function Sl(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:Sl(a,o,s,c,i),Fc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Sl(a,o,s,c,i)):u._visibility&2?Sl(a,o,s,c,i):Cl(a,o),i&&l&2048&&vl(o.alternate,o);break;case 24:Sl(a,o,s,c,i),i&&l&2048&&yl(o.alternate,o);break;default:Sl(a,o,s,c,i)}t=t.sibling}}function Cl(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:Cl(n,r),i&2048&&vl(r.alternate,r);break;case 24:Cl(n,r),i&2048&&yl(r.alternate,r);break;default:Cl(n,r)}t=t.sibling}}var wl=8192;function Tl(e,t,n){if(e.subtreeFlags&wl)for(e=e.child;e!==null;)El(e,t,n),e=e.sibling}function El(e,t,n){switch(e.tag){case 26:Tl(e,t,n),e.flags&wl&&e.memoizedState!==null&&qf(n,dl,e.memoizedState,e.memoizedProps);break;case 5:Tl(e,t,n);break;case 3:case 4:var r=dl;dl=vf(e.stateNode.containerInfo),Tl(e,t,n),dl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=wl,wl=16777216,Tl(e,t,n),wl=r):Tl(e,t,n));break;default:Tl(e,t,n)}}function Dl(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 Ol(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Qc=r,jl(r,e)}Dl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)kl(e),e=e.sibling}function kl(e){switch(e.tag){case 0:case 11:case 15:Ol(e),e.flags&2048&&Ic(9,e,e.return);break;case 3:Ol(e);break;case 12:Ol(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Al(e)):Ol(e);break;default:Ol(e)}}function Al(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Qc=r,jl(r,e)}Dl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Ic(8,t,t.return),Al(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Al(t));break;default:Al(t)}e=e.sibling}}function jl(e,t){for(;Qc!==null;){var n=Qc;switch(n.tag){case 0:case 11:case 15:Ic(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:$i(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Qc=r;else a:for(n=e;Qc!==null;){r=Qc;var i=r.sibling,a=r.return;if(tl(r),r===n){Qc=null;break a}if(i!==null){i.return=a,Qc=i;break a}Qc=a}}}var Ml={getCacheForType:function(e){var t=Gi(Zi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Gi(Zi).controller.signal}},Nl=typeof WeakMap==`function`?WeakMap:Map,Pl=0,Fl=null,Z=null,Il=0,Ll=0,Rl=null,zl=!1,Bl=!1,Vl=!1,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=null,Xl=null,Zl=!1,Ql=0,$l=0,eu=1/0,tu=null,nu=null,ru=0,iu=null,au=null,ou=0,su=0,cu=null,lu=null,uu=0,du=null;function fu(){return Pl&2&&Il!==0?Il&-Il:I.T===null?Ye():dd()}function pu(){if(ql===0){if(!(Il&536870912)||J){var e=Fe;Fe<<=1,!(Fe&3932160)&&(Fe=262144),ql=e}else ql=536870912}return e=qa.current,e!==null&&(e.flags|=32),ql}function mu(e,t,n){(e===Fl&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)&&(xu(e,0),vu(e,Il,ql,!1)),He(e,n),(!(Pl&2)||e!==Fl)&&(e===Fl&&(!(Pl&2)&&(Gl|=n),Ul===4&&vu(e,Il,ql,!1)),rd(e))}function hu(e,t,n){if(Pl&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||Re(e,t),a=r?ku(e,t):Du(e,t,!0),o=r;do{if(a===0){Bl&&!r&&vu(e,t,0,!1);break}if(n=e.current.alternate,o&&!_u(n)){a=Du(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=Yl;var l=c.current.memoizedState.isDehydrated;if(l&&(xu(c,s).flags|=256),s=Du(c,s,!1),s!==2){if(Vl&&!l){c.errorRecoveryDisabledLanes|=o,Gl|=o,a=4;break a}o=Xl,Xl=a,o!==null&&(Xl===null?Xl=o:Xl.push.apply(Xl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){xu(e,0),vu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:vu(r,t,ql,!zl);break a;case 2:Xl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Ql+300-ye(),10<a)){if(vu(r,t,ql,!zl),Le(r,0,!0)!==0)break a;ou=t,r.timeoutHandle=Jd(gu.bind(null,r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,`Throttled`,-0,0),a);break a}gu(r,n,Xl,tu,Zl,t,ql,Gl,Jl,zl,o,null,-0,0)}break}while(1);rd(e)}function gu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Wt},El(t,a,d);var m=(a&62914560)===a?Ql-ye():(a&4194048)===a?$l-ye():0;if(m=Yf(d,m),m!==null){ou=a,e.cancelPendingCommit=m(Iu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),vu(e,a,o,!l);return}}Iu(e,t,a,n,r,i,o,s,c)}function _u(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(!pr(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 vu(e,t,n,r){t&=~Kl,t&=~Gl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ae(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function yu(){return Pl&6?!0:(id(0,!1),!1)}function bu(){if(Z!==null){if(Ll===0)var e=Z.return;else e=Z,Li=Ii=null,xo(e),Sa=null,Ca=0,e=Z;for(;e!==null;)Pc(e.alternate,e),e=e.return;Z=null}}function xu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Yd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ou=0,bu(),Fl=e,Z=n=ti(e.current,null),Il=t,Ll=0,Rl=null,zl=!1,Bl=Re(e,t),Vl=!1,Jl=ql=Kl=Gl=Wl=Ul=0,Xl=Yl=null,Zl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ae(r),a=1<<i;t|=e[i],r&=~a}return Hl=t,Gr(),n}function Su(e,t){X=null,I.H=js,t===fa||t===ma?(t=ba(),Ll=3):t===pa?(t=ba(),Ll=4):Ll=t===Ys?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Rl=t,Z===null&&(Ul=1,Us(e,li(t,e.current)))}function Cu(){var e=qa.current;return e===null?!0:(Il&4194048)===Il?Ja===null:(Il&62914560)===Il||Il&536870912?e===Ja:!1}function wu(){var e=I.H;return I.H=js,e===null?js:e}function Tu(){var e=I.A;return I.A=Ml,e}function Eu(){Ul=4,zl||(Il&4194048)!==Il&&qa.current!==null||(Bl=!0),!(Wl&134217727)&&!(Gl&134217727)||Fl===null||vu(Fl,Il,ql,!1)}function Du(e,t,n){var r=Pl;Pl|=2;var i=wu(),a=Tu();(Fl!==e||Il!==t)&&(tu=null,xu(e,t)),t=!1;var o=Ul;a:do try{if(Ll!==0&&Z!==null){var s=Z,c=Rl;switch(Ll){case 8:bu(),o=6;break a;case 3:case 2:case 9:case 6:qa.current===null&&(t=!0);var l=Ll;if(Ll=0,Rl=null,Nu(e,s,c,l),n&&Bl){o=0;break a}break;default:l=Ll,Ll=0,Rl=null,Nu(e,s,c,l)}}Ou(),o=Ul;break}catch(t){Su(e,t)}while(1);return t&&e.shellSuspendCounter++,Li=Ii=null,Pl=r,I.H=i,I.A=a,Z===null&&(Fl=null,Il=0,Gr()),o}function Ou(){for(;Z!==null;)ju(Z)}function ku(e,t){var n=Pl;Pl|=2;var r=wu(),a=Tu();Fl!==e||Il!==t?(tu=null,eu=ye()+500,xu(e,t)):Bl=Re(e,t);a:do try{if(Ll!==0&&Z!==null){t=Z;var o=Rl;b:switch(Ll){case 1:Ll=0,Rl=null,Nu(e,t,o,1);break;case 2:case 9:if(ga(o)){Ll=0,Rl=null,Mu(t);break}t=function(){Ll!==2&&Ll!==9||Fl!==e||(Ll=7),rd(e)},o.then(t,t);break a;case 3:Ll=7;break a;case 4:Ll=5;break a;case 7:ga(o)?(Ll=0,Rl=null,Mu(t)):(Ll=0,Rl=null,Nu(e,t,o,7));break;case 5:var s=null;switch(Z.tag){case 26:s=Z.memoizedState;case 5:case 27:var c=Z;if(s?Kf(s):c.stateNode.complete){Ll=0,Rl=null;var l=c.sibling;if(l!==null)Z=l;else{var u=c.return;u===null?Z=null:(Z=u,Pu(u))}break b}}Ll=0,Rl=null,Nu(e,t,o,5);break;case 6:Ll=0,Rl=null,Nu(e,t,o,6);break;case 8:bu(),Ul=6;break a;default:throw Error(i(462))}}Au();break}catch(t){Su(e,t)}while(1);return Li=Ii=null,I.H=r,I.A=a,Pl=n,Z===null?(Fl=null,Il=0,Gr(),Ul):0}function Au(){for(;Z!==null&&!_e();)ju(Z)}function ju(e){var t=Tc(e.alternate,e,Hl);e.memoizedProps=e.pendingProps,t===null?Pu(e):Z=t}function Mu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=lc(n,t,t.pendingProps,t.type,void 0,Il);break;case 11:t=lc(n,t,t.pendingProps,t.type.render,t.ref,Il);break;case 5:xo(t);default:Pc(n,t),t=Z=ni(t,Hl),t=Tc(n,t,Hl)}e.memoizedProps=e.pendingProps,t===null?Pu(e):Z=t}function Nu(e,t,n,r){Li=Ii=null,xo(t),Sa=null,Ca=0;var i=t.return;try{if(Js(e,i,t,n,Il)){Ul=1,Us(e,li(n,e.current)),Z=null;return}}catch(t){if(i!==null)throw Z=i,t;Ul=1,Us(e,li(n,e.current)),Z=null;return}t.flags&32768?(J||r===1?e=!0:Bl||Il&536870912?e=!1:(zl=e=!0,(r===2||r===9||r===3||r===6)&&(r=qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Fu(t,e)):Pu(t)}function Pu(e){var t=e;do{if(t.flags&32768){Fu(t,zl);return}e=t.return;var n=Mc(t.alternate,t,Hl);if(n!==null){Z=n;return}if(t=t.sibling,t!==null){Z=t;return}Z=t=e}while(t!==null);Ul===0&&(Ul=5)}function Fu(e,t){do{var n=Nc(e.alternate,e);if(n!==null){n.flags&=32767,Z=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Z=e;return}Z=e=n}while(e!==null);Ul=6,Z=null}function Iu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Vu();while(ru!==0);if(Pl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Wr,Ue(e,n,o,s,c,l),e===Fl&&(Z=Fl=null,Il=0),au=t,iu=e,ou=n,su=o,cu=a,lu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Xu(Ce,function(){return Hu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=I.T,I.T=null,a=L.p,L.p=2,s=Pl,Pl|=4;try{$c(e,t,n)}finally{Pl=s,L.p=a,I.T=r}}ru=1,Lu(),Ru(),zu()}}function Lu(){if(ru===1){ru=0;var e=iu,t=au,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Pl;Pl|=4;try{fl(t,e);var a=Vd,o=vr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&_r(s.ownerDocument.documentElement,s)){if(c!==null&&yr(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 _=gr(s,h),v=gr(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}}lp=!!Bd,Vd=Bd=null}finally{Pl=i,L.p=r,I.T=n}}e.current=t,ru=2}}function Ru(){if(ru===2){ru=0;var e=iu,t=au,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=I.T,I.T=null;var r=L.p;L.p=2;var i=Pl;Pl|=4;try{el(e,t.alternate,t)}finally{Pl=i,L.p=r,I.T=n}}ru=3}}function zu(){if(ru===4||ru===3){ru=0,ve();var e=iu,t=au,n=ou,r=lu;t.subtreeFlags&10256||t.flags&10256?ru=5:(ru=0,au=iu=null,Bu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(nu=null),Je(n),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot==`function`)try{ke.onCommitFiberRoot(Oe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=I.T,i=L.p,L.p=2,I.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{I.T=t,L.p=i}}ou&3&&Vu(),rd(e),i=e.pendingLanes,n&261930&&i&42?e===du?uu++:(uu=0,du=e):uu=0,id(0,!1)}}function Bu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,$i(t)))}function Vu(){return Lu(),Ru(),zu(),Hu()}function Hu(){if(ru!==5)return!1;var e=iu,t=su;su=0;var n=Je(ou),r=I.T,a=L.p;try{L.p=32>n?32:n,I.T=null,n=cu,cu=null;var o=iu,s=ou;if(ru=0,au=iu=null,ou=0,Pl&6)throw Error(i(331));var c=Pl;if(Pl|=4,kl(o.current),xl(o,o.current,s,n),Pl=c,id(0,!1),ke&&typeof ke.onPostCommitFiberRoot==`function`)try{ke.onPostCommitFiberRoot(Oe,o)}catch{}return!0}finally{L.p=a,I.T=r,Bu(e,t)}}function Uu(e,t,n){t=li(n,t),t=Gs(e.stateNode,t,2),e=Pa(e,t,2),e!==null&&(He(e,2),rd(e))}function Wu(e,t,n){if(e.tag===3)Uu(e,e,n);else for(;t!==null;){if(t.tag===3){Uu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(nu===null||!nu.has(r))){e=li(n,e),n=Ks(2),r=Pa(t,n,2),r!==null&&(qs(n,r,t,e),He(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Nl;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)||(Vl=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Fl===e&&(Il&n)===n&&(Ul===4||Ul===3&&(Il&62914560)===Il&&300>ye()-Ql?!(Pl&2)&&xu(e,0):Kl|=n,Jl===Il&&(Jl=0)),rd(e)}function qu(e,t){t===0&&(t=Be()),e=Jr(e,t),e!==null&&(He(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(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),qu(e,n)}function Xu(e,t){return he(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;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-Ae(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=Il,a=Le(r,r===Fl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Re(r,a)||(n=!0,ld(r,a))}r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&qd()&&(e=nd);for(var t=ye(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}ru!==0&&ru!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ae(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ze(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Fl,n=Il,n=Le(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ll===2||Ll===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ge(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Re(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ge(r),Je(n)){case 2:case 8:n=Se;break;case 32:n=Ce;break;case 268435456:n=Te;break;default:n=Ce}return r=cd.bind(null,e),n=he(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ge(r),e.callbackPriority=2,e.callbackNode=null,2}function cd(e,t){if(ru!==0&&ru!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Vu()&&e.callbackNode!==n)return null;var r=Il;return r=Le(e,e===Fl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(hu(e,r,t),sd(e,ye()),e.callbackNode!=null&&e.callbackNode===n?cd.bind(null,e):null)}function ld(e,t){if(Vu())return null;hu(e,t,!0)}function ud(){Zd(function(){Pl&6?he(xe,ad):od()})}function dd(){if(nd===0){var e=na;e===0&&(e=Pe,Pe<<=1,!(Pe&261888)&&(Pe=256)),nd=e}return nd}function fd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Ut(``+e)}function pd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function md(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=fd((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?fd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new fn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(nd!==0){var e=o?pd(i,o):new FormData(i);_s(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?pd(i,o):new FormData(i),_s(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var hd=0;hd<zr.length;hd++){var gd=zr[hd];Br(gd.toLowerCase(),`on`+(gd[0].toUpperCase()+gd.slice(1)))}Br(jr,`onAnimationEnd`),Br(Mr,`onAnimationIteration`),Br(Nr,`onAnimationStart`),Br(`dblclick`,`onDoubleClick`),Br(`focusin`,`onFocus`),Br(`focusout`,`onBlur`),Br(Pr,`onTransitionRun`),Br(Fr,`onTransitionStart`),Br(Ir,`onTransitionCancel`),Br(Lr,`onTransitionEnd`),ht(`onMouseEnter`,[`mouseout`,`mouseover`]),ht(`onMouseLeave`,[`mouseout`,`mouseover`]),ht(`onPointerEnter`,[`pointerout`,`pointerover`]),ht(`onPointerLeave`,[`pointerout`,`pointerover`]),mt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),mt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),mt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),mt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),mt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),mt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var _d=`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(` `),vd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(_d));function yd(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){Vr(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){Vr(e)}i.currentTarget=null,a=c}}}}function bd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(wd(t,e,2,!1),n.add(r))}function xd(e,t,n){var r=0;t&&(r|=4),wd(n,e,r,t)}var Sd=`_reactListening`+Math.random().toString(36).slice(2);function Cd(e){if(!e[Sd]){e[Sd]=!0,ft.forEach(function(t){t!==`selectionchange`&&(vd.has(t)||xd(t,!1,e),xd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Sd]||(t[Sd]=!0,xd(`selectionchange`,!1,t))}}function wd(e,t,n,r){switch(gp(t)){case 2:var i=up;break;case 8:i=dp;break;default:i=fp}n=i.bind(null,t,n,e),i=void 0,!en||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 Td(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=st(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}Zt(function(){var r=a,i=Kt(n),s=[];a:{var c=Rr.get(e);if(c!==void 0){var l=fn,u=e;switch(e){case`keypress`:if(sn(n)===0)break a;case`keydown`:case`keyup`:l=An;break;case`focusin`:u=`focus`,l=xn;break;case`focusout`:u=`blur`,l=xn;break;case`beforeblur`:case`afterblur`:l=xn;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=yn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=bn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Mn;break;case jr:case Mr:case Nr:l=Sn;break;case Lr:l=Nn;break;case`scroll`:case`scrollend`:l=mn;break;case`wheel`:l=Pn;break;case`copy`:case`cut`:case`paste`:l=Cn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=jn;break;case`toggle`:case`beforetoggle`:l=Fn}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=Qt(m,p),g!=null&&d.push(Ed(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Gt&&(u=n.relatedTarget||n.fromElement)&&(st(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?st(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=yn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=jn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:lt(l),h=u==null?c:lt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,st(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Od,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&kd(s,c,l,d,!1),u!==null&&f!==null&&kd(s,f,u,d,!0)}}a:{if(c=r?lt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=tr;else if(Yn(c)){if(nr)v=dr;else{v=lr;var y=cr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Bt(r.elementType)&&(v=tr):v=ur;if(v&&=v(e,r)){Xn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Mt(c,`number`,c.value)}switch(y=r?lt(r):window,e){case`focusin`:(Yn(y)||y.contentEditable===`true`)&&(xr=y,Sr=r,Cr=null);break;case`focusout`:Cr=Sr=xr=null;break;case`mousedown`:wr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:wr=!1,Tr(s,n,i);break;case`selectionchange`:if(br)break;case`keydown`:case`keyup`:Tr(s,n,i)}var b;if(Ln)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Gn?Un(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Bn&&n.locale!==`ko`&&(Gn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Gn&&(b=on()):(nn=i,rn=`value`in nn?nn.value:nn.textContent,Gn=!0)),y=Dd(r,x),0<y.length&&(x=new wn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Wn(n),b!==null&&(x.data=b)))),(b=zn?Kn(e,n):qn(e,n))&&(x=Dd(r,`onBeforeInput`),0<x.length&&(y=new wn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),md(s,e,r,n,i)}yd(s,t)})}function Ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Dd(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=Qt(e,n),i!=null&&r.unshift(Ed(e,i,a)),i=Qt(e,t),i!=null&&r.push(Ed(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Od(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function kd(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=Qt(n,a),l!=null&&o.unshift(Ed(n,l,c))):i||(l=Qt(n,a),l!=null&&o.push(Ed(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ad=/\r\n?/g,jd=/\u0000|\uFFFD/g;function Md(e){return(typeof e==`string`?e:``+e).replace(Ad,`
|
|
9
|
+
`).replace(jd,``)}function Nd(e,t){return t=Md(t),Md(e)===t}function Pd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||It(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&It(e,``+r);break;case`className`:bt(e,`class`,r);break;case`tabIndex`:bt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:bt(e,n,r);break;case`style`:zt(e,r,o);break;case`data`:if(t!==`object`){bt(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=Ut(``+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`&&Pd(e,t,`name`,a.name,a,null),Pd(e,t,`formEncType`,a.formEncType,a,null),Pd(e,t,`formMethod`,a.formMethod,a,null),Pd(e,t,`formTarget`,a.formTarget,a,null)):(Pd(e,t,`encType`,a.encType,a,null),Pd(e,t,`method`,a.method,a,null),Pd(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Ut(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Wt);break;case`onScroll`:r!=null&&bd(`scroll`,e);break;case`onScrollEnd`:r!=null&&bd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Ut(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:bd(`beforetoggle`,e),bd(`toggle`,e),yt(e,`popover`,r);break;case`xlinkActuate`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:xt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:xt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:yt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Vt.get(n)||n,yt(e,n,r))}}function Fd(e,t,n,r,a,o){switch(n){case`style`:zt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?It(e,r):(typeof r==`number`||typeof r==`bigint`)&&It(e,``+r);break;case`onScroll`:r!=null&&bd(`scroll`,e);break;case`onScrollEnd`:r!=null&&bd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Wt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!pt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):yt(e,n,r)}}}function Id(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:bd(`error`,e),bd(`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:Pd(e,t,o,s,n,null)}}a&&Pd(e,t,`srcSet`,n.srcSet,n,null),r&&Pd(e,t,`src`,n.src,n,null);return;case`input`:bd(`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:Pd(e,t,r,d,n,null)}}jt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in bd(`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:Pd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Nt(e,!!r,n,!0):Nt(e,!!r,t,!1);return;case`textarea`:for(s in bd(`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:Pd(e,t,s,c,n,null)}Ft(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:Pd(e,t,l,r,n,null)}return;case`dialog`:bd(`beforetoggle`,e),bd(`toggle`,e),bd(`cancel`,e),bd(`close`,e);break;case`iframe`:case`object`:bd(`load`,e);break;case`video`:case`audio`:for(r=0;r<_d.length;r++)bd(_d[r],e);break;case`image`:bd(`error`,e),bd(`load`,e);break;case`details`:bd(`toggle`,e);break;case`embed`:case`source`:case`link`:bd(`error`,e),bd(`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:Pd(e,t,u,r,n,null)}return;default:if(Bt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Fd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Pd(e,t,c,r,n,null))}function Ld(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)||Pd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Pd(e,t,p,m,r,f)}}At(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)||Pd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Pd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Nt(e,!!n,n?[]:``,!1):Nt(e,!!n,t,!0)):Nt(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:Pd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Pd(e,t,s,a,r,o)}Pt(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:Pd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Pd(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)&&Pd(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:Pd(e,t,u,p,r,m)}return;default:if(Bt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Fd(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||Fd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Pd(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||Pd(e,t,f,p,r,m)}function Rd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function zd(){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&&Rd(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&&Rd(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 Bd=null,Vd=null;function Hd(e){return e.nodeType===9?e:e.ownerDocument}function Ud(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 Wd(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 Gd(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 Kd=null;function qd(){var e=window.event;return e&&e.type===`popstate`?e!==Kd&&(Kd=e,!0):(Kd=null,!1)}var Jd=typeof setTimeout==`function`?setTimeout:void 0,Yd=typeof clearTimeout==`function`?clearTimeout:void 0,Xd=typeof Promise==`function`?Promise:void 0,Zd=typeof queueMicrotask==`function`?queueMicrotask:Xd===void 0?Jd:function(e){return Xd.resolve(null).then(e).catch(Qd)};function Qd(e){setTimeout(function(){throw e})}function $d(e){return e===`head`}function ef(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),Fp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)hf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,hf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[at]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&hf(e.ownerDocument.body)}n=i}while(n);Fp(t)}function tf(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 nf(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`:nf(n),ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rf(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[at])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=uf(e.nextSibling),e===null)break}return null}function af(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=uf(e.nextSibling),e===null))return null;return e}function of(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=uf(e.nextSibling),e===null))return null;return e}function sf(e){return e.data===`$?`||e.data===`$~`}function cf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function lf(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 uf(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 df=null;function ff(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return uf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function pf(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 mf(e,t,n){switch(t=Hd(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 hf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ot(e)}var gf=new Map,_f=new Set;function vf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yf=L.d;L.d={f:bf,r:xf,D:wf,C:Tf,L:Ef,m:Df,X:kf,S:Of,M:Af};function bf(){var e=yf.f(),t=yu();return e||t}function xf(e){var t=ct(e);t!==null&&t.tag===5&&t.type===`form`?ys(t):yf.r(e)}var Sf=typeof document>`u`?null:document;function Cf(e,t,n){var r=Sf;if(r&&typeof t==`string`&&t){var i=kt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_f.has(i)||(_f.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Id(t,`link`,e),dt(t),r.head.appendChild(t)))}}function wf(e){yf.D(e),Cf(`dns-prefetch`,e,null)}function Tf(e,t){yf.C(e,t),Cf(`preconnect`,e,t)}function Ef(e,t,n){yf.L(e,t,n);var r=Sf;if(r&&e&&t){var i=`link[rel="preload"][as="`+kt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+kt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+kt(n.imageSizes)+`"]`)):i+=`[href="`+kt(e)+`"]`;var a=i;switch(t){case`style`:a=Mf(e);break;case`script`:a=If(e)}gf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nf(a))||t===`script`&&r.querySelector(Lf(a))||(t=r.createElement(`link`),Id(t,`link`,e),dt(t),r.head.appendChild(t)))}}function Df(e,t){yf.m(e,t);var n=Sf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+kt(r)+`"][href="`+kt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=If(e)}if(!gf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),gf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Lf(a)))return}r=n.createElement(`link`),Id(r,`link`,e),dt(r),n.head.appendChild(r)}}}function Of(e,t,n){yf.S(e,t,n);var r=Sf;if(r&&e){var i=ut(r).hoistableStyles,a=Mf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gf.get(a))&&Bf(e,n);var c=o=r.createElement(`link`);dt(c),Id(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,zf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function kf(e,t){yf.X(e,t);var n=Sf;if(n&&e){var r=ut(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=m({src:e,async:!0},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),dt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t){yf.M(e,t);var n=Sf;if(n&&e){var r=ut(n).hoistableScripts,i=If(e),a=r.get(i);a||(a=n.querySelector(Lf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=gf.get(i))&&Vf(e,t),a=n.createElement(`script`),dt(a),Id(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t,n,r){var a=(a=te.current)?vf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Mf(n.href),n=ut(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mf(n.href);var o=ut(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(Nf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),gf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gf.set(e,n),o||Ff(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=If(n),n=ut(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mf(e){return`href="`+kt(e)+`"`}function Nf(e){return`link[rel="stylesheet"][`+e+`]`}function Pf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Ff(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Id(t,`link`,n),dt(t),e.head.appendChild(t))}function If(e){return`[src="`+kt(e)+`"]`}function Lf(e){return`script[async]`+e}function Rf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+kt(n.href)+`"]`);if(r)return t.instance=r,dt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),dt(r),Id(r,`style`,a),zf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mf(n.href);var o=e.querySelector(Nf(a));if(o)return t.state.loading|=4,t.instance=o,dt(o),o;r=Pf(n),(a=gf.get(a))&&Bf(r,a),o=(e.ownerDocument||e).createElement(`link`),dt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Id(o,`link`,r),t.state.loading|=4,zf(o,n.precedence,e),t.instance=o;case`script`:return o=If(n.src),(a=e.querySelector(Lf(o)))?(t.instance=a,dt(a),a):(r=n,(a=gf.get(o))&&(r=m({},n),Vf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),dt(a),Id(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,zf(r,n.precedence,e));return t.instance}function zf(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 Bf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Vf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Hf=null;function Uf(e,t,n){if(Hf===null){var r=new Map,i=Hf=new Map;i.set(n,r)}else i=Hf,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[at]||a[Qe]||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 Wf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Gf(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 Kf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function qf(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=Mf(r.href),a=t.querySelector(Nf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Xf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,dt(a);return}a=t.ownerDocument||t,r=Pf(r),(i=gf.get(i))&&Bf(r,i),a=a.createElement(`link`),dt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Id(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=Xf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Jf=0;function Yf(e,t){return e.stylesheets&&e.count===0&&Qf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Jf===0&&(Jf=62500*zd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Qf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Jf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Xf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Qf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zf=null;function Qf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zf=new Map,t.forEach($f,e),Zf=null,Xf.call(e))}function $f(e,t){if(!(t.state.loading&4)){var n=Zf.get(e);if(n)var r=n.get(null);else{n=new Map,Zf.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=Xf.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 ep={$$typeof:C,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function tp(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=Ve(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ve(0),this.hiddenUpdates=Ve(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function np(e,t,n,r,i,a,o,s,c,l,u,d){return e=new tp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=$r(3,null,null,t),e.current=a,a.stateNode=e,t=Qi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ja(a),e}function rp(e){return e?(e=Zr,e):Zr}function ip(e,t,n,r,i,a){i=rp(i),r.context===null?r.context=i:r.pendingContext=i,r=Na(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Pa(e,r,t),n!==null&&(mu(n,e,t),Fa(n,e,t))}function ap(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function op(e,t){ap(e,t),(e=e.alternate)&&ap(e,t)}function sp(e){if(e.tag===13||e.tag===31){var t=Jr(e,67108864);t!==null&&mu(t,e,67108864),op(e,67108864)}}function cp(e){if(e.tag===13||e.tag===31){var t=fu();t=qe(t);var n=Jr(e,t);n!==null&&mu(n,e,t),op(e,t)}}var lp=!0;function up(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=2,fp(e,t,n,r)}finally{L.p=a,I.T=i}}function dp(e,t,n,r){var i=I.T;I.T=null;var a=L.p;try{L.p=8,fp(e,t,n,r)}finally{L.p=a,I.T=i}}function fp(e,t,n,r){if(lp){var i=pp(r);if(i===null)Td(e,t,r,mp,n),Tp(e,r);else if(Dp(i,e,t,n,r))r.stopPropagation();else if(Tp(e,r),t&4&&-1<wp.indexOf(e)){for(;i!==null;){var a=ct(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ie(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ae(o);s.entanglements[1]|=c,o&=~c}rd(a),!(Pl&6)&&(eu=ye()+500,id(0,!1))}}break;case 31:case 13:s=Jr(a,2),s!==null&&mu(s,a,2),yu(),op(a,2)}if(a=pp(r),a===null&&Td(e,t,r,mp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Td(e,t,r,null,n)}}function pp(e){return e=Kt(e),hp(e)}var mp=null;function hp(e){if(mp=null,e=st(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 mp=e,null}function gp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(be()){case xe:return 2;case Se:return 8;case Ce:case we:return 32;case Te:return 268435456;default:return 32}default:return 32}}var _p=!1,vp=null,yp=null,bp=null,xp=new Map,Sp=new Map,Cp=[],wp=`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 Tp(e,t){switch(e){case`focusin`:case`focusout`:vp=null;break;case`dragenter`:case`dragleave`:yp=null;break;case`mouseover`:case`mouseout`:bp=null;break;case`pointerover`:case`pointerout`:xp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Sp.delete(t.pointerId)}}function Ep(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=ct(t),t!==null&&sp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Dp(e,t,n,r,i){switch(t){case`focusin`:return vp=Ep(vp,e,t,n,r,i),!0;case`dragenter`:return yp=Ep(yp,e,t,n,r,i),!0;case`mouseover`:return bp=Ep(bp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return xp.set(a,Ep(xp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Sp.set(a,Ep(Sp.get(a)||null,e,t,n,r,i)),!0}return!1}function Op(e){var t=st(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,Xe(e.priority,function(){cp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){cp(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 kp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Gt=r,n.target.dispatchEvent(r),Gt=null}else return t=ct(n),t!==null&&sp(t),e.blockedOn=n,!1;t.shift()}return!0}function Ap(e,t,n){kp(e)&&n.delete(t)}function jp(){_p=!1,vp!==null&&kp(vp)&&(vp=null),yp!==null&&kp(yp)&&(yp=null),bp!==null&&kp(bp)&&(bp=null),xp.forEach(Ap),Sp.forEach(Ap)}function Mp(e,n){e.blockedOn===n&&(e.blockedOn=null,_p||(_p=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jp)))}var Np=null;function Pp(e){Np!==e&&(Np=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Np===e&&(Np=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(hp(r||n)===null)continue;break}var a=ct(n);a!==null&&(e.splice(t,3),t-=3,_s(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Fp(e){function t(t){return Mp(t,e)}vp!==null&&Mp(vp,e),yp!==null&&Mp(yp,e),bp!==null&&Mp(bp,e),xp.forEach(t),Sp.forEach(t);for(var n=0;n<Cp.length;n++){var r=Cp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Cp.length&&(n=Cp[0],n.blockedOn===null);)Op(n),n.blockedOn===null&&Cp.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[$e]||null;if(typeof a==`function`)o||Pp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(hp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Pp(n)}}}function Ip(){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 Lp(e){this._internalRoot=e}Rp.prototype.render=Lp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;ip(n,fu(),e,t,null,null)},Rp.prototype.unmount=Lp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ip(e.current,2,null,e,null,null),yu(),t[et]=null}};function Rp(e){this._internalRoot=e}Rp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Cp.length&&t!==0&&t<Cp[n].priority;n++);Cp.splice(n,0,e),n===0&&Op(e)}};var zp=n.version;if(zp!==`19.2.8`)throw Error(i(527,zp,`19.2.8`));L.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 Bp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:I,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Vp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vp.isDisabled&&Vp.supportsFiber)try{Oe=Vp.inject(Bp),ke=Vp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Bs,s=Vs,c=Hs;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=np(e,1,!1,null,null,n,r,null,o,s,c,Ip),e[et]=t.current,Cd(e),new Lp(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=typeof window<`u`?v.useLayoutEffect:v.useEffect,b={},x;function S(){if(x)return b;x=1,Object.defineProperty(b,"__esModule",{value:!0}),b.styleq=void 0;var e=new WeakMap,t=`$$css`;function n(n){var r,i,a;return n!=null&&(r=n.disableCache===!0,i=n.disableMix===!0,a=n.transform),function(){for(var n=[],o=``,s=null,c=``,l=r?null:e,u=Array(arguments.length),d=0;d<arguments.length;d++)u[d]=arguments[d];for(;u.length>0;){var f=u.pop();if(f!=null&&f!==!1){if(Array.isArray(f)){for(var p=0;p<f.length;p++)u.push(f[p]);continue}var m=a==null?f:a(f);if(m.$$css!=null){var h=``;if(l!=null&&l.has(m)){var g=l.get(m);g!=null&&(h=g[0],c=g[2],n.push.apply(n,g[1]),l=g[3])}else{var _=[];for(var v in m){var y=m[v];if(v===t){var b=m[v];b!==!0&&(c=c?b+`; `+c:b);continue}typeof y==`string`||y===null?n.includes(v)||(n.push(v),l!=null&&_.push(v),typeof y==`string`&&(h+=h?` `+y:y)):console.error(`styleq: ${v} typeof ${String(y)} is not "string" or "null".`)}if(l!=null){var x=new WeakMap;l.set(m,[h,_,c,x]),l=x}}h&&(o=o?h+` `+o:h)}else if(i)s??={},s=Object.assign({},m,s);else{var S=null;for(var C in m){var w=m[C];w!==void 0&&(n.includes(C)||(w!=null&&(s??={},S??={},S[C]=w),n.push(C),l=null))}S!=null&&(s=Object.assign(S,s))}}}return[o,s,c]}}var r=b.styleq=n();return r.factory=n,b}var C=S();function w(...e){let[t,n,r]=C.styleq(e),i={};return t!=null&&t!==``&&(i.className=t),n!=null&&Object.keys(n).length>0&&(i.style=n),r!=null&&r!==``&&(i[`data-style-src`]=r),i}Object.freeze({});var T={"--color-accent":`light-dark(#0064E0, #2694FE)`,"--color-accent-muted":`light-dark(#0082FB33, #0082FB3F)`,"--color-on-accent":`light-dark(#FFFFFF, #FFFFFF)`,"--color-neutral":`light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))`,"--color-background-surface":`light-dark(#FFFFFF, #1F1F22)`,"--color-background-body":`light-dark(#F1F4F7, #111112)`,"--color-overlay":`light-dark(#01122866, #11111299)`,"--color-overlay-hover":`light-dark(#0536590C, #FFFFFF0C)`,"--color-overlay-pressed":`light-dark(#05365919, #FFFFFF19)`,"--color-background-muted":`light-dark(#0536590C, #1111127F)`,"--color-text-primary":`light-dark(#0A1317, #DFE2E5)`,"--color-text-secondary":`light-dark(#4E606F, #AAAFB5)`,"--color-text-disabled":`light-dark(#A4B0BC, #6F747C)`,"--color-text-accent":`light-dark(#0064E0, #3E9EFB)`,"--color-on-dark":`light-dark(#FFFFFF, #FFFFFF)`,"--color-on-light":`light-dark(#000000, #000000)`,"--color-icon-accent":`light-dark(#0064E0, #2694FE)`,"--color-icon-primary":`light-dark(#0A1317, #DFE2E5)`,"--color-icon-secondary":`light-dark(#4E606F, #AAAFB5)`,"--color-icon-disabled":`light-dark(#A4B0BC, #6F747C)`,"--color-background-card":`light-dark(#FFFFFF, #1F1F22)`,"--color-background-popover":`light-dark(#FFFFFF, #28292C)`,"--color-background-inverted":`light-dark(#0A1317, #FFFFFF)`,"--color-background-error-inverted":`light-dark(#AA071E, #E3193B)`,"--color-success":`light-dark(#0D8626, #0D8626)`,"--color-success-muted":`light-dark(#0B991F33, #0B991F3F)`,"--color-on-success":`light-dark(#FFFFFF, #FFFFFF)`,"--color-error":`light-dark(#E3193B, #F5394F)`,"--color-error-muted":`light-dark(#E3193B33, #F5394F3F)`,"--color-on-error":`light-dark(#FFFFFF, #FFFFFF)`,"--color-warning":`light-dark(#E9AF08, #F2C00B)`,"--color-warning-muted":`light-dark(#E2A40033, #E2A4003F)`,"--color-on-warning":`light-dark(#0A1317, #0A1317)`,"--color-border":`light-dark(#05365919, #F2F4F619)`,"--color-border-emphasized":`light-dark(#CCD3DB, #494D53)`,"--color-skeleton":`light-dark(#CCD3DB, #5A5E66)`,"--color-track":`light-dark(#CCD3DB, #5A5E66)`,"--color-shadow":`light-dark(rgba(5, 54, 89, 0.1), rgba(0, 0, 0, 0.3))`,"--color-tint-hover":`light-dark(black, white)`,"--color-background-blue":`light-dark(#0171E333, #0171E333)`,"--color-border-blue":`light-dark(#0064E0, #2694FE)`,"--color-icon-blue":`light-dark(#0064E0, #2694FE)`,"--color-text-blue":`light-dark(#042F97, #AFD7FF)`,"--color-background-cyan":`light-dark(#03A7D733, #03A7D733)`,"--color-border-cyan":`light-dark(#089DD0, #0171A4)`,"--color-icon-cyan":`light-dark(#00ACC1, #26C6DA)`,"--color-text-cyan":`light-dark(#014975, #A1EEF9)`,"--color-background-gray":`light-dark(#0A131733, #666A724C)`,"--color-border-gray":`light-dark(#647685, #748695)`,"--color-icon-gray":`light-dark(#4E606F, #AAAFB5)`,"--color-text-gray":`light-dark(#0A1317, #E7EAED)`,"--color-background-green":`light-dark(#24BB5E33, #24BB5E33)`,"--color-border-green":`light-dark(#0D8626, #0B991F)`,"--color-icon-green":`light-dark(#0D8626, #26A756)`,"--color-text-green":`light-dark(#09441F, #A5F690)`,"--color-background-orange":`light-dark(#F2790233, #F2790233)`,"--color-border-orange":`light-dark(#EB6E00, #B34A01)`,"--color-icon-orange":`light-dark(#E9690B, #FB8C00)`,"--color-text-orange":`light-dark(#6B2203, #FDB876)`,"--color-background-pink":`light-dark(#E638B333, #E638B333)`,"--color-border-pink":`light-dark(#F351C0, #C02294)`,"--color-icon-pink":`light-dark(#C2185B, #EC407A)`,"--color-text-pink":`light-dark(#650053, #FEADE3)`,"--color-background-purple":`light-dark(#7952FF33, #7952FF33)`,"--color-border-purple":`light-dark(#9081FF, #7340FE)`,"--color-icon-purple":`light-dark(#5B08D8, #7952FF)`,"--color-text-purple":`light-dark(#3E0697, #B3B0FE)`,"--color-background-red":`light-dark(#E3193B33, #E3193B33)`,"--color-border-red":`light-dark(#E3193B, #F5394F)`,"--color-icon-red":`light-dark(#D31130, #E3193B)`,"--color-text-red":`light-dark(#7B0210, #FFB2B8)`,"--color-background-teal":`light-dark(#0DB7AF33, #0DB7AF33)`,"--color-border-teal":`light-dark(#08A3A3, #08767D)`,"--color-icon-teal":`light-dark(#009688, #26A69A)`,"--color-text-teal":`light-dark(#083943, #40DCCD)`,"--color-background-yellow":`light-dark(#E2A40033, #E2A40033)`,"--color-border-yellow":`light-dark(#C58600, #B47700)`,"--color-icon-yellow":`light-dark(#FBC02D, #FFEE58)`,"--color-text-yellow":`light-dark(#753F07, #FBCE03)`},E={"--color-accent":`var(--color-accent)`,"--color-accent-muted":`var(--color-accent-muted)`,"--color-on-accent":`var(--color-on-accent)`,"--color-neutral":`var(--color-neutral)`,"--color-background-surface":`var(--color-background-surface)`,"--color-background-body":`var(--color-background-body)`,"--color-overlay":`var(--color-overlay)`,"--color-overlay-hover":`var(--color-overlay-hover)`,"--color-overlay-pressed":`var(--color-overlay-pressed)`,"--color-background-muted":`var(--color-background-muted)`,"--color-text-primary":`var(--color-text-primary)`,"--color-text-secondary":`var(--color-text-secondary)`,"--color-text-disabled":`var(--color-text-disabled)`,"--color-text-accent":`var(--color-text-accent)`,"--color-on-dark":`var(--color-on-dark)`,"--color-on-light":`var(--color-on-light)`,"--color-icon-accent":`var(--color-icon-accent)`,"--color-icon-primary":`var(--color-icon-primary)`,"--color-icon-secondary":`var(--color-icon-secondary)`,"--color-icon-disabled":`var(--color-icon-disabled)`,"--color-background-card":`var(--color-background-card)`,"--color-background-popover":`var(--color-background-popover)`,"--color-background-inverted":`var(--color-background-inverted)`,"--color-background-error-inverted":`var(--color-background-error-inverted)`,"--color-success":`var(--color-success)`,"--color-success-muted":`var(--color-success-muted)`,"--color-on-success":`var(--color-on-success)`,"--color-error":`var(--color-error)`,"--color-error-muted":`var(--color-error-muted)`,"--color-on-error":`var(--color-on-error)`,"--color-warning":`var(--color-warning)`,"--color-warning-muted":`var(--color-warning-muted)`,"--color-on-warning":`var(--color-on-warning)`,"--color-border":`var(--color-border)`,"--color-border-emphasized":`var(--color-border-emphasized)`,"--color-skeleton":`var(--color-skeleton)`,"--color-track":`var(--color-track)`,"--color-shadow":`var(--color-shadow)`,"--color-tint-hover":`var(--color-tint-hover)`,"--color-background-blue":`var(--color-background-blue)`,"--color-border-blue":`var(--color-border-blue)`,"--color-icon-blue":`var(--color-icon-blue)`,"--color-text-blue":`var(--color-text-blue)`,"--color-background-cyan":`var(--color-background-cyan)`,"--color-border-cyan":`var(--color-border-cyan)`,"--color-icon-cyan":`var(--color-icon-cyan)`,"--color-text-cyan":`var(--color-text-cyan)`,"--color-background-gray":`var(--color-background-gray)`,"--color-border-gray":`var(--color-border-gray)`,"--color-icon-gray":`var(--color-icon-gray)`,"--color-text-gray":`var(--color-text-gray)`,"--color-background-green":`var(--color-background-green)`,"--color-border-green":`var(--color-border-green)`,"--color-icon-green":`var(--color-icon-green)`,"--color-text-green":`var(--color-text-green)`,"--color-background-orange":`var(--color-background-orange)`,"--color-border-orange":`var(--color-border-orange)`,"--color-icon-orange":`var(--color-icon-orange)`,"--color-text-orange":`var(--color-text-orange)`,"--color-background-pink":`var(--color-background-pink)`,"--color-border-pink":`var(--color-border-pink)`,"--color-icon-pink":`var(--color-icon-pink)`,"--color-text-pink":`var(--color-text-pink)`,"--color-background-purple":`var(--color-background-purple)`,"--color-border-purple":`var(--color-border-purple)`,"--color-icon-purple":`var(--color-icon-purple)`,"--color-text-purple":`var(--color-text-purple)`,"--color-background-red":`var(--color-background-red)`,"--color-border-red":`var(--color-border-red)`,"--color-icon-red":`var(--color-icon-red)`,"--color-text-red":`var(--color-text-red)`,"--color-background-teal":`var(--color-background-teal)`,"--color-border-teal":`var(--color-border-teal)`,"--color-icon-teal":`var(--color-icon-teal)`,"--color-text-teal":`var(--color-text-teal)`,"--color-background-yellow":`var(--color-background-yellow)`,"--color-border-yellow":`var(--color-border-yellow)`,"--color-icon-yellow":`var(--color-icon-yellow)`,"--color-text-yellow":`var(--color-text-yellow)`,__varGroupHash__:`xj0fimd`},D={"--spacing-0":`0px`,"--spacing-0-5":`2px`,"--spacing-1":`4px`,"--spacing-1-5":`6px`,"--spacing-2":`8px`,"--spacing-3":`12px`,"--spacing-4":`16px`,"--spacing-5":`20px`,"--spacing-6":`24px`,"--spacing-7":`28px`,"--spacing-8":`32px`,"--spacing-9":`36px`,"--spacing-10":`40px`,"--spacing-11":`44px`,"--spacing-12":`48px`},O={"--spacing-0":`var(--spacing-0)`,"--spacing-0-5":`var(--spacing-0-5)`,"--spacing-1":`var(--spacing-1)`,"--spacing-1-5":`var(--spacing-1-5)`,"--spacing-2":`var(--spacing-2)`,"--spacing-3":`var(--spacing-3)`,"--spacing-4":`var(--spacing-4)`,"--spacing-5":`var(--spacing-5)`,"--spacing-6":`var(--spacing-6)`,"--spacing-7":`var(--spacing-7)`,"--spacing-8":`var(--spacing-8)`,"--spacing-9":`var(--spacing-9)`,"--spacing-10":`var(--spacing-10)`,"--spacing-11":`var(--spacing-11)`,"--spacing-12":`var(--spacing-12)`,__varGroupHash__:`x1kvdh9l`},k={"--size-element-sm":`28px`,"--size-element-md":`32px`,"--size-element-lg":`36px`},A={"--radius-none":`0px`,"--radius-inner":`4px`,"--radius-element":`8px`,"--radius-container":`12px`,"--radius-page":`28px`,"--radius-chat":`28px`,"--radius-full":`9999px`},j={"--shadow-low":`0px 1px 1px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 2px 8px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))`,"--shadow-med":`0px 1px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 2px 12px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))`,"--shadow-high":`0px 2px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 8px 24px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3))`,"--shadow-inset-hover":`inset 0px 0px 0px 2px light-dark(rgba(5, 54, 89, 0.15), rgba(223, 226, 229, 0.2))`,"--shadow-inset-selected":`inset 0px 0px 0px 2px rgba(1, 113, 227, 0.5)`,"--shadow-inset-success":`inset 0px 0px 0px 2px rgba(38, 167, 86, 0.3)`,"--shadow-inset-warning":`inset 0px 0px 0px 2px rgba(226, 164, 0, 0.3)`,"--shadow-inset-error":`inset 0px 0px 0px 2px rgba(227, 25, 59, 0.3)`},M={"--duration-fast-min":`130ms`,"--duration-fast":`175ms`,"--duration-fast-max":`230ms`,"--duration-medium-min":`310ms`,"--duration-medium":`410ms`,"--duration-medium-max":`550ms`,"--duration-slow-min":`730ms`,"--duration-slow":`975ms`,"--duration-slow-max":`1300ms`},N={"--duration-fast-min":`var(--duration-fast-min)`,"--duration-fast":`var(--duration-fast)`,"--duration-fast-max":`var(--duration-fast-max)`,"--duration-medium-min":`var(--duration-medium-min)`,"--duration-medium":`var(--duration-medium)`,"--duration-medium-max":`var(--duration-medium-max)`,"--duration-slow-min":`var(--duration-slow-min)`,"--duration-slow":`var(--duration-slow)`,"--duration-slow-max":`var(--duration-slow-max)`,__varGroupHash__:`x14lkjui`},P={"--ease-standard":`cubic-bezier(0.24, 1, 0.4, 1)`},F={"--ease-standard":`var(--ease-standard)`,__varGroupHash__:`xf09i69`},I={"--font-family-body":`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`,"--font-family-code":`"SF Mono", Monaco, Consolas, monospace`,"--font-family-heading":`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`},L={"--font-size-4xs":`0.375rem`,"--font-size-3xs":`0.4375rem`,"--font-size-2xs":`0.5rem`,"--font-size-xs":`0.625rem`,"--font-size-sm":`0.75rem`,"--font-size-base":`0.875rem`,"--font-size-lg":`1.0625rem`,"--font-size-xl":`1.25rem`,"--font-size-2xl":`1.5rem`,"--font-size-3xl":`1.8125rem`,"--font-size-4xl":`2.1875rem`,"--font-size-5xl":`2.625rem`},R={"--font-weight-normal":`400`,"--font-weight-medium":`500`,"--font-weight-semibold":`600`,"--font-weight-bold":`700`},z={"--text-heading-1-size":`var(--font-size-2xl)`,"--text-heading-1-weight":`var(--font-weight-semibold)`,"--text-heading-1-leading":`1.3333`,"--text-heading-2-size":`var(--font-size-xl)`,"--text-heading-2-weight":`var(--font-weight-semibold)`,"--text-heading-2-leading":`1.4`,"--text-heading-3-size":`var(--font-size-lg)`,"--text-heading-3-weight":`var(--font-weight-semibold)`,"--text-heading-3-leading":`1.4118`,"--text-heading-4-size":`var(--font-size-base)`,"--text-heading-4-weight":`var(--font-weight-semibold)`,"--text-heading-4-leading":`1.4286`,"--text-heading-5-size":`var(--font-size-sm)`,"--text-heading-5-weight":`var(--font-weight-semibold)`,"--text-heading-5-leading":`1.6667`,"--text-heading-6-size":`var(--font-size-xs)`,"--text-heading-6-weight":`var(--font-weight-semibold)`,"--text-heading-6-leading":`1.6`,"--text-body-size":`var(--font-size-base)`,"--text-body-weight":`var(--font-weight-normal)`,"--text-body-leading":`1.4286`,"--text-large-size":`var(--font-size-lg)`,"--text-large-weight":`var(--font-weight-semibold)`,"--text-large-leading":`1.4118`,"--text-label-size":`var(--font-size-base)`,"--text-label-weight":`var(--font-weight-medium)`,"--text-label-leading":`1.4286`,"--text-code-size":`var(--font-size-base)`,"--text-code-weight":`var(--font-weight-normal)`,"--text-code-leading":`1.4286`,"--text-supporting-size":`var(--font-size-sm)`,"--text-supporting-weight":`var(--font-weight-normal)`,"--text-supporting-leading":`1.6667`,"--text-display-1-size":`var(--font-size-5xl)`,"--text-display-1-weight":`var(--font-weight-normal)`,"--text-display-1-leading":`1.2381`,"--text-display-2-size":`var(--font-size-4xl)`,"--text-display-2-weight":`var(--font-weight-normal)`,"--text-display-2-leading":`1.2571`,"--text-display-3-size":`var(--font-size-3xl)`,"--text-display-3-weight":`var(--font-weight-normal)`,"--text-display-3-leading":`1.2414`},B={transparent:{r:0,g:0,b:0,a:0},black:{r:0,g:0,b:0,a:1},white:{r:255,g:255,b:255,a:1}},V=(e,t,n)=>Math.max(t,Math.min(n,e));function H(e){return e.split(``).map(e=>e+e).join(``)}function U(e){if(typeof e!=`string`)return null;let t=e.trim().replace(/^#/,``),n=t.length===3||t.length===4?H(t):t;return n.length!==6&&n.length!==8||!/^[0-9a-fA-F]+$/.test(n)?null:{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:n.length===8?parseInt(n.slice(6,8),16)/255:1}}function W(e){let t=e.indexOf(`(`);if(t===-1||!e.trim().endsWith(`)`))return null;let n=e.slice(t+1,e.lastIndexOf(`)`)).replace(/\//g,` `).split(/[\s,]+/).map(e=>e.trim()).filter(Boolean);if(n.length<3)return null;let r=e=>V(e.endsWith(`%`)?parseFloat(e)/100*255:parseFloat(e),0,255),i=r(n[0]),a=r(n[1]),o=r(n[2]);if([i,a,o].some(Number.isNaN))return null;let s=1;if(n.length>=4){let e=n[3];if(s=e.endsWith(`%`)?parseFloat(e)/100:parseFloat(e),Number.isNaN(s))return null;s=V(s,0,1)}return{r:i,g:a,b:o,a:s}}function ee(e){let t=e.trim(),n=B[t.toLowerCase()];return n?{...n}:t.startsWith(`#`)?U(t):/^rgba?\(/i.test(t)?W(t):null}function te(e,t,n){let r=e=>V(Math.round(e),0,255).toString(16).padStart(2,`0`).toUpperCase();return`#${r(e)}${r(t)}${r(n)}`}function ne({r:e,g:t,b:n,a:r}){if(r>=1)return te(e,t,n);let i=e=>V(Math.round(e),0,255);return`rgba(${i(e)}, ${i(t)}, ${i(n)}, ${parseFloat(r.toFixed(4))})`}var re={"--color-syntax-keyword":`var(--color-text-accent)`,"--color-syntax-string":`var(--color-text-green)`,"--color-syntax-comment":`var(--color-text-secondary)`,"--color-syntax-number":`var(--color-text-orange)`,"--color-syntax-function":`var(--color-text-blue)`,"--color-syntax-type":`var(--color-text-purple)`,"--color-syntax-variable":`var(--color-text-primary)`,"--color-syntax-operator":`var(--color-text-cyan)`,"--color-syntax-constant":`var(--color-text-orange)`,"--color-syntax-tag":`var(--color-text-red)`,"--color-syntax-attribute":`var(--color-text-teal)`,"--color-syntax-property":`var(--color-text-cyan)`,"--color-syntax-punctuation":`var(--color-text-disabled)`,"--color-syntax-background":`var(--color-background-muted)`},ie={"--color-data-categorical-blue":`light-dark(#0171E3, #0171E3)`,"--color-data-categorical-orange":`light-dark(#EB6E00, #EB6E00)`,"--color-data-categorical-purple":`light-dark(#6B1EFD, #6B1EFD)`,"--color-data-categorical-green":`light-dark(#0B991F, #0B991F)`,"--color-data-categorical-pink":`light-dark(#F351C0, #F351C0)`,"--color-data-categorical-cyan":`light-dark(#0171A4, #0171A4)`,"--color-data-categorical-red":`light-dark(#F5394F, #F5394F)`,"--color-data-categorical-teal":`light-dark(#08A3A3, #08A3A3)`,"--color-data-categorical-brown":`light-dark(#965E03, #965E03)`,"--color-data-categorical-indigo":`light-dark(#6F8AFF, #6F8AFF)`,"--color-data-neutral":`light-dark(#8494A3, #8C939B)`,"--color-data-blue-5":`light-dark(#02165E, #02165E)`,"--color-data-blue-4":`light-dark(#004CBC, #004CBC)`,"--color-data-blue-3":`light-dark(#2694FE, #2694FE)`,"--color-data-blue-2":`light-dark(#78BEFF, #78BEFF)`,"--color-data-blue-1":`light-dark(#DBECFF, #DBECFF)`,"--color-data-shamrock-5":`light-dark(#0B603D, #0B603D)`,"--color-data-shamrock-4":`light-dark(#138546, #138546)`,"--color-data-shamrock-3":`light-dark(#24BB5E, #24BB5E)`,"--color-data-shamrock-2":`light-dark(#8EF7AA, #8EF7AA)`,"--color-data-shamrock-1":`light-dark(#D6FEE4, #D6FEE4)`,"--color-data-orange-5":`light-dark(#A13F04, #A13F04)`,"--color-data-orange-4":`light-dark(#D66100, #D66100)`,"--color-data-orange-3":`light-dark(#FD9537, #FD9537)`,"--color-data-orange-2":`light-dark(#FDB876, #FDB876)`,"--color-data-orange-1":`light-dark(#FFE6CF, #FFE6CF)`,"--color-data-pink-5":`light-dark(#8E1073, #8E1073)`,"--color-data-pink-4":`light-dark(#D123A1, #D123A1)`,"--color-data-pink-3":`light-dark(#F989D3, #F989D3)`,"--color-data-pink-2":`light-dark(#FEADE3, #FEADE3)`,"--color-data-pink-1":`light-dark(#FCE3F4, #FCE3F4)`,"--color-data-purple-5":`light-dark(#3E0697, #3E0697)`,"--color-data-purple-4":`light-dark(#6B1EFD, #6B1EFD)`,"--color-data-purple-3":`light-dark(#9081FF, #9081FF)`,"--color-data-purple-2":`light-dark(#B3B0FE, #B3B0FE)`,"--color-data-purple-1":`light-dark(#E8E8FB, #E8E8FB)`,"--color-data-red-5":`light-dark(#9D0519, #9D0519)`,"--color-data-red-4":`light-dark(#D31130, #D31130)`,"--color-data-red-3":`light-dark(#FB7D87, #FB7D87)`,"--color-data-red-2":`light-dark(#FFB2B8, #FFB2B8)`,"--color-data-red-1":`light-dark(#FEE4E6, #FEE4E6)`,"--color-data-teal-5":`light-dark(#08767D, #08767D)`,"--color-data-teal-4":`light-dark(#0C9293, #0C9293)`,"--color-data-teal-3":`light-dark(#0DB7AF, #0DB7AF)`,"--color-data-teal-2":`light-dark(#6CE6D8, #6CE6D8)`,"--color-data-teal-1":`light-dark(#D7FCF8, #D7FCF8)`,"--color-data-yellow-5":`light-dark(#8A5001, #8A5001)`,"--color-data-yellow-4":`light-dark(#D69804, #D69804)`,"--color-data-yellow-3":`light-dark(#FBCE03, #FBCE03)`,"--color-data-yellow-2":`light-dark(#FCEC85, #FCEC85)`,"--color-data-yellow-1":`light-dark(#FDF6BA, #FDF6BA)`,"--color-data-gray-5":`light-dark(#25363F, #333338)`,"--color-data-gray-4":`light-dark(#5D6C7B, #666A72)`,"--color-data-gray-3":`light-dark(#AFB9C4, #B2B8BE)`,"--color-data-gray-2":`light-dark(#CCD3DB, #D0D3D6)`,"--color-data-gray-1":`light-dark(#F1F4F7, #F2F4F6)`},ae={...re,...ie},oe=new Map;function se(e){oe.set(e.name,e)}function ce(e){return e==null||e===``?null:oe.get(e)??null}function le(e){return e===`base`?``:e.split(`+`).map(e=>{let[t,n]=e.split(`:`);return n===void 0?`.${t}`:/^\d/.test(n)?`.${t}-${n}`:`.${n}`}).join(``)}var ue={banner:[{property:`borderRadius`,vars:[`--_banner-radius`]}],button:[{property:`borderRadius`,vars:[`--_button-radius`]}],card:[{property:`borderRadius`,vars:[`--_card-radius`]},{property:`padding`,expand:`container`}],chat:[{property:`borderRadius`,vars:[`--_chat-composer-radius`]},{property:`padding`,vars:[`--_chat-composer-padding`]}],dialog:[{property:`borderRadius`,vars:[`--_dialog-radius`]},{property:`padding`,expand:`container`}],"dropdown-menu":[{property:`borderRadius`,vars:[`--_dropdown-menu-radius`]},{property:`padding`,vars:[`--_dropdown-menu-padding`]}],field:[{property:`borderRadius`,vars:[`--_field-radius`]}],hovercard:[{property:`borderRadius`,vars:[`--_hovercard-radius`]}],popover:[{property:`borderRadius`,vars:[`--_popover-radius`]}],"progressbar-mark":[{property:`width`,vars:[`--_progressbar-mark-width`],replaces:!0},{property:`height`,vars:[`--_progressbar-mark-height`],replaces:!0}],section:[{property:`padding`,expand:`container`}],"segmented-control":[{property:`borderRadius`,vars:[`--_segmented-control-radius`]},{property:`padding`,vars:[`--_segmented-control-padding`]}],textarea:[{property:`paddingInline`,vars:[`--_textarea-inline-padding`],replaces:!0}]};function de(e,t){let n=ue[e];return n?n.filter(e=>e.property===t):[]}var fe=`astryx`,pe=fe,me=fe,he=fe;function ge(e){return`${pe}-${e}`}function _e(e){return`data-${me}-${e}`}function ve(e){return`--${he}-${e}`}function ye(e){return`[data-${me}-theme="${e}"]`}var be=`[data-${me}-theme]`;function xe(e){return`[data-${me}-media="${e}"]`}function Se(e,t){return`.${pe}-${e}${t}`}function Ce(e,t){let n=[],r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t];a===`(`?r++:a===`)`?r=Math.max(0,r-1):a===`,`&&r===0&&(n.push(e.slice(i,t).trim()),i=t+1)}return n.push(e.slice(i).trim()),n.map(e=>`${e}${t}`).join(`, `)}function we(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}var Te=new Set([`padding`,`paddingBlock`,`paddingInline`,`paddingBlockStart`,`paddingBlockEnd`,`paddingInlineStart`,`paddingInlineEnd`]);function Ee(e){let t={};for(let[n,r]of e)switch(n){case`padding`:{let e=r.trim().split(/\s+/);e.length===1?(t.blockStart=e[0],t.blockEnd=e[0],t.inline=e[0]):e.length===2?(t.blockStart=e[0],t.blockEnd=e[0],t.inline=e[1]):e.length>=3&&(t.blockStart=e[0],t.inline=e[1],t.blockEnd=e[2]);break}case`paddingBlock`:{let e=r.trim().split(/\s+/);t.blockStart=e[0],t.blockEnd=e[1]??e[0];break}case`paddingInline`:{let e=r.trim().split(/\s+/);e.length===1?t.inline=e[0]:(t.inlineStart=e[0],t.inlineEnd=e[1]);break}case`paddingBlockStart`:t.blockStart=r;break;case`paddingBlockEnd`:t.blockEnd=r;break;case`paddingInlineStart`:t.inlineStart=r;break;case`paddingInlineEnd`:t.inlineEnd=r}return t}function De(e,t){let n=ve(`${e}-padding`),r=[],i=t.inlineStart??t.inline,a=t.inlineEnd??t.inline;return i!=null&&a!=null&&i===a&&t.blockStart!=null&&t.blockEnd!=null&&i===t.blockStart&&t.blockStart===t.blockEnd?(r.push([n,i??``]),r):(t.inlineStart!=null||t.inlineEnd!=null?(i!=null&&r.push([`${n}-inline-start`,i]),a!=null&&r.push([`${n}-inline-end`,a])):t.inline!=null&&r.push([`${n}-inline`,t.inline]),t.blockStart!=null&&r.push([`${n}-block-start`,t.blockStart]),t.blockEnd!=null&&r.push([`${n}-block-end`,t.blockEnd]),r)}function Oe(e){let t=[],n=e.tokens,r=e=>n[e]||`var(${e})`,i=Object.entries(n);if(i.length>0){let e=i.map(([e,t])=>` ${e}: ${t};`).join(`
|
|
10
|
+
`);t.push(` :scope {\n${e}\n }`)}return e.components&&ke(e.components,t),G(r,t),Ae(e.components||{},t),Me(e.components||{},t),t}function ke(e,t){for(let[n,r]of Object.entries(e))for(let[e,i]of Object.entries(r)){let r=Object.entries(i);if(r.length===0)continue;let a=Se(n,le(e)),o=[],s=[];for(let[e,t]of r)e.startsWith(`:`)&&typeof t==`object`?s.push([e,t]):o.push([e,t]);let c=o,l=[],u=!1,d=new Set;for(let[e,t]of o){let r=de(n,e),i=Te.has(e)&&e!==`padding`?de(n,`padding`):[];for(let n of[...r,...i])if(n.expand===`container`&&Te.has(e)&&(u=!0),n.replaces&&d.add(e),n.vars)for(let e of n.vars)l.push([e,t])}if(u){let e=o.filter(([e])=>Te.has(e)),t=o.filter(([e])=>!Te.has(e)),r=De(n,Ee(e));c=[...t,...r]}if(d.size>0&&(c=c.filter(([e])=>!d.has(e))),l.length>0&&(c=[...c,...l]),c.length>0){let e=c.map(([e,t])=>` ${we(e)}: ${t};`).join(`
|
|
11
|
+
`);t.push(` ${a} {\n${e}\n }`)}for(let[e,n]of s){let r=Object.entries(n);if(r.length>0){let n=r.map(([e,t])=>` ${we(e)}: ${t};`).join(`
|
|
12
|
+
`);t.push(` ${Ce(a,e)} {\n${n}\n }`)}}}}function G(e,t){t.push(` :where(h1, h2, h3, h4, h5, h6) {
|
|
13
|
+
font-family: var(--font-family-heading);
|
|
14
|
+
color: var(--color-text-primary);
|
|
15
|
+
}`);for(let n=1;n<=6;n++)t.push(` :where(h${n}) {
|
|
16
|
+
font-size: ${e(`--text-heading-${n}-size`)};
|
|
17
|
+
font-weight: ${e(`--text-heading-${n}-weight`)};
|
|
18
|
+
line-height: ${e(`--text-heading-${n}-leading`)};
|
|
19
|
+
}`);t.push(` :where(p) {
|
|
20
|
+
font-family: var(--font-family-body);
|
|
21
|
+
font-size: ${e(`--text-body-size`)};
|
|
22
|
+
font-weight: ${e(`--text-body-weight`)};
|
|
23
|
+
line-height: ${e(`--text-body-leading`)};
|
|
24
|
+
color: var(--color-text-primary);
|
|
25
|
+
}`),t.push(` :where(small) {
|
|
26
|
+
font-size: ${e(`--text-supporting-size`)};
|
|
27
|
+
font-weight: ${e(`--text-supporting-weight`)};
|
|
28
|
+
line-height: ${e(`--text-supporting-leading`)};
|
|
29
|
+
color: var(--color-text-secondary);
|
|
30
|
+
}`),t.push(` :where(code, pre) {
|
|
31
|
+
font-family: var(--font-family-code);
|
|
32
|
+
font-size: ${e(`--text-code-size`)};
|
|
33
|
+
line-height: ${e(`--text-code-leading`)};
|
|
34
|
+
}`),t.push(` :where(hr) {
|
|
35
|
+
border: none;
|
|
36
|
+
border-top: 1px solid var(--color-border);
|
|
37
|
+
}`)}function Ae(e,t){let n={primary:`var(--color-text-primary)`,secondary:`var(--color-text-secondary)`,disabled:`var(--color-text-disabled)`,placeholder:`var(--color-text-secondary)`,accent:`var(--color-text-accent)`},r=`text`in e,i=`heading`in e,a=`link`in e;if(r||i||a)for(let[e,o]of Object.entries(n))r&&t.push(` ${Se(`text`,`.${e}`)} { color: ${o}; }`),i&&t.push(` ${Se(`heading`,`.${e}`)} { color: ${o}; }`),a&&t.push(` ${Se(`link`,`.${e}`)} { color: ${o}; }`)}var je={"4xs":`var(--font-size-4xs)`,"3xs":`var(--font-size-3xs)`,"2xs":`var(--font-size-2xs)`,xsm:`var(--font-size-xs)`,sm:`var(--font-size-sm)`,base:`var(--font-size-base)`,lg:`var(--font-size-lg)`,xl:`var(--font-size-xl)`,"2xl":`var(--font-size-2xl)`,"3xl":`var(--font-size-3xl)`,"4xl":`var(--font-size-4xl)`};function Me(e,t){if(`text`in e)for(let[e,n]of Object.entries(je)){let r=le(`size:${e}`);t.push(` ${Se(`text`,r)} { font-size: ${n}; }`)}}function Ne(e){let t=Oe(e),n=[],r=[];for(let e of t)e.trimStart().startsWith(`:where(`)?n.push(e):r.push(e);return{component:r,prose:n}}function Pe(e){let t=[],n=ye(e.name);for(let n of[`dark`,`light`]){let r=n===`dark`?e.__onDark:e.__onLight;if(!r)continue;let i=Object.entries(r.tokens);if(i.length>0){let e=i.map(([e,t])=>` ${e}: ${t};`).join(`
|
|
38
|
+
`);t.push(` ${xe(n)} {\n${e}\n }`)}if(r.components)for(let[e,i]of Object.entries(r.components))for(let[r,a]of Object.entries(i)){let i=Object.entries(a);if(i.length===0)continue;let o=le(r),s=`:is(${xe(n)}) :is(${Se(e,o)})`,c=[],l=[];for(let[e,t]of i)e.startsWith(`:`)&&typeof t==`object`?l.push([e,t]):c.push([e,t]);if(c.length>0){let e=c.map(([e,t])=>` ${we(e)}: ${t};`).join(`
|
|
39
|
+
`);t.push(` ${s} {\n${e}\n }`)}for(let[e,n]of l){let r=Object.entries(n);if(r.length>0){let n=r.map(([e,t])=>` ${we(e)}: ${t};`).join(`
|
|
40
|
+
`);t.push(` ${Ce(s,e)} {\n${n}\n }`)}}}}return t.length===0?``:`@scope (${n}) to (${be}) {\n${t.join(`
|
|
41
|
+
|
|
42
|
+
`)}\n}`}function Fe(e){let{component:t,prose:n}=Ne(e),r=ye(e.name),i=be,a=``;n.length>0&&(a=`@scope (${r}) to (${i}) {\n${n.join(`
|
|
43
|
+
|
|
44
|
+
`)}\n}`);let o=``;t.length>0&&(o=`@scope (${r}) to (${i}) {\n${t.join(`
|
|
45
|
+
|
|
46
|
+
`)}\n}`);let s=Pe(e);return s&&(o=o?`${o}\n\n${s}`:s),{prose:a,component:o}}var K={...T,...D,...k,...A,...j,...M,...P,...I,...L,...R,...z,...ae};function Ie(e){return`var(${e})`}Object.fromEntries(Object.keys(K).map(e=>[e,Ie(e)]));function Le(e){let t=0,n=null,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(n!==null){r?r=!1:a===`\\`?r=!0:a===n&&(n=null);continue}if(a===`"`||a===`'`){n=a;continue}if(a===`(`){t++;continue}if(a===`)`){t=Math.max(0,t-1);continue}if(a===`,`&&t===0)return[e.slice(0,i).trim(),e.slice(i+1).trim()]}return null}function Re(e){let t=e.trim();return!t.startsWith(`light-dark(`)||!t.endsWith(`)`)?null:Le(t.slice(11,-1))}function ze(e,t){if(Array.isArray(e))return t===`dark`?e[1]:e[0];let n=Re(e);return n===null?e:t===`dark`?n[1]:n[0]}function Be(e,t){let n=0;for(let r=t;r<e.length;r++){let t=e[r];if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}return-1}function Ve(e){let t=e.trim(),n=t.match(/\s+([\d.]+)%$/);return n?{color:t.slice(0,n.index).trim(),percentage:parseFloat(n[1])}:{color:t,percentage:null}}function He(e){let t=e.match(/^in\s+([\w-]+)\s*,\s*(.+)$/s);if(!t)return null;let[,n,r]=t;if(n.toLowerCase()!==`srgb`)return null;let i=Le(r);if(i===null)return null;let a=Ve(i[0]),o=Ve(i[1]);if(a===null||o===null)return null;let s=ee(a.color),c=ee(o.color);if(s===null||c===null)return null;let l,u;a.percentage!==null&&o.percentage!==null?(l=a.percentage,u=o.percentage):a.percentage===null?o.percentage===null?(l=50,u=50):(u=o.percentage,l=100-u):(l=a.percentage,u=100-l);let d=l+u;if(d<=0)return null;let f=l/d,p=u/d,m=d<100?d/100:1,h=f*s.a+p*c.a,g=(e,t)=>f*e*s.a+p*t*c.a,_=g(s.r,c.r),v=g(s.g,c.g),y=g(s.b,c.b);return ne({...h===0?{r:0,g:0,b:0}:{r:_/h,g:v/h,b:y/h},a:h*m})}function Ue(e){let t=e.indexOf(`color-mix(`);if(t===-1)return e;let n=t+9,r=Be(e,n);if(r===-1)return e;let i=Ue(e.slice(n+1,r)),a=He(i)??`color-mix(${i})`;return e.slice(0,t)+a+Ue(e.slice(r+1))}function We(e,t,n,r){let i=e.indexOf(`var(`);if(i===-1)return e;let a=i+3,o=Be(e,a);if(o===-1)return e;let s=e.slice(a+1,o),c=Le(s),l=(c?c[0]:s).trim(),u=c?c[1]:null,d;r.has(l)?d=e.slice(i,o+1):l in t?(r.add(l),d=Ke(l,t,n,r),r.delete(l)):d=u===null?e.slice(i,o+1):We(u.trim(),t,n,r);let f=We(e.slice(o+1),t,n,r);return e.slice(0,i)+d+f}function Ge(e,t,n,r){return!e.includes(`var(`)&&!e.includes(`color-mix(`)?e:Ue(We(e,t,n,r))}function Ke(e,t,n,r){if(e in n)return n[e];let i=t[e];if(i===void 0)return``;let a=Ge(i,t,n,r);return n[e]=a,a}function qe(e){let t={};for(let n of Object.keys(e))Ke(n,e,t,new Set);return t}function Je(e,t){let{mode:n}=t,r={};for(let[e,t]of Object.entries(K))r[e]=ze(t,n);if(e==null)return qe(r);for(let[t,i]of Object.entries(e.tokens))r[t]=ze(i,n);if(e.__inputTokens)for(let[t,i]of Object.entries(e.__inputTokens))i!==void 0&&(r[t]=ze(i,n));return qe(r)}function Ye(e,t=!1){let n=(0,v.useCallback)(t=>{let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[e]),r=(0,v.useCallback)(()=>window.matchMedia(e).matches,[e]),i=(0,v.useCallback)(()=>t,[t]);return(0,v.useSyncExternalStore)(n,r,i)}var Xe=(0,v.createContext)(null);Xe.displayName=`ThemeContext`;function Ze(){if(typeof document>`u`)return null;let e=document.documentElement.getAttribute(`data-theme`);return e===`light`||e===`dark`?e:null}function Qe(){return null}function $e(){return typeof document>`u`?null:document.documentElement.getAttribute(_e(`theme`))}function et(){return null}function tt(){return null}var nt=new Set,rt=null,it=new Set,at=null;function ot(){for(let e of nt)e()}function st(e){return nt.add(e),nt.size===1&&typeof MutationObserver<`u`&&(rt=new MutationObserver(ot),rt.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})),()=>{nt.delete(e),nt.size===0&&rt&&(rt.disconnect(),rt=null)}}function ct(){for(let e of it)e()}function lt(e){return it.add(e),it.size===1&&typeof MutationObserver<`u`&&(at=new MutationObserver(ct),at.observe(document.documentElement,{attributes:!0,attributeFilter:[_e(`theme`)]})),()=>{it.delete(e),it.size===0&&at&&(at.disconnect(),at=null)}}function ut(){return()=>{}}function dt(e){return(0,v.useSyncExternalStore)(e?ut:st,e?tt:Ze,Qe)}function ft(e){return(0,v.useSyncExternalStore)(e?ut:lt,e?tt:$e,et)}function pt(){let e=(0,v.use)(Xe),t=ft(e!=null);return e?.theme.name??t}function mt(){let e=(0,v.use)(Xe),t=e!=null,n=dt(t),r=ft(t),i=Ye(`(prefers-color-scheme: dark)`),a=e?.mode??n??`system`,o=e?.theme??ce(r),s=a===`system`?i?`dark`:`light`:a,c=(0,v.useMemo)(()=>Je(o,{mode:s}),[o,s]);return{name:o?.name??`default`,mode:s,token:e=>c[e]??``,tokens:c}}function ht(e,t){return`${e}: ${t}`}function gt(e,t,...n){console.error(ht(e,t),...n)}var _t=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})),q=o(((e,t)=>{t.exports=_t()}))(),vt={base:{k1xSpc:`xjp7ctv`,kMwMTN:`x1tgivj0`,kMv6JI:`x9ynric`,$$css:!0},light:{kQNsl9:`x19aimcq`,$$css:!0},dark:{kQNsl9:`xntwwlm`,$$css:!0},system:{kQNsl9:`x108lcm5`,$$css:!0}},yt=v.createContext(!1);yt.displayName=`ThemeNestingContext`;var bt=new Set;function xt(e){let t=(0,v.useId)();(0,v.useInsertionEffect)(()=>{if(e.__built)return;let n=`astryx-theme-${e.name}`;if(bt.has(n))return;`${e.name}`,`${e.name}${e.name}${e.name}${e.name}`;let{prose:r,component:i}=Fe(e);if(!(!r&&!i)){if(r){let n=document.createElement(`style`);n.setAttribute(_e(`theme-prose`),e.name),n.setAttribute(_e(`id`),t),n.textContent=`@layer reset {\n${r}\n}`,document.head.appendChild(n)}if(i){let n=document.createElement(`style`);n.setAttribute(_e(`theme`),e.name),n.setAttribute(_e(`id`),t),n.textContent=`@layer astryx-theme {\n${i}\n}`,document.head.appendChild(n)}return bt.add(n),()=>{let r=document.querySelector(`style[${_e(`theme-prose`)}="${e.name}"][${_e(`id`)}="${t}"]`),i=document.querySelector(`style[${_e(`theme`)}="${e.name}"][${_e(`id`)}="${t}"]`);r?.remove(),i?.remove(),bt.delete(n)}}},[e,t])}function St(e,t,n){y(()=>{if(!e&&!(typeof document>`u`))return t===`light`||t===`dark`?document.documentElement.setAttribute(`data-theme`,t):document.documentElement.removeAttribute(`data-theme`),document.documentElement.setAttribute(_e(`theme`),n),()=>{document.documentElement.removeAttribute(`data-theme`),document.documentElement.removeAttribute(_e(`theme`))}},[e,t,n])}function Ct({theme:e,mode:t=`system`,children:n}){let r=(0,v.use)(yt);se(e),xt(e),St(r,t,e.name);let i=t===`dark`?vt.dark:t===`light`?vt.light:vt.system,a=(0,v.useMemo)(()=>({theme:e,mode:t}),[e,t]);return(0,q.jsx)(Xe,{value:a,children:(0,q.jsx)(yt,{value:!0,children:(0,q.jsx)(`div`,{...w(vt.base,i),"data-astryx-theme":e.name,"data-theme":t===`system`?void 0:t,children:n})})})}Ct.displayName=`Theme`;var wt=`--color-syntax-`;function Tt(e){return wt+e}var Et=Object.keys(re).map(e=>e.replace(wt,``));function Dt(e){let t={};for(let n of Et)t[Tt(n)]=e.tokens[n];return t}var Ot=(0,v.createContext)(null);Ot.displayName=`SyntaxThemeContext`;function kt({theme:e,children:t}){let n=(0,v.useMemo)(()=>Dt(e),[e]),r=(0,v.useMemo)(()=>({theme:e}),[e]);return(0,q.jsx)(Ot,{value:r,children:(0,q.jsx)(`div`,{style:n,"data-astryx-syntax-theme":e.name,children:t})})}kt.displayName=`SyntaxTheme`;var At=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),jt=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Mt=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Nt=e=>{let t=Mt(e);return t.charAt(0).toUpperCase()+t.slice(1)},Pt={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ft=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},It=(0,v.createContext)({}),Lt=()=>(0,v.useContext)(It),Rt=(0,v.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=Lt()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,v.createElement)(`svg`,{ref:c,...Pt,width:t??l??Pt.width,height:t??l??Pt.height,stroke:e??f,strokeWidth:m,className:At(`lucide`,p,i),...!a&&!Ft(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),zt=(e,t)=>{let n=(0,v.forwardRef)(({className:n,...r},i)=>(0,v.createElement)(Rt,{ref:i,iconNode:t,className:At(`lucide-${jt(Nt(e))}`,`lucide-${e}`,n),...r}));return n.displayName=Nt(e),n},Bt=zt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Vt=zt(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),Ht=zt(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ut=zt(`calendar`,[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),Wt=zt(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Gt=zt(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Kt=zt(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qt=zt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Jt=zt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Yt=zt(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Xt=zt(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Zt=zt(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Qt=zt(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),$t=zt(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),en=zt(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),tn=zt(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),nn=zt(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),rn=zt(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),an=zt(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),on=zt(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),sn=zt(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),cn=zt(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),ln=zt(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),un=zt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),dn=zt(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),fn=zt(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),pn=zt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),mn=zt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),hn={size:`1em`,"aria-hidden":!0},gn={close:(0,q.jsx)(mn,{...hn}),chevronDown:(0,q.jsx)(Kt,{...hn}),chevronLeft:(0,q.jsx)(qt,{...hn}),chevronRight:(0,q.jsx)(Jt,{...hn}),chevronsLeft:(0,q.jsx)(Yt,{...hn}),chevronsRight:(0,q.jsx)(Xt,{...hn}),check:(0,q.jsx)(Gt,{...hn}),success:(0,q.jsx)(Zt,{...hn}),error:(0,q.jsx)(Qt,{...hn}),warning:(0,q.jsx)(fn,{...hn}),info:(0,q.jsx)(sn,{...hn}),calendar:(0,q.jsx)(Ut,{...hn}),clock:(0,q.jsx)($t,{...hn}),externalLink:(0,q.jsx)(rn,{...hn}),menu:(0,q.jsx)(cn,{...hn}),moreHorizontal:(0,q.jsx)(nn,{...hn}),search:(0,q.jsx)(un,{...hn}),arrowUp:(0,q.jsx)(Ht,{...hn}),arrowDown:(0,q.jsx)(Bt,{...hn}),arrowsUpDown:(0,q.jsx)(Vt,{...hn}),funnel:(0,q.jsx)(on,{...hn}),eyeSlash:(0,q.jsx)(an,{...hn}),viewColumns:(0,q.jsx)(en,{...hn}),copy:(0,q.jsx)(tn,{...hn}),checkDouble:(0,q.jsx)(Wt,{...hn}),wrench:(0,q.jsx)(pn,{...hn}),stop:(0,q.jsx)(dn,{...hn}),microphone:(0,q.jsx)(ln,{...hn})},_n=_(),vn={name:`neutral`,__built:!0,tokens:{"--font-size-4xs":`0.375rem`,"--font-size-3xs":`0.4375rem`,"--font-size-2xs":`0.5rem`,"--font-size-xs":`0.625rem`,"--font-size-sm":`0.75rem`,"--font-size-base":`0.875rem`,"--font-size-lg":`1.0625rem`,"--font-size-xl":`1.25rem`,"--font-size-2xl":`1.5rem`,"--font-size-3xl":`1.8125rem`,"--font-size-4xl":`2.1875rem`,"--font-size-5xl":`2.625rem`,"--text-heading-1-size":`var(--font-size-2xl)`,"--text-heading-1-weight":`var(--font-weight-semibold)`,"--text-heading-1-leading":`1.3333`,"--text-heading-2-size":`var(--font-size-xl)`,"--text-heading-2-weight":`var(--font-weight-semibold)`,"--text-heading-2-leading":`1.4`,"--text-heading-3-size":`var(--font-size-lg)`,"--text-heading-3-weight":`var(--font-weight-bold)`,"--text-heading-3-leading":`1.4118`,"--text-heading-4-size":`var(--font-size-base)`,"--text-heading-4-weight":`var(--font-weight-bold)`,"--text-heading-4-leading":`1.4286`,"--text-heading-5-size":`var(--font-size-sm)`,"--text-heading-5-weight":`var(--font-weight-semibold)`,"--text-heading-5-leading":`1.6667`,"--text-heading-6-size":`var(--font-size-xs)`,"--text-heading-6-weight":`var(--font-weight-semibold)`,"--text-heading-6-leading":`1.6`,"--text-body-size":`var(--font-size-base)`,"--text-body-weight":`var(--font-weight-normal)`,"--text-body-leading":`1.4286`,"--text-large-size":`var(--font-size-lg)`,"--text-large-weight":`var(--font-weight-semibold)`,"--text-large-leading":`1.4118`,"--text-label-size":`var(--font-size-base)`,"--text-label-weight":`var(--font-weight-medium)`,"--text-label-leading":`1.4286`,"--text-code-size":`var(--font-size-base)`,"--text-code-weight":`var(--font-weight-normal)`,"--text-code-leading":`1.4286`,"--text-supporting-size":`var(--font-size-sm)`,"--text-supporting-weight":`var(--font-weight-normal)`,"--text-supporting-leading":`1.6667`,"--text-display-1-size":`var(--font-size-5xl)`,"--text-display-1-weight":`var(--font-weight-normal)`,"--text-display-1-leading":`1.2381`,"--text-display-2-size":`var(--font-size-4xl)`,"--text-display-2-weight":`var(--font-weight-normal)`,"--text-display-2-leading":`1.2571`,"--text-display-3-size":`var(--font-size-3xl)`,"--text-display-3-weight":`var(--font-weight-normal)`,"--text-display-3-leading":`1.3793`,"--duration-fast-min":`95ms`,"--duration-fast":`125ms`,"--duration-fast-max":`165ms`,"--duration-medium-min":`225ms`,"--duration-medium":`300ms`,"--duration-medium-max":`400ms`,"--duration-slow-min":`525ms`,"--duration-slow":`700ms`,"--duration-slow-max":`935ms`,"--font-family-body":`Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`,"--font-family-heading":`Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`,"--font-family-code":`ui-monospace, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,"--color-syntax-keyword":`light-dark(#700084, #efa8ff)`,"--color-syntax-string":`light-dark(#005600, #a6d2a2)`,"--color-syntax-comment":`light-dark(#737373, #a3a3a3)`,"--color-syntax-number":`light-dark(#6e3500, #ffb37f)`,"--color-syntax-function":`light-dark(#00458c, #a0caff)`,"--color-syntax-type":`light-dark(#700084, #efa8ff)`,"--color-syntax-variable":`light-dark(#171717, #e5e5e5)`,"--color-syntax-operator":`light-dark(#737373, #a3a3a3)`,"--color-syntax-constant":`light-dark(#6e3500, #ffb37f)`,"--color-syntax-tag":`light-dark(#89001a, #ffaeaa)`,"--color-syntax-attribute":`light-dark(#584400, #eec12f)`,"--color-syntax-property":`light-dark(#005348, #83dac9)`,"--color-syntax-punctuation":`light-dark(#a3a3a3, #525252)`,"--color-syntax-background":`light-dark(#fafafa, #0a0a0a)`,"--color-background-surface":`light-dark(#ffffff, #262626)`,"--color-background-body":`light-dark(#f1f1f1, #1b1b1b)`,"--color-background-card":`light-dark(#ffffff, #1b1b1b)`,"--color-background-popover":`light-dark(#ffffff, #1b1b1b)`,"--color-background-muted":`light-dark(#f1f1f1, #1b1b1b)`,"--color-accent":`light-dark(#262626, #ebebeb)`,"--color-accent-muted":`light-dark(#f1f1f1, #262626)`,"--color-neutral":`light-dark(#0000000F, #FFFFFF1A)`,"--color-overlay":`light-dark(#00000080, #000000CC)`,"--color-overlay-hover":`light-dark(#0000000D, #FFFFFF0D)`,"--color-overlay-pressed":`light-dark(#0000001A, #FFFFFF1A)`,"--color-text-primary":`light-dark(#171717, #fafafa)`,"--color-text-secondary":`light-dark(#525252, #a3a3a3)`,"--color-text-disabled":`light-dark(#a3a3a3, #525252)`,"--color-text-accent":`light-dark(#262626, #ebebeb)`,"--color-on-dark":`#ffffff`,"--color-on-light":`#171717`,"--color-on-accent":`light-dark(#ffffff, #171717)`,"--color-on-success":`light-dark(#ffffff, #171717)`,"--color-on-error":`light-dark(#ffffff, #171717)`,"--color-on-warning":`#171717`,"--color-icon-accent":`light-dark(#262626, #ebebeb)`,"--color-icon-primary":`light-dark(#171717, #fafafa)`,"--color-icon-secondary":`light-dark(#737373, #a3a3a3)`,"--color-icon-disabled":`light-dark(#a3a3a3, #525252)`,"--color-success":`light-dark(#007004, #9fe59b)`,"--color-error":`light-dark(#a50c25, #ffc6c1)`,"--color-warning":`light-dark(#745b00, #fdcf4f)`,"--color-success-muted":`light-dark(#c5e5c0, #84c9803D)`,"--color-error-muted":`light-dark(#facecb, #ff9e973D)`,"--color-warning-muted":`light-dark(#f8da9d, #deb4333D)`,"--color-border":`light-dark(#00000014, #FFFFFF1A)`,"--color-border-emphasized":`light-dark(#d4d4d4, #525252)`,"--color-skeleton":`light-dark(#ebebeb, #525252)`,"--color-shadow":`light-dark(#0000001A, #0000004D)`,"--color-tint-hover":`light-dark(black, white)`,"--color-background-red":`light-dark(#facecb, #ff9e973D)`,"--color-border-red":`light-dark(#e6bab8, #ff6f6c)`,"--color-icon-red":`light-dark(#89001a, #ff9e97)`,"--color-text-red":`light-dark(#89001a, #ffc6c1)`,"--color-background-orange":`light-dark(#fad0b5, #ffa2583D)`,"--color-border-orange":`light-dark(#e6bda2, #e2883e)`,"--color-icon-orange":`light-dark(#6e3500, #ffa258)`,"--color-text-orange":`light-dark(#6e3500, #ffc9a2)`,"--color-background-yellow":`light-dark(#f8da9d, #deb4333D)`,"--color-border-yellow":`light-dark(#e4c279, #c0990e)`,"--color-icon-yellow":`light-dark(#584400, #deb433)`,"--color-text-yellow":`light-dark(#584400, #fdcf4f)`,"--color-background-green":`light-dark(#c5e5c0, #84c9803D)`,"--color-border-green":`light-dark(#b2d1ac, #69ad67)`,"--color-icon-green":`light-dark(#0c5700, #84c980)`,"--color-text-green":`light-dark(#0c5700, #9fe59b)`,"--color-background-teal":`light-dark(#a5e3d6, #7ec6b83D)`,"--color-border-teal":`light-dark(#94d6c8, #63ab9d)`,"--color-icon-teal":`light-dark(#005348, #7ec6b8)`,"--color-text-teal":`light-dark(#005348, #99e2d3)`,"--color-background-cyan":`light-dark(#a3e0ef, #83c2d43D)`,"--color-border-cyan":`light-dark(#91d3e3, #67a7b8)`,"--color-icon-cyan":`light-dark(#00505f, #83c2d4)`,"--color-text-cyan":`light-dark(#00505f, #9edef0)`,"--color-background-blue":`light-dark(#c4ddfb, #9eb7ff3D)`,"--color-border-blue":`light-dark(#b1c9e7, #6d9cfe)`,"--color-icon-blue":`light-dark(#00458c, #9eb7ff)`,"--color-text-blue":`light-dark(#00458c, #c7d3ff)`,"--color-background-purple":`light-dark(#eccef3, #f297ff3D)`,"--color-border-purple":`light-dark(#d8bbdf, #dd74f0)`,"--color-icon-purple":`light-dark(#700084, #f297ff)`,"--color-text-purple":`light-dark(#700084, #fac1ff)`,"--color-background-pink":`light-dark(#fccadc, #ff99c33D)`,"--color-border-pink":`light-dark(#e7b7c8, #f273aa)`,"--color-icon-pink":`light-dark(#83004b, #ff99c3)`,"--color-text-pink":`light-dark(#83004b, #ffc3da)`,"--color-background-gray":`light-dark(#e5e5e5, var(--color-neutral))`,"--color-border-gray":`light-dark(#d4d4d4, #262626)`,"--color-icon-gray":`light-dark(#525252, #a3a3a3)`,"--color-text-gray":`light-dark(#262626, #e5e5e5)`,"--radius-none":`0px`,"--radius-inner":`0.375rem`,"--radius-element":`0.625rem`,"--radius-container":`0.75rem`,"--radius-page":`1.75rem`,"--radius-full":`9999px`,"--shadow-low":`0 2px 4px light-dark(oklch(0 0 0 / 5%), oklch(0 0 0 / 25%)), 0 4px 8px light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 40%)), inset 0 0 0 1px light-dark(transparent, oklch(1 0 0 / 8%))`,"--shadow-med":`0 2px 4px light-dark(oklch(0 0 0 / 5%), oklch(0 0 0 / 35%)), 0 4px 12px light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 50%)), inset 0 0 0 1px light-dark(transparent, oklch(1 0 0 / 12%))`,"--shadow-high":`0 4px 6px light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 50%)), 0 12px 24px light-dark(oklch(0 0 0 / 15%), oklch(0 0 0 / 70%)), inset 0 0 0 1px light-dark(transparent, oklch(1 0 0 / 15%))`,"--shadow-inset-hover":`inset 0px 0px 0px 2px #0074e24D`,"--shadow-inset-selected":`inset 0px 0px 0px 2px #0074e280`,"--shadow-inset-success":`inset 0px 0px 0px 2px #1981004D`,"--shadow-inset-warning":`inset 0px 0px 0px 2px #ffce2f4D`,"--shadow-inset-error":`inset 0px 0px 0px 2px #e33f4a4D`},icons:gn},yn=`stageflow.controlToken`;function bn(){if(typeof localStorage>`u`)return``;try{return localStorage.getItem(yn)??``}catch{return``}}function xn(e){if(!(typeof localStorage>`u`))try{let t=e.trim();t.length===0?localStorage.removeItem(yn):localStorage.setItem(yn,t)}catch{}}function Sn(){let e=bn();return e?{Authorization:`Bearer ${e}`}:{}}async function Cn(e,t){let n=await fetch(e,{...t,headers:{"Content-Type":`application/json`,...Sn(),...t?.headers??{}}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??`Request failed (${n.status})`);return r}function wn(){return Cn(`/api/runs`)}function Tn(e){return Cn(`/api/runs/${encodeURIComponent(e)}`)}function En(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/verification`)}function Dn(){return Cn(`/api/tasks`)}function On(){return Cn(`/api/pipelines`)}function kn(){return Cn(`/api/triggers`)}function An(e){return Cn(`/api/triggers/${encodeURIComponent(e)}`)}function jn(e){return Cn(`/api/triggers/${encodeURIComponent(e)}/fire`,{method:`POST`})}async function Mn(e){try{let t=await fetch(`/api/triggers`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok&&typeof n.id==`string`?{ok:!0,trigger:n}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}function Nn(){return Cn(`/api/models`)}async function Pn(e){try{let t=await fetch(`/api/pipelines`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok&&typeof n.id==`string`?{ok:!0,pipeline:n}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Fn(e){try{let t=await fetch(`/api/stages`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok&&typeof n.id==`string`?{ok:!0,stage:n}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}function In(){return Cn(`/api/skills`)}function Ln(){return Cn(`/api/extensions`)}function Rn(){return Cn(`/api/health`)}function zn(e){return Cn(`/api/settings`,{method:`POST`,body:JSON.stringify({maxConcurrent:e})})}function Bn(){return Cn(`/api/providers`)}function Vn(){return Cn(`/api/providers/detect`)}function Hn(e){return Cn(`/api/providers/${encodeURIComponent(e)}/auth`)}async function Un(e,t){try{let n=await fetch(`/api/providers/${encodeURIComponent(e)}/login`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({authType:`api_key`,apiKey:t})}),r=await n.json().catch(()=>({}));return n.ok&&r.provider?{ok:!0,provider:r.provider}:{ok:!1,status:n.status,error:r.error??`Request failed (${n.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Wn(e){try{let t=await fetch(`/api/providers/${encodeURIComponent(e)}/logout`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));return t.ok&&n.provider?{ok:!0,provider:n.provider}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Gn(e){try{let t=await fetch(`/api/providers/${encodeURIComponent(e)}/login`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({authType:`oauth`})}),n=await t.json().catch(()=>({}));return t.ok&&n.session?{ok:!0,session:n.session}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}function Kn(e,t){return Cn(`/api/providers/${encodeURIComponent(e)}/login/${encodeURIComponent(t)}`)}async function qn(e,t,n){try{let r=await fetch(`/api/providers/${encodeURIComponent(e)}/login/${encodeURIComponent(t)}/answer`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({value:n})}),i=await r.json().catch(()=>({}));return r.ok&&i.session?{ok:!0,session:i.session}:{ok:!1,status:r.status,error:i.error??`Request failed (${r.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Jn(e,t){try{let n=await fetch(`/api/providers/${encodeURIComponent(e)}/login/${encodeURIComponent(t)}/cancel`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({})}),r=await n.json().catch(()=>({}));return n.ok&&r.session?{ok:!0,session:r.session}:{ok:!1,status:n.status,error:r.error??`Request failed (${n.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}function Yn(){return Cn(`/api/settings`)}function Xn(e){return Cn(`/api/settings`,{method:`POST`,body:JSON.stringify({credentialSource:e})})}function Zn(e){return Cn(`/api/settings`,{method:`POST`,body:JSON.stringify({workshopModel:e})})}async function Qn(e,t){try{let n=await fetch(`/api/runs`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({task:e,pipeline:t})}),r=await n.json().catch(()=>({}));return n.ok&&typeof r.runId==`string`?{ok:!0,runId:r.runId}:{ok:!1,error:r.error??`Request failed (${n.status})`,...r.code?{code:r.code}:{},...r.activeRunIds?{activeRunIds:r.activeRunIds}:{},...r.conflictingRunId?{conflictingRunId:r.conflictingRunId}:{}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function $n(e){return Cn(`/api/runs/${encodeURIComponent(e)}/rerun`,{method:`POST`})}function er(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/retry`,{method:`POST`})}function tr(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/resume`,{method:`POST`})}function nr(e,t,n){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/recovery`,{method:`POST`,body:JSON.stringify(n?.trim()?{guidance:n.trim()}:{})})}function rr(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/recovery/stop`,{method:`POST`,body:JSON.stringify({})})}function ir(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/abandon`,{method:`POST`})}function ar(e,t){return Cn(`/api/runs/${encodeURIComponent(e)}/cancel`,{method:`POST`,body:JSON.stringify({reason:t})})}function or(e,t){let n=t?.force===!0?`?force=true`:``;return Cn(`/api/runs/${encodeURIComponent(e)}${n}`,{method:`DELETE`})}function sr(e,t,n){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/answer`,{method:`POST`,body:JSON.stringify(n)})}function cr(e,t,n){return Cn(`/api/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/feedback-decision`,{method:`POST`,body:JSON.stringify(n)})}function lr(){return Cn(`/api/project-mcp`)}function ur(e,t){return Cn(`/api/project-mcp/${encodeURIComponent(e)}/probe`,{method:`POST`,signal:t?.signal})}async function dr(e,t){let n=await fetch(`/api/runs/${encodeURIComponent(e)}/artifact?path=${encodeURIComponent(t)}`,{headers:{...Sn()}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Request failed (${n.status})`)}return n.text()}function fr(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.sessionId==`string`&&Array.isArray(t.events)&&t.draft!==null&&typeof t.draft==`object`&&typeof t.autoApply==`boolean`&&typeof t.model==`string`&&(t.pending===null||typeof t.pending==`object`)}async function pr(){try{let e=await fetch(`/api/workshop/sessions`,{headers:{...Sn()}}),t=await e.json().catch(()=>({}));return e.ok&&Array.isArray(t.sessions)?{ok:!0,sessions:t.sessions}:{ok:!1,status:e.status,error:t.error??`Request failed (${e.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function mr(e){try{let t=await fetch(`/api/workshop/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify(e?.id?{id:e.id}:{})}),n=await t.json().catch(()=>({}));return(t.ok||t.status===201)&&n.session?{ok:!0,session:n.session}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function hr(){try{let e=await fetch(`/api/workshop/picker`,{headers:{...Sn()}}),t=await e.json().catch(()=>({}));return e.ok&&Array.isArray(t.rows)?{ok:!0,rows:t.rows}:{ok:!1,status:e.status,error:t.error??`Request failed (${e.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function gr(e){try{let t=await fetch(`/api/workshop/builds/${encodeURIComponent(e)}`,{headers:{...Sn()}}),n=await t.json().catch(()=>({}));return t.ok&&n.build?{ok:!0,build:n.build}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function _r(e){try{let t=await fetch(`/api/workshop/focus`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({projectRoot:e.projectRoot,relativePath:e.relativePath})}),n=await t.json().catch(()=>({}));return(t.ok||t.status===201)&&n.build?{ok:!0,build:n.build}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function vr(e){try{let t=await fetch(`/api/workshop/sessions/${encodeURIComponent(e.sessionId)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({activeBuildId:e.activeBuildId})}),n=await t.json().catch(()=>({}));return t.ok&&n.session?{ok:!0,session:n.session}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function yr(e){try{let t=await fetch(`/api/workshop/sessions/${encodeURIComponent(e)}`,{headers:{...Sn()}}),n=await t.json().catch(()=>({}));return t.ok&&n.session?{ok:!0,session:n.session}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`,...typeof n.code==`string`?{code:n.code}:{}}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function br(e){try{let t=await fetch(`/api/workshop/sessions/${encodeURIComponent(e.sessionId)}/undo`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({draft:e.draft,...e.mutationId===void 0?{}:{mutationId:e.mutationId}})}),n=await t.json().catch(()=>({}));return t.ok&&n.ok===!0?n:n.ok===!1||t.status>=400?{ok:!1,status:t.status,error:n.notice??(`error`in n&&typeof n.error==`string`?n.error:`Request failed (${t.status})`),...typeof n.reason==`string`?{reason:n.reason}:{},...typeof n.notice==`string`?{notice:n.notice}:{},...n.draft?{draft:n.draft}:{},...n.pending===void 0?{}:{pending:n.pending},...typeof n.sessionId==`string`?{sessionId:n.sessionId}:{}}:{ok:!1,status:t.status,error:`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function xr(e){try{let t=await fetch(`/api/workshop/sessions/${encodeURIComponent(e.sessionId)}/accept`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({draft:e.draft,...e.mutationId===void 0?{}:{mutationId:e.mutationId}})}),n=await t.json().catch(()=>({}));return t.ok&&n.ok===!0?n:n.ok===!1||t.status>=400?{ok:!1,status:t.status,error:n.notice??(`error`in n&&typeof n.error==`string`?n.error:`Request failed (${t.status})`),...typeof n.reason==`string`?{reason:n.reason}:{},...typeof n.notice==`string`?{notice:n.notice}:{},...n.draft?{draft:n.draft}:{},...n.pending===void 0?{}:{pending:n.pending},...typeof n.sessionId==`string`?{sessionId:n.sessionId}:{}}:{ok:!1,status:t.status,error:`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Sr(e){try{let t=await fetch(`/api/workshop/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({sessionId:e.sessionId,message:e.message,draft:e.draft,autoApply:e.autoApply===!0,...e.model===void 0?{}:{model:e.model},stream:!1})}),n=await t.json().catch(()=>({}));return t.ok&&fr(n)?{ok:!0,...n}:{ok:!1,status:t.status,error:n.error??`Request failed (${t.status})`}}catch(e){return{ok:!1,status:0,error:e instanceof Error?e.message:String(e)}}}async function Cr(e){try{let t=await fetch(`/api/workshop/chat/stop`,{method:`POST`,headers:{"Content-Type":`application/json`,...Sn()},body:JSON.stringify({sessionId:e}),signal:AbortSignal.timeout(2e4)}),n=await t.json().catch(()=>({}));return t.ok?{draft:n.draft!==null&&typeof n.draft==`object`?n.draft:null,pending:n.pending!==null&&typeof n.pending==`object`?n.pending:null,buildId:typeof n.buildId==`string`&&n.buildId?n.buildId:null}:null}catch{return null}}async function wr(e,t={}){let n=!1;try{let r=await fetch(`/api/workshop/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/x-ndjson`,...Sn()},body:JSON.stringify({sessionId:e.sessionId,message:e.message,draft:e.draft,autoApply:e.autoApply===!0,...e.model===void 0?{}:{model:e.model},stream:!0}),...t.signal?{signal:t.signal}:{}}),i=r.headers.get(`content-type`)??``;if(!r.ok){let e=await r.json().catch(()=>({}));return{ok:!1,status:r.status,error:e.error??`Request failed (${r.status})`}}if(!i.includes(`ndjson`)||!r.body){let e=await r.json().catch(()=>({}));return fr(e)?{ok:!0,...e}:{ok:!1,status:r.status,error:e.error??`Request failed (${r.status})`}}n=!0;let a=r.body.getReader(),o=new TextDecoder,s=``,c={current:null},l=null,u=e=>{e.type===`delta`?t.onDelta?.(e.text):e.type===`activity`?t.onActivity?.(e):e.type===`pointer-change`?t.onPointerChange?.({buildId:e.buildId,draft:e.draft}):e.type===`event`?(t.onEvent?.(e.event),e.event.type===`error`&&typeof e.event.message==`string`&&e.event.message&&(l=e.event.message)):e.type===`done`&&(c.current={sessionId:e.sessionId,events:e.events??[],draft:e.draft,pending:e.pending,autoApply:e.autoApply,model:e.model,buildId:e.buildId??null})};for(;;){let{done:e,value:t}=await a.read();if(e)break;s+=o.decode(t,{stream:!0});let n=s.split(`
|
|
47
|
+
`);s=n.pop()??``;for(let e of n){let t=e.trim();if(t)try{u(JSON.parse(t))}catch{continue}}}if(s.trim())try{u(JSON.parse(s.trim()))}catch{}return c.current?{ok:!0,...c.current}:l?{ok:!1,status:r.status,error:l}:{ok:!1,status:r.status,error:`Stream ended without a done frame`}}catch(r){return t.signal?.aborted||r instanceof Error&&r.name===`AbortError`?{ok:!1,status:0,error:`Stopped.`}:n?{ok:!1,status:0,error:`Workshop chat stream failed`}:Sr(e)}}function Tr(){return{readListing:()=>wn(),readCapacity:()=>Rn()}}var Er=2e3;function Dr(){return{every(e,t){let n=setInterval(()=>{t()},e);return()=>clearInterval(n)}}}function Or(e){let t=e.intervalMs??Er,n=e.scheduler??Dr(),r=new Set,i={snapshot:{runs:[],health:null},error:null,loading:!0},a=!1,o;function s(){return i}function c(e){return r.add(e),()=>{r.delete(e)}}function l(){for(let e of r)e()}async function u(){let t=i.snapshot.runs,n=i.snapshot.health,r=null,a=e.source.readListing(),o=e.source.readCapacity();try{t=(await a).runs}catch(e){r=e instanceof Error?e.message:String(e)}try{n=await o}catch{}i={snapshot:{runs:t,health:n},error:r,loading:!1},l()}async function d(){a||(a=!0,await u(),o=n.every(t,()=>{if(a)return u()}))}function f(){a=!1,o?.(),o=void 0}async function p(){await u()}return{start:d,stop:f,refresh:p,subscribe:c,getState:s}}var kr=(0,v.createContext)(null);function Ar(){let e=(0,v.useContext)(kr);if(e===null)throw Error(`useRunCatalog must be used within RunCatalogProvider`);return e}function jr({catalog:e,children:t}){return(0,v.useEffect)(()=>(e.start(),()=>{e.stop()}),[e]),(0,v.createElement)(kr.Provider,{value:e},t)}function Mr(){let e=Ar();return(0,v.useSyncExternalStore)(e.subscribe,e.getState)}function Nr(){return Ar()}function Pr(e,t){if(t){let n=t.replace(/\\/g,`/`).replace(/\/$/,``),r=e.replace(/\\/g,`/`);if(r===n)return`.`;let i=`${n}/`;if(r.startsWith(i))return r.slice(i.length)}let n=e.replace(/\\/g,`/`).split(`/`);return n[n.length-1]??e}function Fr(e){return e.replace(/\\/g,`/`)}function Ir(e,t){return!!(e.pipeline_id===t.id||e.pipeline_path&&e.project_root&&Fr(Pr(e.pipeline_path,e.project_root))===Fr(t.path))}function Lr(e){let t=e.pipeline_path?Pr(e.pipeline_path,e.project_root):e.pipeline_id,n=e.task_path?Pr(e.task_path,e.project_root):e.task_id;return n&&n!==t?`${t} · ${n}`:t}function Rr(e){return e.task_path?Pr(e.task_path,e.project_root):e.task_id??e.pipeline_id}function zr(e){return e.length>7?e.slice(0,7):e}function Br(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Vr(e){if(e.kind===`unbound`)return`unbound`;if(e.kind===`checkout`)return e.checkout_root?`checkout · ${Br(e.checkout_root)}`:`checkout · unavailable`;let t=[`repository`];return e.repository&&t.push(e.repository),e.ref&&t.push(e.ref),e.resolved_sha&&t.push(zr(e.resolved_sha)),e.run_branch&&t.push(e.run_branch),t.length===1&&!e.repository?`repository · unavailable`:t.join(` · `)}function Hr(e){if(e.kind===`unbound`)return`unbound`;if(e.kind===`checkout`)return e.checkout_root??`checkout unavailable`;let t=[];return e.resolved_sha&&t.push(e.resolved_sha),e.checkout_root&&t.push(e.checkout_root),t.length>0?t.join(`
|
|
48
|
+
`):Vr(e)}function Ur(e){if(e.kind===`unbound`)return`unbound`;if(e.kind===`checkout`)return`checkout`;let t=[`repository`];return e.repository&&t.push(e.repository),e.ref&&t.push(e.ref),e.resolved_sha&&t.push(zr(e.resolved_sha)),t.join(` · `)}function Wr(e){let t=[],n=[],r=[],i=[];for(let a of e.runs)a.waiting_stage_id?t.push(a):a.status===`failed`?r.push(a):a.status===`succeeded`?i.push(a):(a.status===`running`||a.status===`created`)&&n.push(a);return{waiting:t,inFlight:n,broken:r,finished:i}}function Gr(e){return Wr(e).waiting}function Kr(e,t,n){let r=`${e} in flight · ${t} failed`;if(!n)return r;if(n.slotsAvailable===0)return`${r} · no free session slots`;let i=n.slotsAvailable===1?`slot`:`slots`;return`${r} · ${n.slotsAvailable} free ${i} · ${n.activeCount}/${n.maxConcurrent} in use`}function qr(e){let t=Wr(e);return{line:Kr(t.inFlight.length,t.broken.length,e.health),health:e.health,inFlight:t.inFlight.length,broken:t.broken.length}}function Jr(e){return e.slice().sort((e,t)=>t.created_at.localeCompare(e.created_at))}function Yr(e,t){return Jr(e.runs.filter(e=>e.task_id===t))}function Xr(e,t){return Jr(e.runs.filter(e=>typeof t==`string`?e.pipeline_id===t:Ir(e,t)))}function Zr(e){let t=Wr(e);return{all:e.runs.length,waiting:t.waiting.length,running:t.inFlight.length,failed:t.broken.length,finished:t.finished.length}}function Qr(e,t){let n=new Map(e.runs.map(e=>[e.run_id,e]));return t.flatMap(e=>{let t=n.get(e);return t?.waiting_stage_id?[t]:[]})}function $r({size:e=16,className:t}){return(0,q.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 64 64`,fill:`none`,className:t,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`M 12 20 C 28 20, 28 44, 52 44`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,fill:`none`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`20`,r:`5`,fill:`currentColor`}),(0,q.jsx)(`circle`,{cx:`32`,cy:`32`,r:`5`,fill:`currentColor`}),(0,q.jsx)(`circle`,{cx:`52`,cy:`44`,r:`5`,fill:`currentColor`,opacity:`0.45`})]})}var ei=[{id:`today`,label:`Today`,glyph:`◉`},{id:`runs`,label:`Runs`,glyph:`▤`},{id:`pipelines`,label:`Pipelines`,glyph:`⛓`},{id:`workshop`,label:`Workshop`,glyph:`✎`},{id:`tasks`,label:`Tasks`,glyph:`▦`},{id:`triggers`,label:`Triggers`,glyph:`⚡`},{id:`skills`,label:`Skills`,glyph:`✦`},{id:`extensions`,label:`Extensions`,glyph:`◇`},{id:`settings`,label:`Settings`,glyph:`⚙`}];function ti({activeId:e,onNavigate:t,waitingCount:n,health:r}){return(0,q.jsxs)(`nav`,{className:`rail`,children:[(0,q.jsxs)(`a`,{className:`rail__brand`,href:`#/today`,onClick:e=>{e.preventDefault(),t(`today`)},children:[(0,q.jsx)(`span`,{className:`rail__mark`,"aria-hidden":`true`,children:(0,q.jsx)($r,{size:28})}),(0,q.jsx)(`span`,{children:`Stageflow`})]}),(0,q.jsx)(`div`,{className:`rail__new`,children:(0,q.jsx)(`a`,{className:`btn btn--primary`,href:`#/new`,style:{width:`100%`},onClick:e=>{e.preventDefault(),t(`new`)},children:`Start a run`})}),ei.map(r=>(0,q.jsxs)(`a`,{className:`rail__item`,href:`#/${r.id}`,"aria-current":e===r.id?`page`:void 0,onClick:e=>{e.preventDefault(),t(r.id)},children:[(0,q.jsx)(`span`,{className:`rail__glyph`,"aria-hidden":`true`,children:r.glyph}),(0,q.jsx)(`span`,{className:`rail__label`,children:r.label}),r.id===`today`&&n!=null&&n>0&&(0,q.jsx)(`span`,{className:`rail__count`,children:n})]},r.id)),(0,q.jsxs)(`div`,{className:`rail__foot`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`Capacity`}),r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`capacity`,"aria-hidden":`true`,children:Array.from({length:r.maxConcurrent},(e,t)=>(0,q.jsx)(`i`,{...t<r.activeCount?{"data-used":`true`}:{}},t))}),(0,q.jsxs)(`div`,{className:`mono muted`,style:{fontSize:`var(--font-size-xs)`},children:[r.activeCount,` of `,r.maxConcurrent,` slots · `,r.slotsAvailable===0?`none free`:`${r.slotsAvailable} free`]})]}):(0,q.jsx)(`div`,{className:`mono muted`,style:{fontSize:`var(--font-size-xs)`},children:`—`})]})]})}function ni(e){return Array.isArray(e)&&e.length>0}function ri(e){return e.filter(e=>ni(e.gate_kinds)).length}function ii(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return e;let r=Math.max(0,t-n),i=Math.floor(r/1e3);if(i<60)return`just now`;let a=Math.floor(i/60);if(a<60)return`${a}m`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function ai(e,t){if(!e?.length||!t)return;let n=e.findIndex(e=>e.id===t);if(!(n<0))return`stage ${n+1} of ${e.length}`}function oi(e){if(e.waiting_stage_id){let t=e.waiting_kind?` · ${e.waiting_kind}`:``;return`${e.waiting_stage_id} · asked you${t}`}let t=e.stages?.find(e=>e.status===`running`);if(t)return t.id;if(e.failed_stage_id)return e.failed_stage_id}var si=`process_interrupted: operator abandoned stage`;function ci(e){let t;for(let n of e)n.event===`failed`&&(t=n.reason);return t===si}function li(){return`abandoned`}function ui(e){return e!==void 0&&e.trim()!==``?`cancelled: ${e}`:`cancelled`}function di(e){return e.waiting_stage_id?`waiting_for_input`:e.status}function fi(e){switch(e){case`waiting_for_input`:case`interrupted`:return`waiting`;case`created`:case`queued`:return;case`running`:return`running`;case`succeeded`:return`succeeded`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return}}function pi(e){switch(e){case`waiting_for_input`:return`waiting on you`;case`created`:return`not started`;case`queued`:case`pending`:case`running`:case`interrupted`:case`succeeded`:case`failed`:case`cancelled`:case`skipped`:return e}}function mi(){let e=pi(`waiting_for_input`);return e.charAt(0).toUpperCase()+e.slice(1)}function hi(e){switch(e){case`waiting_for_input`:case`interrupted`:return`waiting`;case`pending`:case`running`:case`succeeded`:case`failed`:case`skipped`:return e}}function gi(e){switch(e){case`waiting_for_input`:case`interrupted`:case`waiting`:return`?`;case`pending`:return``;case`running`:return`▸`;case`succeeded`:return`✓`;case`failed`:return`✕`;case`skipped`:return`–`}}function _i(e){return e===`skipped`?`skipped`:fi(e)}function vi({stages:e,label:t}){return e.length===0?null:(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`mini`,"aria-hidden":`true`,children:e.map((t,n)=>{let r=hi(t.status),i=gi(r)||String(n+1),a=n>0&&e[n-1]?.status===`succeeded`;return(0,q.jsxs)(v.Fragment,{children:[n>0?(0,q.jsx)(`i`,{className:`mini__w`,"data-flowed":a?`true`:void 0}):null,(0,q.jsx)(`i`,{className:`mini__n`,"data-s":r===`pending`?void 0:r,children:i})]},t.id)})}),t?(0,q.jsx)(`span`,{className:`mini__label`,children:t}):null]})}function yi(e){return e===void 0?null:`$${e.toFixed(4)}`}function bi({costUsd:e}){let t=yi(e);return t?(0,q.jsx)(`span`,{className:`chip chip--cost`,"aria-label":`cost ${t}`,children:t}):null}var xi={all:e=>`All ${e.all}`,waiting:e=>`Waiting ${e.waiting}`,running:e=>`Running ${e.running}`,failed:e=>`Failed ${e.failed}`,finished:e=>`Finished ${e.finished}`};function Si(e){return e===void 0?null:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:e<1073741824?`${(e/1048576).toFixed(1)} MiB`:`${(e/1073741824).toFixed(2)} GiB`}function Ci({onOpen:e,onNew:t}){let{snapshot:n,error:r,loading:i}=Mr(),[a,o]=(0,v.useState)(`all`),s=n.runs,c=Zr(n),l=Wr(n),u=(0,v.useMemo)(()=>a===`all`?s:{waiting:l.waiting,running:l.inFlight,failed:l.broken,finished:l.finished}[a],[l,a,s]);return(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Runs`}),(0,q.jsx)(`p`,{children:`Every row carries its own chain, so you read progress as topology rather than a status word.`})]}),(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:t,children:`Start a run`})]}),r?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,marginBottom:`var(--spacing-4)`},children:[`Could not load runs: `,r]}):null,(0,q.jsx)(`div`,{className:`filters`,children:[`all`,`waiting`,`running`,`failed`,`finished`].map(e=>(0,q.jsx)(`button`,{className:`tab`,"data-active":a===e?`true`:void 0,onClick:()=>o(e),children:xi[e](c)},e))}),!i&&s.length===0?(0,q.jsx)(`div`,{className:`empty-hint`,children:`No runs yet. Start a pipeline from Start a run, or use sf run from the CLI.`}):null,u.map(t=>{let n=fi(di(t)),r=Si(t.disk_bytes);return(0,q.jsxs)(`a`,{className:`rrow`,"data-s":n&&n!==`running`?n:void 0,href:`#/runs/${t.run_id}`,onClick:n=>{n.preventDefault(),e(t.run_id)},children:[(0,q.jsxs)(`span`,{className:`rrow__id`,children:[(0,q.jsx)(`span`,{className:`rrow__task`,children:Rr(t)}),(0,q.jsxs)(`span`,{className:`rrow__pipe`,children:[Lr(t),t.binding?` · ${Ur(t.binding)}`:``,` · `,t.run_id.slice(0,8)]})]}),(0,q.jsxs)(`span`,{className:`rrow__right`,children:[r?(0,q.jsx)(`span`,{className:`rrow__disk`,title:`Cached disk usage`,children:r}):null,(0,q.jsx)(bi,{costUsd:t.total_cost_usd}),(0,q.jsxs)(`span`,{className:`status${n&&n!==`running`?` status--${n}`:``}`,children:[(0,q.jsx)(`span`,{className:`dot${n?` dot--${n}`:``}`}),` `,ii(t.updated_at??t.created_at)]})]}),(0,q.jsx)(`span`,{className:`rrow__track`,children:(0,q.jsx)(vi,{stages:t.stages??[],label:oi(t)})})]},t.run_id)}),i?(0,q.jsx)(`p`,{className:`muted`,style:{padding:`var(--spacing-4)`},children:`Loading runs…`}):null]})}function wi(e,t){return e==null?`fallback:${typeof t==`function`?t():t}`:`id:${e}`}function Ti(e,t){let n={...e,...t},r=[e.className,t.className].filter(Boolean).join(` `);r?n.className=r:delete n.className;let i=t.style&&e.style?{...e.style,...t.style}:t.style||e.style;return i?n.style=i:delete n.style,n}function J(e,t,n,r){if(typeof e==`string`){let i=e,a=t??{className:``},o=n,s=a.className?`${i} ${a.className}`:i;o&&(s=`${s} ${o}`);let c=r&&a.style?{...a.style,...r}:r||a.style;return{...a,className:s,style:c}}let i=Ti(e,typeof t==`string`?{className:t}:t??{});return typeof n==`string`?i=Ti(i,{className:n}):n!=null&&(i=Ti(i,{style:n})),r!=null&&(i=Ti(i,{style:r})),i}function Ei(...e){return t=>{let n=[];for(let r of e)if(typeof r==`function`){let e=r(t);n.push(typeof e==`function`?e:()=>r(null))}else if(r!=null){let e=r;e.current=t,n.push(()=>{e.current=null})}if(t!=null&&n.length>0)return()=>{for(let e of n)e()}}}function Di(e){return`data-${e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`}function Oi(e,t){return/^\d/.test(t)?`${e}-${t}`:t}function ki(e,t){let n=[ge(e)];if(t)for(let[e,r]of Object.entries(t))r!=null&&n.push(Oi(e,String(r)));return n.join(` `)}function Ai(e){let t={};if(e)for(let[n,r]of Object.entries(e))r!=null&&(t[Di(n)]=String(r));return t}function Y(e,t,n){let r=ki(e,t),i=n?.legacyNames?.map(e=>ge(e))??[];return{className:i.length>0?[r,...i].join(` `):r,...Ai(t)}}function ji(e){let t=e.auxiliaryData;return typeof t?.group==`string`?t.group:void 0}function Mi(e){if(!e.some(e=>ji(e)!=null))return[{heading:null,items:e}];let t=[],n=new Map,r=[];for(let i of e){let e=ji(i);e==null?r.push(i):(n.has(e)||(t.push(e),n.set(e,[])),n.get(e)?.push(i))}let i=t.map(e=>({heading:e,items:n.get(e)??[]}));return r.length>0&&i.push({heading:null,items:r}),i}var Ni=null,Pi=new Map;function Fi(){return Ni||=new ResizeObserver(e=>{for(let t of e){let e=Pi.get(t.target);e&&e(t)}}),Ni}function Ii(e,t){Pi.set(e,t),Fi().observe(e),t({target:e})}function Li(e){Pi.delete(e),Ni&&(Ni.unobserve(e),Pi.size===0&&(Ni.disconnect(),Ni=null))}function Ri(e){return e!=null&&typeof e!=`boolean`&&e!==``}var zi={kbCHJM:`x1nrll8i`,k3aq6I:`xsqj5wx`,$$css:!0},Bi={mirror:{k3aq6I:`xgtlewx`,$$css:!0},centerInline:e=>[zi,{"--x-transform":`translate(-50%, ${e})`==null?void 0:`translate(-50%, ${e})`}]},Vi=`data-astryx-live-region`,Hi=`position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;inset-block-start:0;inset-inline-start:0;pointer-events:none;user-select:none;`,Ui=2e3,Wi={polite:null,assertive:null};function Gi(e){let t=Wi[e];t!=null&&(clearTimeout(t),Wi[e]=null)}function Ki(e,t){Gi(e),Wi[e]=setTimeout(()=>{Wi[e]=null,t.textContent=``},Ui)}var qi=null;function Ji(e){let t=document.createElement(`div`);return t.setAttribute(Vi,e),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(`role`,e===`assertive`?`alert`:`status`),t.style.cssText=Hi,document.body.appendChild(t),t}function Yi(){return typeof document>`u`?null:qi?(qi.polite.isConnected||document.body.appendChild(qi.polite),qi.assertive.isConnected||document.body.appendChild(qi.assertive),qi):(qi={polite:Ji(`polite`),assertive:Ji(`assertive`)},qi)}function Xi(e,t){let n=Yi();if(!n)return;let r=t===`assertive`?n.assertive:n.polite;r.textContent=``,requestAnimationFrame(()=>{r.textContent=e}),Ki(t,r)}function Zi(e){if(Gi(e),!qi)return;let t=e===`assertive`?qi.assertive:qi.polite;t.textContent=``}function Qi(){return(0,v.useCallback)((e,t=`polite`)=>{if(!e){Zi(t);return}Xi(e,t)},[])}var $i=2e3;function ea(e={}){let{announce:t,resetAfterMs:n=$i}=e,r=Qi(),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>{o.current!=null&&clearTimeout(o.current)},[]),{copy:(0,v.useCallback)(async e=>{try{return await navigator.clipboard.writeText(e),a(!0),t&&r(t),o.current!=null&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,a(!1)},n),!0}catch{return!1}},[r,t,n]),isCopied:i}}var ta={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,width:`1em`,height:`1em`,"aria-hidden":!0},na={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,width:`1em`,height:`1em`,"aria-hidden":!0},ra={close:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M6 6l12 12M6 18L18 6`})}),chevronDown:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M6 9l6 6 6-6`})}),chevronLeft:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M15 6l-6 6 6 6`})}),chevronRight:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M9 6l6 6-6 6`})}),chevronsLeft:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M18 6l-6 6 6 6M11 6l-6 6 6 6`})}),chevronsRight:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M6 6l6 6-6 6M13 6l6 6-6 6`})}),check:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M5 13l4 4L19 7`})}),success:(0,q.jsx)(`svg`,{...na,children:(0,q.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm4.06 6.56a.75.75 0 00-1.12-1l-3.94 4.4-1.94-1.94a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.09-.03l4.47-5z`})}),error:(0,q.jsx)(`svg`,{...na,children:(0,q.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm-2.47 5.47a.75.75 0 00-1.06 1.06L10.94 12l-2.47 2.47a.75.75 0 101.06 1.06L12 13.06l2.47 2.47a.75.75 0 101.06-1.06L13.06 12l2.47-2.47a.75.75 0 00-1.06-1.06L12 10.94l-2.47-2.47z`})}),warning:(0,q.jsx)(`svg`,{...na,children:(0,q.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.29 3.86L2.07 19.05A2 2 0 003.78 22h16.44a2 2 0 001.71-2.95L13.71 3.86a2 2 0 00-3.42 0zM12 9a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0112 9zm0 9a1 1 0 100-2 1 1 0 000 2z`})}),info:(0,q.jsx)(`svg`,{...na,children:(0,q.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3a9 9 0 100 18 9 9 0 000-18zm0 4a1 1 0 100 2 1 1 0 000-2zm-.75 3.75a.75.75 0 011.5 0v5.5a.75.75 0 01-1.5 0v-5.5z`})}),calendar:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,q.jsx)(`path`,{d:`M16 2v4M8 2v4M3 10h18`})]}),clock:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,q.jsx)(`path`,{d:`M12 7v5l3 3`})]}),externalLink:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`path`,{d:`M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6`}),(0,q.jsx)(`path`,{d:`M15 3h6v6`}),(0,q.jsx)(`path`,{d:`M10 14L21 3`})]}),menu:(0,q.jsx)(`svg`,{...ta,strokeWidth:2,children:(0,q.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),moreHorizontal:(0,q.jsxs)(`svg`,{...na,children:[(0,q.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.5`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,q.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.5`})]}),search:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,q.jsx)(`path`,{d:`M21 21l-4.35-4.35`})]}),arrowUp:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M12 19V5m0 0l-7 7m7-7l7 7`})}),arrowDown:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M12 5v14m0 0l7-7m-7 7l-7-7`})}),arrowsUpDown:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M3 7.5L7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5`})}),funnel:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z`})}),eyeSlash:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M3.98 8.223A10.477 10.477 0 001.934 12c1.292 4.338 5.31 7.5 10.066 7.5.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88`})}),viewColumns:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M9 4.5v15m6-15v15m-10.875 0h15.75c.621 0 1.125-.504 1.125-1.125V5.625c0-.621-.504-1.125-1.125-1.125H4.125C3.504 4.5 3 5.004 3 5.625v12.75c0 .621.504 1.125 1.125 1.125z`})}),copy:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`path`,{d:`M8 4v12a2 2 0 002 2h8a2 2 0 002-2V7.242a2 2 0 00-.602-1.43L16.083 2.57A2 2 0 0014.685 2H10a2 2 0 00-2 2z`}),(0,q.jsx)(`path`,{d:`M16 18v2a2 2 0 01-2 2H6a2 2 0 01-2-2V9a2 2 0 012-2h2`})]}),checkDouble:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`path`,{d:`M2 13l4 4L14 7`}),(0,q.jsx)(`path`,{d:`M9 13l4 4L21 7`})]}),wrench:(0,q.jsx)(`svg`,{...ta,children:(0,q.jsx)(`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`})}),stop:(0,q.jsx)(`svg`,{...na,children:(0,q.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}),microphone:(0,q.jsxs)(`svg`,{...ta,children:[(0,q.jsx)(`path`,{d:`M12 2a3 3 0 00-3 3v6a3 3 0 006 0V5a3 3 0 00-3-3z`}),(0,q.jsx)(`path`,{d:`M19 10v1a7 7 0 01-14 0v-1`}),(0,q.jsx)(`path`,{d:`M12 18v4m-4 0h8`})]})},ia={};function aa(e){return e==null?null:typeof e==`string`?ce(e)?.icons??null:e.icons??null}function oa(e,t){return aa(t)?.[e]??ia[e]??ra[e]}var sa={root:{kmuXW:`x2lah0s`,$$css:!0},span:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,$$css:!0}},ca={primary:{kMwMTN:`xtbr613`,$$css:!0},secondary:{kMwMTN:`xv9yike`,$$css:!0},tertiary:{kMwMTN:`xv9yike`,$$css:!0},disabled:{kMwMTN:`xqa6c3m`,$$css:!0},accent:{kMwMTN:`xqwr325`,$$css:!0},success:{kMwMTN:`xtjic6`,$$css:!0},error:{kMwMTN:`xjt36v0`,$$css:!0},warning:{kMwMTN:`xs3pv69`,$$css:!0},inherit:{kMwMTN:`x1heor9g`,$$css:!0},blue:{kMwMTN:`x1fns2mt`,$$css:!0},red:{kMwMTN:`xeffzf7`,$$css:!0},green:{kMwMTN:`xmxeech`,$$css:!0},gray:{kMwMTN:`x1eyinzz`,$$css:!0},cyan:{kMwMTN:`x157w0xa`,$$css:!0},teal:{kMwMTN:`x1f3zxcb`,$$css:!0},yellow:{kMwMTN:`x1g6zdft`,$$css:!0},orange:{kMwMTN:`xxu74a4`,$$css:!0},pink:{kMwMTN:`x1kxxfg5`,$$css:!0},purple:{kMwMTN:`xzdw94u`,$$css:!0}},la={xsm:{kzqmXN:`x1jw3ynk`,kZKoxP:`xvle69y`,$$css:!0},sm:{kzqmXN:`xcdlrvm`,kZKoxP:`x1l36t39`,$$css:!0},md:{kzqmXN:`xwqq7k2`,kZKoxP:`xmll18r`,$$css:!0},lg:{kzqmXN:`xp8d6y2`,kZKoxP:`xam5rvr`,$$css:!0}},ua={xsm:{kzqmXN:`x1jw3ynk`,kZKoxP:`xvle69y`,kGuDYH:`xboafo0`,$$css:!0},sm:{kzqmXN:`xcdlrvm`,kZKoxP:`x1l36t39`,kGuDYH:`x1jchvi3`,$$css:!0},md:{kzqmXN:`xwqq7k2`,kZKoxP:`xmll18r`,kGuDYH:`x1603h9y`,$$css:!0},lg:{kzqmXN:`xp8d6y2`,kZKoxP:`xam5rvr`,kGuDYH:`xngnso2`,$$css:!0}};function da(e){return e!=null&&e!==``?{role:`img`,"aria-label":e}:{"aria-hidden":`true`}}function fa({icon:e,color:t=`inherit`,size:n=`md`,label:r,ref:i,className:a,style:o,xstyle:s,...c}){let l=da(r);return typeof e==`string`?(0,q.jsx)(pa,{name:e,color:t,size:n,a11yProps:l,className:a,style:o,xstyle:s,spanProps:c}):(0,q.jsx)(e,{ref:i,...l,...J(Y(`icon`,{size:n,color:t}),w(sa.root,ca[t],la[n],s),a??void 0,o),...c})}fa.displayName=`Icon`;function pa({name:e,color:t,size:n,a11yProps:r,className:i,style:a,xstyle:o,spanProps:s}){let c=oa(e,pt());if(c==null)return null;let l=s??{};return(0,q.jsx)(`span`,{...r,...l,...J(Y(`icon`,{size:n,color:t}),w(sa.span,ca[t],ua[n],o),i??void 0,a),children:c})}function ma(e,t){return typeof e==`string`||typeof e==`function`||typeof e==`object`&&e&&`render`in e?(0,q.jsx)(fa,{icon:e,...t}):e}function ha(e){return oa(e,pt())}function ga(e){return(e.style.anchorName??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function _a(e,t){e.style.anchorName=t.join(`, `)}function va(e,t){let n=ga(e);n.includes(t)||(n.push(t),_a(e,n))}function ya(e,t){_a(e,ga(e).filter(e=>e!==t))}var ba={keoZOQ:`x1vhfslr`,k1K539:`xlm3tn6`,$$css:!0},xa={base:{keoZOQ:`xdj266r`,k1K539:`xat24cr`,keTefX:`x1lziwak`,k71WvV:`x14z9mp`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,kZCmMZ:`x1c1uobl`,kwRFfy:`xyri2b`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kVQacm:`x1rea2x4`,kMv6JI:`x9ynric`,kWkggS:`xjbqb8w`,$$css:!0},fixed:{kVAEAm:`xixxii4`,$$css:!0},offsetBlock:e=>[ba,{"--x-marginBlockStart":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-marginBlockEnd":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}],offsetInline:e=>[{keTefX:e==null?e:`x4lel18`,k71WvV:e==null?e:`x1c9tiao`,$$css:!0},{"--x-marginInlineStart":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-marginInlineEnd":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function Sa(e){return typeof e==`number`?`${e}px`:e}function Ca(e=`above`,t=`center`){if(e===`above`||e===`below`){let n=e===`above`?`self-block-start`:`self-block-end`;return t===`start`?`${n} span-self-inline-end`:t===`end`?`${n} span-self-inline-start`:n}let n=e===`start`?`self-inline-start`:`self-inline-end`;return t===`start`?`${n} span-self-block-end`:t===`end`?`${n} span-self-block-start`:n}function wa(e=`above`,t=`center`){let n=`flip-block, flip-inline, flip-block flip-inline`;if(t!==`center`)return n;if(e===`above`||e===`below`){let[t,r]=e===`above`?[`top`,`bottom`]:[`bottom`,`top`];return`${n}, ${t} span-left, ${t} span-right, ${r} span-left, ${r} span-right`}let[r,i]=e===`start`?[`left`,`right`]:[`right`,`left`];return`${n}, ${r} span-top, ${r} span-bottom, ${i} span-top, ${i} span-bottom`}function Ta(e){let{mode:t,onShow:n,onHide:r,lightDismiss:i=!1}=e,a=(0,v.useId)(),o=`--astryx-layer-${a.replace(/:/g,``)}`,[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(!1),f=(0,v.useCallback)(()=>{let e=l.current;e&&!d.current&&(typeof e.showPopover==`function`?e.showPopover():e.style.display=`block`,d.current=!0,c(!0),n?.())},[n]),p=(0,v.useCallback)(()=>{if(d.current){let e=l.current;e&&(typeof e.hidePopover==`function`?e.hidePopover():e.style.display=`none`),d.current=!1,c(!1),r?.()}},[r]),m=t===`context`?e=>{u.current&&u.current!==e&&ya(u.current,o),e&&va(e,o),u.current=e}:void 0,h=(0,v.useCallback)(e=>{e.newState===`closed`&&d.current&&(d.current=!1,c(!1),r?.())},[r]),g=(0,v.useRef)(null),_=(0,v.useRef)(null),y=(0,v.useCallback)((e,t)=>{g.current&&_.current&&(g.current!==e||_.current!==t)&&(g.current.removeEventListener(`toggle`,_.current),g.current=null,_.current=null),e&&g.current!==e&&(e.addEventListener(`toggle`,t),g.current=e,_.current=t)},[]),b=(0,v.useCallback)(e=>{l.current=e,y(e,h)},[h,y]);(0,v.useEffect)(()=>(l.current&&y(l.current,h),()=>{g.current&&_.current&&(g.current.removeEventListener(`toggle`,_.current),g.current=null,_.current=null)}),[h,y]);let x=(0,v.useCallback)((e,t)=>{let{placement:n=`above`,alignment:r=`center`,positioning:s=`anchor`,offset:c,role:l,"aria-label":u,xstyle:d,className:f,style:p,as:m=`div`,onMouseEnter:h,onMouseLeave:g}=t||{},_=s===`custom`?{positionAnchor:o}:{positionAnchor:o,positionArea:Ca(n,r),positionTryFallbacks:wa(n,r)},v=s===`anchor`&&c?n===`above`||n===`below`?xa.offsetBlock(Sa(c)):xa.offsetInline(Sa(c)):null,y=w(xa.base,v,d),x=f?`${f} ${y.className??``}`:y.className;return(0,q.jsx)(m,{ref:b,id:a,role:l,"aria-label":u,popover:i?`auto`:`manual`,className:x,style:{...y.style,..._,...p},onMouseEnter:h,onMouseLeave:g,children:e})},[o,a,i,b]),S=(0,v.useCallback)((e,t)=>{let{x:n,y:r,xstyle:o,className:s,style:c}=t,l={top:r,left:n},u=w(xa.base,xa.fixed,o),d=s?`${s} ${u.className??``}`:u.className;return(0,q.jsx)(`div`,{ref:b,id:a,popover:i?`auto`:`manual`,className:d,style:{...u.style,...l,...c},children:e})},[b,a,i]);return t===`context`?{ref:m,anchorId:o,show:f,hide:p,isOpen:s,id:a,render:x}:{ref:void 0,show:f,hide:p,isOpen:s,id:a,render:S}}N[`--duration-fast-max`],F[`--ease-standard`];var Ea={below:{kKVMdj:`xl1vlw0 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},above:{kKVMdj:`x3psbcj x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},end:{kKVMdj:`x1i331go x1vxsm5i x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},start:{kKVMdj:`xck01x9 x18lne9g x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0}},Da=100,Oa={container:{kWkggS:`x19aspcf`,kMwMTN:`xrkvqaz`,kaIpWk:`x1hviunn`,kMv6JI:`x9ynric`,kGuDYH:`xjm74w1`,kLWn49:`xw6l6zx`,$$css:!0}};function ka(e){return e.hasAttribute(`tabindex`)?e.tabIndex>=0:[`A`,`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`].includes(e.tagName)?!e.disabled:!!e.isContentEditable}function Aa(e={}){let{placement:t=`above`,alignment:n=`center`,delay:r=200,hideDelay:i=0,focusTrigger:a=`auto`,isEnabled:o=!0,isOpen:s,isDefaultOpen:c=!1,onShow:l,onHide:u}=e,d=Ta({mode:`context`,onShow:l,onHide:u}),f=Oa.container,p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useCallback)(()=>{p.current&&=(clearTimeout(p.current),null),m.current&&=(clearTimeout(m.current),null)},[]),_=(0,v.useCallback)(()=>{!o||s===!1||(g(),p.current=setTimeout(()=>{d.show()},r))},[o,s,g,d,r]),y=(0,v.useCallback)(()=>{s!==!0&&(g(),m.current=setTimeout(()=>{d.hide()},i>0?i:Da))},[s,g,d,i]),b=(0,v.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null)},[]),x=(0,v.useCallback)(()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: none)`).matches||_()},[_]),S=(0,v.useCallback)(()=>{y()},[y]),C=(0,v.useCallback)(e=>{o&&e.target.matches(`:focus-visible`)&&(g(),d.show())},[o,g,d]),w=(0,v.useCallback)(()=>{y()},[y]),T=(0,v.useCallback)(()=>{s===void 0&&(g(),d.hide())},[s,g,d]),E=(0,v.useCallback)(e=>{h.current&&(h.current.removeEventListener(`mouseenter`,x),h.current.removeEventListener(`mouseleave`,S),h.current.removeEventListener(`focusin`,C),h.current.removeEventListener(`focusout`,w),h.current.removeEventListener(`pointerdown`,T)),e&&(e.addEventListener(`mouseenter`,x),e.addEventListener(`mouseleave`,S),e.addEventListener(`pointerdown`,T),(a===`always`||a===`auto`&&ka(e))&&(e.addEventListener(`focusin`,C),e.addEventListener(`focusout`,w))),h.current=e},[a,x,S,C,w,T]),D=(0,v.useCallback)(e=>{d.ref(e),E(e)},[d,E]);(0,v.useEffect)(()=>()=>{g()},[g]),(0,v.useEffect)(()=>{c&&d.show()},[]),(0,v.useEffect)(()=>{s!==void 0&&(s?(g(),d.show()):(g(),d.hide()))},[s,g,d]),(0,v.useEffect)(()=>{if(s!==void 0)return;let e=e=>{e.key===`Escape`&&(e.isComposing||e.keyCode===229||(g(),d.hide()))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[s,d,g]);let k=(0,v.useCallback)((e,r)=>{let i=r?.placement??t,a={placement:i,alignment:r?.alignment??n,offset:O[`--spacing-1`],role:`tooltip`,xstyle:[f,Ea[i]],className:Y(`tooltip`).className,onMouseEnter:b,onMouseLeave:y};return d.render((0,q.jsx)(`div`,{className:`xfsso4q xy143xn x12gdq22 x1djylfy xw5ewwj x13faqbe`,children:e}),a)},[d,t,n,f,b,y]);return{ref:D,positionRef:d.ref,interactionRef:E,anchorId:d.anchorId,describedBy:d.id,renderTooltip:k}}var ja={primary:{kMwMTN:`x1tgivj0`,$$css:!0},secondary:{kMwMTN:`xv1l7n4`,$$css:!0},disabled:{kMwMTN:`xnbbluu`,$$css:!0},placeholder:{kMwMTN:`xv1l7n4`,$$css:!0},accent:{kMwMTN:`xjse4m1`,$$css:!0},inherit:{kMwMTN:`x1heor9g`,$$css:!0}},Ma={normal:{k63SB2:`x1sodnla`,$$css:!0},medium:{k63SB2:`x1e4wzip`,$$css:!0},semibold:{k63SB2:`x2mo6ok`,$$css:!0},bold:{k63SB2:`x1lvx875`,$$css:!0}},Na={body:{k63SB2:`xxovm9e`,$$css:!0},large:{k63SB2:`x149oux8`,$$css:!0},label:{k63SB2:`xmhvcl5`,$$css:!0},code:{k63SB2:`xx3eeay`,$$css:!0},supporting:{k63SB2:`xv8on6e`,$$css:!0},"display-1":{k63SB2:`x1txul5o`,$$css:!0},"display-2":{k63SB2:`x1y36c3f`,$$css:!0},"display-3":{k63SB2:`x1on40hk`,$$css:!0},inherit:{k63SB2:`x1pd3egz`,$$css:!0}},Pa={body:{kGuDYH:`xjm74w1`,kLWn49:`xw6l6zx`,$$css:!0},large:{kGuDYH:`x18juvz8`,kLWn49:`xf74fhv`,$$css:!0},label:{kGuDYH:`xcr08ib`,kLWn49:`x1kq96og`,$$css:!0},code:{kGuDYH:`xp03k98`,kLWn49:`x17iicif`,kMv6JI:`x9m5x89`,$$css:!0},supporting:{kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},"display-1":{kGuDYH:`xsub3ws`,kLWn49:`x112ttwr`,$$css:!0},"display-2":{kGuDYH:`x1yego12`,kLWn49:`xh0iwvy`,$$css:!0},"display-3":{kGuDYH:`xlgnzhf`,kLWn49:`x1ujwuaq`,$$css:!0},inherit:{kGuDYH:`x1qlqyl8`,kLWn49:`x15bjb6t`,$$css:!0}},Fa={"4xs":{kGuDYH:`xxc45ev`,$$css:!0},"3xs":{kGuDYH:`x10p7juq`,$$css:!0},"2xs":{kGuDYH:`x16a80zy`,$$css:!0},xsm:{kGuDYH:`x51wmvv`,$$css:!0},sm:{kGuDYH:`x1eqnyfr`,$$css:!0},base:{kGuDYH:`x1j29vfg`,$$css:!0},lg:{kGuDYH:`xc7cgfe`,$$css:!0},xl:{kGuDYH:`x1wqms48`,$$css:!0},"2xl":{kGuDYH:`xhs0kqb`,$$css:!0},"3xl":{kGuDYH:`x10srzze`,$$css:!0},"4xl":{kGuDYH:`xqcvi3d`,$$css:!0}},Ia={inline:{k1xSpc:`xt0psk2`,$$css:!0},block:{k1xSpc:`x1lliihq`,$$css:!0}},La={singleLine:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,k1xSpc:`x1lliihq`,$$css:!0},multiLine:{kVQacm:`xb3r6kr`,k1xSpc:`x104kibb`,kgKLqz:`x1ua5tub`,$$css:!0}},Ra={"break-word":{kTgw9:`x1lldw8n`,kHjlTd:`x1mzt3pk`,$$css:!0},"break-all":{kTgw9:`x1yn0g08`,$$css:!0}},za={wrap:{kN2L0X:`xk4td0m`,$$css:!0},nowrap:{kN2L0X:`xebhuq6`,$$css:!0},balance:{kN2L0X:`x1w2vvpw`,$$css:!0},pretty:{kN2L0X:`x1fzhlzt`,$$css:!0}},Ba={enabled:{kxwWH2:`x1b2iylo`,kzeHkT:`xwgcxoh`,k1xSpc:`x1lliihq`,$$css:!0}},Va={strikethrough:{kybGjl:`xmqliwb`,$$css:!0}},Ha={enabled:{kcqcaj:`xss6m8b`,$$css:!0}},Ua={start:{k9WMMc:`x1yc453h`,$$css:!0},center:{k9WMMc:`x2b8uid`,$$css:!0},end:{k9WMMc:`xp4054r`,$$css:!0}},Wa={content:{ks0D6T:`xw5ewwj`,kTgw9:`x13faqbe`,$$css:!0}};function Ga(e){let{maxLines:t}=e,[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(``),o=(0,v.useRef)(null),s=(0,v.useCallback)(e=>{if(t===0){r(!1);return}if(a(e.textContent??``),t===1)r(e.scrollWidth>e.offsetWidth);else{let t=e.scrollHeight;try{let n=document.createRange();n.selectNodeContents(e),t=n.getBoundingClientRect().height,n.detach()}catch{}r(t>e.offsetHeight)}},[t]);return{ref:(0,v.useCallback)(e=>{o.current&&Li(o.current),o.current=e,e&&t>0?typeof ResizeObserver<`u`?Ii(e,()=>{s(e)}):s(e):(r(!1),a(``))},[t,s]),isTruncated:n,fullText:i}}var Ka=`modulepreload`,qa=function(e){return`/`+e},Ja={},Ya=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),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?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=qa(t,n),t=s(t),t in Ja)return;Ja[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ka,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}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)})},Xa=(0,v.lazy)(async()=>Ya(()=>Promise.resolve().then(()=>Tl).then(e=>({default:e.Tooltip})),void 0)),Za={body:`primary`,large:`primary`,label:`primary`,supporting:`secondary`,code:`primary`,"display-1":`primary`,"display-2":`primary`,"display-3":`primary`,inherit:`inherit`};function Qa(e){return e in Pa?e:`body`}function $a(e){return e in ja?e:`primary`}function eo({type:e=`body`,size:t,color:n,weight:r,display:i=`inline`,maxLines:a=0,hasTruncateTooltip:o=!0,wordBreak:s,textWrap:c,justify:l=`start`,hasCapsize:u=!1,hasStrikethrough:d=!1,hasTabularNumbers:f=!1,xstyle:p,className:m,style:h,as:g=`span`,children:_,ref:y,...b}){let x=n??Za[e]??`primary`,S=Qa(e),C=$a(x),T=s??(a===1?`break-all`:`break-word`),E=a>0||u?`block`:i,D=Ga({maxLines:a}),O=typeof o==`string`?o:`above`,k=a>0&&o!==!1&&D.isTruncated,A=(0,v.useRef)(null),j=a>1?{WebkitLineClamp:a}:void 0;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g,{ref:Ei(y,D.ref,A),...J(Y(`text`,{type:e,size:t,color:x}),w(ja[C],Pa[S],t&&Fa[t],Na[S],r&&Ma[r],a===1?La.singleLine:a>1?La.multiLine:Ia[E],a>0&&Ra[T],c&&za[c],l!==`start`&&Ua[l],u&&Ba.enabled,d&&Va.strikethrough,f&&Ha.enabled,p),m,{...h,...j}),title:k?D.fullText:void 0,...b,children:_}),k&&(0,q.jsx)(v.Suspense,{fallback:null,children:(0,q.jsx)(Xa,{anchorRef:A,content:(0,q.jsx)(`span`,{...w(Wa.content),children:D.fullText}),placement:O})})]})}eo.displayName=`Text`;var to=1.5,no={sm:{diameter:10,border:2},md:{diameter:14,border:3},lg:{diameter:18,border:3},xl:{diameter:28,border:4}},X={wrapper:{k1xSpc:`x3nfvp2`,kXwgrk:`xdt5ytf`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,$$css:!0},spinner:{k1xSpc:`xwz0xwf`,kgQiWS:`x1ku5rj1`,kVQacm:`xb3r6kr`,kXLuUW:`xxymvpz`,$$css:!0}};function ro({size:e=`md`,shade:t=`default`,label:n,xstyle:r,className:i,style:a,"aria-label":o,"data-testid":s,ref:c,...l}){let u=(0,v.useRef)(null),{tokens:d}=mt();(0,v.useEffect)(()=>{let n=u.current;if(n==null)return;let r=n.getContext(`2d`);if(!r)return;let{border:i,diameter:a}=no[e],o=window.devicePixelRatio||1,s=t===`inherit`?getComputedStyle(n).color:null,c=t===`inherit`?s:t===`onMedia`?d[`--color-on-dark`]:t===`subtle`?d[`--color-text-secondary`]:d[`--color-accent`],l=t===`inherit`?s:t===`onMedia`?`${d[`--color-on-dark`]}4D`:d[`--color-track`],f=a+i*2,p=Math.round(f*o),m=p+p%2,h=m/f,g=a/2*h,_=i*h;n.height=n.width=m,n.style.width=n.style.height=f+`px`,r.lineCap=`round`,r.lineWidth=_;let v=m/2;r.beginPath(),r.arc(v,v,g,0,2*Math.PI),r.strokeStyle=l,t===`inherit`&&(r.globalAlpha=.3),r.stroke(),r.globalAlpha=1,r.beginPath(),r.arc(v,v,g,to*Math.PI,2.25%2*Math.PI),r.strokeStyle=c,r.stroke()},[t,e,d]);let{border:f,diameter:p}=no[e],m=p+f*2,h=n!=null,g=(0,v.useId)(),_=h&&typeof n==`string`&&o==null,y=(0,q.jsx)(`span`,{ref:h?void 0:c,role:`status`,"aria-label":_?void 0:o??(typeof n==`string`?n:void 0)??`Loading`,"aria-labelledby":_?g:void 0,"data-testid":h?void 0:s,...h?{}:l,...J(h?``:Y(`spinner`,{size:e,shade:t}),w(X.spinner,!h&&r),h?void 0:i,{...h?{}:a,width:m,height:m}),children:(0,q.jsx)(`canvas`,{ref:u,className:`xlp1x4z x1lliihq x1so62im x14qxm4i xnh0sag xa4qsjk x1ka1v4i x1esw782`})});return h?(0,q.jsxs)(`div`,{ref:c,"data-testid":s,...l,...J(Y(`spinner`,{size:e,shade:t}),w(X.wrapper,r),i,a),children:[y,typeof n==`string`?(0,q.jsx)(eo,{id:g,type:`body`,weight:`bold`,children:n}):n]}):y}ro.displayName=`Spinner`;function io({children:e,as:t=`span`,ref:n,...r}){return(0,v.createElement)(t,{ref:n,...r,className:`x10l6tqk x1i1rx1s xjm9jq1 xkdpibf x1717udv xb3r6kr xzpqnlu xuxw1ft xng3xce x13vifvy x1o0tod x47corl x87ps6o`},e)}io.displayName=`VisuallyHidden`;var ao=`data-astryx-edge-comp`,oo=(0,v.createContext)(null);oo.displayName=`SizeContext`;function so(e,t=`md`){let n=(0,v.use)(oo);return e??n??t}oo.Provider;var co=(0,v.createContext)(null);co.displayName=`ButtonGroupContext`;function lo(){return(0,v.use)(co)}var uo=(0,v.createContext)(null);uo.displayName=`LinkContext`;function fo(e){function t({href:t,ref:n,...r}){return(0,v.createElement)(e,{ref:n,href:t,to:t,...r})}return t.displayName=`LinkWithTo(${typeof e==`string`?e:e.displayName||e.name||`Component`})`,t}function po(e){let t=(0,v.use)(uo),n=e??t?.component??`a`;return(0,v.useMemo)(()=>n===`a`?`a`:fo(n),[n])}var mo={outlineWidth:`2px`,outlineStyle:`solid`,outlineColor:E[`--color-accent`],outlineOffset:`3px`},ho={outlineWidth:``,outlineStyle:``,outlineColor:``,outlineOffset:``},go={focusVisible:{kMeerF:`x1k57tk5 x784prv`,k3XXqK:`x1t137rt x9v5kkp`,kjBf7l:`xzunyri`,kInvED:`x1wfwxd8 xj3ae5l`,$$css:!0},focusWithin:{kMeerF:`x1k57tk5 x1odlxkb`,k3XXqK:`x1t137rt xnnj0qo`,kjBf7l:`xee0hk0`,kInvED:`x1wfwxd8 xscfbxq`,$$css:!0},publishFocusVisibleVars:{"--_focus-outline":`x17wzz1v x1bqhfga`,"--_focus-outline-offset":`xgzxwq1 x1tcr69y`,$$css:!0},focusWithinOrPublished:{kI3sdo:`xaw4jrz x1irc7jg`,kInvED:`x1kvmbwa xscfbxq`,$$css:!0}};function _o(e){return(...t)=>w(e,...t)}var vo={focusVisible:_o(go.focusVisible),focusWithin:_o(go.focusWithin),publishFocusVisibleVars:_o(go.publishFocusVisibleVars),focusWithinOrPublished:_o(go.focusWithinOrPublished)},yo=(0,v.createContext)({locale:`en`,direction:`ltr`,messages:{}});yo.displayName=`InternationalizationContext`;function bo(e,t){let n=t&&t.cache?t.cache:Ao,r=t&&t.serializer?t.serializer:Oo;return(t&&t.strategy?t.strategy:To)(e,{cache:n,serializer:r})}function xo(e){return e==null||typeof e==`number`||typeof e==`boolean`}function So(e,t,n,r){let i=xo(r)?r:n(r),a=t.get(i);return a===void 0&&(a=e.call(this,r),t.set(i,a)),a}function Co(e,t,n){let r=Array.prototype.slice.call(arguments,3),i=n(r),a=t.get(i);return a===void 0&&(a=e.apply(this,r),t.set(i,a)),a}function wo(e,t,n,r,i){return n.bind(t,e,r,i)}function To(e,t){let n=e.length===1?So:Co;return wo(e,this,n,t.cache.create(),t.serializer)}function Eo(e,t){return wo(e,this,Co,t.cache.create(),t.serializer)}function Do(e,t){return wo(e,this,So,t.cache.create(),t.serializer)}var Oo=function(){return JSON.stringify(arguments)},ko=class{constructor(){this.cache=Object.create(null)}get(e){return this.cache[e]}set(e,t){this.cache[e]=t}},Ao={create:function(){return new ko}},jo={variadic:Eo,monadic:Do},Mo=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function No(e){let t={};return e.replace(Mo,e=>{let n=e.length;switch(e[0]){case`G`:t.era=n===4?`long`:n===5?`narrow`:`short`;break;case`y`:t.year=n===2?`2-digit`:`numeric`;break;case`Y`:case`u`:case`U`:case`r`:throw RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case`q`:case`Q`:throw RangeError("`q/Q` (quarter) patterns are not supported");case`M`:case`L`:t.month=[`numeric`,`2-digit`,`short`,`long`,`narrow`][n-1];break;case`w`:case`W`:throw RangeError("`w/W` (week) patterns are not supported");case`d`:t.day=[`numeric`,`2-digit`][n-1];break;case`D`:case`F`:case`g`:throw RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case`E`:t.weekday=n===4?`long`:n===5?`narrow`:`short`;break;case`e`:if(n<4)throw RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=[`short`,`long`,`narrow`,`short`][n-3];break;case`c`:if(n<4)throw RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=[`short`,`long`,`narrow`,`short`][n-3];break;case`a`:t.hour12=!0;break;case`b`:case`B`:throw RangeError("`b/B` (period) patterns are not supported, use `a` instead");case`h`:t.hourCycle=`h12`,t.hour=[`numeric`,`2-digit`][n-1];break;case`H`:t.hourCycle=`h23`,t.hour=[`numeric`,`2-digit`][n-1];break;case`K`:t.hourCycle=`h11`,t.hour=[`numeric`,`2-digit`][n-1];break;case`k`:t.hourCycle=`h24`,t.hour=[`numeric`,`2-digit`][n-1];break;case`j`:case`J`:case`C`:throw RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case`m`:t.minute=[`numeric`,`2-digit`][n-1];break;case`s`:t.second=[`numeric`,`2-digit`][n-1];break;case`S`:case`A`:throw RangeError("`S/A` (second) patterns are not supported, use `s` instead");case`z`:t.timeZoneName=n<4?`short`:`long`;break;case`Z`:case`O`:case`v`:case`V`:case`X`:case`x`:throw RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return``}),t}var Po=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function Fo(e){if(e.length===0)throw Error(`Number skeleton cannot be empty`);let t=e.split(Po).filter(e=>e.length>0),n=[];for(let e of t){let t=e.split(`/`);if(t.length===0)throw Error(`Invalid number skeleton`);let[r,...i]=t;for(let e of i)if(e.length===0)throw Error(`Invalid number skeleton`);n.push({stem:r,options:i})}return n}function Io(e){return e.replace(/^(.*?)-/,``)}var Lo=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,Ro=/^(@+)?(\+|#+)?[rs]?$/g,zo=/(\*)(0+)|(#+)(0+)|(0+)/g,Bo=/^(0+)$/;function Vo(e){let t={};return e[e.length-1]===`r`?t.roundingPriority=`morePrecision`:e[e.length-1]===`s`&&(t.roundingPriority=`lessPrecision`),e.replace(Ro,function(e,n,r){return typeof r==`string`?r===`+`?t.minimumSignificantDigits=n.length:n[0]===`#`?t.maximumSignificantDigits=n.length:(t.minimumSignificantDigits=n.length,t.maximumSignificantDigits=n.length+(typeof r==`string`?r.length:0)):(t.minimumSignificantDigits=n.length,t.maximumSignificantDigits=n.length),``}),t}function Ho(e){switch(e){case`sign-auto`:return{signDisplay:`auto`};case`sign-accounting`:case`()`:return{currencySign:`accounting`};case`sign-always`:case`+!`:return{signDisplay:`always`};case`sign-accounting-always`:case`()!`:return{signDisplay:`always`,currencySign:`accounting`};case`sign-except-zero`:case`+?`:return{signDisplay:`exceptZero`};case`sign-accounting-except-zero`:case`()?`:return{signDisplay:`exceptZero`,currencySign:`accounting`};case`sign-never`:case`+_`:return{signDisplay:`never`}}}function Uo(e){let t;if(e[0]===`E`&&e[1]===`E`?(t={notation:`engineering`},e=e.slice(2)):e[0]===`E`&&(t={notation:`scientific`},e=e.slice(1)),t){let n=e.slice(0,2);if(n===`+!`?(t.signDisplay=`always`,e=e.slice(2)):n===`+?`&&(t.signDisplay=`exceptZero`,e=e.slice(2)),!Bo.test(e))throw Error(`Malformed concise eng/scientific notation`);t.minimumIntegerDigits=e.length}return t}function Wo(e){return Ho(e)||{}}function Go(e){let t={};for(let n of e){switch(n.stem){case`percent`:case`%`:t.style=`percent`;continue;case`%x100`:t.style=`percent`,t.scale=100;continue;case`currency`:t.style=`currency`,t.currency=n.options[0];continue;case`group-off`:case`,_`:t.useGrouping=!1;continue;case`precision-integer`:case`.`:t.maximumFractionDigits=0;continue;case`measure-unit`:case`unit`:t.style=`unit`,t.unit=Io(n.options[0]);continue;case`compact-short`:case`K`:t.notation=`compact`,t.compactDisplay=`short`;continue;case`compact-long`:case`KK`:t.notation=`compact`,t.compactDisplay=`long`;continue;case`scientific`:t={...t,notation:`scientific`,...n.options.reduce((e,t)=>({...e,...Wo(t)}),{})};continue;case`engineering`:t={...t,notation:`engineering`,...n.options.reduce((e,t)=>({...e,...Wo(t)}),{})};continue;case`notation-simple`:t.notation=`standard`;continue;case`unit-width-narrow`:t.currencyDisplay=`narrowSymbol`,t.unitDisplay=`narrow`;continue;case`unit-width-short`:t.currencyDisplay=`code`,t.unitDisplay=`short`;continue;case`unit-width-full-name`:t.currencyDisplay=`name`,t.unitDisplay=`long`;continue;case`unit-width-iso-code`:t.currencyDisplay=`symbol`;continue;case`scale`:t.scale=parseFloat(n.options[0]);continue;case`rounding-mode-floor`:t.roundingMode=`floor`;continue;case`rounding-mode-ceiling`:t.roundingMode=`ceil`;continue;case`rounding-mode-down`:t.roundingMode=`trunc`;continue;case`rounding-mode-up`:t.roundingMode=`expand`;continue;case`rounding-mode-half-even`:t.roundingMode=`halfEven`;continue;case`rounding-mode-half-down`:t.roundingMode=`halfTrunc`;continue;case`rounding-mode-half-up`:t.roundingMode=`halfExpand`;continue;case`integer-width`:if(n.options.length>1)throw RangeError(`integer-width stems only accept a single optional option`);n.options[0].replace(zo,function(e,n,r,i,a,o){if(n)t.minimumIntegerDigits=r.length;else if(i&&a)throw Error(`We currently do not support maximum integer digits`);else if(o)throw Error(`We currently do not support exact integer digits`);return``});continue}if(Bo.test(n.stem)){t.minimumIntegerDigits=n.stem.length;continue}if(Lo.test(n.stem)){if(n.options.length>1)throw RangeError(`Fraction-precision stems only accept a single optional option`);n.stem.replace(Lo,function(e,n,r,i,a,o){return r===`*`?t.minimumFractionDigits=n.length:i&&i[0]===`#`?t.maximumFractionDigits=i.length:a&&o?(t.minimumFractionDigits=a.length,t.maximumFractionDigits=a.length+o.length):(t.minimumFractionDigits=n.length,t.maximumFractionDigits=n.length),``});let e=n.options[0];e===`w`?t={...t,trailingZeroDisplay:`stripIfInteger`}:e&&(t={...t,...Vo(e)});continue}if(Ro.test(n.stem)){t={...t,...Vo(n.stem)};continue}let e=Ho(n.stem);e&&(t={...t,...e});let r=Uo(n.stem);r&&(t={...t,...r})}return t}var Ko=function(e){return e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]=`EXPECT_ARGUMENT_CLOSING_BRACE`,e[e.EMPTY_ARGUMENT=2]=`EMPTY_ARGUMENT`,e[e.MALFORMED_ARGUMENT=3]=`MALFORMED_ARGUMENT`,e[e.EXPECT_ARGUMENT_TYPE=4]=`EXPECT_ARGUMENT_TYPE`,e[e.INVALID_ARGUMENT_TYPE=5]=`INVALID_ARGUMENT_TYPE`,e[e.EXPECT_ARGUMENT_STYLE=6]=`EXPECT_ARGUMENT_STYLE`,e[e.INVALID_NUMBER_SKELETON=7]=`INVALID_NUMBER_SKELETON`,e[e.INVALID_DATE_TIME_SKELETON=8]=`INVALID_DATE_TIME_SKELETON`,e[e.EXPECT_NUMBER_SKELETON=9]=`EXPECT_NUMBER_SKELETON`,e[e.EXPECT_DATE_TIME_SKELETON=10]=`EXPECT_DATE_TIME_SKELETON`,e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]=`UNCLOSED_QUOTE_IN_ARGUMENT_STYLE`,e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]=`EXPECT_SELECT_ARGUMENT_OPTIONS`,e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]=`EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE`,e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]=`INVALID_PLURAL_ARGUMENT_OFFSET_VALUE`,e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]=`EXPECT_SELECT_ARGUMENT_SELECTOR`,e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]=`EXPECT_PLURAL_ARGUMENT_SELECTOR`,e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]=`EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT`,e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]=`EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT`,e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]=`INVALID_PLURAL_ARGUMENT_SELECTOR`,e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]=`DUPLICATE_PLURAL_ARGUMENT_SELECTOR`,e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]=`DUPLICATE_SELECT_ARGUMENT_SELECTOR`,e[e.MISSING_OTHER_CLAUSE=22]=`MISSING_OTHER_CLAUSE`,e[e.INVALID_TAG=23]=`INVALID_TAG`,e[e.INVALID_TAG_NAME=25]=`INVALID_TAG_NAME`,e[e.UNMATCHED_CLOSING_TAG=26]=`UNMATCHED_CLOSING_TAG`,e[e.UNCLOSED_TAG=27]=`UNCLOSED_TAG`,e}({});function qo(e){return e.type===0}function Jo(e){return e.type===1}function Yo(e){return e.type===2}function Xo(e){return e.type===3}function Zo(e){return e.type===4}function Qo(e){return e.type===5}function $o(e){return e.type===6}function es(e){return e.type===7}function ts(e){return e.type===8}function ns(e){return!!(e&&typeof e==`object`&&e.type===0)}function rs(e){return!!(e&&typeof e==`object`&&e.type===1)}var is=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,as={"001":[`H`,`h`],419:[`h`,`H`,`hB`,`hb`],AC:[`H`,`h`,`hb`,`hB`],AD:[`H`,`hB`],AE:[`h`,`hB`,`hb`,`H`],AF:[`H`,`hb`,`hB`,`h`],AG:[`h`,`hb`,`H`,`hB`],AI:[`H`,`h`,`hb`,`hB`],AL:[`h`,`H`,`hB`],AM:[`H`,`hB`],AO:[`H`,`hB`],AR:[`h`,`H`,`hB`,`hb`],AS:[`h`,`H`],AT:[`H`,`hB`],AU:[`h`,`hb`,`H`,`hB`],AW:[`H`,`hB`],AX:[`H`],AZ:[`H`,`hB`,`h`],BA:[`H`,`hB`,`h`],BB:[`h`,`hb`,`H`,`hB`],BD:[`h`,`hB`,`H`],BE:[`H`,`hB`],BF:[`H`,`hB`],BG:[`H`,`hB`,`h`],BH:[`h`,`hB`,`hb`,`H`],BI:[`H`,`h`],BJ:[`H`,`hB`],BL:[`H`,`hB`],BM:[`h`,`hb`,`H`,`hB`],BN:[`hb`,`hB`,`h`,`H`],BO:[`h`,`H`,`hB`,`hb`],BQ:[`H`],BR:[`H`,`hB`],BS:[`h`,`hb`,`H`,`hB`],BT:[`h`,`H`],BW:[`H`,`h`,`hb`,`hB`],BY:[`H`,`h`],BZ:[`H`,`h`,`hb`,`hB`],CA:[`h`,`hb`,`H`,`hB`],CC:[`H`,`h`,`hb`,`hB`],CD:[`hB`,`H`],CF:[`H`,`h`,`hB`],CG:[`H`,`hB`],CH:[`H`,`hB`,`h`],CI:[`H`,`hB`],CK:[`H`,`h`,`hb`,`hB`],CL:[`h`,`H`,`hB`,`hb`],CM:[`H`,`h`,`hB`],CN:[`H`,`hB`,`hb`,`h`],CO:[`h`,`H`,`hB`,`hb`],CP:[`H`],CR:[`h`,`H`,`hB`,`hb`],CU:[`h`,`H`,`hB`,`hb`],CV:[`H`,`hB`],CW:[`H`,`hB`],CX:[`H`,`h`,`hb`,`hB`],CY:[`h`,`H`,`hb`,`hB`],CZ:[`H`],DE:[`H`,`hB`],DG:[`H`,`h`,`hb`,`hB`],DJ:[`h`,`H`],DK:[`H`],DM:[`h`,`hb`,`H`,`hB`],DO:[`h`,`H`,`hB`,`hb`],DZ:[`h`,`hB`,`hb`,`H`],EA:[`H`,`h`,`hB`,`hb`],EC:[`h`,`H`,`hB`,`hb`],EE:[`H`,`hB`],EG:[`h`,`hB`,`hb`,`H`],EH:[`h`,`hB`,`hb`,`H`],ER:[`h`,`H`],ES:[`H`,`hB`,`h`,`hb`],ET:[`hB`,`hb`,`h`,`H`],FI:[`H`],FJ:[`h`,`hb`,`H`,`hB`],FK:[`H`,`h`,`hb`,`hB`],FM:[`h`,`hb`,`H`,`hB`],FO:[`H`,`h`],FR:[`H`,`hB`],GA:[`H`,`hB`],GB:[`H`,`h`,`hb`,`hB`],GD:[`h`,`hb`,`H`,`hB`],GE:[`H`,`hB`,`h`],GF:[`H`,`hB`],GG:[`H`,`h`,`hb`,`hB`],GH:[`h`,`H`],GI:[`H`,`h`,`hb`,`hB`],GL:[`H`,`h`],GM:[`h`,`hb`,`H`,`hB`],GN:[`H`,`hB`],GP:[`H`,`hB`],GQ:[`H`,`hB`,`h`,`hb`],GR:[`h`,`H`,`hb`,`hB`],GS:[`H`,`h`,`hb`,`hB`],GT:[`h`,`H`,`hB`,`hb`],GU:[`h`,`hb`,`H`,`hB`],GW:[`H`,`hB`],GY:[`h`,`hb`,`H`,`hB`],HK:[`h`,`hB`,`hb`,`H`],HN:[`h`,`H`,`hB`,`hb`],HR:[`H`,`hB`],HU:[`H`,`h`],IC:[`H`,`h`,`hB`,`hb`],ID:[`H`],IE:[`H`,`h`,`hb`,`hB`],IL:[`H`,`hB`],IM:[`H`,`h`,`hb`,`hB`],IN:[`h`,`H`],IO:[`H`,`h`,`hb`,`hB`],IQ:[`h`,`hB`,`hb`,`H`],IR:[`hB`,`H`],IS:[`H`],IT:[`H`,`hB`],JE:[`H`,`h`,`hb`,`hB`],JM:[`h`,`hb`,`H`,`hB`],JO:[`h`,`hB`,`hb`,`H`],JP:[`H`,`K`,`h`],KE:[`hB`,`hb`,`H`,`h`],KG:[`H`,`h`,`hB`,`hb`],KH:[`hB`,`h`,`H`,`hb`],KI:[`h`,`hb`,`H`,`hB`],KM:[`H`,`h`,`hB`,`hb`],KN:[`h`,`hb`,`H`,`hB`],KP:[`h`,`H`,`hB`,`hb`],KR:[`h`,`H`,`hB`,`hb`],KW:[`h`,`hB`,`hb`,`H`],KY:[`h`,`hb`,`H`,`hB`],KZ:[`H`,`hB`],LA:[`H`,`hb`,`hB`,`h`],LB:[`h`,`hB`,`hb`,`H`],LC:[`h`,`hb`,`H`,`hB`],LI:[`H`,`hB`,`h`],LK:[`H`,`h`,`hB`,`hb`],LR:[`h`,`hb`,`H`,`hB`],LS:[`h`,`H`],LT:[`H`,`h`,`hb`,`hB`],LU:[`H`,`h`,`hB`],LV:[`H`,`hB`,`hb`,`h`],LY:[`h`,`hB`,`hb`,`H`],MA:[`H`,`h`,`hB`,`hb`],MC:[`H`,`hB`],MD:[`H`,`hB`],ME:[`H`,`hB`,`h`],MF:[`H`,`hB`],MG:[`H`,`h`],MH:[`h`,`hb`,`H`,`hB`],MK:[`H`,`h`,`hb`,`hB`],ML:[`H`],MM:[`hB`,`hb`,`H`,`h`],MN:[`H`,`h`,`hb`,`hB`],MO:[`h`,`hB`,`hb`,`H`],MP:[`h`,`hb`,`H`,`hB`],MQ:[`H`,`hB`],MR:[`h`,`hB`,`hb`,`H`],MS:[`H`,`h`,`hb`,`hB`],MT:[`H`,`h`],MU:[`H`,`h`],MV:[`H`,`h`],MW:[`h`,`hb`,`H`,`hB`],MX:[`h`,`H`,`hB`,`hb`],MY:[`hb`,`hB`,`h`,`H`],MZ:[`H`,`hB`],NA:[`h`,`H`,`hB`,`hb`],NC:[`H`,`hB`],NE:[`H`],NF:[`H`,`h`,`hb`,`hB`],NG:[`H`,`h`,`hb`,`hB`],NI:[`h`,`H`,`hB`,`hb`],NL:[`H`,`hB`],NO:[`H`,`h`],NP:[`H`,`h`,`hB`],NR:[`H`,`h`,`hb`,`hB`],NU:[`H`,`h`,`hb`,`hB`],NZ:[`h`,`hb`,`H`,`hB`],OM:[`h`,`hB`,`hb`,`H`],PA:[`h`,`H`,`hB`,`hb`],PE:[`h`,`H`,`hB`,`hb`],PF:[`H`,`h`,`hB`],PG:[`h`,`H`],PH:[`h`,`hB`,`hb`,`H`],PK:[`h`,`hB`,`H`],PL:[`H`,`h`],PM:[`H`,`hB`],PN:[`H`,`h`,`hb`,`hB`],PR:[`h`,`H`,`hB`,`hb`],PS:[`h`,`hB`,`hb`,`H`],PT:[`H`,`hB`],PW:[`h`,`H`],PY:[`h`,`H`,`hB`,`hb`],QA:[`h`,`hB`,`hb`,`H`],RE:[`H`,`hB`],RO:[`H`,`hB`],RS:[`H`,`hB`,`h`],RU:[`H`],RW:[`H`,`h`],SA:[`h`,`hB`,`hb`,`H`],SB:[`h`,`hb`,`H`,`hB`],SC:[`H`,`h`,`hB`],SD:[`h`,`hB`,`hb`,`H`],SE:[`H`],SG:[`h`,`hb`,`H`,`hB`],SH:[`H`,`h`,`hb`,`hB`],SI:[`H`,`hB`],SJ:[`H`],SK:[`H`],SL:[`h`,`hb`,`H`,`hB`],SM:[`H`,`h`,`hB`],SN:[`H`,`h`,`hB`],SO:[`h`,`H`],SR:[`H`,`hB`],SS:[`h`,`hb`,`H`,`hB`],ST:[`H`,`hB`],SV:[`h`,`H`,`hB`,`hb`],SX:[`H`,`h`,`hb`,`hB`],SY:[`h`,`hB`,`hb`,`H`],SZ:[`h`,`hb`,`H`,`hB`],TA:[`H`,`h`,`hb`,`hB`],TC:[`h`,`hb`,`H`,`hB`],TD:[`h`,`H`,`hB`],TF:[`H`,`h`,`hB`],TG:[`H`,`hB`],TH:[`H`,`h`],TJ:[`H`,`h`],TL:[`H`,`hB`,`hb`,`h`],TM:[`H`,`h`],TN:[`h`,`hB`,`hb`,`H`],TO:[`h`,`H`],TR:[`H`,`hB`],TT:[`h`,`hb`,`H`,`hB`],TW:[`hB`,`hb`,`h`,`H`],TZ:[`hB`,`hb`,`H`,`h`],UA:[`H`,`hB`,`h`],UG:[`hB`,`hb`,`H`,`h`],UM:[`h`,`hb`,`H`,`hB`],US:[`h`,`hb`,`H`,`hB`],UY:[`h`,`H`,`hB`,`hb`],UZ:[`H`,`hB`,`h`],VA:[`H`,`h`,`hB`],VC:[`h`,`hb`,`H`,`hB`],VE:[`h`,`H`,`hB`,`hb`],VG:[`h`,`hb`,`H`,`hB`],VI:[`h`,`hb`,`H`,`hB`],VN:[`H`,`h`],VU:[`h`,`H`],WF:[`H`,`hB`],WS:[`h`,`H`],XK:[`H`,`hB`,`h`],YE:[`h`,`hB`,`hb`,`H`],YT:[`H`,`hB`],ZA:[`H`,`h`,`hb`,`hB`],ZM:[`h`,`hb`,`H`,`hB`],ZW:[`H`,`h`],"af-ZA":[`H`,`h`,`hB`,`hb`],"ar-001":[`h`,`hB`,`hb`,`H`],"ca-ES":[`H`,`h`,`hB`],"en-001":[`h`,`hb`,`H`,`hB`],"en-HK":[`h`,`hb`,`H`,`hB`],"en-IL":[`H`,`h`,`hb`,`hB`],"en-MY":[`h`,`hb`,`H`,`hB`],"es-BR":[`H`,`h`,`hB`,`hb`],"es-ES":[`H`,`h`,`hB`,`hb`],"es-GQ":[`H`,`h`,`hB`,`hb`],"fr-CA":[`H`,`h`,`hB`],"gl-ES":[`H`,`h`,`hB`],"gu-IN":[`hB`,`hb`,`h`,`H`],"hi-IN":[`hB`,`h`,`H`],"it-CH":[`H`,`h`,`hB`],"it-IT":[`H`,`h`,`hB`],"kn-IN":[`hB`,`h`,`H`],"ku-SY":[`H`,`hB`],"ml-IN":[`hB`,`h`,`H`],"mr-IN":[`hB`,`hb`,`h`,`H`],"pa-IN":[`hB`,`hb`,`h`,`H`],"ta-IN":[`hB`,`h`,`hb`,`H`],"te-IN":[`hB`,`h`,`H`],"zu-ZA":[`H`,`hB`,`hb`,`h`]};function os(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(i===`j`){let a=0;for(;r+1<e.length&&e.charAt(r+1)===i;)a++,r++;let o=1+(a&1),s=a<2?1:3+(a>>1),c=ss(t);for((c==`H`||c==`k`)&&(s=0);s-->0;)n+=`a`;for(;o-->0;)n=c+n}else n+=i===`J`?`H`:i}return n}function ss(e){let t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case`h24`:return`k`;case`h23`:return`H`;case`h12`:return`h`;case`h11`:return`K`;default:throw Error(`Invalid hourCycle`)}let n=e.language,r;return n!==`root`&&(r=e.maximize().region),(as[r||``]||as[n||``]||as[`${n}-001`]||as[`001`])[0]}var cs=RegExp(`^${is.source}*`),ls=RegExp(`${is.source}*$`);function us(e,t){return{start:e,end:t}}var ds=!!Object.fromEntries,fs=!!String.prototype.trimStart,ps=!!String.prototype.trimEnd,ms=ds?Object.fromEntries:function(e){let t={};for(let[n,r]of e)t[n]=r;return t},hs=fs?function(e){return e.trimStart()}:function(e){return e.replace(cs,``)},gs=ps?function(e){return e.trimEnd()}:function(e){return e.replace(ls,``)},_s=RegExp(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`,`yu`);function vs(e,t){return _s.lastIndex=t,_s.exec(e)[1]??``}function ys(e){if(e.length===0)return null;let t=1,n=1;for(let r=0;r<e.length;){let i=e.charCodeAt(r);switch(i){case 35:case 39:case 60:case 123:case 125:return null}if(i===10)t++,n=1,r++;else if(n++,i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);r+=t>=56320&&t<=57343?2:1}else r++}return{offset:e.length,line:t,column:n}}var bs=class{constructor(e,t={}){this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.locale=t.locale,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error(`parser can only be used once`);if(this.message.length>0){let e=this.message.charCodeAt(0);if(e!==35&&e!==39&&e!==60&&e!==123&&e!==125){let e=ys(this.message);if(e){let t=this.clonePosition();return this.position=e,{val:[{type:0,value:this.message,location:us(t,this.clonePosition())}],err:null}}}}return this.parseMessage(0,``,!1)}parseMessage(e,t,n){let r=[];for(;!this.isEOF();){let i=this.char();if(i===123){let t=this.parseArgument(e,n);if(t.err)return t;r.push(t.val)}else if(i===125&&e>0)break;else if(i===35&&(t===`plural`||t===`selectordinal`)){let e=this.clonePosition();this.bump(),r.push({type:7,location:us(e,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,us(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&xs(this.peek()||0)){let n=this.parseTag(e,t);if(n.err)return n;r.push(n.val)}else{let n=this.parseLiteral(e,t);if(n.err)return n;r.push(n.val)}}return{val:r,err:null}}parseTag(e,t){let n=this.clonePosition();this.bump();let r=this.parseTagName();if(this.bumpSpace(),this.bumpIf(`/>`))return{val:{type:0,value:`<${r}/>`,location:us(n,this.clonePosition())},err:null};if(this.bumpIf(`>`)){let i=this.parseMessage(e+1,t,!0);if(i.err)return i;let a=i.val,o=this.clonePosition();if(this.bumpIf(`</`)){if(this.isEOF()||!xs(this.char()))return this.error(23,us(o,this.clonePosition()));let e=this.clonePosition();return r===this.parseTagName()?(this.bumpSpace(),this.bumpIf(`>`)?{val:{type:8,value:r,children:a,location:us(n,this.clonePosition())},err:null}:this.error(23,us(o,this.clonePosition()))):this.error(26,us(e,this.clonePosition()))}return this.error(27,us(n,this.clonePosition()))}return this.error(23,us(n,this.clonePosition()))}parseTagName(){let e=this.offset();for(this.bump();!this.isEOF()&&Cs(this.char());)this.bump();return this.message.slice(e,this.offset())}parseLiteral(e,t){let n=this.clonePosition(),r=``;for(;;){let n=this.tryParseQuote(t);if(n){r+=n;continue}let i=this.tryParseUnquoted(e,t);if(i){r+=i;continue}let a=this.tryParseLeftAngleBracket();if(a){r+=a;continue}break}let i=us(n,this.clonePosition());return{val:{type:0,value:r,location:i},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!Ss(this.peek()||0))?(this.bump(),`<`):null}tryParseQuote(e){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),`'`;case 123:case 60:case 62:case 125:break;case 35:if(e===`plural`||e===`selectordinal`)break;return null;default:return null}this.bump();let t=[this.char()];for(this.bump();!this.isEOF();){let e=this.char();if(e===39){if(this.peek()===39)t.push(39),this.bump();else{this.bump();break}}else t.push(e);this.bump()}return String.fromCodePoint(...t)}tryParseUnquoted(e,t){if(this.isEOF())return null;let n=this.char();return n===60||n===123||n===35&&(t===`plural`||t===`selectordinal`)||n===125&&e>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(e,t){let n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,us(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,us(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,us(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,us(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:us(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,us(n,this.clonePosition())):this.parseArgumentOptions(e,t,r,n);default:return this.error(3,us(n,this.clonePosition()))}}parseIdentifierIfPossible(){let e=this.clonePosition(),t=this.offset(),n=vs(this.message,t),r=t+n.length;return this.bumpTo(r),{value:n,location:us(e,this.clonePosition())}}parseArgumentOptions(e,t,n,r){let i=this.clonePosition(),a=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(a){case``:return this.error(4,us(i,o));case`number`:case`date`:case`time`:{this.bumpSpace();let e=null;if(this.bumpIf(`,`)){this.bumpSpace();let t=this.clonePosition(),n=this.parseSimpleArgStyleIfPossible();if(n.err)return n;let r=gs(n.val);if(r.length===0)return this.error(6,us(this.clonePosition(),this.clonePosition()));e={style:r,styleLocation:us(t,this.clonePosition())}}let t=this.tryParseArgumentClose(r);if(t.err)return t;let i=us(r,this.clonePosition());if(e&&e.style.startsWith(`::`)){let t=hs(e.style.slice(2));if(a===`number`){let r=this.parseNumberSkeletonFromString(t,e.styleLocation);return r.err?r:{val:{type:2,value:n,location:i,style:r.val},err:null}}{if(t.length===0)return this.error(10,i);let r=t;this.locale&&(r=os(t,this.locale));let o={type:1,pattern:r,location:e.styleLocation,parsedOptions:this.shouldParseSkeletons?No(r):{}};return{val:{type:a===`date`?3:4,value:n,location:i,style:o},err:null}}}return{val:{type:a===`number`?2:a===`date`?3:4,value:n,location:i,style:e?.style??null},err:null}}case`plural`:case`selectordinal`:case`select`:{let i=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(`,`))return this.error(12,us(i,{...i}));this.bumpSpace();let o=this.parseIdentifierIfPossible(),s=0;if(a!==`select`&&o.value===`offset`){if(!this.bumpIf(`:`))return this.error(13,us(this.clonePosition(),this.clonePosition()));this.bumpSpace();let e=this.tryParseDecimalInteger(13,14);if(e.err)return e;this.bumpSpace(),o=this.parseIdentifierIfPossible(),s=e.val}let c=this.tryParsePluralOrSelectOptions(e,a,t,o);if(c.err)return c;let l=this.tryParseArgumentClose(r);if(l.err)return l;let u=us(r,this.clonePosition());return a===`select`?{val:{type:5,value:n,options:ms(c.val),location:u},err:null}:{val:{type:6,value:n,options:ms(c.val),offset:s,pluralType:a===`plural`?`cardinal`:`ordinal`,location:u},err:null}}default:return this.error(5,us(i,o))}}tryParseArgumentClose(e){return this.isEOF()||this.char()!==125?this.error(1,us(e,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let e=0,t=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let e=this.clonePosition();if(!this.bumpUntil(`'`))return this.error(11,us(e,this.clonePosition()));this.bump();break}case 123:e+=1,this.bump();break;case 125:if(e>0)--e;else return{val:this.message.slice(t.offset,this.offset()),err:null};break;default:this.bump();break}return{val:this.message.slice(t.offset,this.offset()),err:null}}parseNumberSkeletonFromString(e,t){let n=[];try{n=Fo(e)}catch{return this.error(7,t)}return{val:{type:0,tokens:n,location:t,parsedOptions:this.shouldParseSkeletons?Go(n):{}},err:null}}tryParsePluralOrSelectOptions(e,t,n,r){let i=!1,a=[],o=new Set,{value:s,location:c}=r;for(;;){if(s.length===0){let e=this.clonePosition();if(t!==`select`&&this.bumpIf(`=`)){let t=this.tryParseDecimalInteger(16,19);if(t.err)return t;c=us(e,this.clonePosition()),s=this.message.slice(e.offset,this.offset())}else break}if(o.has(s))return this.error(t===`select`?21:20,c);s===`other`&&(i=!0),this.bumpSpace();let r=this.clonePosition();if(!this.bumpIf(`{`))return this.error(t===`select`?17:18,us(this.clonePosition(),this.clonePosition()));let l=this.parseMessage(e+1,t,n);if(l.err)return l;let u=this.tryParseArgumentClose(r);if(u.err)return u;a.push([s,{value:l.val,location:us(r,this.clonePosition())}]),o.add(s),this.bumpSpace(),{value:s,location:c}=this.parseIdentifierIfPossible()}return a.length===0?this.error(t===`select`?15:16,us(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(22,us(this.clonePosition(),this.clonePosition())):{val:a,err:null}}tryParseDecimalInteger(e,t){let n=1,r=this.clonePosition();this.bumpIf(`+`)||this.bumpIf(`-`)&&(n=-1);let i=!1,a=0;for(;!this.isEOF();){let e=this.char();if(e>=48&&e<=57)i=!0,a=a*10+(e-48),this.bump();else break}let o=us(r,this.clonePosition());return i?(a*=n,Number.isSafeInteger(a)?{val:a,err:null}:this.error(t,o)):this.error(e,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){let e=this.position.offset;if(e>=this.message.length)throw Error(`out of bound`);let t=this.message.codePointAt(e);if(t===void 0)throw Error(`Offset ${e} is at invalid UTF-16 code unit boundary`);return t}error(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}}bump(){if(this.isEOF())return;let e=this.char();e===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}bumpIf(e){if(this.message.startsWith(e,this.offset())){for(let t=0;t<e.length;t++)this.bump();return!0}return!1}bumpUntil(e){let t=this.offset(),n=this.message.indexOf(e,t);return n>=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)}bumpTo(e){if(this.offset()>e)throw Error(`targetOffset ${e} must be greater than or equal to the current offset ${this.offset()}`);for(e=Math.min(e,this.message.length);;){let t=this.offset();if(t===e)break;if(t>e)throw Error(`targetOffset ${e} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&ws(this.char());)this.bump()}peek(){if(this.isEOF())return null;let e=this.char(),t=this.offset();return this.message.charCodeAt(t+(e>=65536?2:1))??null}};function xs(e){return e>=97&&e<=122||e>=65&&e<=90}function Ss(e){return xs(e)||e===47}function Cs(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function ws(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function Ts(e){e.forEach(e=>{if(delete e.location,Qo(e)||$o(e))for(let t in e.options)delete e.options[t].location,Ts(e.options[t].value);else Yo(e)&&ns(e.style)||(Xo(e)||Zo(e))&&rs(e.style)?delete e.style.location:ts(e)&&Ts(e.children)})}function Es(e,t={}){t={shouldParseSkeletons:!0,requiresOtherClause:!0,...t};let n=new bs(e,t).parse();if(n.err){let e=SyntaxError(Ko[n.err.kind]);throw e.location=n.err.location,e.originalMessage=n.err.message,e}return t?.captureLocation||Ts(n.val),n.val}var Ds=class extends Error{constructor(e,t,n){super(e),this.code=t,this.originalMessage=n}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},Os=class extends Ds{constructor(e,t,n,r){super(`Invalid values for "${e}": "${t}". Options are "${Object.keys(n).join(`", "`)}"`,`INVALID_VALUE`,r)}},ks=class extends Ds{constructor(e,t,n){super(`Value for "${e}" must be of type ${t}`,`INVALID_VALUE`,n)}},As=class extends Ds{constructor(e,t){super(`The intl string context variable "${e}" was not provided to the string "${t}"`,`MISSING_VALUE`,t)}};function js(e){return e.length<2?e:e.reduce((e,t)=>{let n=e[e.length-1];return!n||n.type!==0||t.type!==0?e.push(t):n.value+=t.value,e},[])}function Ms(e){return typeof e==`function`}function Ns(e,t,n,r,i,a,o){if(e.length===1&&qo(e[0]))return[{type:0,value:e[0].value}];let s=[];for(let c of e){if(qo(c)){s.push({type:0,value:c.value});continue}if(es(c)){typeof a==`number`&&s.push({type:0,value:n.getNumberFormat(t).format(a)});continue}let{value:e}=c;if(!(i&&e in i))throw new As(e,o);let l=i[e];if(Jo(c)){(!l||typeof l==`string`||typeof l==`number`||typeof l==`bigint`)&&(l=typeof l==`string`||typeof l==`number`||typeof l==`bigint`?String(l):``),s.push({type:typeof l==`string`?0:1,value:l});continue}if(Xo(c)){let e=typeof c.style==`string`?r.date[c.style]:rs(c.style)?c.style.parsedOptions:void 0;s.push({type:0,value:n.getDateTimeFormat(t,e).format(l)});continue}if(Zo(c)){let e=typeof c.style==`string`?r.time[c.style]:rs(c.style)?c.style.parsedOptions:r.time.medium;s.push({type:0,value:n.getDateTimeFormat(t,e).format(l)});continue}if(Yo(c)){let e=typeof c.style==`string`?r.number[c.style]:ns(c.style)?c.style.parsedOptions:void 0;if(e&&e.scale){let t=e.scale||1;if(typeof l==`bigint`){if(!Number.isInteger(t))throw TypeError(`Cannot apply fractional scale ${t} to bigint value. Scale must be an integer when formatting bigint.`);l*=BigInt(t)}else l*=t}s.push({type:0,value:n.getNumberFormat(t,e).format(l)});continue}if(ts(c)){let{children:e,value:l}=c,u=i[l];if(!Ms(u))throw new ks(l,`function`,o);let d=u(Ns(e,t,n,r,i,a).map(e=>e.value));Array.isArray(d)||(d=[d]),s.push(...d.map(e=>({type:typeof e==`string`?0:1,value:e})))}if(Qo(c)){let e=l,a=(Object.prototype.hasOwnProperty.call(c.options,e)?c.options[e]:void 0)||c.options.other;if(!a)throw new Os(c.value,l,Object.keys(c.options),o);s.push(...Ns(a.value,t,n,r,i));continue}if($o(c)){let e=`=${l}`,a=Object.prototype.hasOwnProperty.call(c.options,e)?c.options[e]:void 0;if(!a){if(!Intl.PluralRules)throw new Ds(`Intl.PluralRules is not available in this environment.
|
|
49
|
+
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
50
|
+
`,`MISSING_INTL_API`,o);let e=typeof l==`bigint`?Number(l):l,r=n.getPluralRules(t,{type:c.pluralType}).select(e-(c.offset||0));a=(Object.prototype.hasOwnProperty.call(c.options,r)?c.options[r]:void 0)||c.options.other}if(!a)throw new Os(c.value,l,Object.keys(c.options),o);let u=typeof l==`bigint`?Number(l):l;s.push(...Ns(a.value,t,n,r,i,u-(c.offset||0)));continue}}return js(s)}function Ps(e,t){return t?{...e,...t,...Object.keys(e).reduce((n,r)=>(n[r]={...e[r],...t[r]},n),{})}:e}function Fs(e,t){return t?Object.keys(e).reduce((n,r)=>(n[r]=Ps(e[r],t[r]),n),{...e}):e}function Is(e){return{create(){return{get(t){return e[t]},set(t,n){e[t]=n}}}}}function Ls(e={number:{},dateTime:{},pluralRules:{}}){return{getNumberFormat:bo((...e)=>new Intl.NumberFormat(...e),{cache:Is(e.number),strategy:jo.variadic}),getDateTimeFormat:bo((...e)=>new Intl.DateTimeFormat(...e),{cache:Is(e.dateTime),strategy:jo.variadic}),getPluralRules:bo((...e)=>new Intl.PluralRules(...e),{cache:Is(e.pluralRules),strategy:jo.variadic})}}var Rs=class e{constructor(t,n=e.defaultLocale,r,i){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=e=>{let t=this.formatToParts(e);if(t.length===1)return t[0].value;let n=t.reduce((e,t)=>(!e.length||t.type!==0||typeof e[e.length-1]!=`string`?e.push(t.value):e[e.length-1]+=t.value,e),[]);return n.length<=1?n[0]||``:n},this.formatToParts=e=>Ns(this.ast,this.locales,this.formatters,this.formats,e,void 0,this.message),this.resolvedOptions=()=>({locale:this.resolvedLocale?.toString()||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}),this.getAst=()=>this.ast,this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t==`string`){if(this.message=t,!e.__parse)throw TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");let{...n}=i||{};this.ast=e.__parse(t,{...n,locale:this.resolvedLocale})}else this.ast=t;if(!Array.isArray(this.ast))throw TypeError(`A message must be provided as a String or AST.`);this.formats=Fs(e.formats,r),this.formatters=i&&i.formatters||Ls(this.formatterCache)}static{this.memoizedDefaultLocale=null}static get defaultLocale(){return e.memoizedDefaultLocale||=new Intl.NumberFormat().resolvedOptions().locale,e.memoizedDefaultLocale}static{this.resolveLocale=e=>{if(Intl.Locale===void 0)return;let t=Intl.NumberFormat.supportedLocalesOf(e);return t.length>0?new Intl.Locale(t[0]):new Intl.Locale(typeof e==`string`?e:e[0])}}static{this.__parse=Es}static{this.formats={number:{integer:{maximumFractionDigits:0},currency:{style:`currency`},percent:{style:`percent`}},date:{short:{month:`numeric`,day:`numeric`,year:`2-digit`},medium:{month:`short`,day:`numeric`,year:`numeric`},long:{month:`long`,day:`numeric`,year:`numeric`},full:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`}},time:{short:{hour:`numeric`,minute:`numeric`},medium:{hour:`numeric`,minute:`numeric`,second:`numeric`},long:{hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`short`},full:{hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`short`}}}}},zs={"@astryx.pagination.label":{defaultMessage:`Pagination`,description:`Aria label for the pagination navigation region.`},"@astryx.pagination.previous":{defaultMessage:`Go to previous page`,description:`Aria label for the previous-page button.`},"@astryx.pagination.next":{defaultMessage:`Go to next page`,description:`Aria label for the next-page button.`},"@astryx.pagination.previousBy":{defaultMessage:`Go back {step, number} {step, plural, one {page} other {pages}}`,description:"Aria label for the previous button when it advances more than one page per click (the `step` prop > 1). `step` is the number of pages skipped."},"@astryx.pagination.nextBy":{defaultMessage:`Go forward {step, number} {step, plural, one {page} other {pages}}`,description:"Aria label for the next button when it advances more than one page per click (the `step` prop > 1). `step` is the number of pages skipped."},"@astryx.pagination.first":{defaultMessage:`Go to first page`,description:`Aria label for the first-page button (« double chevron) in the input pagination variant.`},"@astryx.pagination.last":{defaultMessage:`Go to last page`,description:`Aria label for the last-page button (» double chevron) in the input pagination variant.`},"@astryx.pagination.goToPage":{defaultMessage:`Go to page {page, number}`,description:"Aria label for an individual page-number button. `page` is 1-based."},"@astryx.pagination.goToPageInput":{defaultMessage:`Go to page`,description:`Aria label for the editable page/row number box in the input pagination variant. No number — the box holds the value itself.`},"@astryx.pagination.pageLabel":{defaultMessage:`Page`,description:`Visible label before the editable box in the input pagination variant. Example: "Page [ 1 ] / 10".`},"@astryx.pagination.ofTotalPages":{defaultMessage:`/ {total, number}`,description:`Visible total shown after the editable box in the input pagination variant. Example: the "/ 10" in "Page [ 1 ] / 10".`},"@astryx.pagination.pageIndicators":{defaultMessage:`Page indicators`,description:`Aria label for the dots-variant page-indicator group.`},"@astryx.pagination.itemsPerPage":{defaultMessage:`Items per page`,description:`Label for the page-size selector.`},"@astryx.pagination.count":{defaultMessage:`{from, number}–{to, number} of {total, number}`,description:`Visible range-of-total text on a pagination bar. Example: "1–20 of 347"; the en-dash is translator's choice.`},"@astryx.pagination.pageOfTotal":{defaultMessage:`Page {current, number} of {total, number}`,description:`Visible "Page X of Y" text on the compact pagination variant; also announced by screen readers. Keep short — sits in a compact toolbar.`},"@astryx.pagination.pageAnnounce":{defaultMessage:`Page {current, number}`,description:`Screen-reader announcement when a page changes and total is unknown.`},"@astryx.powersearch.editor.field":{defaultMessage:`Field`,description:`Noun form-label above the field-picker dropdown in the PowerSearch filter-builder popover (which data column to filter on). Not an action.`},"@astryx.powersearch.editor.operator":{defaultMessage:`Operator`,description:`Noun form-label above the operator dropdown in the PowerSearch filter-builder popover. Refers to a comparison verb ("is", "contains"), not a math or phone operator.`},"@astryx.powersearch.editor.addFilter":{defaultMessage:`+ Add filter`,description:`Button label inside a group in the PowerSearch filter-builder; adds another filter row (e.g. "Status = Active"). The leading "+ " is a plus-sign character.`},"@astryx.powersearch.editor.removeFilter":{defaultMessage:`Remove filter`,description:`Screen-reader-only label on the "×" icon button next to a filter row in the PowerSearch editor; removes that row. Imperative verb.`},"@astryx.powersearch.editor.groupOperator":{defaultMessage:`Group operator`,description:`Screen-reader-only label for the AND/OR toggle that combines sibling filters inside a filter group. Sighted users see just "AND" or "OR".`},"@astryx.powersearch.editor.group":{defaultMessage:`Group`,description:`Fallback noun label shown on a nested filter-group chip when no AND/OR combining operator has been chosen. Use the noun ("a cluster"), not the verb "to group".`},"@astryx.powersearch.editor.delete":{defaultMessage:`Delete`,description:`Button label inside the PowerSearch filter-editor popover; deletes the currently-edited filter row. Imperative verb form.`},"@astryx.powersearch.editor.cancel":{defaultMessage:`Cancel`,description:`Button label inside the PowerSearch filter-editor popover; closes the popover and discards pending edits. Imperative verb form.`},"@astryx.powersearch.editor.apply":{defaultMessage:`Apply`,description:`Primary button label inside the PowerSearch filter-editor popover; confirms the edited filter. Imperative verb; consumers may override to "Save".`},"@astryx.powersearch.valueEditor.value":{defaultMessage:`Value`,description:'Noun form-label above a single free-text/number input in the PowerSearch value editor (e.g. the "acme" in `Name contains acme`). Not a verb or "worth".'},"@astryx.powersearch.valueEditor.values":{defaultMessage:`Values`,description:"Plural noun form-label above a multi-value chip input in the PowerSearch value editor. Should match its singular counterpart `Value` in your language."},"@astryx.powersearch.valueEditor.time":{defaultMessage:`Time`,description:`Noun form-label above a time-of-day (HH:MM) picker in the PowerSearch value editor. Clock time, not duration or era.`},"@astryx.powersearch.valueEditor.date":{defaultMessage:`Date`,description:`Noun form-label above a calendar-date picker in the PowerSearch value editor. Calendar date, not romantic date or fruit.`},"@astryx.powersearch.valueEditor.relativeDate":{defaultMessage:`Relative date`,description:`Label for the relative-date selector (e.g. "Last 7 days") in the PowerSearch value editor.`},"@astryx.powersearch.valueEditor.startDate":{defaultMessage:`Start date`,description:"Noun form-label above the start-of-range date picker in the PowerSearch value editor. Pairs with `End date` — keep the two parallel in your language."},"@astryx.powersearch.valueEditor.endDate":{defaultMessage:`End date`,description:"Noun form-label above the end-of-range date picker in the PowerSearch value editor. Pairs with `Start date` — keep the two parallel."},"@astryx.powersearch.valueEditor.entities":{defaultMessage:`Entities`,description:`"Entities" is jargon — plural noun form-label above an entity picker (people, teams, projects). Prefer a natural collective like "items" if your language has no equivalent.`},"@astryx.powersearch.valueEditor.searchPlaceholder":{defaultMessage:`Search…`,description:"Placeholder inside the search input in the PowerSearch entity/typeahead picker. Imperative verb; trailing `…` is one character."},"@astryx.powersearch.valueEditor.enterValuePlaceholder":{defaultMessage:`Enter value…`,description:"Placeholder inside a free-text single-value input in the PowerSearch value editor. Imperative verb; trailing `…` is one character."},"@astryx.powersearch.valueEditor.addValuesPlaceholder":{defaultMessage:`Add values…`,description:"Placeholder inside a multi-value chip input where the user types items and presses Enter to add each as a chip. Imperative verb; trailing `…` is one character."},"@astryx.powersearch.valueEditor.enterNumberPlaceholder":{defaultMessage:`Enter number…`,description:"Placeholder inside a numeric input in the PowerSearch value editor. Imperative verb; trailing `…` is one character."},"@astryx.powersearch.valueEditor.selectValuesPlaceholder":{defaultMessage:`Select values…`,description:`Placeholder on a dropdown for choosing values from a fixed enum list in the PowerSearch value editor. Imperative verb (user selects, not types).`},"@astryx.powersearch.operator.contains":{defaultMessage:`contains`,description:"PowerSearch string operator, rendered inline as `<field> contains <value>` (e.g. `Name contains acme`). Lowercase verb form."},"@astryx.powersearch.operator.notContains":{defaultMessage:`does not contain`,description:"PowerSearch negated string operator. Example: `Name does not contain test`. Lowercase; pairs with `contains`."},"@astryx.powersearch.operator.startsWith":{defaultMessage:`starts with`,description:"PowerSearch string prefix operator. Example: `Email starts with admin@`. Lowercase."},"@astryx.powersearch.operator.notStartsWith":{defaultMessage:`does not start with`,description:"PowerSearch negated prefix operator. Example: `Email does not start with test`. Lowercase; pairs with `starts with`."},"@astryx.powersearch.operator.endsWith":{defaultMessage:`ends with`,description:"PowerSearch string suffix operator. Example: `Email ends with @meta.com`. Lowercase."},"@astryx.powersearch.operator.notEndsWith":{defaultMessage:`does not end with`,description:"PowerSearch negated suffix operator. Example: `Email does not end with @gmail.com`. Lowercase; pairs with `ends with`."},"@astryx.powersearch.operator.is":{defaultMessage:`is`,description:"PowerSearch equality operator for strings/enums. Example: `Status is Active`. Separate from `operator.equals` (numbers) — translations may diverge."},"@astryx.powersearch.operator.isNot":{defaultMessage:`is not`,description:"PowerSearch inequality operator for strings/enums. Example: `Status is not Draft`. Pairs with `is`; separate from `operator.notEquals`."},"@astryx.powersearch.operator.equals":{defaultMessage:`is`,description:'PowerSearch numeric equality operator. Example: `Age is 30`. Ships same English "is" as `operator.is` but is separate so numbers may diverge (e.g. "equals").'},"@astryx.powersearch.operator.notEquals":{defaultMessage:`is not`,description:"PowerSearch numeric inequality operator. Example: `Count is not 0`. Same divergence option as `operator.equals`."},"@astryx.powersearch.operator.greaterThan":{defaultMessage:`is greater than`,description:"PowerSearch numeric operator, strictly greater than. Example: `Age is greater than 18`. Lowercase."},"@astryx.powersearch.operator.lessThan":{defaultMessage:`is less than`,description:"PowerSearch numeric operator, strictly less than. Example: `Priority is less than 5`. Lowercase."},"@astryx.powersearch.operator.greaterThanOrEqual":{defaultMessage:`is greater than or equal to`,description:'PowerSearch numeric operator, ≥. Example: `Age is greater than or equal to 21`. A shorter form (e.g. "≥") is fine if idiomatic.'},"@astryx.powersearch.operator.lessThanOrEqual":{defaultMessage:`is less than or equal to`,description:"PowerSearch numeric operator, ≤. Example: `Priority is less than or equal to 3`. A shorter form is fine if idiomatic."},"@astryx.powersearch.operator.before":{defaultMessage:`is before`,description:"PowerSearch date operator, strictly earlier. Example: `Created is before 2024-01-01`. Temporal, not spatial."},"@astryx.powersearch.operator.after":{defaultMessage:`is after`,description:"PowerSearch date operator, strictly later. Example: `Updated is after 2024-06-01`. Temporal."},"@astryx.powersearch.operator.between":{defaultMessage:`is between`,description:"PowerSearch date operator, inclusive range. Example: `Created is between 2024-01-01 and 2024-06-30`. The `and <end>` portion is composed separately."},"@astryx.powersearch.operator.isTrue":{defaultMessage:`is true`,description:"PowerSearch boolean operator: matches truthy. Example: `Is admin is true`. Pairs with `is false`; field may be affirmative or a yes/no question."},"@astryx.powersearch.operator.isFalse":{defaultMessage:`is false`,description:"PowerSearch boolean operator: matches falsy. Example: `Is admin is false`. Pairs with `is true`."},"@astryx.powersearch.operator.isAnyOf":{defaultMessage:`is any of`,description:"PowerSearch list operator: value is in the set. Example: `Status is any of [Active, Paused, Draft]`. The value list is composed separately; pairs with `is none of`."},"@astryx.powersearch.operator.isNoneOf":{defaultMessage:`is none of`,description:"PowerSearch negated list operator: value not in the set. Example: `Status is none of [Archived, Deleted]`. Pairs with `is any of`."},"@astryx.powersearch.valueEditor.itemsCount":{defaultMessage:`{count, number} {count, plural, one {item} other {items}}`,description:"Overflow summary on a compact filter chip when the list of selected items is too long. Example: `3 items` or `1 item`."},"@astryx.powersearch.valueEditor.entitiesCount":{defaultMessage:`{count, number} {count, plural, one {entity} other {entities}}`,description:"Overflow summary on a compact filter chip when the list of selected entities is too long. Example: `5 entities` or `1 entity`. Pair with `itemsCount` translation."},"@astryx.powersearch.valueEditor.dateRange":{defaultMessage:`date range`,description:"Fallback lowercase noun rendered inline in a filter chip when a date-range value can't be formatted (e.g. `Created is between date range`). Keep lowercase."},"@astryx.powersearch.valueEditor.filtersCount":{defaultMessage:`{count, number} {count, plural, one {filter} other {filters}}`,description:"Summary inside a filter chip when the value is a nested set of filters. Example: `3 filters` or `1 filter`."},"@astryx.powersearch.resultCount":{defaultMessage:`{count, number} {count, plural, one {result} other {results}}`,description:"Live result-count text next to the PowerSearch input, announced to screen readers on change. Example: `12 results`, `1 result`; keep compact."},"@astryx.alertDialog.cancel":{defaultMessage:`Cancel`,description:`Button label on the secondary/dismiss button of an AlertDialog (modal confirmation). Imperative verb; consumers usually override with task-specific text.`},"@astryx.appShell.mobileNavigation":{defaultMessage:`Mobile navigation`,description:`Screen-reader-only accessible name for the mobile-only navigation region on small viewports. "Mobile" = phone/tablet (small screen), not "movable".`},"@astryx.appShell.skipToContent":{defaultMessage:`Skip to content`,description:`Text of the skip link — the first focusable element on the page, visible only while keyboard-focused. Activating it jumps focus past the navigation to the main content area. Imperative verb; keep short.`},"@astryx.avatar.nameWithStatus":{defaultMessage:`{name}, {status}`,description:`Screen-reader accessible name for an Avatar showing a status indicator; composes the person's name with the status label, e.g. "Jane Doe, Online". {name} = the avatar's name/alt text, {status} = the status dot's label. Adjust separator and order per locale.`},"@astryx.avatarGroup.label":{defaultMessage:`Avatars`,description:`Screen-reader-only fallback name for a horizontal cluster of user avatar images. Plural noun; consumers usually override with "Team members", "Attendees", etc.`},"@astryx.avatarGroup.keyboardHint":{defaultMessage:`Use arrow keys to move between avatars`,description:`Screen-reader-only instruction attached (via aria-describedby) to a group of interactive avatars that share a single Tab stop. Tells keyboard users the Left/Right arrow keys move focus between the avatars. Only announced when the group has interactive (link/button) avatars.`},"@astryx.avatarGroup.overflow":{defaultMessage:`{count, number} more`,description:'Accessible name for the "+N" overflow indicator at the end of an AvatarGroup — announces how many additional avatars are not shown. Example: `5 more`. The visible "+N" text is unaffected; this is the aria-label only.'},"@astryx.banner.dismiss":{defaultMessage:`Dismiss`,description:`"Dismiss" = close/hide this notification (not "reject a person"). Aria label AND tooltip on the small X button on a Banner.`},"@astryx.calendar.previousMonth":{defaultMessage:`Previous month`,description:"Screen-reader-only label on the left-arrow button in a Calendar's month header (navigates one month back). Pairs with `calendar.nextMonth`."},"@astryx.calendar.nextMonth":{defaultMessage:`Next month`,description:"Screen-reader-only label on the right-arrow button in a Calendar's month header (navigates one month forward). Pairs with `calendar.previousMonth`."},"@astryx.calendar.daySelected":{defaultMessage:`{date}, selected`,description:'Accessible name for the Calendar day button that is the current single-mode selection. `{date}` is the localized full date, e.g. "Thursday, January 15, 2026". The trailing state word tells screen-reader users the focused day is selected.'},"@astryx.calendar.dayRangeStart":{defaultMessage:`{date}, range start`,description:"Accessible name for the Calendar day button that begins the selected date range (or the first pick of an in-progress range). `{date}` is the localized full date."},"@astryx.calendar.dayRangeEnd":{defaultMessage:`{date}, range end`,description:"Accessible name for the Calendar day button that ends the selected date range. `{date}` is the localized full date. Pairs with `calendar.dayRangeStart`."},"@astryx.calendar.dayRangeStartAndEnd":{defaultMessage:`{date}, range start and range end`,description:"Accessible name for a Calendar day button that both begins and ends a completed one-day range. `{date}` is the localized full date."},"@astryx.calendar.dayInRange":{defaultMessage:`{date}, in range`,description:"Accessible name for a Calendar day button strictly inside the selected date range (not an endpoint). `{date}` is the localized full date."},"@astryx.calendar.rangeStartAnnounce":{defaultMessage:`Start date {date}. Select an end date.`,description:"Screen-reader announcement after the first pick of a Calendar range selection. `{date}` is the localized full date. Prompts the user that a second pick completes the range."},"@astryx.calendar.rangeCompleteAnnounce":{defaultMessage:`Selected range: {start} to {end}.`,description:"Screen-reader announcement after the second pick completes a Calendar range selection. `{start}` and `{end}` are localized full dates in chronological order."},"@astryx.carousel.label":{defaultMessage:`Carousel`,description:`Screen-reader-only fallback name for a horizontally-scrolling row of items. If "carousel" is unfamiliar in your locale, prefer the standard term (e.g. "slider").`},"@astryx.carousel.scrollLeft":{defaultMessage:`Scroll left`,description:"Screen-reader-only label on the left arrow button in a Carousel. Pairs with `carousel.scrollRight`; in RTL locales, coordinate the two so left/right match layout."},"@astryx.carousel.scrollRight":{defaultMessage:`Scroll right`,description:"Screen-reader-only label on the right arrow button in a Carousel. Pairs with `carousel.scrollLeft`; same RTL note."},"@astryx.carousel.slideLabel":{defaultMessage:`Slide {current, number} of {total, number}`,description:"Screen-reader accessible name for one slide in a Carousel, giving its position. `current` is the 1-based slide number; `total` is the slide count."},"@astryx.chat.status.sending":{defaultMessage:`Sending`,description:`Chat send-status caption under an outgoing message while it is being transmitted. Part of the set sending → sent → delivered → read (or failed) — keep tense/aspect consistent.`},"@astryx.chat.status.sent":{defaultMessage:`Sent`,description:`Chat send-status caption shown once the message reaches the server. Part of the set sending → **sent** → delivered → read (or failed) — keep tense consistent.`},"@astryx.chat.status.delivered":{defaultMessage:`Delivered`,description:`Chat send-status caption shown once the recipient's device received the message. Part of the set sending → sent → **delivered** → read (or failed).`},"@astryx.chat.status.read":{defaultMessage:`Read`,description:`Chat send-status caption shown once the recipient opened the message. English past-participle ("has been read", /rɛd/), not the present verb — part of the set sending → sent → delivered → **read**.`},"@astryx.chat.status.failed":{defaultMessage:`Failed`,description:`Chat send-status caption shown when the send attempt errored. Part of the set — the terminal failure branch, orthogonal to the sent → delivered → read success track.`},"@astryx.chat.messageAriaLabel":{defaultMessage:`Message {status}`,description:"Screen-reader-only accessible name for a chat message row. `{status}` interpolates the localized status word (e.g. `Message sent`, `Message delivered`) — reorder if needed."},"@astryx.chat.pastedText.expand":{defaultMessage:`Expand`,description:`Button label on a chip in the chat composer representing a long pasted text block; clicking reveals full content. "Expand" here means reveal more, not grow physically.`},"@astryx.checkboxList.item.checkbox":{defaultMessage:`Checkbox`,description:`Screen-reader-only last-ditch fallback name for a checkbox inside a list item when no label is provided. Should almost never render — consumers should supply a real label.`},"@astryx.commandPalette.emptySearch":{defaultMessage:`No results`,description:`Fallback empty-state text inside a CommandPalette when the user's query has no matches. Very short (2 words); neutral tone.`},"@astryx.commandPalette.emptyBootstrap":{defaultMessage:`Type to search`,description:`Onboarding empty-state text shown inside a CommandPalette on first open, before the user has typed anything. Imperative sentence fragment.`},"@astryx.commandPalette.resultCount":{defaultMessage:`{count, number} {count, plural, one {result} other {results}}`,description:"Screen-reader-only announcement of how many commands match the CommandPalette query as the user types. Example: `12 results`, `1 result`; keep compact."},"@astryx.commandPalette.noResultsFor":{defaultMessage:`No results for {query}`,description:"Screen-reader-only announcement when a CommandPalette query matches nothing. `{query}` is the user's verbatim search text; keep it last if your language allows so truncation-by-AT still conveys the outcome."},"@astryx.commandPalette.loading":{defaultMessage:`Loading`,description:`Screen-reader-only announcement that a CommandPalette search has started and results are being fetched. Present-progressive form; matches the visible spinner.`},"@astryx.dateRangeInput.presetDateRanges":{defaultMessage:`Preset date ranges`,description:`Screen-reader-only accessible name for the sidebar of quick-pick preset ranges inside a DateRangeInput popover (e.g. "Last 7 days", "This month").`},"@astryx.dateTimeInput.timePlaceholder":{defaultMessage:`Select a time`,description:`Grey placeholder inside the empty time-of-day slot in a DateTimeInput. "Time" = clock time (HH:MM), not duration.`},"@astryx.dialog.close":{defaultMessage:`Close`,description:`"Close" = shut/dismiss the dialog, not "nearby" (English homograph). Aria label AND tooltip on the X at the top-right of a Dialog.`},"@astryx.dropdownMenu.label":{defaultMessage:`Menu`,description:`Screen-reader-only fallback name for a dropdown menu popover. Very generic; consumers usually override. Noun ("a menu"), not the imperative.`},"@astryx.lightbox.close":{defaultMessage:`Close`,description:`"Close" = shut/dismiss (not "nearby"). Screen-reader-only label on the X button that dismisses a Lightbox.`},"@astryx.lightbox.previous":{defaultMessage:`Previous`,description:"Screen-reader-only label on the left-arrow button in a Lightbox (navigates to previous media item). Pairs with `lightbox.next`."},"@astryx.lightbox.next":{defaultMessage:`Next`,description:"Screen-reader-only label on the right-arrow button in a Lightbox (navigates to next media item). Pairs with `lightbox.previous`."},"@astryx.markdown.taskList":{defaultMessage:`Task list`,description:"Screen-reader-only accessible name for a GitHub-flavored Markdown task list (rendered from `- [ ] item` / `- [x] done` syntax)."},"@astryx.markdown.table":{defaultMessage:`Table`,description:'Screen-reader-only accessible name for a table rendered inside a Markdown block. Noun ("a table"), not the verb. Separate from `@astryx.table.label` — translations may diverge.'},"@astryx.mobileNav.closeNavigation":{defaultMessage:`Close navigation`,description:"Screen-reader-only label on the X/close button that dismisses the MobileNav overlay. Pairs with `mobileNav.toggle.open`."},"@astryx.multiSelector.selectAll":{defaultMessage:`Select all`,description:`Label on the checkbox/toggle at the top of a MultiSelector dropdown that selects every option. "All" is a determiner here (as in "all the options"), not the pronoun.`},"@astryx.multiSelector.searchPlaceholder":{defaultMessage:`Search…`,description:"Placeholder inside the search input at the top of a MultiSelector's dropdown panel. Imperative verb; trailing `…` is one character."},"@astryx.multiSelector.searchOptions":{defaultMessage:`Search options`,description:`Screen-reader-only accessible name for that same search input inside a MultiSelector.`},"@astryx.multiSelector.selectAllPartiallySelected":{defaultMessage:`{label}, partially selected`,description:'Accessible name for the MultiSelector select-all option while only some options are selected. `{label}` is the visible select-all label (e.g. "Select all"). ARIA forbids aria-selected="mixed" on options, so the indeterminate state is conveyed through the name instead. "Partially" = some but not all.'},"@astryx.popover.close":{defaultMessage:`Close popover`,description:`"Close" = shut/dismiss, not "nearby". Screen-reader-only label on the close button inside a Popover.`},"@astryx.selector.searchPlaceholder":{defaultMessage:`Search…`,description:"Placeholder inside the search input at the top of a Selector's dropdown panel (for filtering options). Imperative verb; trailing `…` is one character."},"@astryx.selector.searchOptions":{defaultMessage:`Search options`,description:`"Options" = the list of choices in the dropdown. Screen-reader-only accessible name for the search input inside a Selector.`},"@astryx.sideNav.label":{defaultMessage:`Side navigation`,description:`Screen-reader-only accessible name for the primary vertical sidebar nav (usually on the left).`},"@astryx.sideNav.resizeSidebar":{defaultMessage:`Resize sidebar`,description:`Screen-reader-only label on the vertical drag handle at the right edge of the SideNav that lets the user resize the sidebar's width.`},"@astryx.sideNav.heading.openMenu":{defaultMessage:`Open menu`,description:"Screen-reader-only label on the `⋯` overflow-menu button embedded in a SideNav section heading. Same string as `topNav.heading.openMenu` — translations may share."},"@astryx.tabList.label":{defaultMessage:`Tabs`,description:`Screen-reader-only fallback name for a horizontal tab bar. Plural noun; "Tabs" here = UI tab panels, not browser tabs or the Tab key.`},"@astryx.table.label":{defaultMessage:`Table`,description:`Fallback screen-reader-only accessible name for a data-table region when the consumer provides none. Noun ("a table"), not the verb "to table".`},"@astryx.table.noData":{defaultMessage:`No data`,description:`Fallback empty-state text in the table body when there are zero rows. Neutral tone (not error-y); consumers commonly override with something specific like "No results".`},"@astryx.table.filter.allPlaceholder":{defaultMessage:`All`,description:`Placeholder on a per-column filter dropdown when nothing is selected, meaning "no filter — all rows match". Determiner form (as in "all values"), not the pronoun.`},"@astryx.table.filter.reset":{defaultMessage:`Reset`,description:`Button label inside a table's filter panel/popover; clears pending filter values back to defaults. Imperative verb.`},"@astryx.table.filter.apply":{defaultMessage:`Apply`,description:"Primary button label inside a table's filter panel/popover; commits pending filter values. Imperative verb; pairs with `Reset`."},"@astryx.table.selection.selectAllRows":{defaultMessage:`Select all rows`,description:`Aria label for the "select all rows" checkbox in a Table header.`},"@astryx.table.selection.selectRow":{defaultMessage:`Select row`,description:`Aria label for the "select row" checkbox on a Table row.`},"@astryx.table.selection.selectRowNamed":{defaultMessage:`Select {label}`,description:`Aria label for a Table row's selection checkbox when a per-row label is available (via getRowLabel). \`label\` is the row's human-readable identity, e.g. "Alice".`},"@astryx.table.sort.ascending":{defaultMessage:`Sort ascending`,description:"Screen-reader-only label on a column header button that will sort the column ascending. Part of a set with `sort.descending` and `sort.clear` — keep parallel."},"@astryx.table.sort.descending":{defaultMessage:`Sort descending`,description:"Screen-reader-only label on a column header button that will sort the column descending. Part of a set with `sort.ascending` and `sort.clear`."},"@astryx.table.sort.clear":{defaultMessage:`Clear sort`,description:`Screen-reader-only label on a column header button that will remove the current sort. "Clear" here means remove, not transparent. Part of the sort set.`},"@astryx.table.sort.direction.ascending":{defaultMessage:`ascending`,description:"Localized direction word interpolated as `direction` into @astryx.table.sort.sortedBy and @astryx.table.sort.sortedByWithPriority."},"@astryx.table.sort.direction.descending":{defaultMessage:`descending`,description:"Localized direction word interpolated as `direction` into @astryx.table.sort.sortedBy and @astryx.table.sort.sortedByWithPriority."},"@astryx.table.sort.sortBy":{defaultMessage:`Sort by {label}`,description:"Aria label for a sortable Table header button when the column is unsorted. `label` is the column header text."},"@astryx.table.sort.sortedBy":{defaultMessage:`Sort by {label}, sorted {direction}`,description:"Aria label for a sorted Table header button. `direction` is the localized direction word from @astryx.table.sort.direction.*."},"@astryx.table.sort.sortedByWithPriority":{defaultMessage:`Sort by {label}, sorted {direction}, priority {rank, number} of {total, number}`,description:"Aria label for a sorted Table header button in multi-sort. `rank` is the 1-based position of this column in the sort order; `total` is the number of sorted columns."},"@astryx.toast.dismiss":{defaultMessage:`Dismiss notification`,description:"Screen-reader-only label on the X button of a Toast (transient notification popup). Distinct from `banner.dismiss` (persistent banner)."},"@astryx.toast.viewport":{defaultMessage:`Notifications`,description:`Screen-reader-only accessible name for the invisible landmark region hosting the stack of Toast popups (usually pinned to a screen corner).`},"@astryx.tokenizer.clearAll":{defaultMessage:`Clear all`,description:`Label on the "×" button that removes every token/chip from a Tokenizer input. Imperative verb + determiner "all"; short.`},"@astryx.topNav.heading.openMenu":{defaultMessage:`Open menu`,description:"Screen-reader-only label on the `⋯` overflow button in a TopNav section heading. Kept separate from `sideNav.heading.openMenu` so translations may diverge."},"@astryx.topNav.landmarkLabel":{defaultMessage:`Top navigation`,description:`Default accessible name (aria-label) for the <nav> landmark rendered by TopNav when no label is provided.`},"@astryx.treeList.toggleChildren":{defaultMessage:`Toggle children`,description:`"Children" = child nodes in the tree, not human children. Screen-reader-only label on the chevron next to a TreeList item that has children — toggles the sub-list.`},"@astryx.typeahead.emptySearchResults":{defaultMessage:`No results found`,description:`Fallback empty-state message inside a Typeahead's suggestion popover when the current query has no matches. Neutral tone (not error-y).`},"@astryx.typeahead.loading":{defaultMessage:`Loading`,description:`Screen-reader-only name for a spinner shown inside a Typeahead dropdown while suggestions are being fetched. Present-progressive form.`},"@astryx.typeahead.searchResults":{defaultMessage:`Search results`,description:`Screen-reader-only accessible name for the list of suggestions inside a Typeahead dropdown.`},"@astryx.typeahead.clearSelection":{defaultMessage:`Clear selection`,description:`"Selection" = the chosen value (not highlighted text). Screen-reader-only label on the X that clears the currently-selected value from a Typeahead.`},"@astryx.breadcrumbs.label":{defaultMessage:`Breadcrumb`,description:"Screen-reader-only fallback name for the breadcrumb trail (e.g. `Home > Section > Page`). Singular in English per ARIA convention; plural is fine if natural in your locale."},"@astryx.chat.composer.placeholder":{defaultMessage:`Type a message…`,description:"Grey placeholder text inside the empty chat composer textarea. Imperative verb; trailing `…` is one character."},"@astryx.chat.composerDrawer.label":{defaultMessage:`Items`,description:`Fallback aria label for the ChatComposerDrawer — a horizontal list of attachment/tool chips. Consumers usually override with "Attachments", "Tools", etc.`},"@astryx.chat.composerInput.label":{defaultMessage:`Message input`,description:`Screen-reader-only accessible name for the chat composer textarea. Reorder freely if your language uses one word for "message field".`},"@astryx.chat.speechRecognition.noSpeechDetected":{defaultMessage:`No speech was detected.`,description:`Full-sentence error shown inline in the chat composer after voice input captured silence. Soft-error tone (not alarming); keep terminal period.`},"@astryx.commandPalette.label":{defaultMessage:`Command palette`,description:`Screen-reader-only fallback name for a keyboard-driven command menu (usually opened with Cmd/Ctrl-K). If unfamiliar, prefer a natural equivalent like "quick actions".`},"@astryx.commandPalette.input.placeholder":{defaultMessage:`Search…`,description:"Grey placeholder inside the CommandPalette's search input. Imperative verb; trailing `…` is one character."},"@astryx.commandPalette.list.label":{defaultMessage:`Commands`,description:`"Command" = an app action a user can invoke (metaphor from CLI), not a Unix command. Screen-reader-only name for the matching-commands list.`},"@astryx.contextMenu.label":{defaultMessage:`Context menu`,description:`Screen-reader-only fallback name for the right-click / long-press popup menu. "Context" = context-specific to the activated element, not linguistic context.`},"@astryx.dateInput.placeholder":{defaultMessage:`Select a date`,description:`Grey placeholder inside an empty DateInput field. "Date" = calendar date, not romantic or fruit. Imperative verb.`},"@astryx.dateInput.dialogLabel":{defaultMessage:`Choose date`,description:`Screen-reader-only accessible name for the popover dialog opened from a DateInput's calendar toggle. Imperative verb + noun.`},"@astryx.dateInput.closeCalendar":{defaultMessage:`Close calendar`,description:"Screen-reader-only label on the X inside the DateInput calendar popover (dismisses the popover). Distinct from `dateInput.toggleCalendarClose`, which labels the outer toggle."},"@astryx.dateInput.openCalendar":{defaultMessage:`Open calendar`,description:`Aria label for the DateInput / DateRangeInput / DateTimeInput calendar toggle button when the popover is closed.`},"@astryx.dateInput.toggleCalendarClose":{defaultMessage:`Close calendar`,description:`Aria label for the DateInput / DateRangeInput / DateTimeInput calendar toggle button when the popover is open. Distinct from closeCalendar (which labels the X inside the popover) so translators can differentiate the toggle vs the close-X UI.`},"@astryx.dateInput.clear":{defaultMessage:`Clear {label}`,description:"Aria label for the clear-value button in DateInput / DateRangeInput / DateTimeInput. `{label}` is the field's own label so screen readers announce e.g. 'Clear Start date'."},"@astryx.dateTimeInput.timeSuffix":{defaultMessage:`{label} time`,description:'Screen-reader-only accessible name for the time-of-day slot in a DateTimeInput. Example: `Start date time`; reorder freely (e.g. "time of {label}").'},"@astryx.dateRangeInput.placeholder":{defaultMessage:`Select date range`,description:`Grey placeholder inside an empty DateRangeInput field. Represents picking a start–end date pair. Imperative verb.`},"@astryx.dateRangeInput.dialogLabel":{defaultMessage:`Choose date range`,description:`Screen-reader-only accessible name for the popover dialog opened from a DateRangeInput. Imperative verb + noun phrase.`},"@astryx.dateTimeInput.placeholder":{defaultMessage:`Select a date`,description:`Grey placeholder inside an empty DateTimeInput field. Note: the English says only "date" though the field is date+time — do not add "and time" unless natural.`},"@astryx.dateTimeInput.dialogLabel":{defaultMessage:`Choose date`,description:`Screen-reader-only accessible name for the DateTimeInput picker dialog. Same English-only "date" phrasing as the placeholder — don't add "and time" unless natural.`},"@astryx.link.newTab":{defaultMessage:`(opens in new tab)`,description:"Visually-hidden (screen-reader-only) suffix appended to a Link's accessible name when it opens in a new tab. Example: `Documentation (opens in new tab)`."},"@astryx.mobileNav.toggle.open":{defaultMessage:`Open navigation`,description:"Screen-reader-only label on the hamburger button that opens the MobileNav overlay (rendered when the overlay is closed). Pairs with `mobileNav.closeNavigation`."},"@astryx.moreMenu.label":{defaultMessage:`More options`,description:"Screen-reader-only name for the small `⋯` (three-dots) overflow button that opens a menu of additional actions. Very short — sits on a tiny icon button."},"@astryx.multiSelector.selectPlaceholder":{defaultMessage:`Select…`,description:'Placeholder on an empty MultiSelector trigger button. Same English as `selector.placeholder` but a separate key — plural phrasing like "Choose items…" is fine.'},"@astryx.outline.label":{defaultMessage:`Table of contents`,description:"Screen-reader-only fallback name for a page's outline / table-of-contents sidebar (list of in-page headings). Rendered as `aria-label` on a `<nav>` landmark."},"@astryx.powersearch.label":{defaultMessage:`Search`,description:`Screen-reader-only accessible name for the PowerSearch input (a filter-builder). The visible placeholder is separate; noun form often reads better than the verb.`},"@astryx.powersearch.placeholder":{defaultMessage:`Search…`,description:"Grey placeholder text inside the empty PowerSearch input. Imperative verb; trailing `…` is one character."},"@astryx.resizable.collapsed":{defaultMessage:`Collapsed`,description:`aria-valuetext for the Resizable drag handle (role=separator) while its panel is collapsed to zero size. Replaces the numeric value announcement, since the numeric value is clamped to the minimum while collapsed. Adjective describing the panel state, not a verb/command.`},"@astryx.resizable.handle.label":{defaultMessage:`Resize handle`,description:`Screen-reader-only accessible name for the small draggable divider between two Resizable panels (users drag it to change the split ratio).`},"@astryx.selector.placeholder":{defaultMessage:`Select…`,description:"Placeholder text on an empty Selector trigger button (a dropdown). Imperative verb; trailing `…` is one character. Very short — appears on the button face."},"@astryx.sideNav.heading.dialogLabel":{defaultMessage:`Navigation menu`,description:`Screen-reader-only accessible name for the dropdown dialog opened from a SideNavHeading's overflow menu.`},"@astryx.table.pagination.label":{defaultMessage:`Table pagination`,description:"Screen-reader-only accessible name for the pagination `<nav>` appended below a data table. Kept separate from `@astryx.pagination.label` so translations may diverge."},"@astryx.timeInput.placeholder":{defaultMessage:`Select a time`,description:`"Time" = clock time (HH:MM), not duration or era. Grey placeholder inside an empty TimeInput field; imperative verb.`},"@astryx.topNav.heading.dialogLabel":{defaultMessage:`Navigation menu`,description:`Screen-reader-only accessible name for the dropdown dialog opened from a TopNavHeading's overflow menu. Kept separate from the SideNav sibling.`},"@astryx.typeahead.searchPlaceholder":{defaultMessage:`Search…`,description:"Placeholder inside an empty Typeahead input (a search field that suggests results as the user types). Imperative verb; trailing `…` is one character."},"@astryx.banner.collapse":{defaultMessage:`Collapse`,description:'"Collapse" = fold up, not crumble. Aria label AND tooltip on the Banner expand/collapse toggle when currently expanded. Pairs with `banner.expand`.'},"@astryx.banner.expand":{defaultMessage:`Expand`,description:'"Expand" = reveal more, not grow physically. Aria label AND tooltip on the same toggle when currently collapsed. Pairs with `banner.collapse`.'},"@astryx.button.loading":{defaultMessage:`Loading`,description:'Screen-reader-only live-region announcement while a Button is in its loading state (spinner shown, action in flight). Progressive sense ("work in progress"), not a noun. Kept separate from `typeahead.loading` — translations may diverge.'},"@astryx.chatComposerDrawer.expand":{defaultMessage:`Expand {label}`,description:"Screen-reader-only label on the ChatComposerDrawer toggle when the drawer is collapsed. `{label}` is the drawer's visible name — example: `Expand Attachments`. Pairs with `collapse`."},"@astryx.chatComposerDrawer.collapse":{defaultMessage:`Collapse {label}`,description:"Screen-reader-only label on the ChatComposerDrawer toggle when the drawer is expanded. Example: `Collapse Attachments`. Pairs with `expand`."},"@astryx.chatDictationButton.startDictation":{defaultMessage:`Start dictation`,description:`Accessible label for the microphone button when idle (not listening).`},"@astryx.chatDictationButton.stopDictation":{defaultMessage:`Stop dictation`,description:`Accessible label for the microphone button when actively listening.`},"@astryx.chatLayout.newMessages":{defaultMessage:`New messages`,description:`Text on a floating pill at the bottom of a chat viewport when unseen messages arrive below the fold; clicking scrolls to bottom. Keep short — narrow pill.`},"@astryx.chatLayoutScrollButton.scrollToBottom":{defaultMessage:`Scroll to bottom`,description:`Visible tooltip AND screen-reader label for a small down-arrow button that scrolls the chat viewport to its latest message.`},"@astryx.chatMessage.messageFrom":{defaultMessage:`Message from {sender}`,description:"Screen-reader-only accessible name for a chat message when the sender name isn't visible. Example: `Message from Sarah`, `Message from Bot` — reorder freely."},"@astryx.chatSendButton.stop":{defaultMessage:`Stop`,description:"Button label that replaces `Send` on the chat send button while an AI response is streaming; clicking aborts generation. Short — appears on a small button."},"@astryx.chatSendButton.send":{defaultMessage:`Send`,description:"Primary button label on the chat submit button (paperplane icon). Imperative verb; pairs with `Stop`. Very short."},"@astryx.chatToolCalls.error":{defaultMessage:`Error: {message}`,description:`Screen-reader text for a tool call that failed. {message} is the error detail.`},"@astryx.chatToolCalls.groupLabel":{defaultMessage:`{count} tool calls`,description:`Summary label shown in the group header when multiple tool calls are expanded. {count} is the number of calls.`},"@astryx.chatTriggerMenu.suggestions":{defaultMessage:`Suggestions`,description:"Screen-reader-only fallback label for the popover listbox opened by a trigger character (`@`, `/`) in the chat composer when the trigger provides no specific label."},"@astryx.citation.label":{defaultMessage:`Citation {number}: {title}`,description:"Screen-reader-only accessible name for a Citation chip (a small numbered link to a source). Example: `Citation 1: OpenAI research paper`. Reorder freely."},"@astryx.codeBlock.copied":{defaultMessage:`Copied`,description:'Screen-reader-only label on the CodeBlock copy button for ~2s after a successful copy. Past-participle ("has been copied"); pairs with `codeBlock.copyCode`.'},"@astryx.codeBlock.copyCode":{defaultMessage:`Copy code`,description:'"Code" = source code. Aria label AND tooltip on the CodeBlock copy button in its default state. Pairs with `codeBlock.copied` (post-click state).'},"@astryx.codeBlock.code":{defaultMessage:`Code`,description:`Screen-reader-only fallback name for a code-snippet scroll container when the code's language is unknown. "Code" = source code, not secret code or code of conduct.`},"@astryx.field.optional":{defaultMessage:`Optional`,description:`Visible indicator shown next to a form field's label when the field is optional (isOptional). Mutually exclusive with the required indicator. Very short — appears inline after the label text.`},"@astryx.field.required":{defaultMessage:`Required`,description:`Visible indicator shown next to a form field's label when the field must be filled in (isRequired). Mutually exclusive with the optional indicator. Very short — appears inline after the label text.`},"@astryx.fileInput.clearLabel":{defaultMessage:`Clear {label}`,description:"Screen-reader-only label on the X that removes the selected file from a FileInput. Example: `Clear Attachment`, `Clear Résumé`."},"@astryx.fileInput.required":{defaultMessage:`Required`,description:'Screen-reader-only description on the FileInput trigger indicating the field must be filled in. Mirrors the visible `Required` indicator next to the field label; conveyed via description because aria-required is not supported on role="button".'},"@astryx.fileInput.triggerWithFiles":{defaultMessage:`{label}, {fileNames}`,description:"Accessible name for a FileInput trigger that has files attached, composing the field label with the selected filenames. Example: `Attachments, report.pdf, notes.txt`."},"@astryx.keyboardHint.toNavigate":{defaultMessage:`to navigate`,description:"Trailing text in the keyboard-hint badge, shown after arrow-key icons — reads as `← → to navigate`. Lowercase sentence fragment completing the visual phrase; the badge is aria-hidden, so this is for sighted users only."},"@astryx.lightbox.mediaViewer":{defaultMessage:`Media viewer`,description:`Screen-reader-only fallback name for the Lightbox dialog when the current media item has no alt text. Should rarely render — consumers should provide alt.`},"@astryx.lightbox.zoom":{defaultMessage:`Zoom`,description:`Screen-reader-only label on the Lightbox image acting as a zoom toggle button (aria-pressed reflects zoomed state). Verb ("to zoom"), very short.`},"@astryx.lightbox.zoomedIn":{defaultMessage:`Zoomed in, use arrow keys to pan`,description:"Polite screen-reader announcement after zooming into a Lightbox image, including a hint that arrow keys pan while zoomed. Pairs with `lightbox.zoomedOut`."},"@astryx.lightbox.zoomedOut":{defaultMessage:`Zoomed out`,description:"Polite screen-reader announcement after zooming back out of a Lightbox image. Pairs with `lightbox.zoomedIn`."},"@astryx.metadataList.showMore":{defaultMessage:`Show more`,description:"Button label under a MetadataList that reveals items hidden beyond the configured maximum. Toggles with `metadataList.showLess` — keep the pair parallel in your language."},"@astryx.metadataList.showLess":{defaultMessage:`Show less`,description:"Button label under a MetadataList that re-hides the extra items revealed by `metadataList.showMore`. Keep the pair parallel."},"@astryx.mobileNav.navigation":{defaultMessage:`Navigation`,description:`Screen-reader-only fallback name for the MobileNav overlay dialog when no explicit label was passed.`},"@astryx.multiSelector.clearAll":{defaultMessage:`Clear all {label}`,description:"Screen-reader-only label on the X that clears every selected value from a MultiSelector. Example: `Clear all Countries`. `{label}` is typically already plural in English."},"@astryx.input.statusButton.error":{defaultMessage:`Error details`,description:`Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is error. Activating or focusing the button reveals the error message in a tooltip. Keep it short — it labels an icon-only button.`},"@astryx.input.statusButton.warning":{defaultMessage:`Warning details`,description:`Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is warning. Activating or focusing the button reveals the warning message in a tooltip.`},"@astryx.input.statusButton.success":{defaultMessage:`Success details`,description:`Accessible name for the focusable status icon button inside an input when statusVariant is 'tooltip' and the status type is success. Activating or focusing the button reveals the success message in a tooltip.`},"@astryx.numberInput.clearLabel":{defaultMessage:`Clear {label}`,description:"Screen-reader-only label on the X that clears the value from a NumberInput. Example: `Clear Age`, `Clear Quantity`."},"@astryx.numberInput.decrementLabel":{defaultMessage:`Decrement {label}`,description:"Accessible label for the NumberInput button that decreases the value by one configured step. Example: `Decrement Quantity`."},"@astryx.numberInput.incrementLabel":{defaultMessage:`Increment {label}`,description:"Accessible label for the NumberInput button that increases the value by one configured step. Example: `Increment Quantity`."},"@astryx.selector.clearLabel":{defaultMessage:`Clear {label}`,description:"Screen-reader-only label on the X that clears the selected value from a Selector. `{label}` is the selector's visible label — example: `Clear Country`."},"@astryx.sideNavCollapseButton.expandSidebar":{defaultMessage:`Expand sidebar`,description:"Aria label AND tooltip on the SideNav collapse/expand toggle when the sidebar is currently collapsed (clicking expands it). Pairs with `collapseSidebar`."},"@astryx.sideNavCollapseButton.collapseSidebar":{defaultMessage:`Collapse sidebar`,description:"Aria label AND tooltip on the same toggle when the sidebar is currently expanded (clicking collapses it). Pairs with `expandSidebar`."},"@astryx.sideNavItem.expand":{defaultMessage:`Expand {label}`,description:"Screen-reader-only label on the chevron next to a SideNav item with children when the group is collapsed. Example: `Expand Settings`. Pairs with `sideNavItem.collapse`."},"@astryx.sideNavItem.collapse":{defaultMessage:`Collapse {label}`,description:"Screen-reader-only label on the same chevron when the group is expanded. Example: `Collapse Settings`. Pairs with `sideNavItem.expand`."},"@astryx.tableFiltering.filterByColumn":{defaultMessage:`Filter {header}`,description:"Triple-use string on per-column filter controls: visible label, placeholder, AND aria label. `{header}` is the column header — example: `Filter Name`. Keep short."},"@astryx.tableGroupedRows.expandGroup":{defaultMessage:`Expand group {groupKey}`,description:"Screen-reader-only label on the chevron next to a grouped table's group header when collapsed. Example: `Expand group Q1 2024`. Pairs with `collapseGroup`."},"@astryx.tableGroupedRows.collapseGroup":{defaultMessage:`Collapse group {groupKey}`,description:"Screen-reader-only label on the same chevron when the group is expanded. Example: `Collapse group Q1 2024`. Pairs with `expandGroup`."},"@astryx.tableRowExpansion.collapseRow":{defaultMessage:`Collapse row`,description:`Screen-reader-only label on the row-expand chevron when the row is currently expanded. Part of the four-way expand/collapse set.`},"@astryx.tableRowExpansion.expandRow":{defaultMessage:`Expand row`,description:"Screen-reader-only label on the row-expand chevron when the row is currently collapsed. Part of a four-way set with `collapseRow`, `expandAllRows`, `collapseAllRows`."},"@astryx.tableRowExpansion.collapseAllRows":{defaultMessage:`Collapse all rows`,description:`Screen-reader-only label on the same header button when every row is expanded. Part of the four-way set.`},"@astryx.tableRowExpansion.expandAllRows":{defaultMessage:`Expand all rows`,description:`Screen-reader-only label on the header expand-all/collapse-all button when at least one row is collapsed (clicking expands every expandable row). Part of the four-way set.`},"@astryx.step.goToStep":{defaultMessage:`Go to step {stepNumber, number}: {label}`,description:`Accessible name for a clickable step in the lab Stepper. {stepNumber} is the 1-based position, {label} is the step's visible label.`},"@astryx.step.goToStepWithStatus":{defaultMessage:`Go to step {stepNumber, number}: {label}, {status}`,description:"Accessible name for a clickable lab Stepper step that also carries a status. {status} is one of the translated `step.status.*` words (completed/warning/error). Keep the pattern parallel to `step.goToStep`."},"@astryx.step.optional":{defaultMessage:`Optional`,description:`Visible indicator appended after a lab Stepper step's label when the step is optional (isOptional). Very short; appears inline after the label text.`},"@astryx.step.status.completed":{defaultMessage:`completed`,description:`Screen-reader-only status word rendered next to a lab Stepper step label when the step is done (either progress-completed or status=success). Lowercase adjective; it is read mid-sentence after the step label.`},"@astryx.step.status.warning":{defaultMessage:`warning`,description:`Screen-reader-only status word rendered next to a lab Stepper step label when status=warning. Lowercase noun/adjective; read mid-sentence after the step label.`},"@astryx.step.status.error":{defaultMessage:`error`,description:`Screen-reader-only status word rendered next to a lab Stepper step label when status=error. Lowercase noun; read mid-sentence after the step label.`},"@astryx.tableTree.collapseRow":{defaultMessage:`Collapse row`,description:`Aria label for the Table tree-data expander chevron when the row is currently expanded.`},"@astryx.tableTree.expandRow":{defaultMessage:`Expand row`,description:`Aria label for the Table tree-data expander chevron when the row is currently collapsed.`},"@astryx.tableTree.collapseAllRows":{defaultMessage:`Collapse all rows`,description:`Aria label for the Table tree-data header toggle when all rows are expanded and clicking it collapses them.`},"@astryx.tableTree.expandAllRows":{defaultMessage:`Expand all rows`,description:`Aria label for the Table tree-data header toggle when rows are collapsed and clicking it expands them.`},"@astryx.textArea.charactersRemaining":{defaultMessage:`{count, number} {count, plural, one {character} other {characters}} remaining`,description:"Screen-reader-only announcement of how many characters the user can still type before hitting a TextArea's maxLength. Announced politely as the count nears the limit. `{count}` is the number remaining — example: `12 characters remaining`."},"@astryx.textArea.charactersOverLimit":{defaultMessage:`{count, number} {count, plural, one {character} other {characters}} over the limit`,description:"Screen-reader-only assertive announcement when the user has typed past a TextArea's maxLength. `{count}` is how many characters over — example: `3 characters over the limit`."},"@astryx.textInput.clearLabel":{defaultMessage:`Clear {label}`,description:"Screen-reader-only label on the X that clears the value from a TextInput. Example: `Clear Email`, `Clear Name`."},"@astryx.thumbnail.remove":{defaultMessage:`Remove {accessibleName}`,description:'Screen-reader-only label on the "×" on a Thumbnail (image preview chip). `{accessibleName}` is the thumbnail\'s name — example: `Remove profile.jpg`.'},"@astryx.thumbnail.open":{defaultMessage:`Open {accessibleName}`,description:'"Open" = launch/reveal (not "unfold" or the adjective). Screen-reader-only name on a clickable Thumbnail — example: `Open Sunset photo`.'},"@astryx.thumbnail.fallbackName":{defaultMessage:`Thumbnail`,description:"Generic screen-reader name for a Thumbnail (image preview) that has no `alt` or `label`. Last-resort fallback so the control is never nameless; prefer a real name via `alt` or `label`."},"@astryx.timeInput.clearLabel":{defaultMessage:`Clear {label}`,description:"Screen-reader-only label on the X that clears the value from a TimeInput. Example: `Clear Start time`."},"@astryx.timestamp.copyValue":{defaultMessage:`Copy {value}`,description:"Aria label on a Timestamp copyable-hover-card row's copy button, in its default state. `value` is the formatted instant that row shows (e.g. `Copy February 19, 2026 at 5:00:00 PM UTC`). Imperative verb. Pairs with `timestamp.copied` (post-click state)."},"@astryx.timestamp.copy":{defaultMessage:`Copy`,description:"Short label shown in the tooltip on a Timestamp copyable-hover-card row's copy button (hover/focus), in its default state. Imperative verb. Pairs with `timestamp.copied` (post-click state). The full `copyValue` string remains the button's aria-label for assistive tech."},"@astryx.timestamp.copied":{defaultMessage:`Copied`,description:'Aria label on a Timestamp copy button for ~1.5s after a successful copy, and the text announced to a polite live region. Past-participle ("has been copied"); pairs with `timestamp.copyValue`.'},"@astryx.timestamp.detailsLabel":{defaultMessage:`Timestamp details`,description:`Accessible name for the Timestamp copyable hover card popup, which lists the instant in the configured time zones/formats with a copy button per row.`},"@astryx.token.remove":{defaultMessage:`Remove {label}`,description:'Screen-reader-only label on the "×" on an individual Token/chip. Example: `Remove John Smith`, `Remove Active`. Imperative verb.'}},Bs=new Map;function Vs(e,t){let n=`${t}::${e}`,r=Bs.get(n);return r===void 0&&(r=new Rs(e,t),Bs.set(n,r)),r}function Hs(e){let t;try{t=new Intl.Locale(e).baseName}catch{t=e}let n=t.split(`-`),r=[];for(let e=n.length;e>0;e--)r.push(n.slice(0,e).join(`-`));return r}function Us(e,t,n,r){let i=Hs(t);if(r!==void 0)for(let t of i){let n=r[t]?.[e];if(n!==void 0)return n}for(let t of i){let r=n[t]?.[e];if(r!==void 0)return r.defaultMessage}let a=zs[e];return a===void 0?null:a.defaultMessage}function Ws(e,t,n,r,i){let a=Us(e,n,r,i);return a===null?(`${n}${e}`,`${e}${n}`,e):t===void 0?a:Vs(a,n).format(t)}function Gs(){let e=(0,v.use)(yo);return(0,v.useCallback)((t,n)=>Ws(t,n,e.locale,e.messages,e.overrides),[e.locale,e.messages,e.overrides])}var Ks={base:{"--button-focus-offset":`xkzo27j`,kInvED:`x1wfwxd8 x13aywxo`,kVAEAm:`x1n2onr6`,k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kOIVth:`x1txdalj`,k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kaIpWk:`x1jxw6zd`,kMv6JI:`xjb2p0i`,kGuDYH:`xcr08ib`,kLWn49:`x1kq96og`,k63SB2:`x1e4wzip`,khDVqt:`xuxw1ft`,kkrTdU:`x1ypdohk`,k1ekBW:`xrafxwg`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},pressable:{k3aq6I:`x3oybdh xk4oym4`,$$css:!0},disabled:{kkrTdU:`x1h6gzvc`,kSiTet:`xbyyjgo`,kKwaWg:`x18o3ruo`,k3aq6I:`x1c071of x1pdlv7q`,$$css:!0},ariaDisabled:{kKwaWg:`x18o3ruo x8o3jvd xuqm82a`,$$css:!0},iconOnly:{"--button-icon-only-aspect":`x1v15ycx`,kOBAk4:`xioom0i`,kg3NbH:`xnjsko4`,k8WAf4:`xt970qd`,$$css:!0},iconWrapper:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,$$css:!0},contentWrapper:{k1xSpc:`xjp7ctv`,$$css:!0},link:{kybGjl:`x1hl2dhg`,$$css:!0}},qs={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]},Js={sm:{kZKoxP:`x6k0iem`,$$css:!0},md:{kZKoxP:`x1ueg155`,$$css:!0},lg:{kZKoxP:`xssyfek`,$$css:!0}},Ys={sm:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,kGuDYH:`x1j61zf2`,$$css:!0},md:{kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,kGuDYH:`x1j61zf2`,$$css:!0},lg:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,kGuDYH:`xwsyq91`,$$css:!0}},Xs={none:{kGVxlE:`x1gnnqk1`,$$css:!0},low:{kGVxlE:`x1i5ehqx`,$$css:!0},med:{kGVxlE:`x14hfi27`,$$css:!0},high:{kGVxlE:`x1kcpxr7`,$$css:!0}},Zs={primary:{kWkggS:`x1ewilqj`,kMwMTN:`x17wrial`,kKwaWg:`x1ilzqfv xq8i9tn`,$$css:!0},secondary:{kWkggS:`x17x4s8c`,kMwMTN:`x1tgivj0`,kKwaWg:`x1ilzqfv xq8i9tn`,$$css:!0},ghost:{kWkggS:`xjbqb8w`,kMwMTN:`x1tgivj0`,kKwaWg:`x1ilzqfv xq8i9tn`,$$css:!0},destructive:{kWkggS:`x1pjz0fi`,kMwMTN:`x1m024r3`,kjBf7l:`x1e0x2sz`,kKwaWg:`x1ilzqfv xq8i9tn`,$$css:!0}};N[`--duration-medium-min`];var Qs={hiddenContent:{kMwMTN:`x19co3pv`,$$css:!0},hiddenContentDelayed:{kKVMdj:`x1ffowhz`,k44tkh:`xjlvqhv`,kWV6AL:`x10e4vud`,kKxzle:`x17yabm6 x14q22ui`,$$css:!0}},$s={horizontal:{krdFHd:`x15mokao x8eehn2`,kVL7Gh:`xbiv7yw x1xrp5p4`,kfmiAY:`x1ga7v0g xbfdvlp`,kT0f0o:`x16uus16 xajhecq`,k2ei4v:`xgbv0en x1pjv70x`,kVhnKS:`x1t7ytsu xyf0ibl`,kGJrpR:`x1j92z86`,$$css:!0},vertical:{krdFHd:`x15mokao x8eehn2`,kfmiAY:`x1ga7v0g x2qxyot`,kVL7Gh:`xbiv7yw x12tyzlf`,kT0f0o:`x16uus16 xajhecq`,kEafiO:`x11xkdxz x1g31smg`,kPef9Z:`x13fuv20 x1d9v4yf`,kLZC3w:`x1pc3f07`,$$css:!0},onSolidHorizontal:{kGJrpR:`xrvmtm5`,$$css:!0},onSolidVertical:{kLZC3w:`x11npmm7`,$$css:!0}};function ec({label:e,variant:t=`secondary`,size:n,type:r=`button`,isDisabled:i=!1,isLoading:a=!1,isInterruptible:o=!1,clickAction:s,icon:c,isIconOnly:l=!1,width:u,elevation:d=`none`,children:f,endContent:p,tooltip:m,href:h,as:g,target:_,rel:y,xstyle:b,className:x,style:S,ref:C,...T}){let E=Gs(),D=so(n,`md`),O=lo(),[k,A]=(0,v.useTransition)(),j=(0,v.useRef)(!1),M=a||k,N=k||o,P=O?.isDisabled??!1,F=i||P||M&&!o,I=po(g),L=h!=null&&!F,R=m!=null&&F,z=Aa({placement:`above`,isEnabled:m!=null}),B=e=>{if(F||j.current&&!o){e.preventDefault();return}T.onClick?.(e),s&&!e.defaultPrevented&&(j.current=!0,A(async()=>{try{await s(e)}finally{j.current=!1}}))},V=R?e=>{e.key===`Enter`||e.key===` `?e.preventDefault():T.onKeyDown?.(e)}:void 0,H=t===`ghost`?{[ao]:``}:null,U=vo.focusVisible(Ks.base,Js[D],l&&Ks.iconOnly,F&&Ks.disabled,R&&Ks.ariaDisabled,L&&Ks.link,!O&&Ks.pressable,O&&(O.orientation===`horizontal`?$s.horizontal:$s.vertical),O&&(t===`primary`||t===`destructive`)&&(O.orientation===`horizontal`?$s.onSolidHorizontal:$s.onSolidVertical),!O&&Xs[d],u!=null&&qs.width(u),Zs[t],b),W=J(Y(`button`,{variant:t,size:D}),U,x,S),ee=(0,q.jsxs)(q.Fragment,{children:[M&&(0,q.jsx)(`span`,{...{0:{className:`x10l6tqk x13vifvy x1o0tod xtijo5x x1ey2m1c xrvj5dj x1ku5rj1`},1:{className:`x10l6tqk x13vifvy x1o0tod xtijo5x x1ey2m1c xrvj5dj x1ku5rj1 xqcmdr3 xb2rp9n xskzprw x17yabm6 x14q22ui`}}[!!N<<0],"aria-hidden":`true`,children:(0,q.jsx)(ro,{size:`sm`,shade:`inherit`})}),(0,q.jsxs)(`span`,{...w(Ks.contentWrapper,M&&(N?Qs.hiddenContentDelayed:Qs.hiddenContent)),"aria-hidden":M||void 0,children:[c&&(0,q.jsx)(`span`,{...w(Ks.iconWrapper,Ys[D]),children:c}),l?null:(0,q.jsx)(`span`,{className:`xb3r6kr xlyipyv xeuugli`,children:f??e}),!l&&p&&(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 x1heor9g`,children:p})]}),(0,q.jsx)(io,{role:`status`,"aria-live":`polite`,children:M?E(`@astryx.button.loading`):``})]}),te=l&&e!==``||M&&!l||f!=null&&f!==e?{"aria-label":e}:null,ne=m==null?null:{"aria-describedby":[T[`aria-describedby`],z.describedBy].filter(Boolean).join(` `)||void 0},re=Ei(C,m==null?void 0:z.ref),ie;return ie=L?(0,q.jsx)(I,{ref:re,href:h,target:_,rel:y,...W,...T,...te,...ne,...H,"aria-busy":M||void 0,onClick:B,children:ee}):(0,q.jsx)(`button`,{ref:re,type:r,disabled:R?void 0:F,...W,...T,...te,...ne,...H,"aria-busy":M||void 0,"aria-disabled":R||void 0,onClick:B,...V?{onKeyDown:V}:null,children:ee}),m?(0,q.jsxs)(q.Fragment,{children:[ie,z.renderTooltip(m)]}):ie}ec.displayName=`Button`;function tc({icon:e,...t}){return(0,q.jsx)(ec,{...t,icon:e,isIconOnly:!0})}tc.displayName=`IconButton`;var nc=new Map,rc=/\b(const|let|var|function|class|if|else|for|while|return|import|export|from|default|async|await|try|catch|throw|new|typeof|instanceof|interface|type|enum|extends|implements|switch|case|break|continue|do|in|of|void|null|undefined|true|false|this|super|yield|delete|static|public|private|protected|readonly|abstract|as|is|keyof|declare|module|namespace|require)\b/,ic=/\b(def|class|if|elif|else|for|while|return|import|from|as|with|try|except|raise|True|False|None|and|or|not|in|is|lambda|yield|async|await|pass|break|continue|del|global|nonlocal|assert|finally|print|self|cls)\b/,ac=/\b(if|then|else|elif|fi|for|do|done|while|until|case|esac|function|in|select|return|exit|local|export|source|alias|unalias|readonly|shift|eval|exec|set|unset|trap|wait|read|echo|printf|test|true|false)\b/,oc=/\b(important|inherit|initial|unset|revert|auto|none)\b/,sc=/\b(function|class|if|else|elseif|for|foreach|while|return|echo|public|private|protected|static|new|try|catch|throw|namespace|use|require|require_once|include|include_once|extends|implements|interface|abstract|final|const|var|true|false|null|array|isset|unset|empty|list|match|enum|switch|case|break|continue|do|yield|fn)\b/,cc=/\b(function|class|if|else|for|foreach|while|return|echo|public|private|protected|static|new|try|catch|throw|namespace|use|require|include|extends|implements|interface|abstract|final|const|shape|vec|dict|keyset|async|await|concurrent|enum|type|newtype|tuple|inout)\b/;function lc(e){let t=nc.get(e);if(t!==void 0)return t;let n=uc(e);return nc.set(e,n),n}function uc(e){let t=dc(e);return t?{defaultType:t.defaultType,patterns:t.patterns.map(e=>{let t=e.regex.flags.replace(/[gy]/g,``)+`y`;return{...e,anchored:new RegExp(e.regex.source,t)}})}:null}function dc(e){switch(e){case`typescript`:case`javascript`:case`tsx`:case`jsx`:case`ts`:case`js`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/\/\*[\s\S]*?\*\//},{type:`comment`,regex:/\/\/[^\n]*/},{type:`string`,regex:/`(?:[^`\\]|\\.)*`/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`constant`,regex:/@[\w]+/},{type:`number`,regex:/\b0[xX][0-9a-fA-F_]+\b/},{type:`number`,regex:/\b0[bB][01_]+\b/},{type:`number`,regex:/\b0[oO][0-7_]+\b/},{type:`number`,regex:/\b\d[\d_]*\.?[\d_]*(?:[eE][+-]?\d+)?\b/},{type:`keyword`,regex:rc},{type:`function`,regex:/\b[a-zA-Z_$][\w$]*(?=\s*\()/},{type:`type`,regex:/\b[A-Z][a-zA-Z0-9_]*\b/},{type:`operator`,regex:/[+\-*/%=!<>&|^~?:]+/},{type:`punctuation`,regex:/[{}()\[\];,.]/},{type:`variable`,regex:/\b[a-zA-Z_$][\w$]*\b/}]};case`json`:return{defaultType:`punctuation`,patterns:[{type:`property`,regex:/"(?:[^"\\]|\\.)*"(?=\s*:)/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`number`,regex:/-?\b\d+\.?\d*(?:[eE][+-]?\d+)?\b/},{type:`constant`,regex:/\b(true|false|null)\b/},{type:`punctuation`,regex:/[{}()\[\]:,]/}]};case`html`:case`xml`:case`svg`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/<!--[\s\S]*?-->/},{type:`keyword`,regex:/<!DOCTYPE[^>]*>/i},{type:`tag`,regex:/<\/[a-zA-Z][\w-]*\s*>/},{type:`tag`,regex:/<[a-zA-Z][\w-]*/},{type:`tag`,regex:/\/?>/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`attribute`,regex:/\b[a-zA-Z_:][\w:.-]*(?=\s*=)/},{type:`operator`,regex:/=/}]};case`css`:case`scss`:case`less`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/\/\*[\s\S]*?\*\//},{type:`comment`,regex:/\/\/[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`variable`,regex:/--[a-zA-Z_-][\w-]*/},{type:`number`,regex:/-?\b\d+\.?\d*(?:px|em|rem|%|vh|vw|vmin|vmax|ch|ex|deg|rad|turn|s|ms|fr)?\b/},{type:`constant`,regex:/#[0-9a-fA-F]{3,8}\b/},{type:`keyword`,regex:oc},{type:`keyword`,regex:/@[a-zA-Z][\w-]*/},{type:`tag`,regex:/[.#][a-zA-Z_-][\w-]*/},{type:`keyword`,regex:/::?[a-zA-Z][\w-]*/},{type:`function`,regex:/\b[a-zA-Z_-][\w-]*(?=\s*\()/},{type:`property`,regex:/[a-zA-Z_-][\w-]*(?=\s*:)/},{type:`punctuation`,regex:/[{}()\[\];:,]/},{type:`operator`,regex:/[+~>*=|^$]/}]};case`python`:case`py`:return{defaultType:`variable`,patterns:[{type:`string`,regex:/"""[\s\S]*?"""/},{type:`string`,regex:/'''[\s\S]*?'''/},{type:`string`,regex:/f"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/f'(?:[^'\\]|\\.)*'/},{type:`comment`,regex:/#[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`constant`,regex:/@[\w.]+/},{type:`number`,regex:/\b0[xX][0-9a-fA-F_]+\b/},{type:`number`,regex:/\b0[bB][01_]+\b/},{type:`number`,regex:/\b0[oO][0-7_]+\b/},{type:`number`,regex:/\b\d[\d_]*\.?[\d_]*(?:[eE][+-]?\d+)?j?\b/},{type:`keyword`,regex:ic},{type:`function`,regex:/\b[a-zA-Z_][\w]*(?=\s*\()/},{type:`type`,regex:/\b[A-Z][a-zA-Z0-9_]*\b/},{type:`operator`,regex:/[+\-*/%=!<>&|^~@:]+/},{type:`punctuation`,regex:/[{}()\[\];,.]/},{type:`variable`,regex:/\b[a-zA-Z_][\w]*\b/}]};case`bash`:case`sh`:case`zsh`:case`shell`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/#[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'[^']*'/},{type:`variable`,regex:/\$\{[^}]+\}/},{type:`variable`,regex:/\$[a-zA-Z_][\w]*/},{type:`variable`,regex:/\$[0-9@#?*!$-]/},{type:`number`,regex:/\b\d+\b/},{type:`keyword`,regex:ac},{type:`function`,regex:/\b[a-zA-Z_][\w]*(?=\s*\()/},{type:`operator`,regex:/[|&<>;!]+/},{type:`punctuation`,regex:/[{}()\[\]]/}]};case`php`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/\/\*[\s\S]*?\*\//},{type:`comment`,regex:/\/\/[^\n]*/},{type:`comment`,regex:/#[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`variable`,regex:/\$[a-zA-Z_][\w]*/},{type:`number`,regex:/\b0[xX][0-9a-fA-F]+\b/},{type:`number`,regex:/\b\d+\.?\d*(?:[eE][+-]?\d+)?\b/},{type:`keyword`,regex:sc},{type:`function`,regex:/\b[a-zA-Z_][\w]*(?=\s*\()/},{type:`type`,regex:/\b[A-Z][a-zA-Z0-9_]*\b/},{type:`operator`,regex:/[+\-*/%=!<>&|^~?:.]+/},{type:`constant`,regex:/@[\w]+/},{type:`punctuation`,regex:/[{}()\[\];,.]/}]};case`hack`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/\/\*[\s\S]*?\*\//},{type:`comment`,regex:/\/\/[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`variable`,regex:/\$[a-zA-Z_][\w]*/},{type:`number`,regex:/\b0[xX][0-9a-fA-F]+\b/},{type:`number`,regex:/\b\d+\.?\d*(?:[eE][+-]?\d+)?\b/},{type:`keyword`,regex:cc},{type:`type`,regex:/\b[A-Z][a-zA-Z0-9_]*\b/},{type:`function`,regex:/\b[a-zA-Z_][\w]*(?=\s*\()/},{type:`property`,regex:/(?<=->|::)\b[a-zA-Z_][\w]*\b/},{type:`operator`,regex:/[+\-*/%=!<>&|^~?:.]+/},{type:`constant`,regex:/<<[\w]+/},{type:`punctuation`,regex:/[{}()\[\];,.]/}]};case`yaml`:case`yml`:return{defaultType:`variable`,patterns:[{type:`comment`,regex:/#[^\n]*/},{type:`string`,regex:/"(?:[^"\\]|\\.)*"/},{type:`string`,regex:/'(?:[^'\\]|\\.)*'/},{type:`constant`,regex:/\b(true|false|yes|no|on|off|null|~)\b/i},{type:`variable`,regex:/[&*][\w]+/},{type:`type`,regex:/!!\w+/},{type:`number`,regex:/\b-?\d+\.?\d*(?:[eE][+-]?\d+)?\b/},{type:`property`,regex:/^[ \t]*[\w][\w ./-]*(?=\s*:)/m},{type:`keyword`,regex:/---/},{type:`keyword`,regex:/\.\.\./},{type:`operator`,regex:/[:|>\-?]/},{type:`punctuation`,regex:/[{}()\[\],]/},{type:`variable`,regex:/\b[a-zA-Z_][\w]*\b/}]};case`markdown`:case`md`:return{defaultType:`variable`,patterns:[{type:`keyword`,regex:/^```[\w]*$/m},{type:`keyword`,regex:/^#{1,6}\s+.*/m},{type:`keyword`,regex:/^---$/m},{type:`keyword`,regex:/^\*\*\*$/m},{type:`string`,regex:/\*\*(?:[^*]|\*(?!\*))+\*\*/},{type:`string`,regex:/\*(?:[^*])+\*/},{type:`constant`,regex:/`[^`]+`/},{type:`function`,regex:/\[(?:[^\]])+\]\([^)]+\)/},{type:`comment`,regex:/^>\s+.*/m},{type:`operator`,regex:/^\s*[-*+]\s/m},{type:`number`,regex:/^\s*\d+\.\s/m}]};default:return null}}var fc=800;async function pc(){return typeof scheduler<`u`&&typeof scheduler.yield==`function`?scheduler.yield():new Promise(e=>setTimeout(e,0))}function mc(e,t,n,r){let i=[],a=n,o=Math.min(r,e.length);for(;a<o;){let r=!1;for(let o of t.patterns){o.anchored.lastIndex=a;let s=o.anchored.exec(e);if(s&&s.index===a&&s[0].length>0){o.type!==t.defaultType&&i.push({type:o.type,start:a-n,end:a-n+s[0].length}),a+=s[0].length,r=!0;break}}r||a++}return i}function hc(e,t){let n=lc(t);if(!n)return[];let r=[],i=0;for(let t=0;t<=e.length;t++)(t===e.length||e[t]===`
|
|
51
|
+
`)&&(r.push(mc(e,n,i,t)),i=t+1);return r}async function gc(e,t,n){let r=lc(t);if(!r)return[];let i=[],a=0,o=0;for(let t=0;t<=e.length;t++)if((t===e.length||e[t]===`
|
|
52
|
+
`)&&(i.push(mc(e,r,a,t)),o+=t-a+1,a=t+1,o>=fc&&t<e.length)){if(n?.aborted)return i;o=0,await pc()}return i}function _c(e,t){let n=[0];for(let e=0;e<t.length;e++)t[e]===`
|
|
53
|
+
`&&n.push(e+1);let r=Array.from({length:n.length},()=>[]),i=0;for(let t of e){for(;i<n.length-1&&t.start>=n[i+1];)i++;let e=n[i];r[i].push({type:t.type,start:t.start-e,end:t.end-e})}return r}var vc=`
|
|
54
|
+
${`:root {\n${Object.entries(re).map(([e,t])=>` ${e}: ${t};`).join(`
|
|
55
|
+
`)}\n}`}
|
|
56
|
+
|
|
57
|
+
.astryx-codeblock code::highlight(astryx-keyword),
|
|
58
|
+
.astryx-codeeditor code::highlight(astryx-keyword) { color: var(--color-syntax-keyword); }
|
|
59
|
+
.astryx-codeblock code::highlight(astryx-string),
|
|
60
|
+
.astryx-codeeditor code::highlight(astryx-string) { color: var(--color-syntax-string); }
|
|
61
|
+
.astryx-codeblock code::highlight(astryx-comment),
|
|
62
|
+
.astryx-codeeditor code::highlight(astryx-comment) { color: var(--color-syntax-comment); }
|
|
63
|
+
.astryx-codeblock code::highlight(astryx-number),
|
|
64
|
+
.astryx-codeeditor code::highlight(astryx-number) { color: var(--color-syntax-number); }
|
|
65
|
+
.astryx-codeblock code::highlight(astryx-function),
|
|
66
|
+
.astryx-codeeditor code::highlight(astryx-function) { color: var(--color-syntax-function); }
|
|
67
|
+
.astryx-codeblock code::highlight(astryx-type),
|
|
68
|
+
.astryx-codeeditor code::highlight(astryx-type) { color: var(--color-syntax-type); }
|
|
69
|
+
.astryx-codeblock code::highlight(astryx-tag),
|
|
70
|
+
.astryx-codeeditor code::highlight(astryx-tag) { color: var(--color-syntax-tag); }
|
|
71
|
+
.astryx-codeblock code::highlight(astryx-attribute),
|
|
72
|
+
.astryx-codeeditor code::highlight(astryx-attribute) { color: var(--color-syntax-attribute); }
|
|
73
|
+
.astryx-codeblock code::highlight(astryx-property),
|
|
74
|
+
.astryx-codeeditor code::highlight(astryx-property) { color: var(--color-syntax-property); }
|
|
75
|
+
.astryx-codeblock code::highlight(astryx-operator),
|
|
76
|
+
.astryx-codeeditor code::highlight(astryx-operator) { color: var(--color-syntax-operator); }
|
|
77
|
+
.astryx-codeblock code::highlight(astryx-constant),
|
|
78
|
+
.astryx-codeeditor code::highlight(astryx-constant) { color: var(--color-syntax-constant); }
|
|
79
|
+
.astryx-codeblock code::highlight(astryx-punctuation),
|
|
80
|
+
.astryx-codeeditor code::highlight(astryx-punctuation) { color: var(--color-syntax-punctuation); }
|
|
81
|
+
.astryx-codeblock code::highlight(astryx-variable),
|
|
82
|
+
.astryx-codeeditor code::highlight(astryx-variable) { color: var(--color-syntax-variable); }
|
|
83
|
+
|
|
84
|
+
/* Span-based fallback classes — used when highlightMode='spans' or
|
|
85
|
+
when the CSS Custom Highlight API is not available. */
|
|
86
|
+
.astryx-token-keyword { color: var(--color-syntax-keyword); }
|
|
87
|
+
.astryx-token-string { color: var(--color-syntax-string); }
|
|
88
|
+
.astryx-token-comment { color: var(--color-syntax-comment); }
|
|
89
|
+
.astryx-token-number { color: var(--color-syntax-number); }
|
|
90
|
+
.astryx-token-function { color: var(--color-syntax-function); }
|
|
91
|
+
.astryx-token-type { color: var(--color-syntax-type); }
|
|
92
|
+
.astryx-token-tag { color: var(--color-syntax-tag); }
|
|
93
|
+
.astryx-token-attribute { color: var(--color-syntax-attribute); }
|
|
94
|
+
.astryx-token-property { color: var(--color-syntax-property); }
|
|
95
|
+
.astryx-token-operator { color: var(--color-syntax-operator); }
|
|
96
|
+
.astryx-token-constant { color: var(--color-syntax-constant); }
|
|
97
|
+
.astryx-token-punctuation { color: var(--color-syntax-punctuation); }
|
|
98
|
+
.astryx-token-variable { color: var(--color-syntax-variable); }
|
|
99
|
+
`,yc=!1;function bc(){if(yc||typeof document>`u`)return;let e=document.createElement(`style`);e.setAttribute(`data-astryx-highlight-styles`,``),e.textContent=vc,document.head.appendChild(e),yc=!0}var xc=new Set([`keyword`,`string`,`comment`,`number`,`function`,`type`,`tag`,`attribute`,`property`,`operator`,`constant`,`punctuation`,`variable`]),Sc=null;function Cc(e){if(xc.has(e)||(xc.add(e),bc(),typeof document>`u`))return;if(!Sc){let e=document.createElement(`style`);if(e.setAttribute(`data-astryx-highlight-dynamic`,``),document.head.appendChild(e),Sc=e.sheet??null,!Sc)return}let t=`astryx-${e}`,n=`var(--color-syntax-${e}, currentColor)`;Sc.insertRule(`.astryx-codeblock code::highlight(${t}), .astryx-codeeditor code::highlight(${t}) { color: ${n}; }`)}function wc(){let e=new Map;return t=>{let n=e.get(t);if(n)return n;Cc(t);let r=`astryx-${t}`;return n=CSS.highlights.get(r),n||(n=new Highlight,CSS.highlights.set(r,n)),e.set(t,n),n}}function Tc(e,t,n,r){if(t.length===0)return;let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return;let a=i.length;for(let e of t){if(e.start>=a||e.end<=0)continue;let t=Math.min(e.start,a),o=Math.min(e.end,a),s=r(e.type);try{let e=new Range;e.setStart(i,t),e.setEnd(i,o),s.add(e),n.push({range:e,highlight:s})}catch{}}}function Ec(e){for(let{range:t,highlight:n}of e)n.delete(t)}function Dc(e,t,n,r){let i=[],a=e.querySelectorAll(`[data-line]`);for(let e=0;e<a.length;e++){let o=t[n+e];o&&o.length>0&&Tc(a[e],o,i,r)}return i}function Oc(e,t){bc();let n=wc(),r=[],i=[],a=0;for(let t=0;t<e.children.length;t++){let n=e.children[t],o=n.querySelectorAll(`[data-line]`);o.length>0&&n.tagName===`DIV`&&!n.hasAttribute(`data-line`)&&(r.push(n),i.push(a),a+=o.length)}if(r.length===0){let r=[],i=e.querySelectorAll(`[data-line]`);for(let e=0;e<i.length;e++){let a=t[e];a&&a.length>0&&Tc(i[e],a,r,n)}return()=>Ec(r)}let o=new Map,s=new Map;function c(e,r){if(o.has(e))return;let a=Dc(e,t,i[r],n);o.set(e,a)}function l(e){let t=o.get(e);t&&(Ec(t),o.delete(e))}for(let e=0;e<r.length;e++){let t=r[e],n=n=>{n.skipped?l(t):c(t,e)};t.addEventListener(`contentvisibilityautostatechange`,n),s.set(t,n);let i=t;typeof i.checkVisibility==`function`?i.checkVisibility({checkVisibilityCSS:!0,contentVisibilityAuto:!0})&&c(t,e):e<5&&c(t,e)}return function(){for(let[e,t]of s)e.removeEventListener(`contentvisibilityautostatechange`,t);s.clear();for(let e of o.values())Ec(e);o.clear()}}var kc={card:{kaIpWk:`xh6dtrn`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kVAM5u:`x14i3s5s`,$$css:!0},section:{kaIpWk:`x2u8bby`,kMzoRj:`xc342km`,ksu8eU:`xng3xce`,kVAM5u:`x9r1u3d`,"--color-syntax-background":`x1mtvhk1`,$$css:!0}},Ac={"--_codeblock-gutter-width":`xtk08jq`,$$css:!0},jc={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,k7Eaqz:(e===`fit-content`?`min(100%, 400px)`:null)==null?e===`fit-content`?`min(100%, 400px)`:null:`xkj4a21`,ks0D6T:(e===`fit-content`?`100%`:null)==null?e===`fit-content`?`100%`:null:`xf68679`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e),"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(e===`fit-content`?`min(100%, 400px)`:null),"--x-maxWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(e===`fit-content`?`100%`:null)}],gutterWidth:e=>[Ac,{"--x---_codeblock-gutter-width":`${e}ch`==null?void 0:`${e}ch`}]},Mc={root:{kVAEAm:`x1n2onr6`,kHBbk8:`xc8icb0`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kogj98:`x1ghz6dp`,kWkggS:`xzyc27v`,kVQacm:`xb3r6kr`,$$css:!0},header:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,kmVPX3:`x1717udv`,kWkggS:`xjbqb8w`,kMwMTN:`x1heor9g`,kVVagm:`xln7xf2`,k9WMMc:`x1yc453h`,$$css:!0},collapseChevronIcon:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},collapseChevronExpanded:{k3aq6I:`x1iffjtl`,$$css:!0},headerCollapsible:{kkrTdU:`x1ypdohk`,kfSwDN:`x87ps6o`,$$css:!0},code:{k1xSpc:`x1lliihq`,kUk6DE:`x98rzlu`,k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,kogj98:`x1ghz6dp`,kMv6JI:`x9m5x89`,kMwMTN:`xdfisg`,kKi2Bq:`xeq4nuv`,khDVqt:`x1sdyfia`,kTgw9:`x1lldw8n`,kHjlTd:`x1h4wwuj`,$$css:!0},codeWrapped:{khDVqt:`x126k92a`,kTgw9:`x1yn0g08`,kHjlTd:`x1mzt3pk`,$$css:!0},codeNumbered:{kVAEAm:`x1n2onr6`,k5JduY:`x1s928wv`,kwXMNM:`x1j6awrg`,kSy8m5:`xd54j2p`,kc1e00:`x1km86hw`,kkgrvl:`xkj6t0a`,kQlJh0:`x1p96cux`,k6vLHU:`xvsnedh`,kkQ525:`xnnzo76`,kloYau:`x2q1x1w`,$$css:!0},sizeSm:{kGuDYH:`x141an7d`,$$css:!0},sizeMd:{kGuDYH:`xp03k98`,$$css:!0},copyButton:{kMwMTN:`x1mjzq1q`,$$css:!0},copyButtonAbsolute:{kVAEAm:`x10l6tqk`,k87sOh:`xctzyg`,kt4wiu:`x72tfeb`,$$css:!0}},Nc=20,Pc=100,Fc=v.memo(function({lines:e,startIndex:t,highlightSet:n,renderLineContent:r,lineNumbers:i}){return(0,q.jsx)(q.Fragment,{children:e.map((e,a)=>{let o=t+a;return(0,q.jsx)(`div`,{"data-line":o+1,...{0:{className:`x17iicif`},2:{className:`x17iicif xrvj5dj x1xx4m37 xf5zn4v x46gnpd x17gn2l9 x19ds33d x1wnbjh8 xtkarl4 x1rbqspl x3nzp0f`},1:{className:`x17iicif xgcxg3y x1ng9b9t x1pzlopt`},3:{className:`x17iicif xrvj5dj x1xx4m37 xf5zn4v x46gnpd x17gn2l9 x19ds33d x1wnbjh8 xtkarl4 x1rbqspl x3nzp0f xgcxg3y x1ng9b9t x1pzlopt`}}[!!i<<1|!!(n?.has(o+1)??!1)<<0],children:r(e,o)},o)})})});function Ic(e,t,n,r,i=Nc){if(i=Math.max(1,Math.floor(i)),e.length<Pc)return(0,q.jsx)(Fc,{lines:e,startIndex:0,highlightSet:t,renderLineContent:n,lineNumbers:r});let a=[];for(let o=0;o<e.length;o+=i){let s=Math.min(o+i,e.length),c=e.slice(o,s),l=`${c.length}lh`;a.push((0,q.jsx)(`div`,{...J({className:`xb5mbof`},{style:{containIntrinsicBlockSize:`auto ${l}`}}),children:(0,q.jsx)(Fc,{lines:c,startIndex:o,highlightSet:t,renderLineContent:n,lineNumbers:r})},o))}return a}function Lc(){return typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight<`u`}function Rc(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)}function zc(e,t,n){let[r,i]=(0,v.useState)(null),a=(0,v.useMemo)(()=>n?_c(n(e,t),e):e.length>=2e3?null:hc(e,t),[e,t,n]);return(0,v.useEffect)(()=>{if(e.length<2e3||n)return;let r=new AbortController;async function a(){try{let n=await gc(e,t,r.signal);r.signal.aborted||i({code:e,language:t,tokens:n})}catch{r.signal.aborted||i({code:e,language:t,tokens:[]})}}return a(),()=>{r.abort()}},[e,t,n]),a??(r?.code===e&&r.language===t?r.tokens:[])}function Bc(e,t){if(t.length===0)return e||``;let n=[],r=0;for(let i of t){i.start>r&&n.push(e.slice(r,i.start));let t=Math.min(i.end,e.length);n.push((0,q.jsx)(`span`,{className:`astryx-token-${i.type} xds-token-${i.type}`,children:e.slice(i.start,t)},`${i.start}-${i.type}`)),r=t}return r<e.length&&n.push(e.slice(r)),n.length>0?n:``}function Vc({lines:e,tokenLines:t,highlightSet:n,isWrapped:r,sizeStyle:i,hasLineNumbers:a,maxDigits:o}){(0,v.useInsertionEffect)(()=>{bc()},[]);let s=(0,v.useCallback)((e,n)=>{let r=t[n]??[];return(0,q.jsx)(`span`,{className:`xeuugli`,children:Bc(e,r)})},[t]);return(0,q.jsx)(`code`,{...w(Mc.code,i,r&&Mc.codeWrapped,a&&Mc.codeNumbered,a&&jc.gutterWidth(o)),children:Ic(e,n,s,a)})}function Hc({lines:e,tokenLines:t,highlightSet:n,isWrapped:r,sizeStyle:i,hasLineNumbers:a,maxDigits:o}){let s=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!Lc())return;bc();let e=s.current;if(!(!e||t.length===0))return Oc(e,t)},[t]);let c=(0,v.useCallback)(e=>e||``,[]);return(0,q.jsx)(`code`,{ref:s,...w(Mc.code,i,r&&Mc.codeWrapped,a&&Mc.codeNumbered,a&&jc.gutterWidth(o)),children:Ic(e,n,c,a)})}function Uc({code:e,language:t=`plaintext`,title:n,hasLanguageLabel:r=!0,hasLineNumbers:i=!1,highlightLines:a,hasCopyButton:o=!0,onCopy:s,isWrapped:c=!1,maxHeight:l,isCollapsible:u=!1,collapsibleThreshold:d=10,size:f=`md`,width:p=`fit-content`,container:m=`card`,tokenizer:h,highlightMode:g=`auto`,syntaxTheme:_,xstyle:y,className:b,style:x,ref:S,...C}){let T=Gs(),{copy:E,isCopied:D}=ea({announce:T(`@astryx.codeBlock.copied`)}),O=g===`spans`||g===`auto`&&!Lc()||g===`auto`&&Rc(),k=(0,v.useMemo)(()=>{let t=e.split(`
|
|
100
|
+
`);return t.length>1&&t[t.length-1]===``&&t.pop(),t},[e]),A=zc(e,t,h),j=(0,v.useMemo)(()=>a?new Set(a):null,[a]),M=(0,v.useCallback)(async()=>{await E(e)&&s?.()},[e,E,s]),N=f===`sm`?Mc.sizeSm:Mc.sizeMd,P=String(k.length).length,F=r&&t!==`plaintext`?t:null,I=n!=null||F!=null,L=u&&k.length>=d,[R,z]=(0,v.useState)(!1),B=(0,v.useId)(),V=(0,v.useRef)(null),H=l?{maxHeight:typeof l==`number`?`${l}px`:l}:void 0,U=o?(0,q.jsx)(tc,{variant:`ghost`,size:`sm`,icon:(0,q.jsx)(fa,{icon:D?`check`:`copy`,size:`sm`,color:`inherit`}),tooltip:T(`@astryx.codeBlock.copyCode`),label:T(D?`@astryx.codeBlock.copied`:`@astryx.codeBlock.copyCode`),onClick:e=>{e.stopPropagation(),M()},xstyle:[Mc.copyButton,!I&&Mc.copyButtonAbsolute],...Y(`codeblock-copy-button`)}):null,W=I?(0,q.jsxs)(`div`,{...J(Y(`codeblock-header`,{size:f,language:t,container:m}),{0:{className:`x78zum5 x6s0dn4 x1qughib x1pzlopt xzyc27v x7wzq59 x13vifvy x1vjfegm xce4md1`},1:{className:`x78zum5 x6s0dn4 x1qughib x1pzlopt xzyc27v x7wzq59 x13vifvy x1vjfegm xce4md1 x92x3c3 x1q0q8m5 xw8gpjh`}}[!!i<<0]),children:[(0,q.jsx)(`div`,{role:L?`button`:void 0,tabIndex:L?0:void 0,"aria-expanded":L?!R:void 0,"aria-controls":L?B:void 0,onClick:L?()=>z(e=>!e):void 0,onKeyDown:L?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),z(e=>!e))}:void 0,...vo.focusVisible(Mc.header,L&&Mc.headerCollapsible),children:(0,q.jsxs)(`span`,{...J(Y(`codeblock-title`,{size:f,language:t}),{className:`x78zum5 x6s0dn4 x141an7d x9m5x89 x1e4wzip x1mjzq1q x1ghz6dp x1ltkj2j`}),children:[L&&(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 xl56j7k x2lah0s x6jxa94 x1v9usgg xnur1sd xb3r6kr x1mjzq1q x1gbn2au x1aquc0h x12wqnr7 x128ha8g`,children:(0,q.jsx)(fa,{icon:`chevronRight`,size:`xsm`,color:`inherit`,xstyle:[Mc.collapseChevronIcon,!R&&Mc.collapseChevronExpanded]})}),n,n&&F?` — `:``,F]})}),U]}):null,ee=(0,q.jsx)(`div`,{ref:V,tabIndex:0,role:`group`,"aria-label":F??T(`@astryx.codeBlock.code`),...J({className:`xw2csxc x1odjw0f`},{style:H}),children:(0,q.jsx)(`div`,{...{0:{className:`x78zum5 x1pshirs`},1:{className:`x78zum5 x1pshirs x1ajqlyv`}}[!!(I&&!i)<<0],children:O?(0,q.jsx)(Vc,{lines:k,tokenLines:A,highlightSet:j,isWrapped:c,sizeStyle:N,hasLineNumbers:i,maxDigits:P}):(0,q.jsx)(Hc,{lines:k,tokenLines:A,highlightSet:j,isWrapped:c,sizeStyle:N,hasLineNumbers:i,maxDigits:P})})}),te=(0,q.jsxs)(`pre`,{ref:S,...J(Y(`codeblock`,{size:f,language:t,container:m}),w(Mc.root,jc.width(p),kc[m],y),b,x),...C,children:[W,L?(0,q.jsx)(`div`,{id:B,inert:R?!0:void 0,...{0:{className:`xrvj5dj x1tu4anv x1qn9uv2 x80gvsz xlr8y92`},1:{className:`xrvj5dj x1qn9uv2 x80gvsz xlr8y92 xihq33y`}}[!!R<<0],children:(0,q.jsx)(`div`,{className:`xb3r6kr x2lwn1j`,children:ee})}):ee,!I&&U]});return _?(0,q.jsx)(kt,{theme:_,children:te}):te}Uc.displayName=`CodeBlock`;var Wc={base:{kMv6JI:`x9m5x89`,kGuDYH:`xp03k98`,kLWn49:`x15bjb6t`,kWkggS:`xwmxj5m`,kg3NbH:`x7a5moj`,k8WAf4:`x1hp7d8q`,kaIpWk:`xx3sua9`,kHjlTd:`x1mzt3pk`,kTgw9:`x13faqbe`,$$css:!0}},Gc={primary:{kMwMTN:`x1tgivj0`,$$css:!0},secondary:{kMwMTN:`xv1l7n4`,$$css:!0},inherit:{kMwMTN:`x1heor9g`,$$css:!0}},Kc={inherit:{kGuDYH:`x1qlqyl8`,kLWn49:`x15bjb6t`,$$css:!0}};function qc({children:e,color:t=`primary`,size:n,xstyle:r,className:i,style:a,ref:o,...s}){return(0,q.jsx)(`code`,{ref:o,...s,...J(Y(`code`,{color:t}),w(Wc.base,Gc[t],n&&Kc[n],r),i,a),children:e})}qc.displayName=`Code`;var Jc=(0,v.createContext)(null);Jc.displayName=`CollapsibleGroupContext`;var Yc=(0,v.createContext)(null);Yc.displayName=`CollapsibleGroupPresentationContext`;function Xc(e){let{isCollapsible:t,value:n}=e,r=(0,v.use)(Jc),i=r!=null&&n!=null,a=t===!0?{}:t||null,o=a!=null,[s,c]=(0,v.useState)(()=>i?!0:a?.isOpen===void 0?a?.defaultIsOpen??!0:a.isOpen),l;return l=i&&n!=null?r.isOpen(n):a?.isOpen===void 0?s:a.isOpen,{isEnabled:o,isOpen:l,toggle:()=>{if(i&&n!=null){r.toggle(n);return}let e=!l;a?.isOpen===void 0&&c(e),a?.onOpenChange?.(e)}}}var Zc={root:{kzqmXN:`xh8yej3`,$$css:!0},trigger:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kzqmXN:`xh8yej3`,kkrTdU:`x1ypdohk`,kMv6JI:`x9ynric`,kGuDYH:`x18juvz8`,k63SB2:`x2mo6ok`,kMwMTN:`x1tgivj0`,k9WMMc:`x1yc453h`,k8WAf4:`xt970qd`,$$css:!0},triggerDisabled:{kkrTdU:`x1h6gzvc`,kSiTet:`xbyyjgo`,$$css:!0},chevron:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kzqmXN:`xta46cu`,kZKoxP:`x1seg80s`,kGuDYH:`x18juvz8`,k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},chevronOpen:{k3aq6I:`x19jd1h0`,$$css:!0},chevronClosed:{k3aq6I:`x7p49u4`,$$css:!0},contentHidden:{k1xSpc:`x1s85apg`,$$css:!0},content:{kLKAdn:`xfsso4q`,kMv6JI:`x9ynric`,kGuDYH:`xjm74w1`,k63SB2:`xxovm9e`,kLWn49:`xw6l6zx`,kMwMTN:`x1tgivj0`,$$css:!0},divided:{kEafiO:`x11xkdxz x1g31smg`,kPef9Z:`x13fuv20`,kLZC3w:`x1pc3f07`,$$css:!0}},Qc={triggerCompact:{k8WAf4:`xu0wf1k`,$$css:!0},triggerBalanced:{k8WAf4:`xce4md1`,$$css:!0},triggerSpacious:{k8WAf4:`x8o8v82`,$$css:!0},contentCompact:{kGO01o:`xy143xn`,$$css:!0},contentBalanced:{kGO01o:`x1wesfrj`,$$css:!0},contentSpacious:{kGO01o:`xvmdzux`,$$css:!0}},$c={compact:Qc.triggerCompact,balanced:Qc.triggerBalanced,spacious:Qc.triggerSpacious},el={compact:Qc.contentCompact,balanced:Qc.contentBalanced,spacious:Qc.contentSpacious};function tl({trigger:e,children:t,defaultIsOpen:n,isOpen:r,isDisabled:i=!1,onOpenChange:a,value:o,ref:s,xstyle:c,className:l,style:u,...d}){let{isOpen:f,toggle:p}=Xc({isCollapsible:r===void 0?{defaultIsOpen:n??!0,onOpenChange:a}:{isOpen:r,onOpenChange:a},value:o}),m=()=>{i||p()},h=(0,v.use)(Yc),g=h?.hasDividers??!1,_=h?.density??null,y=(0,v.useId)();return(0,q.jsxs)(`div`,{ref:s,...J(Y(`collapsible`,{density:_??void 0}),w(Zc.root,g&&Zc.divided,c),l,u),...d,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:m,"aria-disabled":i||void 0,"aria-expanded":f,"aria-controls":y,tabIndex:i?-1:void 0,...J(Y(`collapsible-trigger`,{density:_??void 0}),vo.focusVisible(Zc.trigger,_!=null&&$c[_],i&&Zc.triggerDisabled)),children:[(0,q.jsx)(`span`,{className:`x1b2iylo xwgcxoh`,children:e}),(0,q.jsx)(fa,{icon:`chevronDown`,size:`sm`,color:`secondary`,xstyle:[Zc.chevron,f?Zc.chevronOpen:Zc.chevronClosed]})]}),(0,q.jsx)(`div`,{id:y,...J(Y(`collapsible-content`,{density:_??void 0}),w(Zc.content,_!=null&&el[_],!f&&Zc.contentHidden)),children:h==null?t:(0,q.jsx)(Yc,{value:null,children:t})})]})}tl.displayName=`Collapsible`;function nl(e){let t={},n={};for(let r of e)r.kind===`free_text`?t[r.id]=``:n[r.id]={decision:null,text:``};return{freeText:t,confirm:n}}function rl(e){return e.trim().length>0}function il(e,t){return e.every(e=>e.kind===`free_text`?rl(t.freeText[e.id]??``):t.confirm[e.id]?.decision!=null)}function al(e){if(!e)return!1;let t=e.promptId,n=e.kind;return!!t&&(n===`confirm`||n===`artifact_backed`)}function ol(e){return e?.trim()||void 0}function sl(e,t){if(e.kind!==`confirm`&&e.kind!==`artifact_backed`)return null;let n=ol(t.note);return n?{promptId:e.promptId,kind:e.kind,decision:t.decision,text:n}:{promptId:e.promptId,kind:e.kind,decision:t.decision}}function cl(e,t,n){let r={};for(let e of t)if(e.kind===`free_text`)r[e.id]={kind:`free_text`,text:n.freeText[e.id]??``};else{let t=n.confirm[e.id],i=t?.decision;if(i==null)continue;let a=ol(t.text);r[e.id]=a?{kind:`confirm`,decision:i,text:a}:{kind:`confirm`,decision:i}}return{promptId:e,kind:`multi_question`,answers:r}}function ll(e,t,n){return e.promptId?t.type===`decision`?sl(e,t):t.type===`free_text`?e.kind!==`free_text`||!rl(t.text)?null:{promptId:e.promptId,kind:`free_text`,text:t.text.trim()}:e.kind!==`multi_question`||!n||n.kind!==`multi_question`||!il(n.questions,t.draft)?null:cl(e.promptId,n.questions,t.draft):null}function ul(e){return e?`${e.promptId}:${e.kind}`:null}function dl(){return{submitting:!1,awaitingClear:!1,error:null}}function fl(e){return e.submitting||e.awaitingClear}function pl(e){return{...e,submitting:!0,error:null}}function ml(){return{submitting:!1,awaitingClear:!0,error:null}}function hl(e){return{submitting:!1,awaitingClear:!1,error:e}}function gl(e,t){return ul(e)===ul(t)}async function _l(e){let{pending:t,runId:n,stageId:r,intent:i,prompt:a,submit:o}=e;if(!t||!t.promptId)return{status:`refused`,reason:`stale`};if(!r)return{status:`refused`,reason:`missing_stage`};if(!gl(e.getPending?.()??t,t))return{status:`refused`,reason:`stale`};let s=ll(t,i,a);if(!s||s.promptId!==t.promptId)return{status:`refused`,reason:`invalid`};try{return await o(n,r,s),{status:`posted`}}catch(e){return{status:`failed`,error:e instanceof Error?e.message:String(e)}}}function vl(e){let t=dl(),n=ul(e.getPending());return{getState(){return t},locked(){return fl(t)},syncPending(){let r=ul(e.getPending());r!==n&&(n=r,t=dl())},async submitIntent(n,r){if(fl(t))return;let i=e.getPending(),{runId:a,stageId:o}=e.getTarget();t=pl(t);let s=await _l({pending:i,getPending:e.getPending,runId:a,stageId:o,intent:n,prompt:r,submit:e.submit});if(s.status===`posted`){t=ml(),await e.refresh?.();return}if(s.status===`failed`){t=hl(s.error);return}t=dl()}}}function yl(e,t,n){let r=Nr(),i=(0,v.useRef)(n);i.current=n;let a=(0,v.useRef)({runId:e,stageId:t});a.current={runId:e,stageId:t};let o=(0,v.useRef)(r);o.current=r;let s=(0,v.useRef)(null);s.current===null&&(s.current=vl({getPending:()=>i.current,getTarget:()=>a.current,submit:(e,t,n)=>sr(e,t,n),refresh:()=>o.current.refresh()}));let c=s.current,[l,u]=(0,v.useState)(()=>c.getState()),d=ul(n);(0,v.useEffect)(()=>{c.syncPending(),u(c.getState())},[d,c]);let f=(0,v.useCallback)(async(e,t)=>{let n=c.submitIntent(e,t);u(c.getState()),await n,u(c.getState())},[c]);return{submitting:l.submitting,awaitingClear:l.awaitingClear,error:l.error,locked:fl(l),submitIntent:f}}function bl({runId:e,stageId:t,prompt:n,onReviewSideBySide:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(()=>n.kind===`multi_question`?nl(n.questions):nl([])),{submitting:u,error:d,locked:f,submitIntent:p}=yl(e,t,{promptId:n.id,kind:n.kind});(0,v.useEffect)(()=>{a(``),s(``),l(n.kind===`multi_question`?nl(n.questions):nl([]))},[n.id,n.kind]);async function m(){await p({type:`free_text`,text:i})}async function h(e){(n.kind===`confirm`||n.kind===`artifact_backed`)&&await p({type:`decision`,decision:e,note:o})}async function g(){n.kind===`multi_question`&&await p({type:`multi`,draft:c},n)}let _=n.kind===`multi_question`?`Answer each question below.`:n.message;return(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-3)`},children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h4`,{style:{margin:`0 0 var(--spacing-1)`,fontSize:`var(--font-size-base)`,fontWeight:600},children:`Operator reply`}),(0,q.jsx)(`p`,{className:`muted`,style:{margin:0,fontSize:`var(--font-size-sm)`},children:_})]}),d?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-3)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsxs)(`p`,{style:{margin:0,fontSize:`var(--font-size-sm)`},children:[`Could not submit answer: `,d]})}):null,n.kind===`free_text`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`textarea`,{className:`select`,value:i,onChange:e=>a(e.target.value),rows:4,disabled:f,autoFocus:!0,placeholder:`Your answer`,style:{minHeight:84,resize:`vertical`}}),(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:f||!rl(i),onClick:()=>void m(),children:u?`Submitting…`:`Submit`})]}):null,n.kind===`confirm`||n.kind===`artifact_backed`?(0,q.jsxs)(q.Fragment,{children:[n.kind===`artifact_backed`&&r&&n.artifacts.length>0?(0,q.jsx)(`button`,{className:`btn btn--ghost`,onClick:()=>r(n.artifacts[0]),children:`Review side by side`}):null,(0,q.jsx)(`textarea`,{className:`select`,value:o,onChange:e=>s(e.target.value),rows:3,disabled:f,placeholder:`Optional notes`,style:{minHeight:62,resize:`vertical`}}),(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`},children:[(0,q.jsx)(`button`,{className:`btn btn--accept`,disabled:f,onClick:()=>void h(`accept`),children:u?`Submitting…`:`Accept`}),(0,q.jsx)(`button`,{className:`btn btn--reject`,disabled:f,onClick:()=>void h(`reject`),children:`Reject`})]})]}):null,n.kind===`multi_question`?(0,q.jsxs)(q.Fragment,{children:[n.questions.map(e=>e.kind===`free_text`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{style:{display:`block`,marginBottom:`var(--spacing-1)`,fontSize:`var(--font-size-sm)`,fontWeight:600},children:e.message}),(0,q.jsx)(`textarea`,{className:`select`,value:c.freeText[e.id]??``,onChange:t=>l(n=>({...n,freeText:{...n.freeText,[e.id]:t.target.value}})),rows:3,disabled:f,style:{minHeight:62,resize:`vertical`}})]},e.id):(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{style:{margin:`0 0 var(--spacing-2)`,fontSize:`var(--font-size-sm)`,fontWeight:500},children:e.message}),(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`,marginBottom:`var(--spacing-2)`},children:[(0,q.jsx)(`button`,{className:`btn btn--sm${c.confirm[e.id]?.decision===`accept`?` btn--accept`:``}`,disabled:f,onClick:()=>l(t=>({...t,confirm:{...t.confirm,[e.id]:{decision:`accept`,text:t.confirm[e.id]?.text??``}}})),children:`Accept`}),(0,q.jsx)(`button`,{className:`btn btn--sm${c.confirm[e.id]?.decision===`reject`?` btn--reject`:``}`,disabled:f,onClick:()=>l(t=>({...t,confirm:{...t.confirm,[e.id]:{decision:`reject`,text:t.confirm[e.id]?.text??``}}})),children:`Reject`})]}),(0,q.jsx)(`textarea`,{className:`select`,value:c.confirm[e.id]?.text??``,onChange:t=>l(n=>({...n,confirm:{...n.confirm,[e.id]:{decision:n.confirm[e.id]?.decision??null,text:t.target.value}}})),rows:2,disabled:f,placeholder:`Optional notes`,style:{minHeight:42,resize:`vertical`}})]},e.id)),(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:f||!il(n.questions,c),onClick:()=>void g(),children:u?`Submitting…`:`Submit answers`})]}):null]})}function xl(e){return e===void 0||e<=1?null:`×${e}`}function Sl({count:e}){let t=xl(e);return t?(0,q.jsx)(`span`,{className:`chip chip--attempt`,"aria-label":`${e} attempts`,children:t}):null}function Cl(e){return e.label??e.path.split(`/`).pop()??e.path}function wl({files:e,selectedPath:t,onSelect:n,title:r=`Files`,footer:i}){return(0,q.jsxs)(`aside`,{className:`aside`,style:{height:`100%`},children:[(0,q.jsx)(`header`,{className:`aside__head`,children:(0,q.jsx)(`h4`,{style:{margin:0,fontSize:`var(--font-size-base)`,fontWeight:600},children:r})}),(0,q.jsx)(`nav`,{className:`aside__body`,children:e.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{padding:`var(--spacing-3) var(--spacing-4)`,fontSize:`var(--font-size-sm)`},children:`No files yet.`}):(0,q.jsx)(`div`,{className:`files`,children:e.map(e=>(0,q.jsxs)(`button`,{className:`files__row`,"data-selected":e.path===t?`true`:void 0,onClick:n?()=>n(e.path):void 0,children:[Cl(e),e.meta?(0,q.jsx)(`span`,{children:e.meta}):null]},e.path))})}),i?(0,q.jsx)(`footer`,{className:`aside__foot`,children:i}):null]})}var Tl=s({Tooltip:()=>Ol});function El(e){return typeof e==`string`||typeof e==`number`}function Dl(...e){let t=e.filter(Boolean);return t.length>0?t.join(` `):void 0}function Ol({children:e,anchorRef:t,content:n,placement:r=`above`,alignment:i=`center`,delay:a=200,hideDelay:o=0,focusTrigger:s=`auto`,isEnabled:c=!0,onOpenChange:l,hasHoverIndication:u=`auto`,isOpen:d,isDefaultOpen:f}){let p=(0,v.useRef)(null),m=e!=null&&El(e),h=u===!0||u===`auto`&&m,g=Aa({placement:r,alignment:i,delay:a,hideDelay:o,focusTrigger:s,isEnabled:c,isOpen:d,isDefaultOpen:f,onShow:(0,v.useCallback)(()=>{l?.(!0)},[l]),onHide:(0,v.useCallback)(()=>{l?.(!1)},[l])});return y(()=>{if(!t)return;let e=t.current;if(!e)return;g.ref(e);let n=e.getAttribute(`aria-describedby`);return e.setAttribute(`aria-describedby`,Dl(n,g.describedBy)??``),()=>{g.ref(null),n?e.setAttribute(`aria-describedby`,n):e.removeAttribute(`aria-describedby`)}},[t,g.ref,g.describedBy]),y(()=>{if(t||m)return;let e=p.current;if(!e)return;let n=e.firstElementChild;if(!n)return;g.ref(n);let r=n.getAttribute(`aria-describedby`);return n.setAttribute(`aria-describedby`,Dl(r,g.describedBy)??``),()=>{g.ref(null),r?n.setAttribute(`aria-describedby`,r):n.removeAttribute(`aria-describedby`)}},[t,m,g.ref,g.describedBy]),t&&e==null?(0,q.jsx)(q.Fragment,{children:g.renderTooltip(n)}):m?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{ref:g.ref,tabIndex:0,"aria-describedby":g.describedBy,...{0:{className:`xt0psk2`},1:{className:`xt0psk2 xujl8zx xev0dqp xycaml9 xrys4gj`}}[!!h<<0],children:e}),g.renderTooltip(n)]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{ref:p,className:`xjp7ctv`,children:e}),g.renderTooltip(n)]})}Ol.displayName=`Tooltip`;var kl=`button:not([disabled]), a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], iframe, details > summary:first-child`,Al=[];function jl(e){Al.push(e)}function Ml(e){for(let t=Al.length-1;t>=0;t--)if(Al[t].handler===e){Al.splice(t,1);return}}function Nl(e){if(Al.length===0)return!1;let t=Al[0];for(let e=1;e<Al.length;e++){let n=Al[e],r=t.getContainer(),i=n.getContainer();r!=null&&i!=null&&i!==r&&i.contains(r)||(t=n)}return t.handler===e}function Pl(e){return e.isComposing===!0||e.keyCode===229}function Fl(e){if(e.hasAttribute(`inert`)||e.closest(`[inert]`)||e.hidden||e.closest(`[hidden]`)||e.closest(`[aria-hidden="true"]`))return!1;if(typeof window<`u`&&window.getComputedStyle){let t=window.getComputedStyle(e);if(t.visibility===`hidden`||t.display===`none`)return!1}return!0}function Z(e){return Array.from(e.querySelectorAll(kl)).filter(Fl)}function Il(e){try{e.focus()}catch{}return document.activeElement===e}function Ll(e){let t=Z(e);for(let e of t)if(Il(e))return!0;return!1}function Rl(e){let t=Z(e);for(let e=t.length-1;e>=0;e--)if(Il(t[e]))return!0;return!1}function zl(e){let{isActive:t,onEscape:n}=e,r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(!1),o=(0,v.useCallback)(()=>{r.current&&Ll(r.current)},[]);return(0,v.useEffect)(()=>{if(!t)return;let e=document.activeElement,n=r.current;return()=>{let t=document.activeElement;(t==null||t===document.body||t===document.documentElement||n!=null&&n.contains(t))&&e!=null&&e.isConnected&&typeof e.focus==`function`&&e.focus()}},[t]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{let t=r.current;if(!t)return;let n=e.target;t.contains(n)?i.current=n:a.current&&(Ll(t),i.current===document.activeElement&&Rl(t),i.current=document.activeElement),a.current=!1};return document.addEventListener(`focus`,e,!0),()=>{document.removeEventListener(`focus`,e,!0)}},[t]),(0,v.useEffect)(()=>{if(!t)return;let e=()=>{n?.()};n&&jl({handler:e,getContainer:()=>r.current});let i=t=>{let i=r.current;if(i){if(t.key===`Escape`&&n){if(t.defaultPrevented||Pl(t)||!Nl(e))return;t.preventDefault(),t.stopPropagation(),n();return}if(t.key===`Tab`){a.current=!0;let e=Z(i);if(e.length===0)return;let n=e[0],r=e[e.length-1];t.shiftKey?document.activeElement===n&&(t.preventDefault(),r.focus()):document.activeElement===r&&(t.preventDefault(),n.focus())}}};return document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`keydown`,i),n&&Ml(e)}},[t,n]),{containerRef:r,focusFirst:o}}function Bl(e){return!e||typeof window>`u`?!1:window.getComputedStyle(e).direction===`rtl`}var Vl=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`]);function Hl(e){if(e.isContentEditable)return e;let t=e.closest(`[contenteditable]`);return t&&t.getAttribute(`contenteditable`)!==`false`?t:null}function Ul(e,t){if(!(e instanceof HTMLElement))return!1;let n=Hl(e);if(n){let e=typeof window<`u`?window.getSelection():null;return e&&e.rangeCount>0&&!e.isCollapsed?!0:(n.textContent??``).length>0}let r=e.tagName===`TEXTAREA`,i=e.tagName===`INPUT`&&Vl.has(e.type);if(!r&&!i)return!1;let{selectionStart:a,selectionEnd:o,value:s}=e;return a!==o||a==null?!0:t===`ArrowLeft`||t===`ArrowUp`||t===`Home`?a>0:t===`ArrowRight`||t===`ArrowDown`||t===`End`?a<s.length:!1}function Wl(e={}){let{itemSelector:t=`[role="menuitem"]`,boundarySelector:n,wrap:r=!0,onEscape:i,orientation:a=`vertical`,hasHomeEnd:o=!0,isRtl:s,hasRovingTabIndex:c=!1,hasCaretGuard:l=!1}=e,u=(0,v.useRef)(null),d=(0,v.useCallback)(e=>e.getAttribute(`aria-disabled`)===`true`||e.disabled===!0||e.hasAttribute(`disabled`),[]),f=(0,v.useCallback)(()=>{let e=u.current;if(!e)return[];let r=Array.from(e.querySelectorAll(t));return n?r.filter(t=>t.closest(n)===e):r},[t,n]),p=(0,v.useCallback)(e=>{let t=u.current;if(!t||!n)return!0;let r=e.target;return!r||r.closest(n)===t},[n]),m=(0,v.useCallback)((e,t,n,r)=>{let i=e.length;if(i===0)return-1;let a=t;for(let t=0;t<i;t++){if(a<0||a>=i){if(!r)return-1;a=(a+i)%i}let t=e[a];if(t&&!d(t))return a;a+=n}return-1},[d]),h=(0,v.useCallback)(()=>{let e=f(),t=document.activeElement;return e.findIndex(e=>e===t||e.contains(t))},[f]),g=(0,v.useCallback)((e,t)=>{e.getAttribute(`tabindex`)!==String(t)&&e.setAttribute(`tabindex`,String(t))},[]),_=(0,v.useCallback)(()=>{let e=f(),t=e.filter(e=>!d(e));if(t.length===0)return;let n=t.find(e=>e.getAttribute(`tabindex`)===`0`)??t[0];for(let t of e)g(t,t===n?0:-1)},[f,d,g]);y(()=>{c&&_()});let b=(0,v.useCallback)((e,t)=>{let n=e[t];if(n){if(c)for(let t of e)g(t,t===n?0:-1);n.focus()}},[c,g]),x=(0,v.useCallback)(e=>{let t=f();if(t.length===0)return;let n=Math.max(0,Math.min(e,t.length-1));b(t,n)},[f,b]),S=(0,v.useCallback)(()=>{let e=f(),t=m(e,0,1,!1);return t!==-1&&(b(e,t),!0)},[f,m,b]),C=(0,v.useCallback)(()=>{let e=f(),t=m(e,e.length-1,-1,!1);return t!==-1&&(b(e,t),!0)},[f,m,b]),w=(0,v.useCallback)(()=>{c&&_()},[c,_]);return{listRef:u,handleKeyDown:(0,v.useCallback)(e=>{if(e.ctrlKey||e.metaKey||e.altKey||!p(e))return;if(e.key===`Escape`){e.preventDefault(),i?.();return}let t=a===`horizontal`||a===`both`,n=a===`vertical`||a===`both`,c=[],d=[];if(t){let t=e.key===`ArrowLeft`||e.key===`ArrowRight`?s??Bl(u.current):!1;c.push(t?`ArrowLeft`:`ArrowRight`),d.push(t?`ArrowRight`:`ArrowLeft`)}n&&(c.push(`ArrowDown`),d.push(`ArrowUp`));let g=c.includes(e.key),_=d.includes(e.key),v=o&&e.key===`Home`,y=o&&e.key===`End`;if(!g&&!_&&!v&&!y||l&&(Ul(e.target,e.key)||Ul(document.activeElement,e.key)))return;let x=h(),w=f();if(g){let e=x===-1?0:x+1,t=m(w,e,1,r);t!==-1&&b(w,t)}else if(_){let e=x===-1?w.length-1:x-1,t=m(w,e,-1,r);t!==-1&&b(w,t)}else v?S():y&&C();e.preventDefault()},[h,f,r,a,s,o,l,m,b,S,C,i,p]),handleFocus:w,focusItem:x,focusFirst:S,focusLast:C,ownsEvent:p,getItems:f}}function Gl(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&e.key!==` `}function Kl(e){let{getItemLabels:t,onMatch:n,getCurrentIndex:r,resetMs:i=750,isDisabled:a}=e,o=(0,v.useRef)(``),s=(0,v.useRef)(void 0),c=(0,v.useCallback)(()=>{o.current=``,s.current&&=(clearTimeout(s.current),void 0)},[]),l=(0,v.useCallback)(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current=``,s.current=void 0},i)},[i]);return{onKeyDown:(0,v.useCallback)(e=>{let i=e.key===` `&&!e.ctrlKey&&!e.metaKey&&o.current.length>0;if(!Gl(e)&&!i)return!1;let s=t();if(s.length===0)return!1;let c=e.key.toLowerCase(),u=o.current.length>0&&o.current.split(``).every(e=>e===c)?c:o.current+c;o.current=u,l();let d=r?.()??-1,f=s.length,p=d>=0,m=p?d:0,h=p&&u.length===1?1:0;for(let e=0;e<f;e++){let t=(m+h+e+f)%f;if(a?.(t))continue;let r=s[t];if(r!=null&&r.trim().toLowerCase().startsWith(u))return n(t),!0}return!0},[t,n,r,l,a]),reset:c}}function ql(e,t,n=!0){let r=(0,v.useRef)(!1);(0,v.useEffect)(()=>{n&&!r.current&&(r.current=!0)},[e,t,n])}var Jl=!1;typeof window<`u`&&requestAnimationFrame(()=>{Jl=!0});var Yl={slideDown:{kKVMdj:`x1srr2gu x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},slideUp:{kKVMdj:`x1dvww92 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},fadeIn:{kKVMdj:`xqcmdr3 x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0},scaleIn:{kKVMdj:`x97zbip x1aquc0h`,k44tkh:`x9uej1z`,kyAemX:`x128ha8g`,kWV6AL:`xskzprw`,$$css:!0}};function Xl(e=`slideDown`){let[t]=(0,v.useState)(()=>Jl);return t?Yl[e]:null}var Zl=50,Ql=8;function $l(e){let t=e.match(/^([\d.]+)ms$/);if(t)return parseFloat(t[1]);let n=e.match(/^([\d.]+)s$/);return n?parseFloat(n[1])*1e3:null}var eu={natural:10,fast:4,instant:1/0},tu=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function nu(e){return e>=56320&&e<=57343}function ru(e,t){return t<=0||t>=e.length?t:tu?tu.segment(e).containing(t)?.index??t:nu(e.charCodeAt(t))?t-1:t}function iu(e,t,n){let r=n?.speed??`natural`,i=eu[r],{token:a}=mt(),o=(0,v.useMemo)(()=>{if(r===`instant`)return 0;let e=$l(a(`--duration-fast-min`));if(e==null)return r===`fast`?Ql:Zl;let t=r===`fast`?e/20:e/10;return Math.max(4,Math.round(t))},[a,r]),[s,c]=(0,v.useState)(0),l=(0,v.useRef)(e),u=(0,v.useRef)(0),d=(0,v.useRef)(0),f=(0,v.useRef)(null);l.current=e;let p=(0,v.useRef)(e.length);e.length!==p.current&&(p.current=e.length,e.length===0&&s!==0&&(u.current=0,c(0)));let m=(0,v.useRef)(t);t!==m.current&&(m.current=t,!t&&e.length>0&&(u.current=e.length,c(e.length)));let h=Ye(`(prefers-reduced-motion: reduce)`);return(0,v.useEffect)(()=>{if(!t||r===`instant`||h)return;function e(t){if(t-d.current>=o){d.current=t;let e=l.current,n=u.current;if(n<e.length){let t=Math.min(n+i,e.length);u.current=t,c(t)}}f.current=requestAnimationFrame(e)}return f.current=requestAnimationFrame(e),()=>{f.current!==null&&(cancelAnimationFrame(f.current),f.current=null)}},[t,i,o,r,h]),!t||r===`instant`||h?e:e.slice(0,ru(e,s))}var au=[`button`,`a`,`input`,`select`,`textarea`,`[role="button"]`,`[role="link"]`,`[role="checkbox"]`,`[role="radio"]`,`[role="switch"]`,`[role="tab"]`,`[role="menuitem"]`,`[role="option"]`,`[role="combobox"]`,`[role="listbox"]`,`[role="slider"]`,`[role="spinbutton"]`,`[data-pressable-container]`].join(`,`),ou=`[aria-readonly="true"]`;function su(e,t){let n=e;for(;n!=null&&n!==t&&n!==document.body;){if(n.matches(au)&&!n.matches(ou))return!0;n=n.parentElement}return!1}function cu(e){if(typeof document>`u`||!(`getSelection`in document))return!1;let t=document.getSelection();return t==null||t.isCollapsed?!1:e.contains(t.anchorNode)}function lu({containerRef:e,interactiveRef:t,onClick:n,href:r,target:i,disabled:a=!1}){return(0,v.useEffect)(()=>{let t=e.current;t&&t.setAttribute(`data-pressable-container`,`true`)},[e]),{onClick:(0,v.useCallback)(o=>{if(a)return;let s=e.current;if(!s||cu(s))return;let c=o.target;if(c instanceof Element&&!(c!==o.currentTarget&&su(c,s))&&(n?.(o),!o.defaultPrevented&&(r!=null&&(i===`_blank`||o.ctrlKey||o.metaKey?window.open(r,`_blank`,`noopener`):t?.current?t.current.click():window.location.href=r),r==null&&n==null&&t?.current))){let e=new MouseEvent(`click`,{bubbles:o.bubbles,cancelable:o.cancelable,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey,altKey:o.altKey,button:o.button});t.current.dispatchEvent(e),o.stopPropagation()}},[e,t,n,r,i,a]),onMouseUp:(0,v.useCallback)(t=>{if(a)return;let n=e.current;if(!n)return;let i=t.target;i instanceof Element&&t.button===1&&r!=null&&(i===t.currentTarget||!su(i,n))&&window.open(r,`_blank`,`noopener`)},[e,r,a])}}var uu=new Set([`text`,`password`,`email`,`number`,`search`,`tel`,`url`,`date`,`datetime-local`,`month`,`time`,`week`]),du=new Set([`true`,`menu`,`listbox`,`tree`,`grid`,`dialog`]);function fu(e){if(e.getAttribute(`role`)===`combobox`)return!0;let t=e.getAttribute(`aria-haspopup`);return t!=null&&du.has(t)}function pu({containerRef:e,inputRef:t,disabled:n=!1}){return lu({containerRef:e,interactiveRef:t,onClick:(0,v.useCallback)(()=>{let e=t.current;e!=null&&(e instanceof HTMLElement&&fu(e)?e.click():e instanceof HTMLInputElement&&uu.has(e.type)||e instanceof HTMLTextAreaElement?e.focus():e instanceof HTMLElement?e.click():`focus`in e&&e.focus())},[t]),disabled:n})}var mu=500,hu=10;function gu(e){let{onLongPress:t,disabled:n=!1,delayMs:r=mu,moveCancelPx:i=hu}=e,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(t);s.current=t;let c=(0,v.useCallback)(()=>{a.current!=null&&(clearTimeout(a.current),a.current=null),o.current=null},[]),l=(0,v.useCallback)(e=>{if(n)return;if(e.touches.length!==1){c();return}let t=e.touches[0];c(),o.current={x:t.clientX,y:t.clientY},a.current=setTimeout(()=>{let e=o.current;e!=null&&s.current({x:e.x,y:e.y})},r)},[n,r,c]),u=(0,v.useCallback)(e=>{let t=o.current;if(t==null)return;if(e.touches.length!==1){c();return}let n=e.touches[0];(Math.abs(n.clientX-t.x)>i||Math.abs(n.clientY-t.y)>i)&&c()},[i,c]);return(0,v.useEffect)(()=>c,[c]),{onTouchStart:l,onTouchMove:u,onTouchEnd:c,onTouchCancel:c}}function _u(e,t=!1){let n=(0,v.useCallback)(t=>{let n=e.current?.firstElementChild;n instanceof HTMLElement&&Object.assign(n.style,t?mo:ho)},[e]),r=(0,v.useCallback)(e=>{if(t)return;let r=e.target;r instanceof HTMLElement&&!r.matches(`:focus-visible`)||n(!0)},[t,n]),i=(0,v.useCallback)(()=>n(!1),[n]);return(0,v.useMemo)(()=>({focusProps:{onFocus:r,onBlur:i}}),[r,i])}var vu={label:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`xzye2dw`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kLWn49:`x1kq96og`,k63SB2:`x1e4wzip`,kMwMTN:`xv1l7n4`,kkrTdU:`x1ypdohk`,$$css:!0},labelDisabled:{kMwMTN:`xnbbluu`,kkrTdU:`x1h6gzvc`,$$css:!0},srOnly:{ksu8eU:`xng3xce`,kMcinP:`xzpqnlu`,kZKoxP:`xjm9jq1`,kLqNvP:`x1o0tod`,kogj98:`xkdpibf`,kVQacm:`xb3r6kr`,kmVPX3:`x1717udv`,kfzvcC:`x47corl`,kVAEAm:`x10l6tqk`,k87sOh:`x13vifvy`,kfSwDN:`x87ps6o`,khDVqt:`xuxw1ft`,kzqmXN:`x1i1rx1s`,$$css:!0}};function yu({label:e,inputID:t,labelID:n,isGroupLabel:r=!1,isLabelHidden:i=!1,isDisabled:a=!1,isOptional:o=!1,isRequired:s=!1,labelIcon:c,labelTooltip:l,description:u,descriptionID:d,className:f,style:p,xstyle:m,ref:h,...g}){let _=Gs(),y=o?_(`@astryx.field.optional`):s?_(`@astryx.field.required`):null,b=r?`span`:`label`,x=!r&&t!=null,S=(0,v.useRef)(null),C=pu({containerRef:S,inputRef:(0,v.useMemo)(()=>({get current(){return t==null?null:S.current?.ownerDocument.getElementById(t)??null},set current(e){}}),[t]),disabled:!x}),T=(0,q.jsxs)(q.Fragment,{children:[c&&ma(c,{size:`sm`,color:`inherit`}),e,y&&(0,q.jsxs)(`span`,{className:`x1sodnla x141an7d x1ltkj2j xv1l7n4`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:` ∙ `}),y]}),l&&(0,q.jsx)(Ol,{content:l,placement:`above`,children:(0,q.jsx)(fa,{icon:`info`,size:`sm`,color:`inherit`})})]});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(b,{ref:h,id:n,htmlFor:r?void 0:t,...g,...J(Y(`field-label`),w(vu.label,a&&vu.labelDisabled,i&&vu.srOnly,m),f,p),children:T}),u&&(0,q.jsx)(`span`,{ref:x?S:void 0,id:d,...x?C:void 0,...{0:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4`},2:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk`},1:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`},3:{className:`x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 x1ypdohk xng3xce xzpqnlu xjm9jq1 x1o0tod xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s`}}[!!x<<1|!!i<<0],children:u})]})}yu.displayName=`FieldLabel`;var bu={warning:`warning`,error:`error`,success:`success`},xu={base:{kMv6JI:`x9ynric`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},attached:{keoZOQ:`x1c40v9y`,kLKAdn:`x1ak3mig`,kGO01o:`x1wesfrj`,kg3NbH:`xf314gf`,kVL7Gh:`xquck67`,kT0f0o:`x14i3lts`,$$css:!0},detached:{keoZOQ:`xcsaf9d`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`xh6dtrn`,$$css:!0}},Su={warning:{kWkggS:`x24i8r5`,kMwMTN:`xdhq94a`,$$css:!0},error:{kWkggS:`x1pritpl`,kMwMTN:`x1joocv1`,$$css:!0},success:{kWkggS:`xu13z74`,kMwMTN:`xltfdvo`,$$css:!0}};function Cu({ref:e,type:t,message:n,id:r,variant:i=`attached`,xstyle:a,className:o,style:s,...c}){let l=Xl(`slideDown`),u=Qi();return(0,v.useEffect)(()=>{n&&u(n,t===`error`?`assertive`:`polite`)},[u,n,t]),(0,q.jsx)(`div`,{ref:e,id:r,...c,...J(Y(`field-status`,{type:t,variant:i}),w(xu.base,l,i===`attached`?xu.attached:xu.detached,Su[t],a),o,s),children:i===`detached`?(0,q.jsxs)(`span`,{className:`x78zum5 x1cy8zhl xzye2dw`,children:[(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 x14o5nre x2lah0s`,children:(0,q.jsx)(fa,{icon:bu[t],size:`sm`,color:`inherit`,...Y(`field-status-icon`,{type:t})})}),(0,q.jsx)(`span`,{children:n})]}):n})}Cu.displayName=`FieldStatus`;var wu=(0,v.createContext)({direction:`vertical`});wu.displayName=`FormLayoutContext`;var Tu={container:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},containerGap:{kOIVth:`xzye2dw`,$$css:!0},horizontalLabels:{k1xSpc:`xjp7ctv`,$$css:!0}},Eu={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function Du({label:e,isLabelHidden:t=!1,description:n,inputID:r,labelID:i,isGroupLabel:a=!1,descriptionID:o,isOptional:s=!1,isRequired:c=!1,isDisabled:l=!1,labelIcon:u,status:d,labelTooltip:f,statusVariant:p=`attached`,width:m,xstyle:h,children:g,className:_,style:y,ref:b,...x}){let{direction:S}=(0,v.use)(wu),C=S===`horizontal-labels`,T=o??(n?`${r}-desc`:void 0),E=d?.messageID??(d?.message?`${r}-status`:void 0);ql(`Field`,`isOptional and isRequired are mutually exclusive. isOptional takes precedence.`,s&&c);let D=(0,q.jsx)(yu,{label:e,inputID:r,labelID:i,isGroupLabel:a,isLabelHidden:t,isDisabled:l,isOptional:s,isRequired:c,labelIcon:u,labelTooltip:f,description:C?void 0:n,descriptionID:C?void 0:T}),O=d?.message&&p!==`tooltip`?(0,q.jsx)(Cu,{type:d.type,message:d.message,id:E,variant:p}):null;return C?(0,q.jsxs)(`div`,{ref:b,...J(Y(`field`,{layout:`horizontal-labels`}),w(Tu.horizontalLabels,h),_,y),...x,children:[(0,q.jsx)(`div`,{className:`x1enrzb7`,children:D}),(0,q.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[n&&(0,q.jsx)(eo,{type:`supporting`,display:`block`,id:T,children:n}),g,O]})]}):(0,q.jsxs)(`div`,{ref:b,...J(Y(`field`),w(Tu.container,!t&&Tu.containerGap,m!=null&&Eu.width(m),h),_,y),...x,children:[D,p===`attached`?(0,q.jsxs)(`div`,{className:`x78zum5 xdt5ytf xc8icb0`,children:[g,O]}):(0,q.jsxs)(q.Fragment,{children:[g,O]})]})}Du.displayName=`Field`;var Ou=(0,v.createContext)(null);Ou.displayName=`ListContext`;var ku={list:{kogj98:`x1ghz6dp`,kZCmMZ:`x1c1uobl`,kH6xsr:`x3ct3a4`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,$$css:!0},withDividers:{kOIVth:`xxhr3t`,$$css:!0},withCounter:{kt6KFK:`xif0320`,$$css:!0}},Au={kt6KFK:`x1khind5`,$$css:!0},ju={counterStart:e=>[Au,{"--x-counterReset":`astryx-list ${e}`==null?void 0:`astryx-list ${e}`}]};function Mu({children:e,density:t=`balanced`,hasDividers:n=!1,header:r,listStyle:i=`none`,start:a,xstyle:o,className:s,style:c,"data-testid":l,ref:u}){let d=(0,v.useId)(),f=i===`decimal`,p=f?`ol`:`ul`,m=(0,v.useMemo)(()=>({density:t,hasDividers:n,listStyle:i}),[t,n,i]),h=(0,q.jsx)(p,{ref:u,"data-testid":l,"aria-labelledby":r==null?void 0:d,...f&&a!=null&&a!==1?{start:a}:{},role:`list`,...J(Y(`list`,{density:t,listStyle:i}),w(ku.list,n&&ku.withDividers,i!==`none`&&(a!=null&&a!==1?ju.counterStart(a-1):ku.withCounter),o),s,c),children:e});return r==null?(0,q.jsx)(Ou,{value:m,children:h}):(0,q.jsx)(Ou,{value:m,children:(0,q.jsxs)(`div`,{className:`x78zum5 xdt5ytf`,children:[(0,q.jsx)(`div`,{id:d,className:`x1p37lm5`,children:r}),h]})})}Mu.displayName=`List`;var Nu=(0,v.createContext)(null);Nu.displayName=`CheckboxListContext`;var Pu=[];function Fu({label:e,isLabelHidden:t=!1,description:n,status:r,value:i,onChange:a,changeAction:o,density:s=`balanced`,hasDividers:c=!1,isDisabled:l=!1,disabledMessage:u,isReadOnly:d=!1,children:f,ref:p,width:m,xstyle:h,className:g,style:_,"data-testid":y,...b}){let x=(0,v.useId)(),S=(0,v.useId)(),C=(0,v.useId)(),w=(0,v.useId)(),[,T]=(0,v.useTransition)(),E=i!==void 0,[D,O]=(0,v.useOptimistic)(i??Pu),[k,A]=(0,v.useOptimistic)(null),j=l&&!!u,M=Aa({placement:`above`,focusTrigger:`always`,isEnabled:j}),N=(0,v.useCallback)((e,t)=>{a?.(e),o&&T(async()=>{O(e),t!==void 0&&A(t),await o(e)})},[a,o,T,O,A]),P=(0,v.useMemo)(()=>({value:E?D:void 0,onChange:E?N:void 0,isDisabled:l,hasDisabledMessage:j,isReadOnly:d,loadingValue:k}),[E,D,N,l,j,d,k]);return(0,q.jsxs)(Du,{...b,ref:p,"data-testid":y,label:e,isLabelHidden:t,description:n,inputID:x,labelID:S,isGroupLabel:!0,descriptionID:n?C:void 0,isDisabled:l,status:r?{type:r.type,message:r.message,messageID:r.message?w:void 0}:void 0,statusVariant:`detached`,width:m,xstyle:h,...J(Y(`checkbox-list`),{className:g,style:_}),children:[(0,q.jsx)(Nu,{value:P,children:(0,q.jsx)(`div`,{ref:e=>{M.ref(e)},role:`group`,"aria-labelledby":S,"aria-describedby":[n?C:null,r?.message?w:null,j?M.describedBy:null].filter(Boolean).join(` `)||void 0,children:(0,q.jsx)(Mu,{density:s,hasDividers:c,children:f})})}),j&&M.renderTooltip(u)]})}Fu.displayName=`CheckboxList`;var Iu={x1odsvnm:`x1odsvnm`,$$css:!0},Lu={box:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kaIpWk:`xx3sua9`,k1ekBW:`xts7igz`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},unchecked:{kMwMTN:`xqwr325`,kVAM5u:`xvy26l8 xilc7fp`,kWkggS:`x10xzikg xeultfy`,$$css:!0},checked:{kMwMTN:`x17wrial`,kVAM5u:`xad5do x1ozl1p1`,kWkggS:`x1ewilqj x17srpfb`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kVAM5u:`x14i3s5s x61roa7`,$$css:!0},disabledUnchecked:{kWkggS:`xwmxj5m xqxnq6d`,$$css:!0},checkmark:{k1xSpc:`x1s85apg`,kMwMTN:`x17wrial xs5hli`,$$css:!0},checkmarkVisible:{k1xSpc:`x1lliihq`,$$css:!0},indeterminateMark:{k1xSpc:`x1s85apg`,kWkggS:`x1azo05 xwvh9j7`,kaIpWk:`xjspbzw`,$$css:!0},indeterminateMarkVisible:{k1xSpc:`x1lliihq`,$$css:!0}},Ru={sm:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`xvy4d1p`,kZKoxP:`xxk0z11`,$$css:!0}},zu={sm:{kzqmXN:`xsmyaan`,kZKoxP:`x1kpxq89`,$$css:!0},md:{kzqmXN:`x6jxa94`,kZKoxP:`x1v9usgg`,$$css:!0}},Bu={sm:{kzqmXN:`x1fsd2vl`,kZKoxP:`x36qwtl`,$$css:!0},md:{kzqmXN:`xsmyaan`,kZKoxP:`x36qwtl`,$$css:!0}};function Vu({state:e,size:t=`md`,isDisabled:n=!1,children:r,ref:i,className:a,style:o,xstyle:s,...c}){let l=e===`checked`,u=e===`indeterminate`,d=l||u;return(0,q.jsx)(`span`,{...c,ref:i,"aria-hidden":`true`,...J(Y(`checkbox-indicator`,{size:t,checked:l?`checked`:u?`indeterminate`:null,disabled:n?`disabled`:null},{legacyNames:[`checkbox`]}),w(Lu.box,Ru[t],d?Lu.checked:Lu.unchecked,n&&Lu.disabled,n&&!d&&Lu.disabledUnchecked,s),a,o),children:Ri(r)?r:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`svg`,{viewBox:`0 0 10 10`,...w(Lu.checkmark,zu[t],l&&Lu.checkmarkVisible),children:(0,q.jsx)(`path`,{d:`M8.5 2.5L4 7.5L1.5 5`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,q.jsx)(`span`,{...w(Lu.indeterminateMark,Bu[t],u&&Lu.indeterminateMarkVisible)})]})})}Vu.displayName=`CheckboxIndicator`;var Hu={sm:`sm`,md:`sm`},Uu={slot:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kzqmXN:`xcdlrvm`,kZKoxP:`x1l36t39`,$$css:!0},enabled:{kMwMTN:`xqwr325`,$$css:!0},disabled:{kMwMTN:`xqa6c3m`,$$css:!0}};function Wu({state:e,size:t=`md`,isDisabled:n=!1,children:r,ref:i,className:a,style:o,xstyle:s,...c}){let l=e===`checked`;return Ri(r)?(0,q.jsx)(`span`,{...c,ref:i,"aria-hidden":`true`,...J(w(Uu.slot,n?Uu.disabled:Uu.enabled,s),a,o),children:r}):l?(0,q.jsx)(fa,{...c,"aria-hidden":`true`,icon:`check`,size:Hu[t],color:n?`disabled`:`accent`,xstyle:s,className:a,style:o}):null}Wu.displayName=`CheckIndicator`;var Gu={circle:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kaIpWk:`xjspbzw`,k1ekBW:`xts7igz`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},unchecked:{kVAM5u:`xvy26l8 xilc7fp`,kWkggS:`x10xzikg xeultfy`,$$css:!0},checked:{kVAM5u:`xad5do x1ozl1p1`,kWkggS:`x1ewilqj x17srpfb`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kVAM5u:`x14i3s5s x61roa7`,$$css:!0},disabledUnchecked:{kWkggS:`xwmxj5m xqxnq6d`,$$css:!0},dot:{kaIpWk:`xjspbzw`,kWkggS:`x1azo05 xwvh9j7`,$$css:!0}},Ku={sm:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`xvy4d1p`,kZKoxP:`xxk0z11`,$$css:!0}},qu={sm:{kzqmXN:`x1xc55vz`,kZKoxP:`xdk7pt`,$$css:!0},md:{kzqmXN:`x1fsd2vl`,kZKoxP:`x170jfvy`,$$css:!0}};function Ju({state:e,size:t=`md`,isDisabled:n=!1,children:r,ref:i,className:a,style:o,xstyle:s,...c}){let l=e!==`unchecked`;return(0,q.jsx)(`span`,{...c,ref:i,"aria-hidden":`true`,...J(Y(`radio-indicator`,{size:t,checked:l?`checked`:null,disabled:n?`disabled`:null},{legacyNames:[`radio`]}),w(Gu.circle,Ku[t],l?Gu.checked:Gu.unchecked,n&&Gu.disabled,n&&!l&&Gu.disabledUnchecked,s),a,o),children:Ri(r)?r:l&&(0,q.jsx)(`span`,{...J(Y(`radio-indicator-dot`,{size:t},{legacyNames:[`radio-dot`]}),w(Gu.dot,qu[t]))})})}Ju.displayName=`RadioIndicator`;var Yu={check:Wu,checkbox:Vu,radio:Ju};function Xu(e){return e==null?null:typeof e==`string`?ce(e):e}function Zu(e){return Xu(e)?.indicators??null}function Qu(e,t){return Zu(t)?.[e]??Yu[e]}function $u(e){return Qu(e,pt())}var ed={container:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,$$css:!0},containerLabelHidden:{kOIVth:`xxhr3t`,$$css:!0},checkboxWrapper:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kHBbk8:`xc8icb0`,$$css:!0},input:{kVAEAm:`x10l6tqk`,kogj98:`x1ghz6dp`,kmVPX3:`x1717udv`,kSiTet:`xg01cxk`,kkrTdU:`x1ypdohk`,kY2c9j:`x1vjfegm`,$$css:!0},inputDisabled:{kkrTdU:`x1h6gzvc`,$$css:!0}},td={sm:{kzqmXN:`xw4jnvo`,kZKoxP:`x1qx5ct2`,$$css:!0},md:{kzqmXN:`xvy4d1p`,kZKoxP:`xxk0z11`,$$css:!0}},nd={width:e=>[{kzqmXN:e==null?e:`x5lhr3w`,$$css:!0},{"--x-width":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]};function rd({label:e,isLabelHidden:t=!1,description:n,onChange:r,changeAction:i,isLoading:a=!1,value:o,isDisabled:s=!1,htmlName:c,disabledMessage:l,isReadOnly:u=!1,isOptional:d=!1,isRequired:f=!1,size:p=`md`,onFocus:m,onBlur:h,labelIcon:g,status:_,width:y,xstyle:b,className:x,style:S,ref:C,...T}){let E=(0,v.useId)(),D=(0,v.useId)(),O=(0,v.useId)(),[,k]=(0,v.useTransition)(),[A,j]=(0,v.useOptimistic)(o),M=a||A!==o,N=s&&!!l,P=(0,v.use)(Nu),F=s&&(N||(P?.hasDisabledMessage??!1)),I=Aa({placement:`above`,focusTrigger:`always`,isEnabled:N}),L=$u(`checkbox`),R=(0,v.useRef)(null),{focusProps:z}=_u(R,s),B=A===`indeterminate`,V=A===!0,H=(0,v.useCallback)(e=>{e&&(e.indeterminate=B)},[B]),U=[];n&&U.push(D),_?.message&&U.push(O),N&&U.push(I.describedBy);let W=U.length>0?U.join(` `):void 0;return(0,q.jsxs)(`div`,{...J(Y(`checkbox-input`,{size:p}),w(y!=null&&nd.width(y),b),x,S),children:[(0,q.jsxs)(`div`,{ref:e=>{I.interactionRef(e)},...w(ed.container,t&&ed.containerLabelHidden,!s&&Iu),children:[(0,q.jsxs)(`div`,{...w(ed.checkboxWrapper,td[p]),...z,children:[(0,q.jsx)(`input`,{...T,ref:Ei(C,H,I.positionRef),id:E,type:`checkbox`,name:s?void 0:c,checked:V,disabled:s&&!F,"aria-disabled":F?`true`:void 0,form:F?``:void 0,readOnly:u,required:f,onChange:e=>{if(s||M||u)return;let t=e.target.checked;r?.(t,e),i&&!e.defaultPrevented&&k(async()=>{j(t),await i(t,e)})},onFocus:m,onBlur:h,"aria-readonly":u||void 0,"aria-describedby":W,"aria-invalid":_?.type===`error`||void 0,"aria-busy":M||void 0,...w(ed.input,td[p],s&&ed.inputDisabled)}),(0,q.jsx)(`span`,{ref:R,className:`xjp7ctv`,children:(0,q.jsx)(L,{state:B?`indeterminate`:V?`checked`:`unchecked`,size:p,isDisabled:s,children:M?(0,q.jsx)(ro,{size:`sm`,shade:`inherit`}):null})})]}),(0,q.jsx)(`div`,{className:`x78zum5 xdt5ytf x1lsbc85`,children:(0,q.jsx)(yu,{label:e,inputID:E,isLabelHidden:t,isDisabled:s,isOptional:d,isRequired:f,labelIcon:g,description:n,descriptionID:D})})]}),_?.message&&(0,q.jsx)(Cu,{type:_.type,message:_.message,id:O,variant:`detached`}),N&&I.renderTooltip(l)]})}rd.displayName=`CheckboxInput`;var id=[`noopener`,`noreferrer`];function ad(e,t){if(e!==`_blank`)return{target:e,rel:t};let n=t?.split(/\s+/).filter(Boolean)??[];for(let e of id)n.includes(e)||n.push(e);return{target:e,rel:n.join(` `)}}var od=new Set([`option`,`tab`,`row`,`gridcell`,`columnheader`,`rowheader`,`treeitem`]),sd={root:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1txdalj`,kg3NbH:`xf314gf`,kVAEAm:`x1n2onr6`,kB7OPa:`x9f619`,k9WMMc:`x1yc453h`,kaIpWk:`xh6dtrn`,$$css:!0},alignStart:{kGNEyG:`x1cy8zhl`,$$css:!0},interactive:{kkrTdU:`x1ypdohk`,k1ekBW:`x15406qy`,kIyJzY:`xkvfbh3`,kAMwcw:`xlr8y92`,kWkggS:`xjbqb8w xe9uy6x xyxi2l3`,$$css:!0},highlighted:{kWkggS:`x1lmrjuc`,$$css:!0},selected:{kWkggS:`xgcxg3y`,$$css:!0},disabled:{kkrTdU:`x1h6gzvc`,kfzvcC:`x47corl`,$$css:!0},label:{kMwMTN:`x5tbw38`,kGuDYH:`xjm74w1`,kLWn49:`xw6l6zx`,$$css:!0},labelSingleTruncate:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,$$css:!0},labelMultiTruncate:{kVQacm:`xb3r6kr`,k1xSpc:`x104kibb`,kgKLqz:`x1ua5tub`,$$css:!0},description:{kMwMTN:`x1gb3s7i`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,$$css:!0},descriptionSingleTruncate:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,$$css:!0},descriptionMultiTruncate:{kVQacm:`xb3r6kr`,k1xSpc:`x104kibb`,kgKLqz:`x1ua5tub`,$$css:!0}},cd={lineClamp:e=>[{kJFfOR:e==null?e:`x1yhjpo9`,$$css:!0},{"--x-WebkitLineClamp":e??void 0}]},ld={compact:{k8WAf4:`xu0wf1k`,$$css:!0},balanced:{k8WAf4:`xce4md1`,$$css:!0},spacious:{k8WAf4:`x8o8v82`,kg3NbH:`xrrkdod`,$$css:!0}};function ud({as:e=`div`,marker:t,startContent:n,label:r,description:i,endContent:a,align:o=`center`,density:s=`balanced`,labelLines:c,descriptionLines:l,onClick:u,interactiveRef:d,href:f,target:p,rel:m,isHighlighted:h=!1,isSelected:g=!1,isDisabled:_=!1,xstyle:y,className:b,style:x,ref:S,role:C,...T}){let E=po(),D=d!=null,O=(0,v.useRef)(null),{onClick:k}=lu({containerRef:O,interactiveRef:d??void 0,disabled:_});ql(`Item`,"`interactiveRef` is mutually exclusive with `onClick`/`href`. In delegation mode the row only forwards clicks to the referenced control, so `onClick`/`href` are ignored. Drop one of them.",D&&(u!=null||f!=null));let A=u!=null||f!=null||D,{target:j,rel:M}=ad(p,m),N=C!=null,P=C!=null&&od.has(C),F=typeof r==`string`,I=typeof i==`string`,L=c==null?F?sd.labelSingleTruncate:null:c===1?sd.labelSingleTruncate:sd.labelMultiTruncate,R=l==null?I?sd.descriptionSingleTruncate:null:l===1?sd.descriptionSingleTruncate:sd.descriptionMultiTruncate,z=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{...w(sd.label,L,c!=null&&c>1&&cd.lineClamp(c)),children:r}),i!=null&&(0,q.jsx)(`span`,{...w(sd.description,R,l!=null&&l>1&&cd.lineClamp(l)),children:i})]}),B=e=>{_||e.target.closest(`button, a, input, select, textarea`)||u?.(e)},V=(0,q.jsxs)(q.Fragment,{children:[t,n!=null&&(0,q.jsx)(`span`,{className:`x3psx0u x78zum5`,children:n}),N||D?(0,q.jsx)(`span`,{...{0:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h`},1:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo`}}[!!_<<0],children:z}):f==null?u==null?(0,q.jsx)(`span`,{...{0:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h`},1:{className:`x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h xbyyjgo`}}[!!_<<0],children:z}):(0,q.jsx)(`button`,{type:`button`,onClick:u,disabled:_,...{0:{className:`xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz`},1:{className:`xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1a2a7pz xbyyjgo`}}[!!_<<0],children:z}):(0,q.jsx)(E,{href:f,target:j,rel:M,"aria-disabled":_||void 0,tabIndex:_?-1:void 0,...{0:{className:`xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz`},1:{className:`xmper1u xln7xf2 x1heor9g x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h x1hl2dhg x1a2a7pz xbyyjgo`}}[!!_<<0],children:z}),a!=null&&(0,q.jsx)(`span`,{...{0:{className:`x3psx0u x78zum5 xvc5jky`},1:{className:`x3psx0u x78zum5 xvc5jky xbyyjgo`}}[!!_<<0],children:a})]});return(0,q.jsx)(e,{ref:D?Ei(S,O):S,...T,"aria-selected":P&&g||void 0,"aria-current":T[`aria-current`]??(g&&!P?!0:void 0),"aria-disabled":_||void 0,...J(Y(`item`,{density:s,align:o}),vo.focusWithin(sd.root,ld[s],o===`start`&&sd.alignStart,A&&sd.interactive,h&&sd.highlighted,g&&sd.selected,_&&!N&&sd.disabled,y),b,x),role:C,onClick:D?k:N?u:A?B:void 0,children:V})}ud.displayName=`Item`;var dd={withCounter:{kAmcRD:`xfrknyr`,$$css:!0},withDivider:{kt9PQ7:`x92x3c3`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},fd={noRadius:{kaIpWk:`x2u8bby`,$$css:!0}};function pd({label:e,description:t,startContent:n,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l=!1,isSelected:u=!1,xstyle:d,className:f,style:p,ref:m,...h}){let g=(0,v.use)(Ou),_=g?.density??`balanced`,y=g?.hasDividers??!1,b=g?.listStyle??`none`;return(0,q.jsx)(ud,{as:`li`,ref:m,marker:b===`disc`?(0,q.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,q.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct x19aspcf`})}):b===`circle`?(0,q.jsx)(`span`,{className:`xoi2r2e x9f619 x78zum5 x6s0dn4 xl56j7k x2lah0s x12xnipv x1233pnv`,children:(0,q.jsx)(`span`,{className:`x1v4s8kt xols6we x16rqkct xmkeg23 x1y0btm7 xqcx1ss xjbqb8w`})}):b===`decimal`?(0,q.jsx)(`span`,{className:`xoi2r2e x2lah0s x1tgivj0 xjm74w1 xw6l6zx x12xnipv xc2ndz5`}):null,startContent:n,label:e,description:t,endContent:r,onClick:i,interactiveRef:a,href:o,target:s,rel:c,isDisabled:l,isSelected:u,density:_,xstyle:[b!==`none`&&dd.withCounter,y&&dd.withDivider,y&&fd.noRadius,d],...J(Y(`list-item`),{className:f,style:p}),...h})}pd.displayName=`ListItem`;var md={selected:{kWkggS:`xgcxg3y`,$$css:!0}};function hd({label:e,"aria-label":t,value:n,description:r,endContent:i,isDisabled:a=!1,isLoading:o=!1,isChecked:s,onCheck:c,ref:l,xstyle:u,className:d,style:f,onClick:p,...m}){let h=Gs(),g=(0,v.use)(Nu);if(g&&g.value!==void 0&&n===void 0)throw Error("CheckboxListItem requires a `value` prop when used inside CheckboxList with a value array.");let _=t??(typeof e==`string`?e:h(`@astryx.checkboxList.item.checkbox`));ql(`CheckboxListItem`,'`label` is a ReactNode, so the checkbox falls back to the generic accessible name "Checkbox". Pass `aria-label` with a concise string equivalent of the visible label so screen readers can tell items apart.',typeof e!=`string`&&t==null);let y=((0,v.use)(Ou)?.density??`balanced`)===`compact`?`sm`:`md`,b=(g?.isDisabled??!1)||a,x=g?.isReadOnly??!1,S=o||g?.loadingValue!=null&&n!==void 0&&g.loadingValue===n,C=!1;g&&g.value!==void 0&&n!==void 0?C=g.value.includes(n):s!==void 0&&(C=s);let w=!x&&(g!=null||c!=null),T=(0,v.useRef)(null),E=w||p!=null,D=()=>{b||x||S||(g&&g.value!==void 0&&n!==void 0?g.value.includes(n)?g.onChange?.(g.value.filter(e=>e!==n),n):g.onChange?.([...g.value,n],n):c?.(C!==!0))};return(0,q.jsx)(pd,{...m,ref:l,label:e,description:r,endContent:i,isDisabled:b,interactiveRef:E?T:void 0,"aria-busy":S||void 0,xstyle:[C===!0&&!b&&!x&&md.selected,u],className:d,style:f,startContent:(0,q.jsx)(rd,{ref:T,label:_,isLabelHidden:!0,value:C,onChange:()=>D(),onClick:p,isDisabled:b,isReadOnly:x,isLoading:S,size:y})})}hd.displayName=`CheckboxListItem`;var gd={root:{k2ei4v:`xtpqe59`,kVhnKS:`x1t7ytsu`,kGJrpR:`x14ydlgx`,kZCmMZ:`x1rey3nv`,kMwMTN:`xv1l7n4`,keTefX:`x1lziwak`,k71WvV:`x14z9mp`,keoZOQ:`xdj266r`,k1K539:`xat24cr`,$$css:!0}};function _d({children:e,cite:t,xstyle:n,className:r,style:i,ref:a,...o}){return(0,q.jsxs)(`blockquote`,{ref:a,...J(Y(`blockquote`),w(gd.root,n),r,i),...o,children:[e,t!=null&&(0,q.jsx)(`footer`,{children:(0,q.jsx)(`cite`,{className:`x1lliihq xtbrsbv x141an7d x1ltkj2j x1j61x8r`,children:t})})]})}_d.displayName=`Blockquote`;function vd(e){let t=0,n=0,r=[];for(let i of e){let e=i.width;if(e?.type===`pixel`)n+=e.value;else{let n=e?.value??1,a=e==null?0:e.minWidth??120;t+=n,r.push({key:i.key,proportion:n,minWidth:a})}}let i=0;if(t>0)for(let e of r){let n=e.minWidth*t/e.proportion;n>i&&(i=n)}let a=n+i,o=new Map;for(let n of e){let e=n.width,r={};if(e?.type===`pixel`)r.width=`${e.value}px`,r.minWidth=`${e.value}px`;else{let n=e?.value??1;t>0&&(r.width=`${n/t*100}%`),e!=null&&(r.minWidth=`${e.minWidth??120}px`)}o.set(n.key,{style:r})}return{columns:o,tableMinWidth:a}}function yd(e=1,t){return{type:`proportional`,value:e,minWidth:t?.minWidth??120}}function bd(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function xd(e,t){let n=e[t];return n==null?``:n instanceof Date?n.toISOString():typeof n==`string`||typeof n==`number`||typeof n==`boolean`||typeof n==`bigint`?String(n):``}function Sd(e){return e==null?0:typeof e==`string`?e.length:typeof e==`number`||typeof e==`boolean`?String(e).length:0}function Cd(e){if(e==null||typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)return 0;let t=String(e),n=0,r=0;for(let e=0;e<=t.length;e++)e===t.length||t[e]===` `||t[e]===` `||t[e]===`
|
|
101
|
+
`?(r>n&&(n=r),r=0):r++;return n}var wd=60,Td=8;function Ed(e){if(e.length===0)return[];let t=e[0],n=Object.keys(t),r=e.slice(0,Math.min(5,e.length));return n.map(e=>{let t=bd(e).length,n=t,i=t;for(let t of r){let r=Sd(t[e]);r>n&&(n=r);let a=Cd(t[e]);a>i&&(i=a)}return{key:e,headerLen:t,maxContentLen:n,maxWordLen:i}}).map(e=>{let t=e.maxContentLen<=6?1:e.maxContentLen<=15?2:3,n=Math.max(Math.max(e.headerLen,e.maxWordLen)*Td,wd);return{key:e.key,header:bd(e.key),width:yd(t,{minWidth:n})}})}var Dd={x139im0d:`x139im0d`,$$css:!0},Od={cell:{kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,ks0D6T:`x1m189uc`,$$css:!0}},kd={cell:{kVQacm:`xb3r6kr`,kHjlTd:`x1mzt3pk`,kTgw9:`x13faqbe`,ks0D6T:`x1m189uc`,$$css:!0}},Ad={compact:{kZCmMZ:`x5uh4xs`,kwRFfy:`xbg7gas`,$$css:!0},balanced:{kZCmMZ:`x9bi00s`,kwRFfy:`xpilulx`,$$css:!0},spacious:{kZCmMZ:`x18c6q21`,kwRFfy:`x1wzlfcn`,$$css:!0}},jd=(0,v.createContext)(null);jd.displayName=`TableContext`;var Md={row:{kWkggS:`x1dnou9g`,"--table-row-overlay":`x1rht92`,$$css:!0}},Nd={row:{kWkggS:`xe9uy6x`,"--table-row-overlay":`x1pkcbo2`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0}},Pd={row:{kWkggS:`x1dnou9g xe9uy6x`,"--table-row-overlay":`x1rht92 x1pkcbo2`,k1ekBW:`x15406qy`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0}};function Fd({children:e,xstyle:t,ref:n,isHeaderRow:r=!1,...i}){let a=(0,v.use)(jd);if(!a)return(0,q.jsx)(`tr`,{ref:n,...i,...J(Y(`table-row`),w(Dd,t)),children:e});let o=[];return r||(a.isStriped&&a.hasHover?o.push(Pd.row):a.isStriped?o.push(Md.row):a.hasHover&&o.push(Nd.row)),a.dividers===`rows`||a.dividers,t&&o.push(...t),(0,q.jsx)(`tr`,{ref:n,...i,...J(Y(`table-row`),w(Dd,...o)),children:e})}Fd.displayName=`TableRow`;var Id=(0,v.createContext)(null);Id.displayName=`DropdownMenuContext`;function Ld(){return(0,v.use)(Id)}var Rd=(0,v.createContext)(null);Rd.displayName=`DropdownMenuRadioGroupContext`;function zd(){return(0,v.use)(Rd)}function Bd(e,t){if(t||e.pointerType!==`mouse`)return;let n=e.currentTarget;n!==n.ownerDocument.activeElement&&n.focus()}var Vd={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kkrTdU:`x1ypdohk`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`x1h6gzvc`,$$css:!0},destructive:{kMwMTN:`xjt36v0`,"--_item-label-color":`xufyqxy`,"--_item-description-color":`xqlix59`,$$css:!0}},Hd={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}};function Ud({icon:e,label:t,description:n,onClick:r,isDisabled:i=!1,endContent:a,hasCloseOnSelect:o=!0,variant:s=`default`,xstyle:c,className:l,style:u}){let d=Ld(),f=d?.menuSize??`md`,p=(0,v.useCallback)(()=>{i||(r?.(),o&&d?.closeMenu())},[i,r,o,d]),m=(0,v.useCallback)(e=>Bd(e,i),[i]),h=s===`destructive`;return(0,q.jsx)(ud,{role:`menuitem`,tabIndex:i?void 0:-1,onPointerMove:m,startContent:e?ma(e,{size:`sm`,color:h?`error`:`secondary`}):void 0,label:t,description:n,endContent:a,onClick:p,isDisabled:i,xstyle:[Vd.root,Hd[f],h&&Vd.destructive,i&&Vd.disabled,c],...J(Y(`dropdown-menu-item`,{size:f,variant:h?`destructive`:null}),{className:l,style:u})})}Ud.displayName=`DropdownMenuItem`;var Wd={horizontal:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kzqmXN:`xh8yej3`,$$css:!0},vertical:{k1xSpc:`x3nfvp2`,kXwgrk:`xdt5ytf`,kGNEyG:`x6s0dn4`,kZKoxP:`x5yr21d`,$$css:!0}},Gd={horizontalLine:{kZKoxP:`xsyqizj`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,$$css:!0},verticalLine:{kzqmXN:`xjk4fl7`,kzQI83:`x1iyjqo2`,kmuXW:`xs83m0k`,$$css:!0},subtle:{kWkggS:`x1m4xfpy`,$$css:!0},strong:{kWkggS:`x7njt3n`,$$css:!0}},Kd={horizontal:{keTefX:`xojxgvx`,k71WvV:`x1fcf3bl`,kzqmXN:`xx6qvi6`,$$css:!0},vertical:{keoZOQ:`x1sa9bsh`,k1K539:`x6h7pi7`,kZKoxP:`x12qplqi`,$$css:!0}};function qd({orientation:e=`horizontal`,label:t,variant:n=`subtle`,isFullBleed:r=!1,xstyle:i,className:a,style:o,ref:s,"aria-label":c,"aria-labelledby":l,...u}){let d=e===`horizontal`,f=(0,v.useId)(),p=l??(t&&c==null?f:void 0);return(0,q.jsxs)(`div`,{ref:s,...u,role:`separator`,"aria-orientation":e,"aria-label":c,"aria-labelledby":p,...J(Y(`divider`,{variant:n,orientation:e}),w(d?Wd.horizontal:Wd.vertical,r&&(d?Kd.horizontal:Kd.vertical),i),a,o),children:[(0,q.jsx)(`div`,{...w(d?Gd.horizontalLine:Gd.verticalLine,Gd[n])}),t&&(0,q.jsx)(`div`,{id:f,...{0:{className:`x2lah0s xrrkdod x141an7d x1ltkj2j xv1l7n4`},1:{className:`x2lah0s x141an7d x1ltkj2j xv1l7n4 xnjsko4 x8o8v82`}}[!d<<0],children:t}),t&&(0,q.jsx)(`div`,{...w(d?Gd.horizontalLine:Gd.verticalLine,Gd[n])})]})}qd.displayName=`Divider`;var Jd={divider:{kqGvvJ:`xsq74q5`,$$css:!0}},Yd=Y(`dropdown-menu-divider`).className;function Xd({xstyle:e,className:t,style:n,ref:r}){return(0,q.jsx)(qd,{ref:r,xstyle:[Jd.divider,e],className:t?`${Yd} ${t}`:Yd,style:n})}Xd.displayName=`DropdownMenuDivider`;function Zd(e){let{show:t,hide:n,isOpen:r,isEnabled:i,showDelay:a=150,hideDelay:o=200}=e,s=Ye(`(hover: hover)`),c=(0,v.useRef)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(!1),f=(0,v.useRef)(!1),p=(0,v.useRef)(r);p.current&&!r&&(d.current=!1),p.current=r;let m=(0,v.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null)},[]),{listRef:h,handleKeyDown:g,focusFirst:_}=Wl({onEscape:()=>{m(),n()}});(0,v.useEffect)(()=>()=>m(),[m]);let y=(0,v.useCallback)(()=>{m(),r?(f.current=!0,n()):(f.current=!1,t(),requestAnimationFrame(()=>_()))},[r,m,t,n,_]),b=(0,v.useCallback)(()=>{if(s){if(f.current){f.current=!1;return}d.current=!0,m(),a>0?c.current=setTimeout(()=>{t({skipAutoFocus:!0})},a):t({skipAutoFocus:!0})}},[s,m,t,a]),x=(0,v.useCallback)(()=>{d.current&&(m(),l.current=setTimeout(()=>{n()},o))},[m,n,o]),S=(0,v.useCallback)(()=>{m()},[m]),C=(0,v.useCallback)(e=>{u.current=e},[]),w=(0,v.useCallback)(()=>{},[]),T=(0,v.useCallback)(e=>{},[]),E=(0,v.useCallback)(e=>{},[]);return i?{triggerProps:{onClick:y,onMouseEnter:b,onMouseLeave:x},contentProps:{onMouseEnter:S,onMouseLeave:x,onKeyDown:g},menuRef:h,focusFirst:_,setTriggerEl:C}:{triggerProps:{onClick:w,onMouseEnter:w,onMouseLeave:w},contentProps:{onMouseEnter:w,onMouseLeave:w,onKeyDown:E},menuRef:h,focusFirst:_,setTriggerEl:T}}var Qd=new Set([`menuitem`,`menuitemradio`,`menuitemcheckbox`]),$d=[...Qd].map(e=>`[role="${e}"]:not([aria-disabled="true"])`).join(`,`),ef=`[role="menu"]`,tf={root:{kB7OPa:`x9f619`,kzqmXN:`xh8yej3`,k8WAf4:`xce4md1`,kg3NbH:`xf314gf`,kaIpWk:`x1ws5lxm`,kMv6JI:`x9ynric`,kGuDYH:`xcr08ib`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kkrTdU:`x1ypdohk`,k9WMMc:`x1yc453h`,kI3sdo:`x1a2a7pz`,$$css:!0},open:{kWkggS:`x1lmrjuc`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`x1h6gzvc`,$$css:!0}},nf={sm:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},md:{k8WAf4:`x1vofgu7`,$$css:!0},lg:{$$css:!0}},rf={popover:{k7Eaqz:`x5w4yej`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}]};function af(e){let{icon:t,label:n,description:r,isDisabled:i=!1,hasSpinner:a=!1,menuWidth:o,onOpenChange:s,children:c,xstyle:l,className:u,style:d,"data-testid":f,menuDataTestId:p}=e,m=Ld(),h=m?.menuSize??`md`,g=!i,_=(0,v.useId)(),y=(0,v.useId)(),b=(0,v.useRef)(null),[x,S]=(0,v.useState)(!1),C=Ta({mode:`context`,lightDismiss:!1,onShow:(0,v.useCallback)(()=>{S(!0),s?.(!0)},[s]),onHide:(0,v.useCallback)(()=>{S(!1),s?.(!1)},[s])}),w=(0,v.useCallback)(()=>{g&&C.show()},[g,C]),T=(0,v.useCallback)(()=>{C.hide()},[C]),{listRef:E,handleKeyDown:D,focusFirst:k,focusItem:A,ownsEvent:j,getItems:M}=Wl({itemSelector:$d,boundarySelector:ef,wrap:!1,onEscape:()=>L({focusTrigger:!0})}),N=Kl({getItemLabels:()=>M().map(e=>e.textContent),onMatch:A,getCurrentIndex:()=>M().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))}),{triggerProps:P,contentProps:F}=Zd({show:w,hide:T,isOpen:x,isEnabled:g}),I=(0,v.useCallback)(e=>{g&&(C.show(),e?.focusFirst&&requestAnimationFrame(()=>{k()||E.current?.focus()}))},[g,C,k,E]),L=(0,v.useCallback)(e=>{C.hide(),e?.focusTrigger!==!1&&b.current?.focus()},[C]),R=(0,v.useCallback)(e=>{b.current=e,C.ref(e)},[C]),z=(0,v.useCallback)(()=>{i||(x?L({focusTrigger:!0}):I({focusFirst:!0}))},[i,x,I,L]),B=(0,v.useCallback)(e=>{if(i)return;let t=typeof window<`u`&&b.current&&window.getComputedStyle(b.current).direction===`rtl`?`ArrowLeft`:`ArrowRight`;(e.key===t||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),I({focusFirst:!0}))},[i,I]),V=(0,v.useCallback)(e=>Bd(e,i),[i]),H=(0,v.useCallback)(e=>{if(!j(e))return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),L({focusTrigger:!0});return}if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=document.activeElement;t&&Qd.has(t.getAttribute(`role`)??``)&&t.click();return}let t=typeof window<`u`&&E.current&&window.getComputedStyle(E.current).direction===`rtl`?`ArrowRight`:`ArrowLeft`;if(e.key===t){e.preventDefault(),L({focusTrigger:!0});return}if(N.onKeyDown(e)){e.preventDefault();return}D(e)},[j,L,D,N,E]),U=(0,v.useMemo)(()=>({menuSize:h,closeMenu:()=>{L({focusTrigger:!1}),m?.closeMenu()}}),[h,L,m]),W=a?(0,q.jsx)(`span`,{...J(Y(`dropdown-menu-indicator-icon`),{className:`x78zum5 x6s0dn4`}),children:(0,q.jsx)(ro,{size:`sm`})}):(0,q.jsx)(`span`,{...J(Y(`dropdown-menu-indicator-icon`),{className:`x78zum5 x6s0dn4`}),children:(0,q.jsx)(fa,{icon:`chevronRight`,size:`sm`,color:`secondary`})}),ee=o?rf.popoverCustomWidth(o):rf.popover;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ud,{ref:e=>R(e),id:y,role:`menuitem`,tabIndex:i?void 0:-1,"aria-haspopup":`menu`,"aria-expanded":x,"aria-controls":x?_:void 0,"aria-disabled":i||void 0,"data-testid":f,onMouseEnter:P.onMouseEnter,onMouseLeave:P.onMouseLeave,onPointerMove:V,startContent:t?ma(t,{size:`sm`,color:`secondary`}):void 0,label:n,description:r,endContent:W,onClick:z,onKeyDown:B,isDisabled:i,xstyle:[tf.root,nf[h],x&&tf.open,i&&tf.disabled,l],...J(Y(`dropdown-menu-item`,{size:h}),{className:u,style:d})}),C.render((0,q.jsx)(`div`,{ref:E,id:_,role:`menu`,tabIndex:-1,"aria-labelledby":y,onKeyDown:H,onMouseEnter:F.onMouseEnter,onMouseLeave:F.onMouseLeave,"data-testid":p,...J(Y(`dropdown-menu`),{className:`x9f619 x78zum5 xdt5ytf x1lsbc85 xuyqlj2 x1odjw0f x1fcsqxe xgory14 x9epnlk x1n97fys x1prclbq x1i5ehqx x1hc1fzr x19991ni xuedmi6 xlr8y92`}),children:(0,q.jsx)(Id,{value:U,children:c})}),{placement:`end`,alignment:`start`,offset:O[`--spacing-1`],xstyle:[ee,Ea.end]})]})}af.displayName=`DropdownMenuSubMenu`;function of(e,t){return`item-${e.id??t}`}function sf(e,t){return`section-${e.id??t}`}function cf(e,t){let{items:n,id:r,...i}=e;return(0,q.jsx)(Ud,{...i},of(e,t))}function lf(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];`type`in r&&r.type===`divider`?t.push((0,q.jsx)(Xd,{},`divider-${n}`)):`type`in r&&r.type===`section`?t.push((0,q.jsxs)(`div`,{role:`group`,"aria-label":r.title,children:[r.title&&(0,q.jsx)(`div`,{"aria-hidden":`true`,...J(Y(`dropdown-menu-section-heading`),{className:`xu0wf1k xf314gf x9ynric x141an7d x1ltkj2j xv1l7n4 x87ps6o`}),children:r.title}),r.items.map(cf)]},sf(r,n))):`type`in r||(r.items&&r.items.length>0?t.push((0,q.jsx)(af,{icon:r.icon,label:r.label,isDisabled:r.isDisabled,children:lf(r.items)},of(r,n))):t.push(cf(r,n)))}return t}var uf={trigger:{kVAEAm:`x1n2onr6`,k7VYTy:`xpdipgo`,$$css:!0},menu:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kskxy:`xuyqlj2`,kORKVm:`x1odjw0f`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kmVPX3:`x9epnlk`,kaIpWk:`x1n97fys`,kWkggS:`x1prclbq`,kGVxlE:`x1i5ehqx`,kSiTet:`x1hc1fzr`,k1ekBW:`x19991ni`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,kfSwDN:`x87ps6o`,$$css:!0},popover:{k7Eaqz:`x5w4yej`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}]};function df({children:e,menuWidth:t,size:n=`md`,label:r,isDisabled:i=!1,onOpenChange:a,ref:o,className:s,style:c,xstyle:l,triggerXstyle:u,"data-testid":d,...f}){let p=Gs(),m=r??p(`@astryx.contextMenu.label`),{items:h,menuContent:g,..._}=f,y=h??[],b=g,x=(0,v.useId)(),S=(0,v.useRef)({x:0,y:0}),C=(0,v.useRef)(null),T=(0,v.useRef)(null),E=(0,v.useRef)(null),[D,O]=(0,v.useState)(!1),k=Ta({mode:`context`,onHide:(0,v.useCallback)(()=>{O(!1),a?.(!1);let e=E.current;E.current=null,e&&document.contains(e)&&e.focus()},[a]),onShow:(0,v.useCallback)(()=>{O(!0),a?.(!0)},[a]),lightDismiss:!1}),A=(0,v.useCallback)(()=>{k.hide()},[k]),{listRef:j,handleKeyDown:M,focusFirst:N,focusItem:P,ownsEvent:F,getItems:I}=Wl({itemSelector:$d,boundarySelector:ef,wrap:!1,onEscape:A}),L=Kl({getItemLabels:()=>I().map(e=>e.textContent),onMatch:P,getCurrentIndex:()=>I().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))});(0,v.useEffect)(()=>{if(!D)return;let e=e=>{let t=j.current;t&&!t.contains(e.target)&&A()};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[D,A,j]),(0,v.useEffect)(()=>{if(!D)return;let e=e=>{e.key===`Escape`&&(e.isComposing||e.keyCode===229||(e.preventDefault(),A()))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[D,A]);let R=(0,v.useCallback)(e=>{if(F(e)){if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=document.activeElement;t&&Qd.has(t.getAttribute(`role`)??``)&&t.click();return}if(e.key===`Tab`){A();return}if(L.onKeyDown(e)){e.preventDefault();return}M(e)}},[M,A,L,F]),z=(0,v.useCallback)((e,t,n)=>{S.current={x:e,y:t};let r=C.current;r&&(r.style.left=`${e}px`,r.style.top=`${t}px`),E.current=document.activeElement instanceof HTMLElement?document.activeElement:n,k.show(),requestAnimationFrame(()=>N())},[k,N]),B=(0,v.useCallback)(e=>{if(i)return;e.preventDefault();let t=T.current?.getBoundingClientRect(),n=e.clientX===0&&e.clientY===0&&e.detail===0,r=n||!t?0:e.clientX-t.left,a=n||!t?t?.height??0:e.clientY-t.top;z(r,a,e.currentTarget)},[i,z]),V=gu({disabled:i,onLongPress:(0,v.useCallback)(e=>{let t=T.current?.getBoundingClientRect();z(t?e.x-t.left:e.x,t?e.y-t.top:e.y,T.current)},[z])}),H=t?uf.popoverCustomWidth(t):uf.popover,U=(0,v.useMemo)(()=>({closeMenu:A,menuSize:n}),[A,n]),W=h===void 0?b:lf(y);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{ref:Ei(o,T),..._,onContextMenu:B,...V,"data-testid":d,...w(uf.trigger,...u?Array.isArray(u)?u:[u]:[]),children:[e,(0,q.jsx)(`span`,{ref:Ei(C,k.ref),"aria-hidden":`true`,...J({className:`x10l6tqk xnalus7 xqtp20y x47corl`},{style:{left:`${S.current.x}px`,top:`${S.current.y}px`}})})]}),k.render((0,q.jsx)(`div`,{ref:j,id:x,role:`menu`,"aria-label":m,onKeyDown:R,onContextMenu:e=>e.preventDefault(),...J(Y(`context-menu`),w(uf.menu,l),s,c),children:(0,q.jsx)(Id,{value:U,children:W})}),{placement:`below`,alignment:`start`,xstyle:[H,Ea.below]})]})}df.displayName=`ContextMenu`;function ff({value:e,onChange:t,label:n,hasCloseOnSelect:r=!0,children:i,className:a,style:o,...s}){let c=(0,v.useMemo)(()=>({value:e,onChange:t,hasCloseOnSelect:r}),[e,t,r]);return(0,q.jsx)(`div`,{...s,role:`group`,"aria-label":n,...J({className:`x78zum5 xdt5ytf x1lsbc85`},{className:a,style:o}),children:(0,q.jsx)(Rd,{value:c,children:i})})}ff.displayName=`DropdownMenuRadioGroup`;var pf={root:{kzqmXN:`xh8yej3`,kaIpWk:`x1ws5lxm`,kMwMTN:`x1tgivj0`,kWkggS:`xjbqb8w x1c52tdz`,kkrTdU:`x1ypdohk`,kI3sdo:`x1a2a7pz`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kkrTdU:`x1h6gzvc`,$$css:!0},marker:{kfzvcC:`x47corl`,kayTVb:`x1g77sc7 xozvky`,keTefX:`x1lziwak x1jymrmb`,$$css:!0}};function mf({value:e,label:t,description:n,icon:r,isDisabled:i=!1,endContent:a,xstyle:o,className:s,style:c,...l}){let u=Ld(),d=zd();if(!d)throw Error(`DropdownMenuRadioItem must be used within a DropdownMenuRadioGroup`);let f=u?.menuSize??`md`,p=f===`sm`?`sm`:`md`,m=d.value===e,h=$u(`radio`),g=(0,v.useCallback)(()=>{i||(d.onChange(e),d.hasCloseOnSelect&&u?.closeMenu())},[i,d,e,u]),_=(0,v.useCallback)(e=>Bd(e,i),[i]);return(0,q.jsx)(ud,{...l,role:`menuitemradio`,"aria-checked":m,tabIndex:i?void 0:-1,onPointerMove:_,marker:(0,q.jsx)(h,{state:m?`checked`:`unchecked`,size:p,isDisabled:i,xstyle:pf.marker,...Y(`dropdown-menu-radio`,{size:p,checked:m?`checked`:null,disabled:i?`disabled`:null})}),startContent:r?ma(r,{size:`sm`,color:`secondary`}):void 0,label:t,description:n,endContent:a,onClick:g,isDisabled:i,xstyle:[pf.root,i&&pf.disabled,o],...J(Y(`dropdown-menu-item`,{size:f}),{className:s,style:c})})}mf.displayName=`DropdownMenuRadioItem`;function hf(e){let t=[],n=new Map;for(let r of e){let e=r.group??`__ungrouped__`,i=n.get(e);i||(i=[],n.set(e,i),t.push(e)),i.push(r)}let r=[];return t.forEach((e,t)=>{t>0&&r.push({type:`divider`});for(let t of n.get(e)??[])r.push({label:typeof t.label==`string`?t.label:t.id,icon:t.checked?(0,q.jsx)(fa,{icon:`check`,size:`xsm`,"aria-hidden":!0}):t.icon,isDisabled:t.disabled,onClick:t.onSelect,variant:t.variant})}),r}function gf({element:e,getActions:t,triggerXstyle:n}){let[r,i]=(0,v.useState)(null);return(0,q.jsx)(df,{items:r??[],triggerXstyle:n,onOpenChange:e=>{i(e?hf(t()):null)},children:e})}function _f(e,t,n){return typeof t==`function`?(0,q.jsx)(gf,{element:e,getActions:t,triggerXstyle:n}):!t||t.length===0?e:(0,q.jsx)(df,{items:hf(t),triggerXstyle:n,children:e})}function vf(e,t,n){let r=[];return(e.dividers===`rows`||e.dividers===`grid`)&&r.push(t),(e.dividers===`columns`||e.dividers===`grid`)&&r.push(n),r}function yf(e,t){return t?Array.isArray(t)?[...e,...t]:[...e,t]:e}function bf(){return(0,v.use)(jd)}var xf={compact:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0},balanced:{k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0},spacious:{k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0}},Sf={compact:{kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0},balanced:{kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0},spacious:{kGuDYH:`xjm74w1`,kB7OPa:`x9f619`,$$css:!0}},Cf={compact:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,$$css:!0},balanced:{k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,$$css:!0},spacious:{k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0}},wf={fill:{k1xSpc:`x1lliihq`,kB7OPa:`x9f619`,kZKoxP:`x5yr21d`,kzqmXN:`xh8yej3`,$$css:!0}},Tf={cell:{kZKoxP:`x5yr21d`,$$css:!0}},Ef={cell:{kt9PQ7:`x92x3c3 x1wp2rvj`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},Df={cell:{ke9TFa:`xw8tdv1 x1qlsc9e`,k8ry5P:`x18b5jzi`,kBCPoo:`x1gejf6u`,$$css:!0}},Of={middle:{kXLuUW:`xxymvpz`,$$css:!0},top:{kXLuUW:`x16dsc37`,$$css:!0},bottom:{kXLuUW:`x3ajldb`,$$css:!0}};function kf({children:e,xstyle:t,ref:n,className:r,style:i,contextMenuActions:a,...o}){let s=bf(),c=typeof a==`function`||Array.isArray(a)&&a.length>0,l=s?[c?Sf[s.density]:xf[s.density],s.textOverflow===`truncate`?Od.cell:kd.cell,Ad[s.density],Of[s.verticalAlign],...vf(s,Ef.cell,Df.cell),...c?[Tf.cell]:[]]:[],u=_f(e,a,c&&s?[wf.fill,Cf[s.density]]:c?wf.fill:void 0);return(0,q.jsx)(`td`,{ref:n,...o,...J(Y(`table-cell`,{density:s?.density}),w(...yf(l,t)),r,i),children:u})}kf.displayName=`TableCell`;var Af={compact:{k8WAf4:`xu0wf1k`,kg3NbH:`xf314gf`,kGuDYH:`xcr08ib`,kB7OPa:`x9f619`,$$css:!0},balanced:{k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,kGuDYH:`xcr08ib`,kB7OPa:`x9f619`,$$css:!0},spacious:{k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,kGuDYH:`xcr08ib`,kB7OPa:`x9f619`,$$css:!0}},jf={cell:{k63SB2:`x2mo6ok`,kMwMTN:`xv1l7n4`,k9WMMc:`x1yc453h`,$$css:!0}},Mf={cell:{kt9PQ7:`x92x3c3`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xw8gpjh`,$$css:!0}},Nf={cell:{ke9TFa:`xw8tdv1 x1qlsc9e`,k8ry5P:`x18b5jzi`,kBCPoo:`x1gejf6u`,$$css:!0}};function Pf({children:e,xstyle:t,ref:n,className:r,style:i,contextMenuActions:a,...o}){let s=bf(),c=[];s&&(c.push(jf.cell,Af[s.density],Mf.cell,Od.cell,Ad[s.density]),(s.dividers===`columns`||s.dividers===`grid`)&&c.push(Nf.cell));let l=_f(e,a);return(0,q.jsx)(`th`,{ref:n,...o,...J(Y(`table-header-cell`,{density:s?.density}),w(...yf(c,t)),r,i),children:l})}Pf.displayName=`TableHeaderCell`;function Ff({ref:e,children:t,xstyle:n,className:r,style:i,...a}){return(0,q.jsx)(`thead`,{ref:e,...J(Y(`table-header`),w(n),r,i),...a,children:t})}Ff.displayName=`TableHeader`;function If({ref:e,children:t,xstyle:n,className:r,style:i,...a}){return(0,q.jsx)(`tbody`,{ref:e,...J(Y(`table-body`),w(n),r,i),...a,children:t})}If.displayName=`TableBody`;var Lf={container:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,k9WMMc:`x2b8uid`,kOIVth:`x18g69wz`,k8WAf4:`xmfvnks`,kg3NbH:`xm7rs69`,$$css:!0},containerCompact:{kOIVth:`x1txdalj`,k8WAf4:`x1na6nto`,kg3NbH:`x1pzlopt`,$$css:!0}};function Rf({title:e,description:t,icon:n,actions:r,headingLevel:i=3,isCompact:a=!1,xstyle:o,className:s,style:c,ref:l,...u}){let d=`h${i}`;return(0,q.jsxs)(`div`,{ref:l,...u,role:`status`,...J(Y(`empty-state`,{variant:a?`compact`:null}),w(Lf.container,a&&Lf.containerCompact,o),s,c),children:[n!=null&&(0,q.jsx)(`div`,{"aria-hidden":`true`,children:n}),(0,q.jsxs)(`div`,{className:`x78zum5 xdt5ytf x6s0dn4 xxc7z9f`,children:[(0,v.createElement)(d,J(Y(`empty-state-title`,{variant:a?`compact`:null}),{0:{className:`x1ghz6dp xjb2p0i x18juvz8 x2mo6ok xf74fhv x1tgivj0`},1:{className:`x1ghz6dp xjb2p0i x2mo6ok xf74fhv x1tgivj0 xcr08ib`}}[!!a<<0]),e),t!=null&&(0,q.jsx)(`div`,{...J(Y(`empty-state-description`,{variant:a?`compact`:null}),{0:{className:`x1ghz6dp xjb2p0i xjm74w1 x1sodnla xw6l6zx xv1l7n4`},1:{className:`x1ghz6dp xjb2p0i x1sodnla xw6l6zx xv1l7n4 x141an7d`}}[!!a<<0]),children:t})]}),r!=null&&(0,q.jsx)(`div`,{...{0:{className:`x78zum5 x1q0g3np x6s0dn4 x1txdalj xcsaf9d`},1:{className:`x78zum5 x6s0dn4 x1txdalj xcsaf9d xdt5ytf`}}[!!a<<0],children:r})]})}Rf.displayName=`EmptyState`;var zf={table:{kzqmXN:`xh8yej3`,kLvRdT:`x1mwwwfo`,kheTzg:`x1gukg7c`,kPzzVL:`x140o2bo`,$$css:!0},tableAutoLayout:{kPzzVL:`x1drmoe9`,$$css:!0}};function Bf(e,t,n,...r){return e.reduce((e,n,i)=>{let a=t(n);if(!a)return e;try{return a(e,...r)}catch(t){return gt(`Table`,`Plugin at index ${i} threw in transform:`,t),e}},n)}var Vf=[];function Hf(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Uf({item:e,rowIndex:t,rowKey:n,columns:r,plugins:i,textOverflow:a,RowComponent:o,CellComponent:s,ariaRowIndex:c}){let l=r.map((t,n)=>{let o={};t.align&&(o.style={textAlign:t.align});let c=Bf(i,e=>e.transformBodyCell,{htmlProps:o,xstyle:[],columnIndex:n,columns:r},t,e,n,r),l=!t.renderCell,u=l?xd(e,t.key):t.renderCell?.(e)??null,d;return d=l&&a===`truncate`&&typeof u==`string`&&u.length>0?(0,q.jsx)(eo,{type:`body`,maxLines:1,children:u}):u,(0,q.jsx)(s,{...c.htmlProps,contextMenuActions:c.contextMenuActions,xstyle:c.xstyle,children:d},t.key)}),u=Bf(i,e=>e.transformBodyRow,{htmlProps:c==null?{}:{"aria-rowindex":c},xstyle:[],children:(0,q.jsx)(q.Fragment,{children:l})},e,t),d=(0,q.jsx)(o,{ref:u.ref,...u.htmlProps,xstyle:u.xstyle,children:u.children},n);return u.afterRow?(0,q.jsxs)(q.Fragment,{children:[d,u.afterRow]}):d}function Wf(e,t){if(e.rowKey!==t.rowKey||e.rowIndex!==t.rowIndex||e.ariaRowIndex!==t.ariaRowIndex||e.columns!==t.columns||e.plugins!==t.plugins||e.textOverflow!==t.textOverflow||e.RowComponent!==t.RowComponent||e.CellComponent!==t.CellComponent)return!1;if(e.item===t.item)return!0;let n=e.item,r=t.item,i=Object.keys(r);if(Object.keys(n).length!==i.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0}var Gf=(0,v.memo)(Uf,Wf);function Kf({data:e,columns:t,idKey:n,plugins:r,children:i,textOverflow:a=`wrap`,scrollWrapper:o,emptyState:s,rowIndexStart:c,rowCount:l,xstyle:u,className:d,style:f,ref:p,...m}){let h=Gs(),g=r??Vf,_=c!=null||l!=null,y=c??1,b=_?l??-1:void 0,x=Fd,S=kf,C=Pf,T=Bf(g,e=>e.transformColumns,t??(e?Ed(e):[])),E=(0,v.useRef)(T);Hf(E.current,T)||(E.current=T);let D=E.current,O=vd(D),k=Bf(g,e=>e.transformTable,{htmlProps:{},xstyle:i?[zf.table,zf.tableAutoLayout]:[zf.table]}),A=D.map((e,t)=>{let n=e.header??e.key,r={"data-column-key":e.key,scope:`col`};e.align&&(r.style={textAlign:e.align});let i=Bf(g,e=>e.transformHeaderCell,{htmlProps:r,xstyle:[],content:n,columnIndex:t,columns:D},e,t,D),a=O.columns.get(e.key)?.style??{},o=i.htmlProps.style,s={...i.htmlProps,style:o?{...a,...o}:a},c=i.content??n,l=typeof c==`string`&&c.length>0?{title:c}:{},{before:u,after:d,overlay:f,below:p}=i,m=u!=null||d!=null||f!=null||p!=null?(0,q.jsxs)(q.Fragment,{children:[u,d==null?c:(0,q.jsxs)(`div`,{className:`x3nfvp2 x6s0dn4 xzye2dw xeuugli`,children:[c,d]}),f,p]}):c;return(0,q.jsx)(C,{...s,...l,contextMenuActions:i.contextMenuActions,xstyle:i.xstyle,children:m},e.key)}),j=Bf(g,e=>e.transformHeaderRow,{htmlProps:{},xstyle:[],children:(0,q.jsx)(q.Fragment,{children:A})}),M=e!=null&&e.length>0,N=D.length>0,P={...k.htmlProps.style,...f,...O.tableMinWidth>0?{minWidth:`${O.tableMinWidth}px`}:null},F=(0,q.jsx)(`table`,{ref:p,...b==null?null:{"aria-rowcount":b},...k.htmlProps,...J(Y(`base-table`),w(...k.xstyle,u),[k.htmlProps.className,d].filter(Boolean).join(` `)||void 0,P),...m,children:i||(0,q.jsxs)(q.Fragment,{children:[N&&(0,q.jsx)(Ff,{children:(0,q.jsx)(x,{...j.htmlProps,isHeaderRow:!0,xstyle:j.xstyle,children:j.children})}),(0,q.jsx)(If,{children:M?e.map((e,t)=>{let r=n==null?t:typeof n==`function`?n(e):String(e[n]);return(0,q.jsx)(Gf,{item:e,rowIndex:t,rowKey:r,columns:D,plugins:g,textOverflow:a,RowComponent:x,CellComponent:S,ariaRowIndex:_?y+t:void 0},r)}):e!=null&&s!==!1&&(0,q.jsx)(`tr`,{children:(0,q.jsx)(`td`,{colSpan:D.length,children:s??(0,q.jsx)(Rf,{title:h(`@astryx.table.noData`),isCompact:!0})})})})]})});if(o){let e=Bf(g,e=>e.transformScrollWrapper,{htmlProps:{},xstyle:[]});F=(0,q.jsx)(o,{htmlProps:e.htmlProps,xstyle:e.xstyle,beforeTable:e.beforeTable,afterTable:e.afterTable,children:F})}for(let e=g.length-1;e>=0;e--){let t=g[e];if(t.transformTableContext)try{F=t.transformTableContext(F)}catch(e){gt(`Table`,`Plugin threw in transformTableContext:`,e)}}return F}var qf=Kf;qf.displayName=`BaseTable`;var Jf=[`columnSettings`,`sort`,`tree`,`selection`,`pagination`],Yf=new Map(Jf.map((e,t)=>[e,t]));function Xf(e){let t=Jf.length;return e.sort(([e],[n])=>(Yf.get(e)??t)-(Yf.get(n)??t))}var Zf=new Set([`transformColumns`,`transformTable`,`transformHeaderRow`,`transformHeaderCell`,`transformBodyRow`,`transformBodyCell`,`transformScrollWrapper`,`transformTableContext`]);function Qf(e,t){let n=Object.keys(t);for(let t of n)Zf.has(t)||`${e}${t}${[...Zf].join(`, `)}`;for(let r of n)if(Zf.has(r)){let n=t[r];n!=null&&typeof n!=`function`&&`${e}${r}`}n.some(e=>Zf.has(e)&&typeof t[e]==`function`)||`${e}`}function $f(e,t){let n=(0,v.useRef)(null);if(n.current!=null){let r=n.current;if(r.basePlugins===e&&r.userPlugins===t)return r.result;if(r.basePlugins===e&&ep(r.userPlugins,t))return r.userPlugins=t,r.result}let r=t?Xf(Object.entries(t)).map(([,e])=>e):[],i=[...e,...r];if(t)for(let[e,n]of Object.entries(t))Qf(e,n);return n.current={basePlugins:e,userPlugins:t,result:i},i}function ep(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}var tp={base:{kMv6JI:`xjb2p0i`,kMwMTN:`x1tgivj0`,$$css:!0}},np={base:{kXHlph:`xw2csxc`,kuHK5b:`x5lxg6s`,$$css:!0},containerBleed:{keTefX:`xojxgvx`,k71WvV:`x1fcf3bl`,kzqmXN:`xx6qvi6`,keoZOQ:`xkibk3`,k1K539:`xlayyun`,$$css:!0}};function rp({children:e,htmlProps:t,xstyle:n,beforeTable:r,afterTable:i}){let a=Gs(),{ref:o,...s}=t??{};return(0,q.jsxs)(`div`,{ref:o,tabIndex:0,role:`group`,"aria-label":a(`@astryx.table.label`),...s,...J(Y(`table-scroll-wrapper`),w(np.base,np.containerBleed,...n??[])),children:[r,e,i]})}function ip(){return{transformTable(e){let t=e.htmlProps.className??``,n=Y(`table`).className;return{...e,htmlProps:{...e.htmlProps,className:t?`${t} ${n}`:n},xstyle:[...e.xstyle,tp.base]}}}}function ap({density:e=`balanced`,dividers:t=`rows`,isStriped:n=!1,hasHover:r=!1,verticalAlign:i=`middle`,textOverflow:a=`wrap`,plugins:o,columns:s,data:c,ref:l,...u}){let d=(0,v.useMemo)(()=>ip(),[]),f=$f((0,v.useMemo)(()=>[d],[d]),o),p=(0,v.useMemo)(()=>({density:e,dividers:t,isStriped:n,hasHover:r,verticalAlign:i,textOverflow:a}),[e,t,n,r,i,a]);return(0,q.jsx)(jd,{value:p,children:(0,q.jsx)(qf,{ref:l,data:c,columns:s,plugins:f,textOverflow:a,scrollWrapper:rp,...u})})}var op=ap;op.displayName=`Table`;function sp(e,t,n){if(e.length===0||t>e[e.length-1]){let r=[...e,t];for(;r.length>n;)r.shift();return r}return e}function cp(e,t,n,r){let i=t+e.length;if(n.length===0)return null;let a=n[0];if(i<=a)return null;let o=[],s=t;s<a&&a<i&&(o.push({key:`settled-${r}`,text:e.slice(0,a-t),fading:!1}),s=a);for(let a=0;a<n.length;a++){let c=n[a],l=a+1<n.length?n[a+1]:i;if(c>=i||l<=s)continue;let u=Math.max(c,s),d=Math.min(l,i);u>=d||(o.push({key:`fade-${r}-b${c}`,text:e.slice(u-t,d-t),fading:!0}),s=d)}return o.length>0?o:null}var lp={label:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kOIVth:`xzye2dw`,kXLuUW:`x11njtxf`,kZKoxP:`x1grt7ep`,kGuDYH:`x141an7d`,k63SB2:`xv8on6e`,kLWn49:`x1ltkj2j`,kMwMTN:`xv1l7n4`,kaIpWk:`xh6dtrn`,kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kVAM5u:`x14i3s5s`,kg3NbH:`xf314gf`,keTefX:`xladpz9`,kybGjl:`x1hl2dhg`,k1ekBW:`x1eaenvl`,kIyJzY:`x2rcmwa`,kAMwcw:`xlr8y92`,ks0D6T:`x55n99s`,kVQacm:`xb3r6kr`,$$css:!0},labelWithIcon:{kZCmMZ:`x138rykx`,$$css:!0},labelInteractive:{kkrTdU:`x1ypdohk`,$$css:!0},labelHover:{kWkggS:`xe9uy6x`,kMwMTN:`xv1l7n4 x140uwzg`,$$css:!0},number:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kXLuUW:`x1v0h343`,kGuDYH:`x141an7d`,k63SB2:`x2mo6ok`,kLWn49:`x1ltkj2j`,kMwMTN:`xv1l7n4`,kWkggS:`xgcxg3y`,kaIpWk:`xjspbzw`,k7Eaqz:`x16asifk`,kZKoxP:`x1grt7ep`,kg3NbH:`x7a5moj`,kybGjl:`x1hl2dhg`,k1ekBW:`x15406qy`,kIyJzY:`x2rcmwa`,kAMwcw:`xlr8y92`,$$css:!0},numberInteractive:{kkrTdU:`x1ypdohk`,$$css:!0},numberHover:{kWkggS:`xgcxg3y xe9uy6x`,$$css:!0}};function up({ref:e,source:t,number:n,variant:r=`label`,xstyle:i,className:a,style:o,"data-testid":s,...c}){let l=Gs(),u=t.title??String(n),d=t.url,f=t.icon!=null&&typeof t.icon!=`string`?t.icon:null,p=t.src??(typeof t.icon==`string`?t.icon:void 0),m=f!=null||p!=null,h=d?`a`:`span`,g=d?`doc-noteref`:void 0,_=d?{href:d,target:`_blank`,rel:`noopener noreferrer`,title:u}:{title:u},v=e;return r===`number`?(0,q.jsx)(h,{...c,ref:v,role:g,"aria-label":l(`@astryx.citation.label`,{number:n,title:u}),"data-testid":s,..._,...J(Y(`citation`,{variant:r}),w(lp.number,d!=null&&lp.numberHover,d!=null&&lp.numberInteractive,i),a,o),children:n}):(0,q.jsxs)(h,{...c,ref:v,role:g,"aria-label":l(`@astryx.citation.label`,{number:n,title:u}),"data-testid":s,..._,...J(Y(`citation`,{variant:r}),w(lp.label,m&&lp.labelWithIcon,d!=null&&lp.labelHover,d!=null&&lp.labelInteractive,i),a,o),children:[m&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`x3nfvp2 x6s0dn4 xl56j7k x12xnipv x6b6gus xjspbzw x10xzikg x1litavf x1y0btm7 x14i3s5s xb3r6kr x2lah0s`,children:f==null?(0,q.jsx)(`img`,{src:p,alt:``,className:`x1ad1g3v x9gl9lo`}):ma(f,{size:`sm`})}),(0,q.jsx)(`span`,{className:`xb3r6kr xlyipyv xuxw1ft xeuugli`,children:u})]})}up.displayName=`Citation`;var dp={sourceIds:void 0,autolink:void 0};function fp(e){if(e==null)return dp;if(typeof e.has==`function`)return{sourceIds:e,autolink:void 0};let t=e;return{sourceIds:t.sourceIds,autolink:t.autolink}}var pp=/^ {0,3}\[([^\]^](?:\\.|[^\]\\])*)\]:[ \t]*(?:<([^<>\n]*)>|(\S+))([ \t]+(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\)))?[ \t]*$/,mp=/^ {0,3}(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\))[ \t]*$/;function hp(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function gp(e){let t=pp.exec(e);if(t==null)return null;let n=hp(t[1]),r=t[2]==null?t[3]:t[2];return n===``||r==null?null:{label:n,destination:r,hasTitle:t[4]!=null}}function _p(e){let t=e.split(`
|
|
102
|
+
`),n=new Map,r=Array(t.length).fill(!0),i=!0,a=!1,o=``;for(let e=0;e<t.length;e++){let s=t[e];if(a){s.startsWith(o)?(a=!1,o=``,i=!0):i=!1;continue}let c=s.match(/^(`{3,}|~{3,})/);if(c){a=!0,o=c[1],i=!1;continue}if(s.trim()===``){i=!0;continue}if(i){let i=gp(s);if(i!=null){n.has(i.label)||n.set(i.label,i.destination),r[e]=!1,!i.hasTitle&&e+1<t.length&&mp.test(t[e+1])&&(r[e+1]=!1,e++);continue}}i=/^ {0,3}#{1,6}(?: |\t|$)/.test(s)||Yp(s)}return n.size===0?{defs:n,cleaned:e}:{defs:n,cleaned:t.filter((e,t)=>r[t]).join(`
|
|
103
|
+
`)}}function vp(e){return e.size===0?``:[...e].sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])).map(([e,t])=>`${e}\u0000${t}`).join(``)}function yp(e,t,n,r){let i=e.indexOf(`]`,t+1);if(i===-1)return null;let a=e.slice(t+1,i);if(e[i+1]===`[`){let t=e.indexOf(`]`,i+2);if(t!==-1){let o=e.slice(i+2,t),s=o===``?a:o,c=n.get(hp(s));if(c!=null)return{node:{type:`link`,href:c,children:Dp(a,r)},end:t+1}}}if(a.trim()===``)return null;let o=n.get(hp(a));return o==null?null:{node:{type:`link`,href:o,children:Dp(a,r)},end:i+1}}function bp(e,t,n){let r=e.indexOf(`]`,t+2);if(r===-1)return null;let i=e.slice(t+2,r);if(e[r+1]===`[`){let t=e.indexOf(`]`,r+2);if(t!==-1){let a=e.slice(r+2,t),o=a===``?i:a,s=n.get(hp(o));if(s!=null)return{node:{type:`image`,src:s,alt:i},end:t+1}}}if(i.trim()===``)return null;let a=n.get(hp(i));return a==null?null:{node:{type:`image`,src:a,alt:i},end:r+1}}function xp(e,t){let n=1;for(let r=t;r<e.length;r++)if(e[r]===`(`)n++;else if(e[r]===`)`&&(n--,n===0))return r;return-1}function Sp(e){return e!=null&&/\w/.test(e)}function Cp(e,t,n){if(!n.sourceIds||e[t]!==`【`)return null;let r=e.indexOf(`】`,t+1);if(r===-1)return null;let i=e.slice(t+1,r);return i.length===0||!n.sourceIds.has(i)?null:{sourceId:i,end:r+1}}function wp(e,t,n){if(!n.sourceIds||e[t]!==`[`)return null;let r=e.indexOf(`]`,t+1);if(r===-1||e[r+1]===`(`)return null;let i=e.slice(t+1,r);return i.length===0||!n.sourceIds.has(i)?null:{sourceId:i,end:r+1}}function Tp(e,t){return Ep(e,fp(t))}function Ep(e,t){let n=Dp(e,t);return t.autolink===`gfm`?qp(n):n}function Dp(e,t){let n=[],r=0;for(;r<e.length;){if(e[r]===`\\`&&r+1<e.length){n.push({type:`text`,content:e[r+1]}),r+=2;continue}if(e[r]==="`"){let t=e[r+1]==="`"?e[r+2]==="`"?3:2:1,i=r+t,a=e.indexOf("`".repeat(t),i);if(a!==-1){n.push({type:`code`,content:e.slice(i,a)}),r=a+t;continue}}{let i=Cp(e,r,t);if(i){n.push({type:`citation`,sourceId:i.sourceId}),r=i.end;continue}}if(e[r]===`!`&&e[r+1]===`[`){let t=e.indexOf(`]`,r+2);if(t!==-1&&e[t+1]===`(`){let i=xp(e,t+2);if(i!==-1){n.push({type:`image`,src:e.slice(t+2,i),alt:e.slice(r+2,t)}),r=i+1;continue}}}if(t.linkDefs!=null&&e[r]===`!`&&e[r+1]===`[`){let i=bp(e,r,t.linkDefs);if(i){n.push(i.node),r=i.end;continue}}{let i=wp(e,r,t);if(i){n.push({type:`citation`,sourceId:i.sourceId}),r=i.end;continue}}if(e[r]===`[`){let i=e.indexOf(`]`,r+1);if(i!==-1&&e[i+1]===`(`){let a=xp(e,i+2);if(a!==-1){n.push({type:`link`,href:e.slice(i+2,a),children:Dp(e.slice(r+1,i),t)}),r=a+1;continue}}}if(t.linkDefs!=null&&e[r]===`[`){let i=yp(e,r,t.linkDefs,t);if(i){n.push(i.node),r=i.end;continue}}if(e[r]===`*`&&e[r+1]===`*`&&e[r+2]===`*`||e[r]===`_`&&e[r+1]===`_`&&e[r+2]===`_`){let i=e.slice(r,r+3),a=e[r]===`_`;if(!(a&&Sp(e[r-1]))){let o=e.indexOf(i,r+3);if(o!==-1&&(!a||!Sp(e[o+3]))){n.push({type:`bold`,children:[{type:`italic`,children:Dp(e.slice(r+3,o),t)}]}),r=o+3;continue}}}if(e[r]===`*`&&e[r+1]===`*`||e[r]===`_`&&e[r+1]===`_`){let i=e.slice(r,r+2),a=e[r]===`_`;if(!(a&&Sp(e[r-1]))){let o=e.indexOf(i,r+2);if(o!==-1&&(!a||!Sp(e[o+2]))){n.push({type:`bold`,children:Dp(e.slice(r+2,o),t)}),r=o+2;continue}}}if(e[r]===`~`&&e[r+1]===`~`){let i=e.indexOf(`~~`,r+2);if(i!==-1){n.push({type:`strikethrough`,children:Dp(e.slice(r+2,i),t)}),r=i+2;continue}}if(e[r]===`*`||e[r]===`_`){let i=e[r]===`_`;if(!(i&&Sp(e[r-1]))){let a=e.indexOf(e[r],r+1);if(a!==-1&&a>r+1&&(!i||!Sp(e[a+1]))){n.push({type:`italic`,children:Dp(e.slice(r+1,a),t)}),r=a+1;continue}}}let i=r+1;for(;i<e.length&&!`*_~\`[!\\
|
|
104
|
+
【`.includes(e[i]);)i++;let a=e.slice(r,i);if(i<e.length&&e[i]===`
|
|
105
|
+
`){let e=a.replace(/ +$/,``);if(a.length-e.length>=2){if(e.length>0){let t=n[n.length-1];t?.type===`text`?t.content+=e:n.push({type:`text`,content:e})}n.push({type:`break`}),r=i+1;continue}}let o=n[n.length-1];o?.type===`text`?o.content+=a:n.push({type:`text`,content:a}),r=i}return n}var Op=`[^\\s<]+`,kp=`https?:\\/\\/`,Ap=`[A-Za-z0-9._%+-]+`,jp=`[A-Za-z0-9-]+`,Mp=`${jp}(?:\\.${jp})+`,Np=`[a-zA-Z][a-zA-Z0-9+.-]*`,Pp=`[^<>\\s]*`,Fp=RegExp(`${kp}${Op}`,`g`),Ip=RegExp(`www\\.${Op}`,`g`),Lp=RegExp(`${Ap}@${Mp}`,`g`),Rp=RegExp(`<(${Np}:${Pp})>`,`g`),zp=RegExp(`<(${Ap}@${Mp})>`,`g`),Bp=new Set(`?!.,:*_~`),Vp=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._%+-@`);function Hp(e){let t=e;for(;t.length>0;){if(Bp.has(t[t.length-1])){let e=t.length-1;for(;e>0&&Bp.has(t[e-1]);)e--;t=t.slice(0,e);continue}if(t.endsWith(`)`)){let e=0,n=0;for(let r=0;r<t.length;r++)t[r]===`(`?e++:t[r]===`)`&&n++;if(n>e){t=t.slice(0,-1);continue}}break}return t}var Up=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/=`);function Wp(e){return e==null||!Up.has(e)}function Gp(e){let t=[];{let n=new RegExp(Rp.source,`g`),r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({start:r.index,end:r.index+r[0].length,href:e,display:e})}}{let n=new RegExp(zp.source,`g`),r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({start:r.index,end:r.index+r[0].length,href:`mailto:${e}`,display:e})}}{let n=new RegExp(Fp.source,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1];if(!Wp(n)||e.slice(r.index-2,r.index)===`](`)continue;let i=Hp(r[0]);i.length!==0&&t.push({start:r.index,end:r.index+i.length,href:i,display:i})}}{let n=new RegExp(Ip.source,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1];if(!Wp(n)||e.slice(r.index-3,r.index)===`://`)continue;let i=Hp(r[0]);i.length!==0&&t.push({start:r.index,end:r.index+i.length,href:`http://${i}`,display:i})}}{let n=new RegExp(Lp.source,`g`),r;for(;(r=n.exec(e))!==null;){let n=e[r.index-1];n!=null&&Vp.has(n)||e.slice(Math.max(0,r.index-7),r.index)!==`mailto:`&&t.push({start:r.index,end:r.index+r[0].length,href:`mailto:${r[0]}`,display:r[0]})}}t.sort((e,t)=>e.start-t.start);let n=[],r=0;for(let e of t)e.start>=r&&(n.push(e),r=e.end);return n}function Kp(e){let t=Gp(e);if(t.length===0)return[{type:`text`,content:e}];let n=[],r=0;for(let i of t)i.start>r&&n.push({type:`text`,content:e.slice(r,i.start)}),n.push({type:`link`,href:i.href,children:[{type:`text`,content:i.display}]}),r=i.end;return r<e.length&&n.push({type:`text`,content:e.slice(r)}),n}function qp(e){let t=[];for(let n of e)if(n.type===`text`){let e=Kp(n.content);for(let n of e){let e=t[t.length-1];n.type===`text`&&e?.type===`text`?e.content+=n.content:t.push(n)}}else n.type===`bold`||n.type===`italic`||n.type===`strikethrough`?t.push({...n,children:qp(n.children)}):t.push(n);return t}function Jp(e){let t=0;for(;t<e.length&&e[t]===` `;)t++;return t}function Yp(e){let t=e.trim();if(t.length<3)return!1;let n=t.replace(/ /g,``);if(n.length<3)return!1;let r=n[0];if(r!==`-`&&r!==`*`&&r!==`_`)return!1;for(let e=1;e<n.length;e++)if(n[e]!==r)return!1;return!0}function Xp(e){if(!e.includes(`|`))return!1;let t=e.split(`|`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0&&t.every(e=>/^:?-+:?$/.test(e))}function Zp(e){return!!(/^#{1,6} /.test(e)||/^(`{3,}|~{3,})/.test(e)||Yp(e)||e.startsWith(`> `)||e===`>`||/^ {0,9}[-*+] /.test(e)||/^ {0,9}0*1[.)] /.test(e)||e.includes(`|`))}function Qp(e){let t=0,n=e.length;if(e.startsWith(`|`))for(t=1;t<n&&e[t]===` `;)t++;for(;n>t&&e[n-1]===` `;)n--;n>t&&e[n-1]===`|`&&n--;let r=e.slice(t,n),i=[],a=``;for(let e=0;e<r.length;e++)r[e]===`\\`&&e+1<r.length&&r[e+1]===`|`?(a+=`\\|`,e++):r[e]===`|`?(i.push(a.trim()),a=``):a+=r[e];return i.push(a.trim()),i}function $p(e,t,n){let r=Qp(e[t]).map(e=>({children:Ep(e,n)})),i=Qp(e[t+1]).map(e=>{let t=e.trim(),n=t.startsWith(`:`),r=t.endsWith(`:`);return n&&r?`center`:r?`right`:n?`left`:null}),a=[],o=t+2;for(;o<e.length&&e[o].includes(`|`)&&e[o].trim()!==``;)a.push(Qp(e[o]).map(e=>({children:Ep(e,n)}))),o++;return{node:{type:`table`,headers:r,alignments:i,rows:a},nextIndex:o}}function em(e,t,n,r){let i=[],a=Jp(e[t]),o=n?e[t].match(/^ *(\d+)([.)]) /):null,s=o?o[2]:`.`,c=`\\${s}`,l=RegExp(n?`^ {${a}}\\d+${c} `:`^ {${a}}[-*+] `),u=o?parseInt(o[1],10):void 0,d=!1,f=t;for(;f<e.length&&l.test(e[f]);){let t=n?e[f].replace(RegExp(`^ *\\d+${c} `),``):e[f].replace(/^ *[-*+] /,``),o=t.match(/^\[([ xX])\] (.*)/),s,u;o?(s=o[1].toLowerCase()===`x`,u=o[2]):u=t,f++;let p=[];for(;f<e.length&&e[f].trim()!==``&&Jp(e[f])>a;)p.push(e[f]),f++;if(p.length>0){let e=Math.min(...p.map(e=>Jp(e))),t=p.map(t=>t.slice(e));u+=`
|
|
106
|
+
`+t.join(`
|
|
107
|
+
`)}i.push({checked:s,children:nm(u,r)});let m=f;for(;m<e.length&&e[m].trim()===``;)m++;m>f&&m<e.length&&l.test(e[m])&&(d=!0,f=m)}return{node:{type:`list`,ordered:n,start:u,delimiter:n?s:void 0,loose:d||void 0,items:i},nextIndex:f}}function tm(e,t){return nm(e,fp(t))}function nm(e,t){let{defs:n,cleaned:r}=_p(e),i=t.linkDefs,a;a=n.size===0?i:i==null?n:new Map([...n,...i]);let o=a==null?t:{...t,linkDefs:a},s=r.split(`
|
|
108
|
+
`),c=[],l=0;for(;l<s.length;){let e=s[l];if(e.trim()===``){l++;continue}let t=e.match(/^(`{3,}|~{3,})(\w*)/);if(t){let e=t[1],n=t[2]||`plaintext`,r=[];for(l++;l<s.length&&!s[l].startsWith(e);)r.push(s[l]),l++;l++,c.push({type:`codeblock`,language:n,content:r.join(`
|
|
109
|
+
`)});continue}let n=e.match(/^(#{1,6}) +(.*)/);if(n){c.push({type:`heading`,level:n[1].length,children:Ep(n[2],o)}),l++;continue}if(Yp(e)){c.push({type:`hr`}),l++;continue}let r=e.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(r&&e.trim()===r[0]){c.push({type:`image`,alt:r[1],src:r[2]}),l++;continue}if(l+1<s.length&&e.includes(`|`)&&Xp(s[l+1])){let e=$p(s,l,o);c.push(e.node),l=e.nextIndex;continue}if(e.startsWith(`> `)||e===`>`){let e=[];for(;l<s.length&&(s[l].startsWith(`> `)||s[l]===`>`);)e.push(s[l].replace(/^> ?/,``)),l++;c.push({type:`blockquote`,children:nm(e.join(`
|
|
110
|
+
`),o)});continue}if(/^ {0,9}[-*+] /.test(e)){let e=em(s,l,!1,o);c.push(e.node),l=e.nextIndex;continue}if(/^ {0,9}\d+[.)] /.test(e)){let e=em(s,l,!0,o);c.push(e.node),l=e.nextIndex;continue}let i=[e];for(l++;l<s.length&&!Zp(s[l])&&s[l].trim()!==``;)i.push(s[l]),l++;c.push({type:`paragraph`,children:Ep(i.join(`
|
|
111
|
+
`),o)})}return c}function rm(){return{prevInput:``,settledText:``,settledBlocks:[],settledUpTo:0}}function im(e){let t=!1,n=``,r=-1;for(let i=0;i<e.length;i++){let a=e[i],o=a.match(/^(`{3,}|~{3,})/);o&&(t?o[1].startsWith(n[0])&&o[1].length>=n.length&&(t=!1,n=``):(t=!0,n=o[1])),!t&&a.trim()===``&&i>0&&(r=i)}return t?-1:r}function am(e){let t=e.lastIndexOf(`
|
|
112
|
+
`),n=t===-1?``:e.slice(0,t+1),r=t===-1?e:e.slice(t+1),i=r.lastIndexOf(`[`);if(i!==-1){let e=r.slice(i);if(!(e.includes(`](`)&&e.includes(`)`))){let e=i>0&&r[i-1]===`!`?i-1:i;r=r.slice(0,e)}}let a=r.length;for(;a>0&&r[a-1]==="`";)a--;if(a<r.length&&a>0){let e=r.length-a;r.lastIndexOf("`".repeat(e),a-1)===-1&&(r=r.slice(0,a))}for(a=r.length;a>0&&r[a-1]===`*`;)a--;if(a<r.length&&a>0){let e=r.length-a;e<=3&&r.lastIndexOf(`*`.repeat(e),a-1)===-1&&(r=r.slice(0,a))}{let e=0,t=[];for(;e<r.length;){let n=r.indexOf(`*`,e);if(n===-1)break;let i=1;for(;n+i<r.length&&r[n+i]===`*`;)i++;if(i>3){e=n+i;continue}t.push({pos:n,len:i}),e=n+i}let n=new Set;for(let e=0;e<t.length;e++)if(!n.has(e)){for(let r=e+1;r<t.length;r++)if(!n.has(r)&&t[r].len===t[e].len){n.add(e),n.add(r);break}}for(let e=t.length-1;e>=0;e--)if(!n.has(e)){let n=t[e];n.pos+n.len<r.length?r+=`*`.repeat(n.len):r=r.slice(0,n.pos)}}if(r.length>=2&&r.endsWith(`~~`))r.lastIndexOf(`~~`,r.length-3)===-1&&(r=r.slice(0,-2));else if(r.endsWith(`~`)){let e=r.length-2;e>=0&&r[e]!==`~`&&(r=r.slice(0,-1))}{let e=0,t=0,n=[];for(;;){let i=r.indexOf(`~~`,t);if(i===-1)break;n.push(i),e++,t=i+2}e%2==1&&(r=r.slice(0,n[n.length-1]))}return n+r}function om(e){let t=e.split(`
|
|
113
|
+
`);for(;t.length>0;){let e=t[t.length-1],n=e.trim();if(n===``){t.pop();continue}if(/^ {0,9}[-*+] $/.test(e)||/^ {0,9}\d+[.)] $/.test(e)){t.pop();continue}if(n.includes(`|`)&&!Xp(e)){let e=!1;for(let n=t.length-2;n>=1;n--)if(Xp(t[n])&&t[n-1].includes(`|`)){e=!0;break}if(!e){t.pop();continue}}if(Xp(e)&&(t.length<2||!t[t.length-2].includes(`|`))){t.pop();continue}break}return t.join(`
|
|
114
|
+
`)}function sm(e,t){if(e.length===0||t.length===0)return[...e,...t];let n=e[e.length-1],r=t[0];if(n.type===`list`&&r.type===`list`&&n.ordered===r.ordered&&n.delimiter===r.delimiter){let i={type:`list`,ordered:n.ordered,start:n.start,delimiter:n.delimiter,loose:!0,items:[...n.items,...r.items]};return[...e.slice(0,-1),i,...t.slice(1)]}return[...e,...t]}function cm(e,t,n){let r=fp(n);if(t.autolink!==r.autolink&&(t.prevInput=``,t.settledText=``,t.settledBlocks=[],t.settledUpTo=0,t.autolink=r.autolink),e===``)return t.prevInput=``,t.settledText=``,t.settledBlocks=[],t.settledUpTo=0,t.linkDefsKey=void 0,[];let{defs:i}=_p(e),a=vp(i);t.linkDefsKey!==a&&(t.prevInput=``,t.settledText=``,t.settledBlocks=[],t.settledUpTo=0,t.linkDefsKey=a);let o=i.size>0?{...r,linkDefs:i}:r,s=e.split(`
|
|
115
|
+
`),c=im(s);if(c<0)return t.prevInput=e,nm(e,o);let l=s.slice(0,c).join(`
|
|
116
|
+
`),u=om(s.slice(c).join(`
|
|
117
|
+
`).trim()),d;if(l===t.settledText)d=t.settledBlocks;else if(t.settledText.length>0&&l.startsWith(t.settledText)){let e=nm(l.slice(t.settledText.length),o);d=sm(t.settledBlocks,e)}else d=nm(l,o);let f=u?nm(u,o):[];return t.settledText=l,t.settledBlocks=d,t.settledUpTo=c,t.prevInput=e,sm(d,f)}var lm={start:`0`,center:`auto`},um={start:null,center:`auto`},dm={k7Eaqz:`xkj4a21`,$$css:!0},fm={proseWidth:e=>[{ks0D6T:e==null?e:`xf68679`,$$css:!0},{"--x-maxWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}],proseAlign:e=>[{kUOVxO:e==null?e:`xvlecxo`,$$css:!0},{"--x-marginInline":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}],blockWidth:e=>[dm,{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(`min(${e}, 100%)`)}],blockAlign:e=>[{kUOVxO:e==null?e:`xvlecxo`,$$css:!0},{"--x-marginInline":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}],cellMinWidth:e=>[{k7Eaqz:e==null?e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(e)}]},pm={center:{k9WMMc:`x2b8uid`,$$css:!0},end:{k9WMMc:`xp4054r`,$$css:!0}},Q={root:{kMv6JI:`x9ynric`,kMwMTN:`x1tgivj0`,kLWn49:`xw6l6zx`,kGuDYH:`xjm74w1`,kzqmXN:`xh8yej3`,ks0D6T:`x193iq5w`,k7Eaqz:`xeuugli`,kHjlTd:`x1mzt3pk`,$$css:!0},inlineRoot:{k1xSpc:`xt0psk2`,kzqmXN:`x14atkfc`,ks0D6T:`x1x1rfll`,kMv6JI:`xjb2p0i`,kMwMTN:`x1heor9g`,kLWn49:`x15bjb6t`,kGuDYH:`x1qlqyl8`,$$css:!0},headingBase:{kMv6JI:`x1g81bgm`,kMwMTN:`x1tgivj0`,$$css:!0},h1:{kGuDYH:`xcg7oai`,k63SB2:`x1v68xuy`,kLWn49:`xfmsba7`,$$css:!0},h2:{kGuDYH:`x1xvnhcw`,k63SB2:`x12yy4cs`,kLWn49:`x1cpk1wn`,$$css:!0},h3:{kGuDYH:`xii13ha`,k63SB2:`x1jcxfy8`,kLWn49:`xwjzt0u`,$$css:!0},h4:{kGuDYH:`x8tkxat`,k63SB2:`x2hcmsi`,kLWn49:`xqerer`,$$css:!0},h5:{kGuDYH:`xsgqta0`,k63SB2:`xno150v`,kLWn49:`xo3gurs`,$$css:!0},h6:{kGuDYH:`xw5ohdf`,k63SB2:`x1pw4frv`,kLWn49:`xeixjfn`,$$css:!0},spacingHeadingMajorDefault:{keoZOQ:`x13rv44w`,k1K539:`xep27e5`,$$css:!0},spacingHeadingMinorDefault:{keoZOQ:`x1s1qpeq`,k1K539:`x1p37lm5`,$$css:!0},spacingParagraphDefault:{keoZOQ:`xj6sv8s`,k1K539:`xep27e5`,$$css:!0},spacingCodeblockDefault:{keoZOQ:`x1s1qpeq`,k1K539:`xwh1t77`,$$css:!0},spacingBlockquoteDefault:{keoZOQ:`x1s1qpeq`,k1K539:`xwh1t77`,$$css:!0},spacingListDefault:{keoZOQ:`xj6sv8s`,k1K539:`xep27e5`,$$css:!0},spacingTableDefault:{keoZOQ:`x1s1qpeq`,k1K539:`xwh1t77`,$$css:!0},spacingHrDefault:{keoZOQ:`x13rv44w`,k1K539:`x4d5cxa`,$$css:!0},spacingImageDefault:{keoZOQ:`xj6sv8s`,k1K539:`xep27e5`,$$css:!0},spacingHeadingMajorCompact:{keoZOQ:`x1s1qpeq`,k1K539:`x1p37lm5`,$$css:!0},spacingHeadingMinorCompact:{keoZOQ:`xj6sv8s`,k1K539:`x14cgwvg`,$$css:!0},spacingParagraphCompact:{keoZOQ:`xcsaf9d`,k1K539:`x14cgwvg`,$$css:!0},spacingCodeblockCompact:{keoZOQ:`xtbrsbv`,k1K539:`x1p37lm5`,$$css:!0},spacingBlockquoteCompact:{keoZOQ:`xtbrsbv`,k1K539:`x1p37lm5`,$$css:!0},spacingListCompact:{keoZOQ:`xcsaf9d`,k1K539:`x14cgwvg`,$$css:!0},spacingTableCompact:{keoZOQ:`xtbrsbv`,k1K539:`x1p37lm5`,$$css:!0},spacingHrCompact:{keoZOQ:`xj6sv8s`,k1K539:`xep27e5`,$$css:!0},spacingImageCompact:{keoZOQ:`xtbrsbv`,k1K539:`x1p37lm5`,$$css:!0},noMarginBlockStart:{keoZOQ:`xdj266r`,$$css:!0},noMarginBlockEnd:{k1K539:`xat24cr`,$$css:!0},codeBlockWrapper:{ks0D6T:`x193iq5w`,$$css:!0},tableWrapper:{kXHlph:`xw2csxc`,ks0D6T:`x193iq5w`,"--container-padding-inline-start":`xrhngw9`,"--container-padding-inline-end":`xjsfl84`,"--container-padding-block-start":`x1047aw6`,"--container-padding-block-end":`xax9j7h`,$$css:!0},blockIndent:{kUOVxO:`x1ho7dyk`,$$css:!0},hr:{kMzoRj:`xc342km`,kEafiO:`x11xkdxz`,kPef9Z:`x13fuv20`,kLZC3w:`x1pc3f07`,$$css:!0}};function mm(e){let t=e.match(/^([\d.]+)ms$/);if(t)return parseFloat(t[1]);let n=e.match(/^([\d.]+)s$/);return n?parseFloat(n[1])*1e3:null}function hm(e){let t=0;for(let n of e)switch(n.type){case`text`:t+=n.content.length;break;case`code`:t+=n.content.length;break;case`image`:t+=n.alt.length;break;case`bold`:case`italic`:case`strikethrough`:case`link`:t+=hm(n.children);break;case`break`:t+=1;break;case`citation`:t+=1}return t}function gm(e){let t=0;for(let n of e)switch(n.type){case`heading`:case`paragraph`:t+=hm(n.children);break;case`codeblock`:t+=n.content.length;break;case`blockquote`:t+=gm(n.children);break;case`list`:for(let e of n.items)t+=gm(e.children);break;case`table`:for(let e of n.headers)t+=hm(e.children);for(let e of n.rows)for(let n of e)t+=hm(n.children);break;case`hr`:break;case`image`:t+=n.alt.length}return t}var _m={1:Q.h1,2:Q.h2,3:Q.h3,4:Q.h4,5:Q.h5,6:Q.h6},vm=/^(javascript|data|vbscript):/i;function ym(e){let t=e.trim();return t.length===0||vm.test(t)?null:t}function bm(e,t){let n=[];for(let r of t){r.pattern.lastIndex=0;let t;for(;(t=r.pattern.exec(e))!==null;){let i;if(r.getEndIndex){let n=r.getEndIndex(e,t);if(n===!1)continue;i=n}else i=t.index+t[0].length;n.push({start:t.index,end:i,match:t,plugin:r})}}n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let e of n)e.start>=i&&(r.push(e),i=e.end);if(r.length===0)return[{type:`text`,content:e}];let a=[],o=0;for(let t=0;t<r.length;t++){let n=r[t];n.start>o&&a.push({type:`text`,content:e.slice(o,n.start)}),a.push({type:`plugin`,element:n.plugin.render(n.match,`plugin-${t}`),matchLength:n.end-n.start}),o=n.end}return o<e.length&&a.push({type:`text`,content:e.slice(o)}),a}function xm(e,t,n){let r=t.offset;if(t.offset+=e.length,!t.active)return e;let i=cp(e,r,t.boundaries,n);if(i==null)return e;let a=i.map(e=>e.fading?(0,q.jsx)(`span`,{className:`x1hc1fzr x19991ni x80gvsz x12w9bfk xlr8y92 x4itv7f`,children:e.text},e.key):(0,q.jsx)(`span`,{children:e.text},e.key));return(0,q.jsx)(`span`,{children:a},`wrap-${n}`)}function Sm(e,t){let n=e.numberMap.get(t);return n??(n=e.nextNumber++,e.numberMap.set(t,n)),n}function Cm(e,t,n,r,i,a=`a`,o,s){switch(e.type){case`text`:if(o&&o.length>0){let n=bm(e.content,o);if(n.length!==1||n[0].type!==`text`){let e=[];for(let i=0;i<n.length;i++){let a=n[i];a.type===`text`?e.push(xm(a.content,r,`${t}-seg-${i}`)):(r.offset+=a.matchLength,e.push((0,q.jsx)(v.Fragment,{children:a.element},`plugin-${t}-${i}`)))}return(0,q.jsx)(v.Fragment,{children:e},t)}}return xm(e.content,r,t);case`bold`:return(0,q.jsx)(`strong`,{className:`x2mo6ok`,children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t);case`italic`:return(0,q.jsx)(`em`,{children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t);case`strikethrough`:return(0,q.jsx)(`del`,{className:`xv1l7n4`,children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t);case`code`:{r.offset+=e.content.length;let n=s?.inlineCode;return n?(0,q.jsx)(n,{children:e.content},t):(0,q.jsx)(qc,{children:e.content},t)}case`link`:{let c=ym(e.href);if(c==null)return(0,q.jsx)(`span`,{children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t);let l=s?.link;if(l)return(0,q.jsx)(l,{href:c,children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t);let u=c.startsWith(`https://`)||c.startsWith(`http://`);return(0,q.jsx)(u?`a`:a,{href:c,onClick:n?e=>{n(c,e)===!1&&e.preventDefault()}:void 0,...u?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`xjse4m1 x1bvjpef`,children:e.children.map((e,t)=>Cm(e,t,n,r,i,a,o,s))},t)}case`image`:{let n=ym(e.src);if(n==null)return(0,q.jsxs)(`span`,{children:[`[`,e.alt,`]`]},t);let r=s?.image;return r?(0,q.jsx)(r,{src:n,alt:e.alt},t):(0,q.jsx)(`img`,{src:n,alt:e.alt,className:`x193iq5w xh6dtrn`},t)}case`break`:return r.offset+=1,(0,q.jsx)(`br`,{},t);case`citation`:{if(r.offset+=1,!i)return(0,q.jsxs)(`span`,{children:[`[`,e.sourceId,`]`]},t);let n=Sm(i,e.sourceId),a=i.sources[e.sourceId]??{title:e.sourceId},o=i.style===`number`?`number`:`label`,c=s?.citation;return c?(0,q.jsx)(c,{source:a,number:n,variant:o},t):(0,q.jsx)(up,{source:a,number:n,variant:o},t)}}}function wm(e,t){let n=t===`compact`;switch(e.type){case`heading`:return e.level<=3?n?Q.spacingHeadingMajorCompact:Q.spacingHeadingMajorDefault:n?Q.spacingHeadingMinorCompact:Q.spacingHeadingMinorDefault;case`paragraph`:return n?Q.spacingParagraphCompact:Q.spacingParagraphDefault;case`codeblock`:return n?Q.spacingCodeblockCompact:Q.spacingCodeblockDefault;case`blockquote`:return n?Q.spacingBlockquoteCompact:Q.spacingBlockquoteDefault;case`list`:return n?Q.spacingListCompact:Q.spacingListDefault;case`table`:return n?Q.spacingTableCompact:Q.spacingTableDefault;case`hr`:return n?Q.spacingHrCompact:Q.spacingHrDefault;case`image`:return n?Q.spacingImageCompact:Q.spacingImageDefault}}function Tm(e){return e.headers.map((t,n)=>{let r=hm(t.children);for(let t of e.rows)if(t[n]){let e=hm(t[n].children);e>r&&(r=e)}return r<=6?60:r<=15?80:120})}function Em(e,t,n,r,i,a,o,s,c,l,u=`a`,d,f,p){let m=um[l],h=m==null?null:fm.blockAlign(m),g=wm(e,r),_=t===0,v=t===n-1;switch(e.type){case`heading`:{let n=Math.min(e.level+i-1,6),p=e.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f)),m=f?.heading;if(m)return(0,q.jsx)(m,{level:n,children:p},t);let h=`h${n}`;return(0,q.jsx)(h,{...J(Y(`markdown-heading`,{density:r,level:n}),w(Q.headingBase,_m[n],g,c==null?null:fm.proseWidth(c),l===`start`?null:fm.proseAlign(lm[l]),_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:p},t)}case`paragraph`:{let n=e.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f)),i=f?.paragraph;return i?(0,q.jsx)(i,{children:n},t):(0,q.jsx)(`div`,{role:`paragraph`,...J(Y(`markdown-paragraph`,{density:r}),w(g,c==null?null:fm.proseWidth(c),l===`start`?null:fm.proseAlign(lm[l]),_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:n},t)}case`codeblock`:{o.offset+=e.content.length;let n=f?.code;return n?(0,q.jsx)(n,{code:e.content,language:e.language},t):(0,q.jsx)(`div`,{...J(Y(`markdown-codeblock`,{density:r}),w(g,Q.codeBlockWrapper,_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:(0,q.jsx)(Uc,{code:e.content,language:e.language,isCollapsible:!0,xstyle:[c==null?void 0:fm.blockWidth(c),h]})},t)}case`blockquote`:{let n=f?.blockquote;if(n){let m=e.children.map((t,n)=>Em(t,n,e.children.length,r,i,a,o,s,c,l,u,d,f,p));return(0,q.jsx)(n,{children:m},t)}return(0,q.jsx)(_d,{...Y(`markdown-blockquote`,{density:r}),xstyle:[g,c==null?void 0:fm.proseWidth(c),l===`start`?void 0:fm.proseAlign(lm[l]),_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd],children:e.children.map((t,n)=>Em(t,n,e.children.length,r,i,a,o,s,c,l,u,d,f,p))},t)}case`list`:if(e.items.length>0&&e.items.every(e=>e.checked!=null)){let n=e.items.map((e,t)=>({item:e,key:`task-${t}`})).filter(({item:e})=>e.checked).map(({key:e})=>e);return(0,q.jsx)(`div`,{...J(Y(`markdown-list`,{density:r}),w(g,_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:(0,q.jsx)(Fu,{label:p(`@astryx.markdown.taskList`),isLabelHidden:!0,value:n,xstyle:Q.blockIndent,isReadOnly:!0,density:`compact`,children:e.items.map((e,t)=>{let n=e.children[0],m=e.children.length===1&&n?.type===`paragraph`?(0,q.jsx)(q.Fragment,{children:n.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f))}):(0,q.jsx)(q.Fragment,{children:e.children.map((t,n)=>Em(t,n,e.children.length,r,i,a,o,s,c,l,u,d,f,p))});return(0,q.jsx)(hd,{value:`task-${t}`,label:m},t)})})},t)}return(0,q.jsx)(`div`,{...J(Y(`markdown-list`,{density:r}),w(g,c==null?null:fm.proseWidth(c),l===`start`?null:fm.proseAlign(lm[l]),_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:(0,q.jsx)(Mu,{listStyle:e.ordered?`decimal`:`disc`,density:`compact`,start:e.ordered?e.start:void 0,xstyle:Q.blockIndent,children:e.items.map((e,t)=>{let n=e.children[0],m=e.children.length===1&&n?.type===`paragraph`?(0,q.jsx)(q.Fragment,{children:n.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f))}):(0,q.jsx)(q.Fragment,{children:e.children.map((t,n)=>Em(t,n,e.children.length,r,i,a,o,s,c,l,u,d,f,p))});return(0,q.jsx)(pd,{label:m},t)})})},t);case`table`:{let n=Tm(e);return(0,q.jsx)(`div`,{tabIndex:0,role:`group`,"aria-label":p(`@astryx.markdown.table`),...J(Y(`markdown-table`,{density:r}),w(Q.tableWrapper,g,c==null?null:fm.blockWidth(c),um[l]==null?null:fm.blockAlign(um[l]),_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:(0,q.jsxs)(op,{dividers:`rows`,textOverflow:`wrap`,children:[(0,q.jsx)(Ff,{children:(0,q.jsx)(Fd,{children:e.headers.map((t,r)=>(0,q.jsx)(Pf,{xstyle:[fm.cellMinWidth(`${n[r]}px`),e.alignments[r]===`center`&&pm.center,e.alignments[r]===`right`&&pm.end],children:t.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f))},r))})}),(0,q.jsx)(If,{children:e.rows.map((t,n)=>{let r=t.map((t,n)=>(0,q.jsx)(kf,{xstyle:[e.alignments[n]===`center`&&pm.center,e.alignments[n]===`right`&&pm.end],children:t.children.map((e,t)=>Cm(e,t,a,o,s,u,d,f))},n));return(0,q.jsx)(Fd,{children:r},n)})})]})},t)}case`hr`:{let e=f?.hr;return e?(0,q.jsx)(e,{},t):(0,q.jsx)(`hr`,{...J(Y(`markdown-hr`,{density:r}),w(Q.hr,g,_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd))},t)}case`image`:{let n=ym(e.src);if(n==null)return(0,q.jsxs)(`div`,{...J(Y(`markdown-image`,{density:r}),w(g,_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:[`[`,e.alt,`]`]},t);let i=f?.image;return i?(0,q.jsx)(i,{src:n,alt:e.alt},t):(0,q.jsx)(`div`,{...J(Y(`markdown-image`,{density:r}),w(g,_&&Q.noMarginBlockStart,v&&Q.noMarginBlockEnd)),children:(0,q.jsx)(`img`,{src:n,alt:e.alt,className:`x193iq5w xh6dtrn`})},t)}}}function Dm({ref:e,children:t,display:n=`block`,density:r=`default`,headingLevelStart:i=1,isStreaming:a=!1,onLinkClick:o,sources:s,citationStyle:c=`label`,contentWidth:l=680,contentAlign:u=`start`,components:d,inlinePlugins:f,autolink:p,xstyle:m,className:h,style:g,"data-testid":_}){let y=Gs(),b=po(),x=(0,v.useMemo)(()=>s?new Set(Object.keys(s)):void 0,[s]),S=(0,v.useMemo)(()=>({sourceIds:x,autolink:p}),[x,p]),C=iu(t,a),T=(0,v.useRef)(rm()),E=(0,v.useRef)(p);E.current!==p&&(T.current=rm(),E.current=p);let D=(0,v.useMemo)(()=>n===`inline`?[]:a?C===``?(T.current=rm(),[]):cm(am(C),T.current,S):tm(t,S),[n,C,t,a,S]),O=(0,v.useMemo)(()=>n===`inline`?Tp(a?am(C):t,S):[],[n,C,t,a,S]),{token:k}=mt(),A=(0,v.useMemo)(()=>{let e=mm(k(`--duration-fast-max`))??230,t=mm(k(`--duration-fast-min`)),n=t==null?50:Math.max(4,Math.round(t/10));return Math.min(Math.ceil(e/n),12)},[k]),j=(0,v.useRef)([]),M=(0,v.useRef)([]),N=(0,v.useRef)([]),P=C.length,F={offset:0,boundaries:(0,v.useMemo)(()=>{let e=n===`inline`?hm(M.current):gm(j.current),t=sp(N.current,e,A);return N.current=t,t},[n,P,A]),active:a},I=s?{sources:s,numberMap:new Map,nextNumber:1,style:c}:null;if(n===`inline`){let t=(0,q.jsx)(`span`,{ref:e,"data-testid":_,...J(Y(`markdown`,{density:r}),w(Q.root,Q.inlineRoot,m),h,g),children:O.map((e,t)=>Cm(e,t,o,F,I,b,f,d))});return M.current=O,j.current=[],t}let L=(0,q.jsx)(`div`,{role:`document`,ref:e,"data-testid":_,...J(Y(`markdown`,{density:r}),w(Q.root,m),h,g),children:D.map((e,t)=>Em(e,t,D.length,r,i,o,F,I,l?typeof l==`number`?`${l}px`:l:null,u,b,f,d,y))});return j.current=D,M.current=[],L}Dm.displayName=`Markdown`;function Om(e){return e.split(`/`).pop()??e}function km(e){let t=e.split(`/`);return t.length<=1?``:t.slice(0,-1).join(`/`)}function Am(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function jm(e){let t=e.split(`/`).pop()??e;return/\.(png|jpe?g|gif|webp)$/i.test(t)}function Mm(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)?`markdown`:t.endsWith(`.json`)?`json`:t.endsWith(`.yaml`)||t.endsWith(`.yml`)?`yaml`:t.endsWith(`.ts`)||t.endsWith(`.tsx`)?`typescript`:t.endsWith(`.js`)||t.endsWith(`.jsx`)?`javascript`:t.endsWith(`.py`)?`python`:t.endsWith(`.sh`)?`bash`:t.endsWith(`.html`)?`html`:t.endsWith(`.css`)?`css`:(t.endsWith(`.txt`),`plaintext`)}function Nm(e,t){return`/api/runs/${encodeURIComponent(e)}/artifact?path=${encodeURIComponent(t)}`}function Pm({runId:e,path:t,readOnly:n,onBackToTranscript:r,onHide:i}){let a=Am(t),o=jm(t),[s,c]=(0,v.useState)(a||o?`rendered`:`raw`),[l,u]=(0,v.useState)({status:`loading`}),[d,f]=(0,v.useState)(null);return(0,v.useEffect)(()=>{c(Am(t)||jm(t)?`rendered`:`raw`)},[t]),(0,v.useEffect)(()=>{if(jm(t)){let n=!1,r=null;return u({status:`loading`}),f(null),fetch(Nm(e,t),{headers:{...Sn()}}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Request failed (${e.status})`)}return e.blob()}).then(e=>{let t=URL.createObjectURL(e);if(n){URL.revokeObjectURL(t);return}r=t,f(t),u({status:`ready`,content:``})}).catch(e=>{n||u({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{n=!0,r&&URL.revokeObjectURL(r)}}let n=!1;return u({status:`loading`}),f(null),dr(e,t).then(e=>{n||u({status:`ready`,content:e})}).catch(e=>{n||u({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{n=!0}},[e,t]),(0,q.jsxs)(`div`,{className:`reader`,style:{height:`100%`},children:[(0,q.jsxs)(`div`,{className:`reader__bar`,children:[(0,q.jsx)(`span`,{className:`reader__name`,children:Om(t)}),km(t)?(0,q.jsx)(`span`,{className:`reader__path`,children:km(t)}):null,n?(0,q.jsx)(`span`,{className:`chip`,children:`read only`}):null,(0,q.jsx)(`span`,{className:`topbar__spacer`}),(0,q.jsxs)(`div`,{className:`stream__head-trail`,children:[(0,q.jsx)(`button`,{className:`btn btn--ghost btn--sm`,onClick:r,children:`← Transcript`}),i?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:i,children:`Hide workspace`}):null,(0,q.jsxs)(`div`,{className:`seg`,children:[(0,q.jsx)(`button`,{"data-active":s===`rendered`?`true`:void 0,disabled:!a&&!o,onClick:()=>{(a||o)&&c(`rendered`)},children:`Rendered`}),(0,q.jsx)(`button`,{"data-active":s===`raw`?`true`:void 0,disabled:o,onClick:()=>{o||c(`raw`)},children:`Raw`}),(0,q.jsx)(`button`,{disabled:!0,children:`Diff`})]})]})]}),(0,q.jsxs)(`div`,{className:`reader__body`,children:[l.status===`loading`?(0,q.jsx)(`p`,{className:`muted`,style:{padding:`var(--spacing-6)`},children:`Loading…`}):null,l.status===`error`?(0,q.jsx)(`div`,{style:{padding:`var(--spacing-6)`},children:(0,q.jsxs)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:[(0,q.jsx)(`div`,{className:`gate__label`,style:{color:`var(--color-text-red)`},children:`Could not load artifact`}),(0,q.jsx)(`p`,{className:`gate__question`,style:{color:`var(--color-text-primary)`},children:l.message})]})}):null,l.status===`ready`?(0,q.jsx)(`div`,{className:`page`,children:o?d?(0,q.jsx)(`img`,{src:d,alt:Om(t),style:{maxWidth:`100%`,height:`auto`,display:`block`}}):null:s===`rendered`&&a?l.content.trim().length===0?(0,q.jsx)(`p`,{className:`muted`,children:`Empty file.`}):(0,q.jsx)(Dm,{headingLevelStart:2,contentWidth:`76ch`,children:l.content}):(0,q.jsx)(Uc,{code:l.content,language:Mm(t),title:Om(t),container:`section`,width:`100%`})}):null]})]})}function Fm({question:e,note:t,onNoteChange:n,onAccept:r,onReject:i,isSubmitting:a,error:o,refs:s,children:c}){let l=!!a;return(0,q.jsxs)(`div`,{className:`decide`,style:{height:`100%`},children:[(0,q.jsxs)(`div`,{className:`decide__gate`,children:[(0,q.jsxs)(`div`,{className:`decide__label`,children:[(0,q.jsx)(`span`,{className:`dot dot--waiting`}),mi(),` · artifact_backed`]}),(0,q.jsx)(`p`,{className:`decide__q`,children:e}),s?(0,q.jsx)(`div`,{className:`decide__refs`,children:s}):null,o?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-3)`,marginBottom:`var(--spacing-3)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsxs)(`p`,{style:{margin:0,fontSize:`var(--font-size-sm)`},children:[`Could not submit answer: `,o]})}):null,(0,q.jsx)(`textarea`,{value:t,onChange:e=>n(e.target.value),disabled:l,placeholder:`Optional review notes`,rows:3}),(0,q.jsxs)(`div`,{className:`decide__buttons`,children:[(0,q.jsx)(`button`,{className:`btn btn--accept`,disabled:l,onClick:r,children:a?`Submitting…`:`Accept`}),(0,q.jsx)(`button`,{className:`btn btn--reject`,disabled:l,onClick:i,children:`Reject`})]})]}),c?(0,q.jsx)(`div`,{className:`decide__body`,children:c}):null]})}function Im(e){if(!e||typeof e!=`object`)return null;let t=e.kind;return t===`free_text`||t===`confirm`||t===`multi_question`||t===`artifact_backed`?e:null}function Lm(e){if(!e||typeof e!=`object`)return null;let t=e.kind;return t===`free_text`||t===`confirm`||t===`multi_question`||t===`artifact_backed`?e:null}function Rm(e){let t=0;for(let n of e)n.event===`operator_prompt`&&Im(n.prompt)?.kind===`artifact_backed`&&(t+=1);return Math.max(t,1)}function zm(e){let t=[];return e.forEach((e,n)=>{if(e.event===`operator_prompt`){t.push({key:`ask-${e.at??n}`,label:`Asked you`,at:e.at});return}if(e.event!==`operator_answer`)return;let r=Lm(e.answer),i=`Answered`,a;r?.kind===`artifact_backed`||r?.kind===`confirm`?(i=r.decision===`reject`?`Rejected`:`Accepted`,a=r.text):r?.kind===`free_text`&&(a=r.text),t.push({key:`ans-${e.at??n}`,label:i,at:e.at,note:a})}),t}function Bm(e){if(!e)return``;try{let t=new Date(e),n=Math.round((Date.now()-t.getTime())/1e3);return n<60?`just now`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:t.toLocaleDateString()}catch{return``}}function Vm({runId:e,stageId:t,prompt:n,events:r,inboundEnvelope:i,inboundFromStageId:a,inboundToStageId:o,selectedPath:s,onSelectArtifact:c,onOpenInboundEnvelope:l}){let[u,d]=(0,v.useState)(``),{submitting:f,error:p,locked:m,submitIntent:h}=yl(e,t,{promptId:n.id,kind:n.kind}),g=Rm(r),_=zm(r);async function y(e){await h({type:`decision`,decision:e,note:u})}let b=a&&o?`${a} → ${o}`:a??`previous stage`;return(0,q.jsxs)(Fm,{question:n.message,note:u,onNoteChange:d,onAccept:()=>void y(`accept`),onReject:()=>void y(`reject`),isSubmitting:f||m,error:p,refs:n.artifacts.length>0?(0,q.jsx)(q.Fragment,{children:n.artifacts.map(e=>(0,q.jsx)(`button`,{className:`chip${e===s?` chip--active`:``}`,onClick:()=>c(e),style:e===s?{borderColor:`var(--color-warning)`,background:`var(--color-background-yellow)`}:void 0,children:e.split(`/`).pop()??e},e))}):void 0,children:[(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:[`Iteration `,g,`. A rejection returns to the same live session, which revises this file and asks again — the stage is not restarted.`]}),_.length>0?(0,q.jsxs)(`div`,{style:{marginTop:`var(--spacing-3)`},children:[(0,q.jsx)(`strong`,{style:{fontSize:`var(--font-size-sm)`},children:`Review history`}),_.map(e=>(0,q.jsxs)(`div`,{style:{marginTop:`var(--spacing-2)`},children:[(0,q.jsx)(`span`,{style:{fontSize:`var(--font-size-sm)`,fontWeight:500},children:e.label}),e.at?(0,q.jsx)(`span`,{className:`muted`,style:{fontSize:`var(--font-size-xs)`,marginLeft:`var(--spacing-2)`,fontFamily:`var(--font-family-code)`},children:Bm(e.at)}):null,e.note?(0,q.jsx)(`p`,{className:`muted`,style:{margin:`2px 0 0`,fontSize:`var(--font-size-sm)`},children:e.note}):null]},e.key))]}):null,i?(0,q.jsxs)(`div`,{style:{marginTop:`var(--spacing-3)`},children:[(0,q.jsx)(`strong`,{style:{fontSize:`var(--font-size-sm)`},children:`Inbound context`}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,margin:`2px 0 var(--spacing-2)`},children:i.summary}),l?(0,q.jsx)(`button`,{className:`btn btn--ghost btn--sm`,onClick:l,children:b}):(0,q.jsx)(`span`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:b})]}):null]})}function Hm({envelope:e,onArtifactClick:t,payloadMaxHeight:n=280}){return(0,q.jsxs)(`div`,{className:`drawer__grid`,children:[(0,q.jsxs)(`dl`,{className:`kv`,children:[(0,q.jsx)(`dt`,{children:`Summary`}),(0,q.jsx)(`dd`,{children:e.summary}),(0,q.jsx)(`dt`,{children:`Artifacts`}),(0,q.jsx)(`dd`,{children:e.artifacts.length===0?(0,q.jsx)(`span`,{className:`muted`,children:`none`}):e.artifacts.map(e=>{let n=e.split(`/`).pop()??e;return t?(0,q.jsxs)(`button`,{type:`button`,className:`chip chip--file`,onClick:()=>t(e),children:[`◆ `,n]},e):(0,q.jsxs)(`span`,{className:`chip chip--file`,children:[`◆ `,n]},e)})}),e.notes?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Notes`}),(0,q.jsx)(`dd`,{className:`muted`,children:e.notes})]}):null]}),e.payload?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`eyebrow`,style:{marginBottom:`var(--spacing-2)`},children:`payload`}),(0,q.jsx)(Uc,{code:JSON.stringify(e.payload,null,2),language:`json`,container:`section`,maxHeight:n,width:`100%`})]}):(0,q.jsx)(`p`,{className:`muted`,children:`No payload.`})]})}function Um(e,t,n){let r=e=>n?.(e)??e;return t?`${r(e)} → ${r(t)}`:r(e)}function Wm({fromStageId:e,toStageId:t,envelope:n,onBackToTranscript:r,onHide:i,onArtifactClick:a,stageLabel:o}){let s=Um(e,t,o);return(0,q.jsxs)(`div`,{className:`stream`,style:{height:`100%`},children:[(0,q.jsxs)(`header`,{className:`stream__head`,children:[(0,q.jsx)(`h3`,{className:`stream__name`,children:`Handoff envelope`}),(0,q.jsx)(`span`,{className:`mono muted`,children:s}),(0,q.jsx)(`span`,{className:`topbar__spacer`}),(0,q.jsxs)(`div`,{className:`stream__head-trail`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:r,children:`← Transcript`}),i?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:i,children:`Hide workspace`}):null]})]}),(0,q.jsx)(`div`,{className:`stream__body`,children:(0,q.jsx)(Hm,{envelope:n,onArtifactClick:a,payloadMaxHeight:480})})]})}function Gm(e){return e===`success`?`status status--succeeded`:e===`failure`?`status status--failed`:`status`}function Km(e){return e===`success`?`dot dot--succeeded`:e===`failure`?`dot dot--failed`:`dot`}function qm({isOpen:e,onClose:t,fromStageId:n,toStageId:r,envelope:i,onOpenFullRecord:a,onArtifactClick:o}){let s=r?`${n} → ${r}`:n;return(0,v.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t()}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),(0,q.jsxs)(`aside`,{className:`drawer`,hidden:!e,children:[(0,q.jsxs)(`div`,{className:`drawer__head`,children:[(0,q.jsx)(`span`,{className:`eyebrow`,children:`Handoff envelope`}),(0,q.jsx)(`span`,{className:`mono muted`,children:s}),(0,q.jsxs)(`span`,{className:Gm(i.status),children:[(0,q.jsx)(`span`,{className:Km(i.status)}),` `,i.status]}),(0,q.jsx)(`span`,{style:{marginLeft:`auto`}}),a?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:a,children:`Open full record`}):null,(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:t,children:`Close`})]}),(0,q.jsx)(Hm,{envelope:i,onArtifactClick:o})]})}function Jm(e){let t={submitting:!1,error:null},n=new Set,r=()=>t,i=()=>{for(let e of n)e()};return{getState:r,decide:async(n,r)=>{if(!t.submitting){t={submitting:!0,error:null},i();try{await e.submit(n,r),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{t={...t,submitting:!1},i()}}},clearError:()=>{t.error!==null&&(t={...t,error:null},i())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Ym(e,t){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(t);r.current=t;let i=(0,v.useRef)(null);i.current===null&&(i.current=Jm({submit:async(e,t)=>{await cr(n.current,e,t)},onSuccess:()=>r.current()}));let a=i.current,[o,s]=(0,v.useState)(()=>a.getState());(0,v.useEffect)(()=>a.subscribe(()=>s(a.getState())),[a]);let c=(0,v.useCallback)((e,t)=>void a.decide(e,t),[a]),l=(0,v.useCallback)(()=>a.clearError(),[a]);return{submitting:o.submitting,error:o.error,decide:c,clearError:l}}function Xm({runId:e,decide:t,onSuccess:n}){let[r,i]=(0,v.useState)(``),{submitting:a,error:o,decide:s}=Ym(e,n),c=a,l=t.replayNumber!==void 0&&t.maxReplays!==void 0?`Replay ${t.replayNumber} of ${t.maxReplays}`:t.maxReplays===void 0?null:`Max ${t.maxReplays} replays`;function u(e){let n=r.trim();s(t.sourceStageId,{decision:e,loopId:t.loopId,...n?{reason:n}:{}})}return(0,q.jsx)(`div`,{className:`decide feedback-decide`,style:{height:`100%`},children:(0,q.jsxs)(`div`,{className:`decide__gate`,children:[(0,q.jsxs)(`div`,{className:`decide__label`,children:[(0,q.jsx)(`span`,{className:`dot dot--waiting`}),mi(),` · feedback_loop_decision`]}),(0,q.jsx)(`p`,{className:`decide__q`,children:t.summary??`Feedback loop limit reached — extend, continue, or abandon`}),(0,q.jsxs)(`div`,{className:`decide__refs`,children:[(0,q.jsxs)(`span`,{children:[`Source `,(0,q.jsx)(`strong`,{children:t.sourceStageId})]}),t.deferredTarget?(0,q.jsxs)(`span`,{children:[`Target `,(0,q.jsx)(`strong`,{children:t.deferredTarget})]}):null,l?(0,q.jsx)(`span`,{children:l}):null]}),o?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-3)`,marginBottom:`var(--spacing-3)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsxs)(`p`,{style:{margin:0,fontSize:`var(--font-size-sm)`},children:[`Could not submit decision: `,o]})}):null,(0,q.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),disabled:c,placeholder:`Optional reason`,rows:3}),(0,q.jsxs)(`div`,{className:`decide__buttons`,children:[(0,q.jsx)(`button`,{className:`btn btn--accept`,disabled:c,onClick:()=>u(`extend`),children:a?`Submitting…`:`Extend`}),(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:c,onClick:()=>u(`continue`),children:`Continue`}),(0,q.jsx)(`button`,{className:`btn btn--reject`,disabled:c,onClick:()=>u(`abandon`),children:`Abandon`})]}),(0,q.jsx)(`p`,{className:`decide__hint`,children:`Extend raises the replay budget and continues the deferred send-back. Continue accepts the limit and advances. Abandon stops the loop.`})]})})}function Zm(e){return`Replay ${e.current_replay_number??0} of ${e.policy.max_replays}`}function Qm(e){for(let t=e.length-1;t>=0;t--){let n=e[t]?.replays;if(!n||n.length===0)continue;let r=n[n.length-1]?.replay;if(r?.target_stage_id)return r.target_stage_id}return null}function $m(e,t){let n=e.deferred_send_back?.target??Qm(t)??e.policy.target??null;return n?`${e.source_stage_id} → ${n}`:null}function eh(e){switch(e){case`waiting_for_human`:return`status status--waiting`;case`completed`:case`continued`:return`status status--succeeded`;case`abandoned`:return`status status--failed`;default:return`status`}}function th({active:e,history:t}){if(!e&&t.length===0)return null;let n=e??t[t.length-1]?.loop,r=n?$m(n,t):null,i=n?r??Zm(n):null,a=n?.state===`waiting_for_human`,o=t.flatMap(e=>e.replays),s=t.reduce((e,t)=>{let n=t.fork_generations.filter(e=>e.status===`superseded`).length;for(let e of t.replays)n+=e.fork_generations.filter(e=>e.status===`superseded`).length;return e+n},0);return(0,q.jsx)(`section`,{className:`feedback-loop-panel block`,children:(0,q.jsx)(tl,{trigger:(0,q.jsxs)(`span`,{className:`feedback-loop-panel__trigger`,children:[(0,q.jsx)(`span`,{className:`block__pipeline`,children:`Feedback loop`}),n?(0,q.jsx)(`span`,{className:eh(n.state),children:n.state.replaceAll(`_`,` `)}):null,i?(0,q.jsx)(`span`,{className:`feedback-loop-panel__summary`,children:i}):null]}),defaultIsOpen:a,children:(0,q.jsxs)(`div`,{className:`feedback-loop-panel__body`,children:[n?(0,q.jsxs)(`dl`,{className:`kv`,children:[(0,q.jsx)(`dt`,{children:`Budget`}),(0,q.jsx)(`dd`,{children:Zm(n)}),r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Route`}),(0,q.jsx)(`dd`,{children:r})]}):null,(0,q.jsx)(`dt`,{children:`Session`}),(0,q.jsx)(`dd`,{children:n.policy.replay_session})]}):null,o.length>0?(0,q.jsxs)(`div`,{className:`feedback-loop-panel__timeline`,children:[(0,q.jsx)(`div`,{className:`decide__label`,children:`Replay timeline`}),(0,q.jsx)(`ol`,{className:`feedback-loop-panel__list`,children:o.map(({replay:e,stage_passes:t})=>(0,q.jsxs)(`li`,{children:[(0,q.jsxs)(`span`,{children:[`#`,e.replay_number,` `,e.source_stage_id,` →`,` `,e.target_stage_id]}),(0,q.jsxs)(`span`,{className:`feedback-loop-panel__status`,children:[e.status.replaceAll(`_`,` `),t.length>0?` · ${t.length} stage pass${t.length===1?``:`es`}`:``]})]},e.replay_id))})]}):null,s>0?(0,q.jsxs)(`p`,{className:`block__sub`,children:[s,` superseded fork generation`,s===1?``:`s`,` hidden from the map.`]}):null]})},a?`waiting`:`idle`)})}var nh=160;function rh(e,t=nh){let n=e.trim();return n.length<=t?n:`${n.slice(0,t)}…`}function ih(e){let t=e.prompt;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`multi_question`){let e=n.questions?.length??0;return e===1?`1 question`:`${e} questions`}if(typeof n.message==`string`&&n.message.trim())return rh(n.message)}function ah(e){let t=e.answer;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`free_text`)return typeof n.text==`string`?rh(n.text):void 0;if(n.kind===`confirm`||n.kind===`artifact_backed`){let e=n.decision,t=typeof n.text==`string`&&n.text.trim()?rh(n.text):void 0;return e&&t?`${e} — ${t}`:e||t}if(n.kind===`multi_question`){let e=Object.keys(n.answers??{}).length;return e===1?`1 answer`:`${e} answers`}}function oh(e){switch(e.event){case`started`:return`Stage started`;case`succeeded`:return`Stage succeeded`;case`failed`:return`Stage failed`;case`interrupted`:return`Stage interrupted`;case`agent_start`:return`Agent started`;case`agent_end`:return`Agent settled`;case`turn_start`:return`Turn`;case`tool_start`:return`→ ${e.toolName??`tool`}`;case`tool_end`:return e.isError?`✕ ${e.toolName??`tool`}`:`✓ ${e.toolName??`tool`}`;case`tool_progress`:return`│ ${e.toolName??`tool`}`;case`message`:{let t=e.role??`message`;return e.text?`${t}: ${e.text}`:t}case`operator_prompt`:return`Operator prompt`;case`operator_answer`:return`Operator answer`;case`waiting_for_input`:return mi();case`resumed`:return`Stage resumed`;case`feedback_loop_decided`:return`Feedback loop decided`;default:return e.event}}function sh(e){let t=e.decision;if(t!==`extend`&&t!==`continue`&&t!==`abandon`)return;let n=typeof e.reason==`string`&&e.reason.trim()?rh(e.reason):void 0;return n?`${t} — ${n}`:t}function ch(e){if(e.event===`tool_start`&&e.argsPreview)return e.argsPreview;if(e.event===`tool_end`&&e.resultPreview)return e.resultPreview;if(e.event===`tool_progress`&&e.textPreview)return e.textPreview;if(e.event===`failed`&&e.reason||e.event===`interrupted`&&e.reason||e.event===`turn_start`&&e.reason)return e.reason;if(e.event===`operator_prompt`)return ih(e);if(e.event===`operator_answer`)return ah(e);if(e.event===`feedback_loop_decided`)return sh(e)}var lh=4;function uh(e,t){return`${e.event}-${e.at??`na`}-${t}`}function dh(e){if(!e||typeof e!=`object`)return null;let t=e.kind;return t===`free_text`||t===`confirm`||t===`multi_question`||t===`artifact_backed`?e:null}function fh(e){if(!e||typeof e!=`object`)return null;let t=e.kind;return t===`free_text`||t===`confirm`||t===`multi_question`||t===`artifact_backed`?e:null}function ph(e){return e===`tool_start`||e===`tool_end`||e===`tool_progress`}function mh(e){let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.event===`tool_start`){t.push({name:i.toolName??`tool`,args:i.argsPreview,at:i.at,id:i.toolCallId??`start-${r}`});continue}if(i.event===`tool_progress`){let e=-1;if(i.toolCallId&&(e=t.findIndex(e=>e.id===i.toolCallId)),e<0&&(e=t.length>0?t.length-1:-1),e<0)continue;let n=typeof i.textPreview==`string`?i.textPreview:void 0;n!==void 0&&(t[e].progressPreview=n);continue}if(i.event===`tool_end`){let e=i.toolCallId?t.findIndex(e=>e.id===i.toolCallId):t.findIndex(e=>e.name===(i.toolName??`tool`)),r=e>=0?t.splice(e,1)[0]:void 0;n.push({name:i.toolName??r?.name??`tool`,status:i.isError?`error`:`complete`,args:r?.args,result:i.resultPreview,at:i.at??r?.at,startedAt:r?.at})}}for(let e of t)n.push({name:e.name,status:`running`,args:e.args,progressPreview:e.progressPreview,at:e.at,startedAt:e.at});return n}function hh({at:e}){return e?(0,q.jsx)(`time`,{children:ii(e)}):null}function gh({envelope:e}){return(0,q.jsxs)(`div`,{className:`turn`,children:[(0,q.jsx)(`div`,{className:`turn__who`,children:`Envelope`}),(0,q.jsxs)(`div`,{className:`bubble`,style:{borderColor:`var(--color-border-green)`},children:[(0,q.jsx)(`p`,{children:e.summary}),e.artifacts.length>0?(0,q.jsx)(`p`,{className:`muted`,children:e.artifacts.map(e=>e.split(`/`).pop()??e).join(` · `)}):null]})]})}function _h({calls:e}){let[t,n]=(0,v.useState)(!1),r=!t&&e.length>lh?e.length-lh:0,i=r>0?e.slice(0,lh):e;return(0,q.jsxs)(`div`,{className:`tools`,children:[i.map((e,t)=>{let n=e.status===`running`?e.progressPreview:e.result;return(0,q.jsxs)(`div`,{className:e.status===`error`?`tool tool--error`:`tool`,children:[(0,q.jsxs)(`span`,{children:[e.status===`error`?`✕`:e.status===`running`?`▸`:`⚙`,` `,e.name,e.args?` ${e.args}`:``,n?` · ${n}`:``]}),(0,q.jsx)(hh,{at:e.at})]},`${e.name}-${e.at??t}`)}),r>0?(0,q.jsxs)(`button`,{type:`button`,className:`tools__more`,onClick:()=>n(!0),children:[`Show `,r,` more`]}):null]})}function vh({event:e}){let t=e.role??`message`,n=e.text?.trim();return n?(0,q.jsxs)(`div`,{className:`turn`,children:[(0,q.jsxs)(`div`,{className:`turn__who`,children:[t,(0,q.jsx)(hh,{at:e.at})]}),(0,q.jsx)(`div`,{className:`bubble`,children:(0,q.jsx)(`p`,{children:n})})]}):null}function yh({event:e}){let t=dh(e.prompt);return(0,q.jsxs)(`div`,{className:`ask`,children:[(0,q.jsxs)(`div`,{className:`ask__label`,children:[t?.kind??`ask`,(0,q.jsx)(`span`,{style:{marginLeft:`auto`},children:(0,q.jsx)(hh,{at:e.at})})]}),t?.kind===`multi_question`?(0,q.jsx)(`ol`,{className:`qlist`,children:t.questions.map(e=>(0,q.jsxs)(`li`,{children:[e.message,(0,q.jsx)(`small`,{children:e.kind})]},e.id))}):(0,q.jsx)(`p`,{className:`ask__q`,children:t&&`message`in t?t.message:ch(e)})]})}function bh({event:e}){let t=fh(e.answer),n,r;if(t?.kind===`free_text`)n=`answered`,r=t.text;else if(t?.kind===`confirm`||t?.kind===`artifact_backed`)n=t.decision,r=t.text;else if(t?.kind===`multi_question`){let e=Object.keys(t.answers??{}).length;n=e===1?`1 answer`:`${e} answers`}else r=ch(e);let i=n===`accept`||n===`answered`||n===`reject`?n:void 0;return(0,q.jsxs)(`div`,{className:`answer`,children:[(0,q.jsxs)(`div`,{className:`turn__who`,children:[n?(0,q.jsx)(`span`,{className:`answer__verdict`,...i?{"data-v":i}:{},children:n}):(0,q.jsx)(`span`,{children:`Operator`}),(0,q.jsx)(hh,{at:e.at})]}),r?(0,q.jsx)(`p`,{children:r}):null]})}function xh({event:e}){let t=ch(e),n=oh(e);return(0,q.jsx)(`div`,{className:`divider-iter`,children:t?`${n} · ${t}`:n})}function Sh(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(ph(r.event)){let r=[];for(;n<e.length&&ph(e[n].event);)r.push(e[n]),n+=1;let i=mh(r);i.length>0&&t.push({kind:`tools`,calls:i});continue}r.event===`message`?r.text?.trim()&&t.push({kind:`message`,event:r}):r.event===`operator_prompt`?t.push({kind:`operator_prompt`,event:r}):r.event===`operator_answer`?t.push({kind:`operator_answer`,event:r}):r.event===`turn_start`&&!ch(r)||t.push({kind:`system`,event:r}),n+=1}return t}function Ch({events:e,inboundEnvelope:t}){let n=[];t&&n.push((0,q.jsx)(gh,{envelope:t},`inbound-envelope`));let r=Sh(e);for(let e=0;e<r.length;e++){let t=r[e];if(t.kind===`tools`){n.push((0,q.jsx)(_h,{calls:t.calls},`tools-${e}`));continue}if(t.kind===`message`){n.push((0,q.jsx)(vh,{event:t.event},uh(t.event,e)));continue}if(t.kind===`operator_prompt`){n.push((0,q.jsx)(yh,{event:t.event},uh(t.event,e)));continue}if(t.kind===`operator_answer`){n.push((0,q.jsx)(bh,{event:t.event},uh(t.event,e)));continue}n.push((0,q.jsx)(xh,{event:t.event},uh(t.event,e)))}return n.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No activity yet.`}):(0,q.jsx)(q.Fragment,{children:n})}function wh(e){for(let t=e.length-1;t>=0;t--)if(e[t].kind===`system`&&e[t].status===`failed`)return e[t].id;if(!e.some(e=>e.kind===`system`&&e.sourceEvent===`succeeded`)){for(let t=e.length-1;t>=0;t--)if(e[t].kind===`tool`&&e[t].status===`failed`)return e[t].id}}function Th(e,t){let n=e.find(e=>e.id===t);if(!(!n||n.kind!==`system`))return n.detail??n.label}var Eh=160;function Dh(e,t){let n=e.slice(0,t),r=n.lastIndexOf(` `);return r>0?{shown:n.slice(0,r),cutIndex:r+1}:{shown:n,cutIndex:t}}function Oh(e){let t=e.indexOf(`
|
|
118
|
+
`),n=t===-1?e:e.slice(0,t);if(n.length<=Eh){let r=(t===-1?``:e.slice(t+1)).replace(/^\n+/,``);return{preview:n,hasMore:r.trim().length>0,rest:r}}let{shown:r,cutIndex:i}=Dh(n,Eh);return{preview:`${r}…`,hasMore:!0,rest:e.slice(i).replace(/^\n+/,``)}}function kh(e){if(e<1e3)return`<1s`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ah(e,t){if(e.kind!==`tool`||!e.startedAt)return;let n=Date.parse(e.startedAt);if(Number.isNaN(n))return;if(e.status===`running`)return Math.max(0,t-n);if(!e.finishedAt)return;let r=Date.parse(e.finishedAt);if(!Number.isNaN(r))return Math.max(0,r-n)}function jh(e){return e.status===`error`?`failed`:e.status===`running`?`running`:`succeeded`}var Mh={read:{key:`file_path`,isPath:!0},write:{key:`file_path`,isPath:!0},edit:{key:`file_path`,isPath:!0},notebookedit:{key:`notebook_path`,isPath:!0},bash:{key:`command`,isPath:!1},grep:{key:`pattern`,isPath:!1},glob:{key:`pattern`,isPath:!1},webfetch:{key:`url`,isPath:!1},websearch:{key:`query`,isPath:!1}},Nh=new Set([`read`]);function Ph(e){if(e)try{let t=JSON.parse(e);return t&&typeof t==`object`?t:void 0}catch{return}}function Fh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ih(e,t){let n=Ph(e)?.[t];if(typeof n==`string`)return n;if(!e)return;let r=e.match(RegExp(`"${Fh(t)}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`));return r?r[1]:void 0}function Lh(e){return e.split(`/`).pop()||e}function Rh(e){let t=Mh[e.name.toLowerCase()];if(!t)return e.name;let n=Ih(e.args,t.key);return typeof n!=`string`||!n.trim()?e.name:`${e.name} ${t.isPath?Lh(n):n}`}function zh(e){if(e.status===`running`)return e.progressPreview;if(!(e.status===`complete`&&Nh.has(e.name.toLowerCase())))return e.result}function Bh(e,t){return{id:t,kind:`tool`,label:Rh(e),status:jh(e),detail:zh(e),at:e.at,startedAt:e.startedAt,finishedAt:e.status===`running`?void 0:e.at,defaultExpanded:!1}}function Vh(e,t){return{id:t,kind:`message`,label:e.role??`message`,status:`succeeded`,detail:e.text?.trim(),at:e.at,defaultExpanded:!1}}function Hh(e,t,n){return{id:n,kind:e,label:oh(t),status:e===`system`&&t.event===`failed`?`failed`:`succeeded`,detail:ch(t),at:t.at,defaultExpanded:!1,sourceEvent:e===`system`?t.event:void 0}}function Uh(e){let t=Sh(e),n=[],r=0;for(let e of t){if(e.kind===`tools`){for(let t of e.calls)n.push(Bh(t,`step-${r}`)),r+=1;continue}let t=`step-${r}`;r+=1,e.kind===`message`?n.push(Vh(e.event,t)):e.kind===`operator_prompt`?n.push(Hh(`operator_prompt`,e.event,t)):e.kind===`operator_answer`?n.push(Hh(`operator_answer`,e.event,t)):n.push(Hh(`system`,e.event,t))}let i=wh(n);for(let e of n)e.defaultExpanded=e.status===`running`||e.id===i;return n}function Wh({step:e,now:t,isOpen:n,onToggle:r}){let i=Ah(e,t),{preview:a,hasMore:o,rest:s}=e.detail?Oh(e.detail):{preview:``,hasMore:!1,rest:``};return(0,q.jsxs)(`div`,{id:`logstep-${e.id}`,className:`logstep logstep--${e.status}`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`logstep__row${o?``:` logstep__row--static`}`,disabled:!o,"aria-expanded":o?n:void 0,onClick:o?()=>r(!n):void 0,children:[(0,q.jsx)(fa,{icon:`chevronDown`,size:`sm`,className:`logstep__chevron${o?n?` logstep__chevron--open`:``:` logstep__chevron--hidden`}`}),(0,q.jsx)(`span`,{className:`dot dot--${e.status} logstep__dot`}),(0,q.jsxs)(`span`,{className:`logstep__text`,children:[(0,q.jsxs)(`span`,{className:`logstep__label-row`,children:[(0,q.jsx)(`span`,{className:`logstep__label`,children:e.label}),i===void 0?null:(0,q.jsx)(`span`,{className:`logstep__duration`,children:kh(i)})]}),a?(0,q.jsx)(`span`,{className:`logstep__preview`,children:a}):null]})]}),o&&n?(0,q.jsx)(`pre`,{className:`logstep__detail`,children:s}):null]})}function Gh(e){let t=document.getElementById(`logstep-${e}`);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`logstep--highlight`),window.setTimeout(()=>t.classList.remove(`logstep--highlight`),1500))}function Kh({events:e,headerAction:t}){let n=Uh(e),r=Date.now(),i=wh(n),a=Th(n,i),[o,s]=(0,v.useState)({});return(0,q.jsxs)(`div`,{className:`stream`,style:{height:`100%`},children:[(0,q.jsxs)(`header`,{className:`stream__head`,children:[(0,q.jsx)(`h3`,{className:`stream__name`,children:`Logs`}),t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`topbar__spacer`}),(0,q.jsx)(`div`,{className:`stream__head-trail`,children:t})]}):null]}),(0,q.jsx)(`div`,{className:`stream__body`,children:n.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No activity yet.`}):(0,q.jsx)(`div`,{className:`logpanel`,children:n.map(e=>(0,q.jsx)(Wh,{step:e,now:r,isOpen:o[e.id]??e.defaultExpanded,onToggle:t=>s(n=>({...n,[e.id]:t}))},e.id))})}),a&&i?(0,q.jsxs)(`div`,{className:`logpanel__banner`,children:[(0,q.jsx)(`span`,{className:`logpanel__banner-text`,children:a}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:()=>{s(e=>{if(!(i in e))return e;let t={...e};return delete t[i],t}),Gh(i)},children:`Jump to failing step`})]}):null]})}function qh(e){let t=new Map;for(let n of e){let e=t.get(n.layer)??[];e.push(n),t.set(n.layer,e)}return[...t.keys()].sort((e,t)=>e-t).map(e=>(t.get(e)??[]).sort((e,t)=>e.layer_order-t.layer_order))}function Jh(e){return qh(e).flat()}function Yh(e,t,n,r=0){return{stageId:e,x:t*520,y:r+n*340,width:400,height:128,layerIndex:t,indexInLayer:n}}function Xh(e,t){return t<=1||e>=t?0:(t-e)/2*340}function Zh(e){let t=e?.plannedStageIds??[],n=e?.liveStageIds??[];if(t.length===0)return n;let r=new Set,i=[];for(let e of t)r.add(e),i.push(e);for(let e of n)r.has(e)||i.push(e);return i}function Qh(e,t){if(!e.nodes.length){let e=Zh(t);return{nodes:e.map((e,t)=>Yh(e,t,0)),edges:e.slice(1).map((t,n)=>({from:e[n],to:t}))}}let n=qh(e.nodes),r=n.reduce((e,t)=>Math.max(e,t.length),0);return{nodes:n.flatMap((e,t)=>{let n=Xh(e.length,r);return e.map((e,r)=>Yh(e.stage_id,t,r,n))}),edges:e.edges.map(e=>({from:e.from,to:e.to}))}}function $h(e){return e===`failed`}function eg(e){return e===`running`}function tg(e){if(e.status===`interrupted`)return!0;if(e.status!==`failed`)return!1;let t;for(let n of e.events)n.event===`failed`&&(t=n.reason);return typeof t==`string`&&t.startsWith(`stage timed out after `)}function ng(e,t){return e.retryingStageIds.has(t)||e.abandoningStageId===t||(e.resumingStageIds?.has(t)??!1)}function rg(e){let t={retryingStageIds:new Set,error:null},n=new Set,r=()=>t,i=()=>{for(let e of n)e()};return{getState:r,retry:async n=>{if(t.retryingStageIds.has(n))return;let r=new Set(t.retryingStageIds);r.add(n),t={retryingStageIds:r,error:null},i();try{await e.retry(n),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{let e=new Set(t.retryingStageIds);e.delete(n),t={...t,retryingStageIds:e},i()}},clearError:()=>{t.error!==null&&(t={...t,error:null},i())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function ig(e,t){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(t);r.current=t;let i=(0,v.useRef)(null);i.current===null&&(i.current=rg({retry:async e=>{await er(n.current,e)},onSuccess:()=>r.current()}));let a=i.current,[o,s]=(0,v.useState)(()=>a.getState());(0,v.useEffect)(()=>a.subscribe(()=>s(a.getState())),[a]);let c=(0,v.useCallback)(e=>void a.retry(e),[a]),l=(0,v.useCallback)(()=>a.clearError(),[a]);return{retryingStageIds:o.retryingStageIds,error:o.error,retry:c,clearError:l}}function ag(e){let t={resumingStageIds:new Set,error:null},n=new Set,r=()=>t,i=()=>{for(let e of n)e()};return{getState:r,resume:async n=>{if(t.resumingStageIds.has(n))return;let r=new Set(t.resumingStageIds);r.add(n),t={resumingStageIds:r,error:null},i();try{await e.resume(n),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{let e=new Set(t.resumingStageIds);e.delete(n),t={...t,resumingStageIds:e},i()}},clearError:()=>{t.error!==null&&(t={...t,error:null},i())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function og(e,t){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(t);r.current=t;let i=(0,v.useRef)(null);i.current===null&&(i.current=ag({resume:async e=>{await tr(n.current,e)},onSuccess:()=>r.current()}));let a=i.current,[o,s]=(0,v.useState)(a.getState);(0,v.useEffect)(()=>a.subscribe(()=>s(a.getState())),[a]);let c=(0,v.useCallback)(e=>{a.resume(e)},[a]);return{resumingStageIds:o.resumingStageIds,error:o.error,resume:c,clearError:a.clearError}}function sg(e){let t={abandoningStageId:null,error:null},n=!1,r=new Set,i=()=>t,a=()=>{for(let e of r)e()};return{getState:i,abandon:async r=>{if(!n&&(e.confirm?.(r)??window.confirm(`This stage will be marked failed. Retry stage will become available.`))){n=!0,t={abandoningStageId:r,error:null},a();try{await e.abandon(r),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{n=!1,t={...t,abandoningStageId:null},a()}}},clearError:()=>{t.error!==null&&(t={...t,error:null},a())},subscribe:e=>(r.add(e),()=>{r.delete(e)})}}function cg(e,t){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(t);r.current=t;let i=(0,v.useRef)(null);i.current===null&&(i.current=sg({abandon:async e=>{await ir(n.current,e)},onSuccess:()=>r.current()}));let a=i.current,[o,s]=(0,v.useState)(()=>a.getState());(0,v.useEffect)(()=>a.subscribe(()=>s(a.getState())),[a]);let c=(0,v.useCallback)(e=>void a.abandon(e),[a]),l=(0,v.useCallback)(()=>a.clearError(),[a]);return{abandoningStageId:o.abandoningStageId,error:o.error,abandon:c,clearError:l}}var lg=.25,ug=1.8;function dg(e,t){return Math.abs(e.y+e.height/2-(t.y+t.height/2))<e.height*.75}function fg(e,t){let n=e.x+e.width/2,r=t.x+t.width/2;return Math.max(0,Math.round(Math.abs(r-n)/520)-1)*12}function pg(e,t,n,r,i){return`M${e} ${t} V${i} H${n} V${r}`}function mg(e,t){let n=e.y+e.height/2,r=t.y+t.height/2,i=fg(e,t);if(dg(e,t)){let n=e.x+e.width/2,r=e.y+e.height,a=t.x+t.width/2,o=t.y+t.height;return pg(n,r,a,o,Math.max(r,o)+48+i)}if(r>=n){let n=e.x+e.width/2,r=e.y+e.height,a=t.x+t.width/2,o=t.y,s=o-r;return pg(n,r,a,o,s>=48?r+s/2:Math.max(r,o)+48+i)}let a=e.x+e.width/2,o=e.y,s=t.x+t.width/2,c=t.y;return pg(a,o,s,c,Math.min(o,c)-48-i)}function hg(e){let t=e.match(/[MLHVmlhv]|-?\d*\.?\d+/g);if(!t)return[];let n=[],r=0,i=0,a=0;for(;a<t.length;){let e=t[a++].toUpperCase();e===`M`||e===`L`?(r=Number(t[a++]),i=Number(t[a++]),n.push({x:r,y:i})):e===`H`?(r=Number(t[a++]),n.push({x:r,y:i})):e===`V`&&(i=Number(t[a++]),n.push({x:r,y:i}))}return n}function gg(e,t){let n=hg(mg(e,t));if(n.length===0)return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x)+Math.max(e.width,t.width),height:Math.abs(t.y-e.y)+Math.max(e.height,t.height)};let r=n.map(e=>e.x),i=n.map(e=>e.y),a=Math.min(...r),o=Math.max(...r),s=Math.min(...i),c=Math.max(...i);return{x:a,y:s,width:o-a,height:c-s}}function _g(e,t,n=4){return Math.hypot(e,t)>n}function vg(e,t=24){if(e.length===0)return{x:0,y:0,width:0,height:0};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e)n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x+t.width),a=Math.max(a,t.y+t.height);return{x:n-t,y:r-t,width:i-n+t*2,height:a-r+t*2}}function yg(e,t){if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{panX:0,panY:0,zoom:1};let n=t.width-56,r=t.height-56;if(n<=0||r<=0)return{panX:0,panY:0,zoom:1};let i=Math.max(lg,Math.min(1.1,ug,n/e.width,r/e.height));return{zoom:i,panX:56+(n-e.width*i)/2-e.x*i,panY:56+(r-e.height*i)/2-e.y*i}}function bg(e,t){return e&&!t}function xg(e,t){return e===t?null:e}function Sg(e,t){return!!e.find(e=>e.stage_id===t)?.envelope}function Cg(e,t){return e===`waiting_for_input`||e===`pending`||e===`skipped`?null:e===`running`?`abandon`:e===`failed`||t?`retry`:null}function wg(e){switch(e){case`free_text`:return`free text`;case`confirm`:return`confirm`;case`multi_question`:return`multi-question`;case`artifact_backed`:return`artifact`}}function Tg(e,t,n,r){let i=Math.max(48,(n-e)/2);return`M${e} ${t} C${e+i} ${t} ${n-i} ${r} ${n} ${r}`}function Eg(e,t){return t?`abandoned`:e===`interrupted`?`waiting_for_input`:e}function Dg({layout:e,stages:t,nodeChrome:n,selectedStageId:r,onSelectStage:i,onDeselect:a,retryingStageIds:o,onRetryStage:s,resumingStageIds:c,onResumeStage:l,abandoningStageId:u=null,onAbandonStage:d,runId:f,showHint:p,feedbackOverlays:m=[]}){let h=(0,v.useRef)(null),g=(0,v.useRef)(!1),_=(0,v.useRef)(!1),y=(0,v.useRef)({width:0,height:0}),b=(0,v.useRef)(null),[x,S]=(0,v.useState)({width:0,height:0}),[C,w]=(0,v.useState)({x:0,y:0}),[T,E]=(0,v.useState)(1),[D,O]=(0,v.useState)(!1),k=new Map(t.map(e=>[e.stage_id,e])),A=new Map(n.map(e=>[e.stageId,e])),j=o??new Set,M=c??new Set;(0,v.useLayoutEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();S({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,v.useLayoutEffect)(()=>{g.current=!1,_.current=!1,y.current={width:0,height:0}},[f]);let N=()=>{let t=[...e.nodes];for(let n of m){let r=e.nodes.find(e=>e.stageId===n.from),i=e.nodes.find(e=>e.stageId===n.to);!r||!i||t.push(gg(r,i))}return vg(t)};(0,v.useLayoutEffect)(()=>{if(e.nodes.length===0||x.width===0||x.height===0)return;if(!g.current){let e=yg(N(),x);w({x:e.panX,y:e.panY}),E(e.zoom),g.current=!0,y.current={width:x.width,height:x.height};return}if(y.current.width===x.width&&y.current.height===x.height||(y.current={width:x.width,height:x.height},!bg(!0,_.current)))return;let t=yg(N(),x);w({x:t.panX,y:t.panY}),E(t.zoom)},[m,e.nodes,x.height,x.width]);let P=(e,t)=>{let n=t??{x:x.width/2,y:x.height/2},r=Math.max(lg,Math.min(ug,T*e)),i=(n.x-C.x)/T,a=(n.y-C.y)/T;_.current=!0,w({x:n.x-i*r,y:n.y-a*r}),E(r)},F=()=>{let t=h.current;if(!t||e.nodes.length===0)return;let n=t.getBoundingClientRect(),r=yg(N(),{width:n.width,height:n.height});w({x:r.panX,y:r.panY}),E(r.zoom),_.current=!1,g.current=!0,y.current={width:n.width,height:n.height}},I=e=>{e.target.closest(`.gnode`)||(e.currentTarget.setPointerCapture(e.pointerId),O(!0),b.current={id:e.pointerId,x:e.clientX,y:e.clientY,panX:C.x,panY:C.y})},L=e=>{let t=b.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;_g(n,r)&&(_.current=!0),w({x:t.panX+n,y:t.panY+r})},R=e=>{let t=b.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;b.current=null,O(!1),_g(n,r)||a()};return(0,q.jsxs)(`div`,{className:`graph-view`,children:[(0,q.jsxs)(`svg`,{className:`graph-grid`,"aria-hidden":`true`,width:`100%`,height:`100%`,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`pattern`,{id:`spatial-dots`,width:`24`,height:`24`,patternUnits:`userSpaceOnUse`,children:(0,q.jsx)(`circle`,{cx:`1`,cy:`1`,r:`1`,fill:`var(--color-border)`})})}),(0,q.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#spatial-dots)`})]}),(0,q.jsx)(`div`,{ref:h,className:D?`graph-stage dragging`:`graph-stage`,onPointerDown:I,onPointerMove:L,onPointerUp:R,onPointerCancel:R,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();if(e.metaKey||e.ctrlKey){P(e.deltaY<0?1.08:.92,{x:e.clientX-t.left,y:e.clientY-t.top});return}_.current=!0,w(t=>({x:t.x-e.deltaX,y:t.y-e.deltaY}))},children:(0,q.jsxs)(`svg`,{className:`graph-svg`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,q.jsxs)(`defs`,{children:[(0,q.jsx)(`marker`,{id:`spatial-arrow`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`3`,orient:`auto`,children:(0,q.jsx)(`path`,{d:`M0,0 L7,3 L0,6 Z`,fill:`var(--color-text-disabled)`})}),(0,q.jsx)(`marker`,{id:`spatial-arrow-active`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`3`,orient:`auto`,children:(0,q.jsx)(`path`,{d:`M0,0 L7,3 L0,6 Z`,fill:`var(--color-accent)`})}),(0,q.jsx)(`marker`,{id:`spatial-arrow-feedback`,markerWidth:`8`,markerHeight:`8`,refX:`7`,refY:`3`,orient:`auto`,children:(0,q.jsx)(`path`,{d:`M0,0 L7,3 L0,6 Z`,fill:`var(--color-warning)`})})]}),(0,q.jsxs)(`g`,{className:`world`,transform:`translate(${C.x} ${C.y}) scale(${T})`,children:[e.edges.map(n=>{let r=e.nodes.find(e=>e.stageId===n.from),i=e.nodes.find(e=>e.stageId===n.to);if(!r||!i)return null;let a=r.height,o=i.height,s=r.x+r.width,c=r.y+a/2,l=i.x,u=i.y+o/2,d=Sg(t,n.from);return(0,q.jsx)(`g`,{children:(0,q.jsx)(`path`,{className:d?`edge handoff`:`edge`,d:Tg(s,c,l,u),markerEnd:d?`url(#spatial-arrow-active)`:`url(#spatial-arrow)`})},`${n.from}->${n.to}`)}),m.map(t=>{let n=e.nodes.find(e=>e.stageId===t.from),r=e.nodes.find(e=>e.stageId===t.to);return!n||!r?null:(0,q.jsx)(`path`,{className:t.kind===`deferred`?`edge feedback feedback--deferred`:t.kind===`policy`?`edge feedback feedback--policy`:`edge feedback`,d:mg(n,r),markerEnd:`url(#spatial-arrow-feedback)`},`feedback:${t.kind}:${t.from}->${t.to}`)}),e.nodes.map(e=>{let t=k.get(e.stageId),n=A.get(e.stageId),a=t?.status??n?.status??`pending`,o=t?ci(t.events):!1;return(0,q.jsx)(Og,{node:e,status:a,abandoned:o,chrome:n,selected:r===e.stageId,busy:ng({retryingStageIds:j,abandoningStageId:u,resumingStageIds:M},e.stageId),retrying:j.has(e.stageId),resuming:M.has(e.stageId),abandoning:u===e.stageId,snapshot:t,onSelectStage:i,onRetryStage:s,onResumeStage:l,onAbandonStage:d},e.stageId)})]})]})}),(0,q.jsxs)(`div`,{className:`canvas-tools`,children:[(0,q.jsx)(`button`,{type:`button`,className:`icon`,title:`Zoom out`,"aria-label":`Zoom out`,onClick:()=>P(.87),children:`−`}),(0,q.jsxs)(`span`,{className:`zoom`,"aria-live":`polite`,children:[Math.round(T*100),`%`]}),(0,q.jsx)(`button`,{type:`button`,className:`icon`,title:`Zoom in`,"aria-label":`Zoom in`,onClick:()=>P(1.15),children:`+`}),(0,q.jsx)(`span`,{className:`divider`}),(0,q.jsx)(`button`,{type:`button`,className:`icon fit-btn`,onClick:F,children:`Fit run`})]}),p?(0,q.jsx)(`div`,{className:`canvas-hint`,children:`Stages become selectable when they start.`}):null]})}function Og({node:e,status:t,abandoned:n,chrome:r,selected:i,busy:a,retrying:o,resuming:s,abandoning:c,snapshot:l,onSelectStage:u,onRetryStage:d,onResumeStage:f,onAbandonStage:p}){let m=t!==`pending`,h=Cg(t,n),g=l!==void 0&&tg(l)&&f!==void 0,_=h===`retry`&&$h(t)&&d,v=h===`abandon`&&eg(t)&&p,y=Eg(t,n),b=[r?.isFeedbackSource?`feedback-source`:``,r?.isFeedbackTarget?`feedback-target`:``,r?.isSuperseded?`superseded`:``].filter(Boolean).join(` `),x=n?li():pi(t),S=r?.title??e.stageId,C=r?xg(r.kicker,r.title):null,w=[];r?.titleOnly||(w.push(x),r?.isSuperseded&&w.push(`superseded`),r?.readinessLine&&t===`pending`&&w.push(r.readinessLine),t===`waiting_for_input`?(r?.gateKinds?.length&&w.push(r.gateKinds.map(wg).join(` · `)),r?.promptSummary&&w.push(r.promptSummary)):r?.meta&&w.push(r.meta));let T=()=>{m&&u(e.stageId)};return(0,q.jsxs)(`g`,{className:`gnode ${y}${i?` selected`:``}${b?` ${b}`:``}`,"data-id":e.stageId,"data-waiting":r?.isWaitingAttention?`true`:void 0,"data-feedback-source":r?.isFeedbackSource?`true`:void 0,"data-feedback-target":r?.isFeedbackTarget?`true`:void 0,"data-superseded":r?.isSuperseded?`true`:void 0,transform:`translate(${e.x},${e.y})`,children:[(0,q.jsx)(`rect`,{className:`node-box`,x:0,y:0,width:e.width,height:128,rx:12,ry:12}),(0,q.jsx)(`circle`,{className:`port`,cx:-4,cy:64,r:4}),(0,q.jsx)(`circle`,{className:`port`,cx:e.width+4,cy:64,r:4}),m?(0,q.jsx)(`foreignObject`,{x:0,y:0,width:e.width,height:128,children:(0,q.jsxs)(`button`,{type:`button`,className:`gnode__hit`,onClick:T,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T())},children:[C?(0,q.jsx)(`span`,{className:`gnode__kicker`,children:C}):null,(0,q.jsxs)(`span`,{className:`gnode__title`,children:[S,(0,q.jsx)(Sl,{count:r?.attemptCount})]}),w.length>0?(0,q.jsx)(`span`,{className:`gnode__meta`,children:w.join(` · `)}):null]})}):(0,q.jsxs)(`g`,{className:`gnode__static`,children:[C?(0,q.jsx)(`text`,{className:`kicker`,x:16,y:22,children:C}):null,(0,q.jsx)(`text`,{className:`node-title`,x:16,y:C?44:32,children:S}),w.length>0?(0,q.jsx)(`text`,{className:`node-meta`,x:16,y:66,children:w.join(` · `)}):null]}),(0,q.jsx)(Ag,{status:t,abandoned:n,cx:e.width-26,cy:26,showResume:!!g,showRetry:!!_,showAbandon:!!v,busy:a,resumeLabel:s?`Resuming…`:`Resume session`,retryLabel:o?`Retrying…`:`Retry stage`,abandonLabel:c?`Abandoning…`:`Abandon stage`,onResume:g?()=>{f?.(e.stageId)}:void 0,onRetry:_?()=>{d?.(e.stageId)}:void 0,onAbandon:v?()=>{p?.(e.stageId)}:void 0})]})}function kg({kind:e,cx:t,cy:n,busy:r,label:i,onActivate:a}){return(0,q.jsxs)(`g`,{className:`node-action-btn node-${e}${r?` is-busy`:``}`,role:`button`,tabIndex:r?-1:0,"aria-label":i,"aria-disabled":r||void 0,onClick:e=>{r||(e.stopPropagation(),a?.())},onKeyDown:e=>{r||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),a?.())},children:[(0,q.jsx)(`title`,{children:i}),(0,q.jsx)(`circle`,{className:`action-bg`,cx:t,cy:n,r:11}),e===`retry`?(0,q.jsx)(`path`,{className:`action-icon`,d:[`M${t-3.2} ${n-2.2}`,`A4.2 4.2 0 1 0 ${t+.2} ${n-4}`,`M${t+.2} ${n-7.2}`,`L${t+.2} ${n-3.6}`,`L${t-3.4} ${n-3.6}`].join(` `)}):e===`resume`?(0,q.jsx)(`path`,{className:`action-icon`,d:`M${t-2.2} ${n-3.6} L${t-2.2} ${n+3.6} L${t+4.2} ${n} Z`}):(0,q.jsx)(`rect`,{className:`action-icon`,x:t-3.5,y:n-3.5,width:7,height:7,rx:1.25})]})}function Ag({status:e,abandoned:t,cx:n,cy:r,showResume:i,showRetry:a,showAbandon:o,busy:s,resumeLabel:c,retryLabel:l,abandonLabel:u,onResume:d,onRetry:f,onAbandon:p}){let m=r+28,h=i?m+26:m;return(0,q.jsxs)(`g`,{className:`node-status`,children:[e===`succeeded`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:n,cy:r,r:11,fill:`var(--color-success)`}),(0,q.jsx)(`path`,{d:`M${n-4} ${r} l3 3 l6-7`,fill:`none`,stroke:`var(--color-background-surface)`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`})]}):null,e===`running`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{className:`node-spin`,cx:n,cy:r,r:11,fill:`none`,stroke:`var(--color-border)`,strokeWidth:2}),(0,q.jsx)(`circle`,{className:`node-spin`,cx:n,cy:r,r:11,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:2.25,strokeLinecap:`round`,strokeDasharray:`18 52`})]}):null,e===`waiting_for_input`||e===`interrupted`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:n,cy:r,r:10,fill:`none`,stroke:`var(--color-warning)`,strokeWidth:2,strokeDasharray:`4 3`}),(0,q.jsx)(`text`,{x:n,y:r+4,textAnchor:`middle`,fill:`var(--color-warning)`,fontSize:11,fontWeight:700,children:`!`})]}):null,e===`failed`&&!t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:n,cy:r,r:11,fill:`var(--color-error)`}),(0,q.jsx)(`text`,{x:n,y:r+4,textAnchor:`middle`,fill:`var(--color-background-surface)`,fontSize:12,fontWeight:700,children:`!`})]}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:n,cy:r,r:11,fill:`var(--color-error)`}),(0,q.jsx)(`rect`,{x:n-5,y:r-1.5,width:10,height:3,rx:1,fill:`var(--color-background-surface)`})]}):null,e===`pending`||e===`skipped`?(0,q.jsx)(`circle`,{cx:n,cy:r,r:10,fill:`none`,stroke:`var(--color-text-disabled)`,strokeWidth:1.5}):null,i?(0,q.jsx)(kg,{kind:`resume`,cx:n,cy:m,busy:s,label:c,onActivate:d}):null,a?(0,q.jsx)(kg,{kind:`retry`,cx:n,cy:h,busy:s,label:l,onActivate:f}):null,o?(0,q.jsx)(kg,{kind:`abandon`,cx:n,cy:m,busy:s,label:u,onActivate:p}):null]})}var jg=64;function Mg(e){return e.scrollHeight-e.scrollTop-e.clientHeight<jg}function Ng({stageName:e,status:t,trailing:n,children:r,composer:i,autoScroll:a,scrollKey:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(!0);(0,v.useEffect)(()=>{a&&(c.current=!0)},[a]),(0,v.useEffect)(()=>{if(!a||!c.current)return;let e=s.current;e&&(e.scrollTop=e.scrollHeight)},[a,o]);function l(e){c.current=Mg(e.currentTarget)}return(0,q.jsxs)(`div`,{className:`stream`,style:{height:`100%`},children:[(0,q.jsxs)(`header`,{className:`stream__head`,children:[(0,q.jsx)(`h3`,{className:`stream__name`,children:e}),t,n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`topbar__spacer`}),(0,q.jsx)(`div`,{className:`stream__head-trail`,children:n})]}):null]}),(0,q.jsx)(`div`,{ref:s,className:`stream__body`,onScroll:l,children:(0,q.jsx)(`div`,{className:`thread`,children:r})}),i]})}function Pg(e){switch(e){case`passed`:return`passed`;case`failed`:return`failed`;case`running`:return`running`;case`skipped`:return`skipped`;default:return`pending`}}function Fg(e){let t=e.checks.length===1?`check`:`checks`;return`Attempt ${e.attempt} · ${e.status} · verification ${e.verification_outcome.replace(`_`,` `)} · ${e.checks.length} ${t}`}function Ig({check:e}){let t=e.evidence===void 0?void 0:JSON.stringify(e.evidence,null,2);return(0,q.jsxs)(`div`,{className:`verification-check`,children:[(0,q.jsxs)(`div`,{className:`verification-check__summary`,children:[(0,q.jsxs)(`span`,{className:`status status--${e.status===`passed`?`succeeded`:e.status===`failed`?`failed`:`running`}`,children:[(0,q.jsx)(`span`,{className:`dot dot--${e.status===`passed`?`succeeded`:e.status===`failed`?`failed`:`running`}`}),` `,Pg(e.status)]}),(0,q.jsx)(`code`,{children:e.check_id}),(0,q.jsx)(`span`,{className:`muted`,children:e.check_type})]}),t===void 0?null:(0,q.jsx)(Uc,{code:t,language:`json`,title:`Evidence`,size:`sm`,width:`100%`,maxHeight:260,container:`section`,isCollapsible:!0})]})}function Lg({history:e,error:t,recovering:n=!1,onRecover:r,onStop:i}){let[a,o]=(0,v.useState)(``);return t?(0,q.jsxs)(`div`,{className:`banner banner--warning`,children:[`Verification evidence unavailable: `,t]}):e===null||e.attempts.every(e=>e.checks.length===0)?null:(0,q.jsxs)(`section`,{className:`verification-history`,"aria-label":`Verification history`,children:[(0,q.jsxs)(`div`,{className:`verification-history__head`,children:[(0,q.jsx)(`strong`,{children:`Verification`}),(0,q.jsxs)(`span`,{className:`muted`,children:[e.attempts.length,` attempts`]})]}),e.attempts.map(t=>(0,q.jsx)(tl,{trigger:(0,q.jsx)(`span`,{className:`verification-history__attempt`,children:Fg(t)}),defaultIsOpen:t.attempt===e.attempts.length,children:(0,q.jsx)(`div`,{className:`verification-history__checks`,children:t.checks.length>0?t.checks.map(e=>(0,q.jsx)(Ig,{check:e},e.check_id)):(0,q.jsx)(`p`,{className:`muted`,children:`No completion checks ran in this attempt.`})})},t.attempt)),e.manual_recovery?.status===`available`?(0,q.jsxs)(`section`,{className:`manual-recovery`,"aria-label":`Manual recovery`,children:[(0,q.jsx)(`strong`,{children:`Manual recovery required`}),(0,q.jsx)(`p`,{className:`muted`,children:`This stage remains failed until an operator explicitly retries it or stops recovery.`}),(0,q.jsx)(`label`,{className:`manual-recovery__label`,htmlFor:`manual-recovery-guidance`,children:`Guidance for the retry (optional)`}),(0,q.jsx)(`textarea`,{id:`manual-recovery-guidance`,className:`manual-recovery__guidance`,value:a,maxLength:4e3,onChange:e=>o(e.target.value),placeholder:`Tell the agent what to address before it retries.`,disabled:n}),(0,q.jsxs)(`div`,{className:`manual-recovery__actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:n||r===void 0,onClick:()=>r?.(a),children:n?`Starting recovery…`:`Retry with guidance`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--reject`,disabled:n||i===void 0,onClick:()=>i?.(),children:`Stop recovery`})]})]}):null,e.manual_recovery?.status===`stopped`?(0,q.jsx)(`p`,{className:`muted`,children:`Manual recovery was stopped by an operator.`}):null]})}var Rg=`Cancel this run? Enter a short reason (required):`,zg=`Cancelled from operator console`;function Bg(e){return e===`created`||e===`queued`||e===`running`}function Vg(e){return e===`succeeded`||e===`failed`||e===`cancelled`||e===`created`||e===`queued`||e===`running`}function Hg(e){return e===`created`||e===`queued`||e===`running`}function Ug(e,t=window.prompt.bind(window)){return t(`Type the run id to permanently delete it:\n${e}`)===e}function Wg(e){let t={cancelling:!1,error:null},n=!1,r=new Set,i=()=>t,a=()=>{for(let e of r)e()};return{getState:i,cancel:async()=>{if(n)return;let r=e.promptReason?e.promptReason():window.prompt(Rg,zg);if(r===null)return;let i=r.trim();if(i!==``){n=!0,t={cancelling:!0,error:null},a();try{await e.cancel(i),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{n=!1,t={...t,cancelling:!1},a()}}},clearError:()=>{t.error!==null&&(t={...t,error:null},a())},subscribe:e=>(r.add(e),()=>{r.delete(e)})}}function Gg(e){let t={deleting:!1,error:null},n=!1,r=new Set,i=()=>t,a=()=>{for(let e of r)e()};return{getState:i,deleteRun:async r=>{if(!n&&(e.confirmTyped?.(r)??Ug(r))){n=!0,t={deleting:!0,error:null},a();try{await e.deleteRun(e.isActive),await e.onSuccess()}catch(e){t={...t,error:e instanceof Error?e.message:String(e)}}finally{n=!1,t={...t,deleting:!1},a()}}},clearError:()=>{t.error!==null&&(t={...t,error:null},a())},subscribe:e=>(r.add(e),()=>{r.delete(e)})}}function Kg(e,t){let n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(t);r.current=t;let i=(0,v.useRef)(null);i.current===null&&(i.current=Wg({cancel:async e=>{await ar(n.current,e)},onSuccess:()=>r.current()}));let a=i.current,[o,s]=(0,v.useState)(()=>a.getState());(0,v.useEffect)(()=>a.subscribe(()=>s(a.getState())),[a]);let c=(0,v.useCallback)(()=>void a.cancel(),[a]),l=(0,v.useCallback)(()=>a.clearError(),[a]);return{cancelling:o.cancelling,error:o.error,cancel:c,clearError:l}}function qg(e,t,n){let r=(0,v.useRef)(e);r.current=e;let i=(0,v.useRef)(n);i.current=n;let a=t!==void 0&&Hg(t),o=(0,v.useRef)(a);o.current=a;let s=(0,v.useRef)(null);s.current===null&&(s.current=Gg({deleteRun:async e=>{await or(r.current,{force:e})},onSuccess:()=>i.current(),get isActive(){return o.current}}));let c=s.current,[l,u]=(0,v.useState)(()=>c.getState());(0,v.useEffect)(()=>c.subscribe(()=>u(c.getState())),[c]);let d=(0,v.useCallback)(()=>void c.deleteRun(r.current),[c]),f=(0,v.useCallback)(()=>c.clearError(),[c]);return{deleting:l.deleting,error:l.error,deleteRun:d,clearError:f}}function Jg(e){let{readiness:t,blocked_by:n,status:r}=e;if(t===`blocked`)return n?.length?`Blocked on ${n.join(`, `)}`:`Blocked`;if(t===`skipped`)return`Skipped`;if(t===`ready`)return`Ready`;if((t!==`waiting`||r!==`waiting_for_input`)&&(t!==`interrupted`||r!==`interrupted`)){if(t===`interrupted`)return pi(`interrupted`);if(t===`succeeded`)return pi(`succeeded`);if(t===`failed`)return pi(`failed`);if(t===`running`)return pi(`running`)}}var Yg=`stageflow:envelope:`;function Xg(e){return`${Yg}${e}`}function Zg(e){if(!e.startsWith(Yg))return null;let t=e.slice(19);return t.length>0?t:null}function Qg(e,t){return`${e}->${t}`}var $g={deferred:3,replay:2,policy:1},e_=new Set([`scheduled`,`active`,`waiting_for_human`]);function t_(e,t,n){let r=new Map,i=e=>{let t=Qg(e.from,e.to),n=r.get(t);(!n||$g[e.kind]>$g[n.kind])&&r.set(t,e)};for(let e of n?.nodes??[]){let t=e.feedback_loop?.target;t&&i({from:e.stage_id,to:t,kind:`policy`})}e?.deferred_send_back?.target&&i({from:e.source_stage_id,to:e.deferred_send_back.target,kind:`deferred`});let a=!!e?.deferred_send_back?.target,o=e=>{for(let n of t??[])for(let{replay:t}of n.replays)t.status!==`superseded`&&t.status!==`failed`&&e(t.status)&&i({from:t.source_stage_id,to:t.target_stage_id,kind:`replay`})};return o(e=>e_.has(e)),![...r.values()].some(e=>e.kind===`replay`)&&!a&&o(e=>e===`completed`),e&&i({from:e.source_stage_id,to:e.policy.target,kind:`policy`}),[...r.values()]}function n_(e){let t=new Set;for(let n of e??[]){for(let e of n.fork_generations)if(e.status===`superseded`)for(let n of e.clone_stage_ids)t.add(n);for(let{stage_passes:e,fork_generations:r}of n.replays){for(let n of e)n.status===`superseded`&&t.add(n.stage_id);for(let e of r)if(e.status===`superseded`)for(let n of e.clone_stage_ids)t.add(n)}}return t}function r_(e,t){for(let n of t)if(n.status===`superseded`)for(let t of n.clone_stage_ids)e.add(t)}function i_(e){let t=new Set;for(let n of e??[]){r_(t,n.fork_generations);for(let e of n.replays)r_(t,e.fork_generations)}return t}function a_(e,t){return e.filter(e=>!t.has(e))}function o_(e,t){return t.size===0?e:{nodes:e.nodes.filter(e=>!t.has(e.stage_id)),edges:e.edges.filter(e=>!t.has(e.from)&&!t.has(e.to))}}function s_(e){let t=e.active_feedback_loop;if(!(e.waiting_kind!==`feedback_loop_decision`||!t||t.state!==`waiting_for_human`))return{loopId:t.loop_id,sourceStageId:t.source_stage_id,deferredTarget:t.deferred_send_back?.target,replayNumber:t.current_replay_number,maxReplays:t.policy.max_replays,summary:e.waiting_summary}}function c_(e,t){return e.stages.some(e=>e.stage_id===t)}function l_(e,t,n){return c_(e,t)||e.pipeline_track?.nodes?.some(e=>e.stage_id===t)?!0:!!n?.includes(t)}function u_(e){return new Map(e.stages.map(e=>[e.stage_id,e]))}function d_(e){let t=e.pipeline_track;return t?.nodes?.length?Jh(t.nodes).map(e=>e.stage_id):e.stages.map(e=>e.stage_id)}function f_(e){let t=e.waiting_stage_id;if(!t)return null;let n=e.stages.find(e=>e.stage_id===t)?.pending_prompt?.id;return n?`${t}:${n}`:e.waiting_prompt_id?e.waiting_prompt_id:c_(e,t)?`${t}:`:null}function p_(e,t){if(t.userPicked&&t.previousStageId&&c_(e,t.previousStageId))return t.previousStageId;let n=f_(e);return n&&n!==t.dismissedWaitKey&&e.waiting_stage_id&&c_(e,e.waiting_stage_id)?e.waiting_stage_id:null}function m_(e,t){return e.artifacts.includes(t)?!0:!!e.envelope?.artifacts.includes(t)}function h_(e,t){let n=u_(e);for(let r of d_(e)){let e=n.get(r);if(e&&m_(e,t))return r}return null}function g_(e,t,n){return t===void 0||t===``?e:e===t?t:n===void 0?e:`${t} · ${n}`}function __(e,t,n){if(n===void 0)return;let r=Jh(e).filter(e=>(e.definition_id??e.stage_id)===n).findIndex(e=>e.stage_id===t);if(!(r<0))return r+1}function v_(e,t){return g_(t.stage_id,t.definition_id,__(e,t.stage_id,t.definition_id))}function y_(e,t){let n=e.pipeline_track?.nodes??[],r=n.find(e=>e.stage_id===t);return r?v_(n,r):g_(t)}function b_(e,t,n){let r=hi(e.status);return{id:e.stage_id,label:n??e.stage_id,status:r,selected:e.stage_id===t,meta:r===`waiting`?pi(e.status):e.last_at,envelope:e.envelope?{summary:e.envelope.summary,artifactCount:e.envelope.artifacts.length}:null}}function x_(e,t,n){return{id:e,label:n??e,status:`pending`,selected:e===t,meta:`pending`,envelope:null}}function S_(e,t,n,r){let i=v_(r,e);return t?b_(t,n,i):x_(e.stage_id,n,i)}function C_(e,t,n){if(!n||n.length===0)return e.map(e=>b_(e,t));let r=new Map(e.map(e=>[e.stage_id,e])),i=new Set,a=[];for(let e of n){i.add(e);let n=r.get(e);a.push(n?b_(n,t):x_(e,t))}for(let n of e)i.has(n.stage_id)||a.push(b_(n,t));return a}function w_(e,t,n){return e.waiting_stage_ids?.includes(t)?!0:n===`waiting_for_input`}function T_(e){if(e)switch(e.kind){case`free_text`:case`confirm`:return e.message;case`artifact_backed`:return e.message||e.artifacts[0];case`multi_question`:return e.questions.length===1?`1 question`:`${e.questions.length} questions`}}function E_(e,t,n,r,i,a){return Jh(t).map(o=>{let s=n.get(o.stage_id),c=s?.status??o.status;return{stageId:o.stage_id,title:v_(t,o),kicker:o.definition_id??o.stage_id,status:c,attemptCount:s?.attempt_count??o.attempt_count??1,readinessLine:Jg({readiness:o.readiness,blocked_by:o.blocked_by,status:c}),gateKinds:o.gate_kinds,meta:c===`running`?s?.last_at:void 0,promptSummary:c===`waiting_for_input`?T_(s?.pending_prompt):void 0,isWaitingAttention:w_(e,o.stage_id,c),isFeedbackSource:r.has(o.stage_id)||void 0,isFeedbackTarget:i.has(o.stage_id)||void 0,isSuperseded:a.has(o.stage_id)||void 0}})}function D_(e,t,n,r,i,a){return t.map(t=>{let o=n.get(t.id),s=o?.status??`pending`;return{stageId:t.id,title:t.label,kicker:t.id,status:s,attemptCount:o?.attempt_count??1,meta:s===`running`?o?.last_at:void 0,promptSummary:s===`waiting_for_input`?T_(o?.pending_prompt):void 0,isWaitingAttention:w_(e,t.id,s),isFeedbackSource:r.has(t.id)||void 0,isFeedbackTarget:i.has(t.id)||void 0,isSuperseded:a.has(t.id)||void 0}})}function O_(e,t,n,r,i,a){let o=u_(e),s=o_(e.pipeline_track,a),c=n&&a_(n,a),l=Qh(s,{liveStageIds:a_(e.stages.map(e=>e.stage_id),a),plannedStageIds:c}),u=new Set(r.map(e=>e.from)),d=new Set(r.map(e=>e.to));if(!s.nodes.length){let n=C_(e.stages.filter(e=>!a.has(e.stage_id)),t,c);return{spatialLayout:l,nodeChrome:D_(e,n,o,u,d,i),trackStages:n}}let f=s.nodes,p=Jh(f).map(e=>S_(e,o.get(e.stage_id),t,f));return{spatialLayout:l,nodeChrome:E_(e,f,o,u,d,i),trackStages:p}}function k_(e,t,n){return e===`stream`?t===`waiting_for_input`&&n?{kind:`reply`,prompt:n}:!t||t===`succeeded`||t===`failed`||t===`interrupted`||t===`pending`||t===`skipped`?{kind:`idle`,label:`Session closed`}:{kind:`none`}:{kind:`none`}}function A_(e){return e===`waiting_for_input`?`alive`:e===`succeeded`||e===`failed`||e===`interrupted`||e===`pending`||e===`skipped`?`closed`:null}function j_(e){let t=[];for(let n of e.stages)for(let r of n.artifacts)t.push({path:r,meta:y_(e,n.stage_id)});return t}function M_(e,t){let n=j_(e);return t?.envelope?[{path:Xg(t.stage_id),label:`Handoff envelope`,meta:y_(e,t.stage_id)},...n]:n}function N_(e,t,n){let r=e.pipeline_track;if(r?.nodes?.length)return r.edges.find(e=>e.to===t)?.from;if(n&&n.length>0){let e=n.indexOf(t);if(e>0)return n[e-1]}let i=e.stages.findIndex(e=>e.stage_id===t);if(i>0)return e.stages[i-1]?.stage_id}function P_(e,t,n){let r=e.pipeline_track;if(r?.nodes?.length){let e=r.edges.filter(e=>e.from===t);return e.length===1?e[0]?.to:void 0}if(n&&n.length>0){let e=n.indexOf(t);if(e>=0)return n[e+1]}let i=e.stages.findIndex(e=>e.stage_id===t);if(!(i<0))return e.stages[i+1]?.stage_id}function F_(e){return e?.kind===`artifact_backed`?e:void 0}function I_(e){return e?.status===`waiting_for_input`&&e.pending_prompt?.kind===`artifact_backed`}function L_(e,t){return t.retrying||t.abandoning?!0:e?e.status===`created`||e.status===`running`||e.waiting_stage_id?!0:e.stages.some(e=>e.status===`running`||e.status===`waiting_for_input`):!1}function R_(e,t,n,r){let i=p_(t,n),a=e.kind===`stream`&&e.stageId&&l_(t,e.stageId,r)?e.stageId:i,o=e.kind===`envelope`?e.stageId:e.kind===`artifact`?h_(t,e.path):a,s=t.stages.find(e=>e.stage_id===o)??null,c=t.pipeline_track?.nodes?.length?void 0:r,l=o?N_(t,o,c):void 0,u=l?t.stages.find(e=>e.stage_id===l):void 0,d=I_(s),f=e.kind===`artifact`&&!!n.wasWaitingArtifact&&!d,p;p=e.kind===`envelope`?`envelope`:e.kind===`artifact`&&!f?`artifact`:o?`stream`:`empty`;let m=p===`artifact`&&d,h=m?F_(s?.pending_prompt):void 0,g=s_(t),_=!!g,v=t_(t.active_feedback_loop,t.feedback_loops,t.pipeline_track),y=i_(t.feedback_loops),b=n_(t.feedback_loops),x=e.kind===`envelope`?e.stageId:null,S=x?t.stages.find(e=>e.stage_id===x)??null:null,C=e.kind===`envelope`?{fromStageId:e.stageId,toStageId:P_(t,e.stageId,c),envelope:S?.envelope??null}:null,w=(n.drawerStageId?t.stages.find(e=>e.stage_id===n.drawerStageId)??null:null)?.envelope??null,T=p!==`envelope`&&n.drawerStageId&&w?{fromStageId:n.drawerStageId,toStageId:P_(t,n.drawerStageId,c),envelope:w}:null,{spatialLayout:E,nodeChrome:D,trackStages:O}=O_(t,o,r,v,b,y);return{selectedStageId:o,selectedStage:s,kind:p,composer:k_(p,s?.status,s?.pending_prompt),showDecide:m,decidePrompt:h,showFeedbackDecide:_,feedbackDecide:g,feedbackOverlays:v,artifactReadOnly:!m,selectedPath:p===`artifact`&&e.kind===`artifact`?e.path:p===`envelope`&&e.kind===`envelope`?Xg(e.stageId):void 0,trackStages:O,spatialLayout:E,nodeChrome:D,artifactFiles:M_(t,s),sessionChip:A_(s?.status),inboundEnvelope:u?.envelope??null,inboundFromStageId:u?.stage_id,inboundToStageId:s?.stage_id,drawer:T,envelope:C,liveStream:s?.status===`running`||s?.status===`waiting_for_input`,activeEnvelopeId:e.kind===`envelope`?e.stageId:n.drawerStageId,waitingArtifact:d,syncStreamRoute:f}}function z_(e){return e.syncStreamRoute?{action:`openStream`,stageId:e.selectedStageId??void 0}:e.view.kind!==`stream`||!e.run?{action:`none`}:e.streamViewStageId&&!l_(e.run,e.streamViewStageId,e.plannedStageIds)?{action:`openStream`}:e.userPickedStageId||e.dismissedWaitKey||!e.selectedStageId||e.streamViewStageId===e.selectedStageId?{action:`none`}:{action:`openStream`,stageId:e.selectedStageId}}var B_=300,V_=200,H_=140,U_=24;function W_(e,t){let n=t-H_;return t<340?Math.max(0,n):Math.max(V_,Math.min(e,n))}function G_(e){return e===`alive`?(0,q.jsx)(`span`,{className:`chip`,children:`session alive`}):e===`closed`?(0,q.jsx)(`span`,{className:`chip`,children:`session closed`}):null}function K_(e,t,n){let r=t.selectedStage;if(t.composer.kind===`reply`&&r)return(0,q.jsx)(`div`,{className:`composer`,children:(0,q.jsx)(`div`,{className:`composer__inner`,children:(0,q.jsx)(bl,{runId:e,stageId:r.stage_id,prompt:t.composer.prompt,onReviewSideBySide:n})})});if(t.composer.kind===`idle`)return(0,q.jsx)(`div`,{className:`composer composer--idle`,children:(0,q.jsx)(`div`,{className:`composer__inner`,children:(0,q.jsx)(`p`,{className:`muted`,children:t.composer.label})})})}function q_({runId:e,view:t,onBack:n,onReran:r,onOpenStream:i,onOpenArtifact:a,onOpenEnvelope:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(()=>t.kind===`stream`&&t.stageId?t.stageId:null),w=(0,v.useRef)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(B_),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(0),[F,I]=(0,v.useState)(!1),L=(0,v.useRef)(null),R=(0,v.useRef)(null),[z,B]=(0,v.useState)(!1),V=(0,v.useRef)(!1),H=(0,v.useRef)(i);H.current=i;let U=Nr(),W=t.kind===`stream`?t.stageId:void 0,ee=(0,v.useCallback)(async()=>{try{let t=await Tn(e);c(t),f(null)}catch(e){f(e instanceof Error?e.message:String(e))}},[e]),te=(0,v.useCallback)(async()=>{await ee(),U.refresh()},[ee,U]),ne=(0,v.useCallback)(async(t,n)=>{y(!0),x(null);try{await nr(e,t,n),await te()}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[te,e]),re=(0,v.useCallback)(async t=>{if(window.confirm(`Stop manual recovery? This stage will remain failed in this run.`)){y(!0),x(null);try{await rr(e,t),await te()}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[te,e]),{retryingStageIds:ie,error:ae,retry:oe,clearError:se}=ig(e,te),ce=(0,v.useCallback)(e=>{C(e),i(e),oe(e)},[i,oe]),{resumingStageIds:le,error:ue,resume:de,clearError:fe}=og(e,te),pe=(0,v.useCallback)(e=>{C(e),i(e),de(e)},[i,de]),{abandoningStageId:me,error:he,abandon:ge,clearError:_e}=cg(e,te),ve=(0,v.useCallback)(async()=>{U.refresh(),n()},[U,n]),{cancelling:ye,error:be,cancel:xe,clearError:Se}=Kg(e,te),{deleting:Ce,error:we,deleteRun:Te,clearError:Ee}=qg(e,s?.status,ve),De={retryingStageIds:ie,abandoningStageId:me,resumingStageIds:le};(0,v.useEffect)(()=>{C(W??null),w.current=null,E(null),O(null),A(B_),M(null),c(null),f(null),m(null),g(null),y(!1),x(null),V.current=!1},[e]),(0,v.useEffect)(()=>{ee()},[ee]),(0,v.useEffect)(()=>{t.kind===`stream`&&C(W??null)},[t.kind,W]),(0,v.useEffect)(()=>{let e=!1;return On().then(t=>{e||u(t.pipelines)}).catch(()=>{e||u([])}),()=>{e=!0}},[]);let Oe=L_(s,{retrying:ie.size>0,abandoning:me!==null});(0,v.useEffect)(()=>{if(!Oe)return;let e=window.setInterval(()=>void ee(),1e3);return()=>window.clearInterval(e)},[ee,Oe]);let ke=l?.find(e=>e.id===s?.pipeline_id)?.stages.map(e=>e.id)??[],G=s?R_(t,s,{previousStageId:S??w.current,userPicked:S!==null,drawerStageId:T,dismissedWaitKey:D,wasWaitingArtifact:V.current},ke):null,Ae=G?.selectedStageId,je=G?.selectedStage?.attempt_count;(0,v.useEffect)(()=>{if(!Ae){m(null),g(null);return}let t=!1;return m(null),g(null),En(e,Ae).then(e=>{t||m(e)}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,Ae,je]),G&&(w.current=G.selectedStageId),G?.waitingArtifact?V.current=!0:t.kind!==`artifact`&&(V.current=!1),(0,v.useEffect)(()=>{let e=z_({view:t,streamViewStageId:W,run:s,plannedStageIds:ke,selectedStageId:G?.selectedStageId??null,syncStreamRoute:G?.syncStreamRoute??!1,userPickedStageId:S,dismissedWaitKey:D});e.action===`openStream`&&H.current(e.stageId)},[t,W,s,ke,G?.selectedStageId,G?.syncStreamRoute,S,D]),(0,v.useEffect)(()=>{let e=L.current;if(!e)return;let t=()=>P(e.getBoundingClientRect().height);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let Me=(0,v.useCallback)(e=>{let t=L.current?.getBoundingClientRect().height??N;A(W_(e,t))},[N]),Ne=(0,v.useCallback)(()=>{s&&O(f_(s)),C(null),w.current=null,E(null),i()},[i,s]),Pe=(0,v.useCallback)(()=>{let e=G?.selectedStageId??(t.kind===`envelope`?t.stageId:void 0)??S;if(e){C(e),i(e);return}i()},[i,S,t,G?.selectedStageId]);async function Fe(){B(!0),f(null),se(),_e(),fe(),Se(),Ee();try{r((await $n(e)).runId)}catch(e){f(e instanceof Error?e.message:String(e))}finally{B(!1)}}let K=G?.selectedStage??null,Ie=p!==null&&p.stage_id===K?.stage_id?p.manual_recovery:void 0,Le=G?.selectedPath,Re=s?fi(s.status):void 0,ze=G?K_(e,G,a):void 0,Be=!!(G&&G.spatialLayout.nodes.length>0),Ve=!!(G&&(G.selectedStageId||G.kind===`artifact`||G.kind===`envelope`)),He=K?ci(K.events):!1,Ue=(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:Ne,children:`Hide workspace`}),We;if(d)We=(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsx)(`div`,{className:`banner banner--error`,children:d})});else if(!s||!G)We=(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsx)(`p`,{children:`Loading…`})});else if(G.kind===`artifact`&&Le)We=(0,q.jsx)(Pm,{runId:e,path:Le,readOnly:G.artifactReadOnly,onBackToTranscript:Pe,onHide:Ne});else if(G.kind===`envelope`&&G.envelope)We=G.envelope.envelope?(0,q.jsx)(Wm,{fromStageId:G.envelope.fromStageId,toStageId:G.envelope.toStageId,envelope:G.envelope.envelope,onBackToTranscript:Pe,onHide:Ne,onArtifactClick:a,stageLabel:e=>y_(s,e)}):(0,q.jsxs)(`div`,{className:`stream`,style:{height:`100%`},children:[(0,q.jsxs)(`header`,{className:`stream__head`,children:[(0,q.jsx)(`h3`,{className:`stream__name`,children:`Handoff envelope`}),(0,q.jsx)(`span`,{className:`topbar__spacer`}),(0,q.jsxs)(`div`,{className:`stream__head-trail`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:Pe,children:`← Transcript`}),Ue]})]}),(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsxs)(`div`,{className:`banner banner--warning`,children:[G.envelope.fromStageId,` has not emitted a handoff envelope.`]})})]});else if(G.selectedStageId){let e=G.selectedStageId,t=K?fi(K.status):void 0,n=j!==`transcript`,r=j!==`logs`,i=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:()=>M(r?`logs`:null),children:r?`Hide logs`:`Show logs`}),Ue]}),a=(0,q.jsxs)(q.Fragment,{children:[K?(0,q.jsx)(bi,{costUsd:K.cost_usd}):null,(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:()=>M(n?`transcript`:null),children:n?`Hide transcript`:`Show transcript`}),Ue]});We=(0,q.jsxs)(`div`,{className:`center-split`,children:[(0,q.jsx)(`div`,{className:`center-split__transcript`,hidden:!n,children:(0,q.jsxs)(Ng,{stageName:G.trackStages.find(t=>t.id===e)?.label??e,status:(0,q.jsxs)(q.Fragment,{children:[He?(0,q.jsxs)(`span`,{className:`status status--failed`,children:[(0,q.jsx)(`span`,{className:`dot dot--failed`}),` `,li()]}):(0,q.jsxs)(`span`,{className:`status${t&&t!==`running`?` status--${t}`:``}`,children:[(0,q.jsx)(`span`,{className:`dot${t?` dot--${t}`:``}`}),` `,K?pi(K.status):`pending`]}),K?(0,q.jsx)(Sl,{count:K.attempt_count}):null,K?(0,q.jsx)(bi,{costUsd:K.cost_usd}):null,G_(G.sessionChip),K&&tg(K)&&Ie===void 0?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,disabled:ng(De,K.stage_id),onClick:()=>pe(K.stage_id),children:le.has(K.stage_id)?`Resuming…`:`Resume session`}):null,K&&$h(K.status)&&Ie===void 0?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,disabled:ng(De,K.stage_id),onClick:()=>ce(K.stage_id),children:ie.has(K.stage_id)?`Retrying…`:`Retry stage`}):null,K&&eg(K.status)?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--reject`,disabled:ng(De,K.stage_id),onClick:()=>ge(K.stage_id),children:me===K.stage_id?`Abandoning…`:`Abandon`}):null]}),trailing:i,autoScroll:G.liveStream,scrollKey:K?.events.length,composer:ze,children:[(0,q.jsx)(Ch,{events:K?.events??[],inboundEnvelope:G.inboundEnvelope}),(0,q.jsx)(Lg,{history:p,error:h,recovering:_,onRecover:K?e=>void ne(K.stage_id,e):void 0,onStop:K?()=>void re(K.stage_id):void 0})]})}),(0,q.jsx)(`div`,{className:`center-split__logs`,hidden:!r,children:(0,q.jsx)(Kh,{events:K?.events??[],headerAction:a})})]})}let Ge=Math.max(0,N-H_),Ke=N<340?Ge:V_;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{ref:L,className:`pane run-detail${Ve?` has-stage`:``}${F?` is-resizing`:``}`,style:{height:`100%`,"--work-h":`${k}px`},children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`topbar__back`,href:`#/runs`,onClick:e=>{e.preventDefault(),n()},children:`← Runs`}),(0,q.jsx)(`h2`,{className:`topbar__title`,children:s?Rr(s):`Loading…`}),s?(0,q.jsx)(`span`,{className:`topbar__sub`,title:Lr(s),children:Lr(s)}):null,s?.binding?(0,q.jsx)(`span`,{className:`topbar__sub`,title:Hr(s.binding),children:Vr(s.binding)}):null,s?(0,q.jsxs)(`span`,{className:`status${Re&&Re!==`running`?` status--${Re}`:``}`,title:s.status===`cancelled`&&s.cancel_reason?s.cancel_reason:void 0,children:[(0,q.jsx)(`span`,{className:`dot${Re?` dot--${Re}`:``}`}),` `,s.status===`cancelled`?ui(s.cancel_reason):pi(s.status)]}):null,s&&yi(s.total_cost_usd)?(0,q.jsx)(`span`,{className:`topbar__sub`,title:`Total cost across every stage in this run`,children:yi(s.total_cost_usd)}):null,(0,q.jsx)(`span`,{className:`topbar__spacer`}),s&&Bg(s.status)?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,disabled:ye||Ce||z,onClick:()=>{Se(),xe()},children:ye?`Cancelling…`:`Cancel`}):null,s&&Vg(s.status)?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--reject`,disabled:ye||Ce||z,onClick:()=>{Ee(),Te()},children:Ce?`Deleting…`:`Delete`}):null,(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:z||ye||Ce,onClick:()=>void Fe(),children:z?s?.status===`created`?`Starting…`:`Starting fresh…`:s?.status===`created`?`Start run`:`Start fresh`})]}),ae?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:ae}):null,ue?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:ue}):null,he?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:he}):null,be?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:be}):null,we?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:we}):null,b?(0,q.jsx)(`div`,{className:`banner banner--error`,style:{padding:`var(--spacing-3) var(--spacing-5)`},children:b}):null]}),d&&!s?(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsx)(`div`,{className:`banner banner--error`,children:d})}):!s||!G?(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsx)(`p`,{children:`Loading…`})}):Be?(0,q.jsxs)(`div`,{className:`workspace`,children:[s.active_feedback_loop||(s.feedback_loops?.length??0)>0?(0,q.jsx)(th,{active:s.active_feedback_loop,history:s.feedback_loops??[]}):null,(0,q.jsx)(Dg,{layout:G.spatialLayout,stages:s.stages,nodeChrome:G.nodeChrome,selectedStageId:G.selectedStageId,onSelectStage:e=>{C(e),i(e)},onDeselect:Ne,retryingStageIds:ie,onRetryStage:ce,resumingStageIds:le,onResumeStage:pe,abandoningStageId:me,onAbandonStage:ge,runId:e,showHint:!Ve,feedbackOverlays:G.feedbackOverlays})]}):(0,q.jsx)(`div`,{style:{padding:`var(--spacing-4)`},children:(0,q.jsx)(`p`,{children:`No stages have started yet.`})}),Ve&&s&&G?(0,q.jsxs)(`div`,{className:`work`,children:[(0,q.jsx)(`div`,{className:`work-split${F?` is-dragging`:``}`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize workspace`,"aria-valuemin":Ke,"aria-valuemax":Ge,"aria-valuenow":Math.round(k),tabIndex:0,onPointerDown:e=>{(e.button==null||e.button===0)&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),I(!0),R.current={id:e.pointerId,y:e.clientY,h:k})},onPointerMove:e=>{let t=R.current;!t||t.id!==e.pointerId||Me(t.h+(t.y-e.clientY))},onPointerUp:e=>{R.current?.id===e.pointerId&&(R.current=null,I(!1))},onPointerCancel:e=>{R.current?.id===e.pointerId&&(R.current=null,I(!1))},onKeyDown:e=>{e.key===`ArrowUp`&&(e.preventDefault(),Me(k+U_)),e.key===`ArrowDown`&&(e.preventDefault(),Me(k-U_)),e.key===`Home`&&(e.preventDefault(),Me(Ge)),e.key===`End`&&(e.preventDefault(),Me(Ke))},children:(0,q.jsx)(`span`,{className:`work-split__grip`,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{className:`work-row`,children:[(0,q.jsx)(`div`,{className:`aside`,style:{width:240,flexShrink:0,overflow:`auto`},children:(0,q.jsx)(wl,{files:G.artifactFiles,selectedPath:Le,onSelect:e=>{let t=Zg(e);if(t){C(t),o(t);return}a(e)},footer:(0,q.jsx)(tl,{trigger:(0,q.jsx)(`span`,{style:{fontSize:`var(--font-size-sm)`,fontWeight:500},children:`Input`}),defaultIsOpen:!1,children:(0,q.jsx)(Uc,{code:s.task_yaml,language:`yaml`,container:`section`,maxHeight:200,width:`100%`})})})}),(0,q.jsx)(`div`,{style:{flex:1,minWidth:0,minHeight:0,display:`flex`,flexDirection:`column`},children:We}),G.showFeedbackDecide&&G.feedbackDecide?(0,q.jsx)(`div`,{className:`decide`,style:{width:320,flexShrink:0},children:(0,q.jsx)(Xm,{runId:e,decide:G.feedbackDecide,onSuccess:te})}):G.showDecide&&G.decidePrompt&&K?(0,q.jsx)(`div`,{className:`decide`,style:{width:320,flexShrink:0},children:(0,q.jsx)(Vm,{runId:e,stageId:K.stage_id,prompt:G.decidePrompt,events:K.events,inboundEnvelope:G.inboundEnvelope,inboundFromStageId:G.inboundFromStageId,inboundToStageId:G.inboundToStageId,selectedPath:Le,onSelectArtifact:a,onOpenInboundEnvelope:G.inboundFromStageId?()=>{let e=G.inboundFromStageId;e&&E(e)}:void 0})}):null]})]}):null]}),G?.drawer?(0,q.jsx)(qm,{isOpen:!0,onClose:()=>E(null),fromStageId:G.drawer.fromStageId,toStageId:G.drawer.toStageId,envelope:G.drawer.envelope,onOpenFullRecord:()=>{let e=G.drawer?.fromStageId;E(null),e&&o(e)},onArtifactClick:e=>{E(null),a(e)}}):null]})}function J_({label:e,status:t,index:n,meta:r,selected:i,proposed:a,onClick:o}){let s=gi(t)||(n==null?``:String(n+1));return(0,q.jsxs)(`button`,{type:`button`,className:`node`,"data-s":t,"data-selected":i?`true`:void 0,"data-proposed":a?`true`:void 0,onClick:o,"aria-disabled":!o,style:{cursor:o?`pointer`:`default`},children:[(0,q.jsx)(`span`,{className:`node__ring`,"aria-hidden":`true`,children:s}),(0,q.jsx)(`span`,{className:`node__name`,children:e}),r?(0,q.jsx)(`span`,{className:`node__meta`,children:r}):null]})}function Y_(e){return e===1?`1 file`:`${e} files`}function X_({mode:e,flowed:t,envelope:n,fromStageId:r,selected:i,onEnvelopeClick:a}){let o=n==null,s=o?`no envelope yet`:`envelope · ${Y_(n.artifactCount)}`;return(0,q.jsxs)(`span`,{className:`wire`,"data-flowed":t?`true`:void 0,children:[(0,q.jsx)(`span`,{className:`wire__line`}),e===`definition`?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{className:`wire__env`,disabled:o||!a,"data-selected":i?`true`:void 0,onClick:o||!a?void 0:()=>a(r),children:s}),n?.summary?(0,q.jsx)(`span`,{className:`wire__summary`,children:n.summary}):null]})]})}function Z_({stages:e,mode:t=`run`,onSelect:n,onEnvelopeClick:r,activeEnvelopeId:i}){return(0,q.jsx)(`nav`,{className:`track`,"aria-label":`Pipeline track`,children:(0,q.jsx)(`div`,{className:`track__rail`,children:e.map((a,o)=>(0,q.jsxs)(v.Fragment,{children:[(0,q.jsx)(J_,{id:a.id,label:a.label,status:a.status,index:o,meta:a.meta,selected:a.selected,proposed:a.proposed,onClick:n&&(t===`definition`||a.status!==`pending`)?()=>n(a.id):void 0}),o<e.length-1?(0,q.jsx)(X_,{mode:t,flowed:a.envelope!=null,envelope:a.envelope,fromStageId:a.id,selected:i===a.id,onEnvelopeClick:r}):null]},a.id))})})}var Q_=`Providers are connected through Pi. Stageflow binds the credential store you choose; it is not a standalone non-Pi LLM client.`;function $_(e){return e.credentialSource===void 0}function ev(e){return e?`pi_home`:`sf_owned`}function tv(e){return e.supportsApiKey}function nv(e){return e.supportsOauth&&!e.supportsApiKey}function rv(e){return e?e.configured?e.authKind===`oauth`?`Connected (OAuth)`:e.authKind===`api_key`?`Connected (API key)`:`Connected`:`Not connected`:`Unknown`}function iv(e){return e.credentialSource===void 0?!1:e.credentialSource===`pi_home`||e.configuredCount>0}function av(e){return e.filter(e=>e?.configured===!0).length}async function ov(){let e=await Vn();if($_(e))return{ready:!1,message:`Connect providers before starting a run. Choose an existing Pi login or add API keys in Stageflow.`};let t=e.credentialSource;if(t===`pi_home`)return{ready:!0,credentialSource:t};let n=await Bn();return iv({credentialSource:t,configuredCount:av(await Promise.all(n.providers.map(async e=>{try{let{provider:t}=await Hn(e.id);return t}catch{return}})))})?{ready:!0,credentialSource:t}:{ready:!1,credentialSource:t,message:`Connect at least one provider API key in Settings → Providers (or #/connect) before starting a run.`}}function sv(e){return!Array.isArray(e)||e.length===0?`no gate`:`will ask you`}function cv({onStarted:e,initialPipelinePath:t,initialTaskPath:n}){let[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)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),{snapshot:b,error:x}=Mr(),S=b.health;(0,v.useEffect)(()=>{(async()=>{try{let[e,r]=await Promise.all([Dn(),On()]);i(e.tasks),o(r.pipelines);let a=n&&e.tasks.some(e=>e.path===n)?n:e.tasks[0]?.path??``,s=t&&r.pipelines.some(e=>e.path===t)?t:r.pipelines[0]?.path??``;c(a),u(s)}catch(e){f(e instanceof Error?e.message:String(e))}})()},[t,n]);let C=a.find(e=>e.path===l)??null,w=(0,v.useMemo)(()=>C?C.stages.map(e=>({id:e.id,label:e.id,status:ni(e.gate_kinds)?`waiting`:`pending`,meta:sv(e.gate_kinds)})):[],[C]),T=S!=null&&S.slotsAvailable===0,E=S==null?0:Qr(b,S.activeRunIds).length,D=d??(S==null&&x?x:null);async function O(){if(!s||!l){f(`Pick a task and a pipeline.`);return}m(!0),f(null),g(null),y(null);try{let e=await ov();if(!e.ready){y(e.message??`Connect providers before starting a run.`),m(!1);return}}catch(e){y(e instanceof Error?e.message:String(e)),m(!1);return}let t=await Qn(s,l);if(m(!1),t.ok){e(t.runId);return}g(t)}return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/today`,children:`Today`}),` / start a run`]}),(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Start a run`}),(0,q.jsx)(`p`,{children:`A run is a task path plus a pipeline path. Nothing else is decided here.`})]})}),T&&S?(0,q.jsxs)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`},children:[(0,q.jsxs)(`div`,{className:`gate__label`,children:[(0,q.jsx)(`span`,{className:`dot dot--waiting`}),` No free session slots`]}),(0,q.jsxs)(`p`,{className:`gate__question`,children:[`All `,S.maxConcurrent,` slots are in use`,E>0?` — ${E===1?`one is`:`${E} are`} held by stages waiting on you`:``]}),S.activeRunIds.length>0?(0,q.jsxs)(`p`,{style:{margin:`var(--spacing-2) 0 0`,color:`var(--color-text-yellow)`,fontSize:`var(--font-size-sm)`},children:[`Blocking runs: `,S.activeRunIds.map((e,t)=>(0,q.jsxs)(v.Fragment,{children:[t>0?`, `:``,(0,q.jsx)(`a`,{href:`#/runs/${e}`,children:e.slice(0,8)})]},e))]}):null]}):null,_?(0,q.jsxs)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`},children:[(0,q.jsxs)(`div`,{className:`gate__label`,children:[(0,q.jsx)(`span`,{className:`dot dot--waiting`}),` Providers not ready`]}),(0,q.jsx)(`p`,{className:`gate__question`,children:_}),(0,q.jsxs)(`p`,{style:{margin:`var(--spacing-2) 0 0`,fontSize:`var(--font-size-sm)`},children:[(0,q.jsx)(`a`,{href:`#/connect`,children:`Connect providers`}),` · `,(0,q.jsx)(`a`,{href:`#/settings`,children:`Open Settings`})]})]}):null,h?(0,q.jsxs)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:[(0,q.jsx)(`div`,{className:`gate__label`,style:{color:`var(--color-text-red)`},children:`Could not start run`}),(0,q.jsx)(`p`,{className:`gate__question`,style:{color:`var(--color-text-primary)`},children:h.error})]}):null,D?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,marginBottom:`var(--spacing-4)`},children:[`Could not start run: `,D]}):null,(0,q.jsxs)(`div`,{className:`grid-2`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Task`})}),(0,q.jsx)(`div`,{className:`pick`,children:r.map(e=>(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`task`,checked:s===e.path,onChange:()=>c(e.path)}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:e.id}),(0,q.jsx)(`span`,{children:e.goal}),(0,q.jsx)(`span`,{className:`mono muted`,style:{display:`block`,fontSize:`var(--font-size-xs)`},children:e.path})]})]},e.path))})]})}),(0,q.jsx)(`div`,{children:(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Pipeline`})}),(0,q.jsx)(`div`,{className:`pick`,children:a.map(e=>(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`pipeline`,checked:l===e.path,onChange:()=>u(e.path)}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:e.id}),(0,q.jsxs)(`span`,{children:[e.stages.length,` stages`]}),(0,q.jsx)(`span`,{className:`mono muted`,style:{display:`block`,fontSize:`var(--font-size-xs)`},children:e.path})]})]},e.path))}),w.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`eyebrow`,style:{marginTop:`var(--spacing-4)`,marginBottom:`var(--spacing-3)`},children:`What will run`}),(0,q.jsx)(`div`,{className:`track track--inline`,children:(0,q.jsx)(Z_,{stages:w,mode:`definition`})}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-3)`},children:w.filter(e=>e.status===`waiting`).length===0?`No stage in this pipeline is declared to stop for a human.`:`${w.filter(e=>e.status===`waiting`).length} ${w.filter(e=>e.status===`waiting`).length===1?`stage`:`stages`} will hold and wait for you.`})]}):null]})})]}),(0,q.jsxs)(`div`,{className:`form-actions`,style:{paddingBottom:`var(--spacing-8)`},children:[(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:!s||!l||T||p,onClick:()=>void O(),children:p?`Starting…`:`Start run`}),(0,q.jsx)(`a`,{className:`btn btn--ghost`,href:`#/today`,children:`Cancel`})]})]})}var lv={waiting:`dot dot--waiting`,running:`dot dot--running`,failed:`dot dot--failed`,succeeded:`dot dot--succeeded`};function uv({label:e,count:t,status:n,children:r}){return(0,q.jsxs)(`section`,{className:`zone`,children:[(0,q.jsxs)(`div`,{className:`zone__head`,children:[(0,q.jsx)(`span`,{className:lv[n]}),(0,q.jsx)(`span`,{className:`eyebrow`,children:e}),(0,q.jsx)(`span`,{className:`zone__rule`}),(0,q.jsx)(`span`,{className:`zone__count`,children:t})]}),r]})}function dv({waiting:e,inFlight:t,broken:n,finished:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(uv,{label:e.label,count:e.count,status:e.status,children:e.children}),(0,q.jsx)(uv,{label:t.label,count:t.count,status:t.status,children:t.children}),(0,q.jsx)(uv,{label:n.label,count:n.count,status:n.status,children:n.children}),(0,q.jsx)(uv,{label:r.label,count:r.count,status:r.status,children:r.children})]})}function fv(e){return e===0?`Nothing needs you`:e===1?`One thing needs you`:`${e} things need you`}function pv(e){let t=e.waiting_stage_id??`this stage`;switch(e.waiting_kind){case`confirm`:return`Stage ${t} paused its session to ask. Rejecting sends your note back to the same session.`;case`artifact_backed`:return`Stage ${t} asked an artifact_backed prompt. Reject revises in the same session.`;case`multi_question`:return`Stage ${t} asked a multi_question prompt. All answers go back in one reply.`;case`free_text`:return`Stage ${t} asked a free_text prompt.`;case`feedback_loop_decision`:return`Feedback loop limit — decide extend, continue, or abandon`;default:return`Stage ${t} is waiting for input.`}}function mv(e){let t=e.waiting_artifacts?.[0];return t?{icon:`◆`,name:t.split(`/`).pop()??t}:{icon:`?`,name:e.waiting_kind??`waiting`}}function hv(e){let t=e.waiting_summary??`Waiting for input`;return t.length<=180?t:`${t.slice(0,180)}…`}var gv=400,_v=12;function vv(e){let t=e.split(`
|
|
119
|
+
`).slice(0,_v).join(`
|
|
120
|
+
`);return t.length>gv&&(t=`${t.slice(0,gv).trimEnd()}…`),t}function yv(e){let t=vv(e),n=t.split(`
|
|
121
|
+
`),r,i=[];for(let e of n){let t=e.match(/^#+\s+(.+)/);if(!r&&t?.[1]){r=t[1];continue}e.trim()&&i.push(e.replace(/^#+\s+/,``))}return(0,q.jsxs)(q.Fragment,{children:[r?(0,q.jsx)(`strong`,{children:r}):null,i.length>0?i.map((e,t)=>(0,q.jsx)(`p`,{children:e},t)):r?null:(0,q.jsx)(`p`,{children:t})]})}function bv({run:e}){let t=e.waiting_artifacts?.[0],[n,r]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(e.waiting_kind!==`artifact_backed`||!t){r(null);return}let n=!1;return dr(e.run_id,t).then(e=>{n||r(yv(e))}).catch(()=>{n||r(null)}),()=>{n=!0}},[e.run_id,e.waiting_kind,t]),e.waiting_kind===`multi_question`&&e.waiting_questions?.length?(0,q.jsx)(`span`,{className:`peek-doc`,children:e.waiting_questions.map((e,t)=>(0,q.jsx)(`p`,{children:e},t))}):(0,q.jsx)(`span`,{className:`peek-doc`,children:n??(0,q.jsx)(`p`,{children:hv(e)})})}function xv(e){let t=ii(e.updated_at??e.created_at),n=ai(e.stages,e.waiting_stage_id);return n?`held ${t} at ${n}`:`held ${t}`}function Sv(e){let t=e.stages?.find(e=>e.status===`running`);return t?t.id:e.waiting_stage_id?e.waiting_stage_id:``}function Cv({run:e,onOpen:t,onOpenArtifact:n}){let r=e.waiting_kind,i=r===`feedback_loop_decision`,a=!i&&e.waiting_prompt_id&&r?{promptId:e.waiting_prompt_id,kind:r}:null,{locked:o,error:s,submitIntent:c}=yl(e.run_id,e.waiting_stage_id,a),l=!i&&al({promptId:e.waiting_prompt_id,kind:i?null:r}),u=e.waiting_artifacts?.[0],d=mv(e),f=e.waiting_questions?.length??0;function p(){u?n(e.run_id,u):t(e.run_id)}return(0,q.jsxs)(`article`,{className:`block`,children:[(0,q.jsxs)(`div`,{className:`block__body`,children:[(0,q.jsxs)(`div`,{className:`block__meta`,children:[(0,q.jsx)(`a`,{className:`block__pipeline`,href:`#/pipelines/${e.pipeline_id}`,children:Lr(e)}),(0,q.jsx)(`span`,{className:`status status--waiting`,children:xv(e)})]}),(0,q.jsx)(`p`,{className:`block__q`,children:e.waiting_summary??`Waiting for input`}),(0,q.jsx)(`p`,{className:`block__sub`,children:pv(e)}),s?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`},children:[`Could not accept: `,s]}):null,(0,q.jsxs)(`div`,{className:`block__actions`,children:[i?(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:()=>t(e.run_id),children:`Decide on run`}):null,l?(0,q.jsx)(`button`,{className:`btn btn--accept`,disabled:o,onClick:()=>void c({type:`decision`,decision:`accept`}),children:`Accept`}):null,r===`confirm`||r===`artifact_backed`?(0,q.jsx)(`button`,{className:`btn btn--reject`,onClick:()=>t(e.run_id),children:`Reject with note`}):null,r===`multi_question`?(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:()=>t(e.run_id),children:f>0?`Answer ${f} questions`:`Answer questions`}):null,r===`free_text`?(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:()=>t(e.run_id),children:`Answer`}):null,r===`artifact_backed`&&u?(0,q.jsxs)(`button`,{className:`btn`,onClick:()=>n(e.run_id,u),children:[`Read `,d.name]}):null,(0,q.jsx)(`button`,{className:`btn btn--ghost`,onClick:()=>t(e.run_id),children:`Open run`})]})]}),(0,q.jsxs)(`button`,{className:`block__peek`,onClick:p,"aria-label":u?`Open ${d.name}`:`Open run`,children:[(0,q.jsxs)(`span`,{className:`block__peek-name`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:d.icon}),` `,d.name]}),(0,q.jsx)(bv,{run:e})]})]})}function wv({onOpen:e,onOpenArtifact:t,onNew:n,onSeeRuns:r}){let{snapshot:i,error:a,loading:o}=Mr(),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),d=Wr(i),f=qr(i),p=s??a;async function m(t){u(t);try{e((await $n(t)).runId)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(null)}}let h=!o&&d.waiting.length===0&&d.inFlight.length===0&&d.broken.length===0&&d.finished.length===0,g=d.finished.slice(0,3);return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:fv(d.waiting.length)}),(0,q.jsx)(`p`,{children:f.line})]}),(0,q.jsx)(`a`,{className:`btn btn--primary`,href:`#/new`,onClick:e=>{e.preventDefault(),n()},children:`Start a run`})]}),p?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`},children:[`Could not load runs: `,p]}):null,o?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,h?(0,q.jsx)(`div`,{className:`empty-hint`,children:`No runs yet. Start a pipeline to see triage zones fill in.`}):null,!o&&!h?(0,q.jsx)(dv,{waiting:{label:mi(),count:d.waiting.length,status:`waiting`,children:d.waiting.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Nothing waiting.`}):d.waiting.map(n=>(0,q.jsx)(Cv,{run:n,onOpen:e,onOpenArtifact:t},n.run_id))},inFlight:{label:`In flight`,count:d.inFlight.length,status:`running`,children:d.inFlight.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No runs in flight.`}):(0,q.jsx)(`div`,{className:`runs`,children:d.inFlight.map(t=>(0,q.jsxs)(`a`,{className:`run-row`,href:`#/runs/${t.run_id}`,onClick:n=>{n.preventDefault(),e(t.run_id)},children:[(0,q.jsxs)(`span`,{className:`run-row__id`,children:[(0,q.jsx)(`span`,{className:`dot dot--running`}),(0,q.jsxs)(`span`,{className:`run-row__name`,children:[Rr(t),` `,(0,q.jsxs)(`span`,{children:[`· `,Sv(t)]})]})]}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`track-mini`,"aria-hidden":`true`,children:t.stages.map(e=>{let t=_i(e.status);return(0,q.jsx)(`i`,{className:`track-mini__seg`,...t?{"data-s":t}:{}},e.id)})}),(0,q.jsx)(`span`,{className:`track-mini__label`,children:oi(t)})]}),(0,q.jsx)(`span`,{className:`run-row__right`,children:ii(t.updated_at??t.created_at)})]},t.run_id))})},broken:{label:`Broken`,count:d.broken.length,status:`failed`,children:d.broken.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No failed runs.`}):d.broken.map(t=>(0,q.jsxs)(`div`,{className:`fail-row`,children:[(0,q.jsx)(`span`,{className:`dot dot--failed`}),(0,q.jsxs)(`span`,{className:`fail-row__why`,children:[(0,q.jsx)(`b`,{children:Rr(t)}),` · `,Lr(t),t.failed_reason?(0,q.jsx)(`span`,{children:t.failed_reason}):null]}),(0,q.jsx)(`button`,{className:`btn btn--sm`,onClick:n=>{n.stopPropagation(),e(t.run_id)},children:`Open stage`}),(0,q.jsx)(`button`,{className:`btn btn--sm`,disabled:l===t.run_id,onClick:e=>{e.stopPropagation(),m(t.run_id)},children:l===t.run_id?`Starting fresh…`:`Start fresh`})]},t.run_id))},finished:{label:`Finished`,count:d.finished.length,status:`succeeded`,children:d.finished.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No finished runs yet.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`runs`,children:g.map(t=>(0,q.jsxs)(`a`,{className:`run-row`,href:`#/runs/${t.run_id}`,onClick:n=>{n.preventDefault(),e(t.run_id)},children:[(0,q.jsxs)(`span`,{className:`run-row__id`,children:[(0,q.jsx)(`span`,{className:`dot dot--succeeded`}),(0,q.jsxs)(`span`,{className:`run-row__name`,children:[Rr(t),` `,(0,q.jsxs)(`span`,{children:[`· `,Lr(t)]})]})]}),(0,q.jsxs)(`span`,{className:`mono muted`,children:[t.stages.length,` stages`]}),(0,q.jsx)(`span`,{className:`run-row__right`,children:ii(t.updated_at??t.created_at)})]},t.run_id))}),(0,q.jsx)(`p`,{style:{margin:`var(--spacing-3) 0 0`},children:(0,q.jsx)(`button`,{className:`btn btn--sm btn--ghost`,onClick:r,children:`See every run →`})})]})}}):null]})}var Tv=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,Ev=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Dv(e){let t={};e.directory.trim()||(t.directory=`Directory is required.`);let n=e.id.trim();if(n?(n.length>64||!Tv.test(n))&&(t.id=`Id must be lowercase kebab-case.`):t.id=`Id is required.`,e.selectedStageIds.length===0)t.stages=`Add at least one stage id.`;else if(new Set(e.selectedStageIds).size!==e.selectedStageIds.length)t.stages=`A pipeline cannot repeat the same stage id.`;else{for(let n of e.selectedStageIds)if(!Ev.test(n)){t.stages=`Stage id "${n}" must be lowercase kebab-case.`;break}if(!t.stages&&e.compositionMode===`dependencies`){let n=new Set(e.selectedStageIds);for(let r of e.selectedStageIds){let i=e.stageNeeds[r];if(i&&(!n.has(i)||i===r)){t.stages=`Stage "${r}" needs a stage that is in this pipeline.`;break}}}}return t}function Ov(e,t){let n=t?.trim(),r;if(e===409)r=`Could not create pipeline: this id already exists.`;else if(e===422){let e=n?.toLowerCase()??``;r=e.includes(`cycle`)?`Could not create pipeline: dependency cycle detected.`:e.includes(`unknown needs`)?`Could not create pipeline: a stage needs another stage that is not in this pipeline.`:e.includes(`duplicate`)?`Could not create pipeline: the same stage was listed more than once.`:e.includes(`missing stage file`)?`Could not create pipeline: create stage files beside the pipeline directory first.`:`Could not create pipeline. Try again.`}else r=`Could not create pipeline. Try again.`;return n?`${r} ${n}`:r}function kv(e){let t={};for(let n=1;n<e.length;n++)t[e[n]]=e[n-1];return t}function Av(e){let t=new Set;for(let n of e){let e=n.path.replace(/\\/g,`/`),r=e.lastIndexOf(`/`);t.add(r>=0?e.slice(0,r):`pipelines`)}return t.size===0&&t.add(`pipelines`),[...t].sort()}function jv({isOpen:e,onClose:t,onCreated:n,pipelines:r}){let i=Av(r),[a,o]=(0,v.useState)(i[0]??`pipelines`),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(`linear`),[h,g]=(0,v.useState)({}),[_,y]=(0,v.useState)({}),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),w=(0,v.useRef)(!1);(0,v.useEffect)(()=>{e&&!w.current&&(o(Av(r)[0]??`pipelines`),c(``),u([]),f(``),m(`linear`),g({}),y({}),x(null)),w.current=e},[e,r]),(0,v.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&j()}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);function T(e){e!==p&&(g(e===`dependencies`?kv(l):{}),m(e))}function E(){let e=d.trim();!e||l.includes(e)||(u(t=>[...t,e]),f(``))}function D(e,t){u(n=>{let r=e+t;if(r<0||r>=n.length)return n;let i=[...n],[a]=i.splice(e,1);return i.splice(r,0,a),p===`dependencies`&&g(kv(i)),i})}function O(e){let t=l[e];u(t=>t.filter((t,n)=>n!==e)),g(e=>{let n={...e};delete n[t];for(let[e,r]of Object.entries(n))r===t&&delete n[e];return n})}function k(e,t){g(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}async function A(){let e=s.trim(),t=a.trim(),r=Dv({directory:t,id:e,selectedStageIds:l,compositionMode:p,stageNeeds:h});if(y(r),x(null),Object.keys(r).length>0)return;C(!0);let i=await Pn({directory:t,id:e,stages:l.map(e=>{if(p===`dependencies`){let t=h[e];return t?{id:e,uses:`./${e}.yaml`,needs:t}:{id:e,uses:`./${e}.yaml`}}return{id:e,uses:`./${e}.yaml`}})});if(C(!1),i.ok){n(i.pipeline);return}x(Ov(i.status,i.error))}function j(){c(``),u([]),f(``),m(`linear`),g({}),y({}),x(null),t()}return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`drawer-scrim`,"aria-label":`Close panel`,onClick:j}),(0,q.jsxs)(`aside`,{className:`drawer drawer--right`,"aria-labelledby":`new-pipeline-title`,children:[(0,q.jsxs)(`div`,{className:`drawer__head`,children:[(0,q.jsx)(`h2`,{id:`new-pipeline-title`,style:{margin:0,fontSize:`var(--font-size-lg)`},children:`New pipeline`}),(0,q.jsx)(`span`,{style:{marginLeft:`auto`}}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:j,children:`Close`})]}),(0,q.jsxs)(`div`,{className:`drawer__body`,children:[b?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsx)(`p`,{className:`gate__question`,style:{color:`var(--color-text-primary)`,margin:0},children:b})}):null,(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-pipeline-directory`,children:`Directory`}),(0,q.jsx)(`input`,{id:`new-pipeline-directory`,className:`input`,list:`pipeline-directory-options`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1}),(0,q.jsx)(`datalist`,{id:`pipeline-directory-options`,children:i.map(e=>(0,q.jsx)(`option`,{value:e},e))}),_.directory?(0,q.jsx)(`p`,{className:`field-error`,children:_.directory}):(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:[`Repo-relative folder for `,(0,q.jsxs)(`span`,{className:`mono`,children:[s.trim()||`id`,`.pipeline.yaml`]}),` and stage files.`]})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-pipeline-id`,children:`Id`}),(0,q.jsx)(`input`,{id:`new-pipeline-id`,className:`input`,value:s,onChange:e=>c(e.target.value),autoComplete:`off`,spellCheck:!1}),_.id?(0,q.jsx)(`p`,{className:`field-error`,children:_.id}):null]}),(0,q.jsxs)(`div`,{className:`filters`,style:{marginTop:`var(--spacing-2)`},children:[(0,q.jsx)(`button`,{type:`button`,className:`tab`,"data-active":p===`linear`?`true`:void 0,onClick:()=>T(`linear`),children:`Linear`}),(0,q.jsx)(`button`,{type:`button`,className:`tab`,"data-active":p===`dependencies`?`true`:void 0,onClick:()=>T(`dependencies`),children:`Dependencies`})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`span`,{className:`eyebrow`,children:`Stage ids`}),(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,margin:`var(--spacing-1) 0 var(--spacing-3)`},children:[`Each id maps to `,(0,q.jsx)(`span`,{className:`mono`,children:`./<id>.yaml`}),` beside the pipeline file. Create stage files first.`]}),(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`,marginBottom:`var(--spacing-3)`},children:[(0,q.jsx)(`input`,{className:`input`,value:d,onChange:e=>f(e.target.value),placeholder:`stage-id`,autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())}}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:E,children:`Add`})]}),l.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No stages added yet.`}):(0,q.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0},children:l.map((e,t)=>(0,q.jsxs)(`li`,{style:{display:`flex`,alignItems:`center`,gap:`var(--spacing-2)`,padding:`var(--spacing-2) 0`,borderBottom:`1px solid var(--color-border)`},children:[(0,q.jsxs)(`span`,{className:`mono`,style:{flex:p===`dependencies`?void 0:1},children:[t+1,`. `,e]}),p===`dependencies`?(0,q.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`var(--spacing-2)`,flex:1,fontSize:`var(--font-size-sm)`},children:[(0,q.jsx)(`span`,{className:`muted`,children:`Needs`}),(0,q.jsxs)(`select`,{className:`input`,value:h[e]??``,onChange:t=>k(e,t.target.value),style:{flex:1,minWidth:0},children:[(0,q.jsx)(`option`,{value:``,children:`(none — root)`}),l.filter(t=>t!==e).map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]})]}):null,(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--ghost`,disabled:t===0,onClick:()=>D(t,-1),children:`Up`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--ghost`,disabled:t===l.length-1,onClick:()=>D(t,1),children:`Down`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm btn--ghost`,onClick:()=>O(t),children:`Remove`})]},`${e}-${t}`))}),_.stages?(0,q.jsx)(`p`,{className:`field-error`,children:_.stages}):null]}),(0,q.jsxs)(`div`,{className:`form-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:S,onClick:()=>void A(),children:S?`Creating…`:`Create pipeline`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:j,children:`Cancel`})]})]})]})]}):null}function Mv(e,t){return e===`all`?{}:e===`none`?{gate_kinds:[]}:{gate_kinds:t}}var Nv=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,Pv=`__inherit__`,Fv=`__other__`,Iv=[`free_text`,`confirm`,`multi_question`,`artifact_backed`];function Lv(e){let t={},n=e.id.trim();return n?(n.length>64||!Nv.test(n))&&(t.id=`Id must be lowercase kebab-case.`):t.id=`Id is required.`,e.useDropdown&&e.modelSelect===`__other__`&&!e.model.trim()&&(t.model=`Model is required when Other is selected.`),e.system_prompt.trim()||(t.system_prompt=`System prompt is required.`),t}function Rv(e){return e.useDropdown?e.modelSelect===`__inherit__`?``:e.modelSelect===`__other__`?e.customModel.trim():e.modelSelect.trim():e.plainModel.trim()}function zv(e,t){let n=e===409?`Could not create Stage: this id already exists.`:`Could not create Stage. Try again.`,r=t?.trim();return r?`${n} ${r}`:n}var Bv=()=>({id:``,system_prompt:``,gateMode:`all`,gateKinds:[],modelSelect:Pv,customModel:``,plainModel:``});function Vv({isOpen:e,onClose:t,onCreated:n,pipelineDirectory:r}){let[i,a]=(0,v.useState)(Bv),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)({}),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let{models:e}=await Nn();if(t)return;e.length>0?(s(e),l(!0)):(s([]),l(!1))}catch{if(t)return;s(null),l(!1)}})(),()=>{t=!0}},[e]),(0,v.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&t()}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);function g(){return Rv({useDropdown:c,modelSelect:i.modelSelect,customModel:i.customModel,plainModel:i.plainModel})}function _(e){a(t=>({...t,gateKinds:t.gateKinds.includes(e)?t.gateKinds.filter(t=>t!==e):[...t.gateKinds,e]}))}async function y(){let e=g(),t={id:i.id.trim(),system_prompt:i.system_prompt,model:e},o=Lv({...t,useDropdown:c,modelSelect:i.modelSelect});if(d(o),p(null),Object.keys(o).length>0)return;h(!0);let s=await Fn({pipeline_directory:r,filename:`${i.id.trim()}.yaml`,id:t.id,system_prompt:t.system_prompt,...e.length>0?{model:e}:{},...Mv(i.gateMode,i.gateKinds)});if(h(!1),s.ok){a(Bv()),d({}),p(null),n(s.stage);return}p(zv(s.status,s.error))}function b(){a(Bv()),d({}),p(null),t()}return e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`drawer-scrim`,"aria-label":`Close panel`,onClick:b}),(0,q.jsxs)(`aside`,{className:`drawer drawer--right`,"aria-labelledby":`new-stage-title`,children:[(0,q.jsxs)(`div`,{className:`drawer__head`,children:[(0,q.jsx)(`h2`,{id:`new-stage-title`,style:{margin:0,fontSize:`var(--font-size-lg)`},children:`New stage`}),(0,q.jsx)(`span`,{style:{marginLeft:`auto`}}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:b,children:`Close`})]}),(0,q.jsxs)(`div`,{className:`drawer__body`,children:[f?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsx)(`p`,{className:`gate__question`,style:{color:`var(--color-text-primary)`,margin:0},children:f})}):null,(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-stage-id`,children:`Id`}),(0,q.jsx)(`input`,{id:`new-stage-id`,className:`input`,value:i.id,onChange:e=>a(t=>({...t,id:e.target.value})),autoComplete:`off`,spellCheck:!1}),u.id?(0,q.jsx)(`p`,{className:`field-error`,children:u.id}):(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:[`Writes `,(0,q.jsxs)(`span`,{className:`mono`,children:[r,`/<id>.yaml`]}),`.`]})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-stage-model`,children:`Model`}),c&&o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`select`,{id:`new-stage-model`,className:`select`,value:i.modelSelect,onChange:e=>a(t=>({...t,modelSelect:e.target.value})),children:[(0,q.jsx)(`option`,{value:Pv,children:`Inherit default`}),o.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e)),(0,q.jsx)(`option`,{value:Fv,children:`Other...`})]}),i.modelSelect===`__other__`?(0,q.jsx)(`input`,{className:`input`,style:{marginTop:`var(--spacing-2)`},value:i.customModel,onChange:e=>a(t=>({...t,customModel:e.target.value})),placeholder:`Model id`,autoComplete:`off`,spellCheck:!1}):null]}):(0,q.jsx)(`input`,{id:`new-stage-model`,className:`input`,value:i.plainModel,onChange:e=>a(t=>({...t,plainModel:e.target.value})),autoComplete:`off`,spellCheck:!1}),u.model?(0,q.jsx)(`p`,{className:`field-error`,children:u.model}):(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:`Optional. Inherits pipeline then global default when omitted.`})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-stage-prompt`,children:`System prompt`}),(0,q.jsx)(`textarea`,{id:`new-stage-prompt`,className:`textarea`,rows:6,value:i.system_prompt,onChange:e=>a(t=>({...t,system_prompt:e.target.value}))}),u.system_prompt?(0,q.jsx)(`p`,{className:`field-error`,children:u.system_prompt}):null]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`span`,{className:`eyebrow`,children:`HITL`}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,margin:`var(--spacing-1) 0 var(--spacing-3)`},children:`All kinds keeps every ask kind available. No HITL unregisters ask_operator. Allowlist restricts kinds.`}),(0,q.jsxs)(`div`,{className:`pick`,children:[(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`new-stage-hitl`,checked:i.gateMode===`all`,onChange:()=>a(e=>({...e,gateMode:`all`}))}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`All kinds`}),(0,q.jsx)(`span`,{className:`muted`,children:` Compatible default. Every ask kind is available.`})]})]}),(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`new-stage-hitl`,checked:i.gateMode===`none`,onChange:()=>a(e=>({...e,gateMode:`none`}))}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`No HITL`}),(0,q.jsx)(`span`,{className:`muted`,children:` Writes gate_kinds: []. The stage cannot ask the operator.`})]})]}),(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`new-stage-hitl`,checked:i.gateMode===`allowlist`,onChange:()=>a(e=>({...e,gateMode:`allowlist`}))}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Allowlist`}),(0,q.jsx)(`span`,{className:`muted`,children:` Only the kinds you select.`})]})]})]}),i.gateMode===`allowlist`?(0,q.jsx)(`div`,{className:`pick`,style:{marginTop:`var(--spacing-3)`},children:Iv.map(e=>(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:i.gateKinds.includes(e),onChange:()=>_(e)}),(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{className:`mono`,children:e})})]},e))}):null]}),(0,q.jsxs)(`div`,{className:`form-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:m,onClick:()=>void y(),children:m?`Creating…`:`Create stage`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:b,children:`Cancel`})]})]})]})]}):null}function Hv(e){window.location.hash=e.startsWith(`#`)?e:`#${e}`}function Uv(e){return`/runs/${encodeURIComponent(e)}`}function Wv(e,t){return`/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}`}function Gv(e,t){return`/runs/${encodeURIComponent(e)}/artifacts?path=${encodeURIComponent(t)}`}function Kv(e,t){return`/runs/${encodeURIComponent(e)}/stages/${encodeURIComponent(t)}/envelope`}function qv(e){return`/pipelines/${encodeURIComponent(e)}`}function Jv(e){return`/tasks/${encodeURIComponent(e)}`}function Yv(e){return`/triggers/${encodeURIComponent(e)}`}function Xv(e){return`/skills/${encodeURIComponent(e)}`}function Zv(e,t){return`/extensions/packages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function Qv(e){return`/extensions/files/${encodeURIComponent(e)}`}function $v(e){let t=new URLSearchParams;e?.pipeline&&t.set(`pipeline`,e.pipeline),e?.task&&t.set(`task`,e.task);let n=t.toString();return n?`/workshop?${n}`:`/workshop`}function ey(e){let t=new URLSearchParams;e?.pipeline&&t.set(`pipeline`,e.pipeline),e?.task&&t.set(`task`,e.task);let n=t.toString();return n?`/new?${n}`:`/new`}function ty(e){let t=e.replace(/^#\/?/,``),n=t.indexOf(`?`);return n<0?{path:t,params:new URLSearchParams}:{path:t.slice(0,n),params:new URLSearchParams(t.slice(n+1))}}function ny(e){let t=e.indexOf(`/`),n=t<0?e:e.slice(0,t);return n?decodeURIComponent(n):``}function ry(e=window.location.hash){let{path:t,params:n}=ty(e);if(!t||t===`today`)return{name:`today`};if(t===`runs`)return{name:`runs`};if(t===`new`){let e=n.get(`pipeline`)??void 0,t=n.get(`task`)??void 0;return{name:`new`,...e?{pipelineId:e}:{},...t?{taskPath:t}:{}}}if(t===`pipelines`)return{name:`pipelines`};if(t.startsWith(`pipelines/`)){let e=ny(t.slice(10));if(e)return{name:`pipeline`,pipelineId:e}}if(t===`tasks`)return{name:`tasks`};if(t.startsWith(`tasks/`)){let e=ny(t.slice(6));if(e)return{name:`task`,taskId:e}}if(t===`triggers`)return{name:`triggers`};if(t.startsWith(`triggers/`)){let e=ny(t.slice(9));if(e)return{name:`trigger`,triggerId:e}}if(t===`skills`)return{name:`skills`};if(t.startsWith(`skills/`)){let e=ny(t.slice(7));if(e)return{name:`skill`,skillName:e}}if(t===`extensions`)return{name:`extensions`};if(t.startsWith(`extensions/packages/`)){let e=t.slice(20),n=e.indexOf(`/`);if(n>0){let t=decodeURIComponent(e.slice(0,n)),r=decodeURIComponent(e.slice(n+1));if((t===`user`||t===`project`)&&r)return{name:`extensionPackage`,scope:t,source:r}}}if(t.startsWith(`extensions/files/`)){let e=decodeURIComponent(t.slice(17));if(e)return{name:`extensionFile`,path:e}}if(t===`settings`)return{name:`settings`};if(t===`connect`)return{name:`connect`};if(t===`workshop`||t===`workshop-lab`){let e=n.get(`pipeline`)??void 0,t=n.get(`task`)??void 0;return{name:`workshop`,...e?{pipelinePath:e}:{},...t?{taskPath:t}:{}}}if(t.startsWith(`runs/`)){let e=t.slice(5).split(`/`),r=decodeURIComponent(e[0]??``);if(!r)return{name:`today`};if(e[1]===`stages`&&e[3]===`envelope`&&e[2]&&e.length===4)return{name:`detail`,runId:r,view:{kind:`envelope`,stageId:decodeURIComponent(e[2])}};if(e[1]===`stages`&&e[2]&&e.length===3)return{name:`detail`,runId:r,view:{kind:`stream`,stageId:decodeURIComponent(e[2])}};if(e[1]===`artifacts`&&e.length===2){let e=n.get(`path`);if(e)return{name:`detail`,runId:r,view:{kind:`artifact`,path:e}}}return e.length,{name:`detail`,runId:r,view:{kind:`stream`}}}return{name:`today`}}var iy={center:{kGNEyG:`x6s0dn4`,$$css:!0},end:{kGNEyG:`xuk3077`,$$css:!0},start:{kGNEyG:`x1cy8zhl`,$$css:!0},stretch:{kGNEyG:`x1qjc9v5`,$$css:!0}},ay={start:{kjj79g:`x1nhvcw1`,$$css:!0},center:{kjj79g:`xl56j7k`,$$css:!0},end:{kjj79g:`x13a6bvl`,$$css:!0},between:{kjj79g:`x1qughib`,$$css:!0},around:{kjj79g:`x1l1ennw`,$$css:!0},evenly:{kjj79g:`xaw8158`,$$css:!0}},oy={horizontal:{kXwgrk:`x1q0g3np`,$$css:!0},vertical:{kXwgrk:`xdt5ytf`,$$css:!0}},sy={nowrap:{kwnvtZ:`xozqiw3`,$$css:!0},wrap:{kwnvtZ:`x1a02dak`,$$css:!0},"wrap-reverse":{kwnvtZ:`x8hhl5t`,$$css:!0}},cy={stack:{k1xSpc:`x78zum5`,$$css:!0}},ly={0:{k1C7PZ:`x1o57wo1`,khm7nJ:`x6yxi7o`,$$css:!0},1:{k1C7PZ:`x1lfs0n9`,khm7nJ:`x1ngg2t4`,$$css:!0},2:{k1C7PZ:`xak3so`,khm7nJ:`x1x7z4sm`,$$css:!0},3:{k1C7PZ:`xewh9hi`,khm7nJ:`x4olc9o`,$$css:!0},4:{k1C7PZ:`xty4p9g`,khm7nJ:`xtx9w7w`,$$css:!0},5:{k1C7PZ:`x1eqhezk`,khm7nJ:`x1iu6piu`,$$css:!0},6:{k1C7PZ:`x3qlgwd`,khm7nJ:`xczp1bk`,$$css:!0},8:{k1C7PZ:`xicv188`,khm7nJ:`xgx0vcf`,$$css:!0},10:{k1C7PZ:`x1p37tyl`,khm7nJ:`x1xpicb7`,$$css:!0},"0.5":{k1C7PZ:`x1kihgfc`,khm7nJ:`x1tw44j4`,$$css:!0},"1.5":{k1C7PZ:`x1thn6ci`,khm7nJ:`xhq53yo`,$$css:!0}};function uy({crossAlign:e,direction:t,gap:n,mainAlign:r,wrap:i}){return[cy.stack,oy[t],n!=null&&ly[n],e!=null&&iy[e],r!=null&&ay[r],i!=null&&sy[i]]}var dy={0:{kZCmMZ:`x18gyask`,kwRFfy:`x1s0aq8i`,$$css:!0},1:{kZCmMZ:`x1vsv5vr`,kwRFfy:`x1nryj5t`,$$css:!0},2:{kZCmMZ:`x12gdq22`,kwRFfy:`x1djylfy`,$$css:!0},3:{kZCmMZ:`x126nfab`,kwRFfy:`x1t818jl`,$$css:!0},4:{kZCmMZ:`x1rey3nv`,kwRFfy:`xnjyzlh`,$$css:!0},5:{kZCmMZ:`x1blguxw`,kwRFfy:`xdbrk9v`,$$css:!0},6:{kZCmMZ:`x31w388`,kwRFfy:`x1we12cn`,$$css:!0},8:{kZCmMZ:`x1j3hnjz`,kwRFfy:`x1q91b2g`,$$css:!0},10:{kZCmMZ:`xqp078j`,kwRFfy:`x160ivqr`,$$css:!0},"0.5":{kZCmMZ:`x138rykx`,kwRFfy:`x1le3yxw`,$$css:!0},"1.5":{kZCmMZ:`xfti1ec`,kwRFfy:`x17hk9do`,$$css:!0}},fy={0:{kLKAdn:`x1ydh6w3`,kGO01o:`x1l20ajd`,$$css:!0},1:{kLKAdn:`xfsso4q`,kGO01o:`xy143xn`,$$css:!0},2:{kLKAdn:`x1xye8es`,kGO01o:`x1wesfrj`,$$css:!0},3:{kLKAdn:`x1vlblms`,kGO01o:`xvmdzux`,$$css:!0},4:{kLKAdn:`x1oa1p4a`,kGO01o:`x1awphl8`,$$css:!0},5:{kLKAdn:`xx7rijo`,kGO01o:`x1hk98q`,$$css:!0},6:{kLKAdn:`x1adxfkp`,kGO01o:`xjpqqx5`,$$css:!0},8:{kLKAdn:`xoxd1wu`,kGO01o:`x2oz4g1`,$$css:!0},10:{kLKAdn:`xk6660b`,kGO01o:`x2izi54`,$$css:!0},"0.5":{kLKAdn:`xbx876j`,kGO01o:`xij103a`,$$css:!0},"1.5":{kLKAdn:`x1kwdpsa`,kGO01o:`x1opdxmq`,$$css:!0}},py={scrollable:{kVQacm:`xysyzu8`,$$css:!0}};function my({direction:e=`vertical`,hAlign:t,vAlign:n,justify:r,align:i,gap:a,padding:o,paddingInline:s,paddingBlock:c,isScrollable:l,width:u,height:d,maxWidth:f,minHeight:p,wrap:m,as:h=`div`,xstyle:g,className:_,style:y,children:b,ref:x,...S}){let C=t??(e===`horizontal`?r:i),T=n??(e===`horizontal`?i:r),E=e===`horizontal`?C:T,D=e===`horizontal`?T:C,O=s??o,k=c??o,A=w(...uy({direction:e,crossAlign:D,mainAlign:E,gap:a,wrap:m}),O!=null&&dy[O],k!=null&&fy[k],l&&py.scrollable,g),j={...u!=null&&{width:typeof u==`number`?`${u}px`:u},...d!=null&&{height:typeof d==`number`?`${d}px`:d},...f!=null&&{maxWidth:typeof f==`number`?`${f}px`:f},...p!=null&&{minHeight:typeof p==`number`?`${p}px`:p}};return(0,v.createElement)(h,{ref:x,...J(Y(`stack`,{direction:e,gap:a,wrap:m}),A,_,{...y,...j}),...S},b)}my.displayName=`Stack`;var hy={reset:{kAzted:`x2lwn1j`,k7Eaqz:`xeuugli`,$$css:!0}},gy={center:{kSGwAc:`xamitd3`,$$css:!0},end:{kSGwAc:`xpvyfi4`,$$css:!0},start:{kSGwAc:`xqcrz7y`,$$css:!0},stretch:{kSGwAc:`xkh2ocl`,$$css:!0}},_y={fill:{kzQI83:`x1iyjqo2`,$$css:!0},static:{kzQI83:`x1c4vz4f`,kmuXW:`x2lah0s`,$$css:!0}};function vy({crossAlignSelf:e,size:t}={}){return[hy.reset,_y[t??`static`],e!=null&&gy[e]]}var yy={scrollable:{kVQacm:`xysyzu8`,$$css:!0}};function by({crossAlignSelf:e,size:t,isScrollable:n,as:r=`div`,xstyle:i,className:a,style:o,children:s,ref:c,...l}){let u=w(...vy({crossAlignSelf:e,size:t}),n&&yy.scrollable,i);return(0,v.createElement)(r,{ref:c,...J(Y(`stack-item`,{size:t}),u,a,o),...l},s)}by.displayName=`StackItem`;function xy({status:e}){let t=fi(e),n=t&&t!==`running`?`status status--${t}`:`status`,r=t?`dot dot--${t}`:`dot`;return(0,q.jsxs)(`span`,{className:n,children:[(0,q.jsx)(`span`,{className:r}),` `,pi(e)]})}var Sy=null,Cy=null;function wy(e,t=4e3){Sy||(Sy=document.createElement(`div`),Sy.className=`toast`,Sy.setAttribute(`role`,`status`),document.body.appendChild(Sy)),Sy.textContent=e,Sy.setAttribute(`data-show`,`true`),Cy&&clearTimeout(Cy),Cy=setTimeout(()=>{Sy?.setAttribute(`data-show`,`false`)},t)}function Ty(e){return e.map(e=>{let t=e.gate_kinds;return{id:e.id,label:e.id,status:ni(t)?`waiting`:`pending`,meta:Ey(t)}})}function Ey(e){return!Array.isArray(e)||e.length===0?`none`:e.join(` · `)}function Dy(e){return e.inline?`inline`:e.uses_path?e.uses_path:`—`}function Oy(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n>=0?t.slice(0,n):`.`}function ky(e,t){let n=Oy(e.path);return t.filter(e=>n===`.`?!e.path.includes(`/`):e.path.startsWith(`${n}/`))[0]?.path??t[0]?.path}function Ay({stages:e}){return(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`mini`,"aria-hidden":`true`,children:e.map((e,t)=>(0,q.jsxs)(v.Fragment,{children:[t>0?(0,q.jsx)(`i`,{className:`mini__w`}):null,(0,q.jsx)(`i`,{className:`mini__n`,"data-s":ni(e.gate_kinds)?`waiting`:void 0,children:ni(e.gate_kinds)?`?`:String(t+1)})]},e.id))}),(0,q.jsx)(`span`,{className:`mini__label`,style:{display:`block`},children:e.map(e=>e.id).join(` · `)})]})}function jy({pipelineId:e,onNew:t}){let{snapshot:n,error:r,loading:i}=Mr(),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),_=(0,v.useCallback)(async()=>{try{let[e,t]=await Promise.all([On(),Dn()]);o(e.pipelines),c(t.tasks),u(null)}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}},[]);(0,v.useEffect)(()=>{_()},[_]);let y=d||i,b=l??r,x=e?a.find(t=>t.id===e)??null:null,S=x?Xr(n,x):[];async function C(e){g(!1);try{let e=await On();o(e.pipelines),u(null)}catch(e){u(e instanceof Error?e.message:String(e))}wy(`Pipeline created · ${e.id}`),t(qv(e.id))}return e?(0,q.jsx)(My,{pipelineId:e,pipeline:x,tasks:s,runs:S,loading:y,error:b,onNew:t,onStageCreated:()=>void _(),stagePanelOpen:p,onOpenStagePanel:()=>m(!0),onCloseStagePanel:()=>m(!1)}):(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Pipelines`}),(0,q.jsx)(`p`,{children:`Manifest-declared pipeline files and their embedded stages. Each row shows its chain and which stages will stop for a human.`})]}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>g(!0),children:`New pipeline`})]}),b?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:b}):null,y?(0,q.jsx)(`p`,{className:`muted`,children:`Loading pipelines…`}):null,!y&&a.length===0?(0,q.jsxs)(`div`,{className:`empty-hint`,children:[(0,q.jsxs)(`p`,{style:{margin:`0 0 var(--spacing-3)`},children:[`No pipelines in the manifest yet. Add a `,(0,q.jsx)(`span`,{className:`mono`,children:`stageflow.yaml`}),` catalog entry or run`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`sf init`}),`.`]}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>g(!0),children:`New pipeline`})]}):null,!y&&a.length>0?(0,q.jsx)(q.Fragment,{children:a.map(e=>{let t=Xr(n,e),r=ri(e.stages);return(0,q.jsxs)(`a`,{className:`rrow`,href:`#${qv(e.id)}`,children:[(0,q.jsxs)(`span`,{className:`rrow__id`,children:[(0,q.jsx)(`span`,{className:`rrow__task`,children:e.id}),(0,q.jsx)(`span`,{className:`rrow__pipe`,children:e.path})]}),(0,q.jsxs)(`span`,{className:`rrow__right`,children:[r===1?`1 gate`:`${r} gates`,(0,q.jsx)(`br`,{}),(0,q.jsxs)(`span`,{className:`mono`,style:{fontSize:`var(--font-size-xs)`},children:[t.length,` `,t.length===1?`run`:`runs`]})]}),(0,q.jsx)(`span`,{className:`rrow__track`,children:(0,q.jsx)(Ay,{stages:e.stages})})]},`${e.path}:${e.id}`)})}):null,(0,q.jsx)(jv,{isOpen:h,onClose:()=>g(!1),onCreated:e=>void C(e),pipelines:a})]})}function My({pipelineId:e,pipeline:t,tasks:n,runs:r,loading:i,error:a,onNew:o,onStageCreated:s,stagePanelOpen:c,onOpenStagePanel:l,onCloseStagePanel:u}){let d=(0,v.useMemo)(()=>t?Ty(t.stages):[],[t]),f=t?ri(t.stages):0,p=t?`${t.path} · ${t.stages.length} stages · ${f===1?`1 gate`:`${f} gates`} · ${r.length} ${r.length===1?`run`:`runs`}`:e,m=t?ky(t,n):void 0;return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/pipelines`,children:`Pipelines`}),` / `,e]}),(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e}),(0,q.jsx)(`p`,{className:`mono`,children:p})]}),t?(0,q.jsxs)(`div`,{className:`page-head__actions`,children:[(0,q.jsx)(`a`,{className:`btn`,href:`#${$v({pipeline:t.path})}`,children:`Open in Workshop`}),(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:()=>o(ey({pipeline:t.path,...m?{task:m}:{}})),children:`Start a run with this`})]}):null]}),a?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:a}):null,i?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!i&&!t?(0,q.jsxs)(`p`,{className:`muted`,children:[e,` is not in the current manifest catalog.`]}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Z_,{stages:d,mode:`definition`}),(0,q.jsxs)(`div`,{className:`page-head`,style:{marginTop:`var(--spacing-6)`},children:[(0,q.jsx)(`h3`,{style:{margin:0},children:`Stages`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:l,children:`Add stage file`})]}),(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Stage`}),(0,q.jsx)(`th`,{children:`Gate`}),(0,q.jsx)(`th`,{children:`Source`})]})}),(0,q.jsx)(`tbody`,{children:t.stages.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{className:`mono`,children:e.id}),(0,q.jsx)(`td`,{className:`muted`,children:Ey(e.gate_kinds)}),(0,q.jsx)(`td`,{className:`mono muted`,children:Dy(e)})]},e.id))})]}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-3)`},children:f===1?`Only one stage stops for a human. That is worth knowing before you start a run, not after.`:f===0?`No stage in this pipeline is declared to stop for a human.`:`${f} stages stop for a human.`}),(0,q.jsx)(`h3`,{style:{marginTop:`var(--spacing-6)`},children:`Recent runs`}),r.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No runs of this pipeline yet.`}):(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Task`}),(0,q.jsx)(`th`,{children:`Status`}),(0,q.jsx)(`th`,{children:`When`})]})}),(0,q.jsx)(`tbody`,{children:r.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsxs)(`td`,{children:[(0,q.jsx)(`a`,{href:`#${Uv(e.run_id)}`,children:Rr(e)}),e.task_path?(0,q.jsx)(`span`,{className:`muted mono`,style:{display:`block`,fontSize:`var(--font-size-xs)`},children:Pr(e.task_path,e.project_root)}):null]}),(0,q.jsx)(`td`,{children:(0,q.jsx)(xy,{status:di(e)})}),(0,q.jsx)(`td`,{className:`muted`,children:ii(e.created_at)})]},e.run_id))})]})]}):null,(0,q.jsx)(Vv,{isOpen:c,onClose:u,pipelineDirectory:t?Oy(t.path):`pipelines`,onCreated:e=>{u(),s()}})]})}function Ny({taskId:e,onNew:t}){let{snapshot:n,error:r,loading:i}=Mr(),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{try{let e=await Dn();o(e.tasks),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);(0,v.useEffect)(()=>{d()},[d]);let f=l||i,p=s??r,m=e?a.find(t=>t.id===e)??null:null,h=m?Yr(n,m.id):[];return e?(0,q.jsx)(Py,{taskId:e,task:m,runs:h,loading:f,error:p,onNew:t}):(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Tasks`}),(0,q.jsx)(`p`,{children:`A task is a brief plus the pipeline it should run through. Tasks are reusable; runs are not.`})]})}),p?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:p}):null,f?(0,q.jsx)(`p`,{className:`muted`,children:`Loading tasks…`}):null,!f&&a.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No tasks yet. Add a YAML file under tasks/ in this project.`}):null,!f&&a.length>0?(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Task`}),(0,q.jsx)(`th`,{children:`Pipeline`}),(0,q.jsx)(`th`,{children:`Runs`}),(0,q.jsx)(`th`,{children:`Last result`}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:a.map(e=>{let r=Yr(n,e.id),i=r[0],a=i?di(i):void 0,o=i?.pipeline_id;return(0,q.jsxs)(`tr`,{children:[(0,q.jsxs)(`td`,{children:[(0,q.jsx)(`a`,{href:`#${Jv(e.id)}`,children:e.id}),(0,q.jsx)(`div`,{className:`muted`,style:{fontSize:`var(--font-size-xs)`},children:e.goal})]}),(0,q.jsx)(`td`,{className:`mono`,children:o??`—`}),(0,q.jsx)(`td`,{className:`mono`,children:r.length}),(0,q.jsx)(`td`,{children:a?(0,q.jsx)(xy,{status:a}):(0,q.jsx)(`span`,{className:`muted`,children:`no runs`})}),(0,q.jsx)(`td`,{style:{textAlign:`right`},children:i?(0,q.jsx)(`a`,{className:`btn btn--sm`,href:`#${Uv(i.run_id)}`,children:`Open run`}):(0,q.jsx)(`button`,{className:`btn btn--sm`,onClick:()=>t(ey({task:e.path})),children:`Run it`})})]},e.id)})})]}):null]})}function Py({taskId:e,task:t,runs:n,loading:r,error:i,onNew:a}){let o=n[0],s=o?.pipeline_path&&o.project_root?Pr(o.pipeline_path,o.project_root):o?.pipeline_path&&!o.pipeline_path.startsWith(`/`)?o.pipeline_path:void 0,c=Wr({runs:n,health:null}),l=c.waiting.length+c.inFlight.length,u=t?`${t.path} · ${n.length} ${n.length===1?`run`:`runs`}${l>0?` · ${l} in flight`:``}`:e;return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/tasks`,children:`Tasks`}),` / `,e]}),(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e}),(0,q.jsx)(`p`,{className:`mono`,children:u})]}),t?(0,q.jsxs)(`div`,{className:`page-head__actions`,children:[s?(0,q.jsx)(`a`,{className:`btn`,href:`#${$v({pipeline:s})}`,title:`Opens the bound pipeline; task stays unattached until you attach it`,children:`Open in Workshop`}):(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:!0,title:`Run this task once so Workshop can resolve its pipeline path`,children:`Open in Workshop`}),(0,q.jsx)(`button`,{className:`btn btn--primary`,onClick:()=>a(ey({task:t.path,pipeline:o?.pipeline_id})),children:`Run it again`})]}):null]}),i?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:i}):null,r?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!r&&!t?(0,q.jsxs)(`p`,{className:`muted`,children:[e,` is not in this project's tasks/ catalog.`]}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{children:`Brief`}),(0,q.jsx)(`p`,{children:t.goal}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Pipeline`}),o?(0,q.jsx)(`a`,{href:`#${qv(o.pipeline_id)}`,style:{fontWeight:500},children:o.pipeline_id}):(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No runs yet — pick a pipeline when you start one.`}),(0,q.jsx)(`h3`,{style:{marginTop:`var(--spacing-6)`},children:`Run history`}),n.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`No runs of this task yet.`}):(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Run`}),(0,q.jsx)(`th`,{children:`Status`}),(0,q.jsx)(`th`,{children:`Pipeline`}),(0,q.jsx)(`th`,{children:`When`})]})}),(0,q.jsx)(`tbody`,{children:n.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsx)(`a`,{href:`#${Uv(e.run_id)}`,children:e.run_id})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(xy,{status:di(e)})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(`a`,{href:`#${qv(e.pipeline_id)}`,children:e.pipeline_id})}),(0,q.jsx)(`td`,{className:`muted`,children:ii(e.created_at)})]},e.run_id))})]})]}):null]})}var Fy=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Iy(e){let t={};e.directory.trim()||(t.directory=`Directory is required.`);let n=e.id.trim();return n?(n.length>64||!Fy.test(n))&&(t.id=`Id must be lowercase kebab-case.`):t.id=`Id is required.`,e.pipeline||(t.pipeline=`Select a pipeline.`),e.taskMode===`catalog`&&!e.task&&(t.task=`Select a task.`),e.kind===`schedule`&&!e.cron.trim()&&(t.cron=`Cron expression is required.`),e.kind===`event`&&!e.source.trim()&&(t.source=`Event source is required.`),t}function Ly(e,t){let n=t?.trim(),r;return r=e===409?`Could not create trigger: this id already exists.`:e===422?`Could not create trigger: invalid reference or schedule.`:e===400?`Could not create trigger: invalid input.`:`Could not create trigger. Try again.`,n?`${r} ${n}`:r}function Ry(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n>=0?t.slice(0,n):`.`}var zy=()=>({directory:``,directoryTouched:!1,id:``,pipeline:``,task:``,taskMode:`catalog`,kind:`manual`,cron:``,timezone:``,source:``,enabled:!0});function By({isOpen:e,onClose:t,onCreated:n}){let[r,i]=(0,v.useState)(zy),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;i(zy()),u({}),f(null),o(null),c(null);let t=!1;return(async()=>{try{let[e,n]=await Promise.all([On(),Dn()]);if(t)return;o(e.pipelines),c(n.tasks)}catch{if(t)return;o([]),c([])}})(),()=>{t=!0}},[e]),(0,v.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&_()}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);function h(e){i(t=>{let n={...t,pipeline:e};if(!t.directoryTouched&&a){let t=a.find(t=>t.id===e);t&&(n.directory=Ry(t.path))}return n})}async function g(){let e={directory:r.directory.trim(),id:r.id.trim(),pipeline:r.pipeline,task:r.task,taskMode:r.taskMode,kind:r.kind,cron:r.cron.trim(),source:r.source.trim()},t=Iy(e);if(u(t),f(null),Object.keys(t).length>0)return;m(!0);let i=await Mn({directory:e.directory,id:e.id,pipeline:e.pipeline,...e.taskMode===`catalog`?{task:e.task}:{},kind:e.kind,...e.kind===`schedule`?{schedule:{cron:e.cron,...r.timezone.trim()?{timezone:r.timezone.trim()}:{}}}:{},...e.kind===`event`?{event:{source:e.source}}:{},enabled:r.enabled});if(m(!1),i.ok){n(i.trigger);return}f(Ly(i.status,i.error))}function _(){i(zy()),u({}),f(null),t()}if(!e)return null;let y=a===null,b=s===null;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,className:`drawer-scrim`,"aria-label":`Close panel`,onClick:_}),(0,q.jsxs)(`aside`,{className:`drawer drawer--right`,"aria-labelledby":`new-trigger-title`,children:[(0,q.jsxs)(`div`,{className:`drawer__head`,children:[(0,q.jsx)(`h2`,{id:`new-trigger-title`,style:{margin:0,fontSize:`var(--font-size-lg)`},children:`New trigger`}),(0,q.jsx)(`span`,{style:{marginLeft:`auto`}}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--sm`,onClick:_,children:`Close`})]}),(0,q.jsxs)(`div`,{className:`drawer__body`,children:[d?(0,q.jsx)(`div`,{className:`gate`,style:{padding:`var(--spacing-4)`,marginBottom:`var(--spacing-5)`,borderColor:`var(--color-border-red)`,borderLeftColor:`var(--color-error)`,background:`var(--color-background-red)`,color:`var(--color-text-red)`},children:(0,q.jsx)(`p`,{className:`gate__question`,style:{color:`var(--color-text-primary)`,margin:0},children:d})}):null,(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-pipeline`,children:`Pipeline`}),(0,q.jsxs)(`select`,{id:`new-trigger-pipeline`,className:`select`,value:r.pipeline,disabled:y,onChange:e=>h(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:y?`Loading pipelines…`:`Select a pipeline`}),(a??[]).map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),l.pipeline?(0,q.jsx)(`p`,{className:`field-error`,children:l.pipeline}):!y&&a?.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:`No pipelines in the manifest yet.`}):null]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`span`,{className:`eyebrow`,children:`Task`}),(0,q.jsxs)(`div`,{className:`pick`,style:{marginTop:`var(--spacing-2)`},children:[(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`new-trigger-task-mode`,checked:r.taskMode===`catalog`,onChange:()=>i(e=>({...e,taskMode:`catalog`}))}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Pick from catalog`}),(0,q.jsx)(`span`,{className:`muted`,children:` Runs the same catalog task on every fire.`})]})]}),(0,q.jsxs)(`label`,{className:`pick__opt`,children:[(0,q.jsx)(`input`,{type:`radio`,name:`new-trigger-task-mode`,checked:r.taskMode===`dynamic`,onChange:()=>i(e=>({...e,taskMode:`dynamic`}))}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Dynamic — supplied when fired`}),(0,q.jsx)(`span`,{className:`muted`,children:` No fixed task; the caller must supply one.`})]})]})]}),r.taskMode===`catalog`?(0,q.jsxs)(`div`,{style:{marginTop:`var(--spacing-3)`},children:[(0,q.jsxs)(`select`,{id:`new-trigger-task`,className:`select`,value:r.task,disabled:b,onChange:e=>i(t=>({...t,task:e.target.value})),children:[(0,q.jsx)(`option`,{value:``,children:b?`Loading tasks…`:`Select a task`}),(s??[]).map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.id},e.path))]}),l.task?(0,q.jsx)(`p`,{className:`field-error`,children:l.task}):!b&&s?.length===0?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:`No tasks in the manifest yet.`}):null]}):(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-3)`},children:[`This trigger has no fixed task. Whoever fires it — a webhook, a script,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`sf trigger fire --task-inline`}),`, or the`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`fire_trigger`}),` MCP tool — must supply one, or the fire is rejected.`]})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-directory`,children:`Directory`}),(0,q.jsx)(`input`,{id:`new-trigger-directory`,className:`input`,value:r.directory,onChange:e=>i(t=>({...t,directory:e.target.value,directoryTouched:!0})),autoComplete:`off`,spellCheck:!1}),l.directory?(0,q.jsx)(`p`,{className:`field-error`,children:l.directory}):(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:[`Repo-relative folder for `,(0,q.jsxs)(`span`,{className:`mono`,children:[r.id.trim()||`id`,`.trigger.yaml`]}),`.`]})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-id`,children:`Id`}),(0,q.jsx)(`input`,{id:`new-trigger-id`,className:`input`,value:r.id,onChange:e=>i(t=>({...t,id:e.target.value})),autoComplete:`off`,spellCheck:!1}),l.id?(0,q.jsx)(`p`,{className:`field-error`,children:l.id}):null]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-kind`,children:`Kind`}),(0,q.jsxs)(`select`,{id:`new-trigger-kind`,className:`select`,value:r.kind,onChange:e=>i(t=>({...t,kind:e.target.value})),children:[(0,q.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,q.jsx)(`option`,{value:`schedule`,children:`Schedule`}),(0,q.jsx)(`option`,{value:`event`,children:`Event`})]})]}),r.kind===`schedule`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-cron`,children:`Cron expression`}),(0,q.jsx)(`input`,{id:`new-trigger-cron`,className:`input mono`,value:r.cron,onChange:e=>i(t=>({...t,cron:e.target.value})),placeholder:`0 * * * *`,autoComplete:`off`,spellCheck:!1}),l.cron?(0,q.jsx)(`p`,{className:`field-error`,children:l.cron}):(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:`Validated server-side against real cron syntax.`})]}),(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-timezone`,children:`Timezone (optional)`}),(0,q.jsx)(`input`,{id:`new-trigger-timezone`,className:`input`,value:r.timezone,onChange:e=>i(t=>({...t,timezone:e.target.value})),placeholder:`UTC`,autoComplete:`off`,spellCheck:!1})]})]}):null,r.kind===`event`?(0,q.jsxs)(`div`,{className:`form-field`,children:[(0,q.jsx)(`label`,{htmlFor:`new-trigger-source`,children:`Event source`}),(0,q.jsx)(`input`,{id:`new-trigger-source`,className:`input`,value:r.source,onChange:e=>i(t=>({...t,source:e.target.value})),autoComplete:`off`,spellCheck:!1}),l.source?(0,q.jsx)(`p`,{className:`field-error`,children:l.source}):(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:`No event adapter reads this yet; the trigger will not fire on its own until one lands.`}),(0,q.jsxs)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`,marginTop:`var(--spacing-1)`},children:[`Adapter-specific settings (a GitHub poller's `,(0,q.jsx)(`span`,{className:`mono`,children:`repo`}),`, a webhook's `,(0,q.jsx)(`span`,{className:`mono`,children:`secretRef`}),`/`,(0,q.jsx)(`span`,{className:`mono`,children:`header`}),`, an email adapter's `,(0,q.jsx)(`span`,{className:`mono`,children:`host`}),`/`,(0,q.jsx)(`span`,{className:`mono`,children:`port`}),`/`,(0,q.jsx)(`span`,{className:`mono`,children:`user`}),`/`,(0,q.jsx)(`span`,{className:`mono`,children:`secretRef`}),`) live in`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`event.config`}),`, which this console doesn't have a builder for yet — author it via YAML, HTTP, or MCP directly.`]})]}):null,(0,q.jsx)(`div`,{className:`form-field`,children:(0,q.jsxs)(`label`,{className:`pick__opt`,style:{display:`flex`,alignItems:`center`,gap:`var(--spacing-2)`},children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:r.enabled,onChange:e=>i(t=>({...t,enabled:e.target.checked}))}),(0,q.jsx)(`span`,{children:`Enabled`})]})}),(0,q.jsxs)(`div`,{className:`form-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:p,onClick:()=>void g(),children:p?`Creating…`:`Create trigger`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:_,children:`Cancel`})]})]})]})]})}function Vy(e){return e===`schedule`?`Schedule`:e===`event`?`Event`:`Manual`}function Hy(e){return e.kind===`schedule`&&e.schedule?e.schedule.timezone?`${e.schedule.cron} (${e.schedule.timezone})`:e.schedule.cron:e.kind===`event`&&e.event?`on ${e.event.source}`:`Fired manually only`}function Uy(e){return e?`Enabled`:`Disabled`}function Wy(e){return e??`Dynamic (task supplied at fire time)`}function Gy(e){return e??`Dynamic`}function Ky({triggerId:e}){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1),l=(0,v.useCallback)(async()=>{try{let e=await kn();n(e.triggers),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(!1)}},[]);(0,v.useEffect)(()=>{l()},[l]);async function u(e){c(!1),await l(),wy(`Trigger created · ${e.id}`)}return e?(0,q.jsx)(qy,{triggerId:e,onRefreshList:l}):(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Triggers`}),(0,q.jsx)(`p`,{children:`Manifest-declared triggers and what they fire. Schedule and event triggers run automatically; every trigger can also be fired by hand.`})]}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>c(!0),children:`New trigger`})]}),r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:r}):null,a?(0,q.jsx)(`p`,{className:`muted`,children:`Loading triggers…`}):null,!a&&t.length===0?(0,q.jsxs)(`div`,{className:`empty-hint`,children:[(0,q.jsxs)(`p`,{style:{margin:`0 0 var(--spacing-3)`},children:[`No triggers yet. Add a `,(0,q.jsx)(`span`,{className:`mono`,children:`*.trigger.yaml`}),` `,`file to this project's catalog.`]}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>c(!0),children:`New trigger`})]}):null,!a&&t.length>0?(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Trigger`}),(0,q.jsx)(`th`,{children:`Kind`}),(0,q.jsx)(`th`,{children:`Status`}),(0,q.jsx)(`th`,{children:`Last fired`}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:t.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsxs)(`td`,{children:[(0,q.jsx)(`a`,{href:`#${Yv(e.id)}`,children:e.id}),(0,q.jsxs)(`div`,{className:`muted`,style:{fontSize:`var(--font-size-xs)`},children:[e.pipeline,` · `,Gy(e.task)]})]}),(0,q.jsx)(`td`,{className:`mono`,children:Vy(e.kind)}),(0,q.jsx)(`td`,{children:(0,q.jsx)(`span`,{className:e.enabled?void 0:`muted`,children:Uy(e.enabled)})}),(0,q.jsx)(`td`,{className:`muted`,children:e.last_fired_at?ii(e.last_fired_at):`never`}),(0,q.jsx)(`td`,{style:{textAlign:`right`},children:(0,q.jsx)(`a`,{className:`btn btn--sm`,href:`#${Yv(e.id)}`,children:`Open`})})]},e.id))})]}):null,(0,q.jsx)(By,{isOpen:s,onClose:()=>c(!1),onCreated:e=>void u(e)})]})}function qy({triggerId:e,onRefreshList:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=(0,v.useCallback)(async()=>{try{let t=await An(e);r(t),s(null)}catch(e){s(e instanceof Error?e.message:String(e)),r(null)}finally{a(!1)}},[e]);(0,v.useEffect)(()=>{a(!0),u()},[u]);async function d(){l(!0);try{let n=await jn(e);wy(n.queued?`Trigger queued · ${e}`:`Trigger fired · ${e} · ${n.runId}`),await u(),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}let f=n?`${n.definition_ref} · ${Vy(n.kind)}`:e;return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/triggers`,children:`Triggers`}),` / `,e]}),(0,q.jsxs)(`div`,{className:`page-head`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e}),(0,q.jsx)(`p`,{className:`mono`,children:f})]}),n?(0,q.jsx)(`button`,{className:`btn btn--primary`,disabled:c,onClick:()=>void d(),children:c?`Firing…`:`Fire`}):null]}),o?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:o}):null,i?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!i&&!n?(0,q.jsxs)(`p`,{className:`muted`,children:[e,` is not in the current manifest catalog.`]}):null,n?(0,q.jsxs)(`dl`,{className:`kv`,children:[(0,q.jsx)(`dt`,{children:`Pipeline`}),(0,q.jsx)(`dd`,{children:n.pipeline}),(0,q.jsx)(`dt`,{children:`Task`}),(0,q.jsx)(`dd`,{className:n.task?void 0:`muted`,children:Wy(n.task)}),(0,q.jsx)(`dt`,{children:`Kind`}),(0,q.jsx)(`dd`,{children:Vy(n.kind)}),(0,q.jsx)(`dt`,{children:`Schedule`}),(0,q.jsx)(`dd`,{children:Hy(n)}),(0,q.jsx)(`dt`,{children:`Status`}),(0,q.jsx)(`dd`,{children:Uy(n.enabled)}),(0,q.jsx)(`dt`,{children:`Last fired`}),(0,q.jsx)(`dd`,{children:n.last_fired_at?ii(n.last_fired_at):`never`}),n.last_run_id?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Last run`}),(0,q.jsx)(`dd`,{children:(0,q.jsx)(`a`,{href:`#${Uv(n.last_run_id)}`,children:n.last_run_id})})]}):null,n.next_run_at?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Next run`}),(0,q.jsx)(`dd`,{className:`mono`,children:n.next_run_at})]}):null]}):null]})}function Jy({skillName:e}){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!0),s=(0,v.useCallback)(async()=>{try{let e=await In();n(e.skills),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}finally{o(!1)}},[]);(0,v.useEffect)(()=>{s()},[s]);let c=e?t.find(t=>t.name===e)??null:null;return e?(0,q.jsx)(Yy,{skillName:e,skill:c,loading:a,error:r}):(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Skills`}),(0,q.jsx)(`p`,{children:`Skills the Pi SDK can discover on this machine. Factory stages do not load them.`})]})}),r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:r}):null,a?(0,q.jsx)(`p`,{className:`muted`,children:`Loading skills…`}):null,!a&&t.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No skills found under ~/.pi/agent/skills, ~/.agents/skills, or this project's .pi/skills / .agents/skills.`}):null,!a&&t.length>0?(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Skill`}),(0,q.jsx)(`th`,{children:`Scope`}),(0,q.jsx)(`th`,{children:`Source`}),(0,q.jsx)(`th`,{children:`Invocation`})]})}),(0,q.jsx)(`tbody`,{children:t.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsxs)(`td`,{children:[(0,q.jsx)(`a`,{href:`#${Xv(e.name)}`,children:e.name}),(0,q.jsx)(`div`,{className:`muted`,style:{fontSize:`var(--font-size-xs)`},children:e.description})]}),(0,q.jsx)(`td`,{className:`mono`,children:e.scope}),(0,q.jsx)(`td`,{className:`mono`,children:e.source}),(0,q.jsx)(`td`,{className:`mono`,children:e.disableModelInvocation?`command-only`:`model`})]},`${e.scope}:${e.filePath}`))})]}):null]})}function Yy({skillName:e,skill:t,loading:n,error:r}){return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/skills`,children:`Skills`}),` / `,e]}),(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e}),(0,q.jsx)(`p`,{className:`mono`,children:t?`${t.scope} · ${t.source}`:e})]})}),r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:r}):null,n?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!n&&!t?(0,q.jsxs)(`p`,{className:`muted`,children:[e,` is not in the Pi skill catalog on this machine.`]}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{children:`Description`}),(0,q.jsx)(`p`,{children:t.description}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Invocation`}),(0,q.jsx)(`p`,{className:`mono`,children:t.disableModelInvocation?`command-only`:`model`}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`File path`}),(0,q.jsx)(`p`,{className:`mono`,children:t.filePath}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Base dir`}),(0,q.jsx)(`p`,{className:`mono`,children:t.baseDir})]}):null]})}function Xy({packageScope:e,packageSource:t,filePath:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!0),d=(0,v.useCallback)(async()=>{try{let e=await Ln();i(e.packages),o(e.extensions),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);if((0,v.useEffect)(()=>{d()},[d]),e&&t){let n=r.find(n=>n.scope===e&&n.source===t)??null;return(0,q.jsx)(Zy,{scope:e,source:t,pkg:n,loading:l,error:s})}if(n){let e=a.find(e=>e.path===n)??null;return(0,q.jsx)(Qy,{filePath:n,file:e,loading:l,error:s})}let f=!l&&r.length===0&&a.length===0;return(0,q.jsxs)(`div`,{className:`main__inner main__inner--wide`,children:[(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Extensions`}),(0,q.jsx)(`p`,{children:`Extensions the Pi SDK can discover on this machine. Factory stages do not load them.`})]})}),s?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:s}):null,l?(0,q.jsx)(`p`,{className:`muted`,children:`Loading extensions…`}):null,f?(0,q.jsx)(`p`,{className:`muted`,children:`No extensions found under ~/.pi/agent/extensions, this project's .pi/extensions, or packages in Pi settings.`}):null,!l&&r.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{children:`Packages`}),(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Source`}),(0,q.jsx)(`th`,{children:`Scope`}),(0,q.jsx)(`th`,{children:`Installed`})]})}),(0,q.jsx)(`tbody`,{children:r.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsx)(`a`,{href:`#${Zv(e.scope,e.source)}`,children:e.source})}),(0,q.jsx)(`td`,{className:`mono`,children:e.scope}),(0,q.jsx)(`td`,{className:`mono`,children:e.installedPath??`not installed`})]},`${e.scope}:${e.source}`))})]})]}):null,!l&&a.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{children:`Files`}),(0,q.jsxs)(`table`,{className:`table`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Name`}),(0,q.jsx)(`th`,{children:`Scope`}),(0,q.jsx)(`th`,{children:`Source`}),(0,q.jsx)(`th`,{children:`Origin`})]})}),(0,q.jsx)(`tbody`,{children:a.map(e=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsx)(`a`,{href:`#${Qv(e.path)}`,children:e.name})}),(0,q.jsx)(`td`,{className:`mono`,children:e.scope}),(0,q.jsx)(`td`,{className:`mono`,children:e.source}),(0,q.jsx)(`td`,{className:`mono`,children:e.origin})]},`${e.scope}:${e.path}`))})]})]}):null]})}function Zy({scope:e,source:t,pkg:n,loading:r,error:i}){return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/extensions`,children:`Extensions`}),` / `,t]}),(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:t}),(0,q.jsx)(`p`,{className:`mono`,children:n?`${n.scope} · package`:`${e} · package`})]})}),i?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:i}):null,r?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!r&&!n?(0,q.jsxs)(`p`,{className:`muted`,children:[t,` is not in the Pi package catalog on this machine.`]}):null,n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Scope`}),(0,q.jsx)(`p`,{className:`mono`,children:n.scope}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Source`}),(0,q.jsx)(`p`,{className:`mono`,children:n.source}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Filtered`}),(0,q.jsx)(`p`,{className:`mono`,children:n.filtered?`yes`:`no`}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Installed path`}),(0,q.jsx)(`p`,{className:`mono`,children:n.installedPath??`not installed`})]}):null]})}function Qy({filePath:e,file:t,loading:n,error:r}){let i=t?.name??e;return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsxs)(`p`,{className:`crumbs`,children:[(0,q.jsx)(`a`,{href:`#/extensions`,children:`Extensions`}),` / `,i]}),(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:i}),(0,q.jsx)(`p`,{className:`mono`,children:t?`${t.scope} · ${t.source}`:e})]})}),r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`},children:r}):null,n?(0,q.jsx)(`p`,{className:`muted`,children:`Loading…`}):null,!n&&!t?(0,q.jsx)(`p`,{className:`muted`,children:`This path is not in the Pi extension catalog on this machine.`}):null,t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Scope`}),(0,q.jsx)(`p`,{className:`mono`,children:t.scope}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Source`}),(0,q.jsx)(`p`,{className:`mono`,children:t.source}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Origin`}),(0,q.jsx)(`p`,{className:`mono`,children:t.origin}),(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`File path`}),(0,q.jsx)(`p`,{className:`mono`,children:t.path}),t.baseDir?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-sm)`},children:`Base dir`}),(0,q.jsx)(`p`,{className:`mono`,children:t.baseDir})]}):null]}):null]})}var $y=`sf-theme`;function eb(){try{let e=localStorage.getItem($y);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}function tb(e){try{localStorage.setItem($y,e)}catch{}}function nb({value:e,onChange:t}){return(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Appearance`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:`Applies immediately, on every screen.`}),(0,q.jsx)(`div`,{className:`theme-picks`,role:`radiogroup`,"aria-label":`Color theme`,children:[`system`,`light`,`dark`].map(n=>(0,q.jsxs)(`button`,{type:`button`,className:`theme-pick`,"data-theme":n,"aria-pressed":e===n?`true`:`false`,onClick:()=>{tb(n),t(n)},children:[(0,q.jsx)(`span`,{className:`theme-pick__swatch`,"data-preview":n}),(0,q.jsx)(`strong`,{children:n===`system`?`System`:n===`light`?`Light`:`Dark`}),(0,q.jsx)(`span`,{children:n===`system`?`Follows this machine`:`Astryx neutral`})]},n))})]})}var rb=`http://127.0.0.1:3847/mcp`;function ib(e,t={}){if(t.viteDev)return rb;let n=e.hostname;return n===`localhost`||n===`::1`||n===`[::1]`?n=`127.0.0.1`:n.includes(`:`)&&!n.startsWith(`[`)&&(n=`[${n}]`),`${`${e.protocol}//${n}${e.port?`:${e.port}`:``}`}/mcp`}function ab(e){return`${JSON.stringify({mcpServers:{stageflow:{url:e}}},null,2)}\n`}function ob(){let e=ib(window.location,{viteDev:!1}),t=ab(e),[n,r]=(0,v.useState)(()=>bn());return(0,v.useEffect)(()=>{xn(n)},[n]),(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Operator-host MCP`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:`This console process also serves Streamable HTTP MCP on the same origin. Cursor connects with a URL. There is no stdio command, and the endpoint dies when this process stops.`}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Endpoint`}),(0,q.jsxs)(`p`,{children:[`Same host as this console, path`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`/mcp`}),`. When the Host is bound off loopback, send`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`Authorization: Bearer`}),` with the control token below (drive scope).`]})]}),(0,q.jsx)(`span`,{className:`mono`,style:{wordBreak:`break-all`},children:e})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Control token`}),(0,q.jsxs)(`p`,{children:[`Stored in this browser only (`,(0,q.jsx)(`span`,{className:`mono`,children:`localStorage`}),`). Leave empty for local loopback Hosts that run without`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`STAGEFLOW_CONTROL_TOKEN`}),`.`]})]}),(0,q.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),placeholder:`STAGEFLOW_CONTROL_TOKEN`,style:{minWidth:`16rem`}})]}),(0,q.jsxs)(`ol`,{className:`steps`,children:[(0,q.jsx)(`li`,{children:(0,q.jsx)(`span`,{children:`Keep this operator console running. MCP is not a second server.`})}),(0,q.jsx)(`li`,{children:(0,q.jsxs)(`span`,{children:[`Open Cursor Settings → MCP, or add`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`.cursor/mcp.json`}),` in this project.`]})}),(0,q.jsx)(`li`,{children:(0,q.jsxs)(`span`,{children:[`Paste the snippet below. Use `,(0,q.jsx)(`span`,{className:`mono`,children:`url`}),`, not`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`command`}),`. Remote clients also need the bearer control token.`]})}),(0,q.jsx)(`li`,{children:(0,q.jsxs)(`span`,{children:[`Reload MCP in Cursor. Tools that should appear:`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`list_pipelines`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`start_run`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`get_run`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`get_health`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`list_runs`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`read_artifact`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`wait_run`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`answer_gate`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`decide_feedback_loop`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`describe_pipeline`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`validate`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`list_providers`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`list_models`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`list_project_mcp`}),`,`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`probe_project_mcp`}),`.`]})})]}),(0,q.jsx)(Uc,{code:t,language:`json`,title:`.cursor/mcp.json`,container:`section`,hasLanguageLabel:!1,width:`100%`}),(0,q.jsx)(`p`,{className:`muted`,style:{margin:`var(--spacing-4) 0 0`,fontSize:`var(--font-size-sm)`},children:`This URL is this console's origin plus /mcp. It must match the MCP endpoint line printed on boot.`}),(0,q.jsxs)(`p`,{className:`muted`,style:{margin:`var(--spacing-2) 0 0`,fontSize:`var(--font-size-sm)`},children:[`MCP can submit a waiting-stage answer (`,(0,q.jsx)(`span`,{className:`mono`,children:`answer_gate`}),`) and a feedback-loop decision (`,(0,q.jsx)(`span`,{className:`mono`,children:`decide_feedback_loop`}),`).`]})]})}var sb=`Servers from this project's git-root .mcp.json. Check tests whether a server can connect. It does not start a run and does not attach tools to stages. YAML mcp: still allowlists what a stage receives.`;function cb(e){switch(e){case`not-yet-probed`:return`Not yet probed`;case`probing`:return`Probing…`;case`connected`:return`Connected`;case`needs_auth`:return`Needs auth`;case`connect_failed`:return`Connect failed`;case`unresolved_var`:return`Unresolved variable`;case`invalid_config`:return`Invalid config`;case`missing_catalog`:return`Missing catalog`;case`cancelled`:return`Cancelled`}}function lb(e){switch(e){case`probing`:return`running`;case`connected`:return`succeeded`;case`needs_auth`:return`waiting`;case`connect_failed`:case`unresolved_var`:case`invalid_config`:case`missing_catalog`:return`failed`;case`not-yet-probed`:case`cancelled`:return}}function ub(e){return e===`missing_catalog`?`No git-root .mcp.json in this project.`:e===`invalid_config`?`Project .mcp.json is invalid.`:null}function db(e){let t={loading:!0,catalogStatus:null,servers:[],error:null},n=!1,r=new Map,i=new Set,a=()=>t,o=()=>{for(let e of i)e()},s=(e,n)=>{t={...t,servers:t.servers.map(t=>t.name===e?{...t,...n}:t)},o()};return{getState:a,load:async()=>{if(!n){t={loading:!0,catalogStatus:null,servers:[],error:null},o();try{let r=await e.list();if(n)return;if(r.status!==`ok`){t={loading:!1,catalogStatus:r.status,servers:[],error:null},o();return}t={loading:!1,catalogStatus:`ok`,servers:r.servers.map(e=>({name:e.name,transport:e.transport,status:`not-yet-probed`})),error:null},o()}catch(e){if(n)return;t={loading:!1,catalogStatus:null,servers:[],error:e instanceof Error?e.message:String(e)},o()}}},check:async t=>{if(n||r.has(t))return;let i=new AbortController;r.set(t,i),s(t,{status:`probing`,error:void 0});try{let r=await e.probe(t,{signal:i.signal});if(n)return;s(t,{status:r.status,error:r.error})}catch(e){if(n||i.signal.aborted)return;s(t,{status:`connect_failed`,error:e instanceof Error?e.message:String(e)})}finally{r.delete(t)}},dispose:()=>{n=!0;for(let e of r.values())e.abort();r.clear()},subscribe:e=>(i.add(e),()=>{i.delete(e)})}}function fb(){let e=(0,v.useRef)(null),[t,n]=(0,v.useState)({loading:!0,catalogStatus:null,servers:[],error:null});(0,v.useEffect)(()=>{let t=db({list:lr,probe:ur});e.current=t,n(t.getState());let r=t.subscribe(()=>n(t.getState()));return t.load(),()=>{r(),t.dispose(),e.current===t&&(e.current=null)}},[]);let r=t.catalogStatus?ub(t.catalogStatus):null;return(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Project MCP servers`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:sb}),t.error?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:t.error}):null,r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:r}):null,t.loading?(0,q.jsx)(`p`,{className:`muted`,children:`Loading project catalog…`}):t.catalogStatus===`ok`&&t.servers.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No servers in .mcp.json.`}):t.servers.map(t=>{let n=lb(t.status),r=t.status===`probing`;return(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:t.name}),(0,q.jsx)(`p`,{children:t.transport}),t.error?(0,q.jsx)(`p`,{children:t.error}):null]}),(0,q.jsxs)(`span`,{style:{display:`flex`,gap:`var(--spacing-2)`,alignItems:`center`},children:[(0,q.jsxs)(`span`,{className:`status`,children:[(0,q.jsx)(`span`,{className:`dot${n?` dot--${n}`:``}`}),` `,cb(t.status)]}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:r,onClick:()=>void e.current?.check(t.name),children:r?`Probing…`:`Check`})]})]},t.name)})]})}var pb=`Pi may complete login via a local callback in the Stageflow process. If the browser cannot reach this machine, paste the redirect URL or code when prompted.`,mb=`If automatic completion does not finish, paste the redirect URL or manual code below.`;function hb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type===`auth_url`)return n}}function gb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type===`device_code`)return n}}function _b(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type===`progress`||n?.type===`info`)return n.message}}function vb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.type===`info`&&n.links&&n.links.length>0)return n.links}}function yb(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function bb(e){return e.type===`select`?`select`:e.type===`secret`?`password`:`text`}function xb(e){return e.supportsOauth}var Sb=500;function Cb({providerId:e,providerName:t,onComplete:n,onDismiss:r}){let[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=(0,v.useRef)(!1),h=(0,v.useRef)(!1);(0,v.useEffect)(()=>{m.current||(m.current=!0,(async()=>{d(!0);let t=await Gn(e);if(d(!1),!t.ok){s(t.error);return}a(t.session)})())},[e]),(0,v.useEffect)(()=>{if(!i||yb(i))return;let t=window.setInterval(()=>{(async()=>{try{let{session:t}=await Kn(e,i.id);a(t)}catch(e){s(e instanceof Error?e.message:String(e))}})()},Sb);return()=>window.clearInterval(t)},[e,i?.id,i?.status]),(0,v.useEffect)(()=>{if(!(!i||!yb(i)||h.current)){if(h.current=!0,i.status===`completed`){n(i.provider,i.warning?.message);return}if(i.status===`failed`){s(i.error?.message??`OAuth login failed`);return}r()}},[i,n,r]);let g=i?.pendingPrompt;(0,v.useEffect)(()=>{g||(l(``),s(e=>e===`Enter a value to continue.`?null:e))},[g]);async function _(e,t){try{await navigator.clipboard.writeText(t),p(e),window.setTimeout(()=>p(null),1500)}catch{s(`Could not copy to clipboard`)}}async function y(){if(!i)return;let t=c.trim();if(!t){s(`Enter a value to continue.`);return}d(!0),s(null);let n=await qn(e,i.id,t);if(d(!1),!n.ok){s(n.error);return}l(``),a(n.session)}async function b(t){if(!i)return;d(!0),s(null);let n=await qn(e,i.id,t);if(d(!1),!n.ok){s(n.error);return}a(n.session)}async function x(){if(!i){r();return}d(!0),await Jn(e,i.id),d(!1),h.current=!0,r()}let S=i?hb(i.events):void 0,C=i?gb(i.events):void 0,w=i?_b(i.events):void 0,T=i?vb(i.events):void 0,E=g?bb(g):null;return(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`,marginTop:`var(--spacing-2)`},children:[(0,q.jsxs)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:[`Connecting `,t,` with Pi OAuth / subscription login.`]}),w?(0,q.jsx)(`p`,{className:`muted`,style:{margin:0},children:w}):null,T&&T.length>0?(0,q.jsx)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`,flexWrap:`wrap`},children:T.map(e=>(0,q.jsx)(`a`,{className:`btn btn--ghost`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??`Open link`},e.url))}):null,S?(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`},children:[S.instructions?(0,q.jsx)(`p`,{style:{margin:0,fontSize:`var(--font-size-sm)`},children:S.instructions}):null,(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`,flexWrap:`wrap`},children:[(0,q.jsx)(`a`,{className:`btn btn--primary`,href:S.url,target:`_blank`,rel:`noreferrer`,children:`Open browser`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:()=>void _(`url`,S.url),children:f===`url`?`Copied`:`Copy link`})]}),(0,q.jsxs)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:[pb,` `,mb]})]}):null,C?(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`},children:[(0,q.jsxs)(`p`,{style:{margin:0},children:[`Device code: `,(0,q.jsx)(`strong`,{children:C.userCode})]}),typeof C.expiresInSeconds==`number`?(0,q.jsxs)(`p`,{className:`muted`,style:{margin:0,fontSize:`var(--font-size-sm)`},children:[`Code expires in about `,C.expiresInSeconds,`s.`]}):null,(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`,flexWrap:`wrap`},children:[(0,q.jsx)(`a`,{className:`btn btn--primary`,href:C.verificationUri,target:`_blank`,rel:`noreferrer`,children:`Open verification page`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:()=>void _(`code`,C.userCode),children:f===`code`?`Copied`:`Copy code`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:()=>void _(`uri`,C.verificationUri),children:f===`uri`?`Copied`:`Copy URI`})]})]}):null,g&&E===`select`?(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`},children:[(0,q.jsx)(`p`,{style:{margin:0},children:g.message}),(g.options??[]).map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:u,onClick:()=>void b(e.id),children:[e.label,e.description?` — ${e.description}`:``]},e.id))]}):null,g&&E!==`select`?(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`},children:[(0,q.jsx)(`p`,{style:{margin:0},children:g.message}),g.type===`manual_code`?(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:mb}):null,(0,q.jsx)(`input`,{className:`input`,type:E===`password`?`password`:`text`,autoComplete:`off`,placeholder:g.placeholder??``,value:c,onChange:e=>l(e.target.value)}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:u,onClick:()=>void y(),children:u?`Sending…`:`Continue`})]}):null,o?(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`},children:o}):null,(0,q.jsx)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`},children:(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:u,onClick:()=>void x(),children:`Cancel`})})]})}function wb({provider:e,status:t,connecting:n,oauthing:r,apiKeyDraft:i,rowBusy:a,showDisconnect:o,onSetConnecting:s,onSetOauthing:c,onApiKeyChange:l,onConnectSubmit:u,onDisconnect:d,onOauthComplete:f,onOauthDismiss:p}){let m=t?.configured===!0,h=tv(e),g=xb(e),_=nv(e);return(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:e.name}),(0,q.jsx)(`p`,{children:rv(t)}),n?(0,q.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--spacing-2)`,marginTop:`var(--spacing-2)`},children:[(0,q.jsx)(`input`,{className:`input`,type:`password`,autoComplete:`off`,placeholder:`API key`,value:i,onChange:e=>l(e.target.value)}),(0,q.jsxs)(`div`,{style:{display:`flex`,gap:`var(--spacing-2)`},children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:a,onClick:()=>u(e.id),children:a?`Saving…`:`Save key`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:a,onClick:()=>{s(null),l(``)},children:`Cancel`})]})]}):null,r?(0,q.jsx)(Cb,{providerId:e.id,providerName:e.name,onComplete:f,onDismiss:p}):null]}),(0,q.jsxs)(`span`,{style:{display:`flex`,gap:`var(--spacing-2)`},children:[m&&o?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:a||r,onClick:()=>d(e.id),children:`Disconnect`}):null,m&&!o?(0,q.jsx)(`span`,{className:`muted`,children:`Connected`}):null,h&&!m&&!r?(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:a,onClick:()=>{s(e.id),c(null),l(``)},children:`Connect`}):null,g&&!m&&!n&&!r?(0,q.jsx)(`button`,{type:`button`,className:_?`btn btn--primary`:`btn btn--ghost`,disabled:a,onClick:()=>{c(e.id),s(null),l(``)},children:`Connect with OAuth`}):null]})]},e.id)}function Tb(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)({}),[i,a]=(0,v.useState)(void 0),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[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)(null),T=(0,v.useCallback)(async()=>{l(null);let[e,n]=await Promise.all([Bn(),Vn()]);t(e.providers),a(n.credentialSource);let i={};await Promise.all(e.providers.map(async e=>{try{let{provider:t}=await Hn(e.id);i[e.id]=t}catch{i[e.id]=void 0}})),r(i)},[]);(0,v.useEffect)(()=>{(async()=>{s(!0);try{await T()}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}})()},[T]);async function E(e){if(e===`pi_home`||e===`sf_owned`){d(!0),l(null);try{let t=await Xn(e);a(t.credentialSource),await T()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}}}async function D(e){let t=g.trim();if(!t){S(`Paste an API key to connect.`);return}b(e),S(null);let n=await Un(e,t);if(b(null),!n.ok){S(n.error);return}_(``),p(null),r(t=>({...t,[e]:n.provider}))}async function O(e){b(e),S(null);let t=await Wn(e);if(b(null),!t.ok){S(t.error);return}r(n=>({...n,[e]:t.provider}))}return(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Providers`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:Q_}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Credential source`}),(0,q.jsx)(`p`,{children:`Use credentials already stored by Pi, or keep a Stageflow-owned store for keys you paste here.`})]}),o?(0,q.jsx)(`span`,{className:`muted`,children:`—`}):(0,q.jsxs)(`select`,{className:`select`,value:i??``,disabled:u,onChange:e=>void E(e.target.value),children:[(0,q.jsx)(`option`,{value:``,disabled:!0,children:`Not set`}),(0,q.jsx)(`option`,{value:`pi_home`,children:`Existing Pi login (~/.pi)`}),(0,q.jsx)(`option`,{value:`sf_owned`,children:`Stageflow-owned store`})]})]}),c?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:c}):null,x?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:x}):null,C?(0,q.jsx)(`p`,{style:{color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:C}):null,o?(0,q.jsx)(`p`,{className:`muted`,children:`Loading providers…`}):e.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No providers reported by Pi.`}):e.map(e=>(0,q.jsx)(wb,{provider:e,status:n[e.id],connecting:f===e.id,oauthing:m===e.id,apiKeyDraft:g,rowBusy:y===e.id,showDisconnect:!0,onSetConnecting:e=>{p(e),S(null)},onSetOauthing:e=>{h(e),S(null),w(null)},onApiKeyChange:_,onConnectSubmit:e=>void D(e),onDisconnect:e=>void O(e),onOauthComplete:(t,n)=>{h(null),w(n??null),t?r(n=>({...n,[e.id]:t})):T()},onOauthDismiss:()=>{h(null),S(null)}},e.id))]})}var Eb=`sf-notify-waiting`;function Db(){try{let e=localStorage.getItem(Eb);if(e===`system`||e===`off`)return e}catch{}return`off`}function Ob(e){try{localStorage.setItem(Eb,e)}catch{}}function kb(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function Ab(){return typeof Notification>`u`?`unsupported`:Notification.permission==="default"?Notification.requestPermission():Notification.permission}function jb(e,t){let n=new Set(e.map(e=>e.run_id));if(t===null)return{emit:[],nextSeen:n};let r=[],i=new Set(t);for(let t of e)i.has(t.run_id)||(r.push(t),i.add(t.run_id));for(let e of[...i])n.has(e)||i.delete(e);return{emit:r,nextSeen:i}}function Mb(e){let{snapshot:t,loading:n}=Mr(),r=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(n)return;let{emit:i,nextSeen:a}=jb(Gr(t),r.current);if(r.current=a,e){for(let e of i)if(typeof Notification<`u`&&Notification.permission===`granted`){let t=[e.pipeline_id,e.waiting_summary].filter(e=>!!e);new Notification(`Stage waiting on you`,{body:t.join(` — `)})}}},[t,n,e])}var Nb=`cursor/auto`;function Pb(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:e<1073741824?`${(e/1048576).toFixed(1)} MiB`:`${(e/1073741824).toFixed(2)} GiB`}function Fb({themeMode:e,onThemeChange:t,notifyPreference:n,onNotifyChange:r}){let{snapshot:i,loading:a}=Mr(),o=Nr(),s=i.health,c=a&&s==null,l=!c&&s==null?`unavailable`:null,[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(kb),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,n]=await Promise.all([Yn(),Nn()]);if(e)return;_(t.workshopModel??``),b(n.models)}catch(t){if(e)return;S(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[]);async function T(e){let t=e===`system`?`system`:`off`;if(Ob(t),r(t),t===`system`&&kb()==="default"){let e=await Ab();h(e)}}async function E(e){let t=Number(e);p(!0),d(null);try{await zn(t),await o.refresh()}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}async function D(e){w(!0),S(null);try{let t=e.trim()||Nb,n=await Zn(t);_(n.workshopModel??t)}catch(e){S(e instanceof Error?e.message:String(e))}finally{w(!1)}}let O=[1,2,3,4,6],k=s?.maxConcurrent,A=k!=null&&!O.includes(k)?[k,...O]:O;return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Settings`}),(0,q.jsx)(`p`,{children:`Local to this machine. Nothing here is shared, because Stageflow runs as one operator's CLI.`})]})}),(0,q.jsx)(nb,{value:e,onChange:t}),(0,q.jsx)(Tb,{}),(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Workshop`})}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Workshop model`}),(0,q.jsx)(`p`,{children:`Default model for Workshop Author chat. Uses the same configured providers as stage runs — no separate credentials. Override per session in Workshop chrome.`})]}),(0,q.jsxs)(`select`,{className:`select`,value:g||Nb,disabled:C,onChange:e=>void D(e.target.value),children:[y.includes(g||Nb)?null:(0,q.jsx)(`option`,{value:g||Nb,children:g||Nb}),y.length===0?(0,q.jsx)(`option`,{value:Nb,children:Nb}):y.map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))]})]}),x?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:[`Could not update Workshop model: `,x]}):null]}),(0,q.jsx)(fb,{}),(0,q.jsx)(ob,{}),(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Concurrency`})}),l?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:[`Could not load capacity: `,l]}):null,(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Session slots`}),(0,q.jsx)(`p`,{children:`How many stage sessions may be alive at once. A stage waiting on you still holds its slot. Lowering the cap does not stop runs that are already in flight.`})]}),c?(0,q.jsx)(`span`,{className:`muted`,children:`—`}):s?(0,q.jsx)(`select`,{className:`select`,value:s.maxConcurrent,disabled:f,onChange:e=>void E(e.target.value),children:A.map(e=>(0,q.jsxs)(`option`,{value:e,children:[e,e===s.maxConcurrent?` · current`:``]},e))}):(0,q.jsx)(`span`,{className:`muted`,children:`—`})]}),u?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:[`Could not update slots: `,u]}):null,(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Slots available`}),(0,q.jsx)(`p`,{children:`Free slots that can accept a new run right now.`})]}),(0,q.jsx)(`span`,{className:`muted`,children:c?`—`:s?String(s.slotsAvailable):`—`})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`When slots are full`}),(0,q.jsxs)(`p`,{children:[`New starts enter the admission queue until`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`STAGEFLOW_MAX_QUEUED`}),` is full, then reject with `,(0,q.jsx)(`span`,{className:`mono`,children:`busy_capacity`}),`.`]})]}),(0,q.jsx)(`span`,{className:`muted`,children:`Queue, then busy_capacity`})]})]}),(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Disk`})}),l?(0,q.jsxs)(`p`,{style:{color:`var(--color-text-red)`,fontSize:`var(--font-size-sm)`,marginBottom:`var(--spacing-3)`},children:[`Could not load disk: `,l]}):null,c?(0,q.jsx)(`p`,{className:`muted`,children:`—`}):s?.disk?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Runs`}),(0,q.jsx)(`p`,{children:`Cached workspaces under the durable root.`})]}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.runs_bytes)})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{children:`Worktrees`})}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.worktrees_bytes)})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{children:`Repos caches`})}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.repos_bytes)})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{children:`State database`})}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.state_db_bytes)})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{children:`A2A artifacts`})}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.a2a_artifacts_bytes)})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`strong`,{children:`Free on volume`})}),(0,q.jsx)(`span`,{className:`muted`,children:Pb(s.disk.free_bytes)})]})]}):(0,q.jsx)(`p`,{className:`muted`,children:`Disk breakdown unavailable.`})]}),(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Held stages`})}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Hold timeout`}),(0,q.jsx)(`p`,{children:`A held stage waits until you answer. There is no timeout yet.`})]}),(0,q.jsx)(`span`,{className:`muted`,children:`—`})]}),(0,q.jsxs)(`div`,{className:`setting`,children:[(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:`Notify me when a stage asks`}),(0,q.jsx)(`p`,{children:`A held stage is invisible if this window is closed. A system notification is the only thing that reaches you.`})]}),(0,q.jsxs)(`select`,{className:`select`,value:n,onChange:e=>void T(e.target.value),children:[(0,q.jsx)(`option`,{value:`system`,children:`System notification`}),(0,q.jsx)(`option`,{value:`off`,children:`Nothing`})]})]}),n===`system`&&m===`denied`?(0,q.jsx)(`p`,{className:`muted`,style:{fontSize:`var(--font-size-xs)`,padding:`var(--spacing-2) 0`},children:`Notifications blocked — enable in browser settings`}):null]})]})}function Ib({onComplete:e}){let[t,n]=(0,v.useState)(!0),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(`sf_owned`),[d,f]=(0,v.useState)(`offer`),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)({}),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null);(0,v.useEffect)(()=>{(async()=>{n(!0),i(null);try{let e=await Vn();c(e.piHomeUsable);let t=ev(e.piHomeUsable);u(t),e.piHomeUsable?f(`offer`):(f(`keys`),await O())}catch(e){i(e instanceof Error?e.message:String(e))}finally{n(!1)}})()},[]);async function O(){let e=(await Bn()).providers.filter(e=>tv(e)||xb(e));g(e);let t={};await Promise.all(e.map(async e=>{try{let{provider:n}=await Hn(e.id);t[e.id]=n}catch{t[e.id]=void 0}})),y(t)}async function k(){m(!0),i(null);try{if(await Xn(l),l===`pi_home`){e();return}await O(),f(`keys`)}catch(e){i(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function A(e){let t=w.trim();if(!t){i(`Paste an API key to connect.`);return}D(e),i(null);try{await Xn(`sf_owned`)}catch(e){D(null),i(e instanceof Error?e.message:String(e));return}let n=await Un(e,t);if(D(null),!n.ok){i(n.error);return}T(``),x(null),y(t=>({...t,[e]:n.provider}))}let j=Object.values(_).some(e=>e?.configured);return(0,q.jsxs)(`div`,{className:`main__inner`,children:[(0,q.jsx)(`div`,{className:`page-head`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:`Connect providers`}),(0,q.jsx)(`p`,{children:Q_})]})}),t?(0,q.jsx)(`p`,{className:`muted`,children:`Checking for an existing Pi login…`}):null,r?(0,q.jsx)(`p`,{style:{color:`var(--color-text-red)`,marginBottom:`var(--spacing-4)`},children:r}):null,a?(0,q.jsx)(`p`,{style:{color:`var(--color-text-secondary)`,marginBottom:`var(--spacing-4)`},children:a}):null,!t&&d===`offer`?(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Credential source`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:s?`Usable Pi credentials were found on this machine. Reuse them, or set up keys inside Stageflow.`:`No usable Pi login was detected. Set up credentials in Stageflow.`}),(0,q.jsxs)(`div`,{className:`theme-picks`,role:`radiogroup`,"aria-label":`Credential source`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`theme-pick`,"aria-pressed":l===`pi_home`?`true`:`false`,disabled:!s,onClick:()=>u(`pi_home`),children:[(0,q.jsx)(`strong`,{children:`Use existing Pi login`}),(0,q.jsx)(`span`,{children:`Reuse ~/.pi credentials without re-entering keys`})]}),(0,q.jsxs)(`button`,{type:`button`,className:`theme-pick`,"aria-pressed":l===`sf_owned`?`true`:`false`,onClick:()=>u(`sf_owned`),children:[(0,q.jsx)(`strong`,{children:`Set up in Stageflow`}),(0,q.jsx)(`span`,{children:`Paste API keys or complete Pi OAuth in an SF-owned store`})]})]}),(0,q.jsx)(`div`,{className:`form-actions`,style:{marginTop:`var(--spacing-4)`},children:(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:p||!s&&l===`pi_home`,onClick:()=>void k(),children:p?`Saving…`:`Continue`})})]}):null,!t&&d===`keys`?(0,q.jsxs)(`section`,{className:`card`,children:[(0,q.jsx)(`div`,{className:`card__head`,children:(0,q.jsx)(`h2`,{children:`Providers`})}),(0,q.jsx)(`p`,{style:{margin:0,color:`var(--color-text-secondary)`,fontSize:`var(--font-size-sm)`},children:`Connect at least one provider with an API key or Pi OAuth / subscription login.`}),h.length===0?(0,q.jsx)(`p`,{className:`muted`,children:`No connectable providers are available from Pi right now.`}):h.map(e=>(0,q.jsx)(wb,{provider:e,status:_[e.id],connecting:b===e.id,oauthing:S===e.id,apiKeyDraft:w,rowBusy:E===e.id,showDisconnect:!1,onSetConnecting:x,onSetOauthing:C,onApiKeyChange:T,onConnectSubmit:e=>void A(e),onDisconnect:()=>void 0,onOauthComplete:(t,n)=>{C(null),o(n??null),t?y(n=>({...n,[e.id]:t})):O()},onOauthDismiss:()=>C(null)},e.id)),(0,q.jsxs)(`div`,{className:`form-actions`,style:{marginTop:`var(--spacing-4)`},children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:!j,onClick:e,children:`Continue to console`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,onClick:e,children:`Skip for now`})]})]}):null]})}var Lb=null;function Rb(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=Lb;Lb=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{Lb=n}}function zb(){if(!Lb)throw Error(`No resource fiber available`);return Lb}function Bb(){return Lb}var Vb=typeof process<`u`&&!1,Hb=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),Ub=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},Wb=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(Vb)throw Error(`tap: committed history is shorter than the replay base.`);break}Jb(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;qb(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)Gb(e.changelog[t]);Ub(e)}}},Gb=e=>{Jb(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},Kb=(e,t)=>{e.wipCommitCallbacks.push(t)},qb=(e,t)=>{e.rollbackCallbacks.push(t)},Jb=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),qb(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},Yb=Symbol.for(`react.memo_cache_sentinel`),Xb=e=>Array(e).fill(Yb),Zb=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,qb(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=Xb(t),r[i]=a):Vb&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},Qb=e=>Zb(zb(),e),$b=v.default.__COMPILER_RUNTIME?.c??(e=>(0,v.useMemo)(()=>{let t=Xb(e);return t[Yb]=!0,t},[])),ex=()=>Bb()!==null,$=e=>ex()?Qb(e):$b(e),tx=(e,...t)=>Object.assign(Object.create(null),e,...t),nx=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},rx=()=>{throw Error(`Hook order changed between renders`)},ix=e=>({type:e,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function ax(e,t,n){let r=zb(),i=r.currentIndex++,a=r.cells[i],o=a===void 0?ix(n):a.type===n?a:rx();if(a===void 0&&(r.isFirstRender||nx(),r.cells[i]=o,n===`insertion`?(r.insertionCells??=[]).push(o):r.effectCells.push(o)),o.deps!==null&&!!t!=!!o.deps)throw Error(`useEffect called with and without dependencies across re-renders`);Kb(r,()=>{o.setup=e,o.setupDeps=t,o.generation++})}function ox(e,t){ax(e,t,`effect`)}var sx=(e,t)=>{Vb&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
|
|
122
|
+
|
|
123
|
+
Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},cx=(e,t)=>{Kb(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},lx=(e,t)=>{let n=zb(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||nx();let a=e();return Vb&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&rx();let a=i;if(sx(a.wipDeps,t))return a.isDirty&&cx(n,a),a.wip;let o=e();return Vb&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,qb(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),cx(n,a),o};function ux(e){return lx(()=>({current:e}),[])}var dx=Symbol(`tap.Context.defaultValue`),fx=e=>e,px=new Map,mx=new Set,hx=()=>new Map(px),gx=(e,t)=>{let n=px;px=e;try{return t()}finally{px=n}},_x=(e,t)=>{e[dx]=t},vx=e=>typeof e==`object`&&!!e&&dx in e,yx=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),bx=e=>vx(e)||yx(e),xx=e=>{if(!vx(e)){if(yx(e)){_x(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},Sx=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);xx(e);let r=e,i=zb(),a=ux(void 0),o=a.current===void 0||!Object.is(a.current.value,t);ox(()=>{a.current={value:t}},[t]);let s=px.get(r),c=s!==void 0||px.has(r);px.set(r,{value:t,source:i});try{return Cx(r,o,n)}finally{c?px.set(r,s):px.delete(r)}},Cx=(e,t,n)=>{let r=mx.has(e);t?mx.add(e):mx.delete(e);try{return n()}finally{r?mx.add(e):mx.delete(e)}},wx=e=>{xx(e);let t=e,n=Tx(t,e),r=zb();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},Tx=(e,t)=>px.get(e)??{value:fx(t)[dx],source:null},Ex=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},Dx=(e,t=e.wipContextDeps)=>{let n=Bb();!n||!t||(n.wipContextDeps=Ex(n,e,n.wipContextDeps,t))},Ox=()=>mx.size>0,kx=e=>{if(!e.contextDeps||!Ox())return!1;for(let t of mx.keys())if(e.contextDeps.has(t))return!0;return!1},Ax=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,Gb(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},jx=(e,t,n,r,i)=>{let a=r?r(n):n;Vb&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=Bb();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else Ax(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function Mx(e,t,n,r){let i=zb(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:rx();i.isFirstRender||nx();let s=jx(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,Vb&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):Vb&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(Jb(i,s),s.workInProgress=t)}return s.isDirty&&Kb(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function Nx(e,t,n){return Mx(e,t,n,!1)}var Px=(e,t)=>typeof t==`function`?t(e):t,Fx=e=>e===void 0?void 0:typeof e==`function`?e():e;function Ix(e){return Mx(Px,e,Fx,!0)}var Lx=(e,t)=>lx(()=>e,t);function Rx(e,t){ax(e,t,`insertion`)}function zx(e){let t=zb(),n=ux(e);return n.current!==e&&Kb(t,()=>{n.current=e}),Lx(((...e)=>{if(Vb&&Bb())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var Bx=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,Vx=()=>{},Hx=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(Vx,Vx):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},Ux=e=>Bx(e)?Hx(e):wx(e),Wx=!1,Gx=(e,t,n=t)=>{let r=zb().isNeverMounted,i=r?n():t();Vb&&!Wx&&(!r||n===t)&&(Object.is(i,t())||(Wx=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=Nx(e=>e+1,0),o=ux(0),s=zx(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return ox(()=>e(()=>{s()&&a()}),[e]),ox(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},Kx=(e,t)=>{},qx=0,Jx=()=>{let e=ux(null);return e.current??=`:tap${qx++}:`,e.current},Yx=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?ox(r):ox(r,[...n,e])},Xx=v.default;function Zx(e){let t=(0,v.useRef)(e);return(0,v.useInsertionEffect)(()=>{t.current=e}),(0,v.useCallback)(((...e)=>t.current(...e)),[])}var Qx=Xx.useEffectEvent??Zx,$x=()=>Bb()!==null,eS=v.default,tS=e=>$x()?Ix(e):eS.useState(e),nS=(e,t,n)=>$x()?Nx(e,t,n):eS.useReducer(e,t,n),rS=e=>$x()?ux(e):eS.useRef(e),iS=(e,t)=>$x()?lx(e,t):eS.useMemo(e,t),aS=(e,t)=>$x()?Lx(e,t):eS.useCallback(e,t),oS=(e,t)=>$x()?ox(e,t):eS.useEffect(e,t),sS=(e,t)=>$x()?ox(e,t):eS.useLayoutEffect(e,t),cS=e=>$x()?zx(e):Qx(e),lS=(e,t,n)=>$x()?Gx(e,t,n):eS.useSyncExternalStore(e,t,n),uS=(e,t)=>$x()?void 0:eS.useDebugValue(e,t),dS=(e,t)=>$x()?Rx(e,t):eS.useInsertionEffect(e,t),fS=()=>$x()?Jx():eS.useId(),pS=(e,t,n)=>$x()?Yx(e,t,n):eS.useImperativeHandle(e,t,n),mS=e=>eS.forwardRef(e),hS=(e,t)=>eS.memo(e,t),gS=eS.Fragment;eS.Children,eS.Suspense;var _S=e=>{let t=eS.createContext(e);return _x(t,e),t},vS=e=>$x()&&bx(e)?Ux(e):eS.use(e),yS=e=>$x()&&bx(e)?Ux(e):eS.useContext(e),bS=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},xS=50,SS={schedulers:new Set,isScheduled:!1},CS=null,wS=[],TS=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(CS&&(CS.get(this)??0)>=xS)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,SS.schedulers.add(this),OS()}runTask(){CS?.set(this,(CS.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},ES=[];new TS(()=>{let e=ES.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}bS(t,`Errors occurred while running scheduled tasks`)});var DS=e=>{if(CS!==null){wS.push(e);return}e()},OS=()=>{SS.isScheduled||(SS.isScheduled=!0,AS())},kS=()=>{let e=CS;CS=new Map;let t=[];try{for(let e of SS.schedulers)if(SS.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(CS=e,SS.schedulers.clear(),SS.isScheduled=!1,CS===null)for(;wS.length>0;)try{wS.shift()()}catch(e){t.push(e)}}bS(t,`Errors occurred during flushSync`)},AS=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),kS()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(kS,0)})(),jS=e=>{if(CS!==null)return Vb&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=SS;SS={schedulers:new Set,isScheduled:!0};try{let t=e();return kS(),t}finally{let e=SS.schedulers;if(SS=t,e.size>0){for(let t of e)SS.schedulers.add(t);OS()}}};function MS(e){if(e.length===0)return;let t;for(let n=0;n<e.length;n++)try{e[n]()}catch(e){(t??=[]).push(e)}t!==void 0&&bS(t,`Errors during commit`)}function NS(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var PS=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!sx(e.deps,e.setupDeps);function FS(e,t){let n;for(let t of e)PS(t)&&(n??=[]).push(t);if(n===void 0)return t;for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){(t??=[]).push(e)}finally{e.cleanup=void 0}for(let e of n)try{NS(e)}catch(e){(t??=[]).push(e)}return t}function IS(e,t=!0){let n;e.insertionCells!==null&&t&&(n=FS(e.insertionCells,n)),n=FS(e.effectCells,n),n!==void 0&&bS(n,`Errors during commit`)}function LS(e){let t;for(let n of e)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){(t??=[]).push(e)}finally{n.cleanup=void 0}t!==void 0&&bS(t,`Errors during cleanup`)}var RS={useState:Ix,useReducer:Nx,useRef:ux,useMemo:lx,useCallback:Lx,useEffect:ox,useLayoutEffect:ox,useInsertionEffect:Rx,useEffectEvent:zx,useContext:wx,use:Ux,useSyncExternalStore:Gx,useDebugValue:Kx,useId:Jx,useImperativeHandle:Yx,useMemoCache:Qb},zS=v.default,BS=zS.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??zS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,VS=BS==null?null:`H`in BS?{get current(){return BS.H},set current(e){BS.H=e}}:`ReactCurrentDispatcher`in BS?{get current(){return BS.ReactCurrentDispatcher.current},set current(e){BS.ReactCurrentDispatcher.current=e}}:null;function HS(e){if(!VS)return e();let t=VS.current;VS.current=RS;try{return e()}finally{VS.current=t}}function US(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],insertionCells:null,hostCells:null,contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isReleased:!1,isNeverMounted:!0}}function WS(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function GS(e,t,n){try{t?(e.isReleased=!0,e.insertionCells!==null&&LS(e.insertionCells)):e.isMounted&&(e.isMounted=!1,LS(e.effectCells))}catch(e){(n??=[]).push(e)}if(e.hostCells!==null){for(let r of e.hostCells)if(r.fiber!==null&&(n=GS(r.fiber,t,n)),r.fibers!==null)for(let{fiber:e}of r.fibers.values())n=GS(e,t,n)}return n}function KS(e,t=!0){let n;t&&(n=GS(e,!0,n)),n=GS(e,!1,n),n!==void 0&&bS(n,`Errors during cleanup`)}function qS(e){let t;for(let n of e)n.isReleased&&(t=GS(n,!0,t));for(let n of e)t=GS(n,!1,t);t!==void 0&&bS(t,`Errors during cleanup`)}function JS(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,Rb(e,()=>{r=HS(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw WS(e),t}return Dx(e),r}function YS(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=Vb&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,Ub(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),MS(t)),n&&(IS(e,t!==null),KS(e,!1),e.isMounted=!0),IS(e,!n&&t!==null)}var XS=()=>{let e=zb();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},ZS=()=>`child`,QS=()=>null,$S=()=>{if(!Vb)return QS;let e=rS(0);return tS(()=>e.current++),e.current===2?ZS:QS},eC=()=>Bb()?XS:$S(),tC=e=>{let t=zb(),n=t.currentIndex++,r=t.cells[n],i;if(r===void 0){t.isFirstRender||nx();let r=e instanceof Map;i={type:`host`,fiber:r?null:e,fibers:r?e:null},t.cells[n]=i,(t.hostCells??=[]).push(i)}else r.type!==`host`&&rx(),i=r;return i.fibers===null&&i.fiber!==e&&Kb(t,()=>{i.fiber=e}),i},nC=(e,t)=>{if(!(e instanceof Map))return t(e);for(let{fiber:n}of e.values())t(n)},rC=e=>{e.isReleased=!1},iC=e=>{e.isReleased=!0,e.isMounted||queueMicrotask(()=>{e.isReleased&&KS(e,!0)})},aC=e=>{dS(()=>(nC(e,rC),()=>nC(e,iC)),[e]),oS(()=>()=>{qS(e instanceof Map?Array.from(e.values(),({fiber:e})=>e):[e])},[e])},oC=e=>Bb()?tC(e):(aC(e),null),sC=()=>{let e=rS(0),t=e.current,n=zb();return{version:t,markDirty:iS(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},cC=()=>{let[e]=tS(()=>Hb((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(()=>e()&&t())})),[t,n]=nS((t,n)=>(Wb(e,t),t+ +!!n()),0),[,r]=tS(0);return Wb(e,t),{root:e,version:t,markDirty:void 0}},lC=()=>{let e=eC(),{root:t,version:n,markDirty:r}=Bb()?sC():cC();return{version:n,createFiber:aS((n,i,a)=>US(n,t,a?()=>{a(),r?.()}:r,e()),[])}},uC=e=>e(),dC=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}bS(t,`Errors occurred while notifying Tap root subscribers`)},fC=(e,t,n)=>{let r=new TS(()=>s.handleUpdate()),i=[],a=Hb((e,t)=>{i.length===0&&!e()||(i.push(t),r.markDirty())}),o=US(uC,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{Wb(a,a.committedVersion);for(let e of i)Vb&&o.devStrictMode&&e(),e();return Wb(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,DS(()=>dC(s.subscribers)))},finishFlush:(e,t,n)=>{Ub(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&YS(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{Vb&&o.devStrictMode&&gx(s.context,()=>JS(o,[s.committedRender])),t=gx(s.context,()=>JS(o,[s.committedRender]))}catch(e){if(Wb(a,a.committedVersion),Bx(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},pC=e=>{let[,t]=tS(0),n=eC(),r=rS(null),i=r.current??=fC(e,n(),t),a=hx(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=gx(a,()=>JS(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),oS(()=>(i.isMounted=!0,()=>{i.isMounted=!1}),[i]),oC(i.fiber),oS(()=>{if(c.processed){i.fiber.isMounted||(YS(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}YS(i.fiber),i.publish(c.value,c.version)}),iS(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])};function mC(e){return(...t)=>({hook:e,args:t})}function hC(e,t,n){return typeof t==`function`?(...n)=>hC(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var gC=(e,t)=>({fiber:e,key:t,currentDeps:null,current:null,wipDeps:null,wip:null});function _C(e){let{version:t,createFiber:n}=lC(),r=rS(null),i=r.current??=gC(n(e.hook,e.key),e.key),a=iS(()=>i.fiber.hook===e.hook&&i.key===e.key&&!i.fiber.isReleased?i.fiber:n(e.hook,e.key),[i,e.hook,e.key,n]);i.wipDeps=i.currentDeps,i.wip=i.current;let o=[a,t,e.args];(kx(a)||i.currentDeps===null||!sx(i.currentDeps,o))&&(i.wipDeps=o,i.wip={value:JS(a,e.args)});let s=i.wip,c=oC(a);return oS(()=>{if(i.currentDeps=i.wipDeps,i.current=i.wip,i.fiber=a,i.key=e.key,YS(a),c!==null)return()=>{c.fiber!==a&&KS(a,!0)}},[i,c,a,e.key,s]),s.value}var vC=(e,t,n)=>{let r=rS(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,oS(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&sx(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)},yC=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},bC=(e,t)=>!e.isDirty&&!kx(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&sx(e.committedDeps,t),xC=e=>{if(!Ox())return!1;for(let{fiber:t}of e.values())if(kx(t))return!0;return!1};function SC(e){let[t]=tS(()=>new Map),{version:n,createFiber:r}=lC(),i=xC(t),a=!1,o=vC(()=>{let n=new Set,i=[],o=0;for(let s=0;s<e.length;s++){let c=e[s],l=c.key;if(l===void 0)throw Error(`useResources did not provide a key for array at index ${s}`);if(n.has(l))throw Error(`Duplicate key ${l} in useResources`);n.add(l);let u=t.get(l);if(!u){let e=r(c.hook,c.key,()=>yC(t,l));u={fiber:e,next:{value:JS(e,c.args),deps:c.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},o++,t.set(l,u)}else if(u.fiber.hook!==c.hook){let e=r(c.hook,c.key,()=>yC(t,l)),n=JS(e,c.args);u.next={value:n,deps:c.deps,remount:e},a=!0}else if(bC(u,c.deps))typeof u.next==`object`&&WS(u.fiber),u.fiber.contextDeps&&Dx(u.fiber,u.fiber.contextDeps),u.next=`skip`;else{let e=JS(u.fiber,c.args);u.next={value:e,deps:c.deps}}i.push(typeof u.next==`object`?u.next.value:u.committedValue)}if(t.size>i.length-o)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`,a=!0);return i},[e,t,r,n],i);return oC(t),oS(()=>{if(a){let e=[];for(let[n,r]of t.entries()){let i=r.next;i===`delete`?(e.push(r.fiber),t.delete(n)):i!==`skip`&&i.remount&&(e.push(r.fiber),r.fiber=i.remount)}for(let t of e)t.isReleased=!0;qS(e)}for(let e of t.values()){let t=e.next;t===`skip`?!e.fiber.isNeverMounted&&!e.fiber.isMounted&&YS(e.fiber):t!==`delete`&&(YS(e.fiber),e.committedDeps=t.deps,e.committedValue=t.value,e.isDirty=!1,e.next=`skip`)}},[o,t,a]),o}var CC=e=>e(),wC=e=>{let{createFiber:t}=lC(),[n]=tS(()=>t(CC,void 0)),r=JS(n,[e]);oC(n);let i=!1,a=()=>{i&&n.isMounted||(i=!0,YS(n))};return oS(a),{value:r,effects:a}},TC=mC(()=>{let e=$(4),[t,n]=tS(EC),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=tx(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=tx(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function EC(){return{renderers:tx(),fallbacks:[]}}var DC=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},OC=e=>e,kC=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),AC=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!kC.has(e))return!1}},jC=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},MC=Symbol(`assistant-ui.store.clientId`),NC=Symbol(`assistant-ui.store.instanceTag`),PC=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===MC?RC(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===MC||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(!(typeof n==`symbol`||!(n in t())))return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},FC=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===MC)return n();let i=AC(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},IC=e=>e?.source!=null,LC=e=>e?.source===null,RC=e=>e[MC]??e,zC=e=>e[NC]??RC(e),BC=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,VC=e=>{let t=[];for(let n in e)BC(n)||t.push(n);return t},HC=class extends jC{#e;constructor(e){super(),this.#e=e}get(e,t){let n=AC(t,`OptionalAssistantClient`);if(n!==!1)return n;if(BC(t))return;let r=this.#e[t];return IC(r)?r:void 0}ownKeys(){return VC(this.#e)}has(e,t){return!BC(t)&&t in this.#e}},UC=e=>new Proxy({},new HC(e)),WC=()=>()=>{},GC=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,KC=class extends jC{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return WC;if(t===`optional`)return this.#r??=UC(this.#n());let n=AC(t,this.#e);return n===!1?FC(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},qC=((e,t)=>{let n=new Proxy({},new KC(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>GC),JC=()=>new Proxy({},{get(e,t){let n=AC(t,`AssistantClient`);return n===!1?FC(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),YC=_S(qC),XC=()=>{},ZC=new WeakMap,QC=e=>ZC.get(e)??XC,$C=(e,t)=>{ZC.set(e,t)},ew=()=>yS(YC),tw=(e,t)=>Sx(YC,e,t),nw=Symbol(`assistant-ui.transform-scopes`);function rw(e,t){let n=e;if(n[nw])throw Error(`transformScopes is already attached to this resource`);n[nw]=t}function iw(e){return e[nw]}var aw=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},ow=Symbol(`assistant-ui.store.clientIndex`),sw=e=>e[ow],cw=_S([]),lw=()=>vS(cw),uw=(e,t)=>{let n=$(3),r=lw(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Sx(cw,i,t)},dw=Symbol(`assistant-ui.store.getValue`),fw=e=>{let t=e[dw];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},pw=new Map;function mw(e){let t=pw.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[dw];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},pw.set(e,t)),t}var hw=class extends jC{boundFns;cachedReceiver;outputRef;tagRef;index;self;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===dw)return this.outputRef.current;if(t===ow)return this.index;if(t===MC)return this.self;if(t===NC)return this.tagRef.current;let r=AC(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=mw(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===dw||t===ow||t===MC||t===NC||t in this.outputRef.current}},gw=e=>{let t=rS(null),n=rS(null),r=iS(()=>({}),[e.hook,e.key]),i=lw().length,a=iS(()=>{let e=new hw(t,n,i),r=new Proxy({},e);return e.self=r,r},[i]),o=uw(a,function(){return _C(e)});return t.current||(t.current=o,n.current=r),oS(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},_w=mC(gw),vw=0,yw=0,bw=e=>{vw++,yw++;try{return e()}finally{yw--,vw++}},xw=e=>{let t,n=new Map,r=-1,i=t=>{if(yw===0)return fw(e[t]());if(r!==vw)n.clear(),r=vw;else if(n.has(t))return n.get(t);let i=fw(e[t]());return n.set(t,i),i};class a extends jC{get(t,n){let r=AC(n,`OptionalAssistantState`);if(r!==!1)return r;let a=n;if(!BC(a)&&IC(e[a]))return i(a)}ownKeys(){return VC(e)}has(t,n){return!BC(n)&&n in e}}class o extends jC{get(e,n){let r=AC(n,`AssistantState`);if(r!==!1)return r;if(n===`optional`)return t??=new Proxy({},new a);let o=n;if(!BC(o))return i(o)}ownKeys(){return[...VC(e),`optional`]}has(t,n){return n===`optional`||!BC(n)&&n in e}}return new Proxy({},new o)},Sw=new WeakMap,Cw=e=>{let t=Sw.get(e);return t||(t=xw(e),Sw.set(e,t)),t},ww=_S(null),Tw=Symbol(`aui.scope-effect-unapplied`),Ew=(e,t)=>Sx(ww,e,t),Dw=()=>{let e=vS(ww);if(!e)throw Error(`AssistantTapContext is not available`);return e},Ow=()=>Dw().clientRef,kw=(e,t,n)=>{let r=$(8),{clientRef:i}=Dw(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&IC(t)?zC(t):void 0},a=Tw,o,s=e=>{if(o?.(),o=void 0,a=Tw,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],oS(a,o)},Aw=()=>{let e=$(3),{emit:t}=Dw(),n=lw(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],cS(r)},jw=_S(void 0),Mw=(e,t)=>{let n=vS(jw);return Sx(jw,e??n,t)},Nw=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},Pw=Symbol(`assistant-ui.derived-hook`),Fw=e=>{e[Pw]=!0},Iw=e=>e[Pw]===!0,Lw=e=>{console.error(`NotificationManager: event listener error`,e)},Rw=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(Lw)}catch(e){Lw(e)}},zw=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){!e.has(n)&&t.size===0||queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)Rw(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)Rw(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){bw(()=>{for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}})}}},Bw=()=>tS(zw)[0],Vw=()=>{let[e]=tS(()=>({controller:new AbortController,generation:0}));return dS(()=>{let t=++e.generation;return()=>queueMicrotask(()=>{e.generation===t&&e.controller.abort()})},[e]),e.controller.signal},Hw=e=>{let t=iS(()=>({}),[]);return t.v!==void 0&&Nw(t.v,e)?t.v:(t.v=e,e)},Uw=(()=>{try{return!1}catch{return!1}})(),Ww=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=iw(e.hook);if(a){a(n,t),i=!0;break}}}return n},Gw=e=>Iw(e.hook),Kw=e=>{if(!Gw(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},qw=Symbol.for(`aui.event-receiver-ref`),Jw=(e,t)=>{let n=e===qC?JC():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=UC(r),enumerable:!1}),r},Yw=({notifications:e,clientRef:t})=>iS(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=aw(n),o=n[qw];if(i!==`*`&&!o&&LC(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!IC(a))return;let s=RC(a);if(s===n[sw(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===qC)return s}else if(LC(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),Xw=e=>{let t=$(5),n;t[0]===e?n=t[1]:(n=Kw(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=Hw(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],Hw(o)},Zw=(e,t)=>{let n=$(3),r;return n[0]!==t||n[1]!==e?(r=t?e:_w(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],_C(r)},Qw=mC((e,t)=>{let n=ew(),r=Gw(t),i=Zw(t,r),a=r?i:i.methods,o=Xw(t),s=iS(()=>PC({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),$w=e=>{let t=$(2),n;return t[0]===e?n=t[1]:(n=e.map(uT),t[0]=e,t[1]=n),SC(n)},eT=(e,t)=>{let n=Hw(t),r=iS(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},tT=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=Jw(e,Yw({notifications:r,clientRef:n}));return{client:eT(i,[e,...Ew(iS(()=>({clientRef:n,emit:r.emit}),[n,r.emit]),function(){return tw(i,function(){return $w(t)})})])}},nT=({parent:e,entries:t,destroySignal:n})=>{let r=rS({parent:e,current:null}).current,{value:i,effects:a}=wC(function(){let i=Bw(),{client:a}=Mw(n,function(){return tT({parent:e,entries:t,clientRef:r,notifications:i})});return oS(()=>e.subscribe(i.notifySubscribers),[e,i]),oS(()=>i.notifySubscribers()),a});return dS(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},rT=({parent:e,entries:t,destroySignal:n})=>{let r=rS({parent:e,current:null}).current,{value:i,effects:a}=wC(function(){let i=Bw(),a=pC(function(){return Mw(n,function(){return tT({parent:e,entries:t,clientRef:r,notifications:i})})}),o=lS(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return oS(()=>{let t=()=>jS(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return dS(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},iT=(e,t,n,r)=>{let{get:i}=r.args[0],a=lS(e.subscribe,()=>i(e),()=>i(e)),o=Xw(r),s=iS(()=>PC({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},aT=(e,t)=>{if(Uw){let[e]=tS(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!Gw(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=rS({parent:e,current:null}).current,r=Jw(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=aw(t);if(i===`*`)return e.on(t,r);let o=t[qw];if(!o&&LC(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[qw]:o??n},r)}}),i=eT(r,[e,...t.map(([t,n])=>iT(e,r,t,n))]);return dS(()=>{n.parent=e,n.current=i},[i,e,n]),i},oT=(e,t)=>{let n=$(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(Ww(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(dT),n[3]=i,n[4]=a);let[o]=tS(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},sT=(e,t,n,r)=>{let{entries:i,rooted:a}=oT(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:aT(e,i)}},cT=(e,t,n)=>sT(e,t,nT,n);function lT(e){let t=ew();if(e){let{client:n,effects:r}=sT(t,e,rT,Vw());return r&&$C(n,r),n}return t}function uT(e){let[t,n]=e;return hC(t,Qw(t,n))}function dT(e){let[,t]=e;return!Gw(t)}var fT=e=>{let t=$(6),n=lT(),r;t[0]===n?r=t[1]:(r=Cw(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=lS(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return uS(s),s},pT=e=>{let t=$(3),{get:n}=e,r=lT(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],fT(i)};Fw(pT);var mT=mC(pT),hT=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function gT(e){let t=$(12),n;t[0]===e?n=t[1]:(n=e.map(yT),t[0]=e,t[1]=n);let r=SC(n),i;t[2]===e?i=t[3]:(i=e.reduce(vT,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(_T),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function _T(e){return e.state}function vT(e,t,n){return e[hT(t)]=n,e}function yT(e){return hC(hT(e),_w(e),e.deps)}var bT=Symbol(`skip-update`),xT=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},ST=e=>{xT(e)},CT=(e,t)=>{try{e()}catch(e){console.error(`[assistant-ui] Subscription rollback cleanup threw`,e)}throw t},wT=(e,t)=>e===void 0||t===void 0?e===t:Nw(e,t),TT=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){xT(this._subscribers)}},ET=class extends TT{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},DT=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){DC(this._subscriptions,e,t);return}xT(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){this._subscriptions.add(e);try{this._updateConnection()}catch(t){throw this._subscriptions.delete(e),t}return()=>{this._subscriptions.delete(e),this._updateConnection()}}},OT=class extends DT{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===bT)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===bT||wT(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});try{return this._syncState(),e}catch(t){throw CT(e,t)}}},kT=class extends DT{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==bT&&(this._previousState===void 0||!wT(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},AT=class extends DT{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}},i;try{i=this.outerSubscribe(r)}catch(e){throw CT(()=>n?.(),e)}return()=>ST([()=>i(),()=>n?.()])}},jT=class extends DT{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t),this.config.notifyOnRebind&&t({})}},a;try{a=this.outerSubscribe(i)}catch(e){throw CT(()=>r?.(),e)}return()=>ST([()=>a(),()=>r?.()])}},MT=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},NT=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=tx();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=MT(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=MT({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=tx(),e.tools[i]=MT(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...t.config,...e.config}),t.callSettings&&(e.callSettings={...t.callSettings,...e.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...t.unstable_composerMetadata,...e.unstable_composerMetadata}),e},{})},PT=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return NT(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){xT(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},FT=(e,t)=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),IT=(e,t)=>{let[n]=tS(()=>({pending:void 0}));oS(()=>{let r=n.pending;n.pending=void 0;let i;return r!==void 0&&FT(r.deps,t)?i=r:(r?.cleanup?.(),i={deps:t,cleanup:e()}),()=>{n.pending=i,queueMicrotask(()=>{n.pending===i&&(n.pending=void 0,i.cleanup?.())})}},t)},LT=[],RT={modelName:void 0,toolNames:LT},zT=(e,t)=>e===t||Nw(e,t),BT=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():LT,a=i.length?i:LT;return r===t.modelName&&zT(a,t.toolNames)?t:{modelName:r,toolNames:a}},VT=mC(()=>{let e=$(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new PT,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>BT(n,RT),e[1]=r):r=e[1];let[i,a]=tS(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>BT(n,e)),n.subscribe(()=>{a(e=>BT(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),oS(o,s);let c;e[4]===i?c=e[5]:(c=()=>BT(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),HT=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},UT=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,WT=e=>function(t){return HT(e,t)},GT=e=>{let t=$(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[hC(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=SC(i)[0],[o,s]=tS(qT),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=Ow(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=tx(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=tx(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?WT(i):void 0);a&&e.push(f(t,a,{standalone:UT(r),renderText:i}))}return()=>ST(e)},m=[n,f],t[6]=n,t[7]=p,t[8]=m),oS(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(JT,tx());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),kw(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},KT=mC(GT);rw(GT,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=VT())});function qT(){return tx()}function JT(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var YT=e=>lS(e.subscribe,e.getState,e.getServerSnapshot),XT=Symbol.for(`assistant-ui.silent-runtime-action`),ZT=e=>typeof e==`object`&&!!e&&XT in e,QT=(e,t)=>{let n=t();return n.catch(t=>{ZT(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},$T=mC(e=>{let t=$(9),{runtime:n}=e,r=YT(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>QT(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),eE=mC(e=>{let t=$(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=$T({runtime:a}),t[3]=a,t[4]=o),_C(o)}),tE=mC(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),nE=mC(e=>{let t=$(65),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=YT(i),s=Aw(),c=rS(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>ST(e)},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),oS(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>hC(e.id,eE({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=gT(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>hC(e.id,tE({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=gT(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.inTransit||t[23]!==o.isEditing||t[24]!==o.isEmpty||t[25]!==o.quote||t[26]!==o.role||t[27]!==o.runConfig||t[28]!==o.submission||t[29]!==o.text||t[30]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p,submission:o.submission,inTransit:o.inTransit},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.inTransit,t[23]=o.isEditing,t[24]=o.isEmpty,t[25]=o.quote,t[26]=o.role,t[27]=o.runConfig,t[28]=o.submission,t[29]=o.text,t[30]=g,t[31]=_):_=t[31];let v=_,y;t[32]===v?y=t[33]:(y=()=>v,t[32]=v,t[33]=y);let b;t[34]!==a||t[35]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[34]=a,t[35]=i,t[36]=b):b=t[36];let x;t[37]!==s||t[38]!==r||t[39]!==i||t[40]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[37]=s,t[38]=r,t[39]=i,t[40]=n,t[41]=x):x=t[41];let S=i.beginEdit??rE,C;t[42]===f?C=t[43]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[42]=f,t[43]=C);let w;t[44]===h?w=t[45]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[44]=h,t[45]=w);let T;t[46]===i?T=t[47]:(T=()=>i,t[46]=i,t[47]=T);let E;return t[48]!==i.addAttachment||t[49]!==i.clearAttachments||t[50]!==i.reset||t[51]!==i.setQuote||t[52]!==i.setRole||t[53]!==i.setRunConfig||t[54]!==i.setText||t[55]!==i.startDictation||t[56]!==i.stopDictation||t[57]!==S||t[58]!==C||t[59]!==w||t[60]!==T||t[61]!==y||t[62]!==b||t[63]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[48]=i.addAttachment,t[49]=i.clearAttachments,t[50]=i.reset,t[51]=i.setQuote,t[52]=i.setRole,t[53]=i.setRunConfig,t[54]=i.setText,t[55]=i.startDictation,t[56]=i.stopDictation,t[57]=S,t[58]=C,t[59]=w,t[60]=T,t[61]=y,t[62]=b,t[63]=x,t[64]=E):E=t[64],E});function rE(){throw Error(`beginEdit is not supported in this runtime`)}var iE=e=>({get current(){return e()}}),aE=mC(e=>{let t=$(17),{runtime:n}=e,r=YT(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s;t[2]===n?(a=t[3],o=t[4],s=t[5]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),t[2]=n,t[3]=a,t[4]=o,t[5]=s);let c;t[6]===n.unstable_recordInteraction?c=t[7]:(c=n.unstable_recordInteraction&&{unstable_recordInteraction:e=>n.unstable_recordInteraction(e)},t[6]=n.unstable_recordInteraction,t[7]=c);let l;t[8]===n?l=t[9]:(l=()=>n,t[8]=n,t[9]=l);let u;return t[10]!==i||t[11]!==a||t[12]!==o||t[13]!==s||t[14]!==c||t[15]!==l?(u={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,...c,__internal_getRuntime:l},t[10]=i,t[11]=a,t[12]=o,t[13]=s,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}),oE=mC(e=>{let t=$(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=$T({runtime:a}),t[3]=a,t[4]=o),_C(o)}),sE=mC(e=>{let t=$(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=aE({runtime:a}),t[3]=a,t[4]=o),_C(o)}),cE=mC(e=>{let t=$(77),{runtime:n,threadIdRef:r,threadId:i,isLast:a}=e,o=YT(n),s=Aw(),[c,l]=tS(!1),[u,d]=tS(!1),f;t[0]===n?f=t[1]:(f=iE(()=>n.getState().id),t[0]=n,t[1]=f);let p=f,m=rS(o.status),h;t[2]!==s||t[3]!==n||t[4]!==i?(h=e=>{s(e,{threadId:i,messageId:n.getState().id})},t[2]=s,t[3]=n,t[4]=i,t[5]=h):h=t[5];let g=h,_,v;t[6]!==s||t[7]!==o.id||t[8]!==o.status||t[9]!==i?(_=()=>{let e=o.status,t=m.current;m.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&s(`message.error`,{threadId:i,messageId:o.id,reason:`error`})},v=[o.status,o.id,s,i],t[6]=s,t[7]=o.id,t[8]=o.status,t[9]=i,t[10]=_,t[11]=v):(_=t[10],v=t[11]),oS(_,v);let y;t[12]!==p||t[13]!==n.composer||t[14]!==r?(y=nE({runtime:n.composer,threadIdRef:r,messageIdRef:p}),t[12]=p,t[13]=n.composer,t[14]=r,t[15]=y):y=t[15];let b=gw(y),x;if(t[16]!==n||t[17]!==o.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>hC(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,sE({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),x=o.content.map(e),t[16]=n,t[17]=o.content,t[18]=x}else x=t[18];let S=gT(x),C;t[21]===o.attachments?C=t[22]:(C=o.attachments??[],t[21]=o.attachments,t[22]=C);let w;if(t[23]!==n||t[24]!==C){let e;t[26]===n?e=t[27]:(e=(e,t)=>hC(e.id,oE({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),w=C.map(e),t[23]=n,t[24]=C,t[25]=w}else w=t[25];let T=gT(w),E=o,D;t[28]===a?D=t[29]:(D=a===!1?{isLast:a}:{},t[28]=a,t[29]=D);let O;t[30]!==b.state||t[31]!==c||t[32]!==u||t[33]!==S.state||t[34]!==D||t[35]!==E?(O={...E,...D,parts:S.state,composer:b.state,isCopied:c,isHovering:u},t[30]=b.state,t[31]=c,t[32]=u,t[33]=S.state,t[34]=D,t[35]=E,t[36]=O):O=t[36];let k=O,A;t[37]===k?A=t[38]:(A=()=>k,t[37]=k,t[38]=A);let j;t[39]===b.methods?j=t[40]:(j=()=>b.methods,t[39]=b.methods,t[40]=j);let M;t[41]===n?M=t[42]:(M=()=>n.delete(),t[41]=n,t[42]=M);let N,P;t[43]!==g||t[44]!==n?(N=e=>(g(`message.reload`),n.reload(e)),P=()=>(g(`message.speak`),n.speak()),t[43]=g,t[44]=n,t[45]=N,t[46]=P):(N=t[45],P=t[46]);let F,I;t[47]===n?(F=t[48],I=t[49]):(F=()=>n.stopSpeaking(),I=e=>n.submitFeedback(e),t[47]=n,t[48]=F,t[49]=I);let L;t[50]!==g||t[51]!==n?(L=e=>(g(`message.branchSwitched`),n.switchToBranch(e)),t[50]=g,t[51]=n,t[52]=L):L=t[52];let R;t[53]===n?R=t[54]:(R=()=>n.unstable_getCopyText(),t[53]=n,t[54]=R);let z;t[55]===S?z=t[56]:(z=e=>`index`in e?S.get({index:e.index}):S.get({key:`toolCallId-${e.toolCallId}`}),t[55]=S,t[56]=z);let B;t[57]===T?B=t[58]:(B=e=>`id`in e?T.get({key:e.id}):T.get(e),t[57]=T,t[58]=B);let V;t[59]===g?V=t[60]:(V=e=>{e&&g(`message.copied`),l(e)},t[59]=g,t[60]=V);let H;t[61]===n?H=t[62]:(H=()=>n,t[61]=n,t[62]=H);let U;return t[63]!==A||t[64]!==j||t[65]!==M||t[66]!==N||t[67]!==P||t[68]!==F||t[69]!==I||t[70]!==L||t[71]!==R||t[72]!==z||t[73]!==B||t[74]!==V||t[75]!==H?(U={getState:A,composer:j,delete:M,reload:N,speak:P,stopSpeaking:F,submitFeedback:I,switchToBranch:L,getCopyText:R,part:z,attachment:B,setIsCopied:V,setIsHovering:d,__internal_getRuntime:H},t[63]=A,t[64]=j,t[65]=M,t[66]=N,t[67]=P,t[68]=F,t[69]=I,t[70]=L,t[71]=R,t[72]=z,t[73]=B,t[74]=V,t[75]=H,t[76]=U):U=t[76],U}),lE=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
124
|
+
|
|
125
|
+
`),uE=Object.freeze({type:`complete`}),dE=Object.freeze({type:`running`}),fE=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),pE=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return dE;if(n===`complete`)return uE;if(n!==`incomplete`)return;let{reason:r}=t;return fE[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},mE=e=>e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,hE=(e,t,n)=>{if(e.role!==`assistant`)return uE;if(n.type===`tool-call`)return n.result===void 0||n.isPreliminary||mE(n)?e.status:uE;if(e.status.type===`running`){let e=pE(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?uE:r?e.status:uE},gE=mC(e=>{let t=$(7),{type:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[1]=i):i=t[1];let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o={isEditing:!1,isEmpty:!0,text:``,attachmentAccept:`*`,attachments:r,role:`user`,runConfig:i,canCancel:!1,canSend:!1,type:n,dictation:void 0,quote:void 0,queue:a,submission:void 0,inTransit:void 0},t[3]=n,t[4]=o);let s=o,c;return t[5]===s?c=t[6]:(c={getState:()=>s,setText:_E,setRole:vE,setRunConfig:yE,addAttachment:bE,clearAttachments:xE,attachment:SE,reset:CE,send:wE,cancel:TE,startDictation:EE,stopDictation:DE,beginEdit:OE,setQuote:kE,queueItem:AE},t[5]=s,t[6]=c),c});function _E(){throw Error(`Not supported`)}function vE(){throw Error(`Not supported`)}function yE(){throw Error(`Not supported`)}function bE(){throw Error(`Not supported`)}function xE(){throw Error(`Not supported`)}function SE(){throw Error(`Not supported`)}function CE(){throw Error(`Not supported`)}function wE(){throw Error(`Not supported`)}function TE(){throw Error(`Not supported`)}function EE(){throw Error(`Not supported`)}function DE(){throw Error(`Not supported`)}function OE(){throw Error(`Not supported`)}function kE(){throw Error(`Not supported`)}function AE(){throw Error(`Not supported`)}var jE=mC(e=>{let t=$(8),{part:n,isMessageRunning:r}=e,i;t[0]!==r||t[1]!==n?(i=r?pE(n)??uE:uE,t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;t[3]!==n||t[4]!==i?(a={...n,status:i},t[3]=n,t[4]=i,t[5]=a):a=t[5];let o=a,s;return t[6]===o?s=t[7]:(s={getState:()=>o,addToolResult:PE,resumeToolCall:FE,respondToToolApproval:IE,unstable_recordInteraction:LE},t[6]=o,t[7]=s),s}),ME=mC(({attachment:e})=>({getState:()=>e,remove:()=>{throw Error(`Not supported`)}})),NE=mC(e=>{let t=$(38),{message:n,index:r,isLast:i,branchNumber:a,branchCount:o,submission:s}=e,c=i===void 0||i,l=a===void 0?1:a,u=o===void 0?1:o,[d,f]=tS(!1),[p,m]=tS(!1),h=n.role===`assistant`&&n.status.type===`running`,g;if(t[0]!==h||t[1]!==n.content){let e;t[3]===h?e=t[4]:(e=(e,t)=>hC(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,jE({part:e,isMessageRunning:h}),[e,h]),t[3]=h,t[4]=e),g=n.content.map(e),t[0]=h,t[1]=n.content,t[2]=g}else g=t[2];let _=gT(g),v;t[5]!==n.attachments||t[6]!==s?.attachments?(v=s?.attachments??n.attachments??[],t[5]=n.attachments,t[6]=s?.attachments,t[7]=v):v=t[7];let y;t[8]===v?y=t[9]:(y=v.map(RE),t[8]=v,t[9]=y);let b=gT(y),x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=gE({type:`edit`}),t[10]=x):x=t[10];let S=gw(x),C=S.state,w;t[11]!==u||t[12]!==l||t[13]!==C||t[14]!==r||t[15]!==d||t[16]!==p||t[17]!==c||t[18]!==n||t[19]!==_.state||t[20]!==s?(w={...n,parts:_.state,composer:C,parentId:null,index:r,isLast:c,branchNumber:l,branchCount:u,speech:void 0,isCopied:d,isHovering:p,submission:s},t[11]=u,t[12]=l,t[13]=C,t[14]=r,t[15]=d,t[16]=p,t[17]=c,t[18]=n,t[19]=_.state,t[20]=s,t[21]=w):w=t[21];let T=w,E;t[22]===T?E=t[23]:(E=()=>T,t[22]=T,t[23]=E);let D;t[24]===S.methods?D=t[25]:(D=()=>S.methods,t[24]=S.methods,t[25]=D);let O;t[26]===_?O=t[27]:(O=e=>`index`in e?_.get({index:e.index}):_.get({key:`toolCallId-${e.toolCallId}`}),t[26]=_,t[27]=O);let k;t[28]===b?k=t[29]:(k=e=>`id`in e?b.get({key:e.id}):b.get(e),t[28]=b,t[29]=k);let A;t[30]===n?A=t[31]:(A=()=>lE(n),t[30]=n,t[31]=A);let j;return t[32]!==D||t[33]!==O||t[34]!==k||t[35]!==A||t[36]!==E?(j={getState:E,composer:D,part:O,attachment:k,delete:zE,reload:BE,speak:VE,stopSpeaking:HE,submitFeedback:UE,switchToBranch:WE,getCopyText:A,setIsCopied:f,setIsHovering:m},t[32]=D,t[33]=O,t[34]=k,t[35]=A,t[36]=E,t[37]=j):j=t[37],j});function PE(){throw Error(`Not supported`)}function FE(){throw Error(`Not supported`)}function IE(){throw Error(`Not supported`)}async function LE(){}function RE(e){return hC(e.id,ME({attachment:e}),[e])}function zE(){throw Error(`Not supported in ThreadMessageProvider`)}function BE(){throw Error(`Not supported in ThreadMessageProvider`)}function VE(){throw Error(`Not supported in ThreadMessageProvider`)}function HE(){throw Error(`Not supported in ThreadMessageProvider`)}function UE(){throw Error(`Not supported in ThreadMessageProvider`)}function WE(){throw Error(`Not supported in ThreadMessageProvider`)}var GE=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function KE(e){let t=e.match(/^data:([^;,]*)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase()||`text/plain`,data:t[2]}:null}function qE(e){return/^data:([^;,]+)(?:[;,])/i.exec(e)?.[1]?.toLowerCase()}var JE={entries:32,payloadLength:16384,logLength:65536},YE=64,XE=e=>{let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ZE=(e,t,n)=>{if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:break;default:return!1}if(n>YE||t.has(e))return!1;t.add(e);let r=Array.isArray(e)?e.every(e=>ZE(e,t,n+1)):XE(e)&&Object.values(e).every(e=>ZE(e,t,n+1));return t.delete(e),r},QE=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$E=e=>e===`action`||e===`human-response`;function eD(e,t=Date.now()){let{type:n,payload:r}=e;if(!$E(n))throw Error(`Unknown tool interaction type: ${String(n)}`);if(!ZE(r,new Set,0))throw Error(`A tool interaction payload must be plain JSON.`);if(n===`action`&&!QE(r))throw Error(`An action interaction payload must be a JSON object.`);let i=JSON.stringify(r);if(i.length>JE.payloadLength)throw Error(`A tool interaction payload is limited to ${JE.payloadLength} characters of JSON.`);return{type:n,occurredAt:t,payload:JSON.parse(i)}}function tD(e,t){let n=[...e?.entries??[],t],r=e?.omitted??0;for(;n.length>1&&(n.length>JE.entries||JSON.stringify(n).length>JE.logLength);)n.shift(),r+=1;return r>0?{entries:n,omitted:r}:{entries:n}}var nD=e=>{if(!QE(e))return;let{type:t,occurredAt:n,payload:r}=e;if($E(t)&&!(typeof n!=`number`||!Number.isFinite(n))&&ZE(r,new Set,0))return t===`action`?QE(r)?{type:t,occurredAt:n,payload:r}:void 0:{type:t,occurredAt:n,payload:r}};function rD(e){if(!QE(e))return;let{entries:t,omitted:n}=e,r=Array.isArray(t)?t.flatMap(e=>{let t=nD(e);return t?[t]:[]}):[],i=typeof n==`number`&&Number.isInteger(n)&&n>0?n:0;for(;r.length>1&&(r.length>JE.entries||JSON.stringify(r).length>JE.logLength);)r.shift(),i+=1;if(r.length!==0||i!==0)return i>0?{entries:r,omitted:i}:{entries:r}}async function*iD(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function aD(e){return e[Symbol.asyncIterator]??=iD,e}var oD=/[0-9a-fA-F]/;function sD(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!oD.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var cD=l(o(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),lD=Symbol(`aui.parse-partial-json-object.meta`),uD=e=>{if(e.length===0)return{[lD]:{state:`partial`,partialPath:[]}};try{let t=cD.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[lD]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=sD(e),r=cD.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[lD]={state:`partial`,partialPath:n},r}catch{return}}},dD=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),fD=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},pD=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=fD(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},mD=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),hD=(e,t)=>{let n;return[mD({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},gD=e=>e instanceof TypeError,_D=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!gD(e))throw e;n?.(e)}},vD=e=>{try{e.close()}catch(e){if(!gD(e))throw e}},yD=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return _D(this._controller,t,this._warnDroppedAfterClose),this}return _D(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,_D(this._controller,{type:`part-finish`,path:[]}),vD(this._controller))}},bD=(e,t={})=>mD(e,e=>new yD(e,t)),xD=(e={})=>hD(t=>new yD(t,e)),SD=Symbol.for(`aui.tool-response`),CD=`<no result>`,wD=class e{get[SD](){return!0}artifact;result;isError;isPreliminary;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?CD:t,this.isError=e.isError??!1,e.isPreliminary&&(this.isPreliminary=!0),e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&SD in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?CD:t})}},TD=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=bD({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,_D(this._controller,e);break;case`part-finish`:r||_D(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),_D(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;_D(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?CD:t,isError:e.isError??!1,...e.isPreliminary?{isPreliminary:!0}:{},...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),e.isPreliminary?this._argsTextController.close():await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,_D(this._controller,{type:`part-finish`,path:[]}),vD(this._controller))}},ED=(e={})=>hD(t=>new TD(t,e)),DD=class{value=-1;up(){return++this.value}},OD=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var kD=class extends TransformStream{constructor(e){let t=new DD,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},AD=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:pD(),contentCounter:new DD}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new OD(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new kD(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=xD({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=xD({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??dD(),[i,a]=ED({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function jD(e,t={}){let n=new AD(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function MD(e={}){let{resolve:t,promise:n}=fD(),r;return[jD(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var ND=class extends TransformStream{constructor(e,t,n){let[r,i]=MD({strict:e.strict}),a=new AbortController,o;super({start(t){o=r.pipeTo(new WritableStream({write(e){t.enqueue(e)},abort(e){t.error(e)},close(){t.terminate()}}),{signal:a.signal}).catch(e=>{t.error(e)});try{return e.start?.(i)}catch(e){throw a.abort(e),e}},transform(t){return e.transform?.(t,i)},async flush(){await e.flush?.(i),i.close(),await o}},t,n);let s=super.readable.getReader(),c=!1;Object.defineProperty(this,"readable",{value:new ReadableStream({start(e){s.closed.catch(t=>{a.abort(t),e.error(t),s.releaseLock()})},async pull(e){let t=await s.read();c||(t.done?(e.close(),s.releaseLock()):e.enqueue(t.value))},async cancel(e){c=!0;let t=s.cancel(e);a.abort(e);try{await t}finally{await o,s.releaseLock()}}},{highWaterMark:0}),writable:!1})}},PD=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},FD=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?KE(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,unstable_interactions:r,...i}=e,a=rD(r),o={...i,toolCallId:e.toolCallId||`tool-${GE()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n},...a!==void 0&&{unstable_interactions:a}};return e.args?{...o,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...o,args:uD(e.argsText??``)??{},argsText:e.argsText??``}}case`audio`:throw Error(`Unsupported assistant message part type: ${t}`);default:{let n=t,r=PD(n,e.data);if(r)return r;throw Error(`Unsupported assistant message part type: ${n}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;case`reasoning`:case`source`:case`generative-ui`:case`tool-call`:throw Error(`Unsupported user message part type: ${t}`);default:{let n=t,r=PD(n,e.data);if(r)return r;throw Error(`Unsupported user message part type: ${n}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>PD(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},ID=e=>FD({role:e.role,content:e.role===`system`||e.text?[{type:`text`,text:e.text}]:[],attachments:[],metadata:{custom:{...e.quote?{quote:e.quote}:{}}}},e.id,{type:`complete`,reason:`unknown`}),LD=e=>{let t=iS(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&Nw(t,e)?t:e)});let i=n&&Nw(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},RD=mC(e=>({getState:()=>e})),zD=e=>{let t=$(9),n=LD(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(VD),t[0]=n.suggestions,t[1]=r);let i=gT(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},BD=mC(e=>{let t=$(4),n;t[0]===e?n=t[1]:(n=e.map(HD),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),zD(r)});function VD(e,t){return hC(t,RD(e),[e])}function HD(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var UD=e=>`reason`in e?e.reason:void 0,WD=e=>`error`in e?e.error:void 0,GD=32,KD=new WeakMap,qD=e=>KD.get(e)??e.id,JD=(e,t,n)=>`status`in e&&e.status?hE(e,t,n):uE,YD=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>GD))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=JD(u,e,d),m=UD(p),h=WD(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,KD.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},XD=mC(({task:e})=>({getState:()=>e})),ZD=mC(e=>{let t=$(8),{runtime:n,id:r,threadIdRef:i,threadId:a,isLast:o}=e,s;t[0]!==r||t[1]!==n?(s=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==c||t[5]!==a||t[6]!==i?(l=cE({runtime:c,threadIdRef:i,threadId:a,isLast:o}),t[3]=o,t[4]=c,t[5]=a,t[6]=i,t[7]=l):l=t[7],_C(l)}),QD=mC(e=>{let t=$(111),{runtime:n}=e,r=YT(n),i=Aw(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>ST(e)},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),oS(a,o);let s;t[4]===n?s=t[5]:(s=iE(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=nE({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=gw(p),h;t[15]===r.suggestions?h=t[16]:(h=BD(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=gw(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=YD(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map($D),t[20]=b,t[21]=x);let S=gT(x),C=m.state.submission,w=m.state.inTransit,T;t[22]===w?T=t[23]:(T=w??[],t[22]=w,t[23]=T);let E;t[24]===C?E=t[25]:(E=C?[C]:[],t[24]=C,t[25]=E);let D;t[26]!==T||t[27]!==E?(D=[...T,...E],t[26]=T,t[27]=E,t[28]=D):D=t[28];let O=D,k;t[29]===O?k=t[30]:(k=O.map(ID),t[29]=O,t[30]=k);let A=k,j=r.messages.length-1,M;if(t[31]!==j||t[32]!==O||t[33]!==A||t[34]!==n||t[35]!==r.messages||t[36]!==r.threadId||t[37]!==c){let e;t[39]!==j||t[40]!==O.length||t[41]!==n||t[42]!==r.threadId||t[43]!==c?(e=(e,t)=>{let i=t===j&&O.length>0?!1:void 0;return hC(e.id,ZD({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId,isLast:i}),[n,e.id,c,r.threadId,i])},t[39]=j,t[40]=O.length,t[41]=n,t[42]=r.threadId,t[43]=c,t[44]=e):e=t[44];let i=r.messages.map(e),a;t[45]!==O||t[46]!==A||t[47]!==r.messages.length?(a=O.map((e,t)=>hC(e.id,NE({message:A[t],submission:e,index:r.messages.length+t,isLast:t===O.length-1}),[A[t],e,r.messages.length,t,O.length])),t[45]=O,t[46]=A,t[47]=r.messages.length,t[48]=a):a=t[48],M=[...i,...a],t[31]=j,t[32]=O,t[33]=A,t[34]=n,t[35]=r.messages,t[36]=r.threadId,t[37]=c,t[38]=M}else M=t[38];let N=gT(M),P=N.state.length===0&&!r.isLoading,F;t[49]!==m.state||t[50]!==N.state||t[51]!==r.capabilities||t[52]!==r.extras||t[53]!==r.isDisabled||t[54]!==r.isLoading||t[55]!==r.isRunning||t[56]!==r.speech||t[57]!==r.state||t[58]!==r.suggestions||t[59]!==r.voice||t[60]!==P||t[61]!==b?(F={isEmpty:P,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:N.state,tasks:b},t[49]=m.state,t[50]=N.state,t[51]=r.capabilities,t[52]=r.extras,t[53]=r.isDisabled,t[54]=r.isLoading,t[55]=r.isRunning,t[56]=r.speech,t[57]=r.state,t[58]=r.suggestions,t[59]=r.voice,t[60]=P,t[61]=b,t[62]=F):F=t[62];let I=F,L;t[63]===I?L=t[64]:(L=()=>I,t[63]=I,t[64]=L);let R;t[65]===m.methods?R=t[66]:(R=()=>m.methods,t[65]=m.methods,t[66]=R);let z;t[67]===g?z=t[68]:(z=()=>g.methods,t[67]=g,t[68]=z);let B;t[69]!==S||t[70]!==b?(B=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?qD(t):e.id})}return S.get(e)},t[69]=S,t[70]=b,t[71]=B):B=t[71];let V;t[72]!==i||t[73]!==f||t[74]!==n?(V=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(eO).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[72]=i,t[73]=f,t[74]=n,t[75]=V):V=t[75];let H;t[76]!==u||t[77]!==n||t[78]!==r.isRunning?(H=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[76]=u,t[77]=n,t[78]=r.isRunning,t[79]=H):H=t[79];let U;t[80]!==u||t[81]!==n?(U=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[80]=u,t[81]=n,t[82]=U):U=t[82];let W;t[83]===N?W=t[84]:(W=e=>`id`in e?N.get({key:e.id}):N.get(e),t[83]=N,t[84]=W);let ee;t[85]===n?ee=t[86]:(ee=()=>n,t[85]=n,t[86]=ee);let te;return t[87]!==n.deleteMessage||t[88]!==n.disconnectVoice||t[89]!==n.export||t[90]!==n.getModelContext||t[91]!==n.getVoiceVolume||t[92]!==n.import||t[93]!==n.importExternalState||t[94]!==n.muteVoice||t[95]!==n.reset||t[96]!==n.resumeRun||t[97]!==n.startRun||t[98]!==n.stopSpeaking||t[99]!==n.subscribeVoiceVolume||t[100]!==n.unmuteVoice||t[101]!==L||t[102]!==R||t[103]!==z||t[104]!==B||t[105]!==V||t[106]!==H||t[107]!==U||t[108]!==W||t[109]!==ee?(te={getState:L,composer:R,suggestions:z,task:B,append:V,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:H,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:U,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:W,__internal_getRuntime:ee},t[87]=n.deleteMessage,t[88]=n.disconnectVoice,t[89]=n.export,t[90]=n.getModelContext,t[91]=n.getVoiceVolume,t[92]=n.import,t[93]=n.importExternalState,t[94]=n.muteVoice,t[95]=n.reset,t[96]=n.resumeRun,t[97]=n.startRun,t[98]=n.stopSpeaking,t[99]=n.subscribeVoiceVolume,t[100]=n.unmuteVoice,t[101]=L,t[102]=R,t[103]=z,t[104]=B,t[105]=V,t[106]=H,t[107]=U,t[108]=W,t[109]=ee,t[110]=te):te=t[110],te});function $D(e){return hC(qD(e),XD({task:e}),[e])}function eO(e){return e.type===`text`?e.text:``}var tO=e=>{let t=$(4),n=Aw(),r=rS(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),oS(i,a)},nO=(e,t,n)=>{let r=$(8),i=n===void 0?t:n,a=Aw(),o=t&&i,s;r[0]!==o||r[1]!==e?(s={isMain:o,threadId:e},r[0]=o,r[1]=e,r[2]=s):s=r[2];let c=rS(s),l,u;r[3]!==a||r[4]!==t||r[5]!==e?(l=()=>{let n=c.current;(n.isMain!==t||n.threadId!==e)&&(c.current={isMain:t,threadId:e},a(t?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:e}))},u=[t,e,a],r[3]=a,r[4]=t,r[5]=e,r[6]=l,r[7]=u):(l=r[6],u=r[7]),oS(l,u)},rO=(e,t)=>QT(`thread list ${e}`,t),iO=mC(e=>{let t=$(27),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=YT(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o;nO(a.id,a.isMain);let c;t[3]===s?c=t[4]:(c=()=>s,t[3]=s,t[4]=c);let l,u,d,f,p,m,h;t[5]===n?(l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12]):(u=e=>rO(`switch`,()=>n.switchTo(e)),d=e=>rO(`rename`,()=>n.rename(e)),f=e=>rO(`update custom metadata`,()=>n.updateCustom(e)),p=()=>rO(`archive`,()=>n.archive()),m=()=>rO(`unarchive`,()=>n.unarchive()),h=()=>rO(`delete`,()=>n.delete()),l=e=>rO(`generate title`,()=>n.generateTitle(e)),t[5]=n,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h);let g;t[13]===n?g=t[14]:(g=()=>n,t[13]=n,t[14]=g);let _;return t[15]!==n.detach||t[16]!==n.initialize||t[17]!==l||t[18]!==g||t[19]!==c||t[20]!==u||t[21]!==d||t[22]!==f||t[23]!==p||t[24]!==m||t[25]!==h?(_={getState:c,switchTo:u,rename:d,updateCustom:f,archive:p,unarchive:m,delete:h,generateTitle:l,initialize:n.initialize,detach:n.detach,__internal_getRuntime:g},t[15]=n.detach,t[16]=n.initialize,t[17]=l,t[18]=g,t[19]=c,t[20]=u,t[21]=d,t[22]=f,t[23]=p,t[24]=m,t[25]=h,t[26]=_):_=t[26],_}),aO=mC(e=>{let t=$(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=iO({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],_C(s)}),oO=mC(e=>{let t=$(48),{runtime:n,__internal_assistantRuntime:r}=e,i=YT(n);tO(i.mainThreadId);let a=Aw(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),oS(o,s);let c;t[4]===n.main?c=t[5]:(c=QD({runtime:n.main}),t[4]=n.main,t[5]=c);let l=gw(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>hC(e,aO({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=gT(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>rO(`switch`,()=>n.switchToThread(e,t)),y=()=>rO(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),sO=(e,t)=>{e.thread??=mT({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=mT({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=mT({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=VT()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=mT({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},cO=e=>{let t=$(7),n=Ow(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),kw(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=oO({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),_C(a)},lO=mC(cO);rw(cO,(e,t)=>{sO(e,t),!e.tools&&t.tools.source===null&&(e.tools=KT({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=TC())});var uO=OC({}),dO=({effects:e})=>{"use no memo";return sS(e),null},fO=mS(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=ew();if(Uw){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==qC)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??qC:a?e.value??qC:o,c=Vw(),{client:l,effects:u}=cT(s,n??uO,c);return pS(t,()=>l,[l]),(0,q.jsx)(jw.Provider,{value:c,children:(0,q.jsxs)(YC.Provider,{value:l,children:[(0,q.jsx)(dO,{effects:QC(s)}),u&&(0,q.jsx)(dO,{effects:u}),r]})})}),pO=e=>e._core?.RenderComponent,mO=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=pO(e),a=OC({...n,threads:lO(e)});return(0,q.jsxs)(fO,{extends:t,config:a,children:[i&&(0,q.jsx)(i,{}),r]})},hO=hS(e=>{let t=$(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,q.jsx)(mO,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}),gO=_S(null),_O=(e,t)=>Sx(gO,e,t),vO=()=>yS(gO),yO={},bO=e=>{let t=Hw(e??yO);return e==null?null:t},xO=e=>{let t=$(6),{adapters:n,children:r}=e,i=yS(gO),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,q.jsx)(gO.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s};function SO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function CO(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>CO(e,t+1)):SO(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&CO(n,t+1)):!1}var wO=e=>{if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e!=`string`&&typeof e!=`number`)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},TO=e=>e===`system`||e===`user`||e===`assistant`,EO={running:()=>!0,"requires-action":e=>typeof e.reason==`string`,complete:e=>typeof e.reason==`string`,incomplete:e=>(e.reason===void 0||typeof e.reason==`string`)&&(e.error===void 0||CO(e.error))},DO=e=>SO(e)&&typeof e.type==`string`&&Object.hasOwn(EO,e.type)&&EO[e.type](e)===!0,OO=e=>{if(SO(e)){if(e.messageId!==void 0&&typeof e.messageId!=`string`){let{messageId:t,...n}=e;return OO(n)}if(e.usage!==void 0&&!SO(e.usage)){let{usage:t,...n}=e;return n}return e}},kO=e=>Array.isArray(e)?e.map(OO).filter(e=>e!==void 0):[],AO=(e,t)=>{let n={text:e=>typeof e.text==`string`,reasoning:e=>typeof e.text==`string`||typeof e.unstable_summary==`string`,image:e=>typeof e.image==`string`,file:e=>typeof e.data==`string`&&typeof e.mimeType==`string`,audio:e=>SO(e.audio)&&typeof e.audio.data==`string`&&typeof e.audio.format==`string`,data:e=>typeof e.name==`string`,source:e=>typeof e.id==`string`&&(e.sourceType===`url`?typeof e.url==`string`:e.sourceType===`document`&&typeof e.title==`string`&&typeof e.mediaType==`string`),"generative-ui":e=>SO(e.spec),"tool-call":e=>typeof e.toolCallId==`string`&&typeof e.toolName==`string`&&SO(e.args)&&typeof e.argsText==`string`,...e};return e=>SO(e)&&typeof e.type==`string`&&(Object.hasOwn(n,e.type)?n[e.type](e):t(e.type))};AO({},()=>!0);var jO=AO({reasoning:e=>(e.text===void 0||typeof e.text==`string`)&&(e.unstable_summary===void 0||typeof e.unstable_summary==`string`)&&(typeof e.text==`string`||typeof e.unstable_summary==`string`),"tool-call":e=>typeof e.toolCallId==`string`&&typeof e.toolName==`string`&&(e.args===void 0||SO(e.args))&&(e.argsText===void 0||typeof e.argsText==`string`)&&(e.args!==void 0||e.argsText!==void 0)},e=>e.startsWith(`data-`)),MO={user:{text:!0,image:!0,file:!0,data:!0,audio:!0},assistant:{text:!0,reasoning:!0,"tool-call":!0,source:!0,file:!0,image:!0,data:!0,"generative-ui":!0}},NO=(e,t)=>jO(t)&&(e===`system`?t.type===`text`:Object.hasOwn(MO.assistant,t.type)||Object.hasOwn(MO.user,t.type)?Object.hasOwn(MO[e],t.type):!0),PO=(e,t)=>!SO(e)||typeof e.id!=`string`||typeof e.type!=`string`||typeof e.name!=`string`||!SO(e.status)||e.status.type!==`complete`||!Array.isArray(e.content)?null:{...e,content:e.content.filter(t)},FO={toResponse(e,t){return new Response(FO.toByteStream(e,t),{headers:t.headers??{}})},fromResponse(e,t){return FO.fromByteStream(e.body,t)},toByteStream(e,t){return e.pipeThrough(t)},fromByteStream(e,t){return e.pipeThrough(t)}},IO=new Set([`__proto__`,`constructor`,`prototype`]);function LO(e){if(IO.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var RO=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(LO(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},zO=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},BO=(e,t)=>({...e,parts:t,get content(){return this.parts}}),VO=(e,t)=>BO(e,[...e.parts,t]),HO=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),UO=16,WO=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:BO(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},GO=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return VO(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return VO(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return VO(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return VO(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return VO(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),VO(e,{type:`reasoning`,text:``,status:{type:`running`}})}},KO=(e,t,n)=>WO(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),qO=(e,t,n)=>WO(e,t,n,e=>e.type===`tool-call`&&e.isPreliminary?e:{...e,status:{type:`complete`,reason:`unknown`}}),JO=(e,t,n)=>WO(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=uD(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),YO=(e,t,n)=>WO(e,t,n,e=>{if(e.type===`tool-call`){let n=t.isPreliminary===!0,r=e.status.type===`running`?e.status:{type:`running`,isArgsComplete:e.state!==`partial-call`};if(n)return e.state===`result`?e:{...e,state:e.state===`partial-call`?`partial-call`:`call`,...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,isPreliminary:!0,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:r};let{isPreliminary:i,...a}=e;return{...a,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}}return n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e}),XO=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=ZO(t);return{...e,status:n}},ZO=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},QO=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),$O=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),ek=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),tk=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:dD(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},nk=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},rk=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),ik=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},ak=(e,t,n=0)=>{let r=n>0?n:ik(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},ok=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},sk=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??HO(),a,o,s=new zO,c=new Set,l=(e,t)=>{c.has(e)||c.size>=UO||(c.add(e),console.warn(t))},u,d=t?ok(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=GO(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=KO(i,e,l);break;case`part-finish`:i=qO(i,e,l);break;case`text-delta`:{let t=JO(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=YO(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=XO(i,e);break;case`annotations`:i=QO(i,e);break;case`data`:i=$O(i,e);break;case`step-start`:i=ek(i,e);break;case`step-finish`:i=tk(i,e);break;case`error`:i=nk(i,e),n?.(e.error);break;case`update-state`:a??=new RO(i.metadata.unstable_state,{strict:r}),i=rk(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:ak(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&(e.result===void 0||e.isPreliminary))??!1;i=XO(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:ak(s,i,o)}},e.enqueue(i)}}})}},ck=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new sk))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return aD(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}},lk=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},uk=class extends lk{constructor(){super(e=>{let t=new ND({transform(e,t){t.appendText(e)}});return e.pipeThrough(new TextDecoderStream).pipeThrough(t)})}},dk=100,fk=(e,t,n)=>{if(e===t)return!0;if(n>dk||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>fk(e,t[r],n+1));if(Array.isArray(t)||!SO(e)||!SO(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&fk(e[r],t[r],n+1))},pk=(e,t)=>!CO(e)||!CO(t)?!1:fk(e,t,0);function mk(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function hk(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var gk=e=>{if(!SO(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function _k(e,t,n=[]){if(!SO(e)||!SO(t))return t;let r={...e,...t},[i,...a]=n;return i!==void 0&&Object.hasOwn(t,i)&&(r[i]=_k(e[i],t[i],a)),r}function vk(e,t,n,r){let i=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(i=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);i=i.filter(t=>{let n=gk(t);return n===void 0?!e.has(t):!e.has(n)})}let a=t.update;if(Array.isArray(a)&&a.length>0){let e=new Map;for(let t of a){let n=gk(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}let t=r?.[0]===`update`?{patch:a[Number(r[1])],rest:r.slice(2)}:void 0;i=i.map(n=>{let r=gk(n);if(r===void 0||!SO(n))return n;let i=e.get(r);return i?t&&i===t.patch?_k(n,i,t.rest):{...n,...i}:n})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!SO(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;i=[...i,...e]}return i}function yk(e,t,n){if(!SO(e)||!SO(t))return t;let r=SO(n?.arrayBaseline)?n.arrayBaseline:e,i=n?.partialPath,a=Object.entries(e);for(let[o,s]of Object.entries(t)){let t=r[o],c=i?.[0]===o?i.slice(1):void 0;if(Array.isArray(t)&&SO(s)){let e=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(o))?()=>n.idFactory?.(o):void 0;a.push([o,vk(t,s,e,c)])}else c?a.push([o,_k(e[o],s,c)]):a.push([o,s])}return Object.fromEntries(a)}function bk(e,t){if(!SO(e)||!SO(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!pk(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var xk=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},Sk=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=SO(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},Ck=e=>{let t=SO(e)?e.addedItemIds:void 0;if(!SO(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},wk=new WeakMap;function Tk(e,t,n){let r=wk.get(e);r||(r=new Map,wk.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=hk(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=mk(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:yk(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=xk(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&Sk(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=Ck(r.result);s.push({state:i?yk(e.state,n,{idFactory:i}):yk(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function Ek(e,t,n){let r=Tk(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function Dk(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=Ek(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(pk(r.state,n.state))continue;let i=bk(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var Ok=Symbol(`innerMessage`),kk=e=>e.type===`tool-call`&&e.result===void 0,Ak=e=>e.type===`tool-call`&&mE(e),jk=Symbol(`autoStatus`),Mk=Object.freeze(Object.assign({type:`running`},{[jk]:!0})),Nk=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[jk]:!0})),Pk=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[jk]:!0})),Fk=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[jk]:!0})),Ik=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[jk]:!0})),Lk=(e,t,n,r,i,a,o)=>e&&i!=null?Object.assign({type:`incomplete`,reason:`error`,error:i},{[jk]:!0}):e&&t?Mk:n?Ik:o&&!a?Mk:r?Fk:a?Pk:Nk,Rk=e=>Lk(!1,!1,typeof e!=`string`&&e.some(Ak),typeof e!=`string`&&e.some(kk)),zk=e=>{let t=$(6),{runtime:n,children:r}=e,i=lT(),a;t[0]===n?a=t[1]:(a=OC({threadListItem:iO({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,q.jsx)(fO,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Bk=[`critical`,`warning`,`info`],Vk=[`inline`,`toast`,`silent`,`dev-only`],Hk=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!(typeof t.code!=`string`||typeof t.message!=`string`||`severity`in t&&t.severity!==void 0&&(typeof t.severity!=`string`||!Bk.includes(t.severity))||`display`in t&&t.display!==void 0&&(typeof t.display!=`string`||!Vk.includes(t.display)))},Uk=Symbol.for(`assistant-ui.message-not-sent`),Wk=class extends Error{[Uk]=!0;constructor(e=`The message was not sent.`){super(e),this.name=`MessageNotSentError`}},Gk=e=>typeof e==`object`&&!!e&&Uk in e,Kk=e=>{if(Hk(e))return e;if(e instanceof Error)return{code:`unknown`,message:e.message};if(typeof e==`string`)return{code:`unknown`,message:e};try{return{code:`unknown`,message:`[${typeof e}] ${String(e)}`}}catch{return{code:`unknown`,message:`[${typeof e}]`}}},qk=(e,t)=>{Promise.resolve(t).catch(t=>{Gk(t)||console.error(`[assistant-ui] ${e} failed`,t)})},Jk=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},Yk=class extends Jk{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},Xk=class extends Yk{get source(){return`thread-composer`}},Zk=class extends Yk{get source(){return`edit-composer`}},Qk=class extends Jk{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},$k=Object.freeze([]),eA=Object.freeze({}),tA=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??$k,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??eA,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??$k,submission:e?.submission,inTransit:e?.inTransit??$k,value:e?.text??``}),nA=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??$k,runConfig:e?.runConfig??eA,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??$k,submission:e?.submission,inTransit:e?.inTransit??$k,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),rA=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new jT({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},iA=class extends rA{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new kT({path:e.path,getState:()=>tA(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new Xk(new OT({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:bT},subscribe:e=>this._core.subscribe(e)}),this._core)}},aA=class extends rA{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new kT({path:e.path,getState:()=>nA(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new Zk(new OT({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:bT},subscribe:e=>this._core.subscribe(e)}),this._core)}},oA=e=>e.display===`text`||e.allowFreeform===!0,sA={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},cA=(e,t)=>{let n=t.text;if(n!==void 0&&!oA(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(sA,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=sA[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},lA=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.unstable_recordInteraction=this.unstable_recordInteraction.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=wD.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e}),this.unstable_recordInteraction({type:`human-response`,payload:e}).catch(()=>{})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(cA(t.approval,e))}async unstable_recordInteraction(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to record interaction on non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=this.threadApi.getState();if(!r.unstable_recordToolInteraction)throw Error(`Runtime does not support recording tool interactions.`);await r.unstable_recordToolInteraction({messageId:n.id,toolCallId:t.toolCallId,interaction:eD(e)})}subscribe(e){return this.contentBinding.subscribe(e)}},uA=(e,t)=>{let n=e.content[t];if(!n)return bT;let r=hE(e,t,n);return Object.freeze({...n,[Ok]:n[Ok],status:r})},dA=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new aA(new AT({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);qk(`Message reload`,this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i}))}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return lE(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new lA(new OT({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>uA(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new lA(new OT({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?bT:uA(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new Qk(new OT({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:bT},subscribe:e=>this._core.subscribe(e)}))}},fA=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),pA=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),mA=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},hA=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},gA=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:hA(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),_A=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new OT({path:e.path,getState:()=>gA(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>ST([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new iA(new AT({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){qk(`Message append`,this._threadBinding.getState().append(mA(this._threadBinding.getState().messages,e)))}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(pA(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(fA(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new dA(new OT({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return bT;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[Ok]:e[Ok],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new jT({event:e,binding:this._threadBinding,notifyOnRebind:e===`modelContextUpdate`}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},vA=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),yA=class extends TT{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}async unstable_recordToolInteraction(e){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1,answerToolCall:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},bA=new WeakMap,xA=e=>{let t=bA.get(e);return t||(t=new AbortController,bA.set(e,t)),t.signal},SA=new WeakMap,CA=e=>{let t=SA.get(e);return t||(t=new AbortController,SA.set(e,t)),t},wA=e=>CA(e).signal,TA=e=>{let t=bA.get(e);t?.signal.aborted||(bA.delete(e),t?.abort())},EA=e=>{if(e.voice)try{e.disconnectVoice()}catch(e){console.error(`[assistant-ui] Voice cleanup threw while discarding a thread runtime`,e)}},DA=e=>{EA(e),TA(e)},OA=e=>{let t=bA.get(e)??new AbortController;bA.set(e,t),t.abort(),CA(e).abort(),EA(e)},kA=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||DC([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},AA=Promise.resolve(),jA=()=>{},MA=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),NA=(e,t)=>{if(t===void 0)return bT;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:bT},PA=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=_A){this._core=e,this._runtimeFactory=t;let n=new kT({path:{},getState:()=>MA(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new kA(new OT({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>NA(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new AT({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??jA}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??AA}reloadMainThread(){return this._core.reloadMainThread?.()??AA}loadMore(){return this._core.loadMore?.()??AA}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new OT({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>NA(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new AT({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new kA(new OT({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>NA(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new kA(new OT({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>NA(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new kA(this._createItemStateBinding(e),this._core)}},FA=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new PA(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},IA=class{_contextProvider=new PT;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},LA={fromArray:e=>{let t=e.map(e=>FD(e,GE(),Rk(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:FD(e,e.id,Rk(e.content))}})})},RA=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},zA=(e,t)=>{let n=new Set(e.map(e=>e.message.id)),r=new Set,i=new Map,a=[];for(let o of e){let{parentId:e}=o;if(e!==null&&n.has(e)&&!r.has(e)&&!t(e)){let t=i.get(e);t?t.push(o):i.set(e,[o]);continue}for(let e=a.push(o)-1;e<a.length;e++){let{id:t}=a[e].message;if(r.has(t))continue;r.add(t);let n=i.get(t);n&&(i.delete(t),a.push(...n))}}for(let e of i.values())a.push(...e);return a},BA=e=>{let t=new Set(e.messages.map(e=>e.message.id)),n=new Map,r=[];for(let{message:i,parentId:a}of e.messages){if(a===null)continue;let e=n.get(a);e?e.push(i.id):n.set(a,[i.id]),t.has(a)||r.push(i.id)}let i=new Set;for(let e=0;e<r.length;e++){let t=r[e];if(!i.has(t)){i.add(t);for(let e of n.get(t)??[])r.push(e)}}let a=e.headId!=null&&!t.has(e.headId);if(i.size===0&&!a)return{repository:e,droppedIds:[]};let o=[],s=new Set,c=e.messages.filter(({message:e,parentId:t})=>i.has(e.id)?(o.push(e.id),!1):(t!==null&&s.add(t),!0)),{headId:l}=e;if(l!=null&&(a||i.has(l))){l=null;for(let{message:e}of c)s.has(e.id)||(l=e.id)}return{repository:{...e,messages:c,...l!==void 0&&{headId:l}},droppedIds:o}},VA=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},HA=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,RA(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=RA(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new VA(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){this.performOp(r,n,`relink`),n.current=t,this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e=r;e;e=e.prev)if(e===n)throw Error(`MessageRepository(deleteMessage): Replacement is the deleted message or one of its descendants. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=RA(r??this.root)),this._messages.dirty()}hasChildren(e){return(this.messages.get(e)?.children.length??0)>0}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=RA(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){let n=zA(t,e=>this.messages.has(e));for(let{message:e,parentId:t}of n)this.addOrUpdateMessage(t,e);this.resetHead(e??n.at(-1)?.message.id??null)}},UA=Object.freeze([]);function WA(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function GA(e){let t=GE();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function KA(e){let t=[];for(let n of e)n.type!==`text`&&t.push(GA(n));return t}var qA=e=>`content`in e&&!(`lastModified`in e),JA=e=>e.status.type===`complete`,YA=class{operations=new Set;uploading=new Map;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){if(e.cancelled)return!1;e.attachmentIds.add(t.id);let n=this.uploading.get(t.id);return n?.operation!==e&&(n||t.status.type===`running`)&&this.uploading.set(t.id,{operation:e,waiters:n?.waiters??new Set}),t.status.type!==`running`&&this.settle(t.id,e),!0}finish(e){this.operations.delete(e);for(let t of e.attachmentIds)this.settle(t,e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t));this.settle(e)}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear();for(let e of[...this.uploading.keys()])this.settle(e)}whenSendable(e){let t=this.uploading.get(e);if(t)return new Promise(e=>t.waiters.add(e))}settle(e,t){let n=this.uploading.get(e);if(n&&!(t&&n.operation!==t)){this.uploading.delete(e);for(let e of n.waiters)e()}}},XA=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},ZA=class{entries=new WeakMap;removed=new WeakSet;markRemoved(e){this.removed.add(e)}unmarkRemoved(e){this.removed.delete(e)}isRemoved(e){return this.removed.has(e)}async send(e,t,n){if(JA(e))return e;let r=this.entries.get(e)??{};if(r.result)return r.result;if(!t)throw Error(`Attachments are not supported`);this.entries.set(e,r);let i=await t.send(e,n?{signal:n}:void 0);return r.result=i,i}transfer(e,t){let n=this.entries.get(e);return n&&this.entries.set(t,n),t}},QA=class extends TT{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_submission;_submissionSend;_inTransit=[];_inTransitSubmissions=[];_sendGeneration=0;_attachmentAddOperations=new YA;_attachmentSends=new ZA;get submission(){return this._submission}get inTransit(){return this._inTransitSubmissions}get isSubmitting(){return this._submission!==void 0}get detachesDraftOnSend(){return!0}threadMessageIds(e){}settleInTransit(){if(this._inTransit.length===0)return;let e=new Set,t=this._inTransit.filter(({submission:t,known:n})=>{let r=this.threadMessageIds(t.role)?.find(t=>!n.has(t)&&!e.has(t));return r===void 0||(e.add(r),!1)});t.length!==this._inTransit.length&&(this._setInTransit(t.map(t=>({...t,known:new Set([...t.known,...e])}))),this._notifySubscribers())}_setInTransit(e){this._inTransit=e,this._inTransitSubmissions=e.map(e=>e.submission)}_leaveTransit(e){let t=this._inTransit.filter(t=>t.submission!==e);return t.length!==this._inTransit.length&&(this._setInTransit(t),!0)}_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!JA(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){this._cancelAllAttachmentAdds(),this._sendGeneration++;let e=this._discardSubmission();if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0){await e;return}this._role=`user`,this._runConfig={},this._quote=void 0;let t=this._onClearAttachments();this._emptyTextAndAttachments(),await Promise.all([t,e])}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this.isSubmitting)for(let e of this._attachments)this._attachmentSends.markRemoved(e);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this.isSubmitting)return;if(this._dictationSession){let e=this._activeDictationSessionId;try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation({sessionId:e})}}let t=this.attachments.filter(e=>!this._attachmentSends.isRemoved(e));if(!this.text.trim()&&t.length===0)return;let n={id:GE(),role:this.role,text:this.text,quote:this._quote,attachments:t},r={options:e,runConfig:this.runConfig},i=t.filter(JA),a=i.length===t.length;if(a||(this._submission=n,this._submissionSend={...r,controller:new AbortController}),this.detachesDraftOnSend){let e=new Set(t);this._attachments=this._attachments.filter(t=>!e.has(t)),this._text=``,this._rebaseDictation(``),this._quote=void 0}let o=++this._sendGeneration;if(this._notifySubscribers(),a){this._dispatch(o,n,i,r,!1);return}await this._prepareSubmission(o)}async _prepareSubmission(e){let t=this.getAttachmentAdapter(),n=(this._submission?.attachments??[]).flatMap(e=>{let t=this._attachmentAddOperations.whenSendable(e.id);return t?[t]:[]});if(n.length>0){if(await Promise.all(n),e!==this._sendGeneration)return;this._refreshSubmissionAttachments()}let r=this._submission,i=this._submissionSend;if(!r||!i)return;let a=r.attachments.filter(e=>!this._attachmentSends.isRemoved(e));for(let e of a)this._cancelAttachmentAdd(e.id);let o=await Promise.allSettled(a.map(e=>this._attachmentSends.send(e,t,i.controller.signal)));if(e!==this._sendGeneration)return;let s=o.find(e=>e.status===`rejected`);if(s){this._returnSubmissionToDraft(a,o,s.reason);return}let c=o.flatMap((e,t)=>this._attachmentSends.isRemoved(a[t])||e.status===`rejected`?[]:[e.value]);this._dispatch(e,r,c,i,!0)}_dispatch(e,t,n,r,i){let a={createdAt:new Date,role:t.role,content:t.text?[{type:`text`,text:t.text}]:[],attachments:n,runConfig:r.runConfig,metadata:{custom:{...t.quote?{quote:t.quote}:{}}}},o={...t,attachments:n},s=this.queue.length;if(i){if(this._submission=void 0,this._submissionSend=void 0,!this.detachesDraftOnSend){let e=new Map(n.map(e=>[e.id,e]));this._attachments=this._attachments.map(t=>e.get(t.id)??t)}let e=this.threadMessageIds(t.role);e&&this._setInTransit([...this._inTransit,{submission:o,known:new Set(e)}])}let c;try{c=this.handleSend(a,r.options)}catch(t){console.error(`[assistant-ui] Failed to send the message`,t),this._leaveTransit(o),e===this._sendGeneration?this._returnToDraft(o):this._notifySubscribers();return}c&&c.catch(t=>{let n=this._leaveTransit(o);e===this._sendGeneration&&Gk(t)?this._returnToDraft(o):n&&this._notifySubscribers()}),this._notifyEventSubscribers(`send`,{chars:t.text.length,attachments:n.length}),i&&(this.queue.length>s&&this._leaveTransit(o),this._notifySubscribers(),this.settleInTransit())}_refreshSubmissionAttachments(){let e=this._submission;if(!e)return;let t=e.attachments.filter(e=>!this._attachmentSends.isRemoved(e));t.length!==e.attachments.length&&(this._submission={...e,attachments:t})}_returnSubmissionToDraft(e,t,n){let r=this._submission;if(!r)return;let i=new Map;t.forEach((t,n)=>{t.status===`rejected`&&i.set(e[n].id,t.reason)});let a=r.attachments.map(e=>{if(!i.has(e.id)||JA(e))return e;let t=i.get(e.id);return this._attachmentSends.transfer(e,{...e,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}})});this._endSubmission(),this._returnToDraft({...r,attachments:a}),console.error(`[assistant-ui] Failed to send attachments`,n)}_endSubmission(){this._sendGeneration++,this._submission=void 0,this._submissionSend=void 0}__internal_dispose(){this._cancelAllAttachmentAdds(),this._submission&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers())}cancelSubmission(){let e=this._submission;e&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._returnToDraft(e))}_returnToDraft(e){if(this.detachesDraftOnSend){let t=e.attachments.filter(e=>!this._attachmentSends.isRemoved(e));this._attachments=[...t,...this._attachments];let n=[e.text,this._text].filter(Boolean).join(`
|
|
126
|
+
`);this._text=n,this._rebaseDictation(n),this._quote=this._quote??e.quote}else{let t=new Map(e.attachments.map(e=>[e.id,e]));this._attachments=this._attachments.map(e=>t.get(e.id)??e)}this._notifySubscribers()}async _discardSubmission(){let e=this._submission;if(!e)return;this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers();let t=this.getAttachmentAdapter();if(!t)return;let n=new Set(this._attachments.map(e=>e.id));await Promise.all(e.attachments.filter(e=>!JA(e)&&!n.has(e.id)).map(async e=>t.remove(e)))}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text!==e.text||this._quote!==e.quote||!t||(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}cancel(){this.isSubmitting&&!this.detachesDraftOnSend&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers()),this.handleCancel()}get queue(){return UA}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(qA(e)){let t=this.getAttachmentAdapter();if(t&&!WA({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??GE(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!WA({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e))return!1;let t=this._submission,r=t?.attachments.some(t=>t.id===e.id)??!1;t&&r&&(this._submission={...t,attachments:t.attachments.map(t=>t.id===e.id?this._attachmentSends.transfer(t,e):t)});let i=this._attachments.findIndex(t=>t.id===e.id);return i===-1?r||(this._attachments=[...this._attachments,e]):this._attachments=[...this._attachments.slice(0,i),e,...this._attachments.slice(i+1)],this._notifySubscribers(),!0},i;try{await XA(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1){await this._removeSubmittedAttachment(e);return}let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._attachmentSends.markRemoved(n),!JA(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!JA(t)?this._attachmentSends.transfer(t,{...t,status:{type:`incomplete`,reason:`error`,message:n}}):t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}async _removeSubmittedAttachment(e){let t=this._submission?.attachments.find(t=>t.id===e);if(!t)throw Error(`Attachment not found`);if(this._cancelAttachmentAdd(e),this._attachmentSends.markRemoved(t),!JA(t)){let n=this.getAttachmentAdapter();if(!n)throw Error(`Attachments are not supported`);try{await n.remove(t)}catch(t){throw this._failSubmittedRemoval(e,t),t}}let n=this._submission;n&&(this._submission={...n,attachments:n.attachments.filter(t=>t.id!==e)},this._notifySubscribers())}_failSubmittedRemoval(e,t){let n=this._submission;if(!n)return;let r=t instanceof Error?t.message:String(t);this._submission={...n,attachments:n.attachments.map(t=>{if(t.id!==e||JA(t))return t;let n=this._attachmentSends.transfer(t,{...t,status:{type:`incomplete`,reason:`error`,message:r}});return this._attachmentSends.markRemoved(n),n})},this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n};try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation start notification threw`,e)}if(!this._isActiveSession(i,r))return;let a=[],o=()=>{for(let e of a.splice(0))try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}},s=e=>(a.push(e),this._isActiveSession(i,r)?!0:(o(),!1));try{if(!s(r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()}))||!s(r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())}))||!s(r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})})))return;let e=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);if(!s(()=>clearInterval(e)))return;this._dictationUnsubscribes.push(...a.splice(0))}catch(e){if(o(),this._isActiveSession(i,r))try{r.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation({sessionId:i})}throw e}}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&DC(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},$A=e=>e.capabilities?.cancel?hA(e):!1,ej=class extends QA{get canCancel(){return this.isSubmitting||$A(this.runtime)}get canSend(){if(this.isEmpty||this.runtime.isSendDisabled||this.isSubmitting)return!1;let e=this.runtime.voice;return!e||e.canSendText&&this.role===`user`&&this.attachments.length===0}cancel(){if(!this.isSubmitting){super.cancel();return}this.cancelSubmission(),$A(this.runtime)&&super.cancel()}threadMessageIds(e){return this.runtime.messages.filter(t=>t.role===e).map(e=>e.id)}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??UA,t=this.runtime.getQueueItems?.()??UA,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice?.canSendText,r=this.queue;return this.runtime.subscribe(()=>{this.settleInTransit();let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice?.canSendText;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},tj=class extends QA{get canCancel(){return!0}get detachesDraftOnSend(){return!1}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this.isSubmitting}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;_ended=!1;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(lE(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...KA(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this._ended||(this._ended=!0,this.reset().catch(e=>{console.error(`[assistant-ui] Failed to clear cancelled edit`,e)}),this.endEditCallback(),this._notifySubscribers())}},nj=class extends TT{_isInitialized=!1;repository=new HA;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}_onMessageMetadataChanged(e,t){}_dropVoiceMessage(e,t){let n=this._voiceMessages.findIndex(t=>t.id===e);n!==-1&&(this._voiceMessages.splice(n,1),this._markVoiceMessagesDirty(),t&&this._notifySubscribers())}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new ej(this);_contextProvider;constructor(e){super(),this._contextProvider=e,wA(this).addEventListener(`abort`,()=>{this.composer.__internal_dispose();for(let e of this._editComposers.values())e.__internal_dispose()})}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=Dk(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new tj(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&DC(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?(this.repository.addOrUpdateMessage(o,t),this._onMessageMetadataChanged(a,t)):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(lE(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?xT([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{xT([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);xT([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_toVoiceSessionState(e,t,n){return{status:t,isMuted:e.isMuted,mode:n,canSendText:t.type===`running`&&e.sendText!==void 0}}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}_getVoiceCommitBarrier(){if(!this.isLoading)return;let e=xA(this);return(async()=>{for(;this.isLoading&&!e.aborted;)await new Promise(t=>{let n=()=>{r(),e.removeEventListener(`abort`,n),t()},r=this.subscribe(n);e.addEventListener(`abort`,n)})})()}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{xT(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice=this._toVoiceSessionState(n,n.status,e),this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice=this._toVoiceSessionState(n,t,e),this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{this._voiceSession===n&&(e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers()))})),i())||(r.push(n.onVolumeChange(e=>{this._voiceSession===n&&(this._voiceVolume=e,DC(this._voiceVolumeSubscribers,void 0,`Voice volume`))})),i()))return;r.push(n.onTranscript(e=>{this._voiceSession===n&&this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_observeVoiceCommit(e){Promise.resolve(e).catch(e=>{console.error(`[assistant-ui] Voice message commit failed`,e)})}_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&this._observeVoiceCommit(this._commitVoiceUserMessage({id:GE(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,attachments:[]}));else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:GE(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._observeVoiceCommit(this._commitVoiceMessage(this._currentAssistantMsg)),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_commitVoiceUserMessage(e){this._voiceMessages.push(e);let t=this._commitVoiceMessage(e);return this._markVoiceMessagesDirty(),this._notifySubscribers(),t}async _appendToVoiceSession(e){let t=this._voiceSession;if(!this.voice?.canSendText||!t?.sendText)throw Error(`Cannot send a text message while a voice session is connected`);let n=e.content.filter(e=>e.type===`text`);if(e.role!==`user`||e.sourceId!=null||e.parentId!==this._resolveAppendParent(this.messages.at(-1)?.id??null)||e.attachments?.length||n.length!==e.content.length||!n.some(e=>e.text.trim()))throw Error(`Only a plain text user message can be sent while a voice session is connected`);let r=this.enrichAppendMetadata(e);this.ensureInitialized();let i=xA(this);try{await t.sendText(lE(e))}catch(e){if(i.aborted)return;let t=new Wk;throw t.cause=e,t}if(!i.aborted){if(this._voiceSession!==t)throw new Wk(`The voice session ended before the typed message was recorded`);this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null,await this._commitVoiceUserMessage({id:GE(),role:`user`,content:n,metadata:{custom:{...r.metadata?.custom}},createdAt:e.createdAt,attachments:[]})}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._observeVoiceCommit(this._commitVoiceMessage(this._voiceMessages[n])),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{xT([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>DC(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(LA.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>DC([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&DC([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},rj=_S(!1),ij=e=>Sx(rj,!0,e),aj=e=>e.status?.type!==`running`,oj=async(e,t)=>{let n=ck.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},sj=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{ZT(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(aj);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},cj=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=ij(n),o=a?.thread?.__internal_threadBinding,s=aS(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=rS(!1);c.current||s(),oS(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=rS(void 0),u=rS(!1),d=rS(i.getState().status===`new`),f=rS(void 0),p=rS(!1),m=cS(()=>{if(u.current||i.getState().status!==`new`&&!d.current)return;u.current=!0,d.current=!1;let e=i.initialize();l.current=e,e.then(()=>{p.current&&(f.current?.(),f.current=sj(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),h=cS(()=>(m(),l.current));return oS(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,h)},[o]),oS(()=>{if(!a?.threads?.main)return;u.current=!1,p.current=!0;let e=a.threads.main.unstable_on(`initialize`,m);return()=>{p.current=!1,e(),f.current?.(),f.current=void 0}},[a]),a},lj=mC(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=iS(()=>new kA(new OT({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:bT},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=cT(i,{threadListItem:iO({runtime:c})});return Mw(s,function(){return tw(l,function(){return _O(a,function(){return cj({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),uj=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],dj=e=>{let t=$(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),sS(r,i),null},fj=class extends TT{runtimeHook;adapterStore=new ET({defaultAdapters:null,threadAdapters:new Map});hostStore=new ET({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);if(!t)return this.startThreadRuntime(e);try{t.unsubscribeRunning?.()}finally{t.unsubscribeRunning=void 0,t.runtime&&DA(t.runtime),t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers()}return this._whenRuntimeAttached(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime,a=r.publishedGeneration;r.runtime=t,r.publishedGeneration=n;try{i!==t&&this._trackRunning(e,r)}finally{try{this._notifySubscribers(),i!==void 0&&i!==t&&xT(this.replacedSubscribers)}finally{a===n&&i!==void 0&&i!==t&&OA(i)}}}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){let n=t.unsubscribeRunning;t.unsubscribeRunning=void 0;try{n?.()}finally{let n=t.runtime;if(!n)this._setRunning(t,!1);else{let r=hA(n);t.isRunning!==r&&(t.isRunning=r,queueMicrotask(()=>xT(this.runningSubscribers)));let i=[n.subscribe(()=>{this._setRunning(t,hA(n))}),...uj.map(t=>n.unstable_on(t,()=>{DC(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>ST(i)}}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,xT(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);try{t?.unsubscribeRunning?.()}finally{t?.runtime&&OA(t.runtime),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])try{this.stopThreadRuntime(e)}catch(e){console.error(`[assistant-ui] Thread runtime cleanup threw while stopping a thread`,e)}}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return hC(`${t}:${a}:${n}`,lj({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=YT(this.hostStore),n=YT(this.adapterStore);return SC(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(YT(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,q.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=YT(this.hostStore),n=YT(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=wC(function(){return SC(r)});return sS(i),null};_OuterActiveThreadProvider=hS(({threadId:e,provider:t})=>{let n=iS(()=>new PA(this.parent).getItemById(e),[e]),r=rS(!1);return oS(()=>{},[t]),(0,q.jsx)(zk,{runtime:n,children:(0,q.jsx)(t,{children:(0,q.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=vO();return this.pendingThreadAdapters.set(e,n),sS(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,q.jsx)(dj,{detectorRef:t})}};function pj(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var mj=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),hj=class extends TT{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>mj(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=mj(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},gj=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),_j=new class extends yA{get error(){return gj}messages=[];composer=vA(gj,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(gj)}};function vj(e){return e}var yj=`__LOCALID_`,bj=e=>e||void 0,xj=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=tx(t.threadIdMap),a=tx(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??vj(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},Sj=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:tx(),threadData:tx()}),Cj=e=>{let t;do t=`${yj}${GE()}`;while(e.threadIdMap[t]);let n=vj(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:tx(e.threadIdMap,{[t]:n}),threadData:tx(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},wj=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},Tj=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),Ej=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},Dj=(e,t,n,r,i)=>{let a=vj(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=tx(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=tx(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},Oj=(e,t,n,r)=>{let i=Ej(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=tx(c.threadData);delete r[n],c.threadData=r;let i=tx(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},kj=(e,t,n)=>Oj(e,t,n,void 0),Aj=(e,t,n)=>Oj(e,t,`regular`,n),jj=class extends Error{[XT]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function Mj(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function Nj(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function Pj(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function Fj(e,t){return(e.latestExplicit?.order??0)<t.order}function Ij(e,t,n){let r=Mj(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function Lj(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),Nj(e,t,i))}function Rj(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,Nj(e,t,n),r}function zj(e,t){e.delete(t)}function Bj(e,t,n){let r=Mj(e,t);if(n&&r.pendingClaim===null&&Rj(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function Vj({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=Mj(e,t),s=Bj(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&Rj(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&Fj(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!Pj(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}Pj(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&Pj(o,s)&&await a(t);return}if(!Fj(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!Pj(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),Nj(e,t,o)}}var Hj=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),Uj=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),Wj=Sj(),Gj=class extends TT{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new hj(Wj);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,q.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=bO(e());return n==null?t:(0,q.jsx)(xO,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?gS:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=Tj(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,bj(i.nextCursor));let a=xj(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return wj({...r,isLoading:!1,loadError:void 0,cursor:bj(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=xj(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:bj(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new fj(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new ET(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new jj}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new jj}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:tx(),threadData:tx()};for(let e of r){let t=vj(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=xj(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=vj(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(Ej(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=Cj(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))if(!d.has(t.id))try{this._hookManager.stopThreadRuntime(t.id)}catch(e){console.error(`[assistant-ui] Thread runtime cleanup threw while stopping a thread`,e)}return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return Ej(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&pj(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||_j}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw Hj(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return Ej(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new jj;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=vj(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw Hj(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?rO(`create`,()=>this._startSwitchToNewThread(!1)):rO(`switch`,()=>this._startSwitchToThread(e,void 0,!1))}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=Cj(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw Hj(e,`initializing it`);if(t.status===`new`)throw Uj(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>Aj(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=Dj(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw Hj(e,`generating its title`);if(i.status===`new`)throw Uj(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter(aj);await Vj({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await oj(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=Ej(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw Hj(e,`renaming it`);if(i.status===`new`)throw Uj(e,i.status,`be renamed`);let a=Ij(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=Ej(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return Lj(this._titleStates,i.id,a,!0),o}catch(e){throw Lj(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw Hj(e,`updating its custom metadata`);if(i.status===`new`)throw Uj(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=Ej(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let n=this._switchTask,r=!n||n===t;r&&(n=this.switchToNewThread()),t=n;try{await n}catch(e){if(r&&this._switchTask===n)throw e}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw Hj(e,`archiving it`);if(r.status!==`regular`)throw Uj(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>kj(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw Hj(e,`unarchiving it`);if(r.status!==`archived`)throw Uj(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>kj(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw Hj(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw Uj(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>kj(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),zj(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw Hj(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw Uj(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new ET([]);__internal_RenderComponent=()=>{let e=fS();oS(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=YT(this.boundIdsStore),n=YT(this.providerStore),r=lT();return(t.length===0||t[0]===e)&&(0,q.jsxs)(xO,{adapters:this._runtimeAdapters,children:[(0,q.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,q.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},Kj=class extends IA{threads;constructor(e){super(),this.threads=new Gj(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},qj=e=>{let[t]=tS(()=>new Kj(e)),[n]=tS(()=>({generation:0}));dS(()=>{let e=++n.generation;return()=>queueMicrotask(()=>{n.generation===e&&t.threads.__internal_dispose()})},[t,n]),oS(()=>{t.threads.__internal_setOptions(e),t.threads.__internal_load()},[t,e]),oS(()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{t.threads.loadError!==void 0&&t.threads.reload()},n=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,n)}},[t]);let[r]=tS(()=>new FA(t));return r},Jj=e=>{let[t]=tS(()=>new ET(e.runtimeHook));sS(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=rS(e.initialThreadId),[r]=tS(()=>function(){return YT({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()}),i=cS(t=>e.onThreadIdChange?.(t)),a=iS(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(lT().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return qj(a)},Yj=e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text,...e.providerMetadata===void 0?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`image`:return{type:`image`,image:e.image,...e.filename==null?void 0:{filename:e.filename},...e.providerMetadata===void 0?void 0:{providerMetadata:e.providerMetadata}};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename==null?void 0:{filename:e.filename},...e.sourceType==null?void 0:{sourceType:e.sourceType},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`audio`:return{type:`audio`,audio:{data:e.audio.data,format:e.audio.format}};case`data`:return CO(e.data)||console.warn(`attachment data is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};default:throw Error(`Attachment part type not supported by aui/v0: ${t}`)}},Xj=e=>{if(e.role===`user`&&e.attachments.length!==0)return e.attachments.map(({id:e,type:t,name:n,contentType:r,status:i,content:a})=>({id:e,type:t,name:n,status:i,...r==null?void 0:{contentType:r},content:a.map(Yj)}))},Zj=e=>{if(e!==void 0)try{let t=JSON.stringify(e);return t===void 0?void 0:JSON.parse(t)}catch{return}},Qj=(e,t=0)=>{if(t>100||e===void 0||typeof e==`function`)return!1;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||!e||typeof e.toJSON==`function`)return!0;if((e instanceof Map||e instanceof Set)&&e.size>0)return!1;if(Array.isArray(e)){if(Reflect.ownKeys(e).length!==e.length+1)return!1;for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n)||!Qj(e[n],t+1))return!1;return!0}return Reflect.ownKeys(e).every(n=>typeof n==`string`&&Object.getOwnPropertyDescriptor(e,n)?.enumerable===!0&&Qj(e[n],t+1))},$j=e=>{try{return!Qj(e)}catch{return!0}};function eM(e){let t=e.status?.type===`running`?{type:`incomplete`,reason:`cancelled`}:e.status,n=Xj(e);return{role:e.role,content:e.content.map(e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text,...e.providerMetadata===void 0?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`reasoning`:return{type:`reasoning`,text:e.text,...e.unstable_summary===void 0?void 0:{unstable_summary:e.unstable_summary},...e.providerMetadata===void 0?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`source`:return e.sourceType===`url`?{type:`source`,sourceType:`url`,id:e.id,url:e.url,...e.title==null?void 0:{title:e.title},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}}:{type:`source`,sourceType:`document`,id:e.id,title:e.title,mediaType:e.mediaType,...e.filename==null?void 0:{filename:e.filename},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`tool-call`:{let t=Zj(e.result);e.result!==void 0&&(t===void 0||$j(e.result))&&console.warn(t===void 0?`tool-call result for ${e.toolCallId} cannot be serialized as JSON; omitted`:`tool-call result for ${e.toolCallId} loses data in JSON; persisted as its JSON form`);let n=Zj(e.artifact);e.artifact!==void 0&&n===void 0&&console.warn(`tool-call artifact is not JSON for ${e.toolCallId}`);let r=rD(e.unstable_interactions);return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,...JSON.stringify(e.args)===e.argsText?{args:e.args}:{argsText:e.argsText},...t===void 0?void 0:{result:t},...n===void 0?void 0:{artifact:n},...e.modelContent===void 0?void 0:{modelContent:e.modelContent},...e.providerMetadata===void 0?void 0:{providerMetadata:e.providerMetadata},...e.isPreliminary?{isPreliminary:!0}:void 0,...e.isError?{isError:!0}:void 0,...e.interrupt===void 0?void 0:{interrupt:{type:e.interrupt.type,payload:e.interrupt.payload}},...e.timing===void 0?void 0:{timing:e.timing},...e.mcp===void 0?void 0:{mcp:e.mcp},...e.approval?{approval:e.approval}:void 0,...e.parentId===void 0?void 0:{parentId:e.parentId},...e.messages===void 0?void 0:{messages:e.messages.map(aM)},...r===void 0?void 0:{unstable_interactions:r}}}case`image`:return{type:`image`,image:e.image,...e.filename==null?void 0:{filename:e.filename},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata}};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename==null?void 0:{filename:e.filename},...e.sourceType?{sourceType:e.sourceType}:void 0,...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata},...e.parentId===void 0?void 0:{parentId:e.parentId}};case`data`:return CO(e.data)||console.warn(`data part is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};case`audio`:return{type:`audio`,audio:{data:e.audio.data,format:e.audio.format}};case`generative-ui`:return{type:`generative-ui`,spec:e.spec,...e.id===void 0?void 0:{id:e.id},...e.parentId===void 0?void 0:{parentId:e.parentId}};default:throw Error(`Message part type not supported by aui/v0: ${t}`)}}),metadata:e.metadata,...t?{status:t}:void 0,...n?{attachments:n}:void 0}}var tM=(e,t,n)=>t.flatMap(t=>{if(!NO(e,t))return[];if(t.type!==`tool-call`||t.messages===void 0)return[t];let{messages:r,...i}=t;return!Array.isArray(r)||n>=100?[i]:[{...i,messages:r.flatMap(e=>{let t=rM(e,n+1);return t?[t]:[]})}]}),nM=e=>e.flatMap(e=>{let t=PO(e,e=>NO(`user`,e));return t?[t]:[]}),rM=(e,t)=>{if(!SO(e)||!TO(e.role)||!Array.isArray(e.content))return null;let{role:n}=e,r=tM(n,e.content,t);if(n===`system`&&r.length!==1)return null;let{attachments:i,createdAt:a,status:o,metadata:s,...c}=e,l=wO(a),u=SO(s)?n===`assistant`?{...s,steps:kO(s.steps)}:{...s,steps:void 0}:s;return{...c,...l?{createdAt:a}:void 0,...n===`assistant`&&DO(o)?{status:o}:void 0,...s===void 0?void 0:{metadata:u},content:r,...n===`user`&&Array.isArray(i)?{attachments:nM(i)}:void 0}};function iM(e){try{let t=rM(e.content,0);if(!t)throw Error(`stored row is not an aui/v0 message`);return{parentId:e.parent_id,message:oM({...t,id:e.id,createdAt:e.created_at},e.id)}}catch(t){return console.warn(`aui/v0: dropping unreadable message ${e.id}`,t),null}}var aM=e=>({...eM(e),id:e.id,createdAt:e.createdAt.toISOString()}),oM=(e,t)=>FD({...e,content:e.content.map((n,r)=>n.type!==`tool-call`||n.messages===void 0?n:{...n,messages:n.messages.map((i,a)=>oM({...i,createdAt:i.createdAt===void 0?e.createdAt:new Date(i.createdAt)},i.id??`${t}-${n.toolCallId}-${r}-${a}`))})},t,{type:`complete`,reason:`unknown`}),sM=class extends Error{constructor(e){super(e),this.name=`CloudResponseError`}},cM=(e,t)=>new sM(`Invalid Assistant Cloud response for "${e}": expected ${t}`),lM=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw cM(t,`an object`);return e},uM=(e,t)=>{if(!Array.isArray(e))throw cM(t,`an array`);return e},dM=(e,t)=>{if(typeof e!=`string`)throw cM(t,`a string`);return e},fM=(e,t)=>{if(typeof e!=`number`||!Number.isFinite(e))throw cM(t,`a number`);return e},pM=(e,t)=>e===null?null:fM(e,t),mM=(e,t,n)=>{let r=dM(e,t);if(!n.includes(r))throw cM(t,`one of ${n.map(e=>`"${e}"`).join(`, `)}`);return r},hM=(e,t)=>e===null?null:dM(e,t),gM=(e,t)=>{if(typeof e!=`boolean`)throw cM(t,`a boolean`);return e},_M=(e,t)=>{if(!Number.isInteger(e))throw cM(t,`an integer`);return e},vM=(e,t)=>{if(typeof e!=`string`)throw cM(t,`a canonical ISO timestamp`);let n=new Date(e);if(Number.isNaN(n.getTime())||n.toISOString()!==e)throw cM(t,`a canonical ISO timestamp`);return n},yM=(e,t)=>lM(e,t),bM=3e4,xM=async(e,t)=>{let n=new AbortController,r=!1,i=setTimeout(()=>{r=!0,n.abort()},bM);try{return await t(n.signal)}catch(t){throw r?Error(`Assistant Cloud ${e} timed out after ${bM}ms`,{cause:t}):t}finally{clearTimeout(i)}},SM=e=>{try{let t=e.split(`.`)[1];if(!t)throw Error(`Invalid JWT format`);let n=t.replace(/-/g,`+`).replace(/_/g,`/`);for(;n.length%4!=0;)n+=`=`;let r=atob(n),i=JSON.parse(r).exp;if(!i||typeof i!=`number`)throw Error(`JWT does not contain a valid "exp" field`);return i*1e3}catch(e){throw Error(`Unable to determine the token expiry: ${e}`)}},CM=(e,t)=>{let n=dM(e,t);if(n.length===0)throw new sM(`Invalid Assistant Cloud response for "${t}": expected a non-empty string`);return n},wM=(e,t)=>{let n=lM(e,t);return{token:CM(n.token,`${t}.token`),expires_at:CM(n.expires_at,`${t}.expires_at`)}},TM=async(e,t)=>{let n;try{n=await e.json()}catch{throw new sM(`Invalid Assistant Cloud response for "${t}": expected valid JSON`)}let r=lM(n,t);return{data:r,accessToken:CM(r.access_token,`${t}.access_token`)}},EM=class{strategy=`jwt`;cachedToken=null;tokenExpiry=null;tokenRequest=null;#e;constructor(e){this.#e=e}async getAuthHeaders(){let e=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-e>3e4)return{Authorization:`Bearer ${this.cachedToken}`};this.tokenRequest||=this.fetchAuthHeaders();let t=this.tokenRequest;try{return await t}finally{this.tokenRequest===t&&(this.tokenRequest=null)}}async fetchAuthHeaders(){let e=await this.#e();if(!e)return!1;let t=SM(e);return this.cachedToken=e,this.tokenExpiry=t,{Authorization:`Bearer ${e}`}}readAuthHeaders(e){let t=e.get(`Authorization`);if(!t)return;let[n,r]=t.split(` `);if(n!==`Bearer`||!r)throw Error(`Invalid auth header received`);let i=SM(r);this.cachedToken=r,this.tokenExpiry=i}},DM=class{strategy=`api-key`;#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async getAuthHeaders(){return{Authorization:`Bearer ${this.#e}`,"Aui-User-Id":this.#t,"Aui-Workspace-Id":this.#n}}readAuthHeaders(){}},OM=`aui:refresh_token`,kM=e=>`${OM}:${e}`,AM=e=>{try{e.removeItem(OM)}catch{}},jM=()=>{if(!(`localStorage`in globalThis))return null;try{return globalThis.localStorage}catch{return null}},MM=e=>{let t=jM();if(t)try{let n=kM(e),r=t.getItem(n);if(r)return AM(t),JSON.parse(r);let i=t.getItem(OM);if(!i)return;let a;try{a=JSON.parse(i)}catch{AM(t);return}return t.setItem(n,i),AM(t),a}catch{return}},NM=e=>!e||!e.endsWith(`/`)?e:e.slice(0,-1),PM=(e,t)=>{let n=jM();if(n)try{n.setItem(kM(e),JSON.stringify(t))}catch{}},FM=e=>{let t=jM();if(t)try{t.removeItem(kM(e))}catch{}},IM=new WeakMap,LM=()=>`navigator`in globalThis?globalThis.navigator?.locks??null:null,RM=e=>`assistant-cloud:anonymous-auth:${e}`,zM=(e,t)=>{let n=jM();if(!n)return t();let r=IM.get(n);r||(r=new Map,IM.set(n,r));let i=r.get(e);if(i)return i;let a=LM(),o=(a?a.request(RM(e),t):t()).finally(()=>{r.get(e)===o&&r.delete(e)});return r.set(e,o),o},BM=class{strategy=`anon`;baseUrl;jwtStrategy;constructor(e){this.baseUrl=e;let t=async()=>{let e=Date.now(),t=MM(this.baseUrl);if(t){if(new Date(t.expires_at).getTime()-e>3e4){let e=await xM(`refresh token request`,async e=>{let n=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:t.token}),signal:e});if(n.ok){let{data:e,accessToken:t}=await TM(n,`refresh auth token response`);return e.refresh_token!=null&&PM(this.baseUrl,wM(e.refresh_token,`refresh auth token response.refresh_token`)),t}if(n.status===429||n.status>=500)throw Error(`Assistant Cloud token refresh failed with status ${n.status}`);return null});if(e!==null)return e}else FM(this.baseUrl)}return xM(`anonymous token request`,async e=>{let t=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:`POST`,signal:e});if(!t.ok)return null;let{data:n,accessToken:r}=await TM(t,`anonymous auth token response`);return PM(this.baseUrl,wM(n.refresh_token,`anonymous auth token response.refresh_token`)),r})};this.jwtStrategy=new EM(()=>zM(this.baseUrl,t))}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(e){this.jwtStrategy.readAuthHeaders(e)}},VM=`0.2.4`,HM=class extends Error{status;code;details;constructor(e,t,n,r){super(e),this.status=t,n!==void 0&&(this.code=n),r!==void 0&&(this.details=r),this.name=`CloudAPIError`}},UM=/^[\x21-\x7e]+$/,WM=class{_auth;_baseUrl;registerSdk;sdkHeader;constructor(e){let t=new Map;if(this.registerSdk=e=>{let n=e.name.trim(),r=e.version.trim();!UM.test(n)||!UM.test(r)||t.set(`${n}/${r}`,{name:n,version:r})},this.sdkHeader=()=>[`assistant-cloud/${VM}`,...Array.from(t.values(),({name:e,version:t})=>`${e}/${t}`)].join(` `),`authToken`in e)this._baseUrl=NM(e.baseUrl),this._auth=new EM(e.authToken);else if(`apiKey`in e)this._baseUrl=NM(e.baseUrl??`https://backend.assistant-api.com`),this._auth=new DM(e.apiKey,e.userId,e.workspaceId);else if(`anonymous`in e)this._baseUrl=NM(e.baseUrl),this._auth=new BM(this._baseUrl);else throw Error(`Invalid configuration: Must provide authToken, apiKey, or anonymous configuration`)}async initializeAuth(){return!!await this._auth.getAuthHeaders()}async makeRawRequest(e,t={}){let n=await this._auth.getAuthHeaders();if(!n)throw Error(`Authorization failed`);let r={...n,...t.headers,"Content-Type":`application/json`,"Aui-Sdk":this.sdkHeader()},i=new URLSearchParams;if(t.query)for(let[e,n]of Object.entries(t.query))n!==!1&&(n===!0?i.set(e,`true`):i.set(e,n.toString()));let a=new URL(`${this._baseUrl}/v1${e}`);a.search=i.toString();let o=await fetch(a,{method:t.method??`GET`,headers:r,body:t.body?JSON.stringify(t.body):null,...t.keepalive?{keepalive:!0}:{}});if(this._auth.readAuthHeaders(o.headers),!o.ok){let e=await o.text(),t,n,r;try{let i=JSON.parse(e);if(typeof i==`object`&&i&&!Array.isArray(i)){let e=i;typeof e.message==`string`&&e.message.length>0&&(t=e.message),typeof e.error==`string`&&(n=e.error,r={...e},delete r.error)}}catch{}throw new HM(t??`Request failed with status ${o.status}, ${e}`,o.status,n,r)}return o}async makeRequest(e,t={}){let n=await this.makeRawRequest(e,t);if(n.status===204||n.headers.get(`content-length`)===`0`)return;let r=await n.text();if(r.trim()!==``)return JSON.parse(r)}},GM=20,KM=50,qM=2e3,JM=[250,1e3],YM=new WeakMap,XM=e=>{YM.get(e)?.()},ZM=class{buffer=[];timer;flushing;retryTimer;resolveRetryDelay;bestEffortRequested=!1;generation=0;cloud;isEnabled;listening=!1;constructor(e,t){this.cloud=e,this.isEnabled=t,YM.set(this,()=>this.clearPending())}track(e){if(this.isEnabled()){if(this.listen(),this.buffer.push(QM(e)),this.buffer.length>=GM){this.flush(!0);return}this.scheduleFlush()}}listen(){this.listening||typeof window>`u`||typeof document>`u`||(this.listening=!0,window.addEventListener(`pagehide`,this.flushBestEffort),document.addEventListener(`visibilitychange`,this.onVisibilityChange))}unlisten(){this.listening&&(this.listening=!1,window.removeEventListener(`pagehide`,this.flushBestEffort),document.removeEventListener(`visibilitychange`,this.onVisibilityChange))}dispose(){this.unlisten(),this.clearFlushTimer(),this.flushBestEffort()}clearPending(){this.generation++,this.buffer=[],this.clearFlushTimer(),this.interruptRetryDelay(),this.unlisten()}onVisibilityChange=()=>{document.visibilityState===`hidden`&&this.flushBestEffort()};flushBestEffort=()=>(this.flushing&&(this.bestEffortRequested=!0,this.interruptRetryDelay()),this.flush(!1));flush=async e=>{if(!this.isEnabled()){this.clearPending();return}if(this.flushing)return this.flushing;this.clearFlushTimer();let t=this.flushPending(e);return this.flushing=t,t.then(()=>{this.flushing===t&&(this.flushing=void 0,this.bestEffortRequested=!1,this.buffer.length===0?(this.clearFlushTimer(),this.unlisten()):this.flush(!0))}),t};async flushPending(e){for(;this.buffer.length>0;){if(!this.isEnabled()){this.buffer=[];return}let t=this.buffer.splice(0,KM),n=this.generation;for(let r=0;;r++)try{if(await this.cloud.makeRequest(`/events`,{method:`POST`,body:{events:t},keepalive:!0}),n!==this.generation)return;break}catch{if(n!==this.generation)return;let t=e&&!this.bestEffortRequested?JM[r]:void 0;if(t===void 0)break;if(await this.waitForRetry(t),n!==this.generation)return;if(!this.isEnabled())return this.clearPending();if(this.bestEffortRequested)break}}}waitForRetry(e){return new Promise(t=>{let n=()=>{this.retryTimer=void 0,this.resolveRetryDelay=void 0,t()};this.resolveRetryDelay=n,this.retryTimer=setTimeout(n,e)})}interruptRetryDelay(){this.retryTimer!==void 0&&clearTimeout(this.retryTimer),this.resolveRetryDelay?.()}scheduleFlush(){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush(!0)},qM))}clearFlushTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}},QM=e=>{let t=tN(e.props);return{kind:e.kind,...$M(e.thread_id)?{thread_id:e.thread_id}:{},...$M(e.message_id)?{message_id:e.message_id}:{},...$M(e.run_id)?{run_id:e.run_id}:{},...eN(e.value)?{value:e.value}:{},...t?{props:t}:{}}},$M=e=>e&&e.length<=48?e:void 0,eN=e=>e!==void 0&&Number.isInteger(e)&&e>=0,tN=e=>{if(!e)return;let t=Object.entries(e);if(t.some(([,e])=>typeof e==`string`&&e.length>256||typeof e==`number`&&!Number.isFinite(e)||typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`))return;let n=Object.fromEntries(t);return new TextEncoder().encode(JSON.stringify(n)).byteLength<=1024?n:void 0},nN=[`numeric`,`categorical`,`boolean`],rN=class{cloud;constructor(e){this.cloud=e}async create(e){let t=lM(await this.cloud.makeRequest(`/scores`,{method:`POST`,body:e}),`score response`);return{score_id:dM(t.score_id,`score response.score_id`),name:dM(t.name,`score response.name`),data_type:mM(t.data_type,`score response.data_type`,nN),value:pM(t.value,`score response.value`),string_value:hM(t.string_value,`score response.string_value`)}}},iN=class{cloud;constructor(e){this.cloud=e}async create(){return{token:dM(lM(await this.cloud.makeRequest(`/auth/tokens`,{method:`POST`}),`auth token response`).token,`token`)}}},aN=[`positive`,`negative`],oN=(e,t)=>{let n=lM(e,t);return{id:dM(n.id,`${t}.id`),parent_id:hM(n.parent_id,`${t}.parent_id`),height:_M(n.height,`${t}.height`),created_at:vM(n.created_at,`${t}.created_at`),updated_at:vM(n.updated_at,`${t}.updated_at`),format:dM(n.format,`${t}.format`),content:yM(n.content,`${t}.content`),external_id:hM(n.external_id??null,`${t}.external_id`)}},sN=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:uM(lM(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{query:t}),`thread message list response`).messages,`messages`).map((e,t)=>oN(e,`messages[${t}]`))}}async create(e,t){return{message_id:dM(lM(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{method:`POST`,body:{parent_id:t.parent_id,format:t.format,content:t.content,...t.external_id===void 0?void 0:{external_id:t.external_id},...t.parent_external_id===void 0?void 0:{parent_external_id:t.parent_external_id}}}),`thread message create response`).message_id,`message_id`)}}async update(e,t,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}`,{method:`PUT`,body:n})}async feedback(e,t,n){let r=n.comment?.trim(),i=lM(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}/feedback`,{method:`POST`,body:{type:n.type,...r?{comment:r}:void 0}}),`thread message feedback response`);return{feedback_id:dM(i.feedback_id,`feedback_id`),type:mM(i.type,`type`,aN),...`comment`in i?{comment:hM(i.comment,`comment`)}:void 0}}},cN=(e,t)=>{let n=lM(e,t);return{title:hM(n.title,`${t}.title`)??``,last_message_at:vM(n.last_message_at,`${t}.last_message_at`),metadata:n.metadata,external_id:hM(n.external_id,`${t}.external_id`),id:dM(n.id,`${t}.id`),project_id:dM(n.project_id,`${t}.project_id`),created_at:vM(n.created_at,`${t}.created_at`),updated_at:vM(n.updated_at,`${t}.updated_at`),workspace_id:dM(n.workspace_id,`${t}.workspace_id`),is_archived:gM(n.is_archived,`${t}.is_archived`)}},lN=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new sN(e)}async list(e){let t=e?.is_archived===void 0?e:{...e,is_archived:String(e.is_archived)};return{threads:uM(lM(await this.cloud.makeRequest(`/threads`,{query:t}),`thread list response`).threads,`threads`).map((e,t)=>cN(e,`threads[${t}]`))}}async get(e){return cN(lM(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`),`thread response`).thread,`thread`)}async create(e){return{thread_id:dM(lM(await this.cloud.makeRequest(`/threads`,{method:`POST`,body:e}),`thread create response`).thread_id,`thread_id`)}}async update(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`PUT`,body:t})}async claim(e){return{moved:_M(lM(await this.cloud.makeRequest(`/threads/claim`,{method:`POST`,body:e}),`thread claim response`).moved,`moved`)}}async delete(e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`DELETE`})}},uN=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:uM(lM(await this.cloud.makeRequest(`/projects/threads/${encodeURIComponent(e)}/messages`,{query:t}),`project thread message list response`).messages,`messages`).map((e,t)=>oN(e,`messages[${t}]`))}}},dN=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new uN(e)}async list(e){return{threads:uM(lM(await this.cloud.makeRequest(`/projects/threads`,{query:{...e,...e?.is_archived===void 0?{}:{is_archived:String(e.is_archived)}}}),`project thread list response`).threads,`threads`).map((e,t)=>cN(e,`threads[${t}]`))}}},fN=class{threads;constructor(e){this.threads=new dN(e)}},pN=class{cloud;constructor(e){this.cloud=e}__internal_getAssistantOptions(e){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,protocol:`ui-message-stream`,headers:async()=>{let e=await this.cloud._auth.getAuthHeaders();if(!e)throw Error(`Authorization failed`);return{...e,Accept:`text/plain`,"Aui-Sdk":this.cloud.sdkHeader()}},body:async t=>{let n=t?.threadId;if(n===void 0)throw Error(`Assistant Cloud runs need a thread; the thread list adapter has not assigned a remote id to this thread yet.`);return{assistant_id:e,response_format:`vercel-ai-data-stream/v1`,thread_id:n}}}}async stream(e){let t=await this.cloud.makeRawRequest(`/runs/stream`,{method:`POST`,headers:{Accept:`text/plain`},body:e});if(!t.body)throw new sM(`Invalid Assistant Cloud response for "run stream": expected a response body`);let n=t.headers.get(`content-type`);if(n?.split(`;`,1)[0]?.trim().toLowerCase()!==`text/plain`)throw await t.body.cancel().catch(()=>void 0),new sM(`Invalid Assistant Cloud response for "run stream": expected a "text/plain" content type, received ${n?`"${n}"`:`no Content-Type header`}`);return FO.fromResponse(t,new uk)}async report(e){return{run_id:dM(lM(await this.cloud.makeRequest(`/runs`,{method:`POST`,body:e}),`run report response`).run_id,`run_id`)}}},mN=class{cloud;constructor(e){this.cloud=e}async pdfToImages(e){let t=lM(await this.cloud.makeRequest(`/files/pdf-to-images`,{method:`POST`,body:e}),`PDF conversion response`);return{success:gM(t.success,`PDF conversion response.success`),urls:uM(t.urls,`PDF conversion response.urls`).map((e,t)=>dM(e,`PDF conversion response.urls[${t}]`)),message:dM(t.message,`PDF conversion response.message`)}}async generatePresignedUploadUrl(e){let t=lM(await this.cloud.makeRequest(`/files/attachments/generate-presigned-upload-url`,{method:`POST`,body:e}),`presigned upload response`);return{success:gM(t.success,`presigned upload response.success`),signedUrl:dM(t.signedUrl,`presigned upload response.signedUrl`),expiresAt:dM(t.expiresAt,`presigned upload response.expiresAt`),publicUrl:dM(t.publicUrl,`presigned upload response.publicUrl`),...`key`in t?{key:dM(t.key,`presigned upload response.key`)}:{}}}async generatePresignedDownloadUrl(e){let t=lM(await this.cloud.makeRequest(`/files/attachments/generate-presigned-download-url`,{method:`POST`,body:e}),`presigned download response`);return{signedUrl:dM(t.signedUrl,`presigned download response.signedUrl`),expiresAt:dM(t.expiresAt,`presigned download response.expiresAt`),key:dM(t.key,`presigned download response.key`)}}},hN=class{threads;projects;auth;runs;files;events;scores;telemetry;registerSdk;constructor(e){let t=new WM(e);this.registerSdk=t.registerSdk;let n=e.telemetry,r=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{...n,enabled:n.enabled!==!1};this.telemetry=new Proxy(r,{set:(e,t,n)=>{let r=Reflect.set(e,t,n);return(t===`enabled`||t===`events`)&&(e.enabled===!1||e.events===!1)&&XM(this.events),r}}),this.threads=new lN(t),this.projects=new fN(t),this.auth={tokens:new iN(t)},this.runs=new pN(t),this.files=new mN(t),this.events=new ZM(t,()=>this.telemetry.enabled!==!1&&this.telemetry.events!==!1),this.scores=new rN(t)}},gN=256;function _N(e,t,n){e.delete(t),e.set(t,n),e.size>gN&&e.delete(e.keys().next().value)}function vN(e,t){e.delete(t),e.add(t),e.size>gN&&e.delete(e.values().next().value)}var yN=(e,t)=>({thread_id:e,...t===void 0?void 0:{message_id:t}}),bN=class{runStartedAt=new Map;runEndedAt=new Map;shownErrors=new Set;shownSuggestions=new Set;getCloud;resolveIds;constructor(e,t=yN){this.getCloud=typeof e==`function`?e:()=>e,this.resolveIds=t}runStarted(e){this.runStartedAt.set(e,Date.now()),this.shownErrors.delete(e)}runEnded(e){this.runStartedAt.delete(e),_N(this.runEndedAt,e,Date.now())}runStopped(e){let t=this.runStartedAt.get(e);if(t===void 0)return;let n=Date.now();this.runStartedAt.delete(e),_N(this.runEndedAt,e,n),this.track(`run_stopped`,e,void 0,{value:Math.max(0,n-t)})}messageSent(e,t){let n=this.runEndedAt.get(e);this.track(`message_sent`,e,t.messageId,{props:{chars:t.chars,attachments:t.attachments},...n===void 0?void 0:{value:Math.max(0,Date.now()-n)}},{awaitThread:!0})}messageEdited(e,t){this.track(`message_edited`,e,t.messageId,{props:{chars:t.chars}})}messageRegenerated(e,t){this.track(`message_regenerated`,e,t)}errorShown(e,t){this.shownErrors.has(e)||(vN(this.shownErrors,e),this.track(`error_shown`,e,t.messageId,{props:{reason:t.reason}}))}suggestionsShown(e,t){this.shownSuggestions.has(e)||(vN(this.shownSuggestions,e),this.track(`suggestions_shown`,e,void 0,{value:t}))}suggestionClicked(e){this.track(`suggestion_clicked`,e)}attachmentAdded(e,t){this.track(`attachment_added`,e,t.messageId,{...t.contentType?{props:{type:t.contentType}}:void 0})}attachmentFailed(e,t){this.track(`attachment_failed`,e,t.messageId,{...t.contentType?{props:{type:t.contentType}}:void 0})}voiceStarted(e){this.track(`voice_started`,e)}speechStarted(e,t){this.track(`speech_started`,e,t)}branchSwitched(e,t){this.track(`branch_switched`,e,t)}messageCopied(e,t){this.track(`message_copied`,e,t)}toolApproved(e,t,n,r){this.track(`tool_approved`,e,t,{props:{toolCallId:n,toolName:r}})}toolRejected(e,t,n,r){this.track(`tool_rejected`,e,t,{props:{toolCallId:n,toolName:r}})}threadSwitched(e){this.track(`thread_switched`,e)}track(e,t,n,r={},i={awaitThread:!1}){Promise.resolve().then(()=>this.resolveIds(t,n,i)).then(t=>{t&&(e===`thread_switched`&&!t.thread_id||this.getCloud().events.track({kind:e,...r,...t}))}).catch(()=>{})}},xN=200,SN=class{idMapping=new Map;getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}async append(e,t,n,r,i){let a=this.getCloud(),o=this.idMapping.get(t);if(o instanceof Promise){await o;return}let s=(async()=>{let t=n?this.idMapping.get(n):void 0,o=n?await t??n:null,{message_id:s}=await a.threads.messages.create(e,{parent_id:o,format:r,content:i});return s})();this.idMapping.set(t,s);try{let e=await s;this.idMapping.get(t)===s&&this.idMapping.set(t,e)}catch(e){throw this.idMapping.get(t)===s&&this.idMapping.delete(t),e}}async update(e,t,n,r){let i=this.getCloud(),a=await this.getRemoteId(t);if(!a){console.warn(`Skipping update for message ${t}: no remote id is mapped.`);return}await i.threads.messages.update(e,a,{content:r})}isPersisted(e){return this.idMapping.has(e)}async getRemoteId(e){let t=this.idMapping.get(e);if(t)return t}getResolvedRemoteId(e){let t=this.idMapping.get(e);return typeof t==`string`?t:void 0}record(e,t){this.idMapping.set(e,t)}async load(e,t){let n=this.idMapping,r=this.getCloud(),i=[],a=new Set,o;for(;;){let n=await r.threads.messages.list(e,{...t?{format:t}:void 0,limit:xN,...o?{after:o}:void 0}),s=n.messages.at(-1);if(!s)break;let c=n.messages.filter(e=>!a.has(e.id));if(c.length===0)break;for(let e of c)a.add(e.id);if(i.push(...c),n.messages.length<xN)break;o=s.id}if(this.idMapping===n)for(let e of i){let t=n.get(e.id);t===void 0?n.set(e.id,e.id):t instanceof Promise&&t.catch(()=>{let r=n.get(e.id);(r===void 0||r===t)&&n.set(e.id,e.id)})}return i}reset(){this.idMapping=new Map}},CN=5e4,wN=/^[A-Za-z0-9+/]+={0,2}$/;function TN(e,t=`completed`){if(e.isError)return{status:`error`};if(e.isAbort)return{status:`incomplete`,outcome:`aborted`};if(e.isDisconnect)return{status:`incomplete`,outcome:`disconnected`};switch(e.finishReason){case`length`:return{status:`incomplete`,outcome:`length`};case`content-filter`:case`content_filter`:return{status:`incomplete`,outcome:`content_filter`};case`cancelled`:return{status:`incomplete`,outcome:`aborted`};case`error`:return{status:`error`};default:return{status:e.finishReason===void 0?t:`completed`}}}var EN=64,DN=2048;function ON(e){if(e==null)return{};let t=typeof e==`object`?e:void 0,n=typeof e==`string`?e:typeof t?.message==`string`?t.message:void 0,r=typeof t?.code==`string`?t.code:typeof t?.name==`string`&&t.name!==`Error`?t.name:void 0;return{...n?{error:n.slice(0,DN)}:void 0,...r?{errorCode:r.slice(0,EN)}:void 0}}function kN(e){return e.length<=CN?e:e.slice(0,CN)}function AN(e){if(e!=null)try{return kN(JSON.stringify(e))}catch{return}}var jN=e=>(e.length*3/4/1024).toFixed(1),MN=e=>{if(typeof e!=`string`)return!1;let t=e.slice(0,200);return t.length>0&&t.length%4==0&&wN.test(t)};function NN(e){if(!e||typeof e!=`object`)return e;let t=e;if((t.type===`image`||t.type===`audio`)&&MN(t.data))return{...t,data:`[${String(t.type)}: ${jN(t.data)}KB]`};if(t.type===`resource`&&t.resource&&typeof t.resource==`object`){let e=t.resource;if(MN(e.blob))return{...t,resource:{...e,blob:`[resource: ${jN(e.blob)}KB]`}}}return e}function PN(e){if(e!=null){try{let t=typeof e==`string`?JSON.parse(e):e;if(Array.isArray(t))return kN(JSON.stringify(t.map(NN)));if(typeof t==`object`){let e=t.content;if(Array.isArray(e))return kN(JSON.stringify({...t,content:e.map(NN)}))}}catch{}return AN(e)}}function FN(e){let{toolName:t,toolCallId:n,args:r,argsText:i,result:a,toolSource:o}=e,s={tool_name:t,tool_call_id:n},c=i==null?AN(r):kN(i);c!==void 0&&(s.tool_args=c);let l=o===`mcp`?PN(a):AN(a);return l!==void 0&&(s.tool_result=l),o&&(s.tool_source=o),s}function IN(e){if(!e)return;if(typeof e.modelId==`string`)return e.modelId;let t=e.custom;if(typeof t?.modelId==`string`)return t.modelId;let n=e.steps;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let t=e.response;if(!t||typeof t!=`object`)continue;let n=t.modelId;if(typeof n==`string`)return n}}function LN(e,t){if(!t)return;let n=WN(t);n&&(n.inputTokens!==void 0&&(e.input_tokens=n.inputTokens),n.outputTokens!==void 0&&(e.output_tokens=n.outputTokens),n.reasoningTokens!==void 0&&(e.reasoning_tokens=n.reasoningTokens),n.cachedInputTokens!==void 0&&(e.cached_input_tokens=n.cachedInputTokens))}function RN(e){let t={},n=e.usage?WN(e.usage):void 0;return n?.inputTokens!==void 0&&(t.input_tokens=n.inputTokens),n?.outputTokens!==void 0&&(t.output_tokens=n.outputTokens),n?.reasoningTokens!==void 0&&(t.reasoning_tokens=n.reasoningTokens),n?.cachedInputTokens!==void 0&&(t.cached_input_tokens=n.cachedInputTokens),e.toolCalls!==void 0&&(t.tool_calls=e.toolCalls),e.startMs!==void 0&&(t.start_ms=e.startMs),e.endMs!==void 0&&(t.end_ms=e.endMs),e.finishReason!==void 0&&(t.finish_reason=e.finishReason.slice(0,32)),e.input!==void 0&&(t.input=kN(e.input)),t}function zN(e){if(!e)return;let t=[],n=new Set;for(let r of e){let e=r.trim().slice(0,64).trim();if(!(!e||n.has(e))&&(n.add(e),t.push(e),t.length===20))break}return t.length>0?t:void 0}function BN(e){if(!(e===void 0||!Number.isFinite(e)))return Math.max(0,Math.round(e))}function VN(e){if(!(e===void 0||!Number.isFinite(e)||e<0))return e}function HN(e,t){if(!t)return;let n={},r=VN(t.input);r!==void 0&&(n.input=r);let i=VN(t.inputCachedTokens);i!==void 0&&(n.input_cached_tokens=i);let a=VN(t.output);a!==void 0&&(n.output=a);let o=VN(t.total);o!==void 0&&(n.total=o),Object.keys(n).length>0&&(e.cost_details=n)}function UN(e){let t={thread_id:e.threadId,status:e.status},n=e.traceId?.toLowerCase();n&&/^[0-9a-f]{32}$/.test(n)&&(t.trace_id=n);let r=e.rootSpanId?.toLowerCase();r&&/^[0-9a-f]{16}$/.test(r)&&(t.root_span_id=r),e.outcome!==void 0&&(t.outcome_type=e.outcome),e.errorCode!==void 0&&(t.error_code=e.errorCode),e.error!==void 0&&(t.error=e.error),e.messageId!==void 0&&(t.message_id=e.messageId),e.modelId!==void 0&&(t.model_id=e.modelId),e.provider!==void 0&&(t.provider=e.provider,t.provider_type=e.provider),LN(t,e.usage),e.steps===void 0?e.totalSteps!==void 0&&(t.total_steps=e.totalSteps):(t.steps=e.steps.map(RN),t.total_steps=e.steps.length),e.toolCalls!==void 0&&(t.tool_calls=e.toolCalls);let i=BN(e.durationMs);i!==void 0&&(t.duration_ms=i);let a=BN(e.firstTokenMs);a!==void 0&&(t.first_token_ms=a);let o=VN(e.costUsd);o!==void 0&&(t.cost_usd=o),HN(t,e.costDetails),e.outputText!==void 0&&(t.output_text=kN(e.outputText)),e.attributes!==void 0&&(t.attributes=e.attributes),e.metadata!==void 0&&(t.metadata=e.metadata),e.telemetry?.environment!==void 0&&(t.environment=e.telemetry.environment),e.telemetry?.release!==void 0&&(t.release=e.telemetry.release);let s=zN(e.telemetry?.tags);return s!==void 0&&(t.tags=s),t}function WN(e){let t=e.inputTokens??e.promptTokens,n=e.outputTokens??e.completionTokens,r=e.reasoningTokens??e.outputTokenDetails?.reasoningTokens,i=e.cachedInputTokens??e.inputTokenDetails?.cacheReadTokens;if(t!=null||n!=null||r!=null||i!=null)return{...t==null?void 0:{inputTokens:t},...n==null?void 0:{outputTokens:n},...r==null?void 0:{reasoningTokens:r},...i==null?void 0:{cachedInputTokens:i}}}var GN=class{reported=new Set;getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}async report(e,t){let n;try{let r=this.getCloud();if(!r.telemetry.enabled||t!==void 0&&this.reported.has(t))return;let i=UN({...e,telemetry:r.telemetry}),{beforeReport:a}=r.telemetry,o=a?a(i):i;if(!o)return;t!==void 0&&(this.reported.add(t),n=t),await r.runs.report(o)}catch(e){n!==void 0&&KN(e)&&this.reported.delete(n);return}}},KN=e=>e instanceof HM&&e.status===429,qN=(e,t)=>({append:async(n,r)=>{let i=t.getId(r.message),a=t.encode(r);return e.append(n,i,r.parentId,t.format,a)},update:e.update?async(n,r,i)=>{let a=t.encode(r);return e.update(n,i,t.format,a)}:void 0,load:async n=>({messages:(await e.load(n,t.format)).filter(e=>e.format===t.format).map(e=>t.decode({id:e.id,parent_id:e.parent_id,format:e.format,content:e.content})).reverse()}),isPersisted:t=>e.isPersisted(t)});function JN(e){return typeof e==`object`&&!!e}function YN(e){return JN(e)&&typeof e.type==`string`}function XN(e){if(typeof e.toolCallId!=`string`)return;let t=e.type.startsWith(`tool-`);if(!t&&e.type!==`dynamic-tool`)return;let n=t?e.type.slice(5):typeof e.toolName==`string`?e.toolName:void 0;if(n)return FN({toolName:n,toolCallId:e.toolCallId,args:e.input??e.args,result:e.output??e.result,toolSource:t?`frontend`:`mcp`})}function ZN(e,t){let n=JN(t?.samplingCalls)?t.samplingCalls:void 0;if(n)for(let t of e){let e=n[t.tool_call_id];Array.isArray(e)&&e.length>0&&(t.sampling_calls=e)}}function QN(e){let t=e?.steps;return Array.isArray(t)?t.map(e=>JN(e)&&JN(e.usage)?e.usage:void 0):[]}function $N(e){let t={};for(let n of e)n.inputTokens!=null&&(t.inputTokens=(t.inputTokens??0)+n.inputTokens),n.outputTokens!=null&&(t.outputTokens=(t.outputTokens??0)+n.outputTokens),n.reasoningTokens!=null&&(t.reasoningTokens=(t.reasoningTokens??0)+n.reasoningTokens),n.cachedInputTokens!=null&&(t.cachedInputTokens=(t.cachedInputTokens??0)+n.cachedInputTokens);return t}function eP(e){let t=JN(e?.usage)?WN(e.usage):void 0;if(t)return t;let n=QN(e).flatMap(e=>{let t=e?WN(e):void 0;return t?[t]:[]});return n.length>0?$N(n):void 0}function tP(e){let t=[],n=[],r=[],i=[],a;for(let o of e){if(o.role!==`assistant`)continue;a=o;let e=JN(o.metadata)?o.metadata:void 0,s=QN(e),c=[],l,u=-1;for(let e of o.parts){if(!YN(e))continue;if(e.type===`step-start`){u+=1;let e=s[u];l=e?{usage:e}:{},r.push(l);continue}if(e.type===`text`&&typeof e.text==`string`&&e.text){t.push(e.text);continue}let i=XN(e);i&&(n.push(i),c.push(i),l&&(l.toolCalls=[...l.toolCalls??[],i],l.finishReason=`tool-calls`))}ZN(c,e);let d=eP(e);d&&i.push(d)}if(!a)return null;let o=JN(a.metadata)?a.metadata:void 0,s=i.length>0?$N(i):void 0,c=IN(o),l=t.length>0||n.length>0;return{...a.id===void 0?void 0:{assistantMessageId:a.id},status:l?`completed`:`incomplete`,...n.length>0?{toolCalls:n}:void 0,...r.length>0?{steps:r,totalSteps:r.length}:void 0,...t.length>0?{outputText:kN(t.join(``))}:void 0,...s?{usage:s}:void 0,...c?{modelId:c}:void 0,...o?{metadata:o}:void 0}}var nP=new WeakMap,rP=new WeakMap,iP=e=>{let t=rP.get(e);return t||(t={settled:new Set,reported:new Set},rP.set(e,t)),t},aP=e=>e.role===`assistant`&&(e.status.type===`complete`||e.status.type===`incomplete`),oP=(e,t)=>{let n=rD(t);if(!e)return n;if(!n)return e;let r=Math.max(e.omitted??0,n.omitted??0),i={entries:e.entries,...r?{omitted:r}:void 0};for(let e of n.entries)i.entries.some(t=>t.type===e.type&&t.occurredAt===e.occurredAt&&pk(t.payload,e.payload))||(i=tD(i,e));return i},sP=new Set([401,403,408,429]),cP=new Set([402,404]),lP=e=>e instanceof HM&&e.status>=400&&e.status<500&&!sP.has(e.status),uP=class{cloudRef;getAui;runReporter;copiedThreads=new Map;copyQueues=new Map;constructor(e,t){this.cloudRef=e,this.getAui=t,this.runReporter=new GN(()=>this.cloudRef.current)}get aui(){return this.getAui()}getCloud(){return this.cloudRef.current}ownsThread(e){let t=this.aui.threadListItem;if(!t.source)return!1;let{id:n,remoteId:r}=t.getState();return n===e||r===e}getPersistence(e=this.aui.threadListItem){let t=RC(e);return nP.has(t)||nP.set(t,new SN(()=>this.cloudRef.current)),nP.get(t)}get _persistence(){return this.getPersistence()}async resolveEngagementEventIds(e,t,n){let r=this.getThreadListItem(e);if(!r)return;let i=r.getState().remoteId;!i&&n?.awaitThread&&(i=await r.initialize().then(e=>e.remoteId).catch(()=>void 0));let a=t?this.getPersistence(r).getResolvedRemoteId(t):void 0;return{...i?{thread_id:i}:void 0,...a?{message_id:a}:void 0}}feedback={submit:({message:e,type:t,comment:n})=>{(async()=>{let r=this.tryGetKeyedThreadListItem(),i=r?.getState().remoteId;if(!r||!i){console.warn(`[assistant-ui] Skipping feedback for message ${e.id}: the thread has no remote id.`);return}let a=await this.getPersistence(r).getRemoteId(e.id);if(!a){console.warn(`[assistant-ui] Skipping feedback for message ${e.id}: no cloud message id is mapped.`);return}await this.cloudRef.current.threads.messages.feedback(i,a,{type:t,...n?{comment:n}:void 0})})().catch(e=>{console.error(`[assistant-ui] Cloud feedback submission failed:`,e)})}};tryGetKeyedThreadListItem(){let e=this.aui.threadListItem;if(!e.source)return;let t=e.getState().id;if(t!==void 0)return this.aui.threads.getState().threadItems.some(e=>e.id===t||e.remoteId===t)?this.aui.threads.item({id:t}):e}getThreadListItem(e){let t=this.aui.threadListItem;if(t.source){let n=t.getState();if(n.id===e||n.remoteId===e)return t}let n=this.aui.threads.getState().threadItems.find(t=>t.id===e||t.remoteId===e);return n?this.aui.threads.item({id:n.id}):void 0}withFormat(e){let t=this,n,r=()=>{let e=t.tryGetKeyedThreadListItem();return e&&(n=e),n},i=()=>n??r(),a=n=>qN(t.getPersistence(n),e);return{pin(){r()},async append(e){let t=i();if(!t)throw Error(`Cannot persist cloud history without a thread list item.`);let n=t.getState().remoteId??(await t.initialize()).remoteId;await a(t).append(n,e)},async update(e,t){let n=i(),r=n?.getState().remoteId;!r||!n||await a(n).update?.(r,e,t)},async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)},reportTelemetry(n,r){let a=n.map(t=>e.encode(t));t._reportRunTelemetry(e.format,a,r,i(),pP(fP(n,e),r?.message?mP(r.message,`aui/v0`):void 0))},async load(){let e=r(),n=t.aui.threadListItem,i=n.source?n.getState().remoteId:void 0;return i?a(e??n).load(i):{messages:[]}}}}async append({parentId:e,message:t}){let{remoteId:n}=await this.aui.threadListItem.initialize(),r=this._persistence;await this._writeMessage(r,n,t,i=>r.append(n,t.id,e,`aui/v0`,i))}async update(e){let t=this._persistence;if(!t.isPersisted(e.message.id))return this.append(e);let{message:n}=e,r=this.aui.threadListItem.getState().remoteId;r&&await this._writeMessage(t,r,n,e=>t.update(r,n.id,`aui/v0`,e))}get unstable_copy(){let e=this.cloudRef.current?.telemetry;return e?.enabled===!1||e?.messages===!1?void 0:this.copy}copy=async(e,t)=>{let n=this.cloudRef.current;if(t.length===0)return;let r=this.tryGetKeyedThreadListItem();if(!r)throw Error(`Cannot copy cloud history without a thread list item.`);let i=(await r.initialize()).remoteId,a=this.getPersistence(r),o=(this.copyQueues.get(i)??Promise.resolve()).catch(()=>void 0).then(()=>this.copyBranch(n,i,a,e,t));this.copyQueues.set(i,o);try{await o}finally{this.copyQueues.get(i)===o&&this.copyQueues.delete(i)}};async copyBranch(e,t,n,r,i){let a=this.copiedThreads.get(t);a||(a=(async()=>{let r={stored:new Set,refused:new Set,closed:!1,interactions:new Map},i=new Set,a;for(;;){let o=await e.threads.messages.list(t,{limit:200,...a?{after:a}:void 0}),s=o.messages.filter(e=>!i.has(e.id));for(let e of s){if(i.add(e.id),!e.external_id||e.format!==`aui/v0`)continue;r.stored.add(e.external_id),n.record(e.external_id,e.id);let t=iM(e);for(let e of t?.message.content??[]){if(e.type!==`tool-call`)continue;let t=oP(r.interactions.get(e.toolCallId),e.unstable_interactions);t&&r.interactions.set(e.toolCallId,t)}}let c=o.messages.at(-1);if(s.length===0||o.messages.length<200||!c)break;a=c.id}return r})(),this.copiedThreads.set(t,a));let o;try{o=await a}catch(e){throw this.copiedThreads.get(t)===a&&this.copiedThreads.delete(t),e}if(o.closed)return;let s=r.filter(e=>e.id.length>0&&e.id.length<=255),c=new Set(i),l=0,u;for(let r=0;r<s.length;r++)if(c.has(s[r].id))for(;l<=r;l++){let i=s[l];if(l!==r&&(o.stored.has(i.id)||o.refused.has(i.id))){o.stored.has(i.id)&&(u=i.id);continue}let a=eM(i),c={...a,content:a.content.map(e=>{if(e.type!==`tool-call`)return e;let t=oP(o.interactions.get(e.toolCallId),e.unstable_interactions);return{...e,...t?{unstable_interactions:t}:void 0}})},d;try{({message_id:d}=await e.threads.messages.create(t,{parent_id:null,format:`aui/v0`,content:c,external_id:i.id,...u?{parent_external_id:u}:void 0}))}catch(e){if(!lP(e))throw e;if(cP.has(e.status)||o.stored.size===0&&o.refused.size>0){o.closed=!0,console.warn(`[assistant-ui] The cloud refused copies to thread ${t}; the dashboard shows the conversation as far as it was copied.`,e);return}o.refused.add(i.id),console.warn(`[assistant-ui] The cloud refused the copy of message ${i.id}; the dashboard shows the conversation without it.`,e);continue}o.stored.add(i.id),o.refused.delete(i.id),u=i.id,n.record(i.id,d);for(let e of c.content)e.type===`tool-call`&&e.unstable_interactions&&o.interactions.set(e.toolCallId,e.unstable_interactions)}}async _writeMessage(e,t,n,r){let i=eM(n),a=iP(e),o=aP(n)&&!a.settled.has(n.id);if(await r(i),!o||(a.settled.add(n.id),a.reported.has(n.id))||!this.cloudRef.current.telemetry.enabled)return;let s=bP(`aui/v0`,i);s&&(a.reported.add(n.id),this._sendReport(t,s,void 0,void 0,mP(n,`aui/v0`),e))}async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)}async load(){let e=this.aui.threadListItem.getState().remoteId;if(!e)return{messages:[]};let t=this._persistence,n=(await t.load(e,`aui/v0`)).filter(e=>e.format===`aui/v0`).reverse(),r=[],i=new Set,{settled:a}=iP(t);for(let e of n){let t=iM(e);t&&(t.parentId&&!i.has(t.parentId)||(i.add(t.message.id),aP(t.message)&&a.add(t.message.id),r.push(t)))}return{messages:r}}_reportRunTelemetry(e,t,n,r,i){let a=r??this.aui.threadListItem,o=a.getState().remoteId;if(!o)return;let s=xP(e,t)??(i?.status===void 0?void 0:{status:`incomplete`});s&&this._sendReport(o,s,n?.durationMs,n?.stepTimestamps,i,this.getPersistence(a))}_sendReport(e,t,n,r,i,a=this._persistence){let o=dP(t.steps,r),s=i?.localMessageId?a.getResolvedRemoteId(i.localMessageId):void 0;this.runReporter.report({threadId:e,status:i?.status??t.status,outcome:i?.outcomeType,error:i?.error,errorCode:i?.errorCode,messageId:s,traceId:i?.traceId,modelId:t.modelId,provider:i?.provider,usage:t.usage,steps:o,totalSteps:t.totalSteps,toolCalls:t.toolCalls,durationMs:n,firstTokenMs:i?.firstTokenMs,outputText:t.outputText,metadata:t.metadata})}};function dP(e,t){if(!t)return e;if(!e)return t.map(({start_ms:e,end_ms:t})=>({startMs:e,endMs:t}));let n=Math.min(e.length,t.length);return e.map((e,r)=>({...e,...r<n?{startMs:t[r].start_ms,endMs:t[r].end_ms}:void 0}))}function fP(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n],i=mP(r.message,t.format,t.getId(r.message));if(i)return i}}function pP(e,t){if(!t)return e;let{localMessageId:n,...r}=t;return{...e,...r}}function mP(e,t,n){if(!hP(e)||e.role!==`assistant`)return;let r=hP(e.status)?e.status:void 0,i=hP(e.metadata)?e.metadata:void 0,a=hP(i?.custom)?i.custom:void 0,o=(hP(i?.timing)?i.timing:void 0)?.firstTokenTime,s=typeof o==`number`&&Number.isFinite(o)?Math.round(o):void 0,c=r?.type===`incomplete`?typeof r.reason==`string`?r.reason:void 0:typeof i?.finishReason==`string`?i.finishReason:void 0,l=r?.type===`incomplete`&&r.reason===`error`,u=TN({finishReason:c,isError:l}),d=u.outcome,f=u.status===`error`?`error`:r?.type===`incomplete`?`incomplete`:c===void 0?void 0:u.status,p=l?ON(r.error):{},m=n??(typeof e.id==`string`?e.id:void 0),h=t===`aui/v0`?a?.traceId:t===`ai-sdk/v6`?i?.traceId:void 0,g=typeof a?.provider==`string`?a.provider:typeof i?.provider==`string`?i.provider:void 0;return{...m?{localMessageId:m}:void 0,...f===void 0?void 0:{status:f},...d?{outcomeType:d}:void 0,...p,...s!=null&&s>=0?{firstTokenMs:s}:void 0,...typeof h==`string`?{traceId:h}:void 0,...g===void 0?void 0:{provider:g}}}function hP(e){return typeof e==`object`&&!!e}var gP=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`promptTokens`,`completionTokens`],_P=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:void 0,vP=e=>{if(!hP(e)||Array.isArray(e))return;let t={};for(let n of gP){let r=_P(e[n]);r!==void 0&&(t[n]=r)}let n=hP(e.inputTokenDetails)&&!Array.isArray(e.inputTokenDetails)?_P(e.inputTokenDetails.cacheReadTokens):void 0;n!==void 0&&(t.inputTokenDetails={cacheReadTokens:n});let r=hP(e.outputTokenDetails)&&!Array.isArray(e.outputTokenDetails)?_P(e.outputTokenDetails.reasoningTokens):void 0;return r!==void 0&&(t.outputTokenDetails={reasoningTokens:r}),Object.keys(t).length>0?t:void 0},yP=e=>kO(e).map(e=>{let t=vP(e.usage);return t?{usage:t}:{}});function bP(e,t){switch(e){case`aui/v0`:return SP(t);case`ai-sdk/v6`:return tP([t]);default:return null}}function xP(e,t){if(e===`ai-sdk/v6`)return tP(t);for(let n=t.length-1;n>=0;n--){let r=bP(e,t[n]);if(r)return r}return null}function SP(e){let t=e;if(t.role!==`assistant`||t.status!==void 0&&!DO(t.status))return null;let n=hP(t.status)&&typeof t.status.type==`string`?t.status.type:void 0;if(n===`running`||n===`requires-action`)return null;let r=t.content?.filter(e=>e.type===`tool-call`&&e.toolName&&e.toolCallId).map(e=>FN({toolName:e.toolName,toolCallId:e.toolCallId,args:e.args,result:e.result,argsText:e.argsText})),i=t.content?.filter(e=>e.type===`text`&&e.text),a=i&&i.length>0?kN(i.map(e=>e.text).join(``)):void 0,o=yP(t.metadata?.steps),s,c,l,u;if(o&&o.length>0){let e=0,t=0,n=0,r=0,i=!1,a=!1,d=!1,f=!1;for(let s of o){if(!s.usage)continue;let o=WN(s.usage);o&&(o.inputTokens!=null&&(e+=o.inputTokens,i=!0),o.outputTokens!=null&&(t+=o.outputTokens,a=!0),o.reasoningTokens!=null&&(n+=o.reasoningTokens,d=!0),o.cachedInputTokens!=null&&(r+=o.cachedInputTokens,f=!0))}s=i?e:void 0,c=a?t:void 0,l=d?n:void 0,u=f?r:void 0}let d=n===`incomplete`?`incomplete`:`completed`,f=t.metadata?.custom,p=IN(t.metadata),m=o.length>0?o:void 0;return{status:d,...r&&r.length>0?{toolCalls:r}:void 0,...o?.length?{totalSteps:o.length}:void 0,...s!=null||c!=null||l!=null||u!=null?{usage:{...s==null?void 0:{inputTokens:s},...c==null?void 0:{outputTokens:c},...l==null?void 0:{reasoningTokens:l},...u==null?void 0:{cachedInputTokens:u}}}:void 0,...a==null?void 0:{outputText:a},...f?{metadata:f}:void 0,...m?{steps:m}:void 0,...p?{modelId:p}:void 0}}function CP(e){let t=lT(),n=rS(t);oS(()=>{n.current=t});let[r]=tS(()=>new uP(e,()=>n.current));return AP(r,t),r}var wP=new WeakMap,TP=(e,t)=>{let n;for(let r of e.mounted.keys()){if(t!==void 0&&r.ownsThread(t))return r;n??=r}return n??e.lastMounted},EP=e=>{let t={mounted:new Map,lastMounted:e,reporter:new bN(()=>TP(t).getCloud(),(e,n,r)=>TP(t,e).resolveEngagementEventIds(e,n,r)),host:void 0,dispose:void 0};return t},DP=(e,t)=>{let n=()=>{let{mainThreadId:n}=e.threads.getState(),{isEmpty:r,suggestions:i}=e.thread.getState();!r||i.length===0||t.suggestionsShown(n,i.length)},r=[e.on({scope:`*`,event:`threads.selectionChanged`},e=>{t.threadSwitched(e.threadId)}),e.on({scope:`*`,event:`composer.send`},e=>{e.messageId?t.messageEdited(e.threadId,{messageId:e.messageId,chars:e.chars}):t.messageSent(e.threadId,{chars:e.chars,attachments:e.attachments}),e.suggestion&&t.suggestionClicked(e.threadId)}),e.on({scope:`*`,event:`composer.attachmentAdd`},e=>{t.attachmentAdded(e.threadId,{messageId:e.messageId,contentType:e.contentType})}),e.on({scope:`*`,event:`composer.attachmentAddError`},e=>{t.attachmentFailed(e.threadId,{messageId:e.messageId,contentType:e.contentType})}),e.on({scope:`*`,event:`composer.cancel`},e=>{t.runStopped(e.threadId)}),e.on({scope:`*`,event:`thread.runStart`},e=>{t.runStarted(e.threadId)}),e.on({scope:`*`,event:`thread.runEnd`},e=>{t.runEnded(e.threadId)}),e.on({scope:`*`,event:`thread.cancelRun`},e=>{t.runStopped(e.threadId)}),e.on({scope:`*`,event:`thread.voiceStarted`},e=>{t.voiceStarted(e.threadId)}),e.on({scope:`*`,event:`message.reload`},e=>{t.messageRegenerated(e.threadId,e.messageId)}),e.on({scope:`*`,event:`message.branchSwitched`},e=>{t.branchSwitched(e.threadId,e.messageId)}),e.on({scope:`*`,event:`message.copied`},e=>{t.messageCopied(e.threadId,e.messageId)}),e.on({scope:`*`,event:`thread.toolApprovalAnswered`},e=>{e.approved?t.toolApproved(e.threadId,e.messageId,e.toolCallId,e.toolName):t.toolRejected(e.threadId,e.messageId,e.toolCallId,e.toolName)}),e.on({scope:`*`,event:`message.speak`},e=>{t.speechStarted(e.threadId,e.messageId)}),e.on({scope:`*`,event:`message.error`},e=>{t.errorShown(e.threadId,{messageId:e.messageId,reason:e.reason})}),e.subscribe(n)];return n(),()=>ST(r)},OP=(e,t)=>{e.host=t,e.dispose=DP(t,e.reporter)},kP=e=>{let t=e.dispose;e.host=void 0,e.dispose=void 0,t?.()},AP=(e,t)=>{let n=$(4),r,i;n[0]!==e||n[1]!==t?(r=()=>{let n=RC(t.threads),r=wP.get(n);r||(r=EP(e),wP.set(n,r));let i=r;return i.mounted.set(e,t),i.lastMounted=e,i.host===void 0&&OP(i,t),()=>{if(i.mounted.delete(e),i.host!==t)return;kP(i);let n=i.mounted.values().next();n.done||OP(i,n.value)}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),oS(r,i)};function jP(e,t){return t||qE(e)||`application/octet-stream`}var MP=`application/octet-stream`,NP=e=>e.startsWith(`image/`)?`image`:e.startsWith(`text/`)?`document`:`file`,PP=class{accept=`*`;getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}uploadedUrls=new Map;activeUploads=new Map;async*add({file:e}){let t=GE(),n=NP(e.type),r=e.type||MP,i={id:t,type:n,name:e.name,contentType:r,file:e,status:{type:`running`,reason:`uploading`,progress:0}},a=new AbortController,o={cancelled:!1,controller:a};this.activeUploads.set(t,o);try{if(yield i,o.cancelled)return;let{signedUrl:n,publicUrl:s}=await this.getCloud().files.generatePresignedUploadUrl({filename:e.name});if(o.cancelled)return;let c=await fetch(n,{method:`PUT`,body:e,headers:{"Content-Type":r},mode:`cors`,signal:a.signal});if(o.cancelled)return;if(!c.ok)throw Error(`Failed to upload file: ${c.status} ${c.statusText}`);this.uploadedUrls.set(t,s),i={...i,status:{type:`requires-action`,reason:`composer-send`}},yield i}catch(e){if(o.cancelled)return;console.error(`[assistant-ui] Failed to upload attachment:`,e),i={...i,status:{type:`incomplete`,reason:`error`,message:e instanceof Error?e.message:String(e)}},yield i}finally{this.activeUploads.get(t)===o&&this.activeUploads.delete(t)}}async remove(e){let t=this.activeUploads.get(e.id);t&&(t.cancelled=!0,t.controller.abort(),this.activeUploads.delete(e.id)),this.uploadedUrls.delete(e.id)}async send(e){let t=this.uploadedUrls.get(e.id);if(!t)throw Error(`Attachment not uploaded`);this.uploadedUrls.delete(e.id);let n;return n=e.type===`image`?[{type:`image`,image:t,filename:e.name}]:[{type:`file`,data:t,mimeType:jP(t,e.contentType),filename:e.name}],{...e,status:{type:`complete`},content:n}}},FP=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}updateCustom(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream({start(e){e.close()}}))}fetch(e){return Promise.reject(Error(`Thread "${e}" not found in in-memory thread list.`))}},IP={name:`@assistant-ui/core`,version:`0.3.22`},LP=e=>SO(e)?e:void 0,RP=typeof process<`u`?{}.NEXT_PUBLIC_ASSISTANT_BASE_URL:void 0,zP=RP?new hN({baseUrl:RP,anonymous:!0}):void 0,BP=e=>{let t=CP(e),[n]=tS(()=>new PP(()=>e.current));return iS(()=>({history:t,attachments:n,feedback:t.feedback}),[t,n])},VP=20,HP=e=>{let t={activeCursor:e,archivedCursor:void 0,activeExhausted:!1,archivedExhausted:!1};if(!e||!e.startsWith(`{`))return t;try{let n=JSON.parse(e);return SO(n)?{activeCursor:typeof n.a==`string`?n.a:void 0,archivedCursor:typeof n.r==`string`?n.r:void 0,activeExhausted:n.ae===!0,archivedExhausted:n.re===!0}:t}catch{return t}},UP=e=>{let t=typeof e==`function`?e:()=>e,n=function(){return BP({get current(){return t().cloud??zP}})},r=t().cloud??zP;if(!r){let e=new FP;return e.initialize=async e=>({remoteId:e,externalId:(await t().create?.(e))?.externalId}),e}r.registerSdk?.(IP);let i=t().sdk;return i&&r.registerSdk?.(i),{list:async({after:e}={})=>{let{activeCursor:t,archivedCursor:n,activeExhausted:i,archivedExhausted:a}=HP(e),[{threads:o},{threads:s}]=await Promise.all([i?Promise.resolve({threads:[]}):r.threads.list({limit:VP,...t?{after:t}:{}}),a?Promise.resolve({threads:[]}):r.threads.list({is_archived:!0,limit:VP,...n?{after:n}:{}})]),c=!i&&o.length===VP?o.at(-1)?.id:void 0,l=!a&&s.length===VP?s.at(-1)?.id:void 0;return{threads:[...o,...s].map(e=>({status:e.is_archived?`archived`:`regular`,remoteId:e.id,title:e.title,lastMessageAt:e.last_message_at?new Date(e.last_message_at):void 0,externalId:e.external_id??void 0,custom:LP(e.metadata)})),nextCursor:c||l?JSON.stringify({a:c,r:l,...c===void 0?{ae:!0}:{},...l===void 0?{re:!0}:{}}):void 0}},initialize:async e=>{let n=await(t().create?.(e)??Promise.resolve()),i=n?n.externalId:void 0,{thread_id:a}=await r.threads.create({last_message_at:new Date,external_id:i,...i!==void 0&&t().upsert?{upsert:!0}:{}});return{externalId:i,remoteId:a}},rename:async(e,t)=>r.threads.update(e,{title:t}),updateCustom:async(e,t)=>r.threads.update(e,{metadata:t??null}),archive:async e=>r.threads.update(e,{is_archived:!0}),unarchive:async e=>r.threads.update(e,{is_archived:!1}),delete:async e=>(await t().delete?.(e),r.threads.delete(e)),generateTitle:async(e,t)=>{let n=t.map(e=>({...e,content:e.content.filter(e=>e.type===`text`||e.type===`tool-call`)}));return r.runs.stream({thread_id:e,assistant_id:`system/thread_title`,messages:n})},fetch:async e=>{let t=await r.threads.get(e);return{status:t.is_archived?`archived`:`regular`,remoteId:t.id,title:t.title,lastMessageAt:t.last_message_at?new Date(t.last_message_at):void 0,externalId:t.external_id??void 0,custom:LP(t.metadata)}},unstable_useAdapters:n}},WP=e=>{let t=rS(e);dS(()=>{t.current=e},[e]);let[n]=tS(()=>({get current(){return t.current.cloud??zP}})),[r]=tS(()=>function(){return BP(n)}),i=e.cloud??zP,a=()=>{let n=()=>e,a=UP(()=>({...n(),cloud:i}));return n=()=>t.current,a.unstable_useAdapters===void 0?a:{...a,unstable_useAdapters:r}},[o,s]=tS(()=>({cloud:i,adapter:a()}));if(o.cloud!==i){let e={cloud:i,adapter:a()};return s(e),e.adapter}return o.adapter},GP=async(e,t)=>{let{signal:n,onUpdate:r}=t;if(Symbol.asyncIterator in e)for await(let t of e){if(n.aborted)break;r(t)}else{let t=await e;if(n.aborted)return;r(t)}},KP=e=>{let t=[...e.content,...(e.attachments??[]).flatMap(e=>(e.content??[]).filter(e=>e.type!==`text`))],n=[];for(let e of t)e.type===`file`||e.type===`text`?n.push(e):e.type===`image`&&n.push({type:`file`,data:e.image,mimeType:`image/*`,...e.filename!==void 0&&{filename:e.filename}});return n},qP=e=>{let t={queue:UA,steer:UA},n=new Map,r=new Set,i=!1,a=!1,o=!1,s=!1,c=e=>e,l=0,u=0,d=!1,f=0,p=()=>{DC(r,void 0,`Message queue`)},m=e=>{t=e,D.items=e.queue,D.steerItems=e.steer,p()},h=(e,t)=>({id:e,prompt:lE(t),parts:KP(t)}),g=(e,r,i=0)=>{o=!0,n.set(r.id,r.message),m({...t,[e]:[...t[e].slice(0,i),r.item,...t[e].slice(i)]})},_=e=>{if(t.steer.some(t=>t.id===e))return`steer`;if(t.queue.some(t=>t.id===e))return`queue`},v=()=>{if(i||o||s)return;let r=t.steer.length>0?`steer`:`queue`,l=t[r][0];if(!l)return;let u=n.get(l.id);if(!u)return;i=!0,n.delete(l.id),a=!0,m({...t,[r]:t[r].slice(1)}),a=!1;let d={id:l.id,item:l,message:u},p=f;try{e.run(c(u),{steer:!1})}catch(e){throw f===p&&(i=!1,g(r,d)),e}},y=(t,n=`steer`,r=0)=>{o=!1,l+=Math.max(u,1),u=0;let a=(e=!1)=>{if(e)return;let a=l;l=Math.max(a-1,0),u=+(a>0),i=a>0,g(n,t,r)};d=!0;try{e.cancel()}catch(e){throw a(),e}finally{d=!1}i=!0;let s=f;try{e.run(c(t.message),{steer:!0})}catch(e){throw a(f!==s),e}},b=(e,r)=>{o=!1;let i=GE();n.set(i,r),m({...t,[e]:[...t[e],h(i,r)]}),v()},x=e=>{b(`queue`,e)},S=t=>{if(i&&!a&&e.cancel){let e=GE();y({id:e,item:h(e,t),message:t});return}b(`steer`,t)},C=(r,o)=>{let s=_(r);if(!s)throw Error(`Unknown queue item "${r}".`);let c=o.lane??s,l=t[s].findIndex(e=>e.id===r),u=t[s][l],d=(c===s?t[s]:t[c]).filter(e=>e.id!==r),f=e=>{if(e===r)throw Error(`Queue item "${r}" cannot anchor itself.`);let t=d.findIndex(t=>t.id===e);if(t===-1)throw Error(`Unknown anchor "${e}" in lane "${c}".`);return t},{insertAfter:p,insertBefore:h}=o,g;if(p===void 0&&h===void 0)g=c===s?t[s].findIndex(e=>e.id===r):d.length;else if(p!==void 0&&h!==void 0){let e=p===null?-1:f(p);if((h===null?d.length:f(h))!==e+1)throw Error(`insertAfter "${p}" and insertBefore "${h}" are not adjacent in lane "${c}".`);g=e+1}else g=p===void 0?h===null?d.length:f(h):p===null?0:f(p)+1;if(p===void 0&&h===void 0&&c===`steer`&&s!==`steer`&&i&&!a&&e.cancel){let e=n.get(r);n.delete(r),m({queue:t.queue.filter(e=>e.id!==r),steer:t.steer}),y({id:r,item:u,message:e},s,l);return}let b=[...d.slice(0,g),u,...d.slice(g)],x={...t,[c]:b};c!==s&&(x[s]=t[s].filter(e=>e.id!==r)),m(x),v()},w=(e,r)=>{let i=_(e);if(!i)throw Error(`Unknown queue item "${e}".`);n.set(e,r),m({...t,[i]:t[i].map(t=>t.id===e?h(e,r):t)})},T=e=>{n.delete(e)&&m({queue:t.queue.filter(t=>t.id!==e),steer:t.steer.filter(t=>t.id!==e)})},E=()=>{d||a||i&&u===0&&(o=!0,u=1)},D={items:t.queue,steerItems:t.steer,enqueue:x,steer:S,move:C,edit:w,remove:T,__internal_setDispatchTransform:e=>{c=e},__internal_notifyCancelled:E};return{adapter:D,hold:()=>{s=!0},release:()=>{s=!1,v()},notifyBusy:()=>{o=!1,l+=u,u=0,i=!0,f++},notifyIdle:()=>{if(l>0){l--;return}u>0&&u--,i=!1,v()},notifyCancelled:E,clear:()=>{n.clear(),m({queue:UA,steer:UA})},subscribe:e=>(r.add(e),()=>{r.delete(e)})}},JP=(e,t)=>e.status?.type!==`requires-action`||e.status.reason!==`tool-calls`||e.content.some(e=>e.type===`tool-call`&&e.result===void 0&&e.approval!==void 0&&e.approval.approved===void 0&&e.approval.resolution===void 0)?!1:t===void 0?e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0):e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0||!t.includes(e.toolName)),YP=class extends Error{name=`AbortError`;detach;constructor(e,t){super(t),this.detach=e}},XP=e=>e.role!==`assistant`||e.status.type!==`requires-action`||e.status.reason!==`interrupt`||e.content.some(e=>e.type===`tool-call`&&e.result===void 0&&e.interrupt!=null)?e:{...e,status:Lk(!1,!1,!1,e.content.some(e=>e.type===`tool-call`&&e.result===void 0))},ZP=e=>{let t=!1,n=e.content.map(e=>e.type!==`tool-call`||e.approval===void 0||e.approval.approved!==void 0||e.approval.resolution!==void 0?e:(t=!0,{...e,approval:{...e.approval,resolution:`cancelled`}})),r=e.status.type===`running`||e.status.type===`requires-action`;return!t&&!r?e:{...e,content:n,status:r?{type:`incomplete`,reason:`cancelled`}:e.status}},QP=e=>{let t=new Set(e.messages.map(e=>e.parentId));return{...e,messages:e.messages.map(e=>({...e,message:e.message.role===`assistant`&&t.has(e.message.id)?ZP(e.message):XP(e.message)}))}},$P=e=>{if(e.role!==`assistant`)return e;let t=!1,n=e.content.map(e=>{if(e.type!==`tool-call`)return e;let n=e.messages?.map($P),r=n?.some((t,n)=>t!==e.messages?.[n]);if(e.unstable_interactions===void 0&&r!==!0)return e;t=!0;let{unstable_interactions:i,...a}=e;return r?{...a,messages:n}:a});return t?{...e,content:n}:e},eF=class extends nj{capabilities={switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,delete:!1,reload:!0,refetchThread:!1,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1,answerToolCall:!0};abortController=null;_queue=null;_queueRunInFlight=null;_activeRun=null;_runGeneration=0;_messageReplacements=new WeakMap;_historyWrites=new Map;_chainHistoryWrite(e,t){let n=this._historyWrites.get(e),r;if(n)r=n.then(t,t);else try{r=Promise.resolve(t())}catch(e){r=Promise.reject(e)}let i=r.then(()=>{},()=>{});return this._historyWrites.set(e,i),i.then(()=>{this._historyWrites.get(e)===i&&this._historyWrites.delete(e)}),r}_persistMessageUpdate(e){let t=this._options.adapters.history;if(!t)return;let n;try{n=this.repository.getMessage(e)}catch{return}let{parentId:r,message:i}=n;i.role===`assistant`&&i.status.type!==`running`&&(this._unwrittenMessages.has(i.id)&&!t.update&&i.status.type===`requires-action`||this._persistSettled(r,i)?.catch(()=>{}))}_roundtripsInFlight=new Map;_followedDuringRun=new Set;_unwrittenMessages=new Set;_persistSettled(e,t){let n=this._options.adapters.history;if(!n)return;let r=this._unwrittenMessages.delete(t.id)?n.append.bind(n):n.update?.bind(n);if(!r)return;let i={parentId:e,message:t,runConfig:this._lastRunConfig};return this._chainHistoryWrite(t.id,()=>r(i))}_cancelPause(e){if(e===null)return;let t;try{t=this.repository.getMessage(e)}catch{return}if(t.message.role!==`assistant`)return;if(this._roundtripsInFlight.has(e)){this._followedDuringRun.add(e);let n=ZP(t.message),r=this._options.adapters.history;if(r&&!r.update&&this._roundtripsInFlight.get(e)?.resumedFromPause&&!this._unwrittenMessages.has(e)){let i={parentId:t.parentId,message:n,runConfig:this._lastRunConfig};return this._chainHistoryWrite(e,()=>r.append(i))}return this._persistSettled(t.parentId,n)}let n=ZP(t.message);if(n!==t.message)return this.repository.addOrUpdateMessage(t.parentId,n),this._persistSettled(t.parentId,n)}_resumeIfReady(e){let t=this.getMessageById(e);return t?.message.role!==`assistant`||this.repository.hasChildren(e)||this._followedDuringRun.has(e)||!JP(t.message,this._options.unstable_humanToolNames)?!1:(this._runLoop(t.parentId,t.message,this._lastRunConfig).catch(()=>{}),!0)}isDisabled=!1;isSendDisabled=!1;_isLoading=!1;get isLoading(){return this._isLoading}_suggestions=[];_suggestionsController=null;get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}constructor(e,t){super(e),this.__internal_setOptions(t)}_options;_lastRunConfig={};_getThreadId;__internal_setGetThreadId(e){this._getThreadId=e}_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}get extras(){}__internal_setOptions(e){if(this._options===e)return;let t=this._options?.adapters.history;if(this._options=e,!e.adapters.voice&&this.voice)try{this.disconnectVoice()}catch(e){console.error(`[assistant-ui] Voice cleanup threw after the adapter changed`,e)}let n=!1;e.adapters.suggestion||(this._suggestionsController?.abort(),this._suggestionsController=null,this._suggestions.length>0&&(this._suggestions=[],n=!0));let r=e.adapters?.speech!==void 0;this.capabilities.speech!==r&&(this.capabilities.speech=r,n=!0);let i=e.adapters?.dictation!==void 0;this.capabilities.dictation!==i&&(this.capabilities.dictation=i,n=!0);let a=e.adapters?.voice!==void 0;this.capabilities.voice!==a&&(this.capabilities.voice=a,n=!0);let o=e.adapters?.attachments!==void 0;this.capabilities.attachments!==o&&(this.capabilities.attachments=o,n=!0);let s=e.adapters?.feedback!==void 0;this.capabilities.feedback!==s&&(this.capabilities.feedback=s,n=!0);let c=e.adapters?.history?.delete!==void 0;this.capabilities.delete!==c&&(this.capabilities.delete=c,n=!0);let l=e.unstable_enableMessageQueue===!0;l&&!this._queue?(this._queue=qP({run:e=>{let t={};this._queueRunInFlight=t;let n=this._runGeneration;this._runAppend({...e,parentId:this._resolveAppendParent(this.messages.at(-1)?.id??null)}).finally(()=>{this._queueRunInFlight===t&&(this._queueRunInFlight=null,this._runGeneration===n&&this._queue?.notifyIdle())}).catch(()=>{})}}),this.voice&&this._queue.hold(),this._queue.subscribe(()=>this._notifySubscribers())):!l&&this._queue&&(this._queue=null),this.capabilities.queue!==l&&(this.capabilities.queue=l,n=!0),n&&this._notifySubscribers(),this._loadRequested&&!this._loadPromise&&!t&&e.adapters.history&&this.messages.length===0&&this.__internal_load().catch(e=>{console.error(`[assistant-ui] local thread history load failed:`,e)})}_loadPromise;_loadRequested=!1;__internal_load(){if(this._loadRequested=!0,this._loadPromise)return this._loadPromise;if(!this.adapters.history)return Promise.resolve();let e=this.adapters.history.load();return this._isLoading=!0,this._loadPromise=e.then(e=>{if(!e)return;let{repository:t,droppedIds:n}=BA(e);n.length>0&&console.warn(`[assistant-ui] Skipped history messages with missing parents:`,n),e.headId!=null&&!e.messages.some(t=>t.message.id===e.headId)&&console.warn(`[assistant-ui] History head is not among the loaded messages:`,e.headId),this.repository.import(QP(t)),t.messages.length>0&&this.ensureInitialized(),this._notifySubscribers();let r=this.adapters.history?.resume?.bind(this.adapters.history);e.unstable_resume&&r&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},r).catch(()=>{})}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._notifySubscribers(),this._loadPromise}_getHistoryLoadBarrier(){if(!(!this._isLoading||!this._loadPromise))return this._loadPromise.catch(()=>{})}async append(e){if(e={...e,parentId:this._resolveAppendParent(e.parentId)},this.voice)return this._appendToVoiceSession(e);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be edited`);let t=e.parentId===(this.messages.at(-1)?.id??null),n=e.startRun??e.role===`user`;if(this._queue&&n&&t){e.steer??this._queueRunInFlight!==null?this._queue.adapter.steer(e):this._queue.adapter.enqueue(e);return}return this._queue&&!t&&(this._options.unstable_queueClearOnRewind??!0)&&this._queue.clear(),this._runAppend(e)}_commitVoiceMessage(e){let t=xA(this),n=n=>{if(t.aborted){this._dropVoiceMessage(e.id,n);return}let r=this.repository.headId;this.repository.addOrUpdateMessage(r,e);let i=this._cancelPause(r);this.repository.resetHead(e.id);let a=this._options.adapters.history,o=a?this._chainHistoryWrite(e.id,()=>a.append({parentId:r,message:e})):void 0;return o?.catch(()=>{}),this._dropVoiceMessage(e.id,!1),n&&this._notifySubscribers(),i?Promise.all([i,o]).then(()=>{}):o},r=this._getVoiceCommitBarrier();return r?r.then(()=>n(!0)):n(!1)}_onVoiceConnected(){this._queue?.hold()}_onVoiceDisconnected(){this._queue?.release()}getQueueItems(){return this._queue?.adapter.items??UA}getSteerQueueItems(){return this._queue?.adapter.steerItems??UA}moveQueueItem(e,t){this._queue?.adapter.move(e,t)}removeQueueItem(e){this._queue?.adapter.remove(e)}_rollbackAppend(e){try{this.repository.deleteMessage(e)}catch{return}this._notifySubscribers()}_pendingAppends=0;_isRunActive(){return this._pendingAppends>0||super._isRunActive()}async _runAppend(e){this._pendingAppends+=1;try{await this._runAppendInner(e)}finally{--this._pendingAppends}}async _runAppendInner(e){let t=xA(this),n=this._getHistoryLoadBarrier();if(n){let r=e.parentId===(this.messages.at(-1)?.id??null);if(await n,t.aborted)return;r&&(e={...e,parentId:this._resolveAppendParent(this.messages.at(-1)?.id??null)})}let r=this.enrichAppendMetadata(e);this.ensureInitialized();let i=FD(r,GE(),{type:`complete`,reason:`unknown`});this.repository.addOrUpdateMessage(r.parentId,i),this._notifySubscribers();try{let e=this._getInitializePromise?.();e&&await e}catch(e){if(this._rollbackAppend(i.id),t.aborted)return;r.parentId!==null&&this._resumeIfReady(r.parentId);let n=new Wk;throw n.cause=e,n}if(t.aborted){this._rollbackAppend(i.id);return}let a=this._cancelPause(r.parentId),o=this._options.adapters.history,s=o?this._chainHistoryWrite(i.id,()=>o.append({parentId:r.parentId,message:i,...r.runConfig!==void 0&&{runConfig:r.runConfig}})):void 0,c=a?Promise.all([a,s]).then(()=>{}):s;if(c?.catch(()=>{}),r.startRun??r.role===`user`){let[e,t]=await Promise.allSettled([this.startRun({parentId:i.id,sourceId:r.sourceId,runConfig:r.runConfig??{}}),c]);if(e.status===`rejected`)throw e.reason;if(t.status===`rejected`)throw t.reason}else this.repository.switchToBranch(i.id),this._notifySubscribers(),await c}async deleteMessage(e){let t=this._options.adapters.history;if(!t?.delete)throw Error(`Runtime does not support deleting messages.`);let n=this.repository.getMessages(),r=n.findIndex(t=>t.id===e);if(r===-1)throw Error(`Message not found.`);let i=n[r],a=[{parentId:n[r-1]?.id??null,message:i}];await t.delete(a),this.repository.deleteMessage(e),this._notifySubscribers()}resumeRun({stream:e,...t}){if(!e)throw Error(`You must pass a stream parameter to resume runs.`);return this.startRun(t,e)}exportExternalState(){throw Error(`Runtime does not support exporting external states.`)}import(e){this._roundtripsInFlight.clear(),this._followedDuringRun.clear(),this._unwrittenMessages.clear(),super.import(QP(e))}importExternalState(){throw Error(`Runtime does not support importing external states.`)}unstable_notifySessionReset(){throw Error(`Runtime does not support resetting sessions.`)}async startRun({parentId:e,sourceId:t,runConfig:n},r){if(this.ensureInitialized(),this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(t))throw Error(`Voice transcript messages cannot be reloaded`);let i=this._cancelPause(e),a=GE(),o={id:a,role:`assistant`,status:{type:`running`},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};this._unwrittenMessages.add(a);let s=this._runLoop(e,o,n,r);if(!i)return s;let[c,l]=await Promise.allSettled([s,i]);if(c.status===`rejected`)throw c.reason;if(l.status===`rejected`)throw l.reason}async _runLoop(e,t,n,r){if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);this._notifyEventSubscribers(`runStart`,{});let i={cancelled:!1,resumedFromPause:t.status.type===`requires-action`};this._activeRun=i,this._runGeneration++;let a=!1;try{this._queue?.notifyBusy(),this._suggestions=[],this._suggestionsController?.abort(),this._suggestionsController=null,this._notifySubscribers();do{if(t=await this.performRoundtrip(e,t,n,i,r),r=void 0,this._activeRun!==i)break;let a=this._messageReplacements.get(t);for(;a;)t=a.message,a=this._messageReplacements.get(t);if(this.getMessageById(t.id)?.message!==t)break}while(JP(t,this._options.unstable_humanToolNames)&&!this.repository.hasChildren(t.id))}finally{this._notifyEventSubscribers(`runEnd`,{}),a=this._activeRun===i,a&&(this._activeRun=null),(a||i.cancelled)&&queueMicrotask(()=>this._queue?.notifyIdle())}if(a&&this.adapters.suggestion&&t.status?.type!==`requires-action`){this._suggestionsController=new AbortController;let e=this._suggestionsController.signal,t=this.adapters.suggestion;(async()=>{try{await GP(t.generate({messages:this.messages,signal:e}),{signal:e,onUpdate:e=>{this._suggestions=e,this._notifySubscribers()}})}catch{}})()}}async performRoundtrip(e,t,n,r,i){let a=(e?this.repository.getMessages(e):[]).map(e=>$P(e.role===`assistant`&&(e.status.type===`running`||this._roundtripsInFlight.has(e.id))?ZP(e):e));this.abortController?.abort();let o=new AbortController;this.abortController=o;let s=t.content,c=t.metadata?.unstable_annotations,l=t.metadata?.unstable_data,u=t.metadata?.steps,d=t.metadata?.custom,f=new Set,p=!0;try{this.repository.getMessage(t.id)}catch{p=!1}let m=()=>{if(!p)return this._activeRun===r;try{let e=t,n=this._messageReplacements.get(e);for(;n;)n.toolCallId!==void 0&&f.add(n.toolCallId),e=n.message,n=this._messageReplacements.get(e);return this.repository.getMessage(t.id).message===e&&(t=e,!0)}catch{return!1}},h=e=>{let n=new Map;for(let e of t.content)e.type===`tool-call`&&e.unstable_interactions!==void 0&&n.set(e.toolCallId,e.unstable_interactions);let r=e.map(e=>{if(e.type!==`tool-call`||e.unstable_interactions!==void 0)return e;let t=n.get(e.toolCallId);return t===void 0?e:{...e,unstable_interactions:t}});if(f.size===0)return r;let i=new Map;for(let e of t.content){if(e.type!==`tool-call`||!f.has(e.toolCallId))continue;let t=i.get(e.toolCallId)??[];t.push(e),i.set(e.toolCallId,t)}let a=new Map;return r.map(e=>{if(e.type!==`tool-call`)return e;let t=a.get(e.toolCallId)??0;if(a.set(e.toolCallId,t+1),e.result!==void 0&&e.isPreliminary!==!0)return e;let n=i.get(e.toolCallId)?.[t];if(!n||n.result===void 0||n.isPreliminary===!0)return e;let{isPreliminary:r,artifact:o,modelContent:s,...c}=e;return{...c,result:n.result,isError:n.isError,...n.artifact!==void 0&&{artifact:n.artifact},...n.modelContent!==void 0&&{modelContent:n.modelContent}}})},g=n=>{if(!m())return;let r=n.metadata?.steps,i=r?[...u??[],...r]:void 0,a=n.metadata?.unstable_annotations,o=n.metadata?.unstable_data,f=a?[...c??[],...a]:void 0,g=o?[...l??[],...o]:void 0,_=n.content?h([...s,...n.content]):void 0;t={...t,..._?{content:_}:void 0,status:n.status??t.status,...n.metadata?{metadata:{...t.metadata,...n.metadata.unstable_state===void 0?void 0:{unstable_state:n.metadata.unstable_state},...f?{unstable_annotations:f}:void 0,...g?{unstable_data:g}:void 0,...i?{steps:i}:void 0,...n.metadata?.timing?{timing:n.metadata.timing}:void 0,...n.metadata?.custom?{custom:{...d??{},...n.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(e,t),p=!0,this._notifySubscribers()},_=this._options.maxSteps??2;this._roundtripsInFlight.set(t.id,{controller:o,resumedFromPause:r.resumedFromPause});try{if((t.metadata?.steps?.length??0)>=_)return g({status:{type:`incomplete`,reason:`tool-calls`}}),t;g({status:{type:`running`}}),this.repository.switchToBranch(t.id),this._notifySubscribers(),this._lastRunConfig=n??{};let{unstable_composerMetadata:s,...c}=this.getModelContext();i??=this.adapters.chatModel.run.bind(this.adapters.chatModel);let l=o.signal,u=()=>l.aborted&&(t.status.type===`running`||t.status.type===`requires-action`&&(this._activeRun!==r||JP(t,this._options.unstable_humanToolNames))),d=this._getThreadId?.(),f=i({messages:a,runConfig:this._lastRunConfig,abortSignal:l,context:c,unstable_assistantMessageId:t.id,unstable_threadId:d,unstable_parentId:e,unstable_getMessage(){return m(),$P(t)}});if(Symbol.asyncIterator in f)for await(let e of f){if(l.aborted){u()&&g({status:{type:`incomplete`,reason:`cancelled`}});break}g(e)}else g(await f);u()?g({status:{type:`incomplete`,reason:`cancelled`}}):t.status.type===`running`&&g({status:{type:`complete`,reason:`unknown`}})}catch(e){if(e instanceof YP)g({status:{type:`incomplete`,reason:`cancelled`}});else if(e instanceof Error&&e.name===`AbortError`)g({status:{type:`incomplete`,reason:`cancelled`}});else throw g({status:{type:`incomplete`,reason:`error`,error:Kk(e)}}),e}finally{this.abortController===o&&(this.abortController=null);let n=this._roundtripsInFlight.get(t.id)?.controller===o;n&&this._roundtripsInFlight.delete(t.id);let i=this._options.adapters.history,a=m(),s=!1,c,l=n&&this._followedDuringRun.delete(t.id);if(l){let e=this.getMessageById(t.id);if(e?.message.role===`assistant`){let n=ZP(e.message);n!==e.message&&(this.repository.addOrUpdateMessage(e.parentId,n),s=!0,a?t=n:c=this._persistSettled(e.parentId,n))}}if(n&&!a&&!c){let e=this.getMessageById(t.id);e?.message.role===`assistant`&&(e.message.status.type===`complete`||e.message.status.type===`incomplete`)&&this._unwrittenMessages.has(t.id)&&(c=this._persistSettled(e.parentId,e.message))}let u=t.status.type===`complete`||t.status.type===`incomplete`,d=t.status.type===`requires-action`&&!JP(t,this._options.unstable_humanToolNames);if(a&&(u||d&&i?.update)){if(u&&r.resumedFromPause&&!l&&!this._unwrittenMessages.has(t.id)&&i&&!i.update){let n={parentId:e,message:t,runConfig:this._lastRunConfig};c=this._chainHistoryWrite(t.id,()=>i.append(n))}else c=this._persistSettled(e,t)}s&&this._notifySubscribers(),c&&await c}return t}detach(){TA(this),this._queue=null;let e=new YP(!0);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}cancelRun(){this._queue&&(this._options.unstable_queueClearOnCancel??!0?this._queue.clear():(this._queue.notifyCancelled(),this._activeRun&&(this._activeRun.cancelled=!0)));let e=new YP(!1);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}_onMessageMetadataChanged(e,t){this._messageReplacements.set(e,{message:t}),this._persistMessageUpdate(t.id)}addToolResult({messageId:e,toolCallId:t,result:n,isError:r,artifact:i,modelContent:a}){if(this.voice)throw Error(`Cannot add a tool result while a voice session is connected`);let o=this.repository.getMessage(e),{parentId:s}=o,{message:c}=o;if(c.role!==`assistant`)throw Error(`Tried to add tool result to non-assistant message`);let l=!1,u=!1,d=c.content.map(e=>{if(e.type!==`tool-call`||e.toolCallId!==t)return e;u=!0,(e.result===void 0||e.isPreliminary===!0)&&(l=!0);let{isPreliminary:o,...s}=e;return{...s,result:n,isError:r,...i!==void 0&&{artifact:i},...a!==void 0&&{modelContent:a}}});if(!u)throw Error(`Tried to add tool result to non-existing tool call`);let f=c;c={...c,content:d},f.status.type===`running`&&this._messageReplacements.set(f,{message:c,toolCallId:t}),this.repository.addOrUpdateMessage(s,c),this._notifySubscribers(),l&&(this._resumeIfReady(e)||this._persistMessageUpdate(e))}resumeToolCall(e){throw Error(`Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.`)}async unstable_recordToolInteraction({messageId:e,toolCallId:t,interaction:n}){let r;try{r=this.repository.getMessage(e)}catch{throw Error(`Tried to record a tool interaction on a non-existing message`)}let{parentId:i,message:a}=r;if(a.role!==`assistant`)throw Error(`Tried to record a tool interaction on a non-assistant message`);let o=a.content.findIndex(e=>e.type===`tool-call`&&e.toolCallId===t);if(o===-1)throw Error(`Tried to record a tool interaction on a non-existing tool call`);let s=a.content[o];if(s.type!==`tool-call`)throw Error(`Tried to record a tool interaction on a non-existing tool call`);let c={...a,content:a.content.map((e,t)=>t===o?{...e,unstable_interactions:tD(s.unstable_interactions,n)}:e)};a.status.type===`running`&&this._messageReplacements.set(a,{message:c}),this.repository.addOrUpdateMessage(i,c),this._notifySubscribers(),this._persistMessageUpdate(c.id)}respondToToolApproval({approvalId:e,approved:t,optionId:n,text:r,reason:i}){if(this.voice)throw Error(`Cannot respond to a tool approval while a voice session is connected`);let a=this.repository.getMessages().findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e));if(!a)throw Error(`Tried to respond to a non-existing tool approval`);if(this.abortController!==null)throw Error(`Tried to respond to a tool approval while a run is in progress`);if(a.status?.type!==`requires-action`)throw Error(`Tried to respond to a tool approval on a message whose status is not requires-action`);if(this.repository.hasChildren(a.id))throw Error(`Tried to respond to a tool approval on a message that later messages follow`);if(this._followedDuringRun.has(a.id))throw Error(`Tried to respond to a tool approval that was cancelled or expired`);let o=a.content.find(t=>t.type===`tool-call`&&t.approval?.id===e);if(o?.type!==`tool-call`||!o.approval)throw Error(`Tried to respond to a non-existing tool approval`);if(o.approval.resolution!==void 0)throw Error(`Tried to respond to a tool approval that was cancelled or expired`);if(o.approval.approved!==void 0)throw Error(`Tried to respond to an already decided tool approval`);let s=o.approval,c=a.content.map(e=>{if(e!==o)return e;let a={...s,approved:t,...n!=null&&{optionId:n},...r!=null&&{text:r},...i!=null&&{reason:i}};return t?{...e,approval:a}:{...e,approval:a,result:{error:i||`Tool approval denied`},isError:!0}});a={...a,content:c};let{parentId:l}=this.repository.getMessage(a.id);this.repository.addOrUpdateMessage(l,a),this._notifySubscribers(),this._notifyToolApprovalAnswered(a.id,o.toolCallId,o.toolName,t);let u=this.getMessageById(a.id);return this.repository.headId===a.id&&u?.message.role===`assistant`&&JP(u.message,this._options.unstable_humanToolNames)?this._runLoop(u.parentId,u.message,this._lastRunConfig).catch(()=>{}):this._persistMessageUpdate(a.id),Promise.resolve()}},tF=Object.freeze([]),nF=`__DEFAULT_ID__`,rF=Object.freeze({[nF]:{id:nF,remoteId:void 0,externalId:void 0,status:`regular`,title:void 0}}),iF=class extends TT{_mainThread;constructor(e){super(),this._mainThread=e()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return tF}get archivedThreadIds(){return tF}get mainThreadId(){return nF}get threadItems(){return rF}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getLoadThreadsPromise(){return Promise.resolve()}getItemById(e){if(e===this.mainThreadId)return{status:`regular`,id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw Error(`Method not implemented`)}async switchToThread(){throw Error(`Method not implemented.`)}switchToNewThread(){throw Error(`Method not implemented.`)}rename(){throw Error(`Method not implemented.`)}archive(){throw Error(`Method not implemented.`)}detach(){throw Error(`Method not implemented.`)}unarchive(){throw Error(`Method not implemented.`)}delete(){throw Error(`Method not implemented.`)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},aF=class extends IA{threads;Provider=void 0;_options;constructor(e,t){super(),this._options=e,this.threads=new iF(()=>new eF(this._contextProvider,this._options)),t&&this.threads.getMainThreadRuntimeCore().import(LA.fromArray(t))}},oF=(e,t)=>{let n=$(39),r,i;n[0]===t?(r=n[1],i=n[2]):({initialMessages:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a=vO()??{},o,s;n[3]===a?(o=n[4],s=n[5]):({modelContext:o,...s}=a,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==e||n[7]!==i.adapters||n[8]!==s?(c={...s,...i.adapters,chatModel:e},n[6]=e,n[7]=i.adapters,n[8]=s,n[9]=c):c=n[9];let l;n[10]!==i||n[11]!==c?(l={...i,adapters:c},n[10]=i,n[11]=c,n[12]=l):l=n[12];let u=l,d;n[13]!==r||n[14]!==u?(d=()=>new aF(u,r),n[13]=r,n[14]=u,n[15]=d):d=n[15];let[f]=tS(d),p=lT(),m=rS(void 0),h;n[16]!==p||n[17]!==f.threads?(h=()=>{f.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>p.threadListItem.__internal_getRuntime?.().getState().remoteId)},n[16]=p,n[17]=f.threads,n[18]=h):h=n[18];let g;n[19]!==p||n[20]!==f?(g=[p,f],n[19]=p,n[20]=f,n[21]=g):g=n[21],oS(h,g);let _;n[22]===f.threads?_=n[23]:(_=()=>()=>{f.threads.getMainThreadRuntimeCore().detach()},n[22]=f.threads,n[23]=_);let v;n[24]===f?v=n[25]:(v=[f],n[24]=f,n[25]=v),IT(_,v);let y;n[26]!==u||n[27]!==f.threads?(y=()=>{f.threads.getMainThreadRuntimeCore().__internal_setOptions(u)},n[26]=u,n[27]=f.threads,n[28]=y):y=n[28],oS(y);let b;n[29]===f.threads?b=n[30]:(b=()=>{let e=f.threads.getMainThreadRuntimeCore().__internal_load();m.current!==e&&(m.current=e,e.catch(cF))},n[29]=f.threads,n[30]=b);let x;n[31]===f?x=n[32]:(x=[f],n[31]=f,n[32]=x),oS(b,x);let S,C;n[33]!==o||n[34]!==f?(S=()=>{if(o)return f.registerModelContextProvider(o)},C=[o,f],n[33]=o,n[34]=f,n[35]=S,n[36]=C):(S=n[35],C=n[36]),oS(S,C);let w;n[37]===f?w=n[38]:(w=()=>new FA(f),n[37]=f,n[38]=w);let[T]=tS(w);return T},sF=(e,{cloud:t,...n}={})=>Jj({runtimeHook:function(){return oF(e,n)},adapter:WP({cloud:t}),allowNesting:!0});function cF(e){console.error(`[assistant-ui] local thread history load failed:`,e)}function lF(e,t){function n(n){let r=yS(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function uF(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var dF=_S(null),{useThreadViewport:fF,useThreadViewportStore:pF}=uF(lF(dF,`ThreadPrimitive.Viewport`),`useThreadViewport`),mF=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},hF=(e=>e?mF(e):mF),gF=e=>e;function _F(e,t=gF){let n=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(n),n}var vF=e=>{let t=hF(e),n=e=>_F(t,e);return Object.assign(n,t),n},yF=(e=>e?vF(e):vF),bF=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},xF=(e={})=>{let t=new Set,n=bF(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=bF(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=yF(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{DC(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},SF=e=>e,CF=e=>{let t=$(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=pF(n),i;t[1]===e?i=t[2]:(i=()=>xF(e),t[1]=e,t[2]=i);let[a]=tS(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),oS(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&SF(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),oS(c,l),a},wF=e=>{let t=$(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=CF(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=tS(o),c;return t[4]!==n||t[5]!==s?(c=(0,q.jsx)(dF.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},TF=()=>{let e=$(3),t=lT(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),oS(n,r),null},EF=hS(e=>{let t=$(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,q.jsx)(TF,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,q.jsx)(wF,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,q.jsxs)(hO,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),DF={surface:{kWkggS:`x1prclbq`,kaIpWk:`x1hviunn`,kGVxlE:`x1i5ehqx`,$$css:!0},contentWrapper:{kVAEAm:`x1n2onr6`,$$css:!0},closeButtonWrapper:{kVAEAm:`x10l6tqk`,krVfgx:`x1ey2m1c`,kY2c9j:`x1vjfegm`,kzqmXN:`x1i1rx1s x10okhzq`,kZKoxP:`xjm9jq1 x132qfvm`,kVQacm:`xb3r6kr x1dordxg`,kz4h6p:`x1hyvwdk x10wafsz`,kfzvcC:`x47corl xbt4iw`,kLKAdn:`xexx8yu x1kw28su`,$$css:!0}};function OF(e={}){let{onShow:t,onHide:n,xstyle:r,hasLightDismiss:i=!0,hasEscapeDismiss:a=!0,hasAutoFocus:o=!0,hasSurface:s=!0,hasCloseButton:c=!0,closeButtonLabel:l,dialogLabel:u,role:d=`dialog`,isModal:f=!0}=e,p=Gs(),m=l??p(`@astryx.popover.close`),h=(0,v.useRef)(null),g=(0,v.useRef)(!1),_=Ta({mode:`context`,lightDismiss:i,onShow:t,onHide:n}),{containerRef:y,focusFirst:b}=zl({isActive:_.isOpen,onEscape:a||i?_.hide:void 0});(0,v.useEffect)(()=>{_.isOpen&&o&&!g.current&&requestAnimationFrame(()=>{b()}),_.isOpen||(g.current=!1)},[_.isOpen,o,b]);let x=(0,v.useCallback)(e=>{h.current=e,_.ref(e)},[_]),S=(0,v.useCallback)(e=>{g.current=e?.skipAutoFocus??!1,_.show()},[_]),C=(0,v.useCallback)(()=>{_.isOpen?_.hide():S()},[_,S]),T={"aria-haspopup":d===`dialog`?`dialog`:`true`,"aria-expanded":_.isOpen,"aria-controls":_.id};ql(`usePopover`,'role="dialog" without a `dialogLabel` renders an unnamed dialog. Pass `dialogLabel`, or use `role: "none"` for listbox/menu popups whose content already carries its own role.',d===`dialog`&&!u);let E=(0,v.useCallback)((e,t)=>_.render((0,q.jsxs)(`div`,{ref:y,role:d===`dialog`?`dialog`:void 0,"aria-modal":d===`dialog`&&f?!0:void 0,"aria-label":d===`dialog`?u:void 0,...w(DF.contentWrapper,s&&DF.surface,r),children:[e,c&&(0,q.jsx)(`div`,{...w(DF.closeButtonWrapper,Bi.centerInline(`100%`)),children:(0,q.jsx)(ec,{variant:`secondary`,label:m,onClick:_.hide})})]}),{...t,xstyle:t?.xstyle}),[_,c,s,m,y,u,d,f,r]);return{triggerRef:x,contentRef:y,anchorId:_.anchorId,show:S,hide:_.hide,toggle:C,isOpen:_.isOpen,id:_.id,render:E,triggerProps:T}}var kF={dropdown:{kB7OPa:`x9f619`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kOIVth:`x1lsbc85`,kskxy:`xuyqlj2`,kORKVm:`x1odjw0f`,"--_dropdown-menu-radius":`x1fcsqxe`,"--_dropdown-menu-padding":`xgory14`,kmVPX3:`x9epnlk`,kaIpWk:`x1n97fys`,kSiTet:`x1hc1fzr`,k1ekBW:`x19991ni`,kIyJzY:`xuedmi6`,kAMwcw:`xlr8y92`,$$css:!0},popover:{k7Eaqz:`xrzjruh`,$$css:!0},popoverCustomWidth:e=>[{k7Eaqz:(typeof e==`number`?`${e}px`:e)==null?typeof e==`number`?`${e}px`:e:`xkj4a21`,$$css:!0},{"--x-minWidth":(e=>typeof e==`number`?e+`px`:e??void 0)(typeof e==`number`?`${e}px`:e)}]},AF=`@astryx.dropdownMenu.label`;function jF({button:e,isMenuOpen:t,onOpenChange:n,menuWidth:r,onClick:i,hasChevron:a=!0,placement:o=`below`,alignment:s=`start`,className:c,style:l,xstyle:u,"data-testid":d,...f}){let p=Gs(),m=e??{label:p(AF)},h=(`items`in f?f.items:void 0)??[],g=f.children,{items:_,children:y,...b}=f,x=(0,v.useId)(),S=m.size??`md`,C=(0,v.useRef)(null),[T,E]=(0,v.useState)(!1),D=t!==void 0,k=D?t:T,A=(0,v.useRef)(0),j=(0,v.useCallback)(()=>{A.current=Date.now(),n?.(!1),D||E(!1),C.current?.focus()},[D,n]),M=(0,v.useRef)(!1),N=(0,v.useRef)(`keyboard`),P=OF({onHide:j,onShow:(0,v.useCallback)(()=>{n?.(!0),D||E(!0)},[D,n]),hasLightDismiss:!0,hasCloseButton:!1,hasAutoFocus:!1,role:`none`}),F=(0,v.useCallback)(()=>{P.hide()},[P]),{listRef:I,handleKeyDown:L,focusFirst:R,focusItem:z,ownsEvent:B,getItems:V}=Wl({itemSelector:$d,boundarySelector:ef,wrap:!1,onEscape:F}),H=Kl({getItemLabels:()=>V().map(e=>e.textContent),onMatch:z,getCurrentIndex:()=>V().findIndex(e=>e===document.activeElement||e.contains(document.activeElement))});(0,v.useEffect)(()=>{D&&(t&&!P.isOpen?(M.current=!0,P.show()):!t&&P.isOpen&&P.hide())},[t,D,P]),(0,v.useEffect)(()=>{!P.isOpen||!M.current||(M.current=!1,requestAnimationFrame(()=>{(N.current===`pointer`||!R())&&I.current?.focus(),N.current=`keyboard`}))},[P.isOpen,R,I]);let U=(0,v.useCallback)(e=>{if(B(e)){if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=document.activeElement;t&&Qd.has(t.getAttribute(`role`)??``)&&t.click();return}if(e.key===`Tab`){F();return}if(H.onKeyDown(e)){e.preventDefault();return}L(e)}},[L,F,H,B]),W=(0,v.useCallback)((e=`keyboard`)=>{N.current=e,M.current=!0,P.show()},[P]),ee=(0,v.useCallback)(e=>{if(Date.now()-A.current<50)return;i?.();let r=e.detail===0?`keyboard`:`pointer`;D?(t||(N.current=r),n?.(!t)):P.isOpen?P.hide():W(r)},[i,D,n,t,P,W]),te=(0,v.useCallback)(e=>{P.isOpen||(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),W())},[P.isOpen,W]),ne=m.isIconOnly===!0,re=m.endContent??(a&&!ne?(0,q.jsx)(fa,{icon:`chevronDown`,size:`sm`,color:`inherit`}):void 0),ie=r?kF.popoverCustomWidth(r):kF.popover,ae=(0,v.useMemo)(()=>({closeMenu:F,menuSize:S}),[F,S]),oe=f.items===void 0?g:lf(h);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ec,{...m,ref:e=>{C.current=e,P.triggerRef(e);let t=m.ref;typeof t==`function`?t(e):t&&(t.current=e)},tooltip:k?void 0:m.tooltip,endContent:re,onClick:ee,onKeyDown:te,"aria-haspopup":`menu`,"aria-expanded":k,"aria-controls":x,"data-testid":d}),P.render((0,q.jsx)(`div`,{...b,ref:I,id:x,role:`menu`,tabIndex:-1,"aria-label":m.label,onKeyDown:U,...J(Y(`dropdown-menu`),w(kF.dropdown,u),c,l),children:(0,q.jsx)(Id,{value:ae,children:oe})}),{placement:o,alignment:s,offset:O[`--spacing-1`],xstyle:[ie,Ea[o]]})]})}jF.displayName=`DropdownMenu`;var MF={popoverSurface:{k7Eaqz:`xfb3i0g`,$$css:!0}};function NF(e){let t=window.getSelection();if(!t||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!n.collapsed||!e.contains(n.startContainer))return null;let r=n.startContainer;return r.nodeType===Node.TEXT_NODE?(r.textContent??``).slice(0,n.startOffset):null}function PF(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r===` `||r===`
|
|
127
|
+
`)return null;for(let i of t)if(r===i.character){let t=n>0?e[n-1]:null;if(t===null||t===` `||t===`
|
|
128
|
+
`)return{trigger:i,query:e.slice(n+1),triggerStart:n}}}return null}function FF(e,t){let n=window.getSelection();if(!n||n.rangeCount===0)return;let r=n.getRangeAt(0),i=r.startContainer;if(i.nodeType!==Node.TEXT_NODE)return;let a=i.textContent??``,o=r.startOffset;i.textContent=a.slice(0,t)+a.slice(o);let s=document.createRange();s.setStart(i,t),s.collapse(!0),n.removeAllRanges(),n.addRange(s)}function IF(e){let t=Gs(),{triggers:n,editableRef:r,onInsertToken:i,onInsertText:a,onEmitChange:o,debounceMs:s=150}=e,c=(0,v.useId)(),[l,u]=(0,v.useState)({isActive:!1,activeTrigger:null,query:``,items:[],highlightedIndex:0,isLoading:!1}),d=(0,v.useRef)(-1),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(()=>{p.current&&=(p.current.remove(),null)},[]),h=OF({onHide:(0,v.useCallback)(()=>{m(),u(e=>({...e,isActive:!1,activeTrigger:null,query:``,items:[],highlightedIndex:0,isLoading:!1}))},[m]),hasLightDismiss:!0,hasCloseButton:!1,hasAutoFocus:!1,role:`none`});(0,v.useEffect)(()=>()=>{f.current&&clearTimeout(f.current),m()},[m]);let g=(0,v.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null);let e=l.activeTrigger;e?.searchSource&&e.searchSource.cancel?.(),m(),h.hide(),d.current=-1},[h,l.activeTrigger,m]),_=(0,v.useCallback)(()=>{let e=r.current;if(!e)return;let t=window.getSelection();if(!t||t.rangeCount===0){h.triggerRef(e);return}m();let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let i=typeof n.getBoundingClientRect==`function`?n.getBoundingClientRect():null;if(!i||i.width===0&&i.height===0&&i.top===0&&i.left===0){h.triggerRef(e);return}let a=document.createElement(`span`);a.setAttribute(`aria-hidden`,`true`),a.setAttribute(`data-astryx-trigger-anchor`,``),a.style.position=`fixed`,a.style.left=`${i.left}px`,a.style.top=`${i.top}px`,a.style.width=`${Math.max(i.width,1)}px`,a.style.height=`${i.height}px`,a.style.pointerEvents=`none`,a.style.opacity=`0`,document.body.appendChild(a),p.current=a,h.triggerRef(a)},[r,h,m]),y=(0,v.useCallback)((e,t)=>{f.current&&=(clearTimeout(f.current),null);let n=()=>{if(e.searchSource){e.searchSource.cancel?.(),u(e=>({...e,isLoading:!0}));let n=e.searchSource.search(t);Promise.resolve(n).then(e=>{u(t=>({...t,items:e,highlightedIndex:e.length>0?0:-1,isLoading:!1}))},()=>{u(e=>({...e,items:[],highlightedIndex:-1,isLoading:!1}))})}};e.searchSource&&(e.searchSource.search(``)instanceof Promise&&s>0?(u(e=>({...e,isLoading:!0})),f.current=setTimeout(n,s)):n())},[s]),b=(0,v.useCallback)(e=>{let t=l.activeTrigger;if(!t)return;let n=r.current;if(!n)return;m(),FF(n,d.current);let s=t.onSelect(e);typeof s==`string`?a(s):i(s),o(),g()},[l.activeTrigger,r,m,a,i,o,g]),x=(0,v.useCallback)(()=>{if(!n||n.length===0)return;let e=r.current;if(!e)return;let t=NF(e);if(t===null){l.isActive&&g();return}let i=PF(t,n);if(!i){l.isActive&&g();return}let{trigger:a,query:o,triggerStart:s}=i;!l.isActive||l.activeTrigger!==a?(d.current=s,u(e=>({...e,isActive:!0,activeTrigger:a,query:o,highlightedIndex:0})),_(),y(a,o),h.show()):l.query!==o&&(u(e=>({...e,query:o})),y(a,o))},[n,r,l.isActive,l.activeTrigger,l.query,g,_,y,h]),S=(0,v.useCallback)(e=>{if(!l.isActive||!h.isOpen)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),u(e=>({...e,highlightedIndex:e.highlightedIndex<e.items.length-1?e.highlightedIndex+1:0})),!0;case`ArrowUp`:return e.preventDefault(),u(e=>({...e,highlightedIndex:e.highlightedIndex>0?e.highlightedIndex-1:e.items.length-1})),!0;case`Enter`:case`Tab`:return l.highlightedIndex>=0&&l.highlightedIndex<l.items.length&&(e.preventDefault(),b(l.items[l.highlightedIndex]),!0);case`Escape`:return e.preventDefault(),g(),!0;default:return!1}},[l.isActive,l.highlightedIndex,l.items,h.isOpen,b,g]),C=(0,v.useCallback)(e=>`${c}-option-${e}`,[c]);(0,v.useEffect)(()=>{!h.isOpen||l.highlightedIndex<0||document.getElementById(C(l.highlightedIndex))?.scrollIntoView({block:`nearest`})},[l.highlightedIndex,h.isOpen,C]);let w=(n?.length??0)>0?l.isActive&&h.isOpen?{role:`combobox`,"aria-expanded":!0,"aria-controls":c,"aria-activedescendant":l.highlightedIndex>=0?C(l.highlightedIndex):void 0,"aria-haspopup":`listbox`}:{role:`combobox`,"aria-expanded":!1,"aria-haspopup":`listbox`}:{role:`textbox`};return{state:l,handleInput:x,handleKeyDown:S,renderMenu:(0,v.useCallback)(()=>{let e=l.activeTrigger,n=e?.emptySearchResultsText??`No results`,r=e?.loadingText??`Searching…`,i;if(l.isLoading)i=(0,q.jsx)(`div`,{role:`status`,className:`x1b2ylru x2b8uid x141an7d xv1l7n4`,children:r});else if(l.items.length===0&&l.isActive)i=(0,q.jsx)(`div`,{className:`x1b2ylru x2b8uid x141an7d xv1l7n4`,children:n});else{let t=Mi(l.items),n=0;i=t.map(t=>{let r=t.items.map(t=>{let r=n++;return(0,q.jsx)(`div`,{id:C(r),role:`option`,"aria-selected":r===l.highlightedIndex,tabIndex:-1,onMouseDown:e=>{e.preventDefault(),b(t)},onMouseEnter:()=>u(e=>({...e,highlightedIndex:r})),...{0:{className:`x9f619 x78zum5 x6s0dn4 xh8yej3 xlsj2fj xh6dtrn x1ypdohk x1a2a7pz xjbqb8w x1yc453h x9ynric xjm74w1 xw6l6zx x1tgivj0`},1:{className:`x9f619 x78zum5 x6s0dn4 xh8yej3 xlsj2fj xh6dtrn x1ypdohk x1a2a7pz x1yc453h x9ynric xjm74w1 xw6l6zx x1tgivj0 x1lmrjuc`}}[(r===l.highlightedIndex)<<0],children:e?.renderItem?e.renderItem(t):(0,q.jsx)(`span`,{className:`x98rzlu xeuugli xb3r6kr xlyipyv xuxw1ft`,children:t.label})},t.id)});return t.heading?(0,q.jsxs)(`div`,{role:`group`,"aria-label":t.heading,children:[(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`xf314gf x1xye8es xy143xn x141an7d x1ltkj2j xv1l7n4 x87ps6o`,children:t.heading}),r]},`group-${t.heading}`):r})}return h.render((0,q.jsx)(`div`,{id:c,role:`listbox`,"aria-label":e?.menuLabel??t(`@astryx.chatTriggerMenu.suggestions`),...J(Y(`trigger-menu`),{className:`x9f619 x1xiyphd x1odjw0f x9epnlk xfb3i0g`}),children:i}),{placement:`above`,alignment:`start`,offset:O[`--spacing-1`],xstyle:MF.popoverSurface})},[h,c,l,b,C,t]),reset:g,ariaProps:w}}function LF(e){let t=window.getSelection();if(!t)return null;if(t.rangeCount>0){let n=t.getRangeAt(0);if(e.contains(n.startContainer))return t}let n=document.createRange();return n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t}function RF(e,t){let n=LF(e);if(!n||n.rangeCount===0)return!1;let r=n.getRangeAt(0);r.deleteContents();let i=document.createTextNode(t);return r.insertNode(i),r.setStartAfter(i),r.collapse(!0),n.removeAllRanges(),n.addRange(r),!0}function zF(e){return`render`in e&&typeof e.render==`function`}function BF(e){let t=e;for(;t;){if(t instanceof HTMLElement&&t.hasAttribute(`data-astryx-token`))return t;t=t.parentNode}return null}function VF({editableRef:e,onEmitChange:t}){let[n,r]=(0,v.useState)([]),i=(0,v.useCallback)(t=>{let n=e.current;if(!n)return;let i=LF(n);if(!i||i.rangeCount===0)return;let a=i.getRangeAt(0),o=document.createElement(`span`),s=`token-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;o.setAttribute(`data-astryx-token`,``),o.setAttribute(`data-astryx-token-value`,t.value),o.setAttribute(`data-astryx-token-id`,s),o.contentEditable=`false`,o.style.display=`inline-flex`,o.style.verticalAlign=`baseline`,a.deleteContents(),a.insertNode(o);let c=document.createTextNode(`\xA0`);o.after(c);let l=document.createRange();return l.setStartAfter(c),l.collapse(!0),i.removeAllRanges(),i.addRange(l),r(e=>[...e,{id:s,span:o,token:t}]),s},[e]),a=(0,v.useCallback)(e=>{if(e.key!==`Backspace`)return!1;let n=window.getSelection();if(!n||!n.isCollapsed||n.rangeCount===0)return!1;let{startContainer:r,startOffset:i}=n.getRangeAt(0);if(r.nodeType===Node.TEXT_NODE&&i===0&&r.previousSibling instanceof HTMLElement&&r.previousSibling.hasAttribute(`data-astryx-token`))return!1;if(r.nodeType===Node.TEXT_NODE&&r.textContent===`\xA0`&&i<=1&&r.previousSibling instanceof HTMLElement&&r.previousSibling.hasAttribute(`data-astryx-token`)){e.preventDefault();let n=r.previousSibling,i=r.parentNode;return i&&(i.removeChild(r),i.removeChild(n)),t(),!0}return!1},[t]),o=(0,v.useCallback)(n=>{let r=e.current;if(!r)return!1;let i=LF(r);if(!i||i.rangeCount===0)return!1;let a=BF(i.getRangeAt(0).startContainer);if(a){n.preventDefault();let e=n.clipboardData.getData(`text/plain`),o=a.nextSibling,s=document.createRange();return o&&o.nodeType===Node.TEXT_NODE?s.setStartAfter(o):s.setStartAfter(a),s.collapse(!0),i.removeAllRanges(),i.addRange(s),RF(r,e),t(),!0}return!1},[e,t]);return{tokenPortals:n,expandToken:(0,v.useCallback)(i=>{if(!e.current)return;let a=n.find(e=>e.id===i);if(!a)return;let{span:o}=a,s=o.getAttribute(`data-astryx-token-value`)??``,c=document.createTextNode(s),l=o.nextSibling;l?.nodeType===Node.TEXT_NODE&&l.textContent===`\xA0`&&l.remove(),o.replaceWith(c);let u=window.getSelection();if(u){let e=document.createRange();e.setStartAfter(c),e.collapse(!0),u.removeAllRanges(),u.addRange(e)}r(e=>e.filter(e=>e.id!==i)),t()},[e,n,t]),insertToken:i,handleKeyDown:a,handlePaste:o,cleanupPortals:(0,v.useCallback)(()=>{r(t=>t.filter(t=>e.current?.contains(t.span)))},[e])}}var HF={base:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kOIVth:`xzye2dw`,kZKoxP:`x1grt7ep`,k8WAf4:`xt970qd`,kg3NbH:`xf314gf`,kaIpWk:`xjspbzw`,kMv6JI:`xjb2p0i`,kGuDYH:`x141an7d`,kLWn49:`x1ltkj2j`,k63SB2:`x1e4wzip`,khDVqt:`xuxw1ft`,$$css:!0}},UF={neutral:{kWkggS:`x17x4s8c`,kMwMTN:`x1tgivj0`,$$css:!0},info:{kWkggS:`x1ewilqj`,kMwMTN:`x17wrial`,$$css:!0},success:{kWkggS:`xdsz4j9`,kMwMTN:`xri61p4`,$$css:!0},warning:{kWkggS:`x1q8g9m5`,kMwMTN:`xrebv38`,$$css:!0},error:{kWkggS:`x1pjz0fi`,kMwMTN:`x1m024r3`,$$css:!0},blue:{kWkggS:`x1o0wnni`,kMwMTN:`x1vvqiwl`,$$css:!0},cyan:{kWkggS:`x1rgj867`,kMwMTN:`x1txnczv`,$$css:!0},green:{kWkggS:`x1sqjeoo`,kMwMTN:`xltfdvo`,$$css:!0},orange:{kWkggS:`x1e9xt6e`,kMwMTN:`xm47u9q`,$$css:!0},pink:{kWkggS:`xnpoty2`,kMwMTN:`xiuofww`,$$css:!0},purple:{kWkggS:`x16i6n6f`,kMwMTN:`x1m9wyeb`,$$css:!0},red:{kWkggS:`x1cibrc5`,kMwMTN:`x1joocv1`,$$css:!0},teal:{kWkggS:`x1jtji5o`,kMwMTN:`x9x0lbs`,$$css:!0},yellow:{kWkggS:`x1bo7t0x`,kMwMTN:`xdhq94a`,$$css:!0}};function WF({variant:e=`neutral`,label:t,icon:n,xstyle:r,className:i,style:a,ref:o,...s}){return(0,q.jsxs)(`span`,{ref:o,...J(Y(`badge`,{variant:e}),w(HF.base,UF[e],r),i,a),...s,children:[n,t]})}WF.displayName=`Badge`;var GF={container:{kWkggS:`x10xzikg`,"--_hovercard-radius":`xqwz7mz`,kaIpWk:`x7a53xk`,kGVxlE:`x14hfi27`,$$css:!0}};function KF(e){return e.hasAttribute(`tabindex`)?e.tabIndex>=0:[`A`,`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`].includes(e.tagName)?!e.disabled:!!e.isContentEditable}function qF(e={}){let{placement:t=`above`,alignment:n=`center`,delay:r=300,hideDelay:i=200,focusTrigger:a=`auto`,isEnabled:o=!0,label:s,isOpen:c,isDefaultOpen:l=!1,onShow:u,onHide:d}=e,f=Ta({mode:`context`,onShow:u,onHide:d}),p=GF.container,m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useRef)(null),_=(0,v.useRef)(!1),y=(0,v.useRef)(!1),b=(0,v.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null),h.current&&=(clearTimeout(h.current),null)},[]),x=(0,v.useCallback)(()=>{!o||c===!1||(b(),m.current=setTimeout(()=>{f.show()},r))},[o,c,b,f,r]),S=(0,v.useCallback)(()=>{c!==!0&&(b(),h.current=setTimeout(()=>{_.current||f.hide()},i))},[c,b,f,i]),C=(0,v.useCallback)(()=>{x()},[x]),w=(0,v.useCallback)(()=>{S()},[S]),T=(0,v.useCallback)(()=>{if(o){if(y.current){y.current=!1;return}b(),f.show()}},[o,b,f]),E=(0,v.useCallback)(e=>{let t=e.relatedTarget;document.getElementById(f.id)?.contains(t)||S()},[f.id,S]),D=(0,v.useCallback)(e=>{e.key===`Escape`&&(e.stopPropagation(),b(),f.hide())},[b,f]),k=(0,v.useCallback)(e=>{g.current&&(g.current.removeEventListener(`mouseenter`,C),g.current.removeEventListener(`mouseleave`,w),g.current.removeEventListener(`focusin`,T),g.current.removeEventListener(`focusout`,E),g.current.removeEventListener(`keydown`,D)),e&&(e.addEventListener(`mouseenter`,C),e.addEventListener(`mouseleave`,w),(a===`always`||a===`auto`&&KF(e))&&(e.addEventListener(`focusin`,T),e.addEventListener(`focusout`,E)),e.addEventListener(`keydown`,D)),g.current=e},[a,C,w,T,E,D]),A=(0,v.useCallback)(e=>{f.ref(e),k(e)},[f,k]);(0,v.useEffect)(()=>()=>{b()},[b]),(0,v.useEffect)(()=>{l&&f.show()},[]),(0,v.useEffect)(()=>{c!==void 0&&(c?(b(),f.show()):(b(),f.hide()))},[c,b,f]);let j=(0,v.useCallback)((e,r)=>{let i=r?.placement??t,a=Y(`hovercard`).className,o={placement:i,alignment:r?.alignment??n,offset:O[`--spacing-1`],role:s?`dialog`:`group`,"aria-label":s||void 0,xstyle:[p,Ea[i],r?.xstyle],className:r?.className?`${a} ${r.className}`:a,style:r?.style,as:`span`};return f.render((0,q.jsx)(`span`,{className:`x1lliihq x1vlblms xvmdzux x126nfab x1t818jl`,onMouseEnter:()=>{_.current=!0,b()},onMouseLeave:()=>{_.current=!1,S()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,b(),f.hide(),g.current?.focus())},onBlur:e=>{let t=e.relatedTarget;e.currentTarget.contains(t)||g.current?.contains(t)||S()},children:e}),o)},[f,t,n,s,b,S,p]);return{ref:A,positionRef:f.ref,interactionRef:k,anchorId:f.anchorId,describedBy:f.id,renderHoverCard:j,show:f.show,hide:f.hide}}function JF(e){return typeof e==`string`||typeof e==`number`}function YF(...e){let t=e.filter(Boolean);return t.length>0?t.join(` `):void 0}function XF({children:e,content:t,placement:n=`above`,alignment:r=`center`,delay:i=300,hideDelay:a=200,focusTrigger:o=`auto`,isEnabled:s=!0,label:c,onOpenChange:l,hasHoverIndication:u=`auto`,isOpen:d,isDefaultOpen:f,xstyle:p,className:m,style:h}){let g=(0,v.useRef)(null),_=JF(e),b=u===!0||u===`auto`&&_,x=qF({placement:n,alignment:r,delay:i,hideDelay:a,focusTrigger:o,isEnabled:s,label:c,isOpen:d,isDefaultOpen:f,onShow:(0,v.useCallback)(()=>{l?.(!0)},[l]),onHide:(0,v.useCallback)(()=>{l?.(!1)},[l])});y(()=>{if(_)return;let e=g.current;if(!e)return;let t=e.firstElementChild;if(!t)return;x.ref(t);let n=t.getAttribute(`aria-describedby`);return t.setAttribute(`aria-describedby`,YF(n,x.describedBy)??``),()=>{x.ref(null),n?t.setAttribute(`aria-describedby`,n):t.removeAttribute(`aria-describedby`)}},[_,x.ref,x.describedBy]);let S=x.renderHoverCard(t,{xstyle:p,className:m,style:h});return _?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{ref:x.ref,tabIndex:0,"aria-describedby":x.describedBy,...{0:{className:`xt0psk2`},1:{className:`xt0psk2 xujl8zx xev0dqp xycaml9 x11b3rvo`}}[!!b<<0],children:e}),S]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{ref:g,className:`xjp7ctv`,children:e}),S]})}XF.displayName=`HoverCard`;function ZF(e){let t=e.split(`
|
|
129
|
+
`).length,n=e.length;return t>1?`${t} lines, ${n} chars`:`${n} chars`}function QF({text:e,onExpand:t}){let n=Gs(),r=ZF(e),i=(0,q.jsxs)(`div`,{className:`x78zum5 xdt5ytf x1txdalj x17fpy1y`,children:[(0,q.jsx)(`div`,{className:`x9m5x89 x141an7d x1ltkj2j x1tgivj0 x126k92a x13faqbe x1xiyphd x1odjw0f`,children:e}),(0,q.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x1qughib x1txdalj`,children:[(0,q.jsx)(`span`,{className:`x141an7d xv1l7n4`,children:r}),t&&(0,q.jsx)(ec,{label:n(`@astryx.chat.pastedText.expand`),variant:`ghost`,size:`sm`,onClick:t})]})]});return(0,q.jsx)(XF,{content:i,placement:`above`,alignment:`start`,hasHoverIndication:!1,children:(0,q.jsx)(WF,{label:r,variant:`neutral`})})}QF.displayName=`ChatPastedTextToken`;function $F(e){let t=e.split(`
|
|
130
|
+
`).length,n=e.length;return{value:e,label:t>1?`${t} lines, ${n} chars`:`${n} chars`,variant:`neutral`}}function eI({inputRef:e,threshold:t=200,toToken:n=$F}){return{onPaste:(0,v.useCallback)((r,i)=>{if(i.length<=t)return!1;let a=n(i);return e.current?.insertToken(a),!0},[e,t,n])}}var tI=(0,v.createContext)(null);tI.displayName=`ChatMessageContext`;function nI(){return(0,v.use)(tI)}var rI=(0,v.createContext)(null);rI.displayName=`ChatListContext`;function iI(){return(0,v.use)(rI)}var aI=(0,v.createContext)(null);aI.displayName=`ChatComposerContext`;function oI(){return(0,v.use)(aI)}var sI=(0,v.createContext)(null);sI.displayName=`ChatLayoutContext`;function cI(){return(0,v.use)(sI)}var lI=l(h(),1),uI=22,dI={root:{kVAEAm:`x1n2onr6`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kAzted:`xe0957l`,$$css:!0},disabled:{kSiTet:`xbyyjgo`,kfzvcC:`x47corl`,$$css:!0}};function fI(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function pI(e){let t=``;for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t+=n.textContent??``:n instanceof HTMLElement&&(n.hasAttribute(`data-astryx-token`)?t+=n.getAttribute(`data-astryx-token-value`)??``:n.tagName===`BR`?t+=`
|
|
131
|
+
`:t+=pI(n));return t}function mI(e){let t=Gs(),n=oI(),r=e.value!==void 0,{ref:i,handleRef:a,value:o=n?.value,onChange:s,placeholder:c,maxRows:l=8,triggers:u,debounceMs:d=150,hasHistory:f=!0,label:p,isDisabled:m=n?.isDisabled??!1,onPaste:h,pasteAsToken:g,onFiles:_,onSubmit:y=n?.onSubmit,onKeyDown:b,xstyle:x,className:S,style:C,...T}=e,E=p??t(`@astryx.chat.composerInput.label`),D=c??n?.placeholder??t(`@astryx.chat.composer.placeholder`),O=n?.onChange,k=(0,v.useCallback)(e=>{if(r){s?.(e);return}O?.(e),s!==O&&s?.(e)},[O,r,s]),A=(0,v.useRef)(null),j=(0,v.useRef)(null),[M,N]=(0,v.useState)(!0),P=(0,v.useRef)([]),F=(0,v.useRef)(-1),I=(0,v.useRef)(``),L=(0,v.useRef)(void 0),R=(0,v.useRef)(()=>void 0),z=(0,v.useRef)(()=>{}),B={insertToken:e=>R.current(e),expandToken:e=>W.expandToken(e),insertText:e=>z.current(e),focus:()=>A.current?.focus(),getValue:()=>pI(A.current??document.createElement(`div`))};j.current=B,(0,v.useImperativeHandle)(a,()=>B);let V=n?.inputControlRef;(0,v.useEffect)(()=>{if(V)return V.current={focus:()=>A.current?.focus()},()=>{V.current=null}},[V]),(0,v.useEffect)(()=>{if(o===void 0||!A.current)return;if(o===L.current){L.current=void 0;return}let e=A.current;if(pI(e)!==o){L.current=void 0;let t=document.activeElement===e;if(e.textContent=o,t){let t=window.getSelection();if(t){let n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}N(o.length===0)}else L.current=void 0},[o]);let H=(0,v.useRef)(null),U=(0,v.useCallback)(()=>{if(!A.current)return;let e=pI(A.current),t=A.current.querySelector(`[data-astryx-token], [data-astryx-dictation-interim]`)!=null,n=e.trim().length===0&&!t,r=n?``:e;L.current=r,N(n),k?.(r),H.current?.()},[k]),W=VF({editableRef:A,onEmitChange:U});H.current=W.cleanupPortals;let ee=eI({inputRef:j}),te=g===!1?null:g??ee,ne=(0,v.useCallback)(e=>{let t=A.current;t&&RF(t,e)},[]);R.current=W.insertToken,z.current=ne;let re=IF({triggers:u,editableRef:A,onInsertToken:W.insertToken,onInsertText:ne,onEmitChange:U,debounceMs:d}),ie=(0,v.useCallback)(()=>{U(),re.handleInput()},[U,re]),ae=(0,v.useCallback)(e=>{if(!re.handleKeyDown(e)&&(b?.(e),!e.defaultPrevented)){if(e.key===`Backspace`){let t=window.getSelection();if(t&&t.isCollapsed&&t.rangeCount>0){let{startContainer:n,startOffset:r}=t.getRangeAt(0);if(!(n.nodeType===Node.TEXT_NODE&&r===0&&n.previousSibling instanceof HTMLElement&&n.previousSibling.hasAttribute(`data-astryx-token`))&&n.nodeType===Node.TEXT_NODE&&n.textContent===`\xA0`&&r<=1&&n.previousSibling instanceof HTMLElement&&n.previousSibling.hasAttribute(`data-astryx-token`)){e.preventDefault();let t=n.previousSibling,r=n.parentNode;r&&(r.removeChild(n),r.removeChild(t)),U();return}}}if(e.key===`Enter`&&!e.shiftKey){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||(e.preventDefault(),!A.current))return;let t=pI(A.current).trim();if(!t)return;f&&(P.current.push(t),F.current=-1,I.current=``),y?.(t),A.current.textContent=``,N(!0),k?.(``);return}if(f&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){if(!A.current)return;let t=pI(A.current),n=P.current;if(n.length===0)return;if(e.key===`ArrowUp`){F.current===-1&&(I.current=t);let r=F.current===-1?n.length-1:Math.max(0,F.current-1);F.current=r,A.current.textContent=n[r],fI(A.current),U(),e.preventDefault()}else if(e.key===`ArrowDown`&&F.current!==-1){let t=F.current+1;t>=n.length?(F.current=-1,A.current.textContent=I.current,I.current&&fI(A.current)):(F.current=t,A.current.textContent=n[t],fI(A.current)),U(),e.preventDefault()}}}},[f,y,k,U,re,b]),oe=(0,v.useCallback)(e=>{let t=A.current;if(!t||(LF(t),W.handlePaste(e)))return;let n=Array.from(e.clipboardData.files);if(n.length>0){e.preventDefault(),_?.(n);return}e.preventDefault();let r=e.clipboardData.getData(`text/plain`);if(te?.onPaste(e,r)){U();return}if(h?.(e,r)){U();return}RF(t,r),U()},[_,h,U,W,te]),se=l*uI;return(0,q.jsxs)(`div`,{ref:i,...J(Y(`chat-composer-input`),w(dI.root,m&&dI.disabled,x),S,C),...T,children:[M&&(0,q.jsx)(`div`,{className:`x10l6tqk x13vifvy x1o0tod xtijo5x x47corl xv1l7n4 xjm74w1 x6pjikd x19v9tvf x9ynric x87ps6o x9epnlk`,"aria-hidden":`true`,children:D}),(0,q.jsx)(`div`,{ref:A,"aria-multiline":`true`,"aria-label":E,contentEditable:!m,suppressContentEditableWarning:!0,onInput:ie,onKeyDown:ae,onPaste:oe,...re.ariaProps,...J({className:`x1a2a7pz x126k92a x13faqbe x1odjw0f xjm74w1 x6pjikd x19v9tvf x9ynric x1tgivj0 xxugrtn x9epnlk`},{style:{maxHeight:`${se}px`}})}),re.renderMenu(),W.tokenPortals.filter(({span:e})=>e.isConnected).map(({id:e,span:t,token:n})=>(0,lI.createPortal)(zF(n)?(0,q.jsx)(`span`,{children:n.render()},e):n.value.length>(te===null?1/0:200)?(0,q.jsx)(QF,{text:n.value,onExpand:()=>W.expandToken(e)},e):(0,q.jsx)(WF,{label:n.label,variant:n.variant,icon:n.icon},e),t))]})}mI.displayName=`ChatComposerInput`;var hI={root:{kaIpWk:`xy0xnkn`,kmuXW:`x2lah0s`,$$css:!0}};function gI(e){let t=Gs(),n=oI(),{isStopShown:r=n?.isStopShown??!1,isDisabled:i=!(n?.canSend??!1),onSend:a,onStop:o=n?.onStop,sendIcon:s,stopIcon:c,size:l=`md`,xstyle:u,className:d,style:f,ref:p,...m}=e,h=a??(()=>n?.onSubmit(``)),g=ha(`stop`),_=ha(`arrowUp`);return(0,q.jsx)(ec,{ref:p,label:t(r?`@astryx.chatSendButton.stop`:`@astryx.chatSendButton.send`),variant:r?`secondary`:`primary`,size:l,icon:r?c??g:s??_,isIconOnly:!0,isDisabled:!r&&i,onClick:r?o:h,...m,...J(Y(`chat-send-button`),{className:d},f),xstyle:[hI.root,u]})}gI.displayName=`ChatSendButton`;var _I={body:{kVAEAm:`x1n2onr6`,kY2c9j:`xhtitgo`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kmVPX3:`x18oj4ui`,kOIVth:`x1txdalj`,kaIpWk:`x1xunbrq`,kWkggS:`x1prclbq`,kkrTdU:`x1ed109x`,kmkexE:`xrg7dcy`,$$css:!0},compact:{"--_chat-composer-padding":`x18zce08`,kOIVth:`xzye2dw`,$$css:!0}},vI={low:{kGVxlE:`x1i5ehqx xhouywz`,knuKkz:`xyavpck`,$$css:!0},none:{kMzoRj:`x1litavf`,ksu8eU:`x1y0btm7`,kVAM5u:`xvy26l8 x6q1khz`,kmVPX3:`x1b50gpf`,kGVxlE:`x1gnnqk1 x12y27fx xuihb5h`,$$css:!0}};function yI(e){let t=Gs(),{ref:n,onSubmit:r,onStop:i,isStopShown:a=!1,value:o,onChange:s,placeholder:c,isDisabled:l=!1,density:u=`balanced`,elevation:d=`low`,drawer:f,headerActions:p,headerContext:m,input:h,footerActions:g,sendActions:_,sendButton:y,status:b,statusPosition:x=`bottom`,xstyle:S,className:C,style:T,...E}=e,D=c??t(`@astryx.chat.composer.placeholder`),[O,k]=(0,v.useState)(``),A=o!==void 0,j=A?o:O,M=(0,v.useCallback)(e=>{A||k(e),s?.(e)},[A,s]),N=(0,v.useCallback)(()=>{let e=j.trim();!e||l||(r(e),M(``))},[j,l,r,M]),P=j.trim().length>0&&!l,F=(0,v.useRef)(null),I=(0,v.useRef)(null),L=(0,v.useCallback)(e=>{if(!e.target.closest(`button, a, [role="button"], [contenteditable="true"], [data-astryx-token]`)){if(I.current){I.current.focus();return}(F.current?.querySelector(`[contenteditable="true"], textarea`))?.focus()}},[]),R=b?(0,q.jsxs)(`div`,{role:b.type===`error`?`alert`:`status`,...{0:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x1htvmrp xvpcij2 xckg3cf xkvxy4d x6k0y1c`},4:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x2gtn7z x9jihrk x1z0f2p2 xy7p8pm xzc3kxz`},2:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x1htvmrp xvpcij2 xckg3cf xkvxy4d x6k0y1c x1pritpl x1joocv1`},6:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x2gtn7z x9jihrk x1z0f2p2 xy7p8pm xzc3kxz x1pritpl x1joocv1`},1:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x1htvmrp xvpcij2 xckg3cf xkvxy4d x6k0y1c x24i8r5 xdhq94a`},5:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x2gtn7z x9jihrk x1z0f2p2 xy7p8pm xzc3kxz x24i8r5 xdhq94a`},3:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x1htvmrp xvpcij2 xckg3cf xkvxy4d x6k0y1c x24i8r5 xdhq94a`},7:{className:`x1n2onr6 x1ja2u2z x78zum5 x6s0dn4 x1txdalj x1pzlopt x141an7d x1ltkj2j x9ynric x2gtn7z x9jihrk x1z0f2p2 xy7p8pm xzc3kxz x24i8r5 xdhq94a`}}[(x===`top`)<<2|(b.type===`error`)<<1|(b.type===`warning`)<<0],children:[(0,q.jsx)(fa,{icon:b.type===`error`?`error`:`warning`,size:`md`,color:b.type===`error`?`error`:`warning`}),b.message]}):null,z=(0,v.useMemo)(()=>({value:j,onChange:M,onSubmit:N,placeholder:D,isDisabled:l,isStopShown:a,canSend:P,onStop:i,inputControlRef:I}),[j,M,N,D,l,a,P,i]);return(0,q.jsx)(aI,{value:z,children:(0,q.jsxs)(`div`,{ref:n,...J(Y(`chat-composer`,{density:u}),{0:{className:`x1n2onr6 x1ja2u2z xc8icb0 x78zum5 xdt5ytf xx161y6 xk0ittl xcw7vlg`},1:{className:`x1n2onr6 x1ja2u2z xc8icb0 x78zum5 xdt5ytf xx161y6 xk0ittl xcw7vlg x197sbye x47corl`}}[!!l<<0],C,T),...E,children:[x===`top`&&R,f,(0,q.jsxs)(`div`,{ref:F,onClick:L,...w(_I.body,vI[d],u===`compact`&&_I.compact,S),children:[(p||m)&&(0,q.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x1qughib x1txdalj xe0p6wg`,children:[(0,q.jsx)(`div`,{className:`x78zum5 x6s0dn4 xzye2dw`,children:p}),(0,q.jsx)(`div`,{className:`x78zum5 x6s0dn4 x1txdalj xvc5jky x141an7d x1ltkj2j xv1l7n4`,children:m})]}),(0,q.jsx)(`div`,{className:`x78zum5 xdt5ytf`,children:h??(0,q.jsx)(mI,{})}),(0,q.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x1qughib x1txdalj x21xpn4`,children:[(0,q.jsx)(`div`,{className:`x78zum5 x6s0dn4 xzye2dw`,children:g}),(0,q.jsxs)(`div`,{className:`x78zum5 x6s0dn4 xzye2dw`,children:[_,y??(0,q.jsx)(gI,{})]})]})]}),x===`bottom`&&R]})})}yI.displayName=`ChatComposer`;var bI={root:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUk6DE:`x98rzlu`,kAzted:`x2lwn1j`,$$css:!0},inner:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUk6DE:`x98rzlu`,kAzted:`x2lwn1j`,$$css:!0},gapCompact:{kOIVth:`x1txdalj`,k8WAf4:`xce4md1`,kg3NbH:`xrrkdod`,$$css:!0},gapBalanced:{kOIVth:`x18g69wz`,k8WAf4:`x1na6nto`,kg3NbH:`x1pzlopt`,$$css:!0},gapSpacious:{kOIVth:`x1qh66ti`,k8WAf4:`xq6koh6`,kg3NbH:`xm7rs69`,$$css:!0}},xI={0:{kOIVth:`xsn7fz1`,$$css:!0},1:{kOIVth:`xzye2dw`,$$css:!0},2:{kOIVth:`x1txdalj`,$$css:!0},3:{kOIVth:`xjcht0a`,$$css:!0},4:{kOIVth:`x18g69wz`,$$css:!0},5:{kOIVth:`x9mgr7n`,$$css:!0},6:{kOIVth:`x1qh66ti`,$$css:!0},8:{kOIVth:`x4t41sb`,$$css:!0},10:{kOIVth:`x3hoi3v`,$$css:!0},"0.5":{kOIVth:`x1lsbc85`,$$css:!0},"1.5":{kOIVth:`x1s4dlld`,$$css:!0}};function SI({children:e,emptyState:t,scrollToTopAction:n,density:r=`balanced`,gap:i,isStreaming:a=!1,xstyle:o,className:s,style:c,"data-testid":l,ref:u,...d}){let f=cI(),p=(0,v.useRef)(null),m=(0,v.useRef)(null),[h,g]=(0,v.useTransition)();(0,v.useEffect)(()=>{if(f?.contentRef&&m.current)return f.contentRef(m.current),()=>f.contentRef(null)},[f]);let _=e!=null&&e!==!1&&!(Array.isArray(e)&&e.length===0);(0,v.useEffect)(()=>{let e=f?.scrollContainerRef?.current;if(!n||!p.current)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&g(async()=>{await n()})},{root:e??null,threshold:0});return t.observe(p.current),()=>t.disconnect()},[n,f]);let y=(0,v.useMemo)(()=>({density:r}),[r]),b=r===`compact`?bI.gapCompact:r===`spacious`?bI.gapSpacious:bI.gapBalanced,x=i==null?null:xI[i];return(0,q.jsx)(rI,{value:y,children:(0,q.jsx)(`div`,{...d,ref:u,role:`log`,"aria-live":`polite`,"aria-busy":a||void 0,tabIndex:0,"data-testid":l,...J(Y(`chat-message-list`,{density:r}),w(bI.root,o),s,c),children:(0,q.jsxs)(`div`,{ref:m,...w(bI.inner,b,x),children:[n&&(0,q.jsx)(`div`,{ref:p,"aria-hidden":!0}),h&&(0,q.jsx)(`div`,{className:`x78zum5 xl56j7k x8o8v82`,children:(0,q.jsx)(ro,{size:`md`})}),(0,q.jsx)(`div`,{className:`x98rzlu x2lwn1j`,"aria-hidden":!0}),_?e:t?(0,q.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k x98rzlu x2lwn1j`,children:t}):null]})})})}SI.displayName=`ChatMessageList`;var CI={root:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,ks0D6T:`x193iq5w`,$$css:!0},rootGapCompact:{kOIVth:`x1s4dlld`,$$css:!0},rootGapBalanced:{kOIVth:`x1txdalj`,$$css:!0},rootGapSpacious:{kOIVth:`xjcht0a`,$$css:!0},rootAssistant:{kXwgrk:`x1q0g3np`,kjj79g:`x1nhvcw1`,$$css:!0},rootUser:{kXwgrk:`x15zctf7`,kjj79g:`x1nhvcw1`,$$css:!0},rootSystem:{kXwgrk:`x1q0g3np`,kjj79g:`xl56j7k`,$$css:!0},contentColumn:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,$$css:!0},contentColumnSystem:{ks0D6T:`xq8v1hd`,kGNEyG:`x6s0dn4`,$$css:!0},contentColumnAssistant:{kGNEyG:`x1cy8zhl`,$$css:!0},contentColumnUser:{kGNEyG:`xuk3077`,$$css:!0},childrenWrap:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,k7Eaqz:`xeuugli`,kzqmXN:`xh8yej3`,$$css:!0},childrenAssistant:{kGNEyG:`x1cy8zhl`,$$css:!0},childrenUser:{kGNEyG:`xuk3077`,$$css:!0},childrenSystem:{kGNEyG:`x6s0dn4`,$$css:!0},childrenGapCompact:{kOIVth:`x1lsbc85`,$$css:!0},childrenGapBalanced:{kOIVth:`xzye2dw`,$$css:!0},childrenGapSpacious:{kOIVth:`x1s4dlld`,$$css:!0}};function wI({sender:e,children:t,avatar:n,name:r,metadata:i,density:a,xstyle:o,className:s,style:c,"data-testid":l,ref:u,...d}){let f=Gs(),p=iI(),m=a??p?.density??`balanced`,h=(0,v.useMemo)(()=>({sender:e,density:m}),[e,m]),g=m===`compact`?CI.rootGapCompact:m===`spacious`?CI.rootGapSpacious:CI.rootGapBalanced,_=m===`compact`?CI.childrenGapCompact:m===`spacious`?CI.childrenGapSpacious:CI.childrenGapBalanced,y=e===`system`?CI.rootSystem:e===`user`?CI.rootUser:CI.rootAssistant,b=e===`system`?CI.contentColumnSystem:e===`user`?CI.contentColumnUser:CI.contentColumnAssistant,x=e===`system`?CI.childrenSystem:e===`user`?CI.childrenUser:CI.childrenAssistant,S=e===`system`,C=n!=null&&!S,T=r!=null&&!S,E=(0,v.useId)();return(0,q.jsx)(tI,{value:h,children:(0,q.jsxs)(`article`,{...d,ref:u,"data-testid":l,"aria-label":T?void 0:f(`@astryx.chatMessage.messageFrom`,{sender:e}),"aria-labelledby":T?E:void 0,...J(Y(`chat-message`,{sender:e,density:m}),w(CI.root,y,C&&g,o),s,c),children:[C&&(0,q.jsx)(`div`,{className:`x2lah0s x5du68j`,children:n}),(0,q.jsxs)(`div`,{...w(CI.contentColumn,b),children:[T&&(0,q.jsx)(`div`,{id:E,className:`x141an7d x2mo6ok xv1l7n4 x1ltkj2j x14cgwvg`,children:r}),(0,q.jsx)(`div`,{...w(CI.childrenWrap,x,_),children:t}),i!=null&&!S&&(0,q.jsx)(`div`,{children:i})]})]})})}wI.displayName=`ChatMessage`;var TI={content:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,ks0D6T:`xl6temz`,kaIpWk:`xashgol`,kMv6JI:`x9ynric`,kGuDYH:`xjm74w1`,kLWn49:`xw6l6zx`,kHjlTd:`x1mzt3pk`,kTgw9:`x13faqbe`,$$css:!0},radiusCompact:{kaIpWk:`x1hviunn`,$$css:!0},paddingCompact:{k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0},paddingBalanced:{k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0},paddingSpacious:{k8WAf4:`x1na6nto`,kg3NbH:`xzz68wx`,$$css:!0},paddingBlockNone:{k8WAf4:`xt970qd`,$$css:!0},metadataPaddingCompact:{kg3NbH:`x1pzlopt`,$$css:!0},metadataPaddingBalanced:{kg3NbH:`x1pzlopt`,$$css:!0},metadataPaddingSpacious:{kg3NbH:`xzz68wx`,$$css:!0},metadataReducedGap:{keoZOQ:`x1c40v9y`,$$css:!0},headerReducedGap:{k1K539:`xdrfirk`,$$css:!0},nameRow:{kZKoxP:`x1grt7ep`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,$$css:!0},alignEnd:{k9WMMc:`xp4054r`,$$css:!0},assistant:{kWkggS:`x17x4s8c`,kMwMTN:`x1tgivj0`,$$css:!0},user:{kWkggS:`x17x4s8c`,kMwMTN:`x1tgivj0`,$$css:!0},ghost:{kWkggS:`xjbqb8w`,kMwMTN:`x1tgivj0`,$$css:!0},groupFirstAssistant:{kVL7Gh:`xrfs2vl`,$$css:!0},groupMiddleAssistant:{krdFHd:`x3qb8m`,kVL7Gh:`xrfs2vl`,$$css:!0},groupLastAssistant:{krdFHd:`x3qb8m`,$$css:!0},groupFirstUser:{kT0f0o:`x1whkvtz`,$$css:!0},groupMiddleUser:{kfmiAY:`x126per9`,kT0f0o:`x1whkvtz`,$$css:!0},groupLastUser:{kfmiAY:`x126per9`,$$css:!0}};function EI({children:e,variant:t=`filled`,name:n,metadata:r,group:i,xstyle:a,className:o,style:s,"data-testid":c,ref:l,...u}){let d=nI(),f=d?.sender??`assistant`,p=d?.density??`balanced`,m=p===`compact`?TI.paddingCompact:p===`spacious`?TI.paddingSpacious:TI.paddingBalanced,h=f===`user`,g=t===`ghost`?TI.ghost:h?TI.user:TI.assistant,_=i===`first`?h?TI.groupFirstUser:TI.groupFirstAssistant:i===`middle`?h?TI.groupMiddleUser:TI.groupMiddleAssistant:i===`last`?h?TI.groupLastUser:TI.groupLastAssistant:null,v=p===`compact`?TI.metadataPaddingCompact:p===`spacious`?TI.metadataPaddingSpacious:TI.metadataPaddingBalanced;return(0,q.jsxs)(q.Fragment,{children:[n&&(0,q.jsx)(`div`,{"data-chat-name":!0,...w(v,TI.nameRow,TI.headerReducedGap,h&&TI.alignEnd),children:n}),(0,q.jsx)(`div`,{...u,ref:l,"data-testid":c,...J(Y(`chat-message-bubble`,{sender:f,variant:t,density:p}),w(TI.content,p===`compact`&&TI.radiusCompact,g,m,t===`ghost`&&TI.paddingBlockNone,_,a),o,s),children:e}),r&&(0,q.jsx)(`div`,{...w(v,TI.metadataReducedGap,h&&TI.alignEnd),children:r})]})}EI.displayName=`ChatMessageBubble`;var DI=1e3/60;function OI({scrollRef:e,enabled:t=!0,lockThreshold:n=10,buttonThreshold:r=100,damping:i=.7,stiffness:a=.05,mass:o=1.25}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!0),d=(0,v.useRef)(!0),f=(0,v.useRef)(!0),p=(0,v.useRef)(0),m=(0,v.useRef)(!1),h=(0,v.useRef)(void 0),g=(0,v.useRef)(0),_=(0,v.useRef)(0),y=(0,v.useRef)(0),b=(0,v.useCallback)(()=>{let t=e.current;if(!t||!d.current){m.current=!1,h.current=void 0,p.current=0;return}if(t.scrollHeight<=t.clientHeight){m.current=!1,h.current=void 0,p.current=0;return}let n=t.scrollHeight-t.clientHeight,r=n-t.scrollTop;if(Math.abs(r)<.5&&Math.abs(p.current)<.1){t.scrollTop=n,m.current=!1,h.current=void 0,p.current=0;return}let s=performance.now(),c=h.current?(s-h.current)/DI:1;h.current=s,p.current=(i*p.current+a*r)/o,t.scrollTop+=p.current*c,requestAnimationFrame(b)},[e,i,a,o]),x=(0,v.useCallback)(()=>{let t=e.current;t&&(m.current=!1,p.current=0,h.current=void 0,t.scrollTop=t.scrollHeight-t.clientHeight,g.current=t.scrollTop)},[e]),S=Ye(`(prefers-reduced-motion: reduce)`),C=(0,v.useCallback)(()=>{if(d.current){if(S){x();return}m.current||(m.current=!0,h.current=void 0,requestAnimationFrame(b))}},[b,x,S]),w=(0,v.useCallback)(e=>{if(d.current=!0,u(!0),c(!1),f.current=!1,e?.behavior===`instant`){x();return}C()},[C,x]),T=(0,v.useCallback)(t=>{let n=e.current;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect().top-r.top+n.scrollTop;n.scrollTo({top:i,behavior:`instant`}),g.current=n.scrollTop},[e]),E=(0,v.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getElementsByClassName(`astryx-chat-message`),r=n[n.length-1];r instanceof HTMLElement&&T(r)},[e,T]),D=(0,v.useCallback)(()=>{d.current=!0,u(!0),c(!1),C()},[C]),O=(0,v.useCallback)(()=>{d.current=!1,m.current=!1,u(!1)},[]),k=(0,v.useCallback)(()=>{if(!t||!d.current)return;let n=e.current;if(f.current&&n&&n.scrollHeight>n.clientHeight){f.current=!1,x();return}C()},[t,C,x,e]);return(0,v.useEffect)(()=>{let i=e.current;if(!i||!t)return;g.current=i.scrollTop,_.current=i.scrollHeight,y.current=i.offsetHeight;let a=()=>{let{scrollTop:e,scrollHeight:t,offsetHeight:n}=i,a=t-e-n;c(a>r);let o=t!==_.current,s=n!==y.current;if(_.current=t,y.current=n,o||s){g.current=e;return}let l=e<g.current;g.current=e,l&&d.current&&(d.current=!1,m.current=!1,u(!1))},o=()=>{i.scrollHeight-i.scrollTop-i.offsetHeight<=n&&(d.current=!0,u(!0))},s=e=>{e.deltaY<0&&m.current&&(d.current=!1,m.current=!1,u(!1))},l=()=>{m.current&&(d.current=!1,m.current=!1,u(!1))};return i.addEventListener(`scroll`,a,{passive:!0}),i.addEventListener(`scrollend`,o),i.addEventListener(`wheel`,s,{passive:!0}),i.addEventListener(`touchmove`,l,{passive:!0}),requestAnimationFrame(()=>{i.scrollHeight>i.clientHeight&&(i.scrollTop=i.scrollHeight-i.clientHeight,g.current=i.scrollTop,f.current=!1)}),()=>{i.removeEventListener(`scroll`,a),i.removeEventListener(`scrollend`,o),i.removeEventListener(`wheel`,s),i.removeEventListener(`touchmove`,l)}},[e,t,n,r]),{isScrolledUp:s,isLocked:l,scrollToBottom:w,scrollToMessage:T,lock:D,unlock:O,scrollIfLocked:k,scrollToLastMessage:E}}function kI({isLocked:e,onResize:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(null),a=(0,v.useRef)(e);a.current=e;let o=(0,v.useRef)(t);o.current=t;let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useCallback)(e=>{Ii(e,()=>{o.current?.();let t=e.getElementsByClassName(`astryx-chat-message`),n=t.length>0?t[t.length-1]:null;n&&n!==i.current&&(i.current=n,a.current||r(!0))}),c.current=()=>Li(e)},[]),u=(0,v.useCallback)(()=>{c.current?.(),c.current=null},[]),d=(0,v.useCallback)(e=>{e!==s.current&&(u(),s.current=e,e&&l(e))},[l,u]);return(0,v.useEffect)(()=>()=>u(),[u]),{hasNewMessages:n,dismiss:(0,v.useCallback)(()=>{r(!1)},[]),contentRef:d}}var AI={root:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,keoZOQ:`xtbrsbv`,$$css:!0},chevronTransition:{kmkexE:`x1ob6yzd x9kvfbb`,$$css:!0},chevronExpanded:{k3aq6I:`x19jd1h0`,$$css:!0},statusIcon:{kVAEAm:`x1n2onr6`,k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kmuXW:`x2lah0s`,kzqmXN:`x1kky2od`,kZKoxP:`xlup9mm`,kaIpWk:`xjspbzw`,$$css:!0},nodePill:{kmuXW:`x2lah0s`,$$css:!0},colorPending:{kMwMTN:`xnbbluu`,$$css:!0},colorRunning:{kMwMTN:`xqwr325`,$$css:!0},colorComplete:{kMwMTN:`xtjic6`,$$css:!0},colorError:{kMwMTN:`xjt36v0`,$$css:!0}},jI={pending:`clock`,running:null,complete:`check`,error:`close`},MI={pending:AI.colorPending,running:AI.colorRunning,complete:AI.colorComplete,error:AI.colorError};function NI(e){return wi(e.key,()=>[e.name,e.status??`complete`,e.target??``,e.node??``,e.duration??``,e.additions?.toString()??``,e.deletions?.toString()??``,e.errorMessage??``].join(``))}function PI({call:e}){let t=Gs(),n=e.status??`complete`,r=e.resultDetail!=null,[i,a]=(0,v.useState)(!1),o=(0,v.useId)(),s=r?()=>a(e=>!e):void 0,c=(0,q.jsxs)(`div`,{role:r?`button`:void 0,tabIndex:r?0:void 0,"aria-expanded":r?i:void 0,"aria-controls":r&&i?o:void 0,onClick:s,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s?.())}:void 0,...{0:{className:`x78zum5 x6s0dn4 x1s4dlld xjwf9q1 x13f7esw`},1:{className:`x78zum5 x6s0dn4 x1s4dlld xjwf9q1 x13f7esw x1ypdohk xh6dtrn x7a5moj xtedp8i xe9uy6x`}}[!!r<<0],children:[(0,q.jsxs)(`span`,{title:n===`error`?e.errorMessage:void 0,...w(AI.statusIcon,MI[n]),children:[n===`running`||n===`pending`?(0,q.jsx)(ro,{size:`sm`,shade:`subtle`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`x10l6tqk x10a8y8t x1pjcqnp xtwfq29 x1xyvc85`}),(0,q.jsx)(`span`,{className:`x1n2onr6 x3nfvp2`,children:(0,q.jsx)(fa,{icon:jI[n]??`check`,size:`xsm`,color:`inherit`})})]}),n===`error`&&e.errorMessage!=null&&(0,q.jsx)(io,{children:t(`@astryx.chatToolCalls.error`,{message:e.errorMessage??``})})]}),(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9m5x89 x1e4wzip xv1l7n4 xuxw1ft xb3r6kr xlyipyv xs83m0k x13n9wmd`,children:e.name}),e.node!=null&&(0,q.jsx)(WF,{label:e.node,variant:`neutral`,xstyle:AI.nodePill}),e.target!=null&&(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9ynric xnbbluu xuxw1ft xb3r6kr xlyipyv x1g3ib7 xeuugli`,children:e.target}),(e.additions!=null||e.deletions!=null||e.stats!=null)&&(0,q.jsxs)(`span`,{className:`x78zum5 x6s0dn4 xzye2dw x141an7d x1ltkj2j x9ynric xnbbluu x2lah0s`,children:[e.additions!=null&&(0,q.jsxs)(`span`,{className:`xtjic6`,children:[`+`,e.additions]}),e.deletions!=null&&(0,q.jsxs)(`span`,{className:`xjt36v0`,children:[`-`,e.deletions]}),e.stats]}),e.duration!=null&&n===`complete`&&(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9ynric xnbbluu xuxw1ft x2lah0s`,children:e.duration}),r&&(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 xl56j7k x2lah0s x6jxa94 x1v9usgg xnbbluu xvc5jky`,children:(0,q.jsx)(fa,{icon:`chevronDown`,size:`xsm`,color:`inherit`,xstyle:[AI.chevronTransition,i&&AI.chevronExpanded]})})]});return r?(0,q.jsxs)(`div`,{children:[c,i&&(0,q.jsx)(`div`,{id:o,className:`x1f43n9v x1wesfrj`,children:e.resultDetail})]}):c}function FI(e){let t=Gs(),{calls:n,label:r,isExpanded:i,defaultIsExpanded:a,onExpandedChange:o,xstyle:s,className:c,style:l,ref:u,...d}=e,[f,p]=(0,v.useState)(a??!1),m=(0,v.useId)(),h=i!==void 0,g=h?i:f,_=(0,v.useCallback)(()=>{let e=!g;h||p(e),o?.(e)},[g,h,o]);if(n.length===0)return null;if(n.length===1)return(0,q.jsx)(`div`,{ref:u,...J(Y(`chat-tool-calls`),w(AI.root,s),c,l),...d,children:(0,q.jsx)(PI,{call:n[0]})});let y=n[n.length-1],b=y.status??`complete`;return(0,q.jsxs)(`div`,{ref:u,...J(Y(`chat-tool-calls`),w(AI.root,s),c,l),...d,children:[(0,q.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":g,"aria-controls":m,onClick:_,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())},className:`x78zum5 x6s0dn4 x1s4dlld xjwf9q1 x13f7esw x1ypdohk`,children:[g?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 xl56j7k x2lah0s x1kky2od xlup9mm xv1l7n4`,children:(0,q.jsx)(fa,{icon:`wrench`,size:`sm`,color:`inherit`})}),(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9ynric x1e4wzip xv1l7n4`,children:t(`@astryx.chatToolCalls.groupLabel`,{count:n.length})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{...w(AI.statusIcon,MI[b]),children:b===`running`||b===`pending`?(0,q.jsx)(ro,{size:`sm`,shade:`subtle`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`x10l6tqk x10a8y8t x1pjcqnp xtwfq29 x1xyvc85`}),(0,q.jsx)(`span`,{className:`x1n2onr6 x3nfvp2`,children:(0,q.jsx)(fa,{icon:jI[b]??`check`,size:`xsm`,color:`inherit`})})]})}),(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9m5x89 x1e4wzip xv1l7n4 xuxw1ft xb3r6kr xlyipyv xs83m0k x13n9wmd`,children:y.name}),y.target!=null&&(0,q.jsx)(`span`,{className:`x141an7d x1ltkj2j x9ynric xnbbluu xuxw1ft xb3r6kr xlyipyv x1g3ib7 xeuugli`,children:y.target})]}),(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 x1lsbc85 x141an7d x1ltkj2j x9ynric xnbbluu x2lah0s`,children:!g&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(fa,{icon:`wrench`,size:`xsm`,color:`inherit`}),n.length]})}),(0,q.jsx)(`span`,{className:`x3nfvp2 x6s0dn4 xl56j7k x2lah0s x6jxa94 x1v9usgg xnbbluu`,children:(0,q.jsx)(fa,{icon:`chevronDown`,size:`xsm`,color:`inherit`,xstyle:[AI.chevronTransition,g&&AI.chevronExpanded]})})]}),(0,q.jsx)(`div`,{id:m,...{0:{className:`xrvj5dj xihq33y xb0j27v x9kvfbb`},1:{className:`xrvj5dj xb0j27v x9kvfbb x1tu4anv`}}[!!g<<0],children:(0,q.jsx)(`div`,{className:`xb3r6kr x2lwn1j x7a5moj xtedp8i`,children:(0,q.jsx)(`div`,{className:`x78zum5 xdt5ytf x7a5moj xtedp8i`,children:n.map(e=>(0,q.jsx)(PI,{call:e},NI(e)))})})})]})}FI.displayName=`ChatToolCalls`;var II={wrapper:{k1xSpc:`x78zum5`,kjj79g:`xl56j7k`,kGO01o:`xvmdzux`,$$css:!0},button:{"--radius-element":`xnpej1e`,khDVqt:`xuxw1ft`,kg3NbH:`xf314gf`,$$css:!0},buttonWithLabel:{kwRFfy:`x1t818jl`,$$css:!0}};function LI({ref:e,isVisible:t,label:n,onClick:r,xstyle:i,className:a,style:o,...s}){let c=Gs();return(0,q.jsx)(`div`,{ref:e,...J(Y(`chat-layout-scroll-button`),w(II.wrapper,i),a,o),...s,children:(0,q.jsx)(`div`,{...{0:{className:`xawy1a7 xb3r6kr xjspbzw x1prclbq x14hfi27 x10w6t97 x1apppo2 xlr8y92 x2rcmwa x12w9bfk xg01cxk x47corl x1x67gh`},2:{className:`xawy1a7 xb3r6kr xjspbzw x1prclbq x14hfi27 x10w6t97 x1apppo2 xlr8y92 x2rcmwa x12w9bfk x1hc1fzr x67bb7w x1x67gh`},1:{className:`xawy1a7 xb3r6kr xjspbzw x1prclbq x14hfi27 x10w6t97 x1apppo2 xlr8y92 x2rcmwa x12w9bfk xg01cxk x47corl x1ncir08`},3:{className:`xawy1a7 xb3r6kr xjspbzw x1prclbq x14hfi27 x10w6t97 x1apppo2 xlr8y92 x2rcmwa x12w9bfk x1hc1fzr x67bb7w x1ncir08`}}[!!t<<1|!!n<<0],children:(0,q.jsx)(ec,{label:n??c(`@astryx.chatLayoutScrollButton.scrollToBottom`),"aria-label":n??c(`@astryx.chatLayoutScrollButton.scrollToBottom`),icon:(0,q.jsx)(fa,{icon:`chevronDown`,size:`md`}),variant:`ghost`,size:`md`,isIconOnly:!n,onClick:r,xstyle:[II.button,n?II.buttonWithLabel:null],children:n??void 0})})})}LI.displayName=`ChatLayoutScrollButton`;var RI={root:{kVAEAm:`x1n2onr6`,k9g6sI:`x12h1iku`,kAzted:`x2lwn1j`,kUk6DE:`x98rzlu`,k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},rootScrollable:{kORKVm:`x1odjw0f`,kXHlph:`x6ikm8r`,k5wCbM:`x1mqgsch`,$$css:!0},messageArea:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kUOVxO:`xvueqy4`,kzQI83:`x1iyjqo2`,kmuXW:`x2lah0s`,kCS8Yb:`xdl72j9`,kGO01o:`xjpqqx5`,kzqmXN:`xh8yej3`,ks0D6T:`x193iq5w`,kg3NbH:`xnjsko4`,$$css:!0},blurLayer:{kVAEAm:`x10l6tqk`,krVfgx:`x1ey2m1c`,kLqNvP:`x1o0tod`,kt4wiu:`xtijo5x`,kfzvcC:`x47corl`,k6WDB:`xvn2z4z`,keRtuK:`x67t5t6`,kZKoxP:`xpyat2d`,kX1K2I:`xw26lqc`,kAExgp:`x1bv1mxo`,$$css:!0},dock:{kVAEAm:`x1n2onr6`,kY2c9j:`x1vjfegm`,kfzvcC:`x67bb7w`,kg3NbH:`xrrkdod`,kGO01o:`xvmdzux`,$$css:!0},dockInner:{kUOVxO:`xvueqy4`,kzqmXN:`xh8yej3`,ks0D6T:`x193iq5w`,$$css:!0},messageAreaCompact:{ks0D6T:`x193iq5w`,kg3NbH:`xnjsko4`,$$css:!0},messageAreaBalanced:{ks0D6T:`x193iq5w`,kg3NbH:`xnjsko4`,$$css:!0},messageAreaSpacious:{ks0D6T:`x1ap80js`,kg3NbH:`x1pzlopt`,$$css:!0},blurLayerCompact:{kZKoxP:`xwzfr38`,kX1K2I:`xkm2don`,kAExgp:`xiy8rlo`,$$css:!0},blurLayerBalanced:{kZKoxP:`xpyat2d`,kX1K2I:`xw26lqc`,kAExgp:`x1bv1mxo`,$$css:!0},blurLayerSpacious:{kZKoxP:`x1wkxgih`,kX1K2I:`xr5yg4x`,kAExgp:`xo9xo30`,$$css:!0},dockCompact:{kg3NbH:`xf314gf`,kGO01o:`x1wesfrj`,$$css:!0},dockBalanced:{kg3NbH:`xrrkdod`,kGO01o:`xvmdzux`,$$css:!0},dockSpacious:{kg3NbH:`x1pzlopt`,kGO01o:`xvmdzux`,$$css:!0},dockInnerCompact:{ks0D6T:`x193iq5w`,$$css:!0},dockInnerBalanced:{ks0D6T:`x193iq5w`,$$css:!0},dockInnerSpacious:{ks0D6T:`x1ap80js`,$$css:!0}};function zI(e){return!(e==null||e===!1||Array.isArray(e)&&e.length===0)}function BI({children:e,composer:t,density:n=`balanced`,emptyState:r,scrollButton:i,scrollRef:a,xstyle:o,className:s,style:c,"data-testid":l,ref:u,...d}){let f=Gs(),p=(0,v.useRef)(null),m=a??p,h=!a,g=OI({scrollRef:m}),_=kI({isLocked:g.isLocked,onResize:g.scrollIfLocked}),y=(0,q.jsx)(LI,{isVisible:g.isScrolledUp||_.hasNewMessages,label:_.hasNewMessages?f(`@astryx.chatLayout.newMessages`):void 0,onClick:()=>{_.dismiss(),g.scrollToBottom()}}),b=(0,v.useMemo)(()=>({scrollContainerRef:m,contentRef:_.contentRef}),[m,_.contentRef]),x=!zI(e),S={compact:{messageArea:RI.messageAreaCompact,blurLayer:RI.blurLayerCompact,dock:RI.dockCompact,dockInner:RI.dockInnerCompact},balanced:{messageArea:RI.messageAreaBalanced,blurLayer:RI.blurLayerBalanced,dock:RI.dockBalanced,dockInner:RI.dockInnerBalanced},spacious:{messageArea:RI.messageAreaSpacious,blurLayer:RI.blurLayerSpacious,dock:RI.dockSpacious,dockInner:RI.dockInnerSpacious}}[n];return(0,q.jsx)(sI,{value:b,children:(0,q.jsxs)(`div`,{...d,ref:Ei(u,p),"data-testid":l,...J(Y(`chat-layout`,{density:n}),w(RI.root,h&&RI.rootScrollable,o),s,c),children:[(0,q.jsx)(`div`,{...w(RI.messageArea,S.messageArea),children:x&&r?(0,q.jsx)(`div`,{className:`x78zum5 x6s0dn4 xl56j7k x98rzlu xz65tgg`,children:r}):e}),(0,q.jsxs)(`div`,{...{0:{className:`x1ey2m1c x1o0tod xtijo5x x1ja2u2z xc8icb0 x47corl x2lah0s xixxii4`},1:{className:`x1ey2m1c x1o0tod xtijo5x x1ja2u2z xc8icb0 x47corl x2lah0s x7wzq59`}}[!!h<<0],children:[i===void 0?y:i,(0,q.jsx)(`div`,{...w(RI.blurLayer,S.blurLayer)}),(0,q.jsx)(`div`,{...w(RI.dock,S.dock),children:(0,q.jsx)(`div`,{...w(RI.dockInner,S.dockInner),children:t})})]})]})})}BI.displayName=`ChatLayout`;var VI=`draft_mutation`;function HI(e,t){return e||t}function UI(e){return e.map((e,t)=>{let n={mutationId:e.id,summary:e.summary,affectedStageIds:e.affectedStageIds};return{type:`tool-call`,toolCallId:`mutation-${e.id}-${t}`,toolName:VI,args:n,argsText:JSON.stringify(n),result:{status:`applied`}}})}var WI=`Chat failed:`;function GI(e){return e.trim().length>0}function KI(e){return e===`user`||e===`system`||e===`assistant`?e:`assistant`}function qI(e){return typeof e==`string`?e?[{type:`text`,text:e}]:[]:e}function JI(e){if(!e||typeof e!=`object`)return null;let t=typeof e.mutationId==`string`?e.mutationId:``,n=typeof e.summary==`string`?e.summary:``,r=Array.isArray(e.affectedStageIds)?e.affectedStageIds.filter(e=>typeof e==`string`):[];return t?{mutationId:t,summary:n,affectedStageIds:r}:null}function YI(e){let t=[];for(let n of e){let e=KI(n.role),r=qI(n.content),i=r.filter(e=>e.type===`text`&&typeof e.text==`string`),a=i.find(e=>e.text.startsWith(WI));if(a){t.push({kind:`text`,role:e,text:a.text});continue}let o=i.map(e=>e.text).join(``);o&&t.push({kind:`text`,role:e,text:o});for(let e of r){if(e.type!==`tool-call`||e.toolName!==`draft_mutation`)continue;let n=JI(e.args);n&&t.push({kind:`draft_mutation`,toolCallId:typeof e.toolCallId==`string`&&e.toolCallId?e.toolCallId:`mutation-${n.mutationId}`,args:n})}}return t}function XI(e,t){if(t.length===0)return e?[{kind:`text`,text:e}]:[];let n=[...t].sort((e,t)=>e.textOffset-t.textOffset),r=[];for(let t of n){let n=Math.max(0,Math.min(t.textOffset,e.length)),i=r[r.length-1];i&&i.offset===n?i.calls.push({...t,textOffset:n}):r.push({offset:n,calls:[{...t,textOffset:n}]})}let i=[],a=0;for(let t of r)t.offset>a&&i.push({kind:`text`,text:e.slice(a,t.offset)}),i.push({kind:`tools`,calls:t.calls}),a=t.offset;return a<e.length?i.push({kind:`text`,text:e.slice(a)}):i.length===0&&e&&i.push({kind:`text`,text:e}),i}function ZI(e,t){if(t!==1)return e===0?`first`:e===t-1?`last`:`middle`}function QI(e){return typeof e.content==`string`||Array.isArray(e.content)?e.content:Array.isArray(e.parts)?e.parts:[]}function $I(e,t){return(0,q.jsx)(FI,{calls:t.map(e=>({key:e.id,name:e.name,status:e.status,target:e.target,errorMessage:e.errorMessage}))},e)}function eL({greeting:e,toolActivity:t=[],MutationCard:n,composerActions:r,onStop:i}){let a=lT(),o=fT(e=>e.thread.isRunning),s=fT(e=>e.thread.isEmpty),c=fT(e=>e.thread.messages),l=fT(e=>e.composer.text),u=YI(c.map(e=>({role:e.role,content:QI(e)}))),d=-1;for(let e=u.length-1;e>=0;--e){let t=u[e];if(t.kind===`text`&&t.role===`user`)break;if(t.kind===`text`&&t.role===`assistant`){d=e;break}}let f=d>=0,p=o&&!f&&t.length===0,m=(0,q.jsx)(yI,{value:l,onChange:e=>a.composer.setText(e),onSubmit:e=>{o||GI(e)&&(a.composer.setText(e),a.composer.send())},onStop:i,isStopShown:o,placeholder:`Describe a stage or workflow change…`,footerActions:r,density:`compact`});if(s)return(0,q.jsxs)(my,{height:`100%`,minHeight:0,gap:3,padding:3,children:[(0,q.jsx)(by,{size:`fill`,children:(0,q.jsx)(my,{height:`100%`,vAlign:`center`,hAlign:`center`,padding:3,children:(0,q.jsx)(eo,{type:`body`,justify:`center`,as:`p`,children:e})})}),m]});let h=[],g=[],_=[],v=()=>{if(g.length===0)return;let e=g;g=[],h.push((0,q.jsx)(wI,{sender:`user`,children:e.map((t,n)=>(0,q.jsx)(EI,{group:ZI(n,e.length),children:t},n))},`user-${h.length}`))},y=()=>{if(_.length===0)return;let e=_;_=[],h.push((0,q.jsx)(wI,{sender:`assistant`,children:e},`assistant-${h.length}`))};for(let e=0;e<u.length;e+=1){let r=u[e];if(r.kind===`text`&&r.role===`user`){y(),g.push(r.text);continue}if(r.kind===`text`&&r.role===`assistant`){if(v(),e===d&&t.length>0){let n=XI(r.text,t);for(let[t,r]of n.entries())if(r.kind===`text`){if(!r.text)continue;_.push((0,q.jsx)(EI,{variant:`ghost`,children:(0,q.jsx)(Dm,{isStreaming:!1,density:`compact`,contentWidth:`100%`,children:r.text})},`text-${_.length}`))}else y(),h.push($I(`tools-${e}-${t}`,r.calls))}else _.push((0,q.jsx)(EI,{variant:`ghost`,children:(0,q.jsx)(Dm,{isStreaming:!1,density:`compact`,contentWidth:`100%`,children:r.text})},`text-${_.length}`));continue}if(r.kind===`text`){v(),y(),h.push((0,q.jsx)(wI,{sender:`system`,children:(0,q.jsx)(eo,{type:`supporting`,children:r.text})},`system-${h.length}`));continue}r.kind===`draft_mutation`&&(v(),_.push((0,q.jsx)(n,{args:r.args},r.toolCallId)))}return v(),y(),!f&&t.length>0&&h.push($I(`tool-activity`,t)),p&&h.push((0,q.jsx)(wI,{sender:`assistant`,children:(0,q.jsx)(EI,{variant:`ghost`,children:(0,q.jsx)(eo,{type:`supporting`,children:`Working…`})})},`in-progress`)),(0,q.jsx)(BI,{composer:m,children:(0,q.jsx)(SI,{isStreaming:o,density:`compact`,gap:2,children:h})})}function tL({seedMessages:e,adapter:t,greeting:n,toolActivity:r,MutationCard:i,composerActions:a,onStop:o}){let s=sF(t,{initialMessages:e});return(0,q.jsx)(`div`,{className:`workshop-lab__aui-island`,children:(0,q.jsx)(EF,{runtime:s,children:(0,q.jsx)(`div`,{className:`workshop-lab__aui-thread-wrap`,children:(0,q.jsx)(eL,{greeting:n,toolActivity:r,MutationCard:i,composerActions:a,onStop:o})})})})}function nL(){return{pipeline:{id:`untitled`,stages:[]}}}function rL(e){return(e?.trim()??``)||`Untitled`}function iL(e){return e.id?`build:${e.id}`:`path:${encodeURIComponent(e.projectRoot??``)}/${encodeURIComponent(e.relativePath??``)}`}function aL(e){return e.relativePath?`${e.name} · ${e.relativePath}`:e.name}function oL(e,t){return typeof t==`string`&&t.length>0&&t===e}function sL(e){return{buildId:null,draft:nL(),rows:e.map(e=>({...e})),error:null}}function cL(e){let t=e.rows.map(e=>({...e}));return e.activeBuildId?!e.build||e.build.id!==e.activeBuildId?{buildId:null,draft:nL(),rows:t,error:e.error??`Build not found`}:{buildId:e.build.id,draft:e.build.draft,rows:hL(t,e.build),error:null}:{buildId:null,draft:nL(),rows:t,error:null}}function lL(e,t){return e?t.find(t=>t.id===e)?.name??`Untitled`:null}function uL(e,t){let n=e.rows.find(e=>e.id===t.buildId);return mL(e,{id:t.buildId,draft:t.draft,projectRoot:n?.projectRoot??null,relativePath:n?.relativePath??null})}function dL(e,t){let n=e.map(e=>({...e}));return!t?.id||n.some(e=>e.id===t.id)?n:[...n,{...t}]}function fL(e,t,n){return e.sessionId!==t.sessionId||e.buildId!==t.buildId?new Map:n}async function pL(e){if(e.row.id){let t=await e.loadBuild(e.row.id);if(!t.ok)return{selection:{...e.selection,error:t.error},changed:!1};let n=await e.updatePointer(e.sessionId,t.build.id);if(!n.ok)return{selection:{...e.selection,error:n.error},changed:!1};let r=mL(e.selection,t.build);return{selection:r,changed:r.buildId!==e.selection.buildId}}if(!e.row.projectRoot||!e.row.relativePath)return{selection:e.selection,changed:!1};let t=await e.focus(e.row);if(!t.ok)return{selection:{...e.selection,error:t.error},changed:!1};let n=await e.updatePointer(e.sessionId,t.build.id);if(!n.ok)return{selection:{...e.selection,error:n.error},changed:!1};let r=mL(e.selection,t.build);return{selection:r,changed:r.buildId!==e.selection.buildId}}function mL(e,t){return{buildId:t.id,draft:t.draft,rows:hL(e.rows,t),error:null}}function hL(e,t){let n={id:t.id,name:rL(t.draft.pipeline.id),projectRoot:t.projectRoot,relativePath:t.relativePath},r=t.projectRoot&&t.relativePath?`${t.projectRoot}\0${t.relativePath}`:null,i=!1,a=[];for(let o of e){let e=o.id!=null&&o.id===t.id,s=r!=null&&o.projectRoot===t.projectRoot&&o.relativePath===t.relativePath;if(e||s){i||=(a.push(n),!0);continue}a.push({...o})}return i||a.push(n),a}var gL=420,_L=280,vL=320,yL=32,bL={pipeline:{id:`untitled`,stages:[]}},xL=`What are we building? Tell me the workflow in your own words — I’ll ask where it changes the draft.`,SL={nodes:[],edges:[]},CL=(0,v.createContext)(null);function wL(){let e=(0,v.useContext)(CL);if(!e)throw Error(`WorkshopMutationContext missing`);return e}function TL(e){return e.split(/[-_]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function EL(){return[]}function DL(e){return e.length===0?[]:e.map(e=>({role:e.role===`user`||e.role===`system`||e.role===`assistant`?e.role:`assistant`,content:e.text}))}function OL(e,t){return(e.stages??[]).find(e=>typeof e.body.id==`string`&&e.body.id===t||e.path.replace(/^\.\//,``).replace(/\.ya?ml$/,``)===t)?.body??null}function kL(e){if(!e||e.io==null)return`IO not set yet`;try{return JSON.stringify(e.io)}catch{return`IO present`}}function AL(e){if(!e)return`Verify not set yet`;if(e.verify!=null)try{return JSON.stringify(e.verify)}catch{return`Verify present`}return`Verify not set yet`}function jL(e){if(!e)return[];let t=[];if((e.ask_operator===!0||e.hitl===!0)&&t.push(`confirm`),Array.isArray(e.gates))for(let n of e.gates)typeof n==`string`&&t.push(n);return t}function ML(e,t){let n=new Map;for(let e of t.values())if(e.status===`pending`)for(let t of e.proposal.affectedStageIds)n.set(t,`pending`);return e.pipeline.stages.map((t,r)=>{let i=typeof t.id==`string`&&t.id?t.id:`stage-${r}`,a=OL(e,i),o=typeof a?.system_prompt==`string`?a.system_prompt:typeof a?.systemPrompt==`string`?a.systemPrompt:`Stage ${i}`;return{stageId:i,title:TL(i),promptSummary:o,ioSummary:kL(a),verifySummary:AL(a),hitlFlags:jL(a),mutationStatus:n.get(i)??`applied`}})}function NL(e){return{nodes:e.map((t,n)=>{let r=t.mutationStatus===`pending`;return{stage_id:t.stageId,status:r?`waiting_for_input`:`succeeded`,readiness:r?`waiting`:`succeeded`,layer:n,layer_order:0,attempt_count:+!r,gate_kinds:r?[`confirm`]:void 0,blocked_by:n>0?[e[n-1].stageId]:void 0}}),edges:e.slice(1).map((t,n)=>({from:e[n].stageId,to:t.stageId}))}}function PL(e){return e.map(e=>{let t=e.mutationStatus===`pending`;return{stage_id:e.stageId,status:t?`waiting_for_input`:`succeeded`,events:[],envelope:null,artifacts:[],attempt_count:+!t}})}function FL(e){return e.map(e=>{let t=e.mutationStatus===`pending`;return{stageId:e.stageId,title:e.title,kicker:t?`mutation · pending`:`stage · draft`,status:t?`waiting_for_input`:`succeeded`,attemptCount:t?void 0:1,readinessLine:t?`Awaiting Accept / Reject`:void 0,gateKinds:t?[`confirm`]:void 0,titleOnly:!0,isWaitingAttention:t,isSuperseded:!1}})}function IL(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(!n||n.role!==`user`))return n.content.filter(e=>e.type===`text`).map(e=>e.text).join(` `).trim()}return``}function LL(e){let t=[];for(let n of e)n.type===`message`&&n.role===`assistant`&&n.text?t.push(n.text):n.type===`error`&&n.message&&t.push(n.message);return t.join(`
|
|
132
|
+
|
|
133
|
+
`).trim()}function RL(e){return{async*run({messages:t,abortSignal:n}){let r=IL(t);if(!r){yield{content:[{type:`text`,text:xL}]};return}e.clearActivity();let i=e.sessionId.current;if(!i){yield{content:[{type:`text`,text:`Workshop session is still starting. Try again in a moment.`}]};return}let a=``,o=[],s=[],c,l=e=>{s.push(e),c?.(),c=void 0},u=()=>new Promise(e=>{c=e}),d=new AbortController,f=()=>{d.signal.aborted||(d.abort(),l({kind:`aborted`}))};e.stop.current=f,n?.aborted?f():n?.addEventListener(`abort`,f,{once:!0});let p=wr({sessionId:i,message:r,draft:e.draft.current,model:e.model.current},{onDelta:e=>{a+=e,l({kind:`delta`})},onActivity:t=>{e.sessionId.current===i&&(t.draft!==null&&typeof t.draft==`object`&&oL(e.selectedBuildId.current,t.buildId)&&e.setDraft(t.draft),e.pushActivity({id:t.id,name:t.name,status:t.status,...t.target===void 0?{}:{target:t.target},...t.errorMessage===void 0?{}:{errorMessage:t.errorMessage},textOffset:a.length}))},onEvent:e=>{e.type===`proposal`&&o.push(e.proposal)},onPointerChange:t=>{e.sessionId.current===i&&(e.selectedBuildId.current=t.buildId,e.setDraft(t.draft),e.onPointerChange?.(t))},signal:d.signal}).then(e=>(l({kind:`done`,result:e}),e));try{for(;;){s.length===0&&await u();let t=s.shift();if(t.kind===`delta`){yield{content:[{type:`text`,text:a||`…`}]};continue}if(t.kind===`aborted`){let t=await Cr(i),n=e.sessionId.current===i&&oL(e.selectedBuildId.current,t?.buildId);t?.draft&&n&&e.setDraft(t.draft),n&&t?.pending&&!o.some(e=>e.id===t.pending?.id)&&o.push(t.pending),n&&o.length>0&&e.registerMutations(o),yield{content:[{type:`text`,text:a.trim()||`Stopped.`},...UI(o)]};return}await p;let n=t.result;if(!n.ok){yield{content:[{type:`text`,text:d.signal.aborted||n.error===`Stopped.`?a.trim()||`Stopped.`:`${WI} ${n.error}`}]};return}let r=e.sessionId.current===i&&oL(e.selectedBuildId.current,n.buildId);r&&e.setDraft(n.draft);let c=LL(n.events),l=a.trim()||c||(o.length>0?`Updated the draft. Accept or Reject the mutation cards below.`:`No draft change. ${e.model.current} finished without updating the studio.`);r&&o.length>0?e.registerMutations(o):r&&n.pending&&(e.registerMutations([n.pending]),o.push(n.pending)),yield{content:[{type:`text`,text:l},...UI(o)]};return}}finally{e.stop.current===f&&(e.stop.current=null),n?.removeEventListener(`abort`,f)}}}}function zL({args:e}){let t=wL(),n=fT(e=>e.thread.isRunning),r=typeof e?.mutationId==`string`?e.mutationId:``,i=r?t.getCard(r):void 0,a=typeof e?.summary==`string`?e.summary:i?.proposal.summary??`Draft mutation`,o=Array.isArray(e?.affectedStageIds)&&e.affectedStageIds.length>0?e.affectedStageIds:i?.proposal.affectedStageIds??[],s=i?.status??`pending`,[c,l]=(0,v.useState)(!1),u=HI(n,c),d=async e=>{if(!(!r||u||s!==`pending`)){l(!0);try{e===`accepted`?await t.accept(r):await t.reject(r)}finally{l(!1)}}};return(0,q.jsxs)(`div`,{className:`workshop-lab__proposal`,"data-status":s,"data-tool":`draft_mutation`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__proposal-head`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`Draft mutation`}),(0,q.jsx)(`strong`,{className:`workshop-lab__proposal-title`,children:a}),o.length>0?(0,q.jsx)(`span`,{className:`workshop-lab__proposal-id muted`,children:o.join(`, `)}):null]}),(0,q.jsx)(`p`,{className:`workshop-lab__proposal-summary`,children:`Applied to the studio. Accept confirms; Reject soft-undos when the draft is unchanged.`}),s===`pending`?(0,q.jsxs)(`div`,{className:`workshop-lab__proposal-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn--primary`,disabled:u,onClick:()=>void d(`accepted`),children:`Accept`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost`,disabled:u,onClick:()=>void d(`rejected`),children:`Reject`})]}):(0,q.jsx)(`p`,{className:`workshop-lab__proposal-status muted`,children:s===`accepted`?`Accepted`:s===`rejected`?`Rejected · undone`:i?.notice??`Could not undo — ask the agent to reverse it`})]})}function BL(){return(0,q.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`M8 3.5V8l3 1.5`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.25`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,q.jsx)(`path`,{d:`M3.2 4.2 2 3M3.2 4.2 4.5 3.4`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function VL(){return(0,q.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M8 3.5v9M3.5 8h9`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})}function HL({onHistory:e,onNew:t,historyOpen:n}){return(0,q.jsxs)(`header`,{className:`workshop-lab__chat-header`,children:[(0,q.jsx)(`div`,{className:`workshop-lab__chat-title`,children:`Chat`}),(0,q.jsxs)(`div`,{className:`workshop-lab__chat-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`workshop-lab__icon-btn`,"aria-label":`Chat history`,"aria-expanded":n,onClick:e,children:(0,q.jsx)(BL,{})}),(0,q.jsx)(`button`,{type:`button`,className:`workshop-lab__icon-btn`,"aria-label":`New chat`,onClick:t,children:(0,q.jsx)(VL,{})})]})]})}function UL({sessions:e,pickerRows:t,activeSessionId:n,loading:r,error:i,onClose:a,onSelect:o}){return(0,q.jsxs)(`div`,{className:`workshop-lab__history`,role:`dialog`,"aria-label":`Chat history`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__history-head`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`History`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost btn--sm`,onClick:a,children:`Close`})]}),r?(0,q.jsx)(`p`,{className:`muted workshop-lab__history-empty`,children:`Loading sessions…`}):i?(0,q.jsx)(`p`,{className:`muted workshop-lab__history-empty`,children:i}):e.length===0?(0,q.jsx)(`p`,{className:`muted workshop-lab__history-empty`,children:`No prior sessions yet.`}):(0,q.jsx)(`ul`,{className:`workshop-lab__history-list`,children:e.map(e=>{let r=e.title.trim()||`Untitled session`,i=new Date(e.updatedAt).toLocaleString(),a=lL(e.activeBuildId,t);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,className:`workshop-lab__history-item`,"data-active":e.id===n?`true`:`false`,onClick:()=>o(e.id),children:[(0,q.jsx)(`strong`,{children:r}),a?(0,q.jsx)(`span`,{children:a}):null,(0,q.jsx)(`span`,{className:`muted`,children:i})]})},e.id)})})]})}function WL({stage:e,onClose:t}){(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let n=e.hitlFlags.length>0?e.hitlFlags.join(`, `):`None`;return(0,q.jsxs)(`div`,{className:`workshop-lab__popup-root`,children:[(0,q.jsx)(`button`,{type:`button`,className:`workshop-lab__popup-scrim`,"aria-label":`Close stage details`,onClick:t}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`workshop-stage-popup-title`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__popup-head`,children:[(0,q.jsx)(`h2`,{id:`workshop-stage-popup-title`,className:`workshop-lab__popup-title`,children:e.title}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn--ghost btn--sm`,onClick:t,children:`Close`})]}),(0,q.jsxs)(`dl`,{className:`workshop-lab__popup-fields`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`Name`}),(0,q.jsx)(`dd`,{children:e.stageId})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`Title`}),(0,q.jsx)(`dd`,{children:e.title})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`Prompt`}),(0,q.jsx)(`dd`,{children:e.promptSummary})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`IO`}),(0,q.jsx)(`dd`,{children:e.ioSummary})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`Verify`}),(0,q.jsx)(`dd`,{children:e.verifySummary})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`HITL`}),(0,q.jsx)(`dd`,{children:n})]}),(0,q.jsxs)(`div`,{className:`workshop-lab__popup-field`,children:[(0,q.jsx)(`dt`,{children:`Mutation`}),(0,q.jsx)(`dd`,{children:e.mutationStatus})]})]})]})]})}function GL(){return(0,q.jsxs)(`div`,{className:`workshop-lab__map-empty`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`Studio`}),(0,q.jsx)(`p`,{children:`Pipeline appears here as you build`})]})}var KL=`cursor/auto`;function qL(e){let t=e?.trim()??``;return t.length>0?t:KL}function JL(e){let t=e.split(`/`).pop()??e;return t.endsWith(`:free`)?t.slice(0,-5):t}function YL(e){let t=e.map(JL),n=new Map;for(let e of t)n.set(e,(n.get(e)??0)+1);let r=new Map;return e.forEach((e,i)=>{let a=t[i]??e,o=e.split(`/`)[0]??e;r.set(e,(n.get(a)??0)>1?`${o}/${a}`:a)}),r}function XL({model:e,models:t,settingsDefault:n,onChange:r}){let i=t.length>0?t:[qL(n)],a=i.includes(e)?i:[e,...i],o=YL(a).get(e)??JL(e);return(0,q.jsx)(jF,{placement:`above`,menuWidth:420,button:{label:`Workshop chat model`,variant:`ghost`,size:`sm`,children:o},children:(0,q.jsx)(ff,{label:`Workshop chat model`,value:e,onChange:r,children:a.map(e=>(0,q.jsx)(mf,{value:e,label:e===n?`${e} (default)`:e},e))})})}function ZL(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(bL),[i,a]=(0,v.useState)(()=>new Map),[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(KL),[j,M]=(0,v.useState)([]),[N,P]=(0,v.useState)(null),F=(0,v.useRef)(null),I=(0,v.useRef)(bL),L=(0,v.useRef)(KL),R=(0,v.useRef)(null),z=(0,v.useRef)(null),B=(0,v.useRef)(null),V=(0,v.useRef)([]),H=(0,v.useRef)(sL([])),U=(0,v.useRef)(0),W=(0,v.useRef)(()=>{});F.current=e,I.current=n,L.current=k;let ee=(0,v.useCallback)(e=>{I.current=e,r(e)},[]),te=(0,v.useCallback)(e=>{H.current=e,V.current=e.rows,z.current=e.buildId,B.current=e.buildId,w(e.rows),E(e.buildId),O(e.error),ee(e.draft)},[ee]),ne=(0,v.useCallback)(e=>{V.current=e,H.current={...H.current,rows:e},w(e)},[]),re=(0,v.useCallback)(async()=>{let e=await hr();if(!e.ok)return;let t=H.current.rows.find(e=>e.id!=null&&e.id===z.current)??null;ne(dL(e.rows,t))},[ne]),[ie,ae]=(0,v.useState)([]),oe=(0,v.useCallback)(e=>{ae(t=>{let n=t.findIndex(t=>t.id===e.id);if(n<0)return[...t,e].slice(-12);let r=t.slice();return r[n]=e,r})},[]),se=(0,v.useCallback)(()=>{ae([])},[]),ce=(0,v.useCallback)(e=>{a(t=>{let n=new Map(t);for(let t of e)n.set(t.id,{proposal:t,status:`pending`});return n})},[]),le=(0,v.useMemo)(()=>({sessionId:F,draft:I,model:L,selectedBuildId:z,setDraft:ee,onPointerChange:e=>W.current(e),registerMutations:ce,pushActivity:oe,clearActivity:se,stop:R}),[ee,ce,oe,se]),ue=(0,v.useMemo)(()=>RL(le),[le]);W.current=e=>{let t={sessionId:F.current,buildId:B.current},n=uL(H.current,e);te(n),a(e=>fL(t,{sessionId:F.current,buildId:n.buildId},e)),re()},(0,v.useEffect)(()=>{re()},[re]),(0,v.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,n]=await Promise.all([Yn(),Nn()]);if(e)return;let r=qL(t.defaultModel);P(r),M(n.models),A(r)}catch{if(e)return;M([])}})(),()=>{e=!0}},[]);let de=(0,v.useCallback)(async()=>{let e=++U.current;p(null),h(!1);let n={sessionId:F.current,buildId:B.current},r=await mr();if(U.current!==e)return;if(!r.ok){p(r.error);return}F.current=r.session.id;let i=sL(V.current);te(i),t(r.session.id),a(e=>fL(n,{sessionId:r.session.id,buildId:null},e)),d(null),s(EL()),l(e=>e+1)},[te]);(0,v.useEffect)(()=>{de()},[de]);let fe=(0,v.useCallback)(async()=>{h(!0),_(!0),b(null);let[e,t]=await Promise.all([pr(),hr()]);if(_(!1),t.ok){let e=H.current.rows.find(e=>e.id!=null&&e.id===z.current)??null;ne(dL(t.rows,e))}if(!e.ok){b(e.error),S([]);return}S(e.sessions)},[ne]),pe=(0,v.useCallback)(async e=>{let n=++U.current;_(!0),b(null);let r={sessionId:F.current,buildId:B.current},i=await yr(e);if(U.current!==n)return;if(_(!1),!i.ok){b(i.error);return}F.current=i.session.id,te(sL(V.current)),a(e=>fL(r,{sessionId:i.session.id,buildId:null},e));let o=null,c=null;if(i.session.activeBuildId){let e=await gr(i.session.activeBuildId);if(U.current!==n)return;e.ok?o=e.build:c=e.error}let u=cL({activeBuildId:i.session.activeBuildId,build:o,rows:V.current,error:c}),f=B.current;te(u),t(i.session.id),a(e=>fL({sessionId:i.session.id,buildId:f},{sessionId:i.session.id,buildId:u.buildId},e)),d(null),s(DL(i.session.transcript)),l(e=>e+1),h(!1)},[te]),me=(0,v.useCallback)(async e=>{let t=F.current;if(!t)return;let n=U.current,r={sessionId:t,buildId:B.current},i=await pL({sessionId:t,row:e,selection:H.current,focus:async e=>{if(!e.projectRoot||!e.relativePath)return{ok:!1,error:`project root and path are required`};let t=await _r({projectRoot:e.projectRoot,relativePath:e.relativePath});return t.ok?{ok:!0,build:t.build}:{ok:!1,error:t.error}},updatePointer:async(e,t)=>{let n=await vr({sessionId:e,activeBuildId:t});return n.ok?{ok:!0}:{ok:!1,error:n.error}},loadBuild:async e=>{let t=await gr(e);return t.ok?{ok:!0,build:t.build}:{ok:!1,error:t.error}}});U.current===n&&F.current===t&&(te(i.selection),a(e=>fL(r,{sessionId:t,buildId:i.selection.buildId},e)),d(null))},[te]),he=(0,v.useCallback)(async t=>{if(!e)return;let n=await xr({sessionId:e,draft:I.current,mutationId:t});if(n.ok){ee(n.draft),a(e=>{let n=new Map(e),r=n.get(t);return r&&n.set(t,{...r,status:`accepted`}),n});return}n.draft&&ee(n.draft),a(e=>{let r=new Map(e),i=r.get(t);return i&&r.set(t,{...i,status:`conflict`,notice:n.notice??n.error}),r})},[ee,e]),ge=(0,v.useCallback)(async t=>{if(!e)return;let n=await br({sessionId:e,draft:I.current,mutationId:t});if(n.ok){ee(n.draft),a(e=>{let n=new Map(e),r=n.get(t);return r&&n.set(t,{...r,status:`rejected`}),n});return}n.draft&&ee(n.draft),a(e=>{let r=new Map(e),i=r.get(t);return i&&r.set(t,{...i,status:`conflict`,notice:n.notice??n.error}),r})},[ee,e]),_e=(0,v.useMemo)(()=>({getCard:e=>i.get(e),accept:he,reject:ge}),[he,i,ge]),ve=(0,v.useMemo)(()=>ML(n,i),[n,i]),ye=(0,v.useMemo)(()=>ve.length?NL(ve):SL,[ve]),be=(0,v.useMemo)(()=>Qh(ye),[ye]),xe=(0,v.useMemo)(()=>PL(ve),[ve]),Se=(0,v.useMemo)(()=>FL(ve),[ve]),Ce=ve.find(e=>e.stageId===u)??null,we=(0,v.useMemo)(()=>new Set(ve.filter(e=>e.mutationStatus===`pending`).map(e=>e.stageId)),[ve]),Te=!!u||we.size>0,Ee=(0,v.useRef)(null),De=(0,v.useRef)(null),[Oe,ke]=(0,v.useState)(0),[G,Ae]=(0,v.useState)(gL),[je,Me]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=Ee.current;if(!e)return;let t=()=>ke(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let Ne=Math.max(_L,Oe-vL),Pe=Oe>0&&Oe<600?Math.max(160,Math.floor(Oe/2)):_L,Fe=(0,v.useCallback)(e=>{let t=Oe>0?Oe-vL:e;Ae(Math.max(Pe,Math.min(e,Math.max(Pe,t))))},[Oe,Pe]);(0,v.useEffect)(()=>{if(Oe<=0)return;let e=Oe-vL;Ae(t=>Math.max(Pe,Math.min(t,Math.max(Pe,e))))},[Oe,Pe]);let K=(0,v.useCallback)(()=>d(null),[]),Ie=(0,v.useCallback)(e=>{d(e)},[]);return(0,q.jsxs)(`div`,{className:`pane workshop-lab${je?` is-resizing-x`:``}`,children:[(0,q.jsxs)(`div`,{className:`topbar`,children:[(0,q.jsx)(`div`,{className:`topbar__title`,children:`Workshop`}),(0,q.jsx)(`div`,{className:`topbar__sub`,children:`Live Author · draft mutates before Accept · Reject soft-undos`}),(0,q.jsx)(`div`,{className:`topbar__spacer`})]}),(0,q.jsxs)(`div`,{ref:Ee,className:`workshop-lab__body`,style:{"--chat-w":`${G}px`},children:[(0,q.jsxs)(`section`,{className:`workshop-lab__chat`,"aria-label":`Workshop chat`,children:[(0,q.jsx)(HL,{historyOpen:m,onHistory:()=>{m?h(!1):fe()},onNew:()=>void de()}),f?(0,q.jsx)(`p`,{className:`workshop-lab__boot-error muted`,children:f}):null,m?(0,q.jsx)(UL,{sessions:x,pickerRows:C,activeSessionId:e,loading:g,error:y,onClose:()=>h(!1),onSelect:e=>void pe(e)}):null,(0,q.jsx)(`div`,{className:`workshop-lab__chat-body`,children:(0,q.jsx)(CL.Provider,{value:_e,children:e?(0,q.jsx)(tL,{seedMessages:o,adapter:ue,greeting:xL,toolActivity:ie,MutationCard:zL,onStop:()=>R.current?.(),composerActions:(0,q.jsx)(XL,{model:k,models:j,settingsDefault:N,onChange:A})},`${e}:${c}`):(0,q.jsxs)(`div`,{className:`workshop-lab__welcome`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`Workshop`}),(0,q.jsx)(`p`,{children:`Starting session…`})]})})})]}),(0,q.jsx)(`div`,{className:`workshop-lab__split${je?` is-dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize chat and run map`,"aria-valuemin":Math.round(Pe),"aria-valuemax":Math.round(Ne),"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:e=>{(e.button==null||e.button===0)&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),Me(!0),De.current={id:e.pointerId,x:e.clientX,w:G})},onPointerMove:e=>{let t=De.current;!t||t.id!==e.pointerId||Fe(t.w+(e.clientX-t.x))},onPointerUp:e=>{De.current?.id===e.pointerId&&(De.current=null,Me(!1))},onPointerCancel:e=>{De.current?.id===e.pointerId&&(De.current=null,Me(!1))},onKeyDown:e=>{e.key===`ArrowLeft`&&(e.preventDefault(),Fe(G-yL)),e.key===`ArrowRight`&&(e.preventDefault(),Fe(G+yL)),e.key===`Home`&&(e.preventDefault(),Fe(Pe)),e.key===`End`&&(e.preventDefault(),Fe(Ne))},children:(0,q.jsx)(`span`,{className:`workshop-lab__split-grip`,"aria-hidden":`true`})}),(0,q.jsxs)(`section`,{className:`workshop-lab__map`,"aria-label":`Workshop studio`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__map-head`,children:[(0,q.jsxs)(`div`,{className:`workshop-lab__map-switch`,children:[(0,q.jsx)(`div`,{className:`eyebrow`,children:`Studio · draft`}),(0,q.jsxs)(`select`,{className:`select workshop-lab__pipeline-select`,"aria-label":`Studio pipeline`,value:T?`build:${T}`:``,onChange:e=>{let t=e.target.value;if(!t)return;let n=C.find(e=>iL(e)===t);n&&me(n)},children:[(0,q.jsx)(`option`,{value:``,children:`No pipeline`}),C.map(e=>(0,q.jsx)(`option`,{value:iL(e),children:aL(e)},iL(e)))]})]}),D?(0,q.jsx)(`p`,{className:`workshop-lab__boot-error muted`,children:D}):null,(0,q.jsx)(`p`,{className:`workshop-lab__selection muted`,children:ve.length===0?`Empty — stages appear when the Author mutates the draft`:Ce?`Selected: ${Ce.title}`:`Click a stage for details`})]}),(0,q.jsx)(`div`,{className:`workspace workshop-lab__workspace${Te?` has-highlight`:``}`,children:ve.length===0?(0,q.jsx)(GL,{}):(0,q.jsx)(Dg,{layout:be,stages:xe,nodeChrome:Se,selectedStageId:u,onSelectStage:Ie,onDeselect:K,runId:`workshop-lab-draft`,showHint:!1})})]})]}),Ce?(0,q.jsx)(WL,{stage:Ce,onClose:K}):null]})}function QL(e){return e.name===`connect`?`settings`:e.name===`detail`?`runs`:e.name===`new`?`today`:e.name===`pipeline`?`pipelines`:e.name===`task`?`tasks`:e.name===`trigger`?`triggers`:e.name===`skill`?`skills`:e.name===`extensionPackage`||e.name===`extensionFile`?`extensions`:e.name}function $L(){let[e,t]=(0,v.useState)(()=>ry()),[n,r]=(0,v.useState)(eb),[i,a]=(0,v.useState)(Db),[o,s]=(0,v.useState)(`loading`),{snapshot:c}=Mr();(0,v.useEffect)(()=>{let e=()=>t(ry());return window.addEventListener(`hashchange`,e),window.location.hash||(window.location.hash=`#/today`),()=>window.removeEventListener(`hashchange`,e)},[]),Mb(i===`system`),(0,v.useEffect)(()=>{let e=!1;return Vn().then(t=>{e||s($_(t)?`needs_connect`:`ready`)}).catch(()=>{e||s(`ready`)}),()=>{e=!0}},[]);let l=Gr(c).length,u=c.health,d=(0,v.useCallback)(e=>{Hv(e)},[]),f=(0,v.useCallback)(e=>{d(`/${e}`)},[d]),p;return p=e.name===`new`?(0,q.jsx)(cv,{onStarted:e=>d(Uv(e)),initialPipelinePath:e.pipelineId,initialTaskPath:e.taskPath}):e.name===`detail`?(0,q.jsx)(q_,{runId:e.runId,view:e.view,onBack:()=>d(`/runs`),onReran:e=>d(Uv(e)),onOpenStream:t=>d(t?Wv(e.runId,t):Uv(e.runId)),onOpenArtifact:t=>d(Gv(e.runId,t)),onOpenEnvelope:t=>d(Kv(e.runId,t))}):e.name===`runs`?(0,q.jsx)(Ci,{onOpen:e=>d(Uv(e)),onNew:()=>d(`/new`)}):e.name===`pipelines`?(0,q.jsx)(jy,{onNew:d}):e.name===`pipeline`?(0,q.jsx)(jy,{pipelineId:e.pipelineId,onNew:d}):e.name===`tasks`?(0,q.jsx)(Ny,{onNew:d}):e.name===`task`?(0,q.jsx)(Ny,{taskId:e.taskId,onNew:d}):e.name===`triggers`?(0,q.jsx)(Ky,{}):e.name===`trigger`?(0,q.jsx)(Ky,{triggerId:e.triggerId}):e.name===`skills`?(0,q.jsx)(Jy,{}):e.name===`skill`?(0,q.jsx)(Jy,{skillName:e.skillName}):e.name===`extensions`?(0,q.jsx)(Xy,{}):e.name===`extensionPackage`?(0,q.jsx)(Xy,{packageScope:e.scope,packageSource:e.source}):e.name===`extensionFile`?(0,q.jsx)(Xy,{filePath:e.path}):e.name===`settings`?(0,q.jsx)(Fb,{themeMode:n,onThemeChange:r,notifyPreference:i,onNotifyChange:a}):e.name===`connect`?(0,q.jsx)(Ib,{onComplete:()=>{s(`ready`),d(`/today`)}}):e.name===`workshop`?(0,q.jsx)(ZL,{}):(0,q.jsx)(wv,{onOpen:e=>d(Uv(e)),onOpenArtifact:(e,t)=>d(Gv(e,t)),onNew:()=>d(`/new`),onSeeRuns:()=>d(`/runs`)}),o===`needs_connect`&&e.name!==`settings`&&e.name!==`connect`&&(p=(0,q.jsx)(Ib,{onComplete:()=>{s(`ready`),d(`/today`)}})),(0,q.jsx)(Ct,{theme:vn,mode:n,children:(0,q.jsxs)(`div`,{className:`app`,children:[(0,q.jsx)(ti,{activeId:QL(e),onNavigate:f,waitingCount:l,health:u}),(0,q.jsx)(`main`,{className:`main`,children:p})]})})}function eR(){let[e]=(0,v.useState)(()=>Or({source:Tr()}));return(0,q.jsx)(jr,{catalog:e,children:(0,q.jsx)($L,{})})}(0,_n.createRoot)(document.getElementById(`root`)).render((0,q.jsx)(v.StrictMode,{children:(0,q.jsx)(eR,{})}));
|