@feltdb/core 0.7.4 → 0.8.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 +25 -0
- package/dist/application-development.d.ts +3 -1
- package/dist/application-development.d.ts.map +1 -1
- package/dist/application-development.js +16 -0
- package/dist/application-manifest.d.ts +1 -0
- package/dist/application-manifest.d.ts.map +1 -1
- package/dist/canonical-application.d.ts +1 -0
- package/dist/canonical-application.d.ts.map +1 -1
- package/dist/canonical-application.js +3 -2
- package/dist/cli/cli.js +1 -1
- package/dist/cli/commands.js +225 -42
- package/dist/cli/index.js +1 -1
- package/dist/cli/managed-environment.js +6 -0
- package/dist/cli/managed-project.js +6 -0
- package/dist/cli/proposal-client.js +12 -3
- package/dist/cli/publish-engine.js +7 -4
- package/dist/cli/source-sync.js +47 -3
- package/dist/create/cli.js +10 -1
- package/dist/create/create.js +10 -12
- package/dist/create/managed-account.js +71 -7
- package/dist/create/package-versions.js +1 -1
- package/dist/create/server-source/crates/feltdb/src/application.rs +10 -0
- package/dist/create/server-source/crates/feltdb/src/lib.rs +20 -2
- package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +12 -24
- package/dist/create/server-source/crates/feltdb-server/src/application_contract.rs +11 -3
- package/dist/create/server-source/crates/feltdb-server/src/authenticated_principal.rs +0 -1
- package/dist/create/server-source/crates/feltdb-server/src/certification_harness.rs +23 -22
- package/dist/create/server-source/crates/feltdb-server/src/delegation_token.rs +5 -15
- package/dist/create/server-source/crates/feltdb-server/src/durable_operations.rs +13 -28
- package/dist/create/server-source/crates/feltdb-server/src/identity.rs +79 -14
- package/dist/create/server-source/crates/feltdb-server/src/key_management.rs +28 -7
- package/dist/create/server-source/crates/feltdb-server/src/lib.rs +5 -5
- package/dist/create/server-source/crates/feltdb-server/src/main.rs +1777 -259
- package/dist/create/server-source/crates/feltdb-server/src/managed_diagnostics.rs +10 -30
- package/dist/create/server-source/crates/feltdb-server/src/membership_policy.rs +12 -4
- package/dist/create/server-source/crates/feltdb-server/src/request_telemetry.rs +8 -6
- package/dist/create/server-source/crates/feltdb-server/src/snapshot_cursor.rs +10 -14
- package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +183 -21
- package/dist/create/server-source/crates/feltdb-server/src/tenant_policies.rs +9 -21
- package/dist/create/server-source/crates/feltdb-server/src/transaction_idempotency.rs +5 -3
- package/dist/create/server-source/crates/feltdb-server/src/transaction_recovery.rs +9 -8
- package/dist/create/server-source/crates/feltdb-server/tests/revision_recovery_integration_test.rs +1 -4
- package/dist/create/template/default-project/feltdb.flow +5 -0
- package/dist/flowspec.d.ts +1 -0
- package/dist/flowspec.d.ts.map +1 -1
- package/dist/flowspec.js +46 -12
- package/dist/http-client.d.ts +135 -14
- package/dist/http-client.d.ts.map +1 -1
- package/dist/http-client.js +79 -31
- package/dist/index-core.d.ts +2 -0
- package/dist/index-core.d.ts.map +1 -1
- package/dist/index-core.js +2 -0
- package/dist/module-intent.d.ts +37 -0
- package/dist/module-intent.d.ts.map +1 -0
- package/dist/module-intent.js +81 -0
- package/dist/module.d.ts +76 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +61 -0
- package/dist/proposal.d.ts +80 -4
- package/dist/proposal.d.ts.map +1 -1
- package/dist/proposal.js +132 -5
- package/dist/studio/app.d.ts +3 -1
- package/dist/studio/app.d.ts.map +1 -1
- package/dist/studio/components/AskFeltDB.d.ts +2 -1
- package/dist/studio/components/AskFeltDB.d.ts.map +1 -1
- package/dist/studio/components/ContractInspector.d.ts +7 -0
- package/dist/studio/components/ContractInspector.d.ts.map +1 -0
- package/dist/studio/components/ManagedInstancePanel.d.ts.map +1 -1
- package/dist/studio/components/ManagedInstancePanel.js +1 -5
- package/dist/studio/components/ModuleExplorer.d.ts +6 -0
- package/dist/studio/components/ModuleExplorer.d.ts.map +1 -0
- package/dist/studio/components/ProposalBrowser.d.ts +10 -1
- package/dist/studio/components/ProposalBrowser.d.ts.map +1 -1
- package/dist/studio/components/StateExplorer.d.ts +6 -7
- package/dist/studio/components/StateExplorer.d.ts.map +1 -1
- package/dist/studio/components/index.d.ts +2 -0
- package/dist/studio/components/index.d.ts.map +1 -1
- package/dist/studio/components/index.js +4 -4
- package/dist/studio/components-CNSNrmA9.js +2787 -0
- package/dist/studio/index.js +193 -147
- package/dist/studio/studio.css +1 -1
- package/dist/studio/utils/index.d.ts +2 -0
- package/dist/studio/utils/index.d.ts.map +1 -1
- package/dist/studio/utils/index.js +14 -12
- package/dist/studio/utils/managed-instance.d.ts +0 -4
- package/dist/studio/utils/managed-instance.d.ts.map +1 -1
- package/dist/studio/utils/managed-instance.js +0 -4
- package/dist/studio/utils/proposal-api.d.ts +53 -0
- package/dist/studio/utils/proposal-api.d.ts.map +1 -0
- package/dist/studio/utils/proposal-api.js +91 -0
- package/dist/studio/utils/service-api.d.ts +81 -0
- package/dist/studio/utils/service-api.d.ts.map +1 -0
- package/dist/studio/utils/service-api.js +51 -0
- package/dist/studio-app/assets/{dist-DA1MYSzp.js → dist-CCOk39Uc.js} +1 -1
- package/dist/studio-app/assets/{feltdb_wasm-B-Ccgccb.js → feltdb_wasm-CSB6KVgw.js} +1 -1
- package/dist/studio-app/assets/feltdb_wasm_bg-Dd1fnO9U.wasm +0 -0
- package/dist/studio-app/assets/index-Bncji3aN.js +43 -0
- package/dist/studio-app/assets/{index-BRrmvaKw.css → index-yazaWMUN.css} +1 -1
- package/dist/studio-app/index.html +2 -2
- package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
- package/dist/workspace/local-development-authority.d.ts.map +1 -1
- package/dist/workspace/local-development-authority.js +64 -3
- package/package.json +1 -1
- package/dist/studio/components-Bm4sjhcX.js +0 -2162
- package/dist/studio-app/assets/feltdb_wasm_bg-wH3enJIA.wasm +0 -0
- package/dist/studio-app/assets/index-CEIqowCh.js +0 -42
|
@@ -0,0 +1,43 @@
|
|
|
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,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},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(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 l=o((e=>{var t=Symbol.for(`react.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.provider`),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.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): 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`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function D(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var O=/\/+/g;function k(e,t){return typeof e==`object`&&e&&e.key!=null?D(``+e.key):t.toString(36)}function A(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`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+k(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(O,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(O,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+k(s,l);c+=A(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+k(s,l++),c+=A(s,r,i,u,o);else if(s===`object`)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 j(e,t,n){if(e==null)return e;var r=[],i=0;return A(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function M(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 N={current:null},P={transition:null},te={ReactCurrentDispatcher:N,ReactCurrentBatchConfig:P,ReactCurrentOwner:C};function ne(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=te,e.act=ne,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:M}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=P.transition;P.transition={};try{e()}finally{P.transition=t}},e.unstable_act=ne,e.useCallback=function(e,t){return N.current.useCallback(e,t)},e.useContext=function(e){return N.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return N.current.useDeferredValue(e)},e.useEffect=function(e,t){return N.current.useEffect(e,t)},e.useId=function(){return N.current.useId()},e.useImperativeHandle=function(e,t,n){return N.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return N.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return N.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return N.current.useMemo(e,t)},e.useReducer=function(e,t,n){return N.current.useReducer(e,t,n)},e.useRef=function(e){return N.current.useRef(e)},e.useState=function(e){return N.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return N.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return N.current.useTransition()},e.version=`18.3.1`})),u=o(((e,t)=>{t.exports=l()})),d=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(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=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(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 b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,j(x);else{var t=n(l);t!==null&&M(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&M(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function ee(){return!(e.unstable_now()-E<T)}function D(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?O():(S=!1,C=null)}}else S=!1}var O;if(typeof v==`function`)O=function(){v(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(){g(D,0)};function j(e){C=e,S||(S=!0,O())}function M(t,n){w=g(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_continueExecution=function(){m||p||(m=!0,j(x))},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`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},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_pauseExecution=function(){},e.unstable_requestPaint=function(){},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?(_(w),w=-1):h=!0,M(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,j(x))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;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.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,d=/^[: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]*$/,p={},m={};function h(e){return l.call(m,e)?!0:l.call(p,e)?!1:d.test(e)?m[e]=!0:(p[e]=!0,!1)}function g(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function _(e,t,n,r){if(t==null||g(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(_(t,n,i,r)&&(n=null),r||i===null?h(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type!==3&&``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,w=Symbol.for(`react.element`),T=Symbol.for(`react.portal`),E=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),D=Symbol.for(`react.profiler`),O=Symbol.for(`react.provider`),k=Symbol.for(`react.context`),A=Symbol.for(`react.forward_ref`),j=Symbol.for(`react.suspense`),M=Symbol.for(`react.suspense_list`),N=Symbol.for(`react.memo`),P=Symbol.for(`react.lazy`),te=Symbol.for(`react.offscreen`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var F=Object.assign,ie;function ae(e){if(ie===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ie=t&&t[1]||``}return`
|
|
2
|
+
`+ie+e}var oe=!1;function se(e,t){if(!e||oe)return``;oe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t){if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var i=t.stack.split(`
|
|
3
|
+
`),a=r.stack.split(`
|
|
4
|
+
`),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=`
|
|
5
|
+
`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(`<anonymous>`)&&(c=c.replace(`<anonymous>`,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{oe=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?ae(e):``}function ce(e){switch(e.tag){case 5:return ae(e.type);case 16:return ae(`Lazy`);case 13:return ae(`Suspense`);case 19:return ae(`SuspenseList`);case 0:case 2:case 15:return e=se(e.type,!1),e;case 11:return e=se(e.type.render,!1),e;case 1:return e=se(e.type,!0),e;default:return``}}function le(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case D:return`Profiler`;case ee:return`StrictMode`;case j:return`Suspense`;case M:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case k:return(e.displayName||`Context`)+`.Consumer`;case O:return(e._context.displayName||`Context`)+`.Provider`;case A:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case N:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case P:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}function ue(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return le(t);case 8:return t===ee?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function de(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function pe(e){var t=fe(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function me(e){e._valueTracker||=pe(e)}function he(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=fe(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function ge(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function _e(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ve(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=de(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ye(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function be(e,t){ye(e,t);var n=de(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?Se(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Se(e,t.type,de(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xe(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function Se(e,t,n){(t!==`number`||ge(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ce=Array.isArray;function we(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=``+de(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 Te(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(r(91));return F({},t,{value:void 0,defaultValue:void 0,children:``+e._wrapperState.initialValue})}function Ee(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(r(92));if(Ce(n)){if(1<n.length)throw Error(r(93));n=n[0]}t=n}t??=``,n=t}e._wrapperState={initialValue:de(n)}}function De(e,t){var n=de(t.value),r=de(t.defaultValue);n!=null&&(n=``+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=``+r)}function Oe(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==``&&t!==null&&(e.value=t)}function ke(e){switch(e){case`svg`:return`http://www.w3.org/2000/svg`;case`math`:return`http://www.w3.org/1998/Math/MathML`;default:return`http://www.w3.org/1999/xhtml`}}function Ae(e,t){return e==null||e===`http://www.w3.org/1999/xhtml`?ke(t):e===`http://www.w3.org/2000/svg`&&t===`foreignObject`?`http://www.w3.org/1999/xhtml`:e}var je,Me=function(e){return typeof MSApp<`u`&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!==`http://www.w3.org/2000/svg`||`innerHTML`in e)e.innerHTML=t;else{for(je||=document.createElement(`div`),je.innerHTML=`<svg>`+t.valueOf().toString()+`</svg>`,t=je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ne(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Fe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Pe).forEach(function(e){Fe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pe[t]=Pe[e]})});function Ie(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Pe.hasOwnProperty(e)&&Pe[e]?(``+t).trim():t+`px`}function Le(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ie(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Re=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ze(e,t){if(t){if(Re[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Be(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;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 Ve=null;function He(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ue=null,We=null,Ge=null;function Ke(e){if(e=zi(e)){if(typeof Ue!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Vi(t),Ue(e.stateNode,e.type,t))}}function qe(e){We?Ge?Ge.push(e):Ge=[e]:We=e}function Je(){if(We){var e=We,t=Ge;if(Ge=We=null,Ke(e),t)for(e=0;e<t.length;e++)Ke(t[e])}}function Ye(e,t){return e(t)}function Xe(){}var Ze=!1;function Qe(e,t,n){if(Ze)return e(t,n);Ze=!0;try{return Ye(e,t,n)}finally{Ze=!1,(We!==null||Ge!==null)&&(Xe(),Je())}}function $e(e,t){var n=e.stateNode;if(n===null)return null;var i=Vi(n);if(i===null)return null;n=i[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`:(i=!i.disabled)||(e=e.type,i=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!i;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(r(231,t,typeof n));return n}var et=!1;if(c)try{var tt={};Object.defineProperty(tt,"passive",{get:function(){et=!0}}),window.addEventListener(`test`,tt,tt),window.removeEventListener(`test`,tt,tt)}catch{et=!1}function nt(e,t,n,r,i,a,o,s,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(e){this.onError(e)}}var rt=!1,it=null,at=!1,ot=null,st={onError:function(e){rt=!0,it=e}};function ct(e,t,n,r,i,a,o,s,c){rt=!1,it=null,nt.apply(st,arguments)}function lt(e,t,n,i,a,o,s,c,l){if(ct.apply(this,arguments),rt){if(rt){var u=it;rt=!1,it=null}else throw Error(r(198));at||(at=!0,ot=u)}}function ut(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 dt(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 ft(e){if(ut(e)!==e)throw Error(r(188))}function pt(e){var t=e.alternate;if(!t){if(t=ut(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,i=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(i=a.return,i!==null){n=i;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return ft(a),e;if(o===i)return ft(a),t;o=o.sibling}throw Error(r(188))}if(n.return!==i.return)n=a,i=o;else{for(var s=!1,c=a.child;c;){if(c===n){s=!0,n=a,i=o;break}if(c===i){s=!0,i=a,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,i=a;break}if(c===i){s=!0,i=o,n=a;break}c=c.sibling}if(!s)throw Error(r(189))}}if(n.alternate!==i)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function mt(e){return e=pt(e),e===null?null:ht(e)}function ht(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ht(e);if(t!==null)return t;e=e.sibling}return null}var gt=n.unstable_scheduleCallback,_t=n.unstable_cancelCallback,vt=n.unstable_shouldYield,yt=n.unstable_requestPaint,I=n.unstable_now,bt=n.unstable_getCurrentPriorityLevel,xt=n.unstable_ImmediatePriority,St=n.unstable_UserBlockingPriority,Ct=n.unstable_NormalPriority,wt=n.unstable_LowPriority,Tt=n.unstable_IdlePriority,Et=null,Dt=null;function Ot(e){if(Dt&&typeof Dt.onCommitFiberRoot==`function`)try{Dt.onCommitFiberRoot(Et,e,void 0,(e.current.flags&128)==128)}catch{}}var kt=Math.clz32?Math.clz32:L,At=Math.log,jt=Math.LN2;function L(e){return e>>>=0,e===0?32:31-(At(e)/jt|0)|0}var Mt=64,Nt=4194304;function Pt(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ft(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Pt(a))):r=Pt(s)}else o=n&~i,o===0?a!==0&&(r=Pt(a)):r=Pt(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-kt(t),i=1<<n,r|=e[n],t&=~i;return r}function It(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64: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:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Lt(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var o=31-kt(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=It(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}}function Rt(e){return e=e.pendingLanes&-1073741825,e===0?e&1073741824?1073741824:0:e}function zt(){var e=Mt;return Mt<<=1,!(Mt&4194240)&&(Mt=64),e}function Bt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Vt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-kt(t),e[t]=n}function Ht(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-kt(n),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~a}}function Ut(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-kt(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var R=0;function Wt(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Gt,Kt,qt,Jt,Yt,Xt=!1,Zt=[],Qt=null,$t=null,en=null,tn=new Map,nn=new Map,rn=[],an=`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 submit`.split(` `);function on(e,t){switch(e){case`focusin`:case`focusout`:Qt=null;break;case`dragenter`:case`dragleave`:$t=null;break;case`mouseover`:case`mouseout`:en=null;break;case`pointerover`:case`pointerout`:tn.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:nn.delete(t.pointerId)}}function sn(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=zi(t),t!==null&&Kt(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function cn(e,t,n,r,i){switch(t){case`focusin`:return Qt=sn(Qt,e,t,n,r,i),!0;case`dragenter`:return $t=sn($t,e,t,n,r,i),!0;case`mouseover`:return en=sn(en,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return tn.set(a,sn(tn.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,nn.set(a,sn(nn.get(a)||null,e,t,n,r,i)),!0}return!1}function ln(e){var t=Ri(e.target);if(t!==null){var n=ut(t);if(n!==null){if(t=n.tag,t===13){if(t=dt(n),t!==null){e.blockedOn=t,Yt(e.priority,function(){qt(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 un(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bn(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ve=r,n.target.dispatchEvent(r),Ve=null}else return t=zi(n),t!==null&&Kt(t),e.blockedOn=n,!1;t.shift()}return!0}function dn(e,t,n){un(e)&&n.delete(t)}function fn(){Xt=!1,Qt!==null&&un(Qt)&&(Qt=null),$t!==null&&un($t)&&($t=null),en!==null&&un(en)&&(en=null),tn.forEach(dn),nn.forEach(dn)}function pn(e,t){e.blockedOn===t&&(e.blockedOn=null,Xt||(Xt=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,fn)))}function mn(e){function t(t){return pn(t,e)}if(0<Zt.length){pn(Zt[0],e);for(var n=1;n<Zt.length;n++){var r=Zt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Qt!==null&&pn(Qt,e),$t!==null&&pn($t,e),en!==null&&pn(en,e),tn.forEach(t),nn.forEach(t),n=0;n<rn.length;n++)r=rn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<rn.length&&(n=rn[0],n.blockedOn===null);)ln(n),n.blockedOn===null&&rn.shift()}var hn=C.ReactCurrentBatchConfig,gn=!0;function _n(e,t,n,r){var i=R,a=hn.transition;hn.transition=null;try{R=1,vn(e,t,n,r)}finally{R=i,hn.transition=a}}function z(e,t,n,r){var i=R,a=hn.transition;hn.transition=null;try{R=4,vn(e,t,n,r)}finally{R=i,hn.transition=a}}function vn(e,t,n,r){if(gn){var i=bn(e,t,n,r);if(i===null)ui(e,t,r,yn,n),on(e,r);else if(cn(i,e,t,n,r))r.stopPropagation();else if(on(e,r),t&4&&-1<an.indexOf(e)){for(;i!==null;){var a=zi(i);if(a!==null&&Gt(a),a=bn(e,t,n,r),a===null&&ui(e,t,r,yn,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else ui(e,t,r,null,n)}}var yn=null;function bn(e,t,n,r){if(yn=null,e=He(r),e=Ri(e),e!==null){if(t=ut(e),t===null)e=null;else if(n=t.tag,n===13){if(e=dt(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 yn=e,null}function xn(e){switch(e){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`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 1;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`toggle`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 4;case`message`:switch(bt()){case xt:return 1;case St:return 4;case Ct:case wt:return 16;case Tt:return 536870912;default:return 16}default:return 16}}var Sn=null,Cn=null,wn=null;function Tn(){if(wn)return wn;var e,t=Cn,n=t.length,r,i=`value`in Sn?Sn.value:Sn.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 wn=i.slice(e,1<r?1-r:void 0)}function En(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 Dn(){return!0}function On(){return!1}function B(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)?Dn:On,this.isPropagationStopped=On,this}return F(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=Dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Dn)},persist:function(){},isPersistent:Dn}),t}var kn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},An=B(kn),jn=F({},kn,{view:0,detail:0}),Mn=B(jn),Nn,Pn,Fn,In=F({},jn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:qn,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!==Fn&&(Fn&&e.type===`mousemove`?(Nn=e.screenX-Fn.screenX,Pn=e.screenY-Fn.screenY):Pn=Nn=0,Fn=e),Nn)},movementY:function(e){return`movementY`in e?e.movementY:Pn}}),Ln=B(In),Rn=B(F({},In,{dataTransfer:0})),zn=B(F({},jn,{relatedTarget:0})),Bn=B(F({},kn,{animationName:0,elapsedTime:0,pseudoElement:0})),Vn=B(F({},kn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Hn=B(F({},kn,{data:0})),Un={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Wn={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`},Gn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Kn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Gn[e])?!!t[e]:!1}function qn(){return Kn}var Jn=B(F({},jn,{key:function(e){if(e.key){var t=Un[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=En(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Wn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:qn,charCode:function(e){return e.type===`keypress`?En(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?En(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Yn=B(F({},In,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Xn=B(F({},jn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:qn})),Zn=B(F({},kn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Qn=B(F({},In,{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})),$n=[9,13,27,32],er=c&&`CompositionEvent`in window,tr=null;c&&`documentMode`in document&&(tr=document.documentMode);var nr=c&&`TextEvent`in window&&!tr,rr=c&&(!er||tr&&8<tr&&11>=tr),ir=` `,ar=!1;function or(e,t){switch(e){case`keyup`:return $n.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var cr=!1;function lr(e,t){switch(e){case`compositionend`:return sr(t);case`keypress`:return t.which===32?(ar=!0,ir):null;case`textInput`:return e=t.data,e===ir&&ar?null:e;default:return null}}function ur(e,t){if(cr)return e===`compositionend`||!er&&or(e,t)?(e=Tn(),wn=Cn=Sn=null,cr=!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 rr&&t.locale!==`ko`?null:t.data;default:return null}}var dr={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 fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!dr[e.type]:t===`textarea`}function pr(e,t,n,r){qe(r),t=fi(t,`onChange`),0<t.length&&(n=new An(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var mr=null,hr=null;function gr(e){ai(e,0)}function _r(e){if(he(Bi(e)))return e}function vr(e,t){if(e===`change`)return t}var yr=!1;if(c){var br;if(c){var xr=`oninput`in document;if(!xr){var Sr=document.createElement(`div`);Sr.setAttribute(`oninput`,`return;`),xr=typeof Sr.oninput==`function`}br=xr}else br=!1;yr=br&&(!document.documentMode||9<document.documentMode)}function Cr(){mr&&(mr.detachEvent(`onpropertychange`,wr),hr=mr=null)}function wr(e){if(e.propertyName===`value`&&_r(hr)){var t=[];pr(t,hr,e,He(e)),Qe(gr,t)}}function Tr(e,t,n){e===`focusin`?(Cr(),mr=t,hr=n,mr.attachEvent(`onpropertychange`,wr)):e===`focusout`&&Cr()}function Er(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return _r(hr)}function Dr(e,t){if(e===`click`)return _r(t)}function V(e,t){if(e===`input`||e===`change`)return _r(t)}function Or(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var kr=typeof Object.is==`function`?Object.is:Or;function Ar(e,t){if(kr(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(!l.call(t,i)||!kr(e[i],t[i]))return!1}return!0}function jr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Mr(e,t){var n=jr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=jr(n)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pr(){for(var e=window,t=ge();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=ge(e.document)}return t}function Fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Ir(e){var t=Pr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Nr(n.ownerDocument.documentElement,n)){if(r!==null&&Fr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Mr(n,a);var o=Mr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Lr=c&&`documentMode`in document&&11>=document.documentMode,Rr=null,zr=null,Br=null,Vr=!1;function Hr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vr||Rr==null||Rr!==ge(r)||(r=Rr,`selectionStart`in r&&Fr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Br&&Ar(Br,r)||(Br=r,r=fi(zr,`onSelect`),0<r.length&&(t=new An(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Rr)))}function Ur(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var H={animationend:Ur(`Animation`,`AnimationEnd`),animationiteration:Ur(`Animation`,`AnimationIteration`),animationstart:Ur(`Animation`,`AnimationStart`),transitionend:Ur(`Transition`,`TransitionEnd`)},Wr={},Gr={};c&&(Gr=document.createElement(`div`).style,`AnimationEvent`in window||(delete H.animationend.animation,delete H.animationiteration.animation,delete H.animationstart.animation),`TransitionEvent`in window||delete H.transitionend.transition);function Kr(e){if(Wr[e])return Wr[e];if(!H[e])return e;var t=H[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gr)return Wr[e]=t[n];return e}var qr=Kr(`animationend`),Jr=Kr(`animationiteration`),Yr=Kr(`animationstart`),Xr=Kr(`transitionend`),Zr=new Map,Qr=`abort auxClick 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(` `);function $r(e,t){Zr.set(e,t),o(t,[e])}for(var ei=0;ei<Qr.length;ei++){var ti=Qr[ei];$r(ti.toLowerCase(),`on`+(ti[0].toUpperCase()+ti.slice(1)))}$r(qr,`onAnimationEnd`),$r(Jr,`onAnimationIteration`),$r(Yr,`onAnimationStart`),$r(`dblclick`,`onDoubleClick`),$r(`focusin`,`onFocus`),$r(`focusout`,`onBlur`),$r(Xr,`onTransitionEnd`),s(`onMouseEnter`,[`mouseout`,`mouseover`]),s(`onMouseLeave`,[`mouseout`,`mouseover`]),s(`onPointerEnter`,[`pointerout`,`pointerover`]),s(`onPointerLeave`,[`pointerout`,`pointerover`]),o(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),o(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),o(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),o(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),o(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var ni=`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(` `),ri=new Set(`cancel close invalid load scroll toggle`.split(` `).concat(ni));function ii(e,t,n){var r=e.type||`unknown-event`;e.currentTarget=n,lt(r,t,void 0,e),e.currentTarget=null}function ai(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;ii(i,s,l),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;ii(i,s,l),a=c}}}if(at)throw e=ot,at=!1,ot=null,e}function U(e,t){var n=t[Fi];n===void 0&&(n=t[Fi]=new Set);var r=e+`__bubble`;n.has(r)||(li(t,e,2,!1),n.add(r))}function oi(e,t,n){var r=0;t&&(r|=4),li(n,e,r,t)}var si=`_reactListening`+Math.random().toString(36).slice(2);function ci(e){if(!e[si]){e[si]=!0,i.forEach(function(t){t!==`selectionchange`&&(ri.has(t)||oi(t,!1,e),oi(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[si]||(t[si]=!0,oi(`selectionchange`,!1,t))}}function li(e,t,n,r){switch(xn(t)){case 1:var i=_n;break;case 4:i=z;break;default:i=vn}n=i.bind(null,t,n,e),i=void 0,!et||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 ui(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i||s.nodeType===8&&s.parentNode===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;o=o.return}for(;s!==null;){if(o=Ri(s),o===null)return;if(c=o.tag,c===5||c===6){r=a=o;continue a}s=s.parentNode}}r=r.return}Qe(function(){var r=a,i=He(n),o=[];a:{var s=Zr.get(e);if(s!==void 0){var c=An,l=e;switch(e){case`keypress`:if(En(n)===0)break a;case`keydown`:case`keyup`:c=Jn;break;case`focusin`:l=`focus`,c=zn;break;case`focusout`:l=`blur`,c=zn;break;case`beforeblur`:case`afterblur`:c=zn;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`:c=Ln;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Rn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=Xn;break;case qr:case Jr:case Yr:c=Bn;break;case Xr:c=Zn;break;case`scroll`:c=Mn;break;case`wheel`:c=Qn;break;case`copy`:case`cut`:case`paste`:c=Vn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=Yn}var u=!!(t&4),d=!u&&e===`scroll`,f=u?s===null?null:s+`Capture`:s;u=[];for(var p=r,m;p!==null;){m=p;var h=m.stateNode;if(m.tag===5&&h!==null&&(m=h,f!==null&&(h=$e(p,f),h!=null&&u.push(di(p,h,m)))),d)break;p=p.return}0<u.length&&(s=new c(s,l,null,n,i),o.push({event:s,listeners:u}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,s&&n!==Ve&&(l=n.relatedTarget||n.fromElement)&&(Ri(l)||l[Pi]))break a;if((c||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?Ri(l):null,l!==null&&(d=ut(l),l!==d||l.tag!==5&&l.tag!==6)&&(l=null)):(c=null,l=r),c!==l)){if(u=Ln,h=`onMouseLeave`,f=`onMouseEnter`,p=`mouse`,(e===`pointerout`||e===`pointerover`)&&(u=Yn,h=`onPointerLeave`,f=`onPointerEnter`,p=`pointer`),d=c==null?s:Bi(c),m=l==null?s:Bi(l),s=new u(h,p+`leave`,c,n,i),s.target=d,s.relatedTarget=m,h=null,Ri(i)===r&&(u=new u(f,p+`enter`,l,n,i),u.target=m,u.relatedTarget=d,h=u),d=h,c&&l)b:{for(u=c,f=l,p=0,m=u;m;m=pi(m))p++;for(m=0,h=f;h;h=pi(h))m++;for(;0<p-m;)u=pi(u),p--;for(;0<m-p;)f=pi(f),m--;for(;p--;){if(u===f||f!==null&&u===f.alternate)break b;u=pi(u),f=pi(f)}u=null}else u=null;c!==null&&mi(o,s,c,u,!1),l!==null&&d!==null&&mi(o,d,l,u,!0)}}a:{if(s=r?Bi(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var g=vr;else if(fr(s)){if(yr)g=V;else{g=Er;var _=Tr}}else(c=s.nodeName)&&c.toLowerCase()===`input`&&(s.type===`checkbox`||s.type===`radio`)&&(g=Dr);if(g&&=g(e,r)){pr(o,g,n,i);break a}_&&_(e,s,r),e===`focusout`&&(_=s._wrapperState)&&_.controlled&&s.type===`number`&&Se(s,`number`,s.value)}switch(_=r?Bi(r):window,e){case`focusin`:(fr(_)||_.contentEditable===`true`)&&(Rr=_,zr=r,Br=null);break;case`focusout`:Br=zr=Rr=null;break;case`mousedown`:Vr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Vr=!1,Hr(o,n,i);break;case`selectionchange`:if(Lr)break;case`keydown`:case`keyup`:Hr(o,n,i)}var v;if(er)b:{switch(e){case`compositionstart`:var y=`onCompositionStart`;break b;case`compositionend`:y=`onCompositionEnd`;break b;case`compositionupdate`:y=`onCompositionUpdate`;break b}y=void 0}else cr?or(e,n)&&(y=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(y=`onCompositionStart`);y&&(rr&&n.locale!==`ko`&&(cr||y!==`onCompositionStart`?y===`onCompositionEnd`&&cr&&(v=Tn()):(Sn=i,Cn=`value`in Sn?Sn.value:Sn.textContent,cr=!0)),_=fi(r,y),0<_.length&&(y=new Hn(y,e,null,n,i),o.push({event:y,listeners:_}),v?y.data=v:(v=sr(n),v!==null&&(y.data=v)))),(v=nr?lr(e,n):ur(e,n))&&(r=fi(r,`onBeforeInput`),0<r.length&&(i=new Hn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:i,listeners:r}),i.data=v))}ai(o,t)})}function di(e,t,n){return{instance:e,listener:t,currentTarget:n}}function fi(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=$e(e,n),a!=null&&r.unshift(di(e,a,i)),a=$e(e,t),a!=null&&r.push(di(e,a,i))),e=e.return}return r}function pi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function mi(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(c!==null&&c===r)break;s.tag===5&&l!==null&&(s=l,i?(c=$e(n,a),c!=null&&o.unshift(di(n,c,s))):i||(c=$e(n,a),c!=null&&o.push(di(n,c,s)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var hi=/\r\n?/g,gi=/\u0000|\uFFFD/g;function _i(e){return(typeof e==`string`?e:``+e).replace(hi,`
|
|
6
|
+
`).replace(gi,``)}function vi(e,t,n){if(t=_i(t),_i(e)!==t&&n)throw Error(r(425))}function yi(){}var bi=null,xi=null;function Si(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ci=typeof setTimeout==`function`?setTimeout:void 0,wi=typeof clearTimeout==`function`?clearTimeout:void 0,Ti=typeof Promise==`function`?Promise:void 0,Ei=typeof queueMicrotask==`function`?queueMicrotask:Ti===void 0?Ci:function(e){return Ti.resolve(null).then(e).catch(Di)};function Di(e){setTimeout(function(){throw e})}function Oi(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===`/$`){if(r===0){e.removeChild(i),mn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++}n=i}while(n);mn(t)}function ki(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===`$?`)break;if(t===`/$`)return null}}return e}function Ai(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`){if(t===0)return e;t--}else n===`/$`&&t++}e=e.previousSibling}return null}var ji=Math.random().toString(36).slice(2),Mi=`__reactFiber$`+ji,Ni=`__reactProps$`+ji,Pi=`__reactContainer$`+ji,Fi=`__reactEvents$`+ji,Ii=`__reactListeners$`+ji,Li=`__reactHandles$`+ji;function Ri(e){var t=e[Mi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Pi]||n[Mi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ai(e);e!==null;){if(n=e[Mi])return n;e=Ai(e)}return t}e=n,n=e.parentNode}return null}function zi(e){return e=e[Mi]||e[Pi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Bi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Vi(e){return e[Ni]||null}var Hi=[],Ui=-1;function Wi(e){return{current:e}}function W(e){0>Ui||(e.current=Hi[Ui],Hi[Ui]=null,Ui--)}function G(e,t){Ui++,Hi[Ui]=e.current,e.current=t}var Gi={},Ki=Wi(Gi),qi=Wi(!1),Ji=Gi;function Yi(e,t){var n=e.type.contextTypes;if(!n)return Gi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Xi(e){return e=e.childContextTypes,e!=null}function Zi(){W(qi),W(Ki)}function Qi(e,t,n){if(Ki.current!==Gi)throw Error(r(168));G(Ki,t),G(qi,n)}function $i(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ue(e)||`Unknown`,a));return F({},n,i)}function ea(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Gi,Ji=Ki.current,G(Ki,e),G(qi,qi.current),!0}function ta(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=$i(e,t,Ji),i.__reactInternalMemoizedMergedChildContext=e,W(qi),W(Ki),G(Ki,e)):W(qi),G(qi,n)}var na=null,ra=!1,ia=!1;function aa(e){na===null?na=[e]:na.push(e)}function oa(e){ra=!0,aa(e)}function sa(){if(!ia&&na!==null){ia=!0;var e=0,t=R;try{var n=na;for(R=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}na=null,ra=!1}catch(t){throw na!==null&&(na=na.slice(e+1)),gt(xt,sa),t}finally{R=t,ia=!1}}return null}var ca=[],la=0,ua=null,da=0,fa=[],pa=0,ma=null,ha=1,ga=``;function _a(e,t){ca[la++]=da,ca[la++]=ua,ua=e,da=t}function va(e,t,n){fa[pa++]=ha,fa[pa++]=ga,fa[pa++]=ma,ma=e;var r=ha;e=ga;var i=32-kt(r)-1;r&=~(1<<i),n+=1;var a=32-kt(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ha=1<<32-kt(t)+i|n<<i|r,ga=a+e}else ha=1<<a|n<<i|r,ga=e}function ya(e){e.return!==null&&(_a(e,1),va(e,1,0))}function K(e){for(;e===ua;)ua=ca[--la],ca[la]=null,da=ca[--la],ca[la]=null;for(;e===ma;)ma=fa[--pa],fa[pa]=null,ga=fa[--pa],fa[pa]=null,ha=fa[--pa],fa[pa]=null}var ba=null,xa=null,q=!1,Sa=null;function Ca(e,t){var n=Kl(5,null,null,0);n.elementType=`DELETED`,n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function wa(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null&&(e.stateNode=t,ba=e,xa=ki(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t!==null&&(e.stateNode=t,ba=e,xa=null,!0);case 13:return t=t.nodeType===8?t:null,t!==null&&(n=ma===null?null:{id:ha,overflow:ga},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Kl(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ba=e,xa=null,!0);default:return!1}}function Ta(e){return!!(e.mode&1)&&!(e.flags&128)}function Ea(e){if(q){var t=xa;if(t){var n=t;if(!wa(e,t)){if(Ta(e))throw Error(r(418));t=ki(n.nextSibling);var i=ba;t&&wa(e,t)?Ca(i,n):(e.flags=e.flags&-4097|2,q=!1,ba=e)}}else{if(Ta(e))throw Error(r(418));e.flags=e.flags&-4097|2,q=!1,ba=e}}}function Da(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ba=e}function Oa(e){if(e!==ba)return!1;if(!q)return Da(e),q=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!Si(e.type,e.memoizedProps)),t&&=xa){if(Ta(e))throw ka(),Error(r(418));for(;t;)Ca(e,t),t=ki(t.nextSibling)}if(Da(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){xa=ki(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}xa=null}}else xa=ba?ki(e.stateNode.nextSibling):null;return!0}function ka(){for(var e=xa;e;)e=ki(e.nextSibling)}function Aa(){xa=ba=null,q=!1}function ja(e){Sa===null?Sa=[e]:Sa.push(e)}var Ma=C.ReactCurrentBatchConfig;function Na(e,t,n){if(e=n.ref,e!==null&&typeof e!=`function`&&typeof e!=`object`){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Pa(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function Fa(e){var t=e._init;return t(e._payload)}function Ia(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 i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=Yl(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|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=$l(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===E?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===P&&Fa(i)===t.type)?(r=a(t,n.props),r.ref=Na(e,t,n),r.return=e,r):(r=Xl(n.type,n.key,n.props,null,e.mode,r),r.ref=Na(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=eu(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=Zl(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`)return t=$l(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case w:return n=Xl(t.type,t.key,t.props,null,e.mode,n),n.ref=Na(e,null,t),n.return=e,n;case T:return t=eu(t,e.mode,n),t.return=e,t;case P:var r=t._init;return f(e,r(t._payload),n)}if(Ce(t)||re(t))return t=Zl(t,e.mode,n,null),t.return=e,t;Pa(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`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case w:return n.key===i?l(e,t,n,r):null;case T:return n.key===i?u(e,t,n,r):null;case P:return i=n._init,p(e,t,i(n._payload),r)}if(Ce(n)||re(n))return i===null?d(e,t,n,r,null):null;Pa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case w:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case T:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case P:var a=r._init;return m(e,t,n,a(r._payload),i)}if(Ce(r)||re(r))return e=e.get(n)||null,d(t,e,r,i,null);Pa(t,r)}return null}function h(r,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(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),q&&_a(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return q&&_a(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,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(r,e)}),q&&_a(r,h),l}function g(a,s,c,l){var u=re(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=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),q&&_a(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 q&&_a(a,g),u}for(h=i(a,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)}),q&&_a(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===P&&Fa(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Na(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===E?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=Na(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case P:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(re(i))return g(e,r,i,o);Pa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var La=Ia(!0),Ra=Ia(!1),za=Wi(null),Ba=null,Va=null,Ha=null;function Ua(){Ha=Va=Ba=null}function Wa(e){var t=za.current;W(za),e._currentValue=t}function Ga(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 Ka(e,t){Ba=e,Ha=Va=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ps=!0),e.firstContext=null)}function qa(e){var t=e._currentValue;if(Ha!==e){if(e={context:e,memoizedValue:t,next:null},Va===null){if(Ba===null)throw Error(r(308));Va=e,Ba.dependencies={lanes:0,firstContext:e}}else Va=Va.next=e}return t}var Ja=null;function Ya(e){Ja===null?Ja=[e]:Ja.push(e)}function Xa(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ya(t)):(n.next=i.next,i.next=n),t.interleaved=n,Za(e,r)}function Za(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qa=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function eo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function to(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function no(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Z&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Za(e,n)}return i=r.interleaved,i===null?(t.next=t,Ya(r)):(t.next=i.next,i.next=t),r.interleaved=t,Za(e,n)}function ro(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ut(e,n)}}function io(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={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,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,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ao(e,t,n,r){var i=e.updateQueue;Qa=!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,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=F({},d,f);break a;case 2:Qa=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime: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;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Yc|=o,e.lanes=o,e.memoizedState=d}}function oo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var so={},co=Wi(so),lo=Wi(so),uo=Wi(so);function fo(e){if(e===so)throw Error(r(174));return e}function po(e,t){switch(G(uo,t),G(lo,e),G(co,so),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ae(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ae(t,e)}W(co),G(co,t)}function mo(){W(co),W(lo),W(uo)}function ho(e){fo(uo.current);var t=fo(co.current),n=Ae(t,e.type);t!==n&&(G(lo,e),G(co,n))}function go(e){lo.current===e&&(W(co),W(lo))}var J=Wi(0);function _o(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data===`$?`||n.data===`$!`))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){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 vo=[];function yo(){for(var e=0;e<vo.length;e++)vo[e]._workInProgressVersionPrimary=null;vo.length=0}var bo=C.ReactCurrentDispatcher,xo=C.ReactCurrentBatchConfig,So=0,Y=null,Co=null,wo=null,To=!1,Eo=!1,Do=0,Oo=0;function ko(){throw Error(r(321))}function Ao(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!kr(e[n],t[n]))return!1;return!0}function jo(e,t,n,i,a,o){if(So=o,Y=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,bo.current=e===null||e.memoizedState===null?ms:hs,e=n(i,a),Eo){o=0;do{if(Eo=!1,Do=0,25<=o)throw Error(r(301));o+=1,wo=Co=null,t.updateQueue=null,bo.current=gs,e=n(i,a)}while(Eo)}if(bo.current=ps,t=Co!==null&&Co.next!==null,So=0,wo=Co=Y=null,To=!1,t)throw Error(r(300));return e}function Mo(){var e=Do!==0;return Do=0,e}function No(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wo===null?Y.memoizedState=wo=e:wo=wo.next=e,wo}function Po(){if(Co===null){var e=Y.alternate;e=e===null?null:e.memoizedState}else e=Co.next;var t=wo===null?Y.memoizedState:wo.next;if(t!==null)wo=t,Co=e;else{if(e===null)throw Error(r(310));Co=e,e={memoizedState:Co.memoizedState,baseState:Co.baseState,baseQueue:Co.baseQueue,queue:Co.queue,next:null},wo===null?Y.memoizedState=wo=e:wo=wo.next=e}return wo}function Fo(e,t){return typeof t==`function`?t(e):t}function Io(e){var t=Po(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=Co,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((So&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,Y.lanes|=d,Yc|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,kr(i,t.memoizedState)||(Ps=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,Y.lanes|=o,Yc|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Lo(e){var t=Po(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=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);kr(o,t.memoizedState)||(Ps=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Ro(){}function zo(e,t){var n=Y,i=Po(),a=t(),o=!kr(i.memoizedState,a);if(o&&(i.memoizedState=a,Ps=!0),i=i.queue,Zo(Ho.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||wo!==null&&wo.memoizedState.tag&1){if(n.flags|=2048,Ko(9,Vo.bind(null,n,i,a,t),void 0,null),Uc===null)throw Error(r(349));So&30||Bo(n,t,a)}return a}function Bo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Y.updateQueue,t===null?(t={lastEffect:null,stores:null},Y.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Vo(e,t,n,r){t.value=n,t.getSnapshot=r,Uo(t)&&Wo(e)}function Ho(e,t,n){return n(function(){Uo(t)&&Wo(e)})}function Uo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kr(e,n)}catch{return!0}}function Wo(e){var t=Za(e,1);t!==null&&hl(t,e,1,-1)}function Go(e){var t=No();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:e},t.queue=e,e=e.dispatch=ls.bind(null,Y,e),[t.memoizedState,e]}function Ko(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Y.updateQueue,t===null?(t={lastEffect:null,stores:null},Y.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function qo(){return Po().memoizedState}function Jo(e,t,n,r){var i=No();Y.flags|=e,i.memoizedState=Ko(1|t,n,void 0,r===void 0?null:r)}function Yo(e,t,n,r){var i=Po();r=r===void 0?null:r;var a=void 0;if(Co!==null){var o=Co.memoizedState;if(a=o.destroy,r!==null&&Ao(r,o.deps)){i.memoizedState=Ko(t,n,a,r);return}}Y.flags|=e,i.memoizedState=Ko(1|t,n,a,r)}function Xo(e,t){return Jo(8390656,8,e,t)}function Zo(e,t){return Yo(2048,8,e,t)}function Qo(e,t){return Yo(4,2,e,t)}function $o(e,t){return Yo(4,4,e,t)}function es(e,t){if(typeof t==`function`)return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ts(e,t,n){return n=n==null?null:n.concat([e]),Yo(4,4,es.bind(null,t,e),n)}function ns(){}function rs(e,t){var n=Po();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ao(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function is(e,t){var n=Po();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ao(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function as(e,t,n){return So&21?(kr(n,t)||(n=zt(),Y.lanes|=n,Yc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ps=!0),e.memoizedState=n)}function os(e,t){var n=R;R=n!==0&&4>n?n:4,e(!0);var r=xo.transition;xo.transition={};try{e(!1),t()}finally{R=n,xo.transition=r}}function ss(){return Po().memoizedState}function cs(e,t,n){var r=ml(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},us(e))ds(t,n);else if(n=Xa(e,t,n,r),n!==null){var i=pl();hl(n,e,r,i),fs(n,t,r)}}function ls(e,t,n){var r=ml(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(us(e))ds(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,kr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ya(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Xa(e,t,i,r),n!==null&&(i=pl(),hl(n,e,r,i),fs(n,t,r))}}function us(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function ds(e,t){Eo=To=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ut(e,n)}}var ps={readContext:qa,useCallback:ko,useContext:ko,useEffect:ko,useImperativeHandle:ko,useInsertionEffect:ko,useLayoutEffect:ko,useMemo:ko,useReducer:ko,useRef:ko,useState:ko,useDebugValue:ko,useDeferredValue:ko,useTransition:ko,useMutableSource:ko,useSyncExternalStore:ko,useId:ko,unstable_isNewReconciler:!1},ms={readContext:qa,useCallback:function(e,t){return No().memoizedState=[e,t===void 0?null:t],e},useContext:qa,useEffect:Xo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Jo(4194308,4,es.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Jo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Jo(4,2,e,t)},useMemo:function(e,t){var n=No();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=No();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=cs.bind(null,Y,e),[r.memoizedState,e]},useRef:function(e){var t=No();return e={current:e},t.memoizedState=e},useState:Go,useDebugValue:ns,useDeferredValue:function(e){return No().memoizedState=e},useTransition:function(){var e=Go(!1),t=e[0];return e=os.bind(null,e[1]),No().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=Y,a=No();if(q){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Uc===null)throw Error(r(349));So&30||Bo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Xo(Ho.bind(null,i,o,e),[e]),i.flags|=2048,Ko(9,Vo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=No(),t=Uc.identifierPrefix;if(q){var n=ga,r=ha;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Do++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=Oo++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},hs={readContext:qa,useCallback:rs,useContext:qa,useEffect:Zo,useImperativeHandle:ts,useInsertionEffect:Qo,useLayoutEffect:$o,useMemo:is,useReducer:Io,useRef:qo,useState:function(){return Io(Fo)},useDebugValue:ns,useDeferredValue:function(e){return as(Po(),Co.memoizedState,e)},useTransition:function(){return[Io(Fo)[0],Po().memoizedState]},useMutableSource:Ro,useSyncExternalStore:zo,useId:ss,unstable_isNewReconciler:!1},gs={readContext:qa,useCallback:rs,useContext:qa,useEffect:Zo,useImperativeHandle:ts,useInsertionEffect:Qo,useLayoutEffect:$o,useMemo:is,useReducer:Lo,useRef:qo,useState:function(){return Lo(Fo)},useDebugValue:ns,useDeferredValue:function(e){var t=Po();return Co===null?t.memoizedState=e:as(t,Co.memoizedState,e)},useTransition:function(){return[Lo(Fo)[0],Po().memoizedState]},useMutableSource:Ro,useSyncExternalStore:zo,useId:ss,unstable_isNewReconciler:!1};function _s(e,t){if(e&&e.defaultProps){for(var n in t=F({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function vs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:F({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ys={isMounted:function(e){return(e=e._reactInternals)?ut(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pl(),i=ml(e),a=to(r,i);a.payload=t,n!=null&&(a.callback=n),t=no(e,a,i),t!==null&&(hl(t,e,i,r),ro(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pl(),i=ml(e),a=to(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=no(e,a,i),t!==null&&(hl(t,e,i,r),ro(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pl(),r=ml(e),i=to(n,r);i.tag=2,t!=null&&(i.callback=t),t=no(e,i,r),t!==null&&(hl(t,e,r,n),ro(t,e,r))}};function bs(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?!Ar(n,r)||!Ar(i,a):!0}function xs(e,t,n){var r=!1,i=Gi,a=t.contextType;return typeof a==`object`&&a?a=qa(a):(i=Xi(t)?Ji:Ki.current,r=t.contextTypes,a=(r=r!=null)?Yi(e,i):Gi),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ys,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Ss(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&&ys.enqueueReplaceState(t,t.state,null)}function Cs(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},$a(e);var a=t.contextType;typeof a==`object`&&a?i.context=qa(a):(a=Xi(t)?Ji:Ki.current,i.context=Yi(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(vs(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&ys.enqueueReplaceState(i,i.state,null),ao(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function ws(e,t){try{var n=``,r=t;do n+=ce(r),r=r.return;while(r);var i=n}catch(e){i=`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ts(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Es(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Ds=typeof WeakMap==`function`?WeakMap:Map;function Os(e,t,n){n=to(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){rl||(rl=!0,il=r),Es(e,t)},n}function ks(e,t,n){n=to(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Es(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Es(e,t),typeof r!=`function`&&(al===null?al=new Set([this]):al.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function As(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ds;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)||(i.add(n),e=zl.bind(null,e,t,n),t.then(e,e))}function js(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Ms(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=to(-1,1),t.tag=2,no(n,t,1))),n.lanes|=1),e)}var Ns=C.ReactCurrentOwner,Ps=!1;function Fs(e,t,n,r){t.child=e===null?Ra(t,null,n,r):La(t,e.child,n,r)}function Is(e,t,n,r,i){n=n.render;var a=t.ref;return Ka(t,i),r=jo(e,t,n,r,a,i),n=Mo(),e!==null&&!Ps?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,nc(e,t,i)):(q&&n&&ya(t),t.flags|=1,Fs(e,t,r,i),t.child)}function Ls(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ql(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Rs(e,t,a,r,i)):(e=Xl(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Ar:n,n(o,r)&&e.ref===t.ref)return nc(e,t,i)}return t.flags|=1,e=Yl(a,r),e.ref=t.ref,e.return=t,t.child=e}function Rs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Ar(a,r)&&e.ref===t.ref){if(Ps=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ps=!0);else return t.lanes=e.lanes,nc(e,t,i)}}return Vs(e,t,n,r,i)}function zs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`){if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},G(Kc,Gc),Gc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,G(Kc,Gc),Gc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,G(Kc,Gc),Gc|=r}}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),G(Kc,Gc),Gc|=r;return Fs(e,t,i,n),t.child}function Bs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Vs(e,t,n,r,i){var a=Xi(n)?Ji:Ki.current;return a=Yi(t,a),Ka(t,i),n=jo(e,t,n,r,a,i),r=Mo(),e!==null&&!Ps?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,nc(e,t,i)):(q&&r&&ya(t),t.flags|=1,Fs(e,t,n,i),t.child)}function Hs(e,t,n,r,i){if(Xi(n)){var a=!0;ea(t)}else a=!1;if(Ka(t,i),t.stateNode===null)tc(e,t),xs(t,n,r),Cs(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=qa(l):(l=Xi(n)?Ji:Ki.current,l=Yi(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Ss(t,o,r,l),Qa=!1;var f=t.memoizedState;o.state=f,ao(t,r,o,i),c=t.memoizedState,s!==r||f!==c||qi.current||Qa?(typeof u==`function`&&(vs(t,n,u,r),c=t.memoizedState),(s=Qa||bs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,eo(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:_s(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=qa(c):(c=Xi(n)?Ji:Ki.current,c=Yi(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Ss(t,o,r,c),Qa=!1,f=t.memoizedState,o.state=f,ao(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||qi.current||Qa?(typeof p==`function`&&(vs(t,n,p,r),m=t.memoizedState),(l=Qa||bs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Us(e,t,n,r,a,i)}function Us(e,t,n,r,i,a){Bs(e,t);var o=!!(t.flags&128);if(!r&&!o)return i&&ta(t,n,!1),nc(e,t,a);r=t.stateNode,Ns.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=La(t,e.child,null,a),t.child=La(t,null,s,a)):Fs(e,t,s,a),t.memoizedState=r.state,i&&ta(t,n,!0),t.child}function Ws(e){var t=e.stateNode;t.pendingContext?Qi(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Qi(e,t.context,!1),po(e,t.containerInfo)}function Gs(e,t,n,r,i){return Aa(),ja(i),t.flags|=256,Fs(e,t,n,r),t.child}var Ks={dehydrated:null,treeContext:null,retryLane:0};function qs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Js(e,t,n){var r=t.pendingProps,i=J.current,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(i&2)),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),G(J,i&1),e===null)return Ea(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.lanes=t.mode&1?e.data===`$!`?8:1073741824:1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Ql(o,r,0,null),e=Zl(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=qs(n),t.memoizedState=Ks,e):Ys(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return Zs(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Yl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=Zl(a,o,n,null),a.flags|=2):a=Yl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?qs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Ks,r}return a=e.child,e=a.sibling,r=Yl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ys(e,t){return t=Ql({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function Xs(e,t,n,r){return r!==null&&ja(r),La(t,e.child,null,n),e=Ys(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Zs(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ts(Error(r(422))),Xs(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=Ql({mode:`visible`,children:i.children},a,0,null),o=Zl(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&La(t,e.child,null,s),t.child.memoizedState=qs(s),t.memoizedState=Ks,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return Xs(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ts(o,i,void 0),Xs(e,t,s,i)}if(c=(s&e.childLanes)!==0,Ps||c){if(i=Uc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,Za(e,a),hl(i,e,a,-1))}return kl(),i=Ts(Error(r(421))),Xs(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Vl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,xa=ki(a.nextSibling),ba=t,q=!0,Sa=null,e!==null&&(fa[pa++]=ha,fa[pa++]=ga,fa[pa++]=ma,ha=e.id,ga=e.overflow,ma=t),t=Ys(t,i.children),t.flags|=4096,t)}function Qs(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ga(e.return,t,n)}function $s(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function ec(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Fs(e,t,r.children,n),r=J.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Qs(e,n,t);else if(e.tag===19)Qs(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}r&=1}if(G(J,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&_o(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),$s(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&_o(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}$s(t,!0,n,null,a);break;case`together`:$s(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function tc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function nc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Yc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Yl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rc(e,t,n){switch(t.tag){case 3:Ws(t),Aa();break;case 5:ho(t);break;case 1:Xi(t.type)&&ea(t);break;case 4:po(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;G(za,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(G(J,J.current&1),e=nc(e,t,n),e===null?null:e.sibling):Js(e,t,n):(G(J,J.current&1),t.flags|=128,null);G(J,J.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return ec(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),G(J,J.current),r)break;return null;case 22:case 23:return t.lanes=0,zs(e,t,n)}return nc(e,t,n)}var ic=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},ac=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,fo(co.current);var o=null;switch(n){case`input`:i=_e(e,i),r=_e(e,r),o=[];break;case`select`:i=F({},i,{value:void 0}),r=F({},r,{value:void 0}),o=[];break;case`textarea`:i=Te(e,i),r=Te(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=yi)}ze(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null){if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null))}for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null)){if(u===`style`){if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l}else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&U(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},oc=function(e,t,n,r){n!==r&&(t.flags|=4)};function sc(e,t){if(!q)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 cc(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&14680064,r|=i.flags&14680064,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 lc(e,t,n){var i=t.pendingProps;switch(K(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cc(t),null;case 1:return Xi(t.type)&&Zi(),cc(t),null;case 3:return i=t.stateNode,mo(),W(qi),W(Ki),yo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Oa(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Sa!==null&&(yl(Sa),Sa=null))),cc(t),null;case 5:go(t);var o=fo(uo.current);if(n=t.type,e!==null&&t.stateNode!=null)ac(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return cc(t),null}if(e=fo(co.current),Oa(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Mi]=t,i[Ni]=s,e=!!(t.mode&1),n){case`dialog`:U(`cancel`,i),U(`close`,i);break;case`iframe`:case`object`:case`embed`:U(`load`,i);break;case`video`:case`audio`:for(o=0;o<ni.length;o++)U(ni[o],i);break;case`source`:U(`error`,i);break;case`img`:case`image`:case`link`:U(`error`,i),U(`load`,i);break;case`details`:U(`toggle`,i);break;case`input`:ve(i,s),U(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},U(`invalid`,i);break;case`textarea`:Ee(i,s),U(`invalid`,i)}for(var c in ze(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&vi(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&vi(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&U(`scroll`,i)}switch(n){case`input`:me(i),xe(i,s,!0);break;case`textarea`:me(i),Oe(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=yi)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=ke(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Mi]=t,e[Ni]=i,ic(e,t,!1,!1),t.stateNode=e;a:{switch(c=Be(n,i),n){case`dialog`:U(`cancel`,e),U(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:U(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ni.length;o++)U(ni[o],e);o=i;break;case`source`:U(`error`,e),o=i;break;case`img`:case`image`:case`link`:U(`error`,e),U(`load`,e),o=i;break;case`details`:U(`toggle`,e),o=i;break;case`input`:ve(e,i),o=_e(e,i),U(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=F({},i,{value:void 0}),U(`invalid`,e);break;case`textarea`:Ee(e,i),o=Te(e,i),U(`invalid`,e);break;default:o=i}for(s in ze(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?Le(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&Me(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Ne(e,u):typeof u==`number`&&Ne(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&U(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:me(e),xe(e,i,!1);break;case`textarea`:me(e),Oe(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+de(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&we(e,!!i.multiple,i.defaultValue,!0):we(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=yi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return cc(t),null;case 6:if(e&&t.stateNode!=null)oc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=fo(uo.current),fo(co.current),Oa(t)){if(i=t.stateNode,n=t.memoizedProps,i[Mi]=t,(s=i.nodeValue!==n)&&(e=ba,e!==null))switch(e.tag){case 3:vi(i.nodeValue,n,!!(e.mode&1));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&vi(i.nodeValue,n,!!(e.mode&1))}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Mi]=t,t.stateNode=i}return cc(t),null;case 13:if(W(J),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(q&&xa!==null&&t.mode&1&&!(t.flags&128))ka(),Aa(),t.flags|=98560,s=!1;else if(s=Oa(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Mi]=t}else Aa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;cc(t),s=!1}else Sa!==null&&(yl(Sa),Sa=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||J.current&1?qc===0&&(qc=3):kl())),t.updateQueue!==null&&(t.flags|=4),cc(t),null);case 4:return mo(),e===null&&ci(t.stateNode.containerInfo),cc(t),null;case 10:return Wa(t.type._context),cc(t),null;case 17:return Xi(t.type)&&Zi(),cc(t),null;case 19:if(W(J),s=t.memoizedState,s===null)return cc(t),null;if(i=!!(t.flags&128),c=s.rendering,c===null){if(i)sc(s,!1);else{if(qc!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=_o(e),c!==null){for(t.flags|=128,sc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return G(J,J.current&1|2),t.child}e=e.sibling}s.tail!==null&&I()>tl&&(t.flags|=128,i=!0,sc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=_o(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),sc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!q)return cc(t),null}else 2*I()-s.renderingStartTime>tl&&n!==1073741824&&(t.flags|=128,i=!0,sc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(cc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=I(),t.sibling=null,n=J.current,G(J,i?n&1|2:n&1),t);case 22:case 23:return Tl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Gc&1073741824&&(cc(t),t.subtreeFlags&6&&(t.flags|=8192)):cc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function uc(e,t){switch(K(t),t.tag){case 1:return Xi(t.type)&&Zi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return mo(),W(qi),W(Ki),yo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return go(t),null;case 13:if(W(J),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Aa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(J),null;case 4:return mo(),null;case 10:return Wa(t.type._context),null;case 22:case 23:return Tl(),null;case 24:return null;default:return null}}var dc=!1,fc=!1,pc=typeof WeakSet==`function`?WeakSet:Set,X=null;function mc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){$(e,t,n)}else n.current=null}}function hc(e,t,n){try{n()}catch(n){$(e,t,n)}}var gc=!1;function _c(e,t){if(bi=gn,e=Pr(),Fr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.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||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(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(xi={focusedElem:e,selectionRange:n},gn=!1,X=t;X!==null;)if(t=X,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,X=e;else for(;X!==null;){t=X;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:_s(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,X=e;break}X=t.return}return h=gc,gc=!1,h}function vc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&hc(t,n,a)}i=i.next}while(i!==r)}}function yc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function bc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function xc(e){var t=e.alternate;t!==null&&(e.alternate=null,xc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Mi],delete t[Ni],delete t[Fi],delete t[Ii],delete t[Li])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function Cc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(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.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 wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=yi));else if(r!==4&&(e=e.child,e!==null))for(wc(e,t,n),e=e.sibling;e!==null;)wc(e,t,n),e=e.sibling}function Tc(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&&(e=e.child,e!==null))for(Tc(e,t,n),e=e.sibling;e!==null;)Tc(e,t,n),e=e.sibling}var Ec=null,Dc=!1;function Oc(e,t,n){for(n=n.child;n!==null;)kc(e,t,n),n=n.sibling}function kc(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount==`function`)try{Dt.onCommitFiberUnmount(Et,n)}catch{}switch(n.tag){case 5:fc||mc(n,t);case 6:var r=Ec,i=Dc;Ec=null,Oc(e,t,n),Ec=r,Dc=i,Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ec.removeChild(n.stateNode));break;case 18:Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?Oi(e.parentNode,n):e.nodeType===1&&Oi(e,n),mn(e)):Oi(Ec,n.stateNode));break;case 4:r=Ec,i=Dc,Ec=n.stateNode.containerInfo,Dc=!0,Oc(e,t,n),Ec=r,Dc=i;break;case 0:case 11:case 14:case 15:if(!fc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&hc(n,t,o),i=i.next}while(i!==r)}Oc(e,t,n);break;case 1:if(!fc&&(mc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$(n,t,e)}Oc(e,t,n);break;case 21:Oc(e,t,n);break;case 22:n.mode&1?(fc=(r=fc)||n.memoizedState!==null,Oc(e,t,n),fc=r):Oc(e,t,n);break;default:Oc(e,t,n)}}function Ac(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function jc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Ec=c.stateNode,Dc=!1;break a;case 3:Ec=c.stateNode.containerInfo,Dc=!0;break a;case 4:Ec=c.stateNode.containerInfo,Dc=!0;break a}c=c.return}if(Ec===null)throw Error(r(160));kc(o,s,a),Ec=null,Dc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){$(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Mc(t,e),t=t.sibling}function Mc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(jc(t,e),Nc(e),i&4){try{vc(3,e,e.return),yc(3,e)}catch(t){$(e,e.return,t)}try{vc(5,e,e.return)}catch(t){$(e,e.return,t)}}break;case 1:jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return);break;case 5:if(jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return),e.flags&32){var a=e.stateNode;try{Ne(a,``)}catch(t){$(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&ye(a,o),Be(c,s);var u=Be(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?Le(a,f):d===`dangerouslySetInnerHTML`?Me(a,f):d===`children`?Ne(a,f):S(a,d,f,u)}switch(c){case`input`:be(a,o);break;case`textarea`:De(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?we(a,!!o.multiple,o.multiple?[]:``,!1):we(a,!!o.multiple,o.defaultValue,!0)):we(a,!!o.multiple,m,!1)}a[Ni]=o}catch(t){$(e,e.return,t)}}break;case 6:if(jc(t,e),Nc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){$(e,e.return,t)}}break;case 3:if(jc(t,e),Nc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{mn(t.containerInfo)}catch(t){$(e,e.return,t)}break;case 4:jc(t,e),Nc(e);break;case 13:jc(t,e),Nc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(el=I())),i&4&&Ac(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(fc=(u=fc)||d,jc(t,e),fc=u):jc(t,e),Nc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(X=e,d=e.child;d!==null;){for(f=X=d;X!==null;){switch(p=X,m=p.child,p.tag){case 0:case 11:case 14:case 15:vc(4,p,p.return);break;case 1:mc(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){$(i,n,e)}}break;case 5:mc(p,p.return);break;case 22:if(p.memoizedState!==null){Lc(f);continue}}m===null?Lc(f):(m.return=p,X=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Ie(`display`,s))}catch(t){$(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){$(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:jc(t,e),Nc(e),i&4&&Ac(e);break;case 21:break;default:jc(t,e),Nc(e)}}function Nc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Sc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Ne(a,``),i.flags&=-33),Tc(e,Cc(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;wc(e,Cc(e),o);break;default:throw Error(r(161))}}catch(t){$(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Pc(e,t,n){X=e,Fc(e,t,n)}function Fc(e,t,n){for(var r=!!(e.mode&1);X!==null;){var i=X,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||dc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||fc;s=dc;var l=fc;if(dc=o,(fc=c)&&!l)for(X=i;X!==null;)o=X,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Rc(i):(c.return=o,X=c);for(;a!==null;)X=a,Fc(a,t,n),a=a.sibling;X=i,dc=s,fc=l}Ic(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,X=a):Ic(e,t,n)}}function Ic(e){for(;X!==null;){var t=X;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:fc||yc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!fc){if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:_s(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}}var o=t.updateQueue;o!==null&&oo(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}oo(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&mn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}fc||t.flags&512&&bc(t)}catch(e){$(t,t.return,e)}}if(t===e){X=null;break}if(n=t.sibling,n!==null){n.return=t.return,X=n;break}X=t.return}}function Lc(e){for(;X!==null;){var t=X;if(t===e){X=null;break}var n=t.sibling;if(n!==null){n.return=t.return,X=n;break}X=t.return}}function Rc(e){for(;X!==null;){var t=X;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{yc(4,t)}catch(e){$(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){$(t,i,e)}}var a=t.return;try{bc(t)}catch(e){$(t,a,e)}break;case 5:var o=t.return;try{bc(t)}catch(e){$(t,o,e)}}}catch(e){$(t,t.return,e)}if(t===e){X=null;break}var s=t.sibling;if(s!==null){s.return=t.return,X=s;break}X=t.return}}var zc=Math.ceil,Bc=C.ReactCurrentDispatcher,Vc=C.ReactCurrentOwner,Hc=C.ReactCurrentBatchConfig,Z=0,Uc=null,Q=null,Wc=0,Gc=0,Kc=Wi(0),qc=0,Jc=null,Yc=0,Xc=0,Zc=0,Qc=null,$c=null,el=0,tl=1/0,nl=null,rl=!1,il=null,al=null,ol=!1,sl=null,cl=0,ll=0,ul=null,dl=-1,fl=0;function pl(){return Z&6?I():dl===-1?dl=I():dl}function ml(e){return e.mode&1?Z&2&&Wc!==0?Wc&-Wc:Ma.transition===null?(e=R,e===0?(e=window.event,e=e===void 0?16:xn(e.type),e):e):(fl===0&&(fl=zt()),fl):1}function hl(e,t,n,i){if(50<ll)throw ll=0,ul=null,Error(r(185));Vt(e,n,i),(!(Z&2)||e!==Uc)&&(e===Uc&&(!(Z&2)&&(Xc|=n),qc===4&&xl(e,Wc)),gl(e,i),n===1&&Z===0&&!(t.mode&1)&&(tl=I()+500,ra&&sa()))}function gl(e,t){var n=e.callbackNode;Lt(e,t);var r=Ft(e,e===Uc?Wc:0);if(r===0)n!==null&&_t(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&_t(n),t===1)e.tag===0?oa(Sl.bind(null,e)):aa(Sl.bind(null,e)),Ei(function(){!(Z&6)&&sa()}),n=null;else{switch(Wt(r)){case 1:n=xt;break;case 4:n=St;break;case 16:n=Ct;break;case 536870912:n=Tt;break;default:n=Ct}n=Wl(n,_l.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function _l(e,t){if(dl=-1,fl=0,Z&6)throw Error(r(327));var n=e.callbackNode;if(Ll()&&e.callbackNode!==n)return null;var i=Ft(e,e===Uc?Wc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Al(e,i);else{t=i;var a=Z;Z|=2;var o=Ol();(Uc!==e||Wc!==t)&&(nl=null,tl=I()+500,El(e,t));do try{Ml();break}catch(t){Dl(e,t)}while(1);Ua(),Bc.current=o,Z=a,Q===null?(Uc=null,Wc=0,t=qc):t=0}if(t!==0){if(t===2&&(a=Rt(e),a!==0&&(i=a,t=vl(e,a))),t===1)throw n=Jc,El(e,0),xl(e,i),gl(e,I()),n;if(t===6)xl(e,i);else{if(a=e.current.alternate,!(i&30)&&!bl(a)&&(t=Al(e,i),t===2&&(o=Rt(e),o!==0&&(i=o,t=vl(e,o))),t===1))throw n=Jc,El(e,0),xl(e,i),gl(e,I()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Fl(e,$c,nl);break;case 3:if(xl(e,i),(i&130023424)===i&&(t=el+500-I(),10<t)){if(Ft(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){pl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ci(Fl.bind(null,e,$c,nl),t);break}Fl(e,$c,nl);break;case 4:if(xl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-kt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=I()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*zc(i/1960))-i,10<i){e.timeoutHandle=Ci(Fl.bind(null,e,$c,nl),i);break}Fl(e,$c,nl);break;case 5:Fl(e,$c,nl);break;default:throw Error(r(329))}}}return gl(e,I()),e.callbackNode===n?_l.bind(null,e):null}function vl(e,t){var n=Qc;return e.current.memoizedState.isDehydrated&&(El(e,t).flags|=256),e=Al(e,t),e!==2&&(t=$c,$c=n,t!==null&&yl(t)),e}function yl(e){$c===null?$c=e:$c.push.apply($c,e)}function bl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(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(!kr(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 xl(e,t){for(t&=~Zc,t&=~Xc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-kt(t),r=1<<n;e[n]=-1,t&=~r}}function Sl(e){if(Z&6)throw Error(r(327));Ll();var t=Ft(e,0);if(!(t&1))return gl(e,I()),null;var n=Al(e,t);if(e.tag!==0&&n===2){var i=Rt(e);i!==0&&(t=i,n=vl(e,i))}if(n===1)throw n=Jc,El(e,0),xl(e,t),gl(e,I()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fl(e,$c,nl),gl(e,I()),null}function Cl(e,t){var n=Z;Z|=1;try{return e(t)}finally{Z=n,Z===0&&(tl=I()+500,ra&&sa())}}function wl(e){sl!==null&&sl.tag===0&&!(Z&6)&&Ll();var t=Z;Z|=1;var n=Hc.transition,r=R;try{if(Hc.transition=null,R=1,e)return e()}finally{R=r,Hc.transition=n,Z=t,!(Z&6)&&sa()}}function Tl(){Gc=Kc.current,W(Kc)}function El(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,wi(n)),Q!==null)for(n=Q.return;n!==null;){var r=n;switch(K(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Zi();break;case 3:mo(),W(qi),W(Ki),yo();break;case 5:go(r);break;case 4:mo();break;case 13:W(J);break;case 19:W(J);break;case 10:Wa(r.type._context);break;case 22:case 23:Tl()}n=n.return}if(Uc=e,Q=e=Yl(e.current,null),Wc=Gc=t,qc=0,Jc=null,Zc=Xc=Yc=0,$c=Qc=null,Ja!==null){for(t=0;t<Ja.length;t++)if(n=Ja[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}Ja=null}return e}function Dl(e,t){do{var n=Q;try{if(Ua(),bo.current=ps,To){for(var i=Y.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}To=!1}if(So=0,wo=Co=Y=null,Eo=!1,Do=0,Vc.current=null,n===null||n.return===null){qc=1,Jc=t,Q=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Wc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=js(s);if(m!==null){m.flags&=-257,Ms(m,s,c,o,t),m.mode&1&&As(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}if(!(t&1)){As(o,u,t),kl();break a}l=Error(r(426))}else if(q&&c.mode&1){var _=js(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Ms(_,s,c,o,t),ja(ws(l,c));break a}}o=l=ws(l,c),qc!==4&&(qc=2),Qc===null?Qc=[o]:Qc.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Os(o,l,t);io(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(al===null||!al.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=ks(o,c,t);io(o,x);break a}}o=o.return}while(o!==null)}Pl(n)}catch(e){t=e,Q===n&&n!==null&&(Q=n=n.return);continue}break}while(1)}function Ol(){var e=Bc.current;return Bc.current=ps,e===null?ps:e}function kl(){(qc===0||qc===3||qc===2)&&(qc=4),Uc===null||!(Yc&268435455)&&!(Xc&268435455)||xl(Uc,Wc)}function Al(e,t){var n=Z;Z|=2;var i=Ol();(Uc!==e||Wc!==t)&&(nl=null,El(e,t));do try{jl();break}catch(t){Dl(e,t)}while(1);if(Ua(),Z=n,Bc.current=i,Q!==null)throw Error(r(261));return Uc=null,Wc=0,qc}function jl(){for(;Q!==null;)Nl(Q)}function Ml(){for(;Q!==null&&!vt();)Nl(Q)}function Nl(e){var t=Ul(e.alternate,e,Gc);e.memoizedProps=e.pendingProps,t===null?Pl(e):Q=t,Vc.current=null}function Pl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=uc(n,t),n!==null){n.flags&=32767,Q=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{qc=6,Q=null;return}}else if(n=lc(n,t,Gc),n!==null){Q=n;return}if(t=t.sibling,t!==null){Q=t;return}Q=t=e}while(t!==null);qc===0&&(qc=5)}function Fl(e,t,n){var r=R,i=Hc.transition;try{Hc.transition=null,R=1,Il(e,t,n,r)}finally{Hc.transition=i,R=r}return null}function Il(e,t,n,i){do Ll();while(sl!==null);if(Z&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Ht(e,o),e===Uc&&(Q=Uc=null,Wc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||ol||(ol=!0,Wl(Ct,function(){return Ll(),null})),o=!!(n.flags&15990),n.subtreeFlags&15990||o){o=Hc.transition,Hc.transition=null;var s=R;R=1;var c=Z;Z|=4,Vc.current=null,_c(e,n),Mc(n,e),Ir(xi),gn=!!bi,xi=bi=null,e.current=n,Pc(n,e,a),yt(),Z=c,R=s,Hc.transition=o}else e.current=n;if(ol&&(ol=!1,sl=e,cl=a),o=e.pendingLanes,o===0&&(al=null),Ot(n.stateNode,i),gl(e,I()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(rl)throw rl=!1,e=il,il=null,e;return cl&1&&e.tag!==0&&Ll(),o=e.pendingLanes,o&1?e===ul?ll++:(ll=0,ul=e):ll=0,sa(),null}function Ll(){if(sl!==null){var e=Wt(cl),t=Hc.transition,n=R;try{if(Hc.transition=null,R=16>e?16:e,sl===null)var i=!1;else{if(e=sl,sl=null,cl=0,Z&6)throw Error(r(331));var a=Z;for(Z|=4,X=e.current;X!==null;){var o=X,s=o.child;if(X.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(X=u;X!==null;){var d=X;switch(d.tag){case 0:case 11:case 15:vc(8,d,o)}var f=d.child;if(f!==null)f.return=d,X=f;else for(;X!==null;){d=X;var p=d.sibling,m=d.return;if(xc(d),d===u){X=null;break}if(p!==null){p.return=m,X=p;break}X=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}X=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,X=s;else b:for(;X!==null;){if(o=X,o.flags&2048)switch(o.tag){case 0:case 11:case 15:vc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,X=v;break b}X=o.return}}var y=e.current;for(X=y;X!==null;){s=X;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,X=b;else b:for(s=y;X!==null;){if(c=X,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:yc(9,c)}}catch(e){$(c,c.return,e)}if(c===s){X=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,X=x;break b}X=c.return}}if(Z=a,sa(),Dt&&typeof Dt.onPostCommitFiberRoot==`function`)try{Dt.onPostCommitFiberRoot(Et,e)}catch{}i=!0}return i}finally{R=n,Hc.transition=t}}return!1}function Rl(e,t,n){t=ws(n,t),t=Os(e,t,1),e=no(e,t,1),t=pl(),e!==null&&(Vt(e,1,t),gl(e,t))}function $(e,t,n){if(e.tag===3)Rl(e,e,n);else for(;t!==null;){if(t.tag===3){Rl(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(al===null||!al.has(r))){e=ws(n,e),e=ks(t,e,1),t=no(t,e,1),e=pl(),t!==null&&(Vt(t,1,e),gl(t,e));break}}t=t.return}}function zl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=pl(),e.pingedLanes|=e.suspendedLanes&n,Uc===e&&(Wc&n)===n&&(qc===4||qc===3&&(Wc&130023424)===Wc&&500>I()-el?El(e,0):Zc|=n),gl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=Nt,Nt<<=1,!(Nt&130023424)&&(Nt=4194304)):t=1);var n=pl();e=Za(e,t),e!==null&&(Vt(e,t,n),gl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||qi.current)Ps=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ps=!1,rc(e,t,n);Ps=!!(e.flags&131072)}}else Ps=!1,q&&t.flags&1048576&&va(t,da,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;tc(e,t),e=t.pendingProps;var a=Yi(t,Ki.current);Ka(t,n),a=jo(null,t,i,e,a,n);var o=Mo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Xi(i)?(o=!0,ea(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,$a(t),a.updater=ys,t.stateNode=a,a._reactInternals=t,Cs(t,i,e,n),t=Us(null,t,i,!0,o,n)):(t.tag=0,q&&o&&ya(t),Fs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(tc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Jl(i),e=_s(i,e),a){case 0:t=Vs(null,t,i,e,n);break a;case 1:t=Hs(null,t,i,e,n);break a;case 11:t=Is(null,t,i,e,n);break a;case 14:t=Ls(null,t,i,_s(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Vs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Hs(e,t,i,a,n);case 3:a:{if(Ws(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,eo(e,t),ao(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=ws(Error(r(423)),t),t=Gs(e,t,i,n,a);break a}if(i!==a){a=ws(Error(r(424)),t),t=Gs(e,t,i,n,a);break a}for(xa=ki(t.stateNode.containerInfo.firstChild),ba=t,q=!0,Sa=null,n=Ra(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Aa(),i===a){t=nc(e,t,n);break a}Fs(e,t,i,n)}t=t.child}return t;case 5:return ho(t),e===null&&Ea(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Si(i,a)?s=null:o!==null&&Si(i,o)&&(t.flags|=32),Bs(e,t),Fs(e,t,s,n),t.child;case 6:return e===null&&Ea(t),null;case 13:return Js(e,t,n);case 4:return po(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=La(t,null,i,n):Fs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Is(e,t,i,a,n);case 7:return Fs(e,t,t.pendingProps,n),t.child;case 8:return Fs(e,t,t.pendingProps.children,n),t.child;case 12:return Fs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,G(za,i._currentValue),i._currentValue=s,o!==null){if(kr(o.value,s)){if(o.children===a.children&&!qi.current){t=nc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=to(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ga(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ga(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Fs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Ka(t,n),a=qa(a),i=i(a),t.flags|=1,Fs(e,t,i,n),t.child;case 14:return i=t.type,a=_s(i,t.pendingProps),a=_s(i.type,a),Ls(e,t,i,a,n);case 15:return Rs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),tc(e,t),t.tag=1,Xi(i)?(e=!0,ea(t)):e=!1,Ka(t,n),xs(t,i,a),Cs(t,i,a,n),Us(null,t,i,!0,e,n);case 19:return ec(e,t,n);case 22:return zs(e,t,n)}throw Error(r(156,t.tag))};function Wl(e,t){return gt(e,t)}function Gl(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.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 Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===A)return 11;if(e===N)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(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&14680064,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}function Xl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return Zl(n.children,a,o,t);case ee:s=8,a|=8;break;case D:return e=Kl(12,n,t,a|2),e.elementType=D,e.lanes=o,e;case j:return e=Kl(13,n,t,a),e.elementType=j,e.lanes=o,e;case M:return e=Kl(19,n,t,a),e.elementType=M,e.lanes=o,e;case te:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case O:s=10;break a;case k:s=9;break a;case A:s=11;break a;case N:s=14;break a;case P:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=te,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Bt(0),this.expirationTimes=Bt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(a),e}function ru(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function iu(e){if(!e)return Gi;e=e._reactInternals;a:{if(ut(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(Xi(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(Xi(n))return $i(e,n,t)}return t}function au(e,t,n,r,i,a,o,s,c){return e=nu(n,r,!0,e,i,a,o,s,c),e.context=iu(null),n=e.current,r=pl(),i=ml(n),a=to(r,i),a.callback=t??null,no(n,a,i),e.current.lanes=i,Vt(e,i,r),gl(e,r),e}function ou(e,t,n,r){var i=t.current,a=pl(),o=ml(i);return n=iu(n),t.context===null?t.context=n:t.pendingContext=n,t=to(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=no(i,t,o),e!==null&&(hl(e,i,o,a),ro(e,i,o)),o}function su(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function cu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function lu(e,t){cu(e,t),(e=e.alternate)&&cu(e,t)}function uu(){return null}var du=typeof reportError==`function`?reportError:function(e){console.error(e)};function fu(e){this._internalRoot=e}pu.prototype.render=fu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));ou(e,t,null,null)},pu.prototype.unmount=fu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wl(function(){ou(null,e,null,null)}),t[Pi]=null}};function pu(e){this._internalRoot=e}pu.prototype.unstable_scheduleHydration=function(e){if(e){var t=Jt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<rn.length&&t!==0&&t<rn[n].priority;n++);rn.splice(n,0,e),n===0&&ln(e)}};function mu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function hu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function gu(){}function _u(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=su(o);a.call(e)}}var o=au(t,r,e,0,null,!1,!1,``,gu);return e._reactRootContainer=o,e[Pi]=o.current,ci(e.nodeType===8?e.parentNode:e),wl(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=su(c);s.call(e)}}var c=nu(e,0,!1,null,null,!1,!1,``,gu);return e._reactRootContainer=c,e[Pi]=c.current,ci(e.nodeType===8?e.parentNode:e),wl(function(){ou(t,c,n,r)}),c}function vu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=su(o);s.call(e)}}ou(t,o,e,i)}else o=_u(n,t,e,i,r);return su(o)}Gt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Pt(t.pendingLanes);n!==0&&(Ut(t,n|1),gl(t,I()),!(Z&6)&&(tl=I()+500,sa()))}break;case 13:wl(function(){var t=Za(e,1);t!==null&&hl(t,e,1,pl())}),lu(e,1)}},Kt=function(e){if(e.tag===13){var t=Za(e,134217728);t!==null&&hl(t,e,134217728,pl()),lu(e,134217728)}},qt=function(e){if(e.tag===13){var t=ml(e),n=Za(e,t);n!==null&&hl(n,e,t,pl()),lu(e,t)}},Jt=function(){return R},Yt=function(e,t){var n=R;try{return R=e,t()}finally{R=n}},Ue=function(e,t,n){switch(t){case`input`:if(be(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Vi(i);if(!a)throw Error(r(90));he(i),be(i,a)}}}break;case`textarea`:De(e,n);break;case`select`:t=n.value,t!=null&&we(e,!!n.multiple,t,!1)}},Ye=Cl,Xe=wl;var yu={usingClientEntryPoint:!1,Events:[zi,Bi,Vi,qe,Je,Cl]},bu={findFiberByHostInstance:Ri,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},xu={bundleType:bu.bundleType,version:bu.version,rendererPackageName:bu.rendererPackageName,rendererConfig:bu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=mt(e),e===null?null:e.stateNode},findFiberByHostInstance:bu.findFiberByHostInstance||uu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{Et=Su.inject(xu),Dt=Su}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!mu(t))throw Error(r(200));return ru(e,t,null,n)},e.createRoot=function(e,t){if(!mu(e))throw Error(r(299));var n=!1,i=``,a=du;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=nu(e,1,!1,null,null,n,!1,i,a),e[Pi]=t.current,ci(e.nodeType===8?e.parentNode:e),new fu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=mt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return wl(e)},e.hydrate=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!mu(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=du;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=au(t,null,e,1,n??null,a,!1,o,s),e[Pi]=t.current,ci(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new pu(t)},e.render=function(e,t,n){if(!hu(t))throw Error(r(200));return vu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!hu(e))throw Error(r(40));return e._reactRootContainer?(wl(function(){vu(null,null,e,!1,function(){e._reactRootContainer=null,e[Pi]=null})}),!0):!1},e.unstable_batchedUpdates=Cl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!hu(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return vu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=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=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u(),1),_=c(h(),1),v=`modulepreload`,y=function(e){return`/`+e},b={},x=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=y(t,n),t=s(t),t in b)return;b[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`:v,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)})},S=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,C=/^[\\/]{2}/;function w(e,t){return t+e.replace(/\\/g,`/`)}var T=`popstate`;function E(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function ee(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return j(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:M(t)}return P(t,n,null,e)}function D(e,t){if(e===!1||e==null)throw Error(t)}function O(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function k(){return Math.random().toString(36).substring(2,10)}function A(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function j(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?N(t):t,state:n,key:t&&t.key||r||k(),mask:i}}function M({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function N(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function P(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=E(e)?e:j(h.location,e,t);n&&n(r,e),l=u()+1;let d=A(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=E(e)?e:j(h.location,e,t);n&&n(r,e),l=u();let i=A(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return te(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(T,d),c=e,()=>{i.removeEventListener(T,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function te(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),D(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:M(t);return i=i.replace(/ $/,`%20`),!n&&C.test(i)&&(i=r+i),new URL(i,r)}function ne(e,t,n=`/`){return re(e,t,n,!1)}function re(e,t,n,r,i){let a=xe((typeof t==`string`?N(t):t).pathname||`/`,n);if(a==null)return null;let o=i??F(e),s=null,c=be(a);for(let e=0;s==null&&e<o.length;++e)s=ge(o[e],c,r);return s}function F(e){let t=ie(e);return oe(t),t}function ie(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;D(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=ke([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(D(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ie(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:me(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=ye(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ae(e.path))a(e,t,!0,n)}),t}function ae(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ae(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function oe(e){e.sort((e,t)=>e.score===t.score?he(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var se=/^:[\w-]+$/,ce=3,le=2,ue=1,de=10,fe=-2,pe=e=>e===`*`;function me(e,t){let n=e.split(`/`),r=n.length;return n.some(pe)&&(r+=fe),t&&(r+=le),n.filter(e=>!pe(e)).reduce((e,t)=>e+(se.test(t)?ce:t===``?ue:de),r)}function he(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ge(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?ve(u,l,s.matcher,s.compiledParams):_e(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=_e({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:ke([a,d.pathname]),pathnameBase:je(ke([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=ke([a,d.pathnameBase]))}return o}function _e(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ye(e.path,e.caseSensitive,e.end);return ve(e,t,n,r)}function ve(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return e[t]=n&&!i?void 0:(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ye(e,t=!1,n=!0){O(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function be(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return O(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function xe(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function Se(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?N(e):e,a;return n?(n=Oe(n),a=n.startsWith(`/`)?Ce(n.substring(1),`/`):Ce(n,t)):a=t,{pathname:a,search:Me(r),hash:Ne(i)}}function Ce(e,t){let n=Ae(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function we(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Te(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ee(e){let t=Te(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function De(e,t,n,r=!1){let i;typeof e==`string`?i=N(e):(i={...e},D(!i.pathname||!i.pathname.includes(`?`),we(`?`,`pathname`,`search`,i)),D(!i.pathname||!i.pathname.includes(`#`),we(`#`,`pathname`,`hash`,i)),D(!i.search||!i.search.includes(`#`),we(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Se(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Oe=e=>e.replace(/[\\/]{2,}/g,`/`),ke=e=>Oe(e.join(`/`)),Ae=e=>e.replace(/\/+$/,``),je=e=>Ae(e).replace(/^\/*/,`/`),Me=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ne=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Pe=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Fe(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ie(e){return ke(e.map(e=>e.route.path).filter(Boolean))||`/`}var Le=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Re(e,t){let n=e;if(typeof n!=`string`||!S.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Le)try{let e=new URL(window.location.href),r=C.test(n)?new URL(w(n,e.protocol)):new URL(n),a=xe(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{O(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var ze=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(ze);var Be=[`GET`,...ze];new Set(Be);var Ve=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function He(e){try{return Ve.includes(new URL(e).protocol)}catch{return!1}}var Ue=g.createContext(null);Ue.displayName=`DataRouter`;var We=g.createContext(null);We.displayName=`DataRouterState`;var Ge=g.createContext(!1);function Ke(){return g.useContext(Ge)}var qe=g.createContext({isTransitioning:!1});qe.displayName=`ViewTransition`;var Je=g.createContext(new Map);Je.displayName=`Fetchers`;var Ye=g.createContext(null);Ye.displayName=`Await`;var Xe=g.createContext(null);Xe.displayName=`Navigation`;var Ze=g.createContext(null);Ze.displayName=`Location`;var Qe=g.createContext({outlet:null,matches:[],isDataRoute:!1});Qe.displayName=`Route`;var $e=g.createContext(null);$e.displayName=`RouteError`;var et=`REACT_ROUTER_ERROR`,tt=`REDIRECT`,nt=`ROUTE_ERROR_RESPONSE`;function rt(e){if(e.startsWith(`${et}:${tt}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function it(e){if(e.startsWith(`${et}:${nt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Pe(t.status,t.statusText,t.data)}catch{}}function at(e,{relative:t}={}){D(ot(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=g.useContext(Xe),{hash:i,pathname:a,search:o}=ft(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:ke([n,a])),r.createHref({pathname:s,search:o,hash:i})}function ot(){return g.useContext(Ze)!=null}function st(){return D(ot(),`useLocation() may be used only in the context of a <Router> component.`),g.useContext(Ze).location}var ct=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function lt(e){g.useContext(Xe).static||g.useLayoutEffect(e)}function ut(){let{isDataRoute:e}=g.useContext(Qe);return e?Ot():dt()}function dt(){D(ot(),`useNavigate() may be used only in the context of a <Router> component.`);let e=g.useContext(Ue),{basename:t,navigator:n}=g.useContext(Xe),{matches:r}=g.useContext(Qe),{pathname:i}=st(),a=JSON.stringify(Ee(r)),o=g.useRef(!1);return lt(()=>{o.current=!0}),g.useCallback((r,s={})=>{if(O(o.current,ct),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=De(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:ke([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}g.createContext(null);function ft(e,{relative:t}={}){let{matches:n}=g.useContext(Qe),{pathname:r}=st(),i=JSON.stringify(Ee(n));return g.useMemo(()=>De(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function pt(e,t){return mt(e,t)}function mt(e,t,n){D(ot(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=g.useContext(Xe),{matches:i}=g.useContext(Qe),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;At(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
9
|
+
|
|
10
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=st(),d;if(t){let e=typeof t==`string`?N(t):t;D(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):ne(e,{pathname:p});O(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),O(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=bt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:ke([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:ke([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?g.createElement(Ze.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function ht(){let e=Dt(),t=Fe(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=g.createElement(g.Fragment,null,g.createElement(`p`,null,`💿 Hey developer 👋`),g.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,g.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,g.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),g.createElement(g.Fragment,null,g.createElement(`h2`,null,`Unexpected Application Error!`),g.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?g.createElement(`pre`,{style:i},n):null,o)}var gt=g.createElement(ht,null),_t=class extends g.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=it(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:g.createElement(Qe.Provider,{value:this.props.routeContext},g.createElement($e.Provider,{value:e,children:this.props.component}));return this.context?g.createElement(yt,{error:e},t):t}};_t.contextType=Ge;var vt=new WeakMap;function yt({children:e,error:t}){let{basename:n}=g.useContext(Xe);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=rt(t.digest);if(e){let r=vt.get(t);if(r)throw r;let i=Re(e.location,n),a=i.absoluteURL||i.to;if(He(a))throw Error(`Invalid redirect location`);if(Le&&!vt.get(t)){if(i.isExternal||e.reloadDocument)window.location.href=a;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw vt.set(t,n),n}}return g.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function I({routeContext:e,match:t,children:n}){let r=g.useContext(Ue);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),g.createElement(Qe.Provider,{value:e},n)}function bt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);D(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Ie(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||gt,o&&(s<0&&c===0?(At(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?g.createElement(n.route.Component,null):n.route.element?n.route.element:e,g.createElement(I,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?g.createElement(_t,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function xt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function St(e){let t=g.useContext(Ue);return D(t,xt(e)),t}function Ct(e){let t=g.useContext(We);return D(t,xt(e)),t}function wt(e){let t=g.useContext(Qe);return D(t,xt(e)),t}function Tt(e){let t=wt(e),n=t.matches[t.matches.length-1];return D(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Et(){return Tt(`useRouteId`)}function Dt(){let e=g.useContext($e),t=Ct(`useRouteError`),n=Tt(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Ot(){let{router:e}=St(`useNavigate`),t=Tt(`useNavigate`),n=g.useRef(!1);return lt(()=>{n.current=!0}),g.useCallback(async(r,i={})=>{O(n.current,ct),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var kt={};function At(e,t,n){!t&&!kt[e]&&(kt[e]=!0,O(!1,n))}g.memo(jt);function jt({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return mt(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function L(e){D(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Mt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){D(!ot(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=g.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=N(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=g.useMemo(()=>{let e=xe(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return O(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:g.createElement(Xe.Provider,{value:c},g.createElement(Ze.Provider,{children:t,value:h}))}function Nt({children:e,location:t}){return pt(Pt(e),t)}g.Component;function Pt(e,t=[]){let n=[];return g.Children.forEach(e,(e,r)=>{if(!g.isValidElement(e))return;let i=[...t,r];if(e.type===g.Fragment){n.push.apply(n,Pt(e.props.children,i));return}D(e.type===L,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),D(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Pt(e.props.children,i)),n.push(a)}),n}var Ft=`get`,It=`application/x-www-form-urlencoded`;function Lt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Rt(e){return Lt(e)&&e.tagName.toLowerCase()===`button`}function zt(e){return Lt(e)&&e.tagName.toLowerCase()===`form`}function Bt(e){return Lt(e)&&e.tagName.toLowerCase()===`input`}function Vt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ht(e,t){return e.button===0&&(!t||t===`_self`)&&!Vt(e)}var Ut=null;function R(){if(Ut===null)try{new FormData(document.createElement(`form`),0),Ut=!1}catch{Ut=!0}return Ut}var Wt=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Gt(e){return e!=null&&!Wt.has(e)?(O(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${It}"`),null):e}function Kt(e,t){let n,r,i,a,o;if(zt(e)){let o=e.getAttribute(`action`);r=o?xe(o,t):null,n=e.getAttribute(`method`)||Ft,i=Gt(e.getAttribute(`enctype`))||It,a=new FormData(e)}else if(Rt(e)||Bt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?xe(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Ft,i=Gt(e.getAttribute(`formenctype`))||Gt(o.getAttribute(`enctype`))||It,a=new FormData(o,e),!R()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Lt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Ft,r=null,i=It,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function qt(e,t){if(e===!1||e==null)throw Error(t)}function Jt(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return i.pathname=n?i.pathname.endsWith(`/`)?`${i.pathname}_.${r}`:`${i.pathname}.${r}`:i.pathname===`/`?`_root.${r}`:t&&xe(i.pathname,t)===`/`?`${Ae(t)}/_root.${r}`:`${Ae(i.pathname)}.${r}`,i}async function Yt(e,t){if(e.id in t)return t[e.id];try{let n=await x(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Xt(e){return e!=null&&typeof e.page==`string`}function Zt(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Qt(e,t,n){return rn((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Yt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Zt).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function $t(e,t,n,r,i,a){let o=(e,t)=>!n[t]||e.route.id!==n[t].route.id,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function en(e,t,{includeHydrateFallback:n}={}){return tn(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function tn(e){return[...new Set(e)]}function nn(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function rn(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Xt(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(nn(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function an(){let e=g.useContext(Ue);return qt(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function on(){let e=g.useContext(We);return qt(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var sn=g.createContext(void 0);sn.displayName=`FrameworkContext`;function cn(){let e=g.useContext(sn);return qt(e,`You must render this element inside a <HydratedRouter> element`),e}function ln(e,t){let n=g.useContext(sn),[r,i]=g.useState(!1),[a,o]=g.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=g.useRef(null);g.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),g.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:un(s,p),onBlur:un(c,m),onMouseEnter:un(l,p),onMouseLeave:un(u,m),onTouchStart:un(d,p)}]:[a,f,{}]:[!1,f,{}]}function un(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function dn({page:e,...t}){let n=Ke(),{nonce:r}=cn(),{router:i}=an(),a=g.useMemo(()=>ne(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),n?g.createElement(pn,{page:e,matches:a,...t}):g.createElement(mn,{page:e,matches:a,...t})):null}function fn(e){let{manifest:t,routeModules:n}=cn(),[r,i]=g.useState([]);return g.useEffect(()=>{let r=!1;return Qt(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function pn({page:e,matches:t,...n}){let r=st(),{future:i}=cn(),{basename:a}=an(),o=g.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=Jt(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return g.createElement(g.Fragment,null,o.map(e=>g.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function mn({page:e,matches:t,...n}){let r=st(),{future:i,manifest:a,routeModules:o}=cn(),{basename:s}=an(),{loaderData:c,matches:l}=on(),u=g.useMemo(()=>$t(e,t,l,a,r,`data`),[e,t,l,a,r]),d=g.useMemo(()=>$t(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=g.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=Jt(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=g.useMemo(()=>en(d,a),[d,a]),m=fn(d);return g.createElement(g.Fragment,null,f.map(e=>g.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>g.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>g.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function hn(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}g.Component;var gn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{gn&&(window.__reactRouterVersion=`7.18.2`)}catch{}function _n({basename:e,children:t,useTransitions:n,window:r}){let i=g.useRef();i.current??=ee({window:r,v5Compat:!0});let a=i.current,[o,s]=g.useState({action:a.action,location:a.location}),c=g.useCallback(e=>{n===!1?s(e):g.startTransition(()=>s(e))},[n]);return g.useLayoutEffect(()=>a.listen(c),[a,c]),g.createElement(Mt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}var z=g.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:_,useTransitions:v}=g.useContext(Xe),y=typeof l==`string`&&S.test(l),b=Re(l,h);l=b.to;let x=at(l,{relative:r}),C=st(),w=null;if(o){let e=De(o,[],C.mask?C.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:ke([h,e.pathname])),w=_.createHref(e)}let[T,E,ee]=ln(n,p),D=Sn(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:v});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(b.isExternal||i),A=g.createElement(`a`,{...p,...ee,href:(k?w:void 0)||b.absoluteURL||x,onClick:k?O:e,ref:hn(m,E),target:c,"data-discover":!y&&t===`render`?`true`:void 0});return T&&!y?g.createElement(g.Fragment,null,A,g.createElement(dn,{page:x})):A});z.displayName=`Link`;var vn=g.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=ft(a,{relative:c.relative}),d=st(),f=g.useContext(We),{navigator:p,basename:m}=g.useContext(Xe),h=f!=null&&Dn(u)&&o===!0,_=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,v=d.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&m&&(y=xe(y,m)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return g.createElement(z,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});vn.displayName=`NavLink`;var yn=g.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Ft,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=g.useContext(Xe),_=Tn(),v=En(s,{relative:l}),y=o.toLowerCase()===`get`?`get`:`post`,b=typeof s==`string`&&S.test(s);return g.createElement(`form`,{ref:m,method:y,action:v,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>_(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?g.startTransition(()=>p()):p()},...p,"data-discover":!b&&e===`render`?`true`:void 0})});yn.displayName=`Form`;function bn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xn(e){let t=g.useContext(Ue);return D(t,bn(e)),t}function Sn(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=ut(),d=st(),f=ft(e,{relative:o});return g.useCallback(p=>{if(Ht(p,t)){p.preventDefault();let t=n===void 0?M(d)===M(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?g.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}var Cn=0,wn=()=>`__${String(++Cn)}__`;function Tn(){let{router:e}=xn(`useSubmit`),{basename:t}=g.useContext(Xe),n=Et(),r=e.fetch,i=e.navigate;return g.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Kt(e,t);if(a.navigate===!1){let e=a.fetcherKey||wn();await r(e,n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync})}else await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function En(e,{relative:t}={}){let{basename:n}=g.useContext(Xe),r=g.useContext(Qe);D(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ft(e||`.`,{relative:t})},o=st();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:ke([n,a.pathname])),M(a)}function Dn(e,{relative:t}={}){let n=g.useContext(qe);D(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=xn(`useViewTransitionState`),i=ft(e,{relative:t});if(!n.isTransitioning)return!1;let a=xe(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=xe(n.nextLocation.pathname,r)||n.nextLocation.pathname;return _e(i.pathname,o)!=null||_e(i.pathname,a)!=null}var On=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),B=o(((e,t)=>{t.exports=On()}))();function kn({stats:e}){return e?(0,B.jsxs)(`div`,{className:`overview-dashboard`,children:[(0,B.jsxs)(`div`,{className:`dashboard-header`,children:[(0,B.jsx)(`h1`,{children:`FeltDB Studio`}),(0,B.jsx)(`div`,{className:`namespace-badge`,children:e.namespace})]}),(0,B.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Runtime`}),(0,B.jsx)(`div`,{className:`status-indicator ${e.status}`,children:`●`}),(0,B.jsx)(`span`,{children:e.status.charAt(0).toUpperCase()+e.status.slice(1)})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Storage`}),(0,B.jsxs)(`span`,{children:[e.persistence,` / `,e.storageBackend]})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Peers`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.peersCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Objects`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.objectsCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Operations`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.operationsCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Capabilities`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.capabilitiesCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Executions`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.executionsCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Workflows`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.workflowsCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Agents`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.agentsCount})]}),(0,B.jsxs)(`div`,{className:`stat-card`,children:[(0,B.jsx)(`label`,{children:`Conflicts`}),(0,B.jsx)(`span`,{className:`stat-number`,children:e.conflictsCount})]})]})]}):(0,B.jsx)(`div`,{className:`overview-dashboard loading`,children:(0,B.jsx)(`p`,{children:`Loading runtime information...`})})}var An=class extends Error{constructor(e,t,n){super(t),this.code=e,this.status=n}},jn=class{constructor(e){this.options=e,this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}async get(e,t={}){let n=new URL(e,`${this.options.baseUrl||window.location.origin}/`);n.searchParams.set(`application_id`,this.options.applicationId),n.searchParams.set(`environment`,this.options.environment);for(let[e,r]of Object.entries(t))r!==void 0&&r!==``&&n.searchParams.set(e,r);let r=await this.fetcher(n,{cache:`no-store`,headers:this.options.token?{authorization:`Bearer ${this.options.token}`}:{}}),i=await r.json().catch(()=>({}));if(!r.ok)throw new An(i.code||`request_failed`,i.message||`The Service API request failed.`,r.status);return i}application(){return this.get(`/v1/application`)}schema(){return this.get(`/v1/application/schema`)}records(e,t,n={},r=50){return this.get(`/v1/data/${encodeURIComponent(e)}`,{limit:String(r),cursor:t,...n})}record(e,t){return this.get(`/v1/data/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}};function Mn(e){return/secret|password|token|api[_-]?key|credential|private[_-]?key/i.test(e)}function Nn(e,t){return Mn(e.name)?t==null?t:`[REDACTED]`:t&&typeof t==`object`&&!Array.isArray(t)&&t.secret===!0?{configured:!!t.configured,secret:!0}:t}function Pn(e,t){return e instanceof An?e.code===`record_not_found`?`Record not found.`:e.code===`unauthorized`?`Sign in to inspect this application.`:e.code===`forbidden`||e.code===`inspection_not_allowed`?t?`You don't have access to ${t}.`:`You don't have access to this application.`:e.code===`invalid_cursor`?`Invalid cursor. Refreshing from the first page.`:e.message:t?`Unable to load ${t}.`:`Unable to load application data.`}function Fn({field:e,value:t}){let n=Nn(e,t);if(n==null)return(0,B.jsx)(`span`,{className:`data-null`,children:`—`});if(typeof n==`boolean`)return(0,B.jsx)(`span`,{className:`data-boolean ${n}`,children:n?`True`:`False`});if(/date|time/i.test(e.type)&&(typeof n==`string`||typeof n==`number`)){let e=new Date(n);if(!Number.isNaN(e.valueOf()))return(0,B.jsx)(`time`,{dateTime:e.toISOString(),children:e.toLocaleString()})}return typeof n==`object`?!Array.isArray(n)&&n.secret===!0?(0,B.jsxs)(`span`,{className:`secret-state`,children:[n.configured?`Configured`:`Not configured`,` · Secret`]}):(0,B.jsxs)(`details`,{children:[(0,B.jsx)(`summary`,{children:Array.isArray(n)?`${n.length} items`:`Object`}),(0,B.jsx)(`pre`,{children:JSON.stringify(n,null,2)})]}):(0,B.jsx)(B.Fragment,{children:String(n)})}function In({api:e,schema:t,detail:n,onNavigate:r,onClose:i}){let[a,o]=(0,g.useState)({}),[s,c]=(0,g.useState)(``),l=new Map(n.relationships.map(e=>[e.name,e])),u=async t=>{try{let r=await e.records(t.source_collection,void 0,{[t.foreign_field]:String(n.record.id)},20);o(e=>({...e,[t.name]:r.records}))}catch(e){c(Pn(e,t.source_collection))}};return(0,B.jsxs)(`section`,{className:`data-detail studio-card`,"aria-label":`${t.collection} record detail`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`record`}),(0,B.jsx)(`h2`,{children:t.collection})]}),(0,B.jsx)(`button`,{className:`data-close`,onClick:i,"aria-label":`Close record`,children:`×`})]}),(0,B.jsx)(`dl`,{children:[{name:`id`,type:`text`},...t.fields].map(e=>{let t=l.get(e.name);return(0,B.jsxs)(g.Fragment,{children:[(0,B.jsxs)(`dt`,{children:[e.name,(0,B.jsxs)(`small`,{children:[e.type,e.required?` · required`:``]})]}),(0,B.jsx)(`dd`,{children:t?.reference?(0,B.jsxs)(`button`,{className:`reference-value`,onClick:()=>r(t.reference.collection,t.reference.id),children:[`→ `,t.reference.collection,` / `,t.reference.id]}):(0,B.jsx)(Fn,{field:e,value:n.record[e.name]})})]},e.name)})}),t.relationships.filter(e=>e.cardinality===`many`).map(e=>(0,B.jsxs)(`section`,{className:`reverse-relationship`,children:[(0,B.jsx)(`h3`,{children:e.source_collection}),(0,B.jsxs)(`p`,{children:[`References this `,t.collection,` through `,(0,B.jsx)(`code`,{children:e.foreign_field}),`.`]}),!a[e.name]&&(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>void u(e),children:`Show related records (up to 20)`}),a[e.name]?.map(t=>(0,B.jsxs)(`button`,{className:`reference-value`,onClick:()=>r(e.source_collection,String(t.id)),children:[`→ `,e.source_collection,` / `,String(t.id)]},String(t.id)))]},e.name)),s&&(0,B.jsx)(`p`,{role:`alert`,className:`runtime-error`,children:s})]})}function Ln({serviceUrl:e=``,token:t=``,applicationId:n,environment:r,refreshIntervalMs:i=3e4}){let a=(0,g.useMemo)(()=>new jn({baseUrl:e,token:t,applicationId:n,environment:r}),[e,t,n,r]),[o,s]=(0,g.useState)(),[c,l]=(0,g.useState)(),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)([]),[m,h]=(0,g.useState)(),[_,v]=(0,g.useState)(),[y,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(``),[ee,D]=(0,g.useState)({}),[O,k]=(0,g.useState)(!0),[A,j]=(0,g.useState)(``),M=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([a.application(),a.schema()]);s(e),l(t),j(``),d(e=>t.collections.some(t=>t.collection===e)?e:t.collections[0]?.collection||``)}catch(e){j(Pn(e))}},[a]),N=(0,g.useCallback)(async(e,t=ee,n=!0)=>{if(u){k(!0),j(``),h(void 0);try{let n=await a.records(u,e,t);p(n.records),v(e),S(n.pagination.nextCursor)}catch(r){if(n&&e&&r instanceof An&&r.code===`invalid_cursor`){b([]),await N(void 0,t,!1),j(`The cursor expired. Refreshed from the first page.`);return}j(Pn(r,u)),p([])}finally{k(!1)}}},[ee,a,u]);(0,g.useEffect)(()=>{k(!0),M().finally(()=>k(!1));let e=window.setInterval(()=>void M(),i);return()=>window.clearInterval(e)},[M,i]),(0,g.useEffect)(()=>{b([]),v(void 0),S(null),D({}),w(``),E(``),u&&N(void 0,{})},[u,a]);let P=c?.collections.find(e=>e.collection===u),te=c?.collections.find(e=>e.collection===m?.collection),ne=async(e,t)=>{j(``);try{h(await a.record(e,t))}catch(t){h(void 0),j(Pn(t,e))}},re=()=>{let e=C&&T?{[C]:T}:{};D(e),b([]),N(void 0,e)};return(0,B.jsxs)(`div`,{className:`studio-model-page data-explorer`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Application state`}),(0,B.jsx)(`h1`,{children:`Data`}),(0,B.jsx)(`p`,{children:`Real persisted records, authorized and redacted by the FeltDB Service API.`})]}),(0,B.jsxs)(`section`,{className:`application-context`,"aria-label":`Active application context`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`small`,{children:`Application`}),(0,B.jsx)(`strong`,{children:o?.application_name||o?.application_id||n})]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`small`,{children:`Environment`}),(0,B.jsx)(`strong`,{children:o?.environment||r})]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`small`,{children:`Contract`}),(0,B.jsxs)(`strong`,{children:[`v`,o?.version??c?.contract_version??`…`]})]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`small`,{children:`Contract Hash`}),(0,B.jsx)(`code`,{children:o?.contract_hash?`${o.contract_hash.slice(0,12)}…`:`…`})]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`small`,{children:`Flow`}),(0,B.jsx)(`code`,{children:o?.flow_hash?`${o.flow_hash.slice(0,12)}…`:`Not recorded`})]})]}),(0,B.jsxs)(`div`,{className:`data-layout`,children:[(0,B.jsxs)(`aside`,{className:`studio-card`,children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`Collections`}),c?.collections.map(e=>(0,B.jsx)(`button`,{className:e.collection===u?`active`:``,onClick:()=>d(e.collection),children:e.collection},e.collection)),!c?.collections.length&&!O&&(0,B.jsx)(`p`,{children:`No application collections.`})]}),(0,B.jsxs)(`section`,{className:`data-browser`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`collection`}),(0,B.jsx)(`h2`,{children:u||`Data`})]}),P&&(0,B.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),re()},children:[(0,B.jsxs)(`select`,{"aria-label":`Filter field`,value:C,onChange:e=>w(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Filter field`}),P.fields.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,B.jsx)(`input`,{"aria-label":`Filter value`,value:T,onChange:e=>E(e.target.value),placeholder:`Equals…`}),(0,B.jsx)(`button`,{children:`Apply`})]})]}),A&&(0,B.jsxs)(`div`,{className:`data-error`,role:`alert`,children:[A,(0,B.jsx)(`button`,{onClick:()=>void N(void 0),children:`Refresh`})]}),O?(0,B.jsx)(`div`,{className:`model-empty`,children:`Loading…`}):f.length===0?(0,B.jsxs)(`div`,{className:`model-empty`,children:[`No records yet.`,(0,B.jsx)(`br`,{}),`Create a `,u||`record`,` through your application to see persisted application state here.`]}):P&&(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`id`}),P.fields.map(e=>(0,B.jsxs)(`th`,{children:[e.name,(0,B.jsxs)(`small`,{children:[e.type,e.reference?` → ${e.reference}`:``]})]},e.name))]})}),(0,B.jsx)(`tbody`,{children:f.map(e=>(0,B.jsxs)(`tr`,{onClick:()=>void ne(u,String(e.id)),children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(`button`,{className:`record-link`,children:String(e.id)})}),P.fields.map(t=>(0,B.jsx)(`td`,{children:t.reference&&e[t.name]!=null?(0,B.jsxs)(`span`,{className:`reference-value`,children:[`→ `,t.reference,` / `,String(e[t.name])]}):(0,B.jsx)(Fn,{field:t,value:e[t.name]})},t.name))]},String(e.id)))})]})}),(0,B.jsxs)(`footer`,{className:`data-pagination`,children:[(0,B.jsxs)(`span`,{children:[`Showing `,+!!f.length,`–`,f.length]}),(0,B.jsx)(`button`,{disabled:!y.length,onClick:()=>{let e=y.at(-1);b(e=>e.slice(0,-1)),N(e)},children:`← Previous`}),(0,B.jsx)(`button`,{disabled:!x,onClick:()=>{b(e=>[...e,_]),N(x||void 0)},children:`Next →`})]}),m&&te&&(0,B.jsx)(In,{api:a,schema:te,detail:m,onNavigate:(e,t)=>void ne(e,t),onClose:()=>h(void 0)})]})]})]})}function Rn(e){let t=e.trim().replace(/^flow:\/\//,``).split(`/`).filter(Boolean);return e.startsWith(`flow://`)?t.length>=3?{collection:t[t.length-2],id:t[t.length-1]}:null:t.length>=2?{collection:t[t.length-2],id:t[t.length-1]}:null}function zn({db:e,model:t,namespace:n=`default`}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(),[s,c]=(0,g.useState)(`Enter a reference to resolve live state.`),l=async()=>{let t=Rn(r);if(!t||!e){o(void 0),c(e?`Use Collection/id or flow://namespace/Collection/id.`:`Runtime unavailable.`);return}let n=await e.collection(t.collection).get(t.id);o(n),c(n?`Materialized locally`:`Reference is valid but is not materialized locally`)};return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`References`}),(0,B.jsx)(`p`,{children:`Resolve stable Flow references directly into their materialized state.`})]}),(0,B.jsxs)(`div`,{className:`reference-query`,children:[(0,B.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},placeholder:`flow://${n}/Collection/id`}),(0,B.jsx)(`button`,{onClick:()=>void l(),children:`Resolve`})]}),(0,B.jsxs)(`div`,{className:`reference-layout`,children:[(0,B.jsxs)(`article`,{className:`studio-card`,children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`Known collections`}),t?.collections.map(e=>(0,B.jsxs)(`button`,{className:`reference-example`,onClick:()=>i(`flow://${n}/${e.name}/id`),children:[e.name,(0,B.jsxs)(`small`,{children:[e.fields.length,` fields`]})]},e.name))]}),(0,B.jsxs)(`article`,{className:`studio-card reference-result`,children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`Resolution`}),(0,B.jsx)(`h2`,{children:s}),a!==void 0&&(0,B.jsx)(`pre`,{children:JSON.stringify(a,null,2)})]})]})]})}function Bn({db:e,namespace:t=`default`}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(`all`);(0,g.useEffect)(()=>{if(!e)return;let t=!0,n=async()=>{let n=await e.auditEvents();t&&r(n.slice().reverse())};n();let i=setInterval(()=>void n(),1e3);return()=>{t=!1,clearInterval(i)}},[e]);let o=n.filter(e=>i===`all`||e.type===i);return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Operations`}),(0,B.jsx)(`p`,{children:`The runtime's durable local mutation log—not a simulated activity feed.`})]}),(0,B.jsxs)(`div`,{className:`model-summary`,children:[(0,B.jsxs)(`span`,{children:[n.length,` recorded`]}),(0,B.jsxs)(`span`,{children:[t,` namespace`]}),(0,B.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All mutations`}),(0,B.jsx)(`option`,{value:`put`,children:`Writes`}),(0,B.jsx)(`option`,{value:`delete`,children:`Deletes`})]})]}),(0,B.jsx)(`div`,{className:`table-shell`,children:(0,B.jsxs)(`table`,{className:`operations-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Sequence`}),(0,B.jsx)(`th`,{children:`Mutation`}),(0,B.jsx)(`th`,{children:`Collection`}),(0,B.jsx)(`th`,{children:`Key`}),(0,B.jsx)(`th`,{children:`Timestamp`})]})}),(0,B.jsxs)(`tbody`,{children:[o.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.sequence}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`span`,{className:`event-pill ${e.type}`,children:e.type})}),(0,B.jsx)(`td`,{children:e.collection}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`code`,{children:e.key})}),(0,B.jsx)(`td`,{children:new Date(e.timestamp).toLocaleString()})]},`${e.sequence}-${e.key}`)),!o.length&&(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`empty-message`,children:`No matching mutations yet. Create or change application state to populate this stream.`})})]})]})})]})}function Vn({peers:e=[],localInstance:t=`local`}){return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Peers`}),(0,B.jsx)(`p`,{children:`The live topology participating in this application's convergence fabric.`})]}),(0,B.jsxs)(`div`,{className:`peer-topology`,children:[(0,B.jsxs)(`article`,{className:`peer-node local`,children:[(0,B.jsx)(`span`,{children:`this instance`}),(0,B.jsx)(`h2`,{children:t}),(0,B.jsx)(`small`,{children:`online · authoritative local state`})]}),e.map(e=>(0,B.jsxs)(g.Fragment,{children:[(0,B.jsx)(`i`,{className:`peer-link`}),(0,B.jsxs)(`article`,{className:`peer-node`,children:[(0,B.jsx)(`span`,{children:`connected peer`}),(0,B.jsx)(`h2`,{children:e}),(0,B.jsx)(`small`,{children:`online · exchanging operations`})]})]},e))]}),!e.length&&(0,B.jsx)(`div`,{className:`model-empty`,children:`This embedded runtime is operating independently. Its state remains durable and can converge when a network peer is attached.`})]})}function Hn({model:e}){let t=e?.capabilities??[];return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Design`}),(0,B.jsx)(`h1`,{children:`Capabilities`}),(0,B.jsxs)(`p`,{children:[`Declared authority available to workflows and autonomous agents in `,e?.app??`this application`,`.`]})]}),(0,B.jsxs)(`div`,{className:`model-summary`,children:[(0,B.jsxs)(`span`,{children:[t.length,` declared`]}),(0,B.jsxs)(`span`,{children:[new Set(t.flatMap(e=>e.statements)).size,` permission rules`]})]}),(0,B.jsxs)(`div`,{className:`studio-card-grid`,children:[t.map(e=>(0,B.jsxs)(`article`,{className:`studio-card capability-card`,children:[(0,B.jsx)(`div`,{className:`card-kind`,children:`capability`}),(0,B.jsx)(`h2`,{children:e.name}),(0,B.jsx)(`div`,{className:`statement-list`,children:e.statements.map(e=>{let[t,...n]=e.split(` `);return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:t}),(0,B.jsx)(`code`,{children:n.join(` `)})]},e)})})]},e.name)),!t.length&&(0,B.jsx)(`div`,{className:`model-empty`,children:`No capabilities are declared in the current project model.`})]})]})}function Un(e,t=`default`){let[n,r]=(0,g.useState)(null);return(0,g.useEffect)(()=>{if(!e){r(null);return}let n=e.runtime(),i=n.runtime===`browser`?`browser`:n.runtime===`node`?`self-hosted`:`remote`;r({db:e,connected:!0,namespace:t,instanceId:e.instanceId?.()||`unknown`,environment:i})},[e,t]),n}function Wn(e,t=null,n=`default`){let[r,i]=(0,g.useState)(null);return(0,g.useEffect)(()=>{if(!e){i(null);return}let r=async()=>{try{let r=e.runtime(),a=e.health(),o=e.sync?.(),s=t?await Promise.all(t.collections.map(t=>e.collection(t.name).count())):[];i({namespace:n,status:a?.status||`healthy`,storageBackend:r.storage,persistence:r.persistent?`durable`:`volatile`,peersCount:o?.connected_peers?.length||0,objectsCount:s.reduce((e,t)=>e+t,0),operationsCount:o?.sequence||0,capabilitiesCount:t?.capabilities.length||0,executionsCount:await e.collection(`_flow_executions`).count()||await e.collection(`Decision`).count(),workflowsCount:t?.workflows.length||0,agentsCount:t?.agents.length||0,conflictsCount:o?.conflicts_detected||0})}catch(e){console.error(`Failed to fetch dashboard stats:`,e)}};r();let a=setInterval(r,5e3);return()=>clearInterval(a)},[e,t,n]),r}function Gn(e){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=(0,g.useCallback)(async()=>{if(e){i(!0),o(null);try{let t=e.health();n(t)}catch(e){o(e instanceof Error?e.message:`Failed to fetch diagnostics`)}finally{i(!1)}}},[e]);return(0,g.useEffect)(()=>{s()},[e,s]),{diagnostics:t,loading:r,error:a,refresh:s}}function Kn(e,t){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(!0),[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{if(e){a(!0),s(null);try{let n=e.collection(t).subscribe(e=>{r(e),a(!1)});return()=>n()}catch(e){s(e instanceof Error?e.message:`Failed to load collection`),a(!1)}}},[e,t]),{items:n,loading:i,error:o}}function qn(e){let[t,n]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!e){n([]);return}let t=()=>{try{let t=e.sync?.();n(t?.connected_peers||[])}catch(e){console.error(`Failed to fetch peers:`,e)}};t();let r=setInterval(t,2e3);return()=>clearInterval(r)},[e]),t}function Jn({db:e,name:t,label:n}){let{items:r}=Kn(e,t);return r.length?(0,B.jsxs)(`section`,{children:[(0,B.jsxs)(`h2`,{children:[n,(0,B.jsx)(`span`,{children:r.length})]}),(0,B.jsx)(`div`,{className:`execution-list`,children:r.map((e,r)=>(0,B.jsxs)(`article`,{className:`execution-row`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:String(e.name??e.workflow??e.incident_id??e.id??n)}),(0,B.jsx)(`small`,{children:t})]}),(0,B.jsx)(`span`,{className:`event-pill put`,children:String(e.status??e.state??`materialized`)}),(0,B.jsx)(`pre`,{children:JSON.stringify(e,null,2)})]},String(e.id??r)))})]}):null}function Yn({db:e,model:t}){return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Executions`}),(0,B.jsx)(`p`,{children:`Capability work, workflow runs, assignments, and agent decisions as inspectable state.`})]}),(0,B.jsxs)(`div`,{className:`model-summary`,children:[(0,B.jsxs)(`span`,{children:[t?.workflows.length??0,` workflow definitions`]}),(0,B.jsxs)(`span`,{children:[t?.agents.length??0,` autonomous agents`]})]}),(0,B.jsx)(Jn,{db:e??null,name:`_flow_executions`,label:`Capability executions`}),(0,B.jsx)(Jn,{db:e??null,name:`_flow_workflow_runs`,label:`Workflow runs`}),(0,B.jsx)(Jn,{db:e??null,name:`Assignment`,label:`Materialized assignments`}),(0,B.jsx)(Jn,{db:e??null,name:`Decision`,label:`Agent decisions`}),(0,B.jsx)(Jn,{db:e??null,name:`_flow_agent_executions`,label:`Agent executions`}),(0,B.jsxs)(`div`,{className:`model-empty execution-empty`,children:[`Execution sections appear as soon as their state is committed. Defined workflows: `,t?.workflows.map(e=>e.name).join(`, `)||`none`,`.`]})]})}function Xn({db:e,diagnostics:t}){let n=(()=>{try{return e?.sync()}catch{return}})(),r=n?.conflicts_detected??0;return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Conflicts`}),(0,B.jsx)(`p`,{children:`Concurrent mutations detected while replicas converge.`})]}),(0,B.jsxs)(`div`,{className:`metric-grid`,children:[(0,B.jsxs)(`article`,{children:[(0,B.jsx)(`b`,{children:r}),(0,B.jsx)(`span`,{children:`detected`})]}),(0,B.jsxs)(`article`,{children:[(0,B.jsx)(`b`,{children:n?.pending_operations??0}),(0,B.jsx)(`span`,{children:`pending operations`})]}),(0,B.jsxs)(`article`,{children:[(0,B.jsx)(`b`,{children:n?.connected_peers.length??0}),(0,B.jsx)(`span`,{children:`connected peers`})]})]}),(0,B.jsxs)(`article`,{className:`studio-card`,children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`Convergence`}),(0,B.jsx)(`h2`,{children:r?`Conflict activity detected`:`No conflicts detected`}),(0,B.jsx)(`p`,{children:t?.sync.connected?`The fabric is connected and applying causal ordering.`:`The local replica is independent; conflict detection begins when operations converge with peers.`}),(0,B.jsx)(`code`,{children:`Causal ordering → deterministic materialization → auditable resolution`})]})]})}function Zn({model:e}){let t=e?.workflows??[],[n,r]=(0,g.useState)(),i=t.find(e=>e.name===n)??t[0];return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Design`}),(0,B.jsx)(`h1`,{children:`Workflows`}),(0,B.jsx)(`p`,{children:`Durable state transitions declared by the application model.`})]}),(0,B.jsxs)(`div`,{className:`split-browser`,children:[(0,B.jsx)(`aside`,{children:t.map(e=>(0,B.jsxs)(`button`,{className:e.name===i?.name?`active`:``,onClick:()=>r(e.name),children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsxs)(`span`,{children:[e.steps.length,` steps`]})]},e.name))}),(0,B.jsx)(`section`,{children:i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`card-kind`,children:`workflow`}),(0,B.jsx)(`h2`,{children:i.name}),i.parameters.length>0&&(0,B.jsxs)(`code`,{className:`signature`,children:[`(`,i.parameters,`)`]}),(0,B.jsx)(`div`,{className:`workflow-track`,children:i.steps.map((e,t)=>(0,B.jsxs)(g.Fragment,{children:[(0,B.jsxs)(`article`,{children:[(0,B.jsx)(`span`,{children:t+1}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:e.name}),e.statements.map(e=>(0,B.jsx)(`code`,{children:e},e))]})]}),t<i.steps.length-1&&(0,B.jsx)(`i`,{children:`→`})]},e.name))})]}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No workflows are declared.`})})]})]})}function Qn({model:e}){let t=e?.agents??[],[n,r]=(0,g.useState)(),i=t.find(e=>e.name===n)??t[0];return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Design`}),(0,B.jsx)(`h1`,{children:`Agents`}),(0,B.jsx)(`p`,{children:`Autonomous participants whose authority and workflows are part of the model.`})]}),(0,B.jsxs)(`div`,{className:`split-browser`,children:[(0,B.jsx)(`aside`,{children:t.map(e=>(0,B.jsxs)(`button`,{className:e.name===i?.name?`active`:``,onClick:()=>r(e.name),children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsxs)(`span`,{children:[e.statements.length,` bindings`]})]},e.name))}),(0,B.jsx)(`section`,{children:i?(0,B.jsx)(B.Fragment,{children:(0,B.jsxs)(`div`,{className:`agent-orbit`,children:[(0,B.jsxs)(`div`,{className:`agent-core`,children:[(0,B.jsx)(`span`,{children:`agent`}),(0,B.jsx)(`strong`,{children:i.name})]}),i.statements.map(e=>(0,B.jsxs)(`div`,{className:`agent-binding`,children:[(0,B.jsx)(`span`,{children:e.split(` `)[0]}),(0,B.jsx)(`strong`,{children:e.split(` `).slice(1).join(` `)})]},e))]})}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No agents are declared.`})})]})]})}function $n({db:e,namespace:t=`default`,reference:n}){let[r,i]=(0,g.useState)(n??``),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(`Enter a Flow reference to trace it.`);(0,g.useEffect)(()=>{n&&i(n)},[n]);let d=async()=>{if(!(!e||!r))try{let t=e.provenance(r);o(t),u(`Causal graph resolved`)}catch{o(null);let t=await e.auditEvents(),n=r.split(`/`),i=n[n.length-1]??``,a=t.filter(e=>e.key.includes(i));c(a),u(a.length?`Local mutation lineage`:`No local lineage found for this reference`)}};return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Provenance`}),(0,B.jsx)(`p`,{children:`Follow why state exists—from durable mutations to causal workflow and agent edges.`})]}),(0,B.jsxs)(`div`,{className:`reference-query`,children:[(0,B.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`flow://${t}/Collection/id`}),(0,B.jsx)(`button`,{onClick:()=>void d(),children:`Trace`})]}),(0,B.jsxs)(`article`,{className:`studio-card provenance-result`,children:[(0,B.jsx)(`span`,{className:`card-kind`,children:`Lineage`}),(0,B.jsx)(`h2`,{children:l}),a&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`model-summary`,children:[(0,B.jsxs)(`span`,{children:[a.nodes.length,` nodes`]}),(0,B.jsxs)(`span`,{children:[a.edges.length,` edges`]})]}),(0,B.jsx)(`div`,{className:`provenance-nodes`,children:a.nodes.map(e=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:e.label}),(0,B.jsx)(`small`,{children:e.type})]},e.id))})]}),!a&&s.map(e=>(0,B.jsxs)(`div`,{className:`provenance-event`,children:[(0,B.jsx)(`span`,{children:e.sequence}),(0,B.jsxs)(`b`,{children:[e.type,` `,e.collection]}),(0,B.jsx)(`code`,{children:e.key}),(0,B.jsx)(`small`,{children:new Date(e.timestamp).toLocaleString()})]},`${e.sequence}-${e.key}`))]})]})}function er({diagnostics:e,model:t}){let n=e?[[`Runtime`,e.runtime.status,e.runtime.reactive?`reactive`:`non-reactive`],[`Storage`,e.storage.status,`${e.storage.backend} · ${e.storage.persistent?`persistent`:`volatile`}`],[`Synchronization`,e.sync.status,`${e.sync.peers} peers · ${e.sync.pendingOperations} pending`],[`Fabric`,e.fabric.status,`${e.fabric.references} references`],[`Capabilities`,e.capabilities.status,`${e.capabilities.available}/${e.capabilities.count} available`],[`Execution`,e.execution.status,`${e.execution.running} running · ${e.execution.failed} failed`],[`Workflows`,e.workflow.status,`${e.workflow.active}/${e.workflow.total} active`]]:[];return(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Observe`}),(0,B.jsx)(`h1`,{children:`Health`}),(0,B.jsx)(`p`,{children:`Runtime diagnostics, not optimistic defaults.`})]}),(0,B.jsx)(`div`,{className:`health-grid`,children:n.map(([e,t,n])=>(0,B.jsxs)(`article`,{className:`health-item status-${t}`,children:[(0,B.jsx)(`span`,{className:`status-icon`,children:t===`healthy`?`✓`:`!`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:e}),(0,B.jsx)(`small`,{children:n})]})]},e))}),!e&&(0,B.jsx)(`div`,{className:`model-empty`,children:`Diagnostics are unavailable until Studio connects to a runtime.`}),e?.issues.map((e,t)=>(0,B.jsxs)(`div`,{className:`health-issue ${e.severity}`,children:[(0,B.jsx)(`b`,{children:e.component}),` `,e.message]},t)),(0,B.jsxs)(`div`,{className:`model-summary`,children:[(0,B.jsxs)(`span`,{children:[t?.collections.length??0,` collections modeled`]}),(0,B.jsxs)(`span`,{children:[t?.workflows.length??0,` workflows modeled`]}),(0,B.jsxs)(`span`,{children:[t?.agents.length??0,` agents modeled`]})]})]})}function tr({db:e,remoteUrl:t=``,token:n=``,onConnect:r}){let[i,a]=(0,g.useState)(t),[o,s]=(0,g.useState)(n),c=e?.runtime();return(0,g.useEffect)(()=>{a(t),s(n)},[t,n]),(0,B.jsxs)(`div`,{className:`settings-panel`,children:[(0,B.jsx)(`h2`,{children:`Settings`}),(0,B.jsxs)(`div`,{className:`settings-content`,children:[(0,B.jsx)(`h3`,{children:`Connection`}),(0,B.jsxs)(`div`,{className:`connection-info`,children:[(0,B.jsxs)(`div`,{className:`info-row`,children:[(0,B.jsx)(`label`,{children:`Runtime Environment`}),(0,B.jsx)(`span`,{children:c?.runtime||`unavailable`})]}),(0,B.jsxs)(`div`,{className:`info-row`,children:[(0,B.jsx)(`label`,{children:`Storage Backend`}),(0,B.jsx)(`span`,{children:c?.storage||`unavailable`})]}),(0,B.jsxs)(`div`,{className:`info-row`,children:[(0,B.jsx)(`label`,{children:`Instance ID`}),(0,B.jsx)(`span`,{className:`monospace`,children:e?.instanceId?.()||`unavailable`})]})]}),(0,B.jsxs)(`form`,{className:`connection-form`,onSubmit:e=>{e.preventDefault(),r?.(i,o)},children:[(0,B.jsxs)(`label`,{children:[`Server or managed endpoint`,(0,B.jsx)(`input`,{type:`url`,value:i,onChange:e=>a(e.target.value),placeholder:`https://your-runtime.example.com`})]}),(0,B.jsxs)(`label`,{children:[`API token`,(0,B.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),placeholder:`fdb_live_…`,autoComplete:`off`})]}),(0,B.jsx)(`p`,{children:`Tokens are kept in this browser session and are never written to the project.`}),(0,B.jsx)(`button`,{className:`btn btn-primary`,type:`submit`,children:`Connect Studio`})]})]})]})}function nr({db:e,model:t,onSearch:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([]),s=e=>{i(e),n&&n(e)};return(0,g.useEffect)(()=>{let n=!0;return(async()=>{let i=r.trim().toLowerCase();if(!i){o([]);return}let a=[...t?.collections.map(e=>({kind:`collection`,name:e.name,detail:`${e.fields.length} fields`}))??[],...t?.capabilities.map(e=>({kind:`capability`,name:e.name,detail:e.statements.join(` · `)}))??[],...t?.workflows.map(e=>({kind:`workflow`,name:e.name,detail:`${e.steps.length} steps`}))??[],...t?.agents.map(e=>({kind:`agent`,name:e.name,detail:e.statements.join(` · `)}))??[]].filter(e=>JSON.stringify(e).toLowerCase().includes(i)),s=e&&t?(await Promise.all(t.collections.map(async t=>(await e.collection(t.name).all()).filter(e=>JSON.stringify(e).toLowerCase().includes(i)).slice(0,3).map(e=>({kind:`object`,name:`${t.name}/${String(e.id??`record`)}`,detail:JSON.stringify(e)}))))).flat():[];n&&o([...a,...s].slice(0,12))})(),()=>{n=!1}},[e,t,r]),(0,B.jsxs)(`div`,{className:`global-search`,children:[(0,B.jsx)(`input`,{type:`text`,placeholder:`Search: documents/123, flow://, agent/name, etc.`,value:r,onChange:e=>s(e.target.value),className:`search-input global`}),r&&(0,B.jsx)(`div`,{className:`search-results`,children:(0,B.jsxs)(`div`,{className:`results-group`,children:[(0,B.jsx)(`h4`,{children:`Model & runtime`}),a.map((e,t)=>(0,B.jsxs)(`div`,{className:`search-result`,children:[(0,B.jsx)(`b`,{children:e.name}),(0,B.jsx)(`span`,{children:e.kind}),(0,B.jsx)(`small`,{children:e.detail})]},`${e.kind}-${e.name}-${t}`)),!a.length&&(0,B.jsx)(`div`,{className:`empty-message`,children:`No matches`})]})})]})}var rr=Object.freeze({domain:`undeclared`,validation:`refresh`,invalidation:!1,reason:`the runtime does not declare a freshness capability`}),ir=class extends Error{constructor(e){super(e),this.name=`FreshnessContractViolation`}};function ar(e,t){let n=typeof t.revision==`function`;if(e.validation===`revision`){if(!n)throw new ir(`a runtime advertising revision validation must implement revision()`);if(!e.revisionScope)throw new ir(`a runtime advertising revision validation must name the scope its revisions are comparable within`);if(e.domain===`replicated`||e.domain===`multi-process-file`)throw new ir(`the ${e.domain} domain has no serialization boundary that can make a scalar revision authoritative`);return e}if(!e.reason)throw new ir(`a runtime that cannot validate by revision must say why`);return e}async function or(e){return typeof e.freshness==`function`?ar(await e.freshness(),e):ar(rr,e)}async function sr(e){let t=await or(e);if(t.validation!==`revision`)throw new ir(`this runtime does not offer revision validation: ${t.reason}`);let n=await e.revision();if(n.scope!==t.revisionScope)throw new ir(`revision scope ${n.scope} does not match the advertised scope ${t.revisionScope}`);return n}function cr(e,t){return e.scope===t.scope&&e.value===t.value}var lr=class{dependencies=new Map;subscribers=new Map;recentChanges=new Map;registerDependency(e,t){this.dependencies.has(e)||this.dependencies.set(e,new Set),this.dependencies.get(e).add(t)}subscribe(e,t){this.subscribers.has(e)||this.subscribers.set(e,new Set);let n=this.subscribers.get(e);return n.add(t),()=>{n.delete(t),n.size===0&&this.subscribers.delete(e)}}async emitChange(e,t){this.recentChanges.has(e)||this.recentChanges.set(e,[]),this.recentChanges.get(e).push(t);let n=this.subscribers.get(e);n&&await Promise.all([...n].map(e=>e(t)));let r=this.dependencies.get(e);if(r)for(let e of r)await this.emitChange(e,t)}getRecentChanges(e){return this.recentChanges.get(e)||[]}clearRecentChanges(e){this.recentChanges.delete(e)}getSubscriberCount(e){return this.subscribers.get(e)?.size??0}hasDependents(e){let t=this.dependencies.get(e);return t!==void 0&&t.size>0}getDependents(e){let t=this.dependencies.get(e);return t?Array.from(t):[]}},ur=null;function dr(){return ur||=new lr,ur}var fr=class{entries=new Map;field;stats={reads:0,writes:0,selectivity:0};constructor(e){this.field=e}add(e,t){let n=this.normalizeKey(t);this.entries.has(n)||this.entries.set(n,new Set),this.entries.get(n).add(e),this.stats.writes++}remove(e,t){let n=this.normalizeKey(t),r=this.entries.get(n);r&&(r.delete(e),r.size===0&&this.entries.delete(n)),this.stats.writes++}query(e){let t=this.normalizeKey(e);this.stats.reads++;let n=this.entries.get(t);return n?Array.from(n):[]}size(){return this.entries.size}getStats(){return{entries:this.entries.size,reads:this.stats.reads,writes:this.stats.writes,selectivity:this.entries.size>0?1/this.entries.size:0}}normalizeKey(e){return e==null?`__null__`:typeof e==`object`?JSON.stringify(e):String(e)}},pr=class{entries=[];field;stats={reads:0,writes:0,selectivity:0};constructor(e){this.field=e}add(e,t){let n=this.entries.find(e=>this.compareKeys(e.key,t)===0);n||(n={key:t,recordIds:new Set},this.entries.push(n),this.entries.sort((e,t)=>this.compareKeys(e.key,t.key))),n.recordIds.add(e),this.stats.writes++}remove(e,t){let n=this.entries.find(e=>this.compareKeys(e.key,t)===0);n&&(n.recordIds.delete(e),n.recordIds.size===0&&(this.entries=this.entries.filter(e=>e!==n))),this.stats.writes++}queryEqual(e){this.stats.reads++;let t=this.entries.find(t=>this.compareKeys(t.key,e)===0);return t?Array.from(t.recordIds):[]}queryRange(e,t,n=!0,r=!0){this.stats.reads++;let i=new Set;for(let a of this.entries){let o=this.compareKeys(a.key,e),s=this.compareKeys(a.key,t);(n?o>=0:o>0)&&(r?s<=0:s<0)&&a.recordIds.forEach(e=>i.add(e))}return Array.from(i)}size(){return this.entries.length}getStats(){return this.entries.reduce((e,t)=>e+t.recordIds.size,0),{entries:this.entries.length,reads:this.stats.reads,writes:this.stats.writes,selectivity:this.entries.length>0?1/this.entries.length:0}}compareKeys(e,t){return e==null?-1:t==null?1:e<t?-1:+(e>t)}},mr=class{tokenIndex=new Map;fields;stats={reads:0,writes:0,selectivity:0};constructor(e){this.fields=e}add(e,t){let n=this.extractText(t),r=this.tokenize(n);for(let t of r)this.tokenIndex.has(t)||this.tokenIndex.set(t,new Set),this.tokenIndex.get(t).add(e);this.stats.writes++}remove(e,t){let n=this.extractText(t),r=this.tokenize(n);for(let t of r){let n=this.tokenIndex.get(t);n&&(n.delete(e),n.size===0&&this.tokenIndex.delete(t))}this.stats.writes++}query(e){this.stats.reads++;let t=this.tokenize(e);if(t.length===0)return[];let n=this.tokenIndex.get(t[0]);if(!n)return[];n=new Set(n);for(let e=1;e<t.length;e++){let r=this.tokenIndex.get(t[e]);if(!r)return[];n=new Set([...n].filter(e=>r.has(e)))}return Array.from(n)}size(){return this.tokenIndex.size}getStats(){return{entries:this.tokenIndex.size,reads:this.stats.reads,writes:this.stats.writes,selectivity:this.tokenIndex.size>0?1/this.tokenIndex.size:0}}extractText(e){return this.fields.map(t=>{let n=e[t];return n?String(n):``}).join(` `)}tokenize(e){return e.toLowerCase().split(/\s+/).filter(e=>e.length>0)}},hr=class{indexes=new Map;config=new Map;indexStats=new Map;buildIndex(e){if(e.type===`hash`&&e.field)return new fr(e.field);if(e.type===`sorted`&&e.field)return new pr(e.field);if(e.type===`text`&&e.textFields)return new mr(e.textFields);throw Error(`Invalid index config: ${JSON.stringify(e)}`)}resetEntries(){for(let[e,t]of this.config){this.indexes.set(e,this.buildIndex(t));let n=this.indexStats.get(e);n&&(n.entries=0,n.size=0,n.lastUpdated=Date.now())}}createIndex(e){if(this.indexes.has(e.name))throw Error(`Index ${e.name} already exists`);let t=this.buildIndex(e);this.indexes.set(e.name,t),this.config.set(e.name,e),this.indexStats.set(e.name,{name:e.name,type:e.type,entries:0,size:0,lastUpdated:Date.now(),reads:0,writes:0,selectivity:0})}updateRecord(e,t,n){for(let[r,i]of this.indexes){let a=this.config.get(r);t&&(a.type===`hash`&&a.field||a.type===`sorted`&&a.field?i.remove(e,t[a.field]):a.type===`text`&&i.remove(e,t)),a.type===`hash`&&a.field||a.type===`sorted`&&a.field?i.add(e,n[a.field]):a.type===`text`&&i.add(e,n);let o=this.indexStats.get(r);o.lastUpdated=Date.now();let s=i.getStats();Object.assign(o,s)}}queryIndex(e,t){let n=this.indexes.get(e);if(!n)throw Error(`Index ${e} not found`);let r=this.config.get(e);if(r.type===`hash`)return n.query(t.value);if(r.type===`sorted`){let e=n;if(t.operator===`eq`)return e.queryEqual(t.value);if(t.operator===`range`)return e.queryRange(t.min,t.max);if(t.operator===`gte`)return e.queryRange(t.value,Number.MAX_VALUE);if(t.operator===`lte`)return e.queryRange(Number.MIN_VALUE,t.value)}else if(r.type===`text`)return n.query(t.value);return[]}listIndexes(){return Array.from(this.config.values())}getStats(e){return this.indexStats.get(e)||null}planQuery(e){let t=[];for(let n of e)for(let[e,r]of this.config)if(r.field===n||r.fields?.includes(n)){let n=this.indexStats.get(e);t.push({indexName:e,indexType:r.type,estimatedRows:Math.ceil(100/(n.selectivity||1)),cost:n.reads+n.writes,canPruneAll:r.type===`hash`,requiresPostFilter:r.type===`text`||r.type===`sorted`})}if(t.length===0)return{strategy:`full-scan`,indexes:[],estimatedRows:1e3,totalCost:1e3,explanation:`No suitable index found, using full collection scan`};t.sort((e,t)=>e.cost-t.cost);let n=t[0];return{strategy:`index-scan`,indexes:[n],estimatedRows:n.estimatedRows,totalCost:n.cost,explanation:`Using ${n.indexType} index on ${n.indexName}`}}},gr=null;async function _r(){if(gr!==null)return gr;try{let e=await x(()=>import(`./feltdb_wasm-CSB6KVgw.js`),[]);return gr=e,e}catch{return null}}var vr=class{tsBackend=null;wasmBackend=null;useWasm=!1;constructor(){this.tsBackend=new hr}async initializeWasm(){if(this.wasmBackend!==null)return;let e=await _r();if(e&&e.WasmIndexManager)try{this.wasmBackend=new e.WasmIndexManager,this.useWasm=!0}catch{this.useWasm=!1}}createIndex(e){if(this.useWasm&&this.wasmBackend)try{this.wasmBackend.create_index(JSON.stringify(e));return}catch{}this.tsBackend?.createIndex(e)}updateRecord(e,t,n){if(this.useWasm&&this.wasmBackend)try{let r=t?JSON.stringify(t):null,i=JSON.stringify(n);this.wasmBackend.update_record(e,r,i);return}catch{}this.tsBackend?.updateRecord(e,t,n)}resetEntries(){return this.useWasm&&this.wasmBackend?!1:(this.tsBackend?.resetEntries(),this.tsBackend!==null)}queryIndex(e,t){if(this.useWasm&&this.wasmBackend)try{let n=this.wasmBackend.query_index(e,t.operator,String(t.value||``));return JSON.parse(n)}catch{}return this.tsBackend?.queryIndex(e,t)||[]}queryCompoundIndex(e,t){if(this.useWasm&&this.wasmBackend)try{let n=Object.values(t).map(e=>String(e)).join(`\0`),r=this.wasmBackend.query_index(e,`eq`,n);return JSON.parse(r)}catch{}return[]}listIndexes(){if(this.useWasm&&this.wasmBackend)try{let e=this.wasmBackend.list_indexes();return JSON.parse(e)}catch{}return this.tsBackend?.listIndexes()||[]}},yr=class{db;collectionName;constructor(e,t){this.db=e,this.collectionName=t}async saveIndexConfig(e,t){let n=`__indexes__:${this.collectionName}:${e.name}`,r={config:e,version:1,createdAt:Date.now(),lastUpdated:Date.now(),entryCount:t},i=await this.db.insert(n,JSON.stringify(r));i.success||console.warn(`Failed to save index config for ${e.name}: ${i.error}`)}async loadIndexConfigs(){let e=await this.db.query(`__indexes__:${this.collectionName}`);if(!e.success||!e.data)return[];try{return JSON.parse(e.data).map(e=>e.config)}catch{return console.warn(`Failed to parse index configs for ${this.collectionName}`),[]}}async getIndexConfig(e){let t=`__indexes__:${this.collectionName}:${e}`,n=await this.db.get(t);if(!n.success||!n.data)return null;try{return JSON.parse(n.data).config}catch{return null}}async deleteIndexConfig(e){let t=`__indexes__:${this.collectionName}:${e}`;if(!this.db.delete){console.warn(`Failed to delete index config for ${e}: delete is not supported`);return}let n=this.db.delete(t),r=n instanceof Promise?await n:n;r?.success||console.warn(`Failed to delete index config for ${e}: ${r?.error}`)}async updateIndexStats(e,t){let n=`__indexes__:${this.collectionName}:${e}`,r=await this.db.get(n);if(!(!r.success||!r.data))try{let e=JSON.parse(r.data);e.lastUpdated=Date.now(),e.entryCount=t,await this.db.insert(n,JSON.stringify(e))}catch{console.warn(`Failed to update index stats for ${e}`)}}async getSnapshot(){let e=await this.loadIndexConfigs();return{collectionName:this.collectionName,indexes:e.map(e=>({config:e,version:1,createdAt:Date.now(),lastUpdated:Date.now(),entryCount:0})),timestamp:Date.now()}}},br=class e{db;name;collectionId;predicate=null;cache=[];subscribers=new Set;parent=null;parentId=null;isInitialized=!1;unsubscribeFunctions=new Set;graphUnsubscribe=null;runtimeUnsubscribe=null;indexBackend=new vr;indexStore;indexesLoaded=!1;cacheGeneration=0;indexedGeneration=-1;lastPlan=null;recordsById=null;lastRawSnapshot=null;cachedRevision=null;lastFreshness=null;constructor(e,t,n,r,i=!0){this.db=e,this.name=t,this.collectionId=`${t}-${Math.random().toString(36).substr(2,9)}`,this.predicate=n||null,this.parent=r||null,this.parentId=r?r.collectionId:null,this.indexStore=new yr(e,t),r&&dr().registerDependency(r.collectionId,this.collectionId),i?this.loadPersistedIndexes():this.indexesLoaded=!0}async loadPersistedIndexes(){try{let e=await this.indexStore.loadIndexConfigs();for(let t of e)this.indexBackend.createIndex(t);this.indexesLoaded=!0}catch(e){console.warn(`Failed to load persisted indexes for ${this.name}:`,e),this.indexesLoaded=!0}}async all(){return await this.refresh(),[...this.cache]}async find(e={}){let t=await this.all(),n=Object.entries(e);if(n.length===0)return this.lastPlan={strategy:`scan`,reason:`no query fields`,candidatesExamined:t.length,recordsReturned:t.length},t;let r=e=>n.every(([t,n])=>e[t]===n),i=this.indexFor(n);if(i){let e=this.indexCandidates(i.indexName,i.field,i.value);if(e){let t=e.filter(r);return this.lastPlan={strategy:`index`,indexName:i.indexName,field:i.field,candidatesExamined:e.length,recordsReturned:t.length},t}}let a=t.filter(r);return this.lastPlan={strategy:`scan`,reason:i?`index could not be trusted for this snapshot`:`no index covers the queried fields`,candidatesExamined:t.length,recordsReturned:a.length},a}lastQueryPlan(){return this.lastPlan}indexFor(e){for(let t of this.indexBackend.listIndexes()){if(t.type!==`hash`||!t.field)continue;let n=e.find(([e])=>e===t.field);if(n)return{indexName:t.name,field:t.field,value:n[1]}}return null}indexCandidates(e,t,n){if(!this.ensureIndexReflectsCache())return null;let r;try{r=this.indexBackend.queryIndex(e,{field:t,operator:`eq`,value:n})}catch{return null}let i=[];for(let e of r){let t=this.recordsById?.get(e);if(t===void 0)return null;i.push(t)}return i}ensureIndexReflectsCache(){if(this.indexedGeneration===this.cacheGeneration)return this.recordsById!==null;if(!this.indexBackend.resetEntries())return this.recordsById=null,!1;let e=new Map;for(let t of this.cache){let n=t?.id;if(n==null)return this.recordsById=null,this.indexedGeneration=this.cacheGeneration,!1;let r=String(n);e.set(r,t),this.indexBackend.updateRecord(r,null,t)}return this.recordsById=e,this.indexedGeneration=this.cacheGeneration,!0}createIndex(e){this.indexBackend.createIndex(e);for(let e of this.cache){let t=e?.id||JSON.stringify(e);this.indexBackend.updateRecord(t,null,e)}this.indexStore.saveIndexConfig(e,this.cache.length)}listIndexes(){return this.indexBackend.listIndexes()}async rebuildIndexes(){let e=this.indexBackend.listIndexes(),t=await this.all();for(let n of t){let t=n?.id||JSON.stringify(n);for(let r of e)this.indexBackend.updateRecord(t,null,n)}}async validateIndexes(){return this.indexBackend.listIndexes().length===0||(await this.all()).length,!0}async get(e){let t=`${this.name}:${e}`,n=await this.db.get(t);if(!n.success)throw Error(n.error||`Failed to read record ${e}`);return n.data?JSON.parse(n.data):null}where(t){return new e(this.db,this.name,e=>(!this.predicate||this.predicate(e))&&t(e),this.parent||this)}async insert(e,t){let n=t??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,r=`${this.name}:${n}`,i=typeof e==`object`&&e?{...e,id:n,__version:1}:e,a=await this.db.insert(r,JSON.stringify(i));if(!a.success)throw Error(`Insert failed: ${a.error}`);this.indexBackend.updateRecord(String(n),null,i);let o={type:`insert`,key:r,value:i,timestamp:Date.now()};return await dr().emitChange(this.name,o),String(n)}async update(e,t){let n=await this.get(e);if(!n)throw Error(`Record ${e} not found`);let r=(n.__version||1)+1,i={...n,...t,__version:r},a=`${this.name}:${e}`,o=await(this.db.update?this.db.update(a,JSON.stringify(i)):this.db.insert(a,JSON.stringify(i)));if(!o.success)throw Error(`Update failed: ${o.error}`);this.indexBackend.updateRecord(String(e),n,i);let s={type:`update`,key:a,value:i,timestamp:Date.now()};await dr().emitChange(this.name,s)}async updateIfVersion(e,t,n,r,i,a,o){let s=o??await this.get(e);if(!s)throw Error(`Record ${e} not found`);let c={...n};delete c.__version;let l={...s,...c},u=`${this.name}:${e}`;if(!this.db.cas)throw Error(`updateIfVersion is not supported by this FeltDB runtime. Only FileJsDb (Node.js) and HTTP/Server backends support atomic version-checked updates.`);let d=await this.db.cas({key:u,expectedVersion:t,expectedEpoch:r,expectedLeaseId:i,rejectIfDiverged:a,value:JSON.stringify(l)});if(!d.updated)return{updated:!1,currentVersion:d.currentVersion,conflictCode:d.conflictCode};let f=d.item||l;f.__version=d.currentVersion,this.indexBackend.updateRecord(String(e),s,f);let p={type:`update`,key:u,value:f,timestamp:Date.now()};return await dr().emitChange(this.name,p),{updated:!0,item:f}}async delete(e){let t=`${this.name}:${e}`;if(!this.db.delete)throw Error(`Delete is not supported by this FeltDB runtime`);let n=await this.db.delete(t);if(!n.success)throw Error(`Delete failed: ${n.error}`);let r=await this.get(e);r&&this.indexBackend.updateRecord(String(e),r,{});let i={type:`delete`,key:t,value:null,timestamp:Date.now()};await dr().emitChange(this.name,i)}async count(){return(await this.all()).length}async exists(e){return await this.get(e)!==null}async putIfAbsent(e,t){let n=`${this.name}:${e}`,r=typeof t==`object`&&t?{...t,id:e}:t,i=JSON.stringify(r);if(!this.db.putIfAbsent)throw Error(`putIfAbsent is not supported by this FeltDB runtime. Only FileJsDb (Node.js) supports durable atomic conditional creation.`);let a=await this.db.putIfAbsent(n,i);if(a.inserted){let e={type:`insert`,key:n,value:r,timestamp:Date.now()};await dr().emitChange(this.name,e)}return{inserted:a.inserted,value:JSON.parse(a.value)}}subscribe(e,t){if(this.subscribers.add(e),this.isInitialized||this.refresh().catch(e=>console.error(`Failed to initialize collection:`,e)),!this.graphUnsubscribe){let e=null,t=()=>e||(e=(async()=>{await this.refresh();for(let e of this.subscribers)e([...this.cache])})().finally(()=>{e=null}),e),n=dr();this.graphUnsubscribe=n.subscribe(this.name,t),this.db.subscribe_changes&&(this.runtimeUnsubscribe=this.db.subscribe_changes(e=>{e===this.name&&t()},this.name))}return()=>{if(this.subscribers.delete(e),this.subscribers.size===0){this.graphUnsubscribe?.(),this.runtimeUnsubscribe?.(),this.graphUnsubscribe=null,this.runtimeUnsubscribe=null;for(let e of this.unsubscribeFunctions)e();this.unsubscribeFunctions.clear()}}}close(){this.graphUnsubscribe?.(),this.runtimeUnsubscribe?.(),this.graphUnsubscribe=null,this.runtimeUnsubscribe=null,this.subscribers.clear();for(let e of this.unsubscribeFunctions)e();this.unsubscribeFunctions.clear()}freshness(){return or(this.db)}lastFreshnessCheck(){return this.lastFreshness}async currentRevision(){try{return{revision:await sr(this.db)}}catch(e){return{reason:e instanceof Error?e.message:String(e)}}}async refresh(){try{let e=await this.currentRevision();if(`revision`in e){if(this.isInitialized&&this.cachedRevision&&cr(this.cachedRevision,e.revision)){this.lastFreshness={validation:`revision`,servedFromCache:!0,revision:e.revision};return}}else this.cachedRevision=null;let t=await this.db.query(this.name);if(this.lastFreshness=`revision`in e?{validation:`revision`,servedFromCache:!1,revision:e.revision}:{validation:`refresh`,servedFromCache:!1,reason:e.reason},t.success&&t.data){if(this.cachedRevision=`revision`in e?e.revision:null,this.isInitialized&&t.data===this.lastRawSnapshot)return;try{let e=JSON.parse(t.data);this.predicate&&(e=e.filter(e=>{try{return this.predicate(e)}catch{return!1}})),this.cache=e,this.cacheGeneration+=1,this.lastRawSnapshot=t.data,this.isInitialized=!0}catch(e){console.error(`Failed to parse query results:`,e)}}else t.success||console.error(`Query failed:`,t.error)}catch(e){console.error(`Refresh error:`,e)}}},xr=class extends Error{transactionId;constructor(e,t){super(e),this.name=`AtomicTransactionError`,this.transactionId=t}},Sr=class extends xr{code=`PRECONDITION_FAILED`;failure;constructor(e,t,n){super(e,t),this.name=`ConditionalConflictError`,this.failure=n}};function Cr(e){let{ifVersion:t,expectedVersion:n,...r}=e;if(t!==void 0&&n!==void 0&&t!==n)throw Error(`precondition on ${e.collection}:${e.id} supplies ifVersion ${t} and expectedVersion ${n}; they are the same predicate`);let i=t??n;return i===void 0?{...r}:{...r,expectedVersion:i}}function wr(){let e=Math.random().toString(36).slice(2,10);return`tx_${Date.now().toString(36)}_${e}`}var Tr=class{transactionId;staged=[];required=[];sealed=!1;constructor(e){this.transactionId=e||wr()}get operations(){return this.staged}collection(e){if(!e||!e.trim())throw Error(`collection name is required`);let t=e=>{let{ifVersion:t,expectedVersion:n,...r}=e;if(t!==void 0&&n!==void 0&&t!==n)throw Error(`${e.collection}:${e.id} supplies ifVersion ${t} and expectedVersion ${n}; they are the same predicate`);let i=t??n,a=i===void 0?{...r}:{...r,expectedVersion:i};if(this.sealed)throw Error(`this transaction has already been committed; start a new one`);if(this.staged.find(e=>e.collection===a.collection&&e.id===a.id))throw Error(`transaction already stages ${a.collection}:${a.id}; a transaction may write each record at most once`);this.staged.push(a)},n={set:(r,i,a)=>(t({collection:e,id:String(r),value:i,requireAbsent:a?.requireAbsent,ifVersion:a?.ifVersion,expectedVersion:a?.expectedVersion,expectedEpoch:a?.expectedEpoch,expectedLeaseId:a?.expectedLeaseId}),n),insert:(e,t,r)=>n.set(t,e,r),delete:(r,i)=>(t({collection:e,id:String(r),requireAbsent:i?.requireAbsent,ifVersion:i?.ifVersion,expectedVersion:i?.expectedVersion,expectedEpoch:i?.expectedEpoch,expectedLeaseId:i?.expectedLeaseId}),n)};return n}get preconditions(){return this.required}require(e){if(this.sealed)throw Error(`this transaction has already been committed; start a new one`);if(!e.collection?.trim()||!String(e.id??``).trim())throw Error(`a precondition requires a collection and an id`);let t=Cr(e);if(t.requireAbsent!==!0&&t.expectedVersion===void 0&&t.expectedEpoch===void 0&&t.expectedLeaseId===void 0)throw Error(`precondition on ${e.collection}:${e.id} constrains nothing`);return this.required.push({...t,id:String(e.id)}),this}seal(){return this.sealed=!0,{transactionId:this.transactionId,operations:[...this.staged],preconditions:[...this.required]}}},Er=Symbol(`FELTDB_NO_CHANGE`),Dr=class{id;jsDb;cellCollection;replicaCollection;failureObservationCollection;mutationQueue=[];isLocked=!1;changeHandlers=[];isReplica=!1;constructor(e,t){this.id=t,this.jsDb=e,this.cellCollection=new br(e,`_cells`,void 0,void 0,!1),this.replicaCollection=new br(e,`_replicas`,void 0,void 0,!1),this.failureObservationCollection=new br(e,`_failure_observations`,void 0,void 0,!1)}setReplica(e){this.isReplica=e}isReplicaCell(){return this.isReplica}async applyReplication(e){return this.acquireLock(async()=>{let t=this.encodeKey();for(;;){let n=await this.cellCollection.get(t),r=n?this.snapshotFromState(n):null;if(r&&r.version>e.version)throw Error(`REPLICATION_CONFLICT: cannot apply version ${e.version}, current is ${r.version}`);if(r&&r.version===e.version){if(JSON.stringify(r.value)!==JSON.stringify(e.value)){let n=`version ${e.version} has divergent state`;throw await this.replicaCollection.insert({cellId:this.id,version:r.version,value:r.value,updatedAt:r.updatedAt,authority:r.authority,placement:r.placement,lease:r.lease,divergent:!0,conflictReason:n},t),Error(`REPLICATION_CONFLICT: ${n}`)}await this.clearDivergenceMarker();return}let i={id:e.cellId,version:e.version,value:e.value,updatedAt:e.updatedAt,authority:{owner:e.authority.owner,epoch:e.authority.epoch,lifecycle:e.authority.lifecycle},placement:{nodeId:e.placement.nodeId},lease:e.lease};if(!r)await this.cellCollection.insert(i,t);else{let e=n?.__version??r.version;if(!(await this.cellCollection.updateIfVersion(t,e,i,r.authority.epoch)).updated)continue}await this.clearDivergenceMarker();return}})}async clearDivergenceMarker(){try{await this.replicaCollection.delete(this.encodeKey())}catch(e){if(e instanceof Error&&/^Delete failed: record(?: .+)? not found$/i.test(e.message))return;throw e}}encodeKey(){return`${this.hashId(this.id)}`}hashId(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}async get(){let e=this.encodeKey(),t=await this.cellCollection.get(e);return t?this.snapshotFromState(t):null}async set(e,t){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let n=await this.getUnlocked();if(n?.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);let r=n?.authority.epoch??0;if(t?.authorityEpoch!==void 0&&n&&t.authorityEpoch!==r)throw Error(`AUTHORITY_CONFLICT: expected epoch ${r}, got ${t.authorityEpoch}`);if(t?.leaseId!==void 0){if(!n?.lease)throw Error(`LEASE_INVALID: no active lease`);if(n.lease.leaseId!==t.leaseId)throw Error(`LEASE_INVALID: lease ID mismatch`);if(n.lease.expiresAt<=Date.now())throw Error(`LEASE_EXPIRED: lease has expired`);if(n.lease.epoch!==r)throw Error(`LEASE_INVALID: lease epoch does not match authority epoch`)}let i=n?.version??0,a=n?.authority??{owner:null,epoch:0,lifecycle:`active`},o=n?.placement??{nodeId:null},s=n?.lease??null,c={id:this.id,version:i+1,value:e,updatedAt:new Date().toISOString(),authority:a,placement:o,lease:s},l=this.encodeKey();if(i===0)await this.cellCollection.insert(c,l);else if(!(await this.cellCollection.updateIfVersion(l,i,c,r,t?.leaseId)).updated)throw Error(`Cell ${this.id} version conflict`);return this.emitChange({cellId:this.id,version:c.version,value:e,timestamp:c.updatedAt,epoch:c.authority.epoch}),this.snapshotFromState(c)})}async update(e,t){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let n=await this.getUnlocked();if(n?.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);let r=n?.authority.epoch??0;if(t?.authorityEpoch!==void 0&&n&&t.authorityEpoch!==r)throw Error(`AUTHORITY_CONFLICT: expected epoch ${r}, got ${t.authorityEpoch}`);if(t?.leaseId!==void 0){if(!n?.lease)throw Error(`LEASE_INVALID: no active lease`);if(n.lease.leaseId!==t.leaseId)throw Error(`LEASE_INVALID: lease ID mismatch`);if(n.lease.expiresAt<=Date.now())throw Error(`LEASE_EXPIRED: lease has expired`);if(n.lease.epoch!==r)throw Error(`LEASE_INVALID: lease epoch does not match authority epoch`)}let i=n?.value??null,a=n?.version??0,o=e(i);if(o===Er){if(n)return this.snapshotFromState(n);throw Error(`Cell ${this.id} update returned NO_CHANGE but cell does not exist`)}let s=n?.authority??{owner:null,epoch:0,lifecycle:`active`},c=n?.placement??{nodeId:null},l=n?.lease??null,u={id:this.id,version:a+1,value:o,updatedAt:new Date().toISOString(),authority:s,placement:c,lease:l},d=this.encodeKey();if(a===0)await this.cellCollection.insert(u,d);else if(!(await this.cellCollection.updateIfVersion(d,a,u,r,t?.leaseId)).updated)throw Error(`Cell ${this.id} conflict during update`);return this.emitChange({cellId:this.id,version:u.version,value:o,timestamp:u.updatedAt,epoch:u.authority.epoch}),this.snapshotFromState(u)})}async transact(e){return this.acquireLock(async()=>e({get:()=>this.getUnlocked(),set:(e,t)=>this.setUnlocked(e,t),update:(e,t)=>this.updateUnlocked(e,t)}))}async transitionAuthority(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(t.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);if(t.authority.epoch!==e.expectedEpoch)throw Error(`AUTHORITY_CONFLICT: expected epoch ${e.expectedEpoch}, got ${t.authority.epoch}`);e.lifecycle!==void 0&&this.validateLifecycleTransition(t.authority.lifecycle,e.lifecycle);let n={owner:e.owner===void 0?t.authority.owner:e.owner,epoch:t.authority.epoch+1,lifecycle:e.lifecycle===void 0?t.authority.lifecycle:e.lifecycle},r={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:n,placement:t.placement,lease:null},i=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(i,t.version,r,t.authority.epoch)).updated)throw Error(`AUTHORITY_CONFLICT: epoch changed during transition`);return this.emitChange({cellId:this.id,version:r.version,value:t.value,timestamp:r.updatedAt,epoch:r.authority.epoch}),this.snapshotFromState(r)})}async delegate(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(t.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);if(t.authority.epoch!==e.expectedEpoch)throw Error(`AUTHORITY_CONFLICT: expected epoch ${e.expectedEpoch}, got ${t.authority.epoch}`);if(t.authority.owner!==e.from)throw Error(`AUTHORITY_CONFLICT: expected owner ${e.from}, got ${t.authority.owner}`);let n={owner:e.to,epoch:t.authority.epoch+1,lifecycle:t.authority.lifecycle},r={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:n,placement:t.placement,lease:null},i=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(i,t.version,r,t.authority.epoch)).updated)throw Error(`AUTHORITY_CONFLICT: authority changed during delegation`);return this.emitChange({cellId:this.id,version:r.version,value:t.value,timestamp:r.updatedAt,epoch:r.authority.epoch}),this.snapshotFromState(r)})}async updatePlacement(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(t.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);let n=t.authority.epoch,r={nodeId:e.nodeId},i={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:t.authority,placement:r,lease:t.lease},a=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(a,t.version,i,n)).updated)throw Error(`Cell ${this.id} conflict during placement update`);return this.emitChange({cellId:this.id,version:i.version,value:t.value,timestamp:i.updatedAt,epoch:i.authority.epoch}),this.snapshotFromState(i)})}async acquireLease(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(t.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);if(t.authority.lifecycle===`suspended`)throw Error(`Cell ${this.id} is suspended`);if(t.lease&&t.lease.expiresAt>Date.now())throw Error(`LEASE_CONFLICT: lease already held by ${t.lease.holder}`);let n=t.authority.epoch,r=`${this.id}:${Date.now()}:${Math.random().toString(36).slice(2)}`,i={holder:e.holder,leaseId:r,epoch:n,expiresAt:Date.now()+e.durationMs},a={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:t.authority,placement:t.placement,lease:i},o=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(o,t.version,a,n)).updated)throw Error(`Cell ${this.id} conflict during lease acquisition`);return this.emitChange({cellId:this.id,version:a.version,value:t.value,timestamp:a.updatedAt,epoch:a.authority.epoch}),this.snapshotFromState(a)})}async renewLease(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(!t.lease)throw Error(`Cell ${this.id} has no active lease`);if(t.lease.leaseId!==e.leaseId)throw Error(`LEASE_CONFLICT: lease ID mismatch`);if(t.lease.expiresAt<=Date.now())throw Error(`LEASE_EXPIRED: lease has expired`);if(t.lease.epoch!==t.authority.epoch)throw Error(`AUTHORITY_CONFLICT: authority epoch changed since lease acquisition`);let n=t.authority.epoch,r={holder:t.lease.holder,leaseId:t.lease.leaseId,epoch:t.lease.epoch,expiresAt:Date.now()+e.durationMs},i={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:t.authority,placement:t.placement,lease:r},a=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(a,t.version,i,n)).updated)throw Error(`Cell ${this.id} conflict during lease renewal`);return this.emitChange({cellId:this.id,version:i.version,value:t.value,timestamp:i.updatedAt,epoch:i.authority.epoch}),this.snapshotFromState(i)})}async releaseLease(e){return this.acquireLock(async()=>{if(this.isReplica)throw Error(`REPLICA_READ_ONLY: Cell ${this.id} is a read-only replica`);let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);if(!t.lease)throw Error(`Cell ${this.id} has no active lease`);if(t.lease.leaseId!==e.leaseId)throw Error(`LEASE_CONFLICT: lease ID mismatch`);let n=t.authority.epoch,r={id:this.id,version:t.version+1,value:t.value,updatedAt:new Date().toISOString(),authority:t.authority,placement:t.placement,lease:null},i=this.encodeKey();if(!(await this.cellCollection.updateIfVersion(i,t.version,r,n)).updated)throw Error(`Cell ${this.id} conflict during lease release`);return this.emitChange({cellId:this.id,version:r.version,value:t.value,timestamp:r.updatedAt,epoch:r.authority.epoch}),this.snapshotFromState(r)})}async promote(e){return this.acquireLock(async()=>{let t=await this.getUnlocked();if(!t)throw Error(`Cell ${this.id} does not exist`);return this.promoteSnapshot(t,e)})}async promoteSnapshot(e,t){if(e.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);if(e.version!==t.expectedVersion)throw Error(`PROMOTION_CONFLICT: expected version ${t.expectedVersion}, got ${e.version}`);if(e.authority.epoch!==t.expectedEpoch)throw Error(`PROMOTION_CONFLICT: expected epoch ${t.expectedEpoch}, got ${e.authority.epoch}`);let n={owner:t.newOwner,epoch:e.authority.epoch+1,lifecycle:e.authority.lifecycle},r={nodeId:t.newNodeId===void 0?e.placement.nodeId:t.newNodeId},i={id:this.id,version:e.version+1,value:e.value,updatedAt:new Date().toISOString(),authority:n,placement:r,lease:null},a=this.encodeKey(),o=e.lease&&e.lease.expiresAt>Date.now()?e.lease.leaseId:void 0,s=await this.cellCollection.updateIfVersion(a,e.__version??e.version,i,e.authority.epoch,o,!0,e);if(!s.updated)throw s.conflictCode===`REPLICATION_CONFLICT`?Error(`REPLICATION_CONFLICT: divergent replica cannot be promoted`):Error(`PROMOTION_CONFLICT: cell state changed during promotion`);return this.emitChange({cellId:this.id,version:i.version,value:e.value,timestamp:i.updatedAt,epoch:i.authority.epoch}),this.snapshotFromState(i)}async observeHealth(e){let t=`observation_${this.id}_${e.nodeId}`,n=await this.failureObservationCollection.get(t);if(!(n&&n.observedAt>e.observedAt)){if(n){let r=n.__version??1;if(!(await this.failureObservationCollection.updateIfVersion(t,r,e,0)).updated)return}else await this.failureObservationCollection.insert(e,t)}}async evaluateFailure(e){let t=`observation_${this.id}_${e.nodeId}`,n=await this.failureObservationCollection.get(t);if(!n)return{status:`healthy`,authorityEpoch:e.nodeId===(await this.getUnlocked())?.authority.owner?(await this.getUnlocked())?.authority.epoch??0:0,nodeId:e.nodeId};let r=await this.getUnlocked();if(r&&n.authorityEpoch<r.authority.epoch)return{status:`healthy`,authorityEpoch:r.authority.epoch,nodeId:e.nodeId};let i=e.now-n.lastSeenAt,a;return a=i<e.suspectAfterMs?`healthy`:i<e.failedAfterMs?`suspect`:`failed`,{status:a,authorityEpoch:n.authorityEpoch,nodeId:e.nodeId,ageMs:i}}async attemptAutomaticFailover(e){if(!this.isReplica)return{attempted:!1,promoted:!1,reason:`Not a replica`,diagnostics:{isReplica:!1,eligibilityChecksPassed:!1,promotionAttempted:!1,promotionSucceeded:!1}};let t=e.replicaSnapshot??await this.getUnlocked();if(!t)return{attempted:!1,promoted:!1,reason:`Replica state not found`,diagnostics:{isReplica:!0,eligibilityChecksPassed:!1,promotionAttempted:!1,promotionSucceeded:!1}};let n=`observation_${this.id}_${e.failureEvaluationOptions.nodeId}`,r=e.failureObservation??await this.failureObservationCollection.get(n),i=this.evaluateFailureSnapshot(e.failureEvaluationOptions,r,t);if(i.status!==`failed`)return{attempted:!1,promoted:!1,reason:`Current authority not failed (status: ${i.status})`,diagnostics:{isReplica:!0,failureStatus:i.status,eligibilityChecksPassed:!1,promotionAttempted:!1,promotionSucceeded:!1}};if(t.authority.lifecycle===`retired`)return{attempted:!1,promoted:!1,reason:`Cell is retired`,diagnostics:{isReplica:!0,failureStatus:i.status,eligibilityChecksPassed:!1,promotionAttempted:!1,promotionSucceeded:!1}};if(t.authority.epoch!==i.authorityEpoch)return{attempted:!1,promoted:!1,reason:`Replica authority epoch mismatch: replica=${t.authority.epoch}, observed=${i.authorityEpoch}`,diagnostics:{isReplica:!0,failureStatus:i.status,eligibilityChecksPassed:!1,promotionAttempted:!1,promotionSucceeded:!1}};try{return await this.promoteSnapshot(t,{expectedVersion:t.version,expectedEpoch:t.authority.epoch,newOwner:e.newOwner,newNodeId:t.placement.nodeId}),{attempted:!0,promoted:!0,diagnostics:{isReplica:!0,failureStatus:i.status,eligibilityChecksPassed:!0,promotionAttempted:!0,promotionSucceeded:!0}}}catch(e){return{attempted:!0,promoted:!1,reason:`Promotion failed: ${e instanceof Error?e.message:String(e)}`,diagnostics:{isReplica:!0,failureStatus:i.status,eligibilityChecksPassed:!0,promotionAttempted:!0,promotionSucceeded:!1}}}}evaluateFailureSnapshot(e,t,n){if(!t)return{status:`healthy`,authorityEpoch:e.nodeId===n.authority.owner?n.authority.epoch:0,nodeId:e.nodeId};if(t.authorityEpoch<n.authority.epoch)return{status:`healthy`,authorityEpoch:n.authority.epoch,nodeId:e.nodeId};let r=e.now-t.lastSeenAt;return{status:r<e.suspectAfterMs?`healthy`:r<e.failedAfterMs?`suspect`:`failed`,authorityEpoch:t.authorityEpoch,nodeId:e.nodeId,ageMs:r}}validateLifecycleTransition(e,t){if(!{active:[`suspended`,`retired`],suspended:[`active`,`retired`],retired:[]}[e].includes(t))throw Error(`Invalid lifecycle transition: ${e} → ${t}`)}async getUnlocked(){let e=this.encodeKey(),t=await this.cellCollection.get(e);return t?this.snapshotFromState(t):null}async setUnlocked(e,t){let n=await this.getUnlocked();if(n?.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);let r=n?.authority.epoch??0;if(t?.authorityEpoch!==void 0&&n&&t.authorityEpoch!==r)throw Error(`AUTHORITY_CONFLICT: expected epoch ${r}, got ${t.authorityEpoch}`);if(t?.leaseId!==void 0){if(!n?.lease)throw Error(`LEASE_INVALID: no active lease`);if(n.lease.leaseId!==t.leaseId)throw Error(`LEASE_INVALID: lease ID mismatch`);if(n.lease.expiresAt<=Date.now())throw Error(`LEASE_EXPIRED: lease has expired`);if(n.lease.epoch!==r)throw Error(`LEASE_INVALID: lease epoch does not match authority epoch`)}let i=n?.version??0,a=n?.authority??{owner:null,epoch:0,lifecycle:`active`},o=n?.placement??{nodeId:null},s=n?.lease??null,c={id:this.id,version:i+1,value:e,updatedAt:new Date().toISOString(),authority:a,placement:o,lease:s},l=this.encodeKey();if(i===0)await this.cellCollection.insert(c,l);else if(!(await this.cellCollection.updateIfVersion(l,i,c,r)).updated)throw Error(`Cell ${this.id} version conflict`);return this.emitChange({cellId:this.id,version:c.version,value:e,timestamp:c.updatedAt,epoch:c.authority.epoch}),this.snapshotFromState(c)}async updateUnlocked(e,t){let n=await this.getUnlocked();if(n?.authority.lifecycle===`retired`)throw Error(`Cell ${this.id} is retired`);let r=n?.authority.epoch??0;if(t?.authorityEpoch!==void 0&&n&&t.authorityEpoch!==r)throw Error(`AUTHORITY_CONFLICT: expected epoch ${r}, got ${t.authorityEpoch}`);if(t?.leaseId!==void 0){if(!n?.lease)throw Error(`LEASE_INVALID: no active lease`);if(n.lease.leaseId!==t.leaseId)throw Error(`LEASE_INVALID: lease ID mismatch`);if(n.lease.expiresAt<=Date.now())throw Error(`LEASE_EXPIRED: lease has expired`);if(n.lease.epoch!==r)throw Error(`LEASE_INVALID: lease epoch does not match authority epoch`)}let i=n?.value??null,a=n?.version??0,o=e(i);if(o===Er){if(n)return this.snapshotFromState(n);throw Error(`Cell ${this.id} update returned NO_CHANGE but cell does not exist`)}let s=n?.authority??{owner:null,epoch:0,lifecycle:`active`},c=n?.placement??{nodeId:null},l=n?.lease??null,u={id:this.id,version:a+1,value:o,updatedAt:new Date().toISOString(),authority:s,placement:c,lease:l},d=this.encodeKey();if(a===0)await this.cellCollection.insert(u,d);else if(!(await this.cellCollection.updateIfVersion(d,a,u,r)).updated)throw Error(`Cell ${this.id} conflict during update`);return this.emitChange({cellId:this.id,version:u.version,value:o,timestamp:u.updatedAt,epoch:u.authority.epoch}),this.snapshotFromState(u)}snapshotFromState(e){let t={id:this.id,version:e.version,value:e.value,updatedAt:e.updatedAt,authority:e.authority,placement:e.placement,lease:e.lease},n=e.__version;return n!==void 0&&Object.defineProperty(t,"__version",{value:n,enumerable:!1}),t}on(e,t){e===`change`&&this.changeHandlers.push(t)}off(e,t){if(e===`change`){let e=this.changeHandlers.indexOf(t);e>=0&&this.changeHandlers.splice(e,1)}}emitChange(e){for(let t of this.changeHandlers)try{t(e)}catch(e){console.error(`Error in cell change handler: ${e}`)}}acquireLock(e){return new Promise((t,n)=>{this.mutationQueue.push(async()=>{try{t(await e())}catch(e){n(e)}}),this.isLocked||this.processQueue()})}async processQueue(){if(this.isLocked||this.mutationQueue.length===0)return;this.isLocked=!0;let e=this.mutationQueue.shift();if(e)try{await e()}catch{}finally{this.isLocked=!1,this.processQueue()}}},V;(function(e){e.Created=`Created`,e.Planning=`Planning`,e.Observing=`Observing`,e.Deciding=`Deciding`,e.Acting=`Acting`,e.Waiting=`Waiting`,e.Completed=`Completed`,e.Failed=`Failed`,e.Cancelled=`Cancelled`,e.Blocked=`Blocked`})(V||={});function Or(e,t){return{name:e,version:t,toString(){return`flow://agent/${this.name}@${this.version}`}}}function kr(e){return`exec-${e}-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}var Ar=class{agents=new Map;register(e,t){let n=e.toString(),r={agentRef:e,definition:t,providers:[],compatibleStateVersions:[],registeredAt:Date.now(),updatedAt:Date.now(),active:!0};this.agents.set(n,r)}unregister(e){let t=e.toString();this.agents.delete(t)}get(e){let t=e.toString();return this.agents.get(t)}getByName(e){let t;for(let n of this.agents.values())n.definition.name===e&&(!t||n.agentRef.version>t.agentRef.version)&&(t=n);return t}getAll(){return Array.from(this.agents.values())}addProvider(e,t){let n=e.toString(),r=this.agents.get(n);if(!r)throw Error(`Agent not registered: ${n}`);r.providers=r.providers.filter(e=>e.peerId!==t.peerId),r.providers.push(t),r.updatedAt=Date.now()}removeProvider(e,t){let n=e.toString(),r=this.agents.get(n);if(!r)throw Error(`Agent not registered: ${n}`);r.providers=r.providers.filter(e=>e.peerId!==t),r.updatedAt=Date.now()}getAvailableProviders(e){let t=this.get(e);return t?t.providers.filter(e=>e.available):[]}findByCapability(e){let t=[];for(let n of this.agents.values())n.definition.capabilities.includes(e)&&t.push(n);return t}updateAvailability(e,t,n){let r=this.get(e);if(!r)throw Error(`Agent not registered: ${e.toString()}`);let i=r.providers.find(e=>e.peerId===t);i&&(i.available=n,i.lastHeartbeat=Date.now(),r.updatedAt=Date.now())}clear(){this.agents.clear()}},jr=class{ownership=new Map;locks=new Map;claim(e,t,n){let r=this.ownership.get(e);if(r===t)return!0;if(r)return!1;let i=this.locks.get(e);return i&&i.expiresAt>Date.now()?!1:(this.ownership.set(e,t),this.locks.set(e,{peerId:t,expiresAt:Date.now()+n}),!0)}release(e,t){this.ownership.get(e)===t&&(this.ownership.delete(e),this.locks.delete(e))}getOwner(e){return this.ownership.get(e)}isValid(e){let t=this.locks.get(e);return t?t.expiresAt>Date.now():!1}renew(e,t,n){return this.ownership.get(e)===t&&(this.locks.set(e,{peerId:t,expiresAt:Date.now()+n}),!0)}},Mr=class{config;registry;handlers=new Map;executions=new Map;ownership;triggers=new Map;constructor(e,t){this.registry=e,this.config=t,this.ownership=new jr}registerHandler(e,t){this.handlers.set(e,t)}async createExecution(e,t,n,r){let i=kr(t.name),a={executionId:i,agentRef:t,status:V.Created,goal:n,inputs:r,stateVersion:0,observationIds:[],decisionIds:[],actionIds:[],attempt:1,createdMs:Date.now()};return this.executions.set(i,a),a}async start(e,t){if(!this.ownership.claim(e.executionId,t,3e4))throw Error(`Failed to claim ownership of execution ${e.executionId}`);try{return e.status=V.Planning,e.ownedBy=t,e.startedMs=Date.now(),{execution:e,status:V.Planning,resultRef:void 0}}catch(t){return e.status=V.Failed,e.error=String(t),e.completedMs=Date.now(),{execution:e,status:V.Failed,error:String(t)}}}async resume(e,t){if(!this.ownership.claim(e.executionId,t,3e4)&&this.ownership.getOwner(e.executionId)!==t)throw Error(`Cannot resume execution ${e.executionId}: owned by ${this.ownership.getOwner(e.executionId)}`);return e.ownedBy=t,e.status=V.Observing,{execution:e,status:V.Observing}}async transition(e,t){if(!({[V.Created]:[V.Planning],[V.Planning]:[V.Observing],[V.Observing]:[V.Deciding,V.Waiting],[V.Deciding]:[V.Acting],[V.Acting]:[V.Observing,V.Waiting,V.Completed],[V.Waiting]:[V.Observing,V.Blocked],[V.Completed]:[],[V.Failed]:[],[V.Cancelled]:[],[V.Blocked]:[V.Observing]}[e.status]||[]).includes(t))throw Error(`Invalid transition from ${e.status} to ${t}`);e.status=t}async complete(e,t){e.status=V.Completed,e.resultRef=t,e.completedMs=Date.now(),e.ownedBy&&this.ownership.release(e.executionId,e.ownedBy)}async fail(e,t){e.status=V.Failed,e.error=t,e.completedMs=Date.now(),e.ownedBy&&this.ownership.release(e.executionId,e.ownedBy)}getExecution(e){return this.executions.get(e)}getOwner(e){return this.ownership.getOwner(e)}registerTriggers(e,t){this.triggers.set(e,t)}getTriggers(e){return this.triggers.get(e)||[]}};function Nr(e,t){return`${e}:${t}`}var Pr=/^[A-Za-z0-9._-]{1,128}$/;function Fr(e,t){if(!e.transactionId||!e.transactionId.trim())return{kind:`reject`,reason:`transactionId is required`};if(e.operations.length===0)return{kind:`reject`,reason:`a transaction requires at least one operation`};if(t.hasApplied(e.transactionId))return{kind:`duplicate`};let n=[...(e.preconditions??[]).map(e=>({...e})),...e.operations.filter(e=>e.expectedVersion!==void 0||e.expectedEpoch!==void 0||e.expectedLeaseId!==void 0).map(e=>({collection:e.collection,id:e.id,expectedVersion:e.expectedVersion,expectedEpoch:e.expectedEpoch,expectedLeaseId:e.expectedLeaseId}))];if(n.length>0&&!t.read)return{kind:`reject`,reason:`this runtime cannot evaluate transaction preconditions, so it refuses the transaction rather than committing it unconditionally`};for(let e of n){if(!Pr.test(e.collection)||!Pr.test(String(e.id)))return{kind:`reject`,reason:`invalid collection or id: ${e.collection}:${e.id}`};if(e.requireAbsent!==!0&&e.expectedVersion===void 0&&e.expectedEpoch===void 0&&e.expectedLeaseId===void 0)return{kind:`reject`,reason:`precondition on ${e.collection}:${e.id} constrains nothing`};let n=Nr(e.collection,String(e.id)),r=t.read(n);if(e.requireAbsent){if(r!==void 0)return{kind:`reject`,reason:`PRECONDITION_FAILED:${n}:record already exists`};continue}if(r===void 0)return{kind:`reject`,reason:`PRECONDITION_FAILED:${n}:record does not exist`};if(e.expectedVersion!==void 0){let t=typeof r.__version==`number`?r.__version:1;if(t!==e.expectedVersion)return{kind:`reject`,reason:`PRECONDITION_FAILED:${n}:version ${t}, expected ${e.expectedVersion}`}}if(e.expectedEpoch!==void 0){let t=r.authority,i=typeof t?.epoch==`number`?t.epoch:0;if(i!==e.expectedEpoch)return{kind:`reject`,reason:`PRECONDITION_FAILED:${n}:epoch ${i}, expected ${e.expectedEpoch}`}}if(e.expectedLeaseId!==void 0){let t=r.lease,i=t?.leaseId,a=typeof t?.expiresAt==`number`&&t.expiresAt>Date.now();if(i!==e.expectedLeaseId||!a)return{kind:`reject`,reason:`PRECONDITION_FAILED:${n}:lease ${i??`none`}, expected ${e.expectedLeaseId}`}}}let r=[],i=new Set;for(let a of e.operations){if(!Pr.test(a.collection)||!Pr.test(a.id))return{kind:`reject`,reason:`invalid collection or id: ${a.collection}:${a.id}`};let e=Nr(a.collection,a.id);if(i.has(e))return{kind:`reject`,reason:`transaction writes ${e} more than once`};if(i.add(e),a.requireAbsent&&t.exists(e))return{kind:`reject`,reason:`PRECONDITION_FAILED:${e}:record already exists`};let o=a.requireAbsent===!0||n.some(e=>e.requireAbsent===!0&&e.collection===a.collection&&String(e.id)===a.id),s=a.value===void 0?void 0:o?{...a.value,id:a.id,__version:1}:a.expectedVersion===void 0?{...a.value,id:a.id}:{...a.value,id:a.id,__version:a.expectedVersion+1};r.push({key:e,collection:a.collection,id:a.id,value:s})}return{kind:`apply`,mutations:r}}function Ir(e,t,n,r){return{transactionId:e.transactionId,duplicate:t,operations:e.operations.length,stateBefore:n,stateAfter:r}}var Lr=class extends Error{constructor(e){super(e),this.name=`EmbeddedTransactionRejected`}},Rr=new Map,zr=new Map;function Br(e){let t=zr.get(e);return t||(t={value:0,replicated:!1},zr.set(e,t)),t}var Vr=class{rows;events=[];sequence=0;origin;revisionState;peers=new Set;applied=new Set;constructor(e){let t=Rr.get(e);t||(t=new Map,Rr.set(e,t)),this.rows=t,this.revisionState=Br(e),this.origin=`memory:${e}`}event(e,t,n,r){this.sequence+=1,this.revisionState.value+=1;let i=Date.now();this.events.push({sequence:this.sequence,collection:e,key:t,type:n,value:r,timestamp:i,origin:this.origin,id:`${this.origin}:${i}:${this.sequence}`})}async commit_transaction(e){let t=this.sequence,n=Fr(e,{exists:e=>this.rows.has(e),hasApplied:e=>this.applied.has(e),read:e=>this.rows.get(e)});if(n.kind===`duplicate`)return Ir(e,!0,t,this.sequence);if(n.kind===`reject`)throw new Lr(n.reason);for(let e of n.mutations)e.value===void 0?(this.rows.delete(e.key),this.event(e.collection,e.key,`delete`)):(this.rows.set(e.key,e.value),this.event(e.collection,e.key,`put`,e.value));return this.applied.add(e.transactionId),Ir(e,!1,t,this.sequence)}insert(e,t){try{return this.rows.set(e,JSON.parse(t)),this.event(e.split(`:`)[0],e,`put`,JSON.parse(t)),{success:!0,data:e}}catch(e){return{success:!1,error:String(e)}}}update(e,t){return this.rows.has(e)?this.insert(e,t):{success:!1,error:`Record ${e} not found`}}get(e){let t=this.rows.get(e);return t===void 0?{success:!0}:{success:!0,data:JSON.stringify(t)}}delete(e){return this.rows.delete(e),this.event(e.split(`:`)[0],e,`delete`),{success:!0,data:e}}putIfAbsent(e,t){let n=this.rows.get(e);if(n!==void 0)return Promise.resolve({inserted:!1,value:JSON.stringify(n)});let r=JSON.parse(t);return this.rows.set(e,r),this.event(e.split(`:`)[0],e,`put`,r),Promise.resolve({inserted:!0,value:t})}cas(e){let t=this.rows.get(e.key),n=JSON.parse(e.value);if(t===void 0)return Promise.resolve({updated:!1,currentVersion:0});let r=t,i=r.__version??1,a=r.authority?.epoch??0;if(i!==e.expectedVersion||e.expectedEpoch!==void 0&&a!==e.expectedEpoch)return Promise.resolve({updated:!1,currentVersion:i,currentEpoch:a});let o=e.expectedVersion+1,s={...n,__version:o};return this.rows.set(e.key,s),this.event(e.key.split(`:`)[0],e.key,`put`,s),Promise.resolve({updated:!0,currentVersion:o,currentEpoch:a})}query(e){let t=`${e}:`,n=[...this.rows].filter(([e])=>e.startsWith(t)).map(([,e])=>e);return{success:!0,data:JSON.stringify(n)}}get_capability_records(e){return this.query(e)}execute_op(){return{success:!1,error:`Raw operations are unavailable in the memory runtime`}}sync_info(){return{success:!0,data:JSON.stringify({instance_id:this.origin,sequence:this.sequence,connected_peers:[...this.peers],pending_operations:0,operations_sent:0,operations_received:0,conflicts_detected:0,last_sync_ms:0,is_connected:this.peers.size>0})}}add_peer(){return{success:!0}}add_sync_peer(e){return this.peers.add(e),{success:!0}}remove_sync_peer(e){return this.peers.delete(e),{success:!0}}acknowledge_peer_operations(){return{success:!0}}get_pending_for_peer(){return{success:!0,data:`[]`}}instance_id(){return this.origin}get_sequence(){return this.sequence}freshness(){return this.revisionState.replicated||this.peers.size>0?{domain:`replicated`,validation:`refresh`,invalidation:!1,reason:`remote operations order causally across replicas, so a local counter is not an authoritative revision`}:{domain:`single-process`,validation:`revision`,invalidation:!1,revisionScope:this.origin}}async revision(){let e=this.freshness();if(e.validation!==`revision`)throw new ir(`memory runtime: ${e.reason}`);return{value:this.revisionState.value,scope:this.origin}}audit_events(){return[...this.events]}export_operations(e){return this.events.filter(t=>t.sequence>e)}apply_remote_operations(e){e.length>0&&(this.revisionState.replicated=!0);let t=0,n=0;for(let r of e){if(this.events.some(e=>e.id===r.id)){n++;continue}let e=[...this.events].reverse().find(e=>e.key===r.key),i=`${String(r.timestamp).padStart(16,`0`)}:${r.origin}:${r.id}`,a=e?`${String(e.timestamp).padStart(16,`0`)}:${e.origin}:${e.id}`:``;this.sequence+=1,this.events.push({...r,sequence:this.sequence}),i>=a?(r.type===`delete`?this.rows.delete(r.key):this.rows.set(r.key,r.value),t++):n++}return{applied:t,ignored:n}}},Hr;(function(e){e.OK=`OK`,e.CONFLICT=`CONFLICT`,e.PRECONDITION_FAILED=`PRECONDITION_FAILED`,e.TOO_BUSY=`TOO_BUSY`,e.INTERNAL_ERROR=`INTERNAL_ERROR`,e.AUTHENTICATION_REQUIRED=`AUTHENTICATION_REQUIRED`,e.AUTHENTICATION_FAILED=`AUTHENTICATION_FAILED`,e.FORBIDDEN=`FORBIDDEN`,e.NOT_FOUND=`NOT_FOUND`,e.VALIDATION_ERROR=`VALIDATION_ERROR`,e.IDEMPOTENCY_CONFLICT=`IDEMPOTENCY_CONFLICT`,e.QUERY_INVALID=`QUERY_INVALID`,e.QUERY_LIMIT_EXCEEDED=`QUERY_LIMIT_EXCEEDED`,e.WORKFLOW_NOT_FOUND=`WORKFLOW_NOT_FOUND`,e.AGENT_NOT_FOUND=`AGENT_NOT_FOUND`,e.CAPABILITY_NOT_FOUND=`CAPABILITY_NOT_FOUND`,e.EXECUTION_FAILED=`EXECUTION_FAILED`,e.SERVICE_UNAVAILABLE=`SERVICE_UNAVAILABLE`})(Hr||={});var Ur=class extends Error{code;requestId;status;constructor(e,t,n,r){super(e),this.code=t,this.requestId=n,this.status=r,this.name=`FeltDBServiceError`}},H=class{url;token;applicationId;environment;activeRevision;constructor(e){this.url=e.url.replace(/\/$/,``),this.token=e.token||``,this.applicationId=e.applicationId,this.environment=e.environment||`production`}headers(e=!1){return{...this.token?{Authorization:`Bearer ${this.token}`}:{},"FeltDB-Protocol":`1`,...e?{"Content-Type":`application/json`}:{}}}async auth_request(e,t){let n=await fetch(`${this.url}/v1/auth/${e}`,{method:e===`session`?`GET`:`POST`,headers:this.headers(t!==void 0),...t===void 0?{}:{body:JSON.stringify(e===`signup`?{application_id:this.applicationId,...t}:t)}}),r=n.status===204?{}:await n.json();if(!n.ok)throw new Ur(r.message||r.error||`Authentication failed`,r.code||r.error||`AUTHENTICATION_FAILED`,r.request_id,n.status);return r.access_token&&(this.token=r.access_token),e===`signout`&&(this.token=``),r}splitKey(e){let t=e.indexOf(`:`);if(t<1||t===e.length-1)throw Error(`Invalid FeltDB key: ${e}`);return[e.slice(0,t),e.slice(t+1)]}async revisionId(){if(!this.applicationId)throw Error(`applicationId is required for the canonical application service`);return this.activeRevision??=this.application_request(`/application`).then(e=>e.revision_id),this.activeRevision}async canonical(e,t){let n=await this.revisionId();return this.application_request(e,{method:`POST`,body:JSON.stringify({application_id:this.applicationId,revision_id:n,environment:this.environment,...t})})}transactionDocument(e,t,n=crypto.randomUUID()){return{transaction_id:n,tenant_id:``,application_id:this.applicationId,revision_id:e,schema_version:0,authorization:{subject:``,tenant_id:``,application_id:this.applicationId,revision_id:e,capabilities:[]},operations:t}}async canonicalTransaction(e,t){let n=await this.revisionId();return this.application_request(`/transactions`,{method:`POST`,body:JSON.stringify({application_id:this.applicationId,revision_id:n,environment:this.environment,transaction:this.transactionDocument(n,e,t)})})}async get(e){try{let[t,n]=this.splitKey(e);if(this.applicationId){let e=await this.canonical(`/query`,{query:{collection:t,filter:{operator:`eq`,field:`id`,value:n},limit:1}});return{success:!0,data:e.records.length?JSON.stringify(e.records[0]):void 0}}let r=await fetch(`${this.url}/collections/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{headers:this.headers()});if(r.status===404)return{success:!0};if(!r.ok)return this.failure(r);let i=await r.json();return{success:!0,data:JSON.stringify(i.value)}}catch(e){return{success:!1,error:String(e)}}}async query(e){try{if(this.applicationId){let t=await this.canonical(`/query`,{query:{collection:e,limit:500}});return{success:!0,data:JSON.stringify(t.records)}}let t=await fetch(`${this.url}/collections/${encodeURIComponent(e)}`,{headers:this.headers()});if(!t.ok)return this.failure(t);let n=await t.json();return{success:!0,data:JSON.stringify(n.map(e=>e.value))}}catch(e){return{success:!1,error:String(e)}}}async authority_query(e){if(this.applicationId){let t=(e.where||[]).map(e=>{let t=Object.keys(e).find(e=>e!==`field`)||`eq`;return{operator:t,field:e.field,value:e[t]}}),n=await this.canonical(`/query`,{query:{collection:e.collection,filter:t.length===1?t[0]:t.length?{operator:`and`,filters:t}:void 0,order_by:e.orderBy?.map(e=>({field:e.field,direction:e.direction})),limit:e.limit,cursor:e.cursor}});return{records:n.records,nextCursor:n.next_cursor,exhausted:!n.next_cursor}}let t=await fetch(`${this.url}/query`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify(e)}),n=await t.json();if(!t.ok){let e=Error(n.message||n.error||`authority query failed with HTTP ${t.status}`);throw e.code=n.code,e.status=t.status,e}return n}async insert(e,t){try{let[n,r]=this.splitKey(e),i=JSON.parse(t);if(this.applicationId)return await this.canonicalTransaction([{kind:`insert`,collection:n,id:r,value:i}]),{success:!0,data:e};let a=await fetch(`${this.url}/collections/${encodeURIComponent(n)}`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify({...i,id:r})});return a.ok?{success:!0,data:e}:this.failure(a)}catch(e){return{success:!1,error:String(e)}}}async update(e,t){try{let[n,r]=this.splitKey(e);if(this.applicationId)return await this.canonicalTransaction([{kind:`update`,collection:n,id:r,value:JSON.parse(t)}]),{success:!0,data:e};let i=await fetch(`${this.url}/collections/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,{method:`PATCH`,headers:this.headers(!0),body:t});return i.ok?{success:!0,data:e}:this.failure(i)}catch(e){return{success:!1,error:String(e)}}}async commit_transaction(e){if(this.applicationId){if(e.preconditions?.length)throw Error(`record preconditions are not representable by the canonical transaction contract`);let t=e.operations.map(e=>({kind:e.value===void 0?`delete`:e.requireAbsent?`insert`:`update`,collection:e.collection,id:e.id,value:e.value,if_version:e.expectedVersion})),n=await this.canonicalTransaction(t,e.transactionId);return{transactionId:n.transaction_id,duplicate:n.duplicate,operations:t.length,stateBefore:n.state_before,stateAfter:n.state_after}}let t=await fetch(`${this.url}/transactions`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify(e)});if(!t.ok){let e={};try{e=await t.json()}catch{}let n=Error(e.error||`transaction failed with HTTP ${t.status}`);throw n.status=t.status,e.code&&(n.feltdbCode=e.code),e.failure&&(n.feltdbConflict=e.failure),n}return await t.json()}async cas(e){try{let[t,n]=this.splitKey(e.key),r=JSON.parse(e.value),i=await fetch(`${this.url}/collections/${encodeURIComponent(t)}/${encodeURIComponent(n)}/cas`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify({expectedVersion:e.expectedVersion,expectedEpoch:e.expectedEpoch,expectedLeaseId:e.expectedLeaseId,rejectIfDiverged:e.rejectIfDiverged,value:r})});if(i.status===409){let e=await i.json();if((e.code===`VERSION_CONFLICT`||e.code===`AUTHORITY_CONFLICT`||e.code===`LEASE_CONFLICT`||e.code===`REPLICATION_CONFLICT`)&&e.currentVersion!==void 0)return{updated:!1,currentVersion:e.currentVersion,currentEpoch:e.currentEpoch,conflictCode:e.code}}if(!i.ok){let e=await this.failure(i);throw Error(e.error||`HTTP CAS failed`)}return await i.json()}catch(e){throw e instanceof Error?e:Error(String(e))}}async delete(e){try{let[t,n]=this.splitKey(e);if(this.applicationId)return await this.canonicalTransaction([{kind:`delete`,collection:t,id:n}]),{success:!0,data:e};let r=await fetch(`${this.url}/collections/${encodeURIComponent(t)}/${encodeURIComponent(n)}`,{method:`DELETE`,headers:this.headers()});return r.ok?{success:!0,data:e}:this.failure(r)}catch(e){return{success:!1,error:String(e)}}}async acquire(e,t){let n=await fetch(`${this.url}/refs/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{headers:this.headers()});if(n.status===404)return null;if(!n.ok)throw Error((await this.failure(n)).error);return(await n.json()).value}async search(e,t,n=50){let r=await fetch(`${this.url}/capabilities/search/${encodeURIComponent(e)}`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify({query:t,limit:n})});if(!r.ok)throw Error((await this.failure(r)).error);return(await r.json()).map(e=>e.value)}async provenance(e,t){let n=await fetch(`${this.url}/provenance/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{headers:this.headers()});if(!n.ok)throw Error((await this.failure(n)).error);return n.json()}async storeContent(e){let t=await fetch(`${this.url}/content`,{method:`PUT`,headers:this.headers(),body:e});if(!t.ok)throw Error((await this.failure(t)).error);return t.json()}async acquireContent(e){let t=await fetch(`${this.url}/content/${encodeURIComponent(e)}`,{headers:this.headers()});if(t.status===404)return null;if(!t.ok)throw Error((await this.failure(t)).error);return new Uint8Array(await t.arrayBuffer())}async command(e,t){let n=await fetch(`${this.url}${e}`,{method:`POST`,headers:this.headers(!0),body:JSON.stringify(t)});if(!n.ok)throw Error((await this.failure(n)).error);return n.status===204?void 0:n.json()}async application_request(e,t={}){let n=e.includes(`?`)?`&`:`?`,r=this.applicationId?`${n}application_id=${encodeURIComponent(this.applicationId)}&environment=${encodeURIComponent(this.environment)}`:``,i=await fetch(`${this.url}/v1${e}${r}`,{...t,headers:{...this.headers(t.body!==void 0),...t.headers||{}}}),a=await i.text(),o;try{o=a?JSON.parse(a):void 0}catch{o={message:a}}if(!i.ok)throw new Ur(o?.message||o?.error||`FeltDB service request failed: HTTP ${i.status}`,o?.code||o?.error||`REQUEST_FAILED`,o?.request_id,i.status);return o}subscribe_changes(e){let t=new AbortController;return this.consumeEvents(t,e),()=>t.abort()}async consumeEvents(e,t){for(;!e.signal.aborted;){try{let n=this.applicationId?`/v1/events?application_id=${encodeURIComponent(this.applicationId)}&environment=${encodeURIComponent(this.environment)}`:`/events`,r=await fetch(`${this.url}${n}`,{headers:this.headers(),signal:e.signal});if(!r.ok||!r.body)throw Error(`Event stream failed: HTTP ${r.status}`);let i=r.body.getReader(),a=new TextDecoder,o=``;for(;!e.signal.aborted;){let{done:e,value:n}=await i.read();if(e)break;o+=a.decode(n,{stream:!0}).replace(/\r\n/g,`
|
|
11
|
+
`);let r=o.split(`
|
|
12
|
+
|
|
13
|
+
`);o=r.pop()??``;for(let e of r){let n=e.split(`
|
|
14
|
+
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trim()).join(`
|
|
15
|
+
`);if(!n)continue;let r=JSON.parse(n);r.resource&&t(r.resource)}}}catch{if(e.signal.aborted)return}if(e.signal.aborted)return;await new Promise(t=>{let n=setTimeout(t,1e3);n?.unref?.(),e.signal.addEventListener(`abort`,()=>{clearTimeout(n),t()},{once:!0})})}}async failure(e){let t=`HTTP ${e.status}`;try{let n=await e.json();n.error&&(t=n.error)}catch{}return{success:!1,error:t}}get_capability_records(e){return this.query(e)}execute_op(){return{success:!1,error:`Raw operation execution is internal to the server fabric`}}sync_info(){return{success:!1,error:`Use the server runtime endpoint for diagnostics`}}add_peer(){return{success:!1,error:`Peer topology is server-managed`}}add_sync_peer(){return{success:!1,error:`Peer topology is server-managed`}}remove_sync_peer(){return{success:!1,error:`Peer topology is server-managed`}}get_pending_for_peer(){return{success:!1,error:`Operation transport is server-managed`}}acknowledge_peer_operations(){return{success:!1,error:`Operation transport is server-managed`}}instance_id(){return`remote:${this.url}`}get_sequence(){return 0}advertisedScope;async freshness(){if(this.advertisedScope===void 0){let e=await fetch(`${this.url}/revision`,{headers:this.headers()});if(e.status===404)return{domain:`single-authority`,validation:`refresh`,invalidation:!0,reason:`this authority does not serve GET /revision, so it cannot report a committed revision`};this.absorb(await this.body(e))}return{domain:`single-authority`,validation:`revision`,invalidation:!0,revisionScope:this.advertisedScope}}async revision(){let e=this.absorb(await this.body(await fetch(`${this.url}/revision`,{headers:this.headers()})));return{value:e.revision,scope:e.scope}}async body(e){if(!e.ok)throw Error(`revision request failed: ${e.status} ${e.statusText}`);return await e.json()}absorb(e){return this.advertisedScope??=e.scope,e}},Wr=class{database;channel;sequence=0;origin;peers=new Set;changeListeners=new Map;changeCursor=0;changePollGeneration=0;changePollRunning=!1;changePollTimer;changeChannelListening=!1;changeCoordinatorReady=!1;pendingChangeAnnouncements=[];announcedChangeSequences=new Set;constructor(e){if(typeof indexedDB>`u`)throw Error(`IndexedDB is unavailable in this browser`);this.database=this.open(`feltdb:${e}`),this.origin=`browser:${e}`,typeof BroadcastChannel<`u`&&(this.channel=new BroadcastChannel(`feltdb:${e}:changes`))}open(e){return new Promise((t,n)=>{let r=indexedDB.open(e,2);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(`rows`)||e.createObjectStore(`rows`),e.objectStoreNames.contains(`changes`)||e.createObjectStore(`changes`,{keyPath:`sequence`,autoIncrement:!0}),e.objectStoreNames.contains(`transactions`)||e.createObjectStore(`transactions`)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error??Error(`open IndexedDB failed`)),r.onblocked=()=>n(Error(`IndexedDB upgrade blocked by another tab`))})}splitKey(e){let t=e.indexOf(`:`);if(t<1)throw Error(`Invalid FeltDB key: ${e}`);return e.slice(0,t)}async mutate(e,t,n){try{let r=await this.database,i=0,a=this.splitKey(e);return await new Promise((o,s)=>{let c;try{c=r.transaction([`rows`,`changes`],`readwrite`,{durability:`strict`})}catch{c=r.transaction([`rows`,`changes`],`readwrite`)}n===`delete`?c.objectStore(`rows`).delete(e):c.objectStore(`rows`).put(t,e);let l=c.objectStore(`changes`),u=Date.now(),d=l.add({collection:a,key:e,type:n,value:t,timestamp:u,origin:this.origin,id:`${this.origin}:${u}:${Math.random().toString(36).slice(2)}`});d.onsuccess=()=>{let e=Number(d.result);i=e,e>1e4&&l.delete(IDBKeyRange.upperBound(e-1e4))},c.oncomplete=()=>o(),c.onerror=()=>s(c.error??Error(`IndexedDB mutation failed`)),c.onabort=()=>s(c.error??Error(`IndexedDB mutation aborted`))}),this.sequence+=1,this.announceLocalChange(a,i),this.channel?.postMessage({collection:a,sequence:i}),{success:!0,data:e}}catch(e){return{success:!1,error:String(e)}}}insert(e,t){return this.mutate(e,JSON.parse(t),`put`)}update(e,t){return this.mutate(e,JSON.parse(t),`put`)}delete(e){return this.mutate(e,void 0,`delete`)}async commit_transaction(e){let t=await this.database,n=this.sequence,r=Fr(e,{exists:()=>!1,hasApplied:()=>!1});if(r.kind===`reject`)throw new Lr(r.reason);if(await this.request(`transactions`,t=>t.get(e.transactionId))!==void 0)return Ir(e,!0,n,this.sequence);let i=await new Promise((n,r)=>{let i;try{i=t.transaction([`rows`,`changes`,`transactions`],`readwrite`,{durability:`strict`})}catch{i=t.transaction([`rows`,`changes`,`transactions`],`readwrite`)}let a=i.objectStore(`rows`),o=i.objectStore(`changes`),s=i.objectStore(`transactions`),c=new Map,l=e.operations.length,u=null,d=()=>{let t=Fr(e,{exists:e=>c.get(e)===!0,hasApplied:()=>!1});if(u=t,t.kind!==`apply`){i.abort();return}let n=Date.now();for(let e of t.mutations)e.value===void 0?a.delete(e.key):a.put(e.value,e.key),o.add({collection:e.collection,key:e.key,type:e.value===void 0?`delete`:`put`,value:e.value,timestamp:n,origin:this.origin,id:`${this.origin}:${n}:${Math.random().toString(36).slice(2)}`});s.put({transactionId:e.transactionId,committedAt:n},e.transactionId)};for(let t of e.operations){let e=`${t.collection}:${t.id}`,n=a.getKey(e);n.onsuccess=()=>{c.set(e,n.result!==void 0),--l,l===0&&d()},n.onerror=()=>r(n.error??Error(`IndexedDB read failed`))}i.oncomplete=()=>n(u??{kind:`reject`,reason:`transaction did not decide`}),i.onabort=()=>{u&&u.kind!==`apply`?n(u):r(i.error??Error(`IndexedDB transaction aborted`))},i.onerror=()=>{u&&u.kind!==`apply`||r(i.error??Error(`IndexedDB transaction failed`))}});if(i.kind===`duplicate`)return Ir(e,!0,n,this.sequence);if(i.kind===`reject`)throw new Lr(i.reason);this.sequence+=i.mutations.length;for(let e of i.mutations)this.announceLocalChange(e.collection,this.sequence);return Ir(e,!1,n,this.sequence)}async cas(e){try{let t=await this.database,n={updated:!1,currentVersion:0},r=0,i=this.splitKey(e.key);return await new Promise((a,o)=>{let s;try{s=t.transaction([`rows`,`changes`],`readwrite`,{durability:`strict`})}catch{s=t.transaction([`rows`,`changes`],`readwrite`)}let c=s.objectStore(`rows`),l=s.objectStore(`changes`),u=c.get(e.key);u.onsuccess=()=>{let t=u.result;if(t===void 0){n={updated:!1,currentVersion:0};return}let a=t.__version??1;if(a!==e.expectedVersion){n={updated:!1,currentVersion:a};return}let o=JSON.parse(e.value),s=e.expectedVersion+1,d={...o,__version:s};c.put(d,e.key);let f=Date.now(),p=l.add({collection:i,key:e.key,type:`put`,value:d,timestamp:f,origin:this.origin,id:`${this.origin}:${f}:${Math.random().toString(36).slice(2)}`});p.onsuccess=()=>{r=Number(p.result),n={updated:!0,currentVersion:s}}},u.onerror=()=>{s.abort()},s.oncomplete=()=>a(),s.onerror=()=>o(s.error??Error(`IndexedDB CAS failed`)),s.onabort=()=>o(s.error??Error(`IndexedDB CAS aborted`))}),n.updated&&r>0&&(this.sequence+=1,this.announceLocalChange(i,r),this.channel?.postMessage({collection:i,sequence:r})),n}catch{return{updated:!1,currentVersion:0}}}async get(e){try{let t=await this.request(`rows`,t=>t.get(e));return{success:!0,data:t===void 0?void 0:JSON.stringify(t)}}catch(e){return{success:!1,error:String(e)}}}async query(e){try{let t=await this.database,n=await new Promise((n,r)=>{let i=t.transaction(`rows`).objectStore(`rows`).openCursor(),a=[];i.onsuccess=()=>{let t=i.result;if(!t)return n(a);String(t.key).startsWith(`${e}:`)&&a.push(t.value),t.continue()},i.onerror=()=>r(i.error)});return{success:!0,data:JSON.stringify(n)}}catch(e){return{success:!1,error:String(e)}}}async request(e,t){let n=await this.database;return new Promise((r,i)=>{let a=t(n.transaction(e).objectStore(e));a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)})}subscribe_changes(e,t){let n=this.changeListeners.get(t);n||(n=new Set,this.changeListeners.set(t,n)),n.add(e),this.changePollRunning||this.startChangeCoordinator();let r=!0;return()=>{if(!r)return;r=!1;let n=this.changeListeners.get(t);n?.delete(e),n?.size===0&&this.changeListeners.delete(t),this.changeListeners.size===0&&this.stopChangeCoordinator()}}receiveChangeMessage=e=>{if(!e.data?.collection)return;let t={collection:e.data.collection,sequence:e.data.sequence};if(!this.changeCoordinatorReady){this.pendingChangeAnnouncements.push(t);return}this.deliverChangeAnnouncement(t)};deliverChangeAnnouncement(e){if(e.sequence!==void 0){if(e.sequence<=this.changeCursor||this.announcedChangeSequences.has(e.sequence))return;this.rememberAnnouncedSequence(e.sequence)}this.notifyChangeListeners(e.collection)}announceLocalChange(e,t){this.changeListeners.size!==0&&(t&&this.rememberAnnouncedSequence(t),this.notifyChangeListeners(e))}rememberAnnouncedSequence(e){if(this.announcedChangeSequences.add(e),this.announcedChangeSequences.size>1e4){let e=this.announcedChangeSequences.values().next().value;e!==void 0&&this.announcedChangeSequences.delete(e)}}notifyChangeListeners(e){let t=new Set([...this.changeListeners.get(e)??[],...this.changeListeners.get(void 0)??[]]);for(let n of t)n(e)}async startChangeCoordinator(){if(this.changePollRunning||this.changeListeners.size===0)return;this.changePollRunning=!0,this.changeCoordinatorReady=!1;let e=++this.changePollGeneration;this.channel&&!this.changeChannelListening&&(this.channel.addEventListener(`message`,this.receiveChangeMessage),this.changeChannelListening=!0);try{this.changeCursor=await this.latestChangeSequence()}catch{}if(e!==this.changePollGeneration||this.changeListeners.size===0)return;for(let e of this.announcedChangeSequences)e<=this.changeCursor&&this.announcedChangeSequences.delete(e);this.changeCoordinatorReady=!0;let t=this.pendingChangeAnnouncements.splice(0);for(let e of t)this.deliverChangeAnnouncement(e);this.pollChanges(e)}async latestChangeSequence(){let e=await this.database;return new Promise((t,n)=>{let r=e.transaction(`changes`).objectStore(`changes`).openKeyCursor(null,`prev`);r.onsuccess=()=>t(r.result?Number(r.result.key):0),r.onerror=()=>n(r.error)})}async pollChanges(e){if(e===this.changePollGeneration&&this.changeListeners.size!==0){try{let e=await this.database;await new Promise((t,n)=>{let r=this.changeCursor?IDBKeyRange.lowerBound(this.changeCursor,!0):void 0,i=e.transaction(`changes`).objectStore(`changes`).openCursor(r);i.onsuccess=()=>{let e=i.result;if(!e)return t();this.changeCursor=Number(e.key),this.announcedChangeSequences.has(this.changeCursor)?this.announcedChangeSequences.delete(this.changeCursor):this.notifyChangeListeners(e.value.collection),e.continue()},i.onerror=()=>n(i.error)})}catch{}e===this.changePollGeneration&&this.changeListeners.size!==0&&(this.changePollTimer=setTimeout(()=>void this.pollChanges(e),500))}}stopChangeCoordinator(){this.changePollGeneration+=1,this.changePollRunning=!1,this.changeCoordinatorReady=!1,this.pendingChangeAnnouncements=[],this.changePollTimer!==void 0&&clearTimeout(this.changePollTimer),this.changePollTimer=void 0,this.announcedChangeSequences.clear(),this.channel&&this.changeChannelListening&&(this.channel.removeEventListener(`message`,this.receiveChangeMessage),this.changeChannelListening=!1)}close(){this.changeListeners.clear(),this.stopChangeCoordinator(),this.database.then(e=>e.close()),this.channel?.close()}get_capability_records(e){return this.query(e)}execute_op(){return{success:!1,error:`Raw operations are unavailable in IndexedDB`}}sync_info(){return{success:!0,data:JSON.stringify({instance_id:this.origin,sequence:this.sequence,connected_peers:[...this.peers],pending_operations:0,operations_sent:0,operations_received:0,conflicts_detected:0,last_sync_ms:0,is_connected:this.peers.size>0})}}add_peer(){return{success:!1,error:`Use a remote runtime for peer sync`}}add_sync_peer(e){return this.peers.add(e),{success:!0}}remove_sync_peer(e){return this.peers.delete(e),{success:!0}}get_pending_for_peer(){return{success:!0,data:`[]`}}acknowledge_peer_operations(){return{success:!0}}instance_id(){return this.origin}get_sequence(){return this.sequence}freshness(){return this.peers.size>0?{domain:`replicated`,validation:`refresh`,invalidation:!0,reason:`sync peers order operations causally, so the local autoIncrement key is not authoritative across replicas`}:{domain:`local-first`,validation:`revision`,invalidation:!0,revisionScope:this.origin}}async revision(){let e=this.freshness();if(e.validation!==`revision`)throw new ir(`browser runtime: ${e.reason}`);let t=await this.request(`changes`,e=>e.openKeyCursor(null,`prev`));return{value:t?Number(t.key):0,scope:this.origin}}async audit_events(){return(await this.request(`changes`,e=>e.getAll())).map((e,t)=>({...e,sequence:e.sequence??t+1}))}async export_operations(e){return(await this.audit_events()).filter(t=>(t.sequence??0)>e)}async apply_remote_operations(e){let t=await this.database,n=0,r=0;for(let i of e){let e=await this.audit_events();if(e.some(e=>e.id===i.id)){r++;continue}let a=e.filter(e=>e.key===i.key).sort((e,t)=>(t.sequence??0)-(e.sequence??0))[0],o=`${String(i.timestamp).padStart(16,`0`)}:${i.origin}:${i.id}`>=(a?`${String(a.timestamp).padStart(16,`0`)}:${a.origin}:${a.id}`:``),s=0;await new Promise((e,n)=>{let r=t.transaction([`rows`,`changes`],`readwrite`);o&&(i.type===`delete`?r.objectStore(`rows`).delete(i.key):r.objectStore(`rows`).put(i.value,i.key));let{sequence:a,...c}=i,l=r.objectStore(`changes`).add(c);l.onsuccess=()=>{s=Number(l.result)},r.oncomplete=()=>e(),r.onerror=()=>n(r.error),r.onabort=()=>n(r.error)}),this.announceLocalChange(i.collection,s),this.channel?.postMessage({collection:i.collection,sequence:s}),o?n++:r++}return{applied:n,ignored:r}}},Gr=new Map;function Kr(e){return Gr.get(e)}function qr(e,t,n){let r=Kr(e);if(!r)throw Error(n);return r(t)}var Jr={id:`stripe`,name:`Stripe-compatible billing`,version:`1.0.0`,provider:`stripe-compatible`,compatibility:[`stripe`,`stripe-compatible`],models:[`Customer`,`Product`,`Price`,`Subscription`,`SubscriptionItem`,`Invoice`,`PaymentIntent`,`CheckoutSession`,`PaymentMethod`,`Refund`,`WebhookEvent`].map(e=>({name:e,authority:`external`,ownership:`external-authoritative`,fields:[{name:`id`,type:`text`,immutable:!0,externally_owned:!0,application_readable:!0},{name:`status`,type:`text`,optional:!0,externally_owned:!0,application_readable:!0},{name:`created_at`,type:`datetime`,externally_owned:!0,application_readable:!0},{name:`metadata`,type:`json`,optional:!0,externally_owned:!0,application_readable:!0}]})),relationships:[{from:`Customer`,to:`Subscription`,kind:`many`},{from:`Subscription`,to:`SubscriptionItem`,kind:`many`},{from:`SubscriptionItem`,to:`Price`,kind:`one`},{from:`Price`,to:`Product`,kind:`one`},{from:`Customer`,to:`Invoice`,kind:`many`},{from:`Invoice`,to:`PaymentIntent`,kind:`one`}],events:[`stripe.customer.created`,`stripe.customer.updated`,`stripe.subscription.created`,`stripe.subscription.updated`,`stripe.subscription.deleted`,`stripe.invoice.paid`,`stripe.invoice.payment_failed`,`stripe.checkout.session.completed`],capabilities:[`stripe.customer.read`,`stripe.customer.create`,`stripe.checkout.create`,`stripe.subscription.read`,`stripe.subscription.create`,`stripe.subscription.cancel`,`stripe.invoice.read`,`stripe.webhooks.receive`],workflows:[`ReconcileSubscription`,`ReconcileFailedPayment`],configuration:[{name:`STRIPE_PUBLISHABLE_KEY`,required:!1,description:`Browser-safe publishable provider key`}],secrets:[{name:`STRIPE_SECRET_KEY`,required:!0,description:`Server-side provider credential`},{name:`STRIPE_WEBHOOK_SECRET`,required:!0,environments:[`production`],description:`Webhook signature verification secret`}],validation:[`Webhook receivers must verify signatures`,`Checkout creation requires authenticated authorization`],dependencies:[],authorization:[{capability:`stripe.checkout.create`,subject:`authenticated`,implication:`A signed-in billing owner may create a hosted checkout session`},{capability:`stripe.subscription.cancel`,subject:`owner`,implication:`Only the billing owner may cancel a subscription`}],patterns:[{name:`organization billing`,when:`The application contains Organization or Workspace state`,owner_candidates:[`Organization`,`Workspace`],application_models:[{name:`BillingAccount`,ownership:`application-authoritative`,purpose:`Connect the application billing owner to provider state`},{name:`Entitlement`,ownership:`derived`,purpose:`Materialize product access from reconciled subscription state`}]},{name:`user billing`,when:`The application is user-centric and has no organizational owner`,owner_candidates:[`User`,`Account`],application_models:[{name:`BillingAccount`,ownership:`application-authoritative`,purpose:`Connect the user to provider state`},{name:`Entitlement`,ownership:`derived`,purpose:`Materialize product access from reconciled subscription state`}]}],reconciliation:[{event:`stripe.subscription.updated`,workflow:`ReconcileSubscription`,reads:[`stripe.Subscription`,`BillingAccount`],writes:[`BillingAccount`,`Entitlement`],outcome:`Subscription changes become application entitlements`},{event:`stripe.invoice.payment_failed`,workflow:`ReconcileFailedPayment`,reads:[`stripe.Invoice`,`BillingAccount`],writes:[`BillingAccount`,`Entitlement`],outcome:`Failed payment state restricts derived entitlements`}]},Yr=new Map([[Jr.id,Jr]]);function Xr(){return[...Yr.values()].map(e=>structuredClone(e))}function Zr(e){let t=Yr.get(e.name);if(!t)throw Error(`UNKNOWN_MODULE: ${e.name}`);if(!t.compatibility.includes(e.provider))throw Error(`INCOMPATIBLE_MODULE_PROVIDER: ${e.name} does not support ${e.provider}`);if(e.version&&e.version!==t.version)throw Error(`INCOMPATIBLE_MODULE_VERSION: ${e.name}@${e.version}; available ${t.version}`);return{...structuredClone(t),provider:e.provider}}function Qr(e){let t=e.trim().toLowerCase();return Xr().filter(e=>e.id===t||e.name.toLowerCase().includes(t)||e.compatibility.some(e=>e.includes(t)))}function $r(e=[]){return e.map(Zr).sort((e,t)=>e.id.localeCompare(t.id))}var ei=[`text`,`integer`,`number`,`boolean`,`datetime`,`date`,`time`,`json`,`uuid`,`decimal`,`money`,`bigint`,`email`,`url`,`phone`,`binary`,`file`,`geo`,`object`];function ti(e){let t=e.trim();if(ei.includes(t)||/^ref [A-Za-z_][A-Za-z0-9_-]*(?:\.[A-Za-z_][A-Za-z0-9_-]*)?$/.test(t))return!0;if(/^enum\([^)]+\)$/.test(t))return t.slice(5,-1).split(`,`).every(e=>e.trim().length>0);if(/^vector(?:<[1-9][0-9]*>)?$/.test(t))return!0;let n=/^(array|map)<(.+)>$/.exec(t);return!!(n&&ti(n[2]))}function ni(e,t,n){let r=$r(e.modules),i=[...e.capabilities.map(e=>({name:e.name,visibility:e.statements.find(e=>e.startsWith(`visibility `))?.slice(11)||`public`})),...r.flatMap(e=>e.capabilities.map(t=>({name:t,provider:e.id,visibility:`internal`})))],a=(e,t)=>e.map(e=>RegExp(`^${t}\\s*:\\s*(.+)$`).exec(e)?.[1]).find(Boolean),o=e=>{let t=e.type.startsWith(`ref `)?e.type.slice(4):void 0,n=e.type.startsWith(`enum(`)&&e.type.endsWith(`)`)?e.type.slice(5,-1).split(`,`).map(e=>e.trim()):void 0;return{name:e.name,type:t?`reference`:n?`enum`:e.type,required:!e.optional,...t?{reference:t}:{},...n?{enum_values:n}:{}}};return{application_id:n,tenant_id:t,schema:1,metadata:{name:e.app,labels:{}},collections:e.collections.map(e=>({name:e.name,fields:e.fields.map(o)})),indexes:e.collections.flatMap(e=>e.indexes.map(t=>({name:t.name,collection:e.name,fields:[t.expression],unique:t.kind===`unique`}))),references:[],queries:[],actions:[],workflows:e.workflows.map(e=>({name:e.name,steps:e.steps.map(e=>({name:e.name,capability:e.statements.find(e=>e.startsWith(`capability `))?.slice(11)}))})),triggers:e.triggers.map((t,n)=>({name:`trigger-${n+1}`,event:t.event,workflow:e.workflows[0]?.name||``})),schedules:e.schedules.map(t=>({name:t.name,expression:t.statements[0]||``,workflow:e.workflows[0]?.name||``})),agents:e.agents.map(e=>({name:e.name,capabilities:i.map(e=>e.name).filter(t=>e.statements.some(e=>e.includes(t)))})),capabilities:i,modules:$r(e.modules),connections:[],policies:e.policies.map(e=>({name:e.name,resource:e.name,read:a(e.statements,`read`),write:a(e.statements,`write`),capabilities:[]})),ui:{routes:[],bindings:[],forms:[],dashboards:[]},environments:[`development`,`preview`,`staging`,`production`].map(e=>({name:e,configuration:{}})),artifacts:[],deployment:{environments:[`development`,`preview`,`staging`,`production`]},runtime:{contract:1,minimum_engine:`0.2.0`,maximum_engine_exclusive:`2.0.0`}}}function ri(e){let t=[],n=1;for(let r=0;r<e.length;){let i=e[r];if(i===`
|
|
16
|
+
`){t.push({value:`
|
|
17
|
+
`,line:n}),n++,r++;continue}if(/\s/.test(i)){r++;continue}if(e.startsWith(`//`,r)){for(;r<e.length&&e[r]!==`
|
|
18
|
+
`;)r++;continue}if(i===`"`){let i=`"`;for(r++;r<e.length;){let t=e[r++];if(i+=t,t===`\\`&&r<e.length)i+=e[r++];else if(t===`"`)break}t.push({value:i,line:n});continue}let a=e.slice(r,r+2);if(a===`->`){t.push({value:a,line:n}),r+=2;continue}if(`{}():?,`.includes(i)){t.push({value:i,line:n}),r++;continue}let o=``;for(;r<e.length&&!/\s/.test(e[r])&&!`{}():?,`.includes(e[r]);)o+=e[r++];t.push({value:o,line:n})}return t}var ii=class{tokens;index=0;constructor(e){this.tokens=e}peek(e){return this.index<this.tokens.length&&(e===void 0||this.tokens[this.index].value===e)}take(e){let t=this.tokens[this.index++];if(!t||e&&t.value!==e)throw Error(`Expected ${e??`token`} at line ${t?.line??`EOF`}`);return t}newlines(){for(;this.peek(`
|
|
19
|
+
`);)this.take()}identifier(){let e=this.take();if(!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(e.value))throw Error(`Invalid identifier ${e.value} at line ${e.line}`);return e.value}line(){let e=[];for(;this.peek()&&!this.peek(`
|
|
20
|
+
`)&&!this.peek(`}`);)e.push(this.take().value);return this.newlines(),e.join(` `).replace(/\s+([,?)])/g,`$1`).replace(/\s+\(/g,`(`).replace(/([(])\s+/g,`$1`).trim()}statements(){this.take(`{`),this.newlines();let e=[];for(;!this.peek(`}`);){let t=this.line();if(t)e.push(t);else if(!this.peek())throw Error(`Unclosed block`)}return this.take(`}`),this.newlines(),e}parse(){this.newlines();let e=1;if(this.peek(`flow_version`)){this.take(`flow_version`);let t=this.take();if(!/^\d+$/.test(t.value))throw Error(`Invalid flow_version ${t.value} at line ${t.line}`);let n=Number(t.value);if(n!==1)throw Error(`Unsupported flow_version ${n}; this SDK supports flow_version 1`);e=1,this.newlines()}this.take(`app`);let t=this.identifier();this.take(`{`),this.newlines();let n={version:e,app:t,collections:[],capabilities:[],agents:[],workflows:[],triggers:[],policies:[],schedules:[],modules:[]};for(;!this.peek(`}`);){let e=this.take().value;if(e===`collection`)n.collections.push(this.collection());else if(e===`module`){let e=this.identifier(),t=this.statements(),r=t.find(e=>e.startsWith(`provider `))?.slice(9),i=t.find(e=>e.startsWith(`version `))?.slice(8);if(!r)throw Error(`Module ${e} requires provider`);n.modules.push({name:e,provider:r.replace(/^"|"$/g,``),version:i?.replace(/^"|"$/g,``)})}else if(e===`workflow`)n.workflows.push(this.workflow());else if(e===`trigger`)n.triggers.push(this.trigger());else if([`capability`,`agent`,`policy`,`schedule`].includes(e)){let t={name:this.identifier(),statements:this.statements()};e===`capability`?n.capabilities.push(t):e===`agent`?n.agents.push(t):e===`policy`?n.policies.push(t):n.schedules.push(t)}else throw Error(`Unknown declaration ${e} at line ${this.tokens[this.index-1].line}`);this.newlines()}if(this.take(`}`),this.newlines(),this.peek())throw Error(`Unexpected token ${this.take().value}`);return n}collection(){let e=this.identifier();this.take(`{`),this.newlines();let t=[],n=[];for(;!this.peek(`}`);){let e=this.identifier();if(e===`index`){let e=this.identifier();this.take(`using`);let t=this.identifier(),r=this.line();n.push({name:e,kind:t,expression:r})}else{this.take(`:`);let n=[];for(;this.peek()&&!this.peek(`
|
|
21
|
+
`)&&!this.peek(`}`);)n.push(this.take().value);this.newlines();let r=!1;n.at(-1)===`?`&&(r=!0,n.pop());let i=n.join(` `).replace(/\s+([,)])/g,`$1`).replace(/([(])\s+/g,`$1`).replace(/^enum\s+\(/,`enum(`).replace(/,\s+/g,`,`);t.push({name:e,type:i,optional:r})}}return this.take(`}`),this.newlines(),{name:e,fields:t,indexes:n}}workflow(){let e=this.identifier(),t=``;if(this.peek(`(`)){this.take();let e=[];for(;!this.peek(`)`);)e.push(this.take().value);this.take(`)`),t=e.join(` `).replace(/\s+([,])/g,`$1`)}this.take(`{`),this.newlines();let n=[];for(;!this.peek(`}`);){this.take(`step`);let e=this.identifier();n.push({name:e,statements:this.statements()})}return this.take(`}`),this.newlines(),{name:e,parameters:t,steps:n}}trigger(){this.take(`on`);let e=[];for(;!this.peek(`{`);)e.push(this.take().value);return{event:e.join(` `),statements:this.statements()}}};function ai(e){return new ii(ri(e)).parse()}function U(e){let t=[],n=(e,n)=>n.filter((e,t)=>n.indexOf(e)!==t).forEach(n=>t.push({severity:`error`,message:`Duplicate ${e}: ${n}`}));n(`collection`,e.collections.map(e=>e.name)),n(`capability`,e.capabilities.map(e=>e.name)),n(`agent`,e.agents.map(e=>e.name)),n(`workflow`,e.workflows.map(e=>e.name)),n(`module`,(e.modules??[]).map(e=>e.name));let r=[];try{r=$r(e.modules)}catch(e){t.push({severity:`error`,path:`modules`,message:e instanceof Error?e.message:String(e)})}for(let n of e.capabilities){let e=n.statements.find(e=>e.startsWith(`visibility `))?.slice(11);e&&![`public`,`agent`,`workflow`,`internal`].includes(e)&&t.push({severity:`error`,path:`capability ${n.name}`,message:`Unsupported capability visibility ${e}`})}let i=new Set(e.collections.map(e=>e.name));for(let a of e.collections){n(`field in ${a.name}`,a.fields.map(e=>e.name));for(let e of a.fields)if(ti(e.type)||t.push({severity:`error`,path:`${a.name}.${e.name}`,message:`Unsupported field type ${e.type}`}),e.type.startsWith(`ref `)){let n=e.type.slice(4),[o,s]=n.split(`.`),c=s&&r.some(e=>e.id===o&&e.models.some(e=>e.name===s));!i.has(n)&&!c&&t.push({severity:`error`,path:`${a.name}.${e.name}`,message:`Unknown referenced collection or module model ${n}`})}}for(let r of e.workflows)n(`step in ${r.name}`,r.steps.map(e=>e.name)),r.steps.length||t.push({severity:`error`,message:`Workflow ${r.name} has no steps`});for(let n of e.triggers){let e=n.event.split(`.`)[0],i=r.find(t=>t.id===e);e&&n.event.split(`.`).length>=3&&!i?t.push({severity:`error`,path:`trigger ${n.event}`,message:`Module event ${n.event} requires module ${e}`}):i&&!i.events.includes(n.event)&&t.push({severity:`error`,path:`trigger ${n.event}`,message:`Unknown ${e} module event ${n.event}`})}return t}function oi(e,t,n=` `){return`${n}${e} ${t.name} {\n${t.statements.map(e=>`${n} ${e}`).join(`
|
|
22
|
+
`)}\n${n}}`}function si(e){let t=[];for(let n of e.collections)t.push(` collection ${n.name} {\n${n.fields.map(e=>` ${e.name}: ${e.type}${e.optional?`?`:``}`).concat(n.indexes.map(e=>` index ${e.name} using ${e.kind} ${e.expression}`)).join(`
|
|
23
|
+
`)}\n }`);for(let n of e.capabilities)t.push(oi(`capability`,n));for(let n of e.agents)t.push(oi(`agent`,n));for(let n of e.workflows)t.push(` workflow ${n.name}${n.parameters?`(${n.parameters})`:``} {\n${n.steps.map(e=>` step ${e.name} {\n${e.statements.map(e=>` ${e}`).join(`
|
|
24
|
+
`)}\n }`).join(`
|
|
25
|
+
`)}\n }`);for(let n of e.triggers)t.push(` trigger on ${n.event} {\n${n.statements.map(e=>` ${e}`).join(`
|
|
26
|
+
`)}\n }`);for(let n of e.policies)t.push(oi(`policy`,n));for(let n of e.schedules)t.push(oi(`schedule`,n));for(let n of e.modules??[])t.push(` module ${n.name} {\n provider ${n.provider}\n${n.version?` version ${n.version}\n`:``} }`);return`flow_version ${e.version}\n\napp ${e.app} {\n${t.join(`
|
|
27
|
+
|
|
28
|
+
`)}\n}\n`}function ci(e,t){let n=e=>new Map([...e.collections.map(e=>[`collection ${e.name}`,JSON.stringify(e)]),...e.capabilities.map(e=>[`capability ${e.name}`,JSON.stringify(e)]),...e.agents.map(e=>[`agent ${e.name}`,JSON.stringify(e)]),...e.workflows.map(e=>[`workflow ${e.name}`,JSON.stringify(e)]),...e.triggers.map(e=>[`trigger ${e.event}`,JSON.stringify(e)]),...e.policies.map(e=>[`policy ${e.name}`,JSON.stringify(e)]),...e.schedules.map(e=>[`schedule ${e.name}`,JSON.stringify(e)]),...(e.modules??[]).map(e=>[`module ${e.name}`,JSON.stringify(e)])]),r=n(e),i=n(t);return{added:[...i.keys()].filter(e=>!r.has(e)),removed:[...r.keys()].filter(e=>!i.has(e)),changed:[...i.keys()].filter(e=>r.has(e)&&r.get(e)!==i.get(e))}}function li(e,t){let n=[],r=new Map(e.collections.map(e=>[e.name,e])),i=new Map(t.collections.map(e=>[e.name,e]));for(let[e,t]of i){let i=r.get(e);if(!i){n.push({kind:`add`,target:`collection ${e}`,safety:`safe`,detail:`Create collection model`});continue}let a=new Map(i.fields.map(e=>[e.name,e])),o=new Map(t.fields.map(e=>[e.name,e]));for(let[t,r]of o){let i=a.get(t);i?(i.type!==r.type||i.optional!==r.optional)&&n.push({kind:`change`,target:`${e}.${t}`,safety:`requires_transform`,detail:`${i.type}${i.optional?`?`:``} → ${r.type}${r.optional?`?`:``}`}):n.push({kind:`add`,target:`${e}.${t}`,safety:r.optional?`safe`:`requires_transform`,detail:r.optional?`Add optional field`:`Required field needs a backfill`})}for(let t of a.keys())o.has(t)||n.push({kind:`remove`,target:`${e}.${t}`,safety:`destructive`,detail:`Field is no longer declared`})}for(let e of r.keys())i.has(e)||n.push({kind:`remove`,target:`collection ${e}`,safety:`destructive`,detail:`Collection model is no longer declared`});let a=ci(e,t);for(let e of a.added.filter(e=>!e.startsWith(`collection `)))n.push({kind:`add`,target:e,safety:`safe`,detail:`Deploy application primitive`});for(let e of a.changed.filter(e=>!e.startsWith(`collection `)))n.push({kind:`change`,target:e,safety:`safe`,detail:`Version application primitive`});for(let e of a.removed.filter(e=>!e.startsWith(`collection `)))n.push({kind:`remove`,target:e,safety:`destructive`,detail:`Application primitive is no longer declared`});return n}function ui(e=`MyApp`){return{version:1,app:e,collections:[],capabilities:[],agents:[],workflows:[],triggers:[],policies:[],schedules:[],modules:[]}}var di=class{value;listeners=new Set;constructor(e=`offline`){this.value=e}subscribe(e){return this.listeners.add(e),e(this.value),()=>this.listeners.delete(e)}set(e){this.value=e;for(let t of this.listeners)t(e)}get(){return this.value}},fi=class{config;status=new di;fetcher;sessionId;cursor;error;timer;constructor(e){this.config=e,this.fetcher=e.fetcher||fetch,this.restore()}key(){return`feltdb:sync:v1:${this.config.device.application_id}:${this.config.device.device_id}`}restore(){if(!(typeof localStorage>`u`))try{let e=JSON.parse(localStorage.getItem(this.key())||`{}`);this.sessionId=e.sessionId,this.cursor=e.cursor,this.error=e.error}catch{}}persist(){typeof localStorage<`u`&&localStorage.setItem(this.key(),JSON.stringify({sessionId:this.sessionId,cursor:this.cursor,error:this.error,outbox:this.readOutbox()}))}readOutbox(){if(typeof localStorage>`u`)return[];try{return JSON.parse(localStorage.getItem(`${this.key()}:outbox`)||`[]`)}catch{return[]}}writeOutbox(e){typeof localStorage<`u`&&localStorage.setItem(`${this.key()}:outbox`,JSON.stringify(e))}async request(e,t){let n=await this.fetcher(`${this.config.endpoint||``}/v1/sync/${e}`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`sync ${e} failed (${n.status})`);return r}async start(){this.status.set(`connecting`);try{if(!this.sessionId){let e={resources:this.config.scope.resources||this.config.scope.collections?.map(e=>`flow://${this.config.device.application_id}/${e}/*`)||[],fields:this.config.scope.fields||{}},t=await this.request(`session`,{device:{...this.config.device,created_at:Math.floor(Date.now()/1e3)},scope:e,offline_grant:this.config.offlineGrant});this.sessionId=t.session_id,this.cursor=t.cursor,this.persist()}return await this.flush(),this.timer=setInterval(()=>void this.flush(),5e3),this}catch(e){throw this.error=String(e),this.status.set(`degraded`),this.persist(),e}}async stop(){this.timer&&clearInterval(this.timer),this.sessionId&&await this.request(`close`,{session_id:this.sessionId}),this.status.set(`offline`)}enqueue(e){let t=this.readOutbox();return t.some(t=>t.operation_id===e.operation_id)||(t.push(e),this.writeOutbox(t)),e.operation_id}async flush(){if(!(!this.sessionId||!this.cursor)){this.status.set(`syncing`);try{let e=this.readOutbox();if(e.length){let t=await this.request(`push`,{session_id:this.sessionId,operations:e}),n=new Set([...t.acknowledgements.map(e=>e.operation_id),...t.rejections.filter(e=>!e.retryable).map(e=>e.operation_id)]);this.writeOutbox(e.filter(e=>!n.has(e.operation_id))),this.cursor=t.cursor}let t=await this.request(`pull`,{session_id:this.sessionId,cursor:this.cursor,limit:250});this.cursor=t.cursor,await this.request(`ack`,{session_id:this.sessionId,cursor:this.cursor}),this.error=void 0,this.status.set(`synced`),this.persist()}catch(e){this.error=String(e),this.status.set(typeof navigator<`u`&&!navigator.onLine?`offline`:`degraded`),this.persist()}}}pending(){return this.readOutbox()}conflicts(){return this.readOutbox().filter(e=>e.status===`CONFLICTED`)}lastCursor(){return this.cursor}lastError(){return this.error}},pi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`,...t?.headers||{}},...t}),r=n.status===204?void 0:await n.json();if(!n.ok)throw Error(r?.error||`Workload request failed (${n.status})`);return r}create(e){return this.json(`/v1/workloads`,{method:`POST`,body:JSON.stringify({...e,created_at:e.created_at||Math.floor(Date.now()/1e3)})})}list(e){return this.json(`/v1/workloads?application_id=${encodeURIComponent(e)}`)}inspect(e){return this.json(`/v1/workloads/${encodeURIComponent(e)}`)}claim(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/claim`,{method:`POST`,body:JSON.stringify(t)})}start(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/start`,{method:`POST`,body:JSON.stringify(t)})}heartbeat(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/heartbeat`,{method:`POST`,body:JSON.stringify(t)})}checkpoint(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/checkpoint`,{method:`POST`,body:JSON.stringify(t)})}complete(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/complete`,{method:`POST`,body:JSON.stringify(t)})}fail(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/fail`,{method:`POST`,body:JSON.stringify(t)})}confirmCancelled(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/cancelled`,{method:`POST`,body:JSON.stringify(t)})}executionContext(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/context`,{method:`POST`,body:JSON.stringify(t)})}cancel(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/cancel`,{method:`POST`,body:JSON.stringify({grant:t})})}retry(e,t){return this.json(`/v1/workloads/${encodeURIComponent(e)}/retry`,{method:`POST`,body:JSON.stringify({grant:t})})}history(e){return this.json(`/v1/workloads/${encodeURIComponent(e)}/history`)}result(e){return this.json(`/v1/workloads/${encodeURIComponent(e)}/result`)}},mi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`,...t?.headers||{}},...t}),r=n.status===204?void 0:await n.json();if(!n.ok)throw Error(r?.error||`Mesh request failed (${n.status})`);return r}},hi=class extends mi{register(e){return this.json(`/v1/workers/register`,{method:`POST`,body:JSON.stringify({...e,registered_at:e.registered_at||Math.floor(Date.now()/1e3)})})}list(e){return this.json(`/v1/workers?application_id=${encodeURIComponent(e)}`)}inspect(e){return this.json(`/v1/workers/${encodeURIComponent(e)}`)}heartbeat(e,t,n){return this.json(`/v1/workers/${encodeURIComponent(e)}/heartbeat`,{method:`POST`,body:JSON.stringify({heartbeat:t,grant:n})})}drain(e,t){return this.json(`/v1/workers/${encodeURIComponent(e)}/drain`,{method:`POST`,body:JSON.stringify({grant:t})})}recover(e,t){return this.json(`/v1/workers/${encodeURIComponent(e)}/recover`,{method:`POST`,body:JSON.stringify({grant:t})})}reconcile(e,t,n){return this.json(`/v1/workers/${encodeURIComponent(e)}/reconcile`,{method:`POST`,body:JSON.stringify({reconciliation:t,grant:n})})}},gi=class extends mi{list(e){return this.json(`/v1/worker-pools?application_id=${encodeURIComponent(e)}`)}create(e,t){return this.json(`/v1/worker-pools`,{method:`POST`,body:JSON.stringify({pool:e,grant:t})})}inspect(e){return this.json(`/v1/worker-pools/${encodeURIComponent(e)}`)}},_i=class extends mi{async status(e){let[t,n]=await Promise.all([new hi(this.baseUrl,this.fetcher).list(e),new gi(this.baseUrl,this.fetcher).list(e)]);return{workers:t.workers,pools:n.pools,ready:t.workers.filter(e=>e.lifecycle===`READY`).length,busy:t.workers.filter(e=>e.lifecycle===`BUSY`).length}}eligibleWorkers(e){return this.json(`/v1/workloads/${encodeURIComponent(e)}/eligible-workers`)}},vi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,...t}),r=await n.json();if(!n.ok)throw Error(r?.error||`Artifact request failed (${n.status})`);return r}async create(e){let t=new URLSearchParams({application_id:e.applicationId,kind:typeof e.kind==`string`?e.kind:`OTHER(${e.kind.OTHER})`,name:e.name,content_type:e.contentType,producer_kind:e.producerKind||`human`,producer_id:e.producerId||``});for(let n of e.parents||[])t.append(`parents`,n);for(let[n,r]of Object.entries({supersedes:e.supersedes,revision:e.revision,workload:e.workload,execution:e.execution}))r&&t.set(n,r);return this.json(`/v1/artifacts?${t}`,{method:`POST`,headers:{"content-type":e.contentType},body:(e.content instanceof Blob||e.content instanceof Uint8Array,e.content)})}list(e){return this.json(`/v1/artifacts?application_id=${encodeURIComponent(e)}`)}get(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}`)}async content(e){let t=await this.fetcher(`${this.baseUrl}/v1/artifacts/${encodeURIComponent(e)}/content`,{credentials:`include`});if(!t.ok)throw Error(`Artifact content failed (${t.status})`);return new Uint8Array(await t.arrayBuffer())}provenance(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}/provenance`)}parents(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}/parents`)}children(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}/children`)}archive(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}/archive`,{method:`POST`})}restore(e){return this.json(`/v1/artifacts/${encodeURIComponent(e)}/restore`,{method:`POST`})}},yi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`},...t}),r=await n.json();if(!n.ok)throw Error(r?.error||`Bundle request failed (${n.status})`);return r}export(e,t={}){return this.json(`/v1/bundles/export`,{method:`POST`,body:JSON.stringify({application_id:e,options:t})})}inspect(e){return this.json(`/v1/bundles/${encodeURIComponent(e)}`)}verify(e){return this.json(`/v1/bundles/${encodeURIComponent(e)}/verify`,{method:`POST`})}planImport(e,t,n,r){return this.json(`/v1/bundles/import/plan`,{method:`POST`,body:JSON.stringify({bundle:e,mode:t,destination_tenant:n,destination_application:r})})}import(e,t,n,r){return this.json(`/v1/bundles/import/apply`,{method:`POST`,body:JSON.stringify({bundle:e,mode:t,destination_tenant:n,destination_application:r})})}},bi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`},...t}),r=await n.json();if(!n.ok)throw Error(r?.error||`Release request failed (${n.status})`);return r}create(e){return this.json(`/v1/releases`,{method:`POST`,body:JSON.stringify({manifest:e})})}list(e){return this.json(`/v1/releases?application_id=${encodeURIComponent(e)}`)}get(e){return this.json(`/v1/releases/${encodeURIComponent(e)}`)}verify(e){return this.json(`/v1/releases/${encodeURIComponent(e)}/verify`,{method:`POST`})}promote(e,t,n){return this.json(`/v1/releases/${encodeURIComponent(e)}/promote`,{method:`POST`,body:JSON.stringify({application_id:t,environment:n})})}plan(e,t,n){return this.json(`/v1/deployments/plan`,{method:`POST`,body:JSON.stringify({release_id:e,environment:t,rollback_target:n})})}deploy(e){return this.json(`/v1/deployments`,{method:`POST`,body:JSON.stringify({plan:e})})}status(e){return this.json(`/v1/deployments/${encodeURIComponent(e)}`)}health(e){return this.json(`/v1/deployments/${encodeURIComponent(e)}/health`)}stop(e){return this.json(`/v1/deployments/${encodeURIComponent(e)}/stop`,{method:`POST`})}},xi=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`},...t}),r=await n.json();if(!n.ok)throw Error(r?.error||`Observe request failed (${n.status})`);return r}events(e){return this.json(`/v1/observability/events?application_id=${encodeURIComponent(e)}`)}cause(e){return this.json(`/v1/observability/causes/${encodeURIComponent(e)}`)}workload(e){return this.json(`/v1/observability/workloads/${encodeURIComponent(e)}/timeline`)}execution(e){return this.json(`/v1/observability/executions/${encodeURIComponent(e)}/timeline`)}revision(e){return this.json(`/v1/observability/revisions/${encodeURIComponent(e)}/timeline`)}append(e){return this.json(`/v1/observability/events`,{method:`POST`,body:JSON.stringify({event:e})})}},Si=class{baseUrl;fetcher;constructor(e=``,t=fetch){this.baseUrl=e,this.fetcher=t}async json(e,t){let n=await this.fetcher(`${this.baseUrl}${e}`,{credentials:`include`,headers:{"content-type":`application/json`},...t}),r=await n.json();if(!n.ok)throw Error(r?.error||`Provider request failed (${n.status})`);return r}list(){return this.json(`/v1/providers`)}inspect(e){return this.json(`/v1/providers/${encodeURIComponent(e)}`)}install(e,t,n){return this.json(`/v1/providers`,{method:`POST`,body:JSON.stringify({manifest:e,tenant_id:t,application_id:n})})}enable(e){return this.status(e,`ENABLED`)}disable(e){return this.status(e,`DISABLED`)}revoke(e){return this.status(e,`REVOKED`)}status(e,t){return this.json(`/v1/providers/${encodeURIComponent(e)}/status`,{method:`POST`,body:JSON.stringify({status:t})})}health(e){return this.json(`/v1/providers/${encodeURIComponent(e)}/health`)}dependencies(e){return this.json(`/v1/providers/${encodeURIComponent(e)}/dependencies`)}};function Ci(e){return Array.isArray(e)?e.map(Ci):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Ci(t)])):e}function wi(e){return new TextEncoder().encode(JSON.stringify(Ci(e)))}async function Ti(e){let t=wi(e),n=await crypto.subtle.digest(`SHA-256`,t.slice().buffer);return`sha256:${Array.from(new Uint8Array(n),e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function Ei(e,t,n){if(e.version!==1)throw Error(`Unsupported flow_version ${e.version}; this SDK supports flow_version 1`);let r=ni(e,t,n),[i,a,o,s,c,l]=await Promise.all([Ti({collections:r.collections,indexes:r.indexes,references:r.references}),Ti(r.policies),Ti({workflows:r.workflows,triggers:r.triggers,schedules:r.schedules}),Ti(r.agents),Ti(r.capabilities),Ti(r.modules??[])]),u=await Ti({dsl_version:e.version,manifest:r});return{application_id:n,tenant_id:t,schema_version:r.schema,dsl_version:e.version,manifest:r,hashes:{model:i,authorization:a,workflows:o,agents:s,capabilities:c,modules:l,application:u}}}function Di(e){let t=/^\s*implement\s+([a-z0-9][a-z0-9-]*)\s*[.!]?\s*$/i.exec(e),n=/^\s*(?:add|support|enable)\b.+\b(?:billing|plan|subscription)\b.*$/i.test(e);if(!t&&!n)return;let r=t?t[1].toLowerCase():`billing`,i=Qr(r);if(!i.length)throw Error(`MODULE_NOT_AVAILABLE: ${r}. No proposal created. Available modules: ${Xr().map(e=>e.id).join(`, `)}`);if(i.length>1)throw Error(`AMBIGUOUS_MODULE_INTENT: ${r}. Available providers: ${i.map(e=>e.provider).join(`, `)}`);let a=i[0];return{action:t?`implement`:`extend`,module:a.id,provider:a.provider,version:a.version,original:e}}function Oi(e,t){let n=new Set(e.collections.map(e=>e.name));for(let e of t.patterns)for(let t of e.owner_candidates)if(n.has(t))return t;return e.collections.find(e=>/user|account|member/i.test(e.name))?.name??e.collections[0]?.name??`User`}function ki(e,t,n){let r=Zr({name:e.module,provider:e.provider,version:e.version}),i=ai(n),a=Oi(i,r),o=!!i.modules?.some(e=>e.name===r.id),s=r.patterns.find(e=>e.owner_candidates.includes(a))??r.patterns[0],c=new Set(i.triggers.map(e=>e.event)),l=new Set(i.workflows.map(e=>e.name));return{intent:e,module:r,alreadyInstalled:o,owner:a,applicationModels:s.application_models,relationships:[`BillingAccount.owner -> ${a}`,`BillingAccount.customer -> ${r.id}.Customer`,`BillingAccount.subscription -> ${r.id}.Subscription`,`Entitlement.billing_account -> BillingAccount`],events:r.reconciliation.map(e=>e.event).filter(e=>!c.has(e)),workflows:r.reconciliation.map(e=>e.workflow).filter(e=>!l.has(e)),capabilities:[`stripe.checkout.create`,`stripe.subscription.read`,`stripe.subscription.cancel`].filter(e=>r.capabilities.includes(e)),authorization:r.authorization,configuration:r.configuration.map(e=>e.name),secrets:r.secrets.map(e=>e.name),stateFlow:[`${r.id}.subscription.updated`,`ReconcileSubscription`,`BillingAccount`,`Entitlement`],warnings:[`Production webhook configuration and signature verification required`]}}async function Ai(e){let t=await crypto.subtle.digest(`SHA-256`,e.slice().buffer);return`sha256:${Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}`}function ji(e,t={}){let n=e.manifest;return{application:{application_id:e.application_id,environment:t.environment??`local`},contract_version:t.contractVersion??e.schema_version,contract_hash:e.hashes.application,dsl_version:e.dsl_version,schema:n.collections,indexes:n.indexes,policies:n.policies,workflows:n.workflows,agents:n.agents,capabilities:n.capabilities,modules:n.modules??[],supported_primitives:ei}}function Mi(e){return new TextDecoder().decode(wi(e))}async function Ni(e){return Ai(new TextEncoder().encode(e.replace(/\r\n/g,`
|
|
29
|
+
`)))}var Pi=`FeltDB FlowSpec v1 reference:
|
|
30
|
+
- One document: flow_version 1, then app Name { ... }.
|
|
31
|
+
- collection Name { field: primitive; optional fields append ?; references use ref Collection; indexes use index name using hash(field) }.
|
|
32
|
+
- capability Name { visibility public|internal|agent; read Collection; write Collection }.
|
|
33
|
+
- module Name { provider provider-name; version exact-semver }. Module-qualified references use ref module.Model.
|
|
34
|
+
- workflow Name { step step_name { read Collection | write Collection | capability CapabilityName } }.
|
|
35
|
+
- agent Name { capability CapabilityName; workflow WorkflowName }.
|
|
36
|
+
- policy Collection { read: expression; write: expression }. Preserve existing authorization unless the request explicitly requires a change.
|
|
37
|
+
- Valid policy examples include authenticated, member, owner, self(field), and alternatives joined with |.
|
|
38
|
+
- Every referenced collection, capability, and workflow must be declared. Names are case-sensitive.
|
|
39
|
+
- Use only supported_primitives from the supplied snapshot. Do not invent UI, deployment, record data, secrets, or executable implementation syntax.
|
|
40
|
+
- Make the smallest semantic change that satisfies the request and retain all unrelated declarations.`;function Fi(e,t,n){let r=Ii(n,e,t);return[{role:`system`,content:[`You propose minimal changes to a FeltDB application.`,`feltdb.flow is authoritative. Preserve every unrelated declaration verbatim in meaning.`,`Generate flow_version ${e.dsl_version} only. Never invent unsupported primitives.`,`Return only JSON with: proposedFlow, summary, changes, warnings.`,`The proposedFlow value must contain the complete resulting document, not a patch or excerpt.`,`Do not include application records, credentials, tokens, environment configuration, or deployment actions.`,Pi,`Current contract snapshot: ${Mi(e)}`,`Current feltdb.flow:\n${t}`,r?`Authoritative resolved module implementation context (fit these semantics to the application; do not invent or redefine module semantics):\n${r}`:``].join(`
|
|
41
|
+
|
|
42
|
+
`)},{role:`user`,content:n}]}function Ii(e,t,n){try{let r=Di(e);return r?JSON.stringify(ki(r,t,n)):void 0}catch(e){if(e instanceof Error&&(e.message.startsWith(`MODULE_NOT_AVAILABLE`)||e.message.startsWith(`AMBIGUOUS_MODULE_INTENT`)))throw e;return}}async function Li(e){let t=e.raw.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n;try{n=JSON.parse(t)}catch{throw Error(`The configured model returned an invalid flow proposal document`)}let r={baseContractHash:e.snapshot.contract_hash,baseFlowHash:await Ni(e.currentFlow),proposedFlow:String(n.proposedFlow??``),summary:String(n.summary??``),changes:Array.isArray(n.changes)?n.changes.map(String):[],warnings:Array.isArray(n.warnings)?n.warnings.map(String):[]},i=await zi({proposal:r,currentFlow:e.currentFlow,snapshot:e.snapshot});if(!e.allowDestructiveProposal&&(i.diff.removed.length||i.migration.some(e=>e.safety===`destructive`)))throw Error(`NON_MINIMAL_FLOW_PROPOSAL: generated change removes existing application semantics (${i.diff.removed.join(`, `)})`);return r}function Ri(e,t){let n=new Map(e.policies.map(e=>[e.name,e.statements])),r=new Map(t.policies.map(e=>[e.name,e.statements])),i=new Set([...n.keys(),...r.keys()]),a=/\b(public|any|anonymous|authenticated)\b/i;return[...i].flatMap(e=>{let t=n.get(e),i=r.get(e);if(JSON.stringify(t)===JSON.stringify(i))return[];let o=(i??[]).filter(e=>!(t??[]).includes(e));return[{policy:e,before:t,after:i,widening:!i||o.some(e=>a.test(e))}]})}async function zi(e){let t=await Ni(e.currentFlow);if(e.proposal.baseFlowHash!==t)throw Error(`STALE_FLOW_PROPOSAL: proposal is based on ${e.proposal.baseFlowHash}, current flow is ${t}`);if(e.proposal.baseContractHash!==e.snapshot.contract_hash)throw Error(`STALE_CONTRACT_PROPOSAL: proposal is based on ${e.proposal.baseContractHash}, current contract is ${e.snapshot.contract_hash}`);let n=ai(e.currentFlow),r=ai(e.proposal.proposedFlow);if(r.version!==e.snapshot.dsl_version)throw Error(`DSL_VERSION_MISMATCH: proposal uses ${r.version}, runtime requires ${e.snapshot.dsl_version}`);let i=U(r),a=i.filter(e=>e.severity===`error`);if(a.length)throw Error(`INVALID_FLOW_PROPOSAL: ${a.map(e=>e.message).join(`; `)}`);let o=await Ei(r,e.tenantId??`local`,e.snapshot.application.application_id);return{proposal:e.proposal,proposedSpec:r,proposedContract:o,diagnostics:i,diff:ci(n,r),migration:li(n,r),authorizationChanges:Ri(n,r)}}var Bi=()=>typeof window<`u`&&window.document!==void 0,Vi=e=>typeof process<`u`?{}[e]:void 0,Hi=()=>{try{let e=globalThis.crypto;if(typeof e?.randomUUID==`function`)return e.randomUUID()}catch{}let e=new Uint8Array(16),t=globalThis.crypto;if(typeof t?.getRandomValues==`function`)try{t.getRandomValues(e)}catch{for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256)}else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`},Ui=class{id=null;identityFile=null;getId(){if(this.id)return this.id;try{if(Bi()){let e=globalThis.localStorage?.getItem(`feltdb.install-id`);return this.id=e&&this.isValidUUID(e)?e:Hi(),globalThis.localStorage?.setItem(`feltdb.install-id`,this.id),this.id}return this.id=Hi(),this.id}catch{return this.id||=Hi(),this.id}}isValidUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}},Wi=class{identity;enabled;batchSize=10;eventQueue=[];flushTimer=null;coreVersion;runtime=`node`;constructor(e=`0.5.7`){this.coreVersion=e,this.identity=new Ui,this.enabled=Vi(`FELTDB_TELEMETRY`)!==`0`&&Vi(`FELTDB_TELEMETRY`)!==`false`,Bi()&&(this.runtime=`browser`)}emit(e){if(this.enabled)try{let t={event:e,installation_id:this.identity.getId(),core_version:this.coreVersion,runtime:this.runtime,os:this.getOS(),timestamp:new Date().toISOString()};this.eventQueue.push(t),this.eventQueue.length>=this.batchSize?this.flush():this.scheduleFlush()}catch{}}async flush(){if(this.eventQueue.length===0||!this.enabled)return;this.flushTimer&&=(clearTimeout(this.flushTimer),null);let e=this.eventQueue.splice(0,this.batchSize);try{await this.sendEvents(e)}catch{}}scheduleFlush(){this.flushTimer||!this.enabled||(this.flushTimer=setTimeout(()=>{this.flush().catch(()=>{})},5e3))}async sendEvents(e){let t=Vi(`FELTDB_TELEMETRY_ENDPOINT`)||`https://feltdb.com/api/v1/telemetry/events`,n=new AbortController,r=setTimeout(()=>n.abort(),3e3);try{(await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({events:e}),signal:n.signal})).ok}catch{}finally{clearTimeout(r)}}getOS(){if(Bi())return`browser`;let e=typeof process<`u`?process.platform:`unknown`;switch(e){case`darwin`:return`macos`;case`linux`:return`linux`;case`win32`:return`windows`;case`freebsd`:return`freebsd`;default:return e}}enable(){this.enabled=!0}disable(){this.enabled=!1,this.eventQueue=[],this.flushTimer&&=(clearTimeout(this.flushTimer),null)}isEnabled(){return this.enabled}async forceFlush(){for(;this.eventQueue.length>0;)await this.flush()}},W=null;function G(e){return W||=new Wi(e),W}function Gi(e){G().emit(e)}function Ki(){return`runtime_${globalThis.crypto?.randomUUID?.().replace(/-/g,``)??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}${Math.random().toString(36).slice(2)}`}`}function qi(){let e={};if(e?.FELTDB_DEV_SESSION_ID)return{sessionId:e.FELTDB_DEV_SESSION_ID,workspaceId:e.FELTDB_WORKSPACE_ID,namespace:e.FELTDB_NAMESPACE,runtime:e.FELTDB_RUNTIME,authorityUrl:e.FELTDB_AUTHORITY_URL||e.FELTDB_WORKSPACE_ENDPOINT,bridgeUrl:e.FELTDB_DEV_BRIDGE_URL,applicationUrl:e.FELTDB_APPLICATION_URL}}function Ji(e){try{let t=new URL(e);return t.protocol!==`http:`||![`127.0.0.1`,`localhost`,`::1`,`[::1]`].includes(t.hostname)?void 0:t.origin}catch{return}}function Yi(e){let t=Ki(),n,r,i,a=!1,o=!1,s=0,c=[],l=e.applicationId||globalThis.document?.title||{}.npm_package_name||`application`,u=async i=>{let a=i||qi(),o=a?.runtime===e.runtime||e.runtime===`remote`&&[`managed`,`self-hosted`,`remote`].includes(a?.runtime||``);if(!a||a.namespace!==e.namespace||!o)return;let s=Ji(a.bridgeUrl);if(!s)return;n={...a,bridgeUrl:s};let c={...n,runtimeInstanceId:t,applicationId:l};try{if(!(await fetch(`${s}/api/v1/development/runtime/register`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(c)})).ok)return;r||(r=setInterval(()=>{u(n)},2e3),r.unref?.())}catch{}},d=async()=>{if(a||!n||c.length===0)return;a=!0;let e=c.splice(0,32),r=s;s=0;try{if(!(await fetch(`${n.bridgeUrl}/api/v1/development/runtime/${encodeURIComponent(t)}/observations`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:n.sessionId,observations:e,dropped:r})})).ok)throw Error(`observation delivery failed`)}catch{if(!o){let t=256-c.length;c.unshift(...e.slice(Math.max(0,e.length-t))),s+=r+Math.max(0,e.length-t)}}finally{a=!1,c.length&&!o&&(i=setTimeout(()=>{i=void 0,d()},100),i.unref?.())}},f=e=>{!n||o||(c.length>=256?s++:c.push(e),!i&&!a&&(i=setTimeout(()=>{i=void 0,d()},0),i.unref?.()))},p={start(e,r={}){let i=`op_${Ki().slice(8)}`,a=Date.now(),o=(o,s,c)=>f({eventId:`evt_${Ki().slice(8)}`,correlationId:i,timestamp:Date.now(),workspaceId:n?.workspaceId,sessionId:n?.sessionId,runtimeInstanceId:t,operation:{type:e,collection:r.collection,transactionId:r.transactionId},status:o,durationMs:o===`started`?void 0:Date.now()-a,metadata:s||r.metadata,error:o===`failed`?{code:typeof c==`object`&&c&&`code`in c?String(c.code):void 0,message:(c instanceof Error?c.message:String(c)).slice(0,500)}:void 0});return o(`started`),{complete:e=>o(`completed`,e),fail:e=>o(`failed`,void 0,e)}}},m=globalThis.window,h=e=>{e.source===m?.parent&&e.data?.type===`feltdb:dev-session`&&u(e.data.session)};m?.addEventListener?.(`message`,h),u();let g=async()=>{for(o=!0,r&&clearInterval(r),i&&clearTimeout(i);c.length;)await d();if(m?.removeEventListener?.(`message`,h),n)try{await fetch(`${n.bridgeUrl}/api/v1/development/runtime/${encodeURIComponent(t)}?sessionId=${encodeURIComponent(n.sessionId)}`,{method:`DELETE`,keepalive:!0})}catch{}};return m?.addEventListener?.(`pagehide`,()=>{g()},{once:!0}),{runtimeInstanceId:t,observation:p,close:g}}async function Xi(e,t){let n=Uint8Array.from(t.match(/../g)||[],e=>parseInt(e,16)),r=new TextEncoder().encode(e),i=await crypto.subtle.importKey(`raw`,r.slice().buffer,`PBKDF2`,!1,[`deriveBits`]),a=await crypto.subtle.deriveBits({name:`PBKDF2`,salt:n.slice().buffer,iterations:21e4,hash:`SHA-256`},i,256);return Array.from(new Uint8Array(a),e=>e.toString(16).padStart(2,`0`)).join(``)}function Zi(e=32){let t=crypto.getRandomValues(new Uint8Array(e));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function Qi(e){if(!e?.namespace?.trim())throw Error(`createFeltDB requires a non-empty namespace`);let t=e.server?new H(e.server):`browser`in e&&e.browser?new Wr(e.namespace):`path`in e&&e.path?qr(`file`,e.path,`createFeltDB({ path }) needs the Node file runtime, which is not available here. In a browser use createFeltDB({ browser: true }); in Node import "@feltdb/core" rather than a browser-conditioned build.`):new Vr(e.namespace),n=e.server?`remote`:`browser`in e&&e.browser?`browser`:`path`in e?`node`:`memory`,r=Yi({namespace:e.namespace,runtime:n});return new ta(ea(t,r.observation),r.observation,r.close)}var $i=new Set([`get`,`query`,`insert`,`update`,`delete`,`cas`,`putIfAbsent`,`export_operations`,`apply_operations`,`sync`]);function ea(e,t){return new Proxy(e,{get(e,n,r){let i=Reflect.get(e,n,r);if(typeof n!=`string`||typeof i!=`function`)return i;let a=i.bind(e);return $i.has(n)?(...e)=>{let r=typeof e[0]==`string`?e[0]:void 0,i=t.start(n,{collection:r?.includes(`:`)?r.split(`:`,1)[0]:void 0});try{let t=a(...e);return Promise.resolve(t).then(e=>(i.complete(),e),e=>{throw i.fail(e),e})}catch(e){throw i.fail(e),e}}:a}})}var ta=class{jsDb;collections=new Map;cells=new Map;runtimeInfo;agentRegistry;agentRuntime;capabilityWorkers=new Map;observation;closeDevelopmentBridge;localActorSession;workloads=new pi;artifacts=new vi;bundle=new yi;releases=new bi;observe=new xi;providers=new Si;workers=new hi;workerPools=new gi;mesh=new _i;workflows={run:(e,t={},n={})=>this.applicationRequest(`/workflows/${encodeURIComponent(e)}/run`,{method:`POST`,headers:n.idempotencyKey?{"Idempotency-Key":n.idempotencyKey}:{},body:JSON.stringify({input:t})})};agents={run:(e,t={},n={})=>this.applicationRequest(`/agents/${encodeURIComponent(e)}/run`,{method:`POST`,headers:n.idempotencyKey?{"Idempotency-Key":n.idempotencyKey}:{},body:JSON.stringify({goal:n.goal||e,input:t})})};capabilities={run:(e,t={},n={})=>this.applicationRequest(`/capabilities/${encodeURIComponent(e)}/run`,{method:`POST`,headers:n.idempotencyKey?{"Idempotency-Key":n.idempotencyKey}:{},body:JSON.stringify(t)})};application={get:async()=>{if(this.jsDb instanceof H)return this.applicationRequest(`/application`);let e=await this.collection(`_flow_apps`).all(),t=e.find(e=>e.status===`active`)??e[0];if(!t?.spec)throw Error(`No application contract has been deployed to this embedded runtime`);let n=await Ei(t.spec,`local`,t.app);return{application_id:t.app,environment:`local`,version:t.version??1,contract_hash:n.hashes.application,dsl_version:n.dsl_version,snapshot:ji(n,{environment:`local`,contractVersion:t.version??1})}}};schema={get:async()=>{let e=await this.applicationRequest(`/application`);return this.applicationRequest(`/schema?revision_id=${encodeURIComponent(e.revision_id)}`)}};auth={signUp:e=>this.authRequest(`signup`,e),signIn:e=>this.authRequest(`signin`,e),signOut:()=>this.authRequest(`signout`),session:()=>this.authRequest(`session`)};constructor(e,t,n){this.jsDb=e,this.observation=t,this.closeDevelopmentBridge=n,this.runtimeInfo=this.detectRuntime(),this.agentRegistry=new Ar;let r={persistent:this.runtimeInfo.persistent,executionTimeoutMs:3e4,supportsReactiveTriggers:!0,defaultRetryPolicy:{maxAttempts:3,backoffMs:1e3}};this.agentRuntime=new Mr(this.agentRegistry,r),Gi(`initialize`)}applicationRequest(e,t){return this.jsDb instanceof H?this.jsDb.application_request(e,t):Promise.reject(Error(`${e} requires an application service runtime; embedded collection and capability APIs remain available locally.`))}authRequest(e,t){return this.jsDb instanceof H?this.jsDb.auth_request(e,t):this.localAuthRequest(e,t)}async localAuthRequest(e,t){let n=this.collection(`_flow_local_identities`);if(e===`session`){if(!this.localActorSession||this.localActorSession.session.expires_at<=Date.now())throw Error(`Authentication required`);return this.localActorSession}if(e===`signout`)return this.localActorSession=void 0,{};let r=t?.email?.trim().toLowerCase(),i=t?.password||``;if(!r||i.length<8)throw Error(`email and a password of at least 8 characters are required`);let a=(await n.find({email:r}))[0];if(e===`signup`){if(a)throw Error(`identity already exists`);let e=Zi(16),o=`user_${Zi(12)}`;a={id:o,email:r,display_name:t?.display_name,salt:e,password_hash:await Xi(i,e),created_at:new Date().toISOString()},await n.insert(a,o)}else if(!a||a.password_hash!==await Xi(i,a.salt))throw Error(`invalid credentials`);let o={session_id:`session_${Zi(12)}`,expires_at:Date.now()+9e5};return this.localActorSession={access_token:`local_${Zi()}`,actor:{user_id:a.id,email:a.email,display_name:a.display_name},session:o},this.localActorSession}detectRuntime(){let e=typeof window<`u`&&typeof document<`u`,t=typeof process<`u`&&process.versions&&`node`in process.versions,n=this.jsDb instanceof Vr,r=this.jsDb instanceof H,i=this.jsDb instanceof Wr,a=`memory`,o=!1;return r?(a=`remote`,o=!0):n?a=`memory`:i?(a=`indexeddb`,o=!0):t&&(a=`file`,o=!0),{runtime:r?`remote`:i||e?`browser`:t?`node`:`wasm`,storage:a,persistent:o,reactive:!0,durable:o,version:`0.1.0`,supportsCheckpointing:o,supportsLifecycle:e||i}}runtime(){return{...this.runtimeInfo}}collection(e){return this.collections.has(e)||this.collections.set(e,new br(this.jsDb,e)),this.collections.get(e)}async query(e){if(!this.jsDb.authority_query)throw Error(`db.query() requires a remote FeltDB authority; embedded runtimes do not provide authority query semantics.`);return this.jsDb.authority_query(e)}async transaction(e,t={}){if(typeof e!=`function`){let n=e;return this.transaction(e=>{for(let t of n.preconditions??[])e.require(t);for(let t of n.operations){let n=e.collection(t.collection);t.value===void 0?n.delete(t.id,t):n.set(t.id,t.value,t)}},{...t,transactionId:n.transactionId??t.transactionId})}let n=new Tr(t.transactionId),r=this.observation?.start(`transaction`,{transactionId:n.transactionId});if(!this.jsDb.commit_transaction){let e=new xr(`This FeltDB runtime does not provide atomic transactions. Connect to a FeltDB authority (createFeltDB({ server: ... })) to use db.transaction(). FeltDB will not emulate a transaction with separate writes, because that would not be atomic.`,n.transactionId);throw r?.fail(e),e}try{await e(n)}catch(e){throw r?.fail(e),e}let i=n.seal();if(i.operations.length===0){let e=new xr(`a transaction requires at least one operation`,i.transactionId);throw r?.fail(e),e}try{let e=await this.jsDb.commit_transaction(i),t={transactionId:e.transactionId??i.transactionId,duplicate:!!e.duplicate,operations:e.operations??i.operations.length,stateBefore:e.stateBefore??0,stateAfter:e.stateAfter??0};return r?.complete({operations:t.operations,duplicate:t.duplicate}),t}catch(e){let t=e,n=t?.feltdbCode===`PRECONDITION_FAILED`?new Sr(e instanceof Error?e.message:String(e),i.transactionId,t.feltdbConflict):new xr(e instanceof Error?e.message:String(e),i.transactionId);throw r?.fail(n),n}}cell(e){return this.cells.has(e)||this.cells.set(e,new Dr(this.jsDb,e)),this.cells.get(e)}async acquire(e,t){return this.jsDb instanceof H?this.jsDb.acquire(e,t):this.collection(e).get(t)}async search(e,t,n=50){if(this.jsDb instanceof H)return this.jsDb.search(e,t,n);let r=t.toLowerCase();return(await this.collection(e).all()).filter(e=>JSON.stringify(e).toLowerCase().includes(r)).slice(0,n)}async defineCapability(e,t){if(!(this.jsDb instanceof H))throw Error(`Distributed capabilities require a server runtime`);return this.jsDb.command(`/capabilities/${encodeURIComponent(e)}`,{steps:t})}registerCapabilityWorker(e,t){if(this.jsDb instanceof H)throw Error(`Remote capability workers are installed on the server`);return this.capabilityWorkers.set(e,t),()=>this.capabilityWorkers.delete(e)}async executeCapability(e,t){if(this.jsDb instanceof H)return this.jsDb.command(`/capabilities/${encodeURIComponent(e)}/execute`,t);let n=this.capabilityWorkers.get(e);if(!n)throw Error(`No embedded capability worker registered for ${e}`);let r=`cap-${e}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,i=this.collection(`_flow_executions`);await i.insert({id:r,capability:e,input:t,status:`running`,owner:this.instanceId(),started_at:Date.now()},r);try{let e=await n(t);return await i.update(r,{status:`completed`,output:e,completed_at:Date.now()}),e}catch(e){throw await i.update(r,{status:`failed`,error:e instanceof Error?e.message:String(e),completed_at:Date.now()}),e}}async changeClusterMembership(e,t){if(!(this.jsDb instanceof H))throw Error(`Cluster membership requires a server runtime`);return this.jsDb.command(`/cluster/members`,{expected_epoch:e,peers:t})}async deployFlowSpec(e,t,n=!1){let r=U(e).filter(e=>e.severity===`error`);if(r.length)throw Error(r.map(e=>e.message).join(`; `));let i=this.collection(`_flow_apps`),a=await i.get(e.app),o=(a?.version??0)+1;if(t!==void 0&&(a?.version??0)!==t)throw Error(`FlowSpec version conflict: expected ${t}, found ${a?.version??0}`);let s=li(a?.spec??ui(e.app),e),c=s.filter(e=>e.safety===`destructive`);if(c.length&&!n)throw Error(`Destructive migration requires explicit approval: ${c.map(e=>e.target).join(`, `)}`);let l={id:e.app,app:e.app,version:o,status:`deploying`,spec:e,migration:s,deployed_at:Date.now()};a?await i.update(e.app,l):await i.insert(l,e.app);let u=(t,n)=>`${e.app}-${t}-${n}`.replace(/[^A-Za-z0-9_-]/g,`_`),d=async(t,n,r,i)=>{let a=this.collection(t),s=new Set(i.map(e=>e.name??e.event??`unnamed`));for(let e of r){let t=e.name??e.event??`unnamed`;s.has(t)||await a.delete(u(n,t))}for(let t of i){let r=t.name??t.event??`unnamed`,i=u(n,r),s={id:i,app:e.app,version:o,...t};await a.get(i)?await a.update(i,s):await a.insert(s,i)}},f=a?.spec??ui(e.app);if(await d(`_flow_collection_models`,`collection`,f.collections,e.collections),await d(`_flow_capability_models`,`capability`,f.capabilities,e.capabilities),await d(`_flow_trigger_models`,`trigger`,f.triggers,e.triggers),await d(`_flow_policy_models`,`policy`,f.policies,e.policies),await d(`_flow_schedule_models`,`schedule`,f.schedules,e.schedules),this.jsDb instanceof H){for(let t of f.workflows)e.workflows.some(e=>e.name===t.name)||await this.collection(`_flow_workflows`).delete(u(`workflow`,t.name));for(let t of f.agents)e.agents.some(e=>e.name===t.name)||await this.collection(`_flow_agents`).delete(u(`agent`,t.name));for(let t of e.workflows)await this.defineWorkflow(u(`workflow`,t.name),t.steps.map(e=>e.name));for(let t of e.agents){let n=t.statements.filter(e=>e.startsWith(`capability `)).map(e=>e.slice(11).trim());await this.defineStateAgent(u(`agent`,t.name),n,{flowspec_app:e.app,flowspec_version:o})}}else await d(`_flow_workflows`,`workflow`,f.workflows,e.workflows),await d(`_flow_agents`,`agent`,f.agents,e.agents);let p={...l,status:`active`};return await i.update(e.app,p),await this.collection(`_flow_app_versions`).insert({id:`${e.app}-${o}`,app:e.app,version:o,spec:e,migration:s,deployed_at:p.deployed_at},`${e.app}-${o}`),{app:e.app,version:o,status:`active`}}async auditEvents(){return this.jsDb.audit_events?await this.jsDb.audit_events():[]}async exportOperations(e=0){if(!this.jsDb.export_operations)throw Error(`This runtime uses server-managed replication`);return await this.jsDb.export_operations(e)}async applyOperations(e){if(!this.jsDb.apply_remote_operations)throw Error(`This runtime uses server-managed replication`);return await this.jsDb.apply_remote_operations(e)}async synchronizeWith(e){let t=await this.exportOperations(),n=await e.exportOperations();await this.addSyncPeer(e.instanceId()),await e.addSyncPeer(this.instanceId());let r=await e.applyOperations(t),i=await this.applyOperations(n);return{sent:t.length,received:n.length,applied:i.applied+r.applied,ignored:i.ignored+r.ignored}}async executeCapabilityWithFailover(e,t,n=[]){let r=this.collection(`_flow_capability_routes`),i=`route-${e}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,a=[this,...n],o=[];await r.insert({id:i,capability:e,status:`routing`,input:t,candidates:a.map(e=>e.instanceId()),started_at:Date.now()},i);for(let n of a)try{let a=await n.executeCapability(e,t);return await r.update(i,{status:`completed`,provider:n.instanceId(),attempts:o.length+1,failures:o,completed_at:Date.now()}),{output:a,provider:n.instanceId(),attempts:o.length+1}}catch(e){o.push({provider:n.instanceId(),error:e instanceof Error?e.message:String(e)})}throw await r.update(i,{status:`failed`,attempts:o.length,failures:o,completed_at:Date.now()}),Error(`No provider could execute capability ${e}: ${o.map(e=>e.error).join(`; `)}`)}async recordProvenance(e,t){if(!(this.jsDb instanceof H))throw Error(`Causal provenance requires a server runtime`);return this.jsDb.provenance(e,t)}async storeContent(e){if(!(this.jsDb instanceof H))throw Error(`Durable content storage requires a server runtime`);return this.jsDb.storeContent(e)}async acquireContent(e){if(!(this.jsDb instanceof H))throw Error(`Network content acquisition requires a server runtime`);return this.jsDb.acquireContent(e)}async defineWorkflow(e,t){if(!(this.jsDb instanceof H))throw Error(`Durable workflow coordination requires a server runtime`);return this.jsDb.command(`/workflows/${encodeURIComponent(e)}`,{steps:t})}async startWorkflow(e,t=null){if(!(this.jsDb instanceof H))throw Error(`Durable workflow coordination requires a server runtime`);return this.jsDb.command(`/workflows/${encodeURIComponent(e)}/runs`,{input:t})}async claimWorkflowStep(e,t,n,r=3e4){if(!(this.jsDb instanceof H))throw Error(`Durable workflow coordination requires a server runtime`);return this.jsDb.command(`/workflow-runs/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/claim`,{worker:n,lease_ms:r})}async completeWorkflowStep(e,t,n,r=null){if(!(this.jsDb instanceof H))throw Error(`Durable workflow coordination requires a server runtime`);return this.jsDb.command(`/workflow-runs/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/complete`,{claim_id:n,result:r})}async defineStateAgent(e,t=[],n=null){if(!(this.jsDb instanceof H))throw Error(`Durable agent coordination requires a server runtime`);return this.jsDb.command(`/agents/${encodeURIComponent(e)}`,{capabilities:t,constraints:n})}async startStateAgent(e,t,n=null){if(!(this.jsDb instanceof H))throw Error(`Durable agent coordination requires a server runtime`);return this.jsDb.command(`/agents/${encodeURIComponent(e)}/runs`,{goal:t,input:n})}defineAgent(e){let t=Or(e.name,e.version);return this.agentRegistry.register(t,e),t}agent(e){return this.agentRegistry.getByName(e)?.agentRef}getAgentRegistry(){return this.agentRegistry}getAgentRuntime(){return this.agentRuntime}async createAgentExecution(e,t,n){let r=await this.agentRuntime.createExecution(this,e,t,n);return await this.collection(`_flow_agent_executions`).insert(this.agentExecutionRecord(r),r.executionId),r}agentExecutionRecord(e){return{...e,id:e.executionId,agentRef:e.agentRef.toString()}}async startAgentExecution(e,t=this.instanceId()){await this.agentRuntime.start(e,t),await this.collection(`_flow_agent_executions`).update(e.executionId,this.agentExecutionRecord(e))}async transitionAgentExecution(e,t){await this.agentRuntime.transition(e,t),await this.collection(`_flow_agent_executions`).update(e.executionId,this.agentExecutionRecord(e))}async completeAgentExecution(e,t){await this.agentRuntime.complete(e,t),await this.collection(`_flow_agent_executions`).update(e.executionId,this.agentExecutionRecord(e))}async failAgentExecution(e,t){await this.agentRuntime.fail(e,t),await this.collection(`_flow_agent_executions`).update(e.executionId,this.agentExecutionRecord(e))}async close(){for(let e of this.collections.values())e.close();this.collections.clear(),await this.jsDb.close?.(),await this.closeDevelopmentBridge?.()}sync(e){if(e)return new fi(e);let t=this.jsDb.sync_info();if(!t.success||!t.data)throw Error(t.error||`Failed to get sync info`);return JSON.parse(t.data)}async addSyncPeer(e){let t=this.jsDb.add_sync_peer(e);if(!t.success)throw Error(t.error||`Failed to add peer`)}async removeSyncPeer(e){let t=this.jsDb.remove_sync_peer(e);if(!t.success)throw Error(t.error||`Failed to remove peer`)}async getPendingForPeer(e,t){let n=this.jsDb.get_pending_for_peer(e,t);if(!n.success||!n.data)throw Error(n.error||`Failed to get pending operations`);return JSON.parse(n.data)}async acknowledgePeerOperations(e,t){let n=this.jsDb.acknowledge_peer_operations(e,t);if(!n.success)throw Error(n.error||`Failed to acknowledge operations`)}instanceId(){return this.jsDb.instance_id()}getSequence(){return this.jsDb.get_sequence()}freshness(){return or(this.jsDb)}revision(){return sr(this.jsDb)}async registerTrigger(e){}async scheduleCron(e){}async getPendingExecutions(){return[]}async completeExecution(e,t){}provenance(e){let[t,...n]=e.split(`://`)[1]?.split(`/`)||[],r={id:e,type:`Record`,label:n.join(`/`)||e,created_ms:Date.now()};return{root:r,nodes:[r],edges:[]}}health(){let e=this.sync(),t=this.runtime(),n=e.is_connected&&e.pending_operations===0?`healthy`:`degraded`,r=[];e.pending_operations>0&&r.push({severity:`info`,component:`sync`,message:`${e.pending_operations} pending operations`}),e.is_connected||r.push({severity:`warning`,component:`sync`,message:`Network disconnected`}),e.conflicts_detected>0&&r.push({severity:`warning`,component:`sync`,message:`${e.conflicts_detected} conflicts detected`});let i=r.length>0?`degraded`:`healthy`;return{runtime:{status:`healthy`,wasm:t.runtime===`wasm`||t.runtime===`browser`,reactive:t.reactive},storage:{status:`healthy`,backend:t.storage,persistent:t.persistent,durable:t.durable},sync:{status:n,connected:e.is_connected,peers:e.connected_peers.length,pendingOperations:e.pending_operations},fabric:{status:`healthy`,references:0,peers:e.connected_peers.length},capabilities:{status:`healthy`,count:0,available:0},execution:{status:`healthy`,pending:0,running:0,failed:0},workflow:{status:`healthy`,total:0,active:0},status:i,issues:r}}async allocateSequence(e){if(typeof this.jsDb.allocateSequence!=`function`)throw Error(`allocateSequence is not supported by ${this.runtimeInfo.storage} backend. Only FileJsDb (Node.js) supports atomic sequence allocation.`);return this.jsDb.allocateSequence(e)}async putIfAbsent(e,t){if(typeof this.jsDb.putIfAbsent!=`function`)throw Error(`putIfAbsent is not supported by ${this.runtimeInfo.storage} backend. Only FileJsDb (Node.js) supports durable idempotent mutation.`);return this.jsDb.putIfAbsent(e,t)}async cas(e){if(typeof this.jsDb.cas!=`function`)throw Error(`cas is not supported by ${this.runtimeInfo.storage} backend. Only FileJsDb (Node.js) supports compare-and-set with version detection.`);return this.jsDb.cas(e)}},na;(function(e){e.Insert=`Insert`,e.Update=`Update`,e.Delete=`Delete`,e.Query=`Query`,e.Upsert=`Upsert`})(na||={});var ra;(function(e){e.Pending=`Pending`,e.Running=`Running`,e.Succeeded=`Succeeded`,e.Failed=`Failed`,e.RetryScheduled=`RetryScheduled`,e.DeadLettered=`DeadLettered`})(ra||={});var ia=si(ui(`Application`));function aa({db:e,namespace:t=`default`,projectSpec:n,managedPublish:r,onSpecChange:i}){let a=`feltdb:studio:draft:${t}`,o=(0,g.useRef)((()=>{if(typeof window>`u`)return ia;let e=window.localStorage.getItem(a);if(!e)return ia;try{return ai(e),e}catch{return ia}})()),s=(0,g.useRef)(o.current!==ia),[c,l]=(0,g.useState)(o.current),[u,d]=(0,g.useState)(()=>ai(o.current)),[f,p]=(0,g.useState)([]),[m,h]=(0,g.useState)([]),[_,v]=(0,g.useState)(`Draft is valid`),[y,b]=(0,g.useState)(0),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),[ee,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(()=>({url:r?.url||``,namespace:r?.namespace||t,token:r?.token||``,environment:r?.environment,applicationId:r?.applicationId,publishEndpoint:r?.publishEndpoint,allowDestructive:!1})),A=(0,g.useRef)(null),j=m.length?m[m.length-1].source:si(ui(u.app)),M=(0,g.useMemo)(()=>ci(ai(j),u),[j,u]),N=(0,g.useMemo)(()=>li(ai(j),u),[j,u]);(0,g.useEffect)(()=>{if(!e||n)return;let t=!1;return(async()=>{try{let n=await e.collection(`_flow_apps`).all(),r=n.find(e=>e.status===`active`)??n[0];if(!r||t)return;let i=si(r.spec);s.current||(d(r.spec),l(i)),b(r.version??0);let a=(await e.collection(`_flow_app_versions`).all()).filter(e=>e.app===r.app).sort((e,t)=>e.version-t.version);t||(h(a.map(e=>({version:e.version,source:si(e.spec),savedAt:e.deployed_at}))),v(`Loaded ${r.app} v${r.version}`))}catch(e){t||v(`Could not load deployed model: ${e instanceof Error?e.message:String(e)}`)}})(),()=>{t=!0}},[e,n]),(0,g.useEffect)(()=>{let e=window.setTimeout(()=>window.localStorage.setItem(a,c),200);return()=>window.clearTimeout(e)},[a,c]);let P=e=>{l(e);try{let t=ai(e),n=U(t);d(t),i?.(t),p(n),v(n.some(e=>e.severity===`error`)?`Model has validation errors`:`Draft is valid`)}catch(e){p([{severity:`error`,message:e instanceof Error?e.message:String(e)}]),v(`DSL parse failed`)}};(0,g.useEffect)(()=>{if(!n)return;let e=si(n);l(e),d(n),p(U(n)),v(`Loaded ${n.app} project model`)},[n]);let te=e=>{d(e),P(si(e))},ne=()=>{if(!C)return w({name:``});let e=C.name.trim();if(!/^[A-Z][A-Za-z0-9_]*$/.test(e))return w({...C,error:`Use a capitalized name with no spaces.`});if(u.collections.some(t=>t.name===e))return w({...C,error:`That collection already exists.`});te({...u,collections:[...u.collections,{name:e,fields:[],indexes:[]}]}),w(null)},re=e=>S({collection:e,name:``,type:`text`,reference:``,optional:!1}),F=()=>{if(!x)return;let e=x.name.trim(),t=u.collections.find(e=>e.name===x.collection);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))return S({...x,error:`Use a letter-led name with no spaces.`});if(t?.fields.some(t=>t.name===e))return S({...x,error:`That field already exists.`});if([`ref`,`enum`,`array`,`map`,`vector`].includes(x.type)&&!x.reference.trim())return S({...x,error:`Configure this field type.`});let n=x.type===`ref`?`ref ${x.reference}`:x.type===`enum`?`enum(${x.reference.split(`,`).map(e=>e.trim()).filter(Boolean).join(`,`)})`:x.type===`array`?`array<${x.reference.trim()}>`:x.type===`map`?`map<${x.reference.trim()}>`:x.type===`vector`?`vector<${x.reference.trim()}>`:x.type;te({...u,collections:u.collections.map(t=>t.name===x.collection?{...t,fields:[...t.fields,{name:e,type:n,optional:x.optional}]}:t)}),S(null)},ie=()=>{let e=[...m,{version:m.length+1,source:c,savedAt:Date.now()}];h(e),v(`Saved local revision v${e.length}`)},ae=async()=>{if(!e)return v(`Local embedded storage is unavailable`);if(f.some(e=>e.severity===`error`))return v(`Resolve validation errors before deploying`);if(N.filter(e=>e.safety===`destructive`).length&&!T)return v(`Review and approve destructive local changes before applying`);try{let t=await e.deployFlowSpec(u,y,T),n=[...m,{version:t.version,source:c,savedAt:Date.now()}];h(n),b(t.version),E(!1),v(`Applied locally as ${t.app} v${t.version}`)}catch(e){v(`Local apply failed: ${e instanceof Error?e.message:String(e)}`)}},oe=async()=>{if(O.publishEndpoint){k({...O,publishing:!0,error:void 0});try{let e=await fetch(O.publishEndpoint,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({environment:O.environment,approveDestructive:O.allowDestructive})}),t=await e.json();if(!e.ok)throw Error(t.error||`Publish failed`);k({...O,publishing:!1,error:void 0}),D(!1),v(t.messages?.at(-1)||`Published immutable version ${t.version}`);return}catch(e){k({...O,publishing:!1,error:e instanceof Error?e.message:String(e)});return}}if(!O.url.trim()||!O.token.trim())return k({...O,error:`Cloud URL and API key are required.`});if(f.some(e=>e.severity===`error`))return k({...O,error:`Resolve validation errors before publishing.`});k({...O,publishing:!0,error:void 0});let e=Qi({namespace:O.namespace.trim()||t,server:{url:O.url.trim().replace(/\/$/,``),token:O.token}});try{let t=await e.collection(`_flow_apps`).get(u.app),n=li(t?.spec??ui(u.app),u).filter(e=>e.safety===`destructive`);if(n.length&&!O.allowDestructive)return k({...O,publishing:!1,destructive:n.map(e=>e.target),error:`Review and approve destructive changes: ${n.map(e=>e.target).join(`, `)}`});let r=await e.deployFlowSpec(u,t?.version??0,O.allowDestructive);window.sessionStorage.setItem(`feltdb-token:${O.url.trim()}`,O.token),k({...O,publishing:!1,error:void 0}),D(!1),v(`Published ${r.app} v${r.version} to ${O.environment||`cloud`}`)}catch(e){k({...O,publishing:!1,error:e instanceof Error?e.message:String(e)})}finally{await e.close()}},se=()=>{let e=URL.createObjectURL(new Blob([c],{type:`text/plain`})),t=document.createElement(`a`);t.href=e,t.download=`feltdb.flow`,t.click(),URL.revokeObjectURL(e)},ce=async e=>{e&&P(await e.text())},le=[[`Data`,u.collections.map(e=>e.name)],[`Capabilities`,u.capabilities.map(e=>e.name)],[`Agents`,u.agents.map(e=>e.name)],[`Workflows`,u.workflows.map(e=>e.name)],[`Triggers`,u.triggers.map(e=>e.event)],[`Policies`,u.policies.map(e=>e.name)],[`Schedules`,u.schedules.map(e=>e.name)]];return(0,B.jsxs)(`div`,{className:`application-designer`,children:[(0,B.jsxs)(`header`,{className:`designer-header`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Application fabric`}),(0,B.jsx)(`h1`,{children:u.app}),(0,B.jsx)(`p`,{children:`One model for state, intelligence, automation, security, and placement.`})]}),(0,B.jsxs)(`div`,{className:`designer-actions`,children:[(0,B.jsx)(`input`,{ref:A,hidden:!0,type:`file`,accept:`.flow,text/plain`,onChange:e=>void ce(e.target.files?.[0])}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>A.current?.click(),children:`Import`}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:se,children:`Export`}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:ie,children:`Version`}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>void ae(),children:`Apply locally`}),(0,B.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>D(e=>!e),children:`Publish to cloud`})]})]}),N.some(e=>e.safety===`destructive`)&&(0,B.jsxs)(`label`,{className:`local-destructive`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked)}),(0,B.jsxs)(`span`,{children:[`Approve destructive local changes: `,N.filter(e=>e.safety===`destructive`).map(e=>e.target).join(`, `)]})]}),ee&&(0,B.jsxs)(`form`,{className:`cloud-publisher`,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,B.jsxs)(`div`,{className:`cloud-publisher-heading`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Cloud release`}),(0,B.jsx)(`h2`,{children:`Publish this application definition`}),(0,B.jsx)(`p`,{children:`FeltDB validates an immutable revision and atomically promotes the environment.`})]}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Close cloud publisher`,onClick:()=>D(!1),children:`×`})]}),(0,B.jsxs)(`div`,{className:`cloud-fields`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`FeltDB Cloud URL`}),(0,B.jsx)(`input`,{type:`url`,value:O.url,readOnly:!!O.publishEndpoint,onChange:e=>k({...O,url:e.target.value,error:void 0,destructive:void 0,allowDestructive:!1})})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Namespace`}),(0,B.jsx)(`input`,{value:O.namespace,readOnly:!!O.publishEndpoint,onChange:e=>k({...O,namespace:e.target.value,error:void 0,destructive:void 0,allowDestructive:!1})})]}),!O.publishEndpoint&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`API key`}),(0,B.jsx)(`input`,{type:`password`,autoComplete:`off`,placeholder:`Loaded securely from this project`,value:O.token,onChange:e=>k({...O,token:e.target.value,error:void 0})})]}),O.environment&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Environment`}),(0,B.jsx)(`input`,{value:O.environment,readOnly:!0})]}),O.applicationId&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Application`}),(0,B.jsx)(`input`,{value:O.applicationId,readOnly:!0})]})]}),(O.destructive?.length||N.some(e=>e.safety===`destructive`))&&(0,B.jsxs)(`label`,{className:`cloud-destructive`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:O.allowDestructive,onChange:e=>k({...O,allowDestructive:e.target.checked})}),(0,B.jsxs)(`span`,{children:[`I reviewed and approve destructive model changes`,O.destructive?.length?`: ${O.destructive.join(`, `)}`:`.`]})]}),O.error&&(0,B.jsx)(`div`,{className:`cloud-error`,role:`alert`,children:O.error}),(0,B.jsxs)(`div`,{className:`cloud-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>D(!1),children:`Cancel`}),(0,B.jsx)(`button`,{className:`btn btn-primary`,disabled:O.publishing,type:`submit`,children:O.publishing?`Publishing…`:`Review and publish`})]})]}),(0,B.jsxs)(`div`,{className:`designer-status ${f.some(e=>e.severity===`error`)?`error`:``}`,children:[(0,B.jsx)(`span`,{children:_}),(0,B.jsxs)(`span`,{children:[u.collections.length,` collections · `,u.workflows.length,` workflows · `,m.length?`v${m.length}`:`draft`]})]}),(0,B.jsxs)(`div`,{className:`designer-grid`,children:[(0,B.jsxs)(`aside`,{className:`model-tree`,children:[(0,B.jsxs)(`div`,{className:`panel-title`,children:[(0,B.jsx)(`span`,{children:`Application`}),(0,B.jsx)(`button`,{"aria-label":`Add collection`,onClick:()=>w({name:``}),children:`+`})]}),C&&(0,B.jsxs)(`form`,{className:`collection-editor`,onSubmit:e=>{e.preventDefault(),ne()},onKeyDown:e=>{e.key===`Escape`&&w(null)},children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`New collection`}),(0,B.jsx)(`input`,{autoFocus:!0,placeholder:`e.g. Customer`,value:C.name,onChange:e=>w({name:e.target.value})})]}),C.error&&(0,B.jsx)(`div`,{className:`field-error`,role:`alert`,children:C.error}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>w(null),children:`Cancel`}),(0,B.jsx)(`button`,{className:`collection-save`,type:`submit`,children:`Add`})]})]}),le.map(([e,t])=>(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:e}),t.length?t.map(e=>(0,B.jsx)(`div`,{className:`tree-item`,children:e},e)):(0,B.jsx)(`div`,{className:`tree-empty`,children:`None`})]},e))]}),(0,B.jsxs)(`section`,{className:`model-canvas`,children:[(0,B.jsxs)(`div`,{className:`panel-title`,children:[(0,B.jsx)(`span`,{children:`Application graph`}),(0,B.jsx)(`span`,{className:`graph-legend`,children:`intent → fabric`})]}),(0,B.jsxs)(`div`,{className:`graph-board`,children:[u.collections.map(e=>(0,B.jsxs)(`article`,{className:`model-node`,children:[(0,B.jsx)(`div`,{className:`node-kind`,children:`collection`}),(0,B.jsx)(`h3`,{children:e.name}),e.fields.map(e=>(0,B.jsxs)(`div`,{className:`node-field`,children:[(0,B.jsx)(`span`,{children:e.name}),(0,B.jsxs)(`code`,{children:[e.type,e.optional?`?`:``]})]},e.name)),x?.collection===e.name?(0,B.jsxs)(`form`,{className:`field-editor`,onSubmit:e=>{e.preventDefault(),F()},onKeyDown:e=>{e.key===`Escape`&&S(null)},children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Field name`}),(0,B.jsx)(`input`,{autoFocus:!0,value:x.name,placeholder:`e.g. publishedAt`,onChange:e=>S({...x,name:e.target.value,error:void 0})})]}),(0,B.jsxs)(`div`,{className:`field-editor-row`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Type`}),(0,B.jsxs)(`select`,{value:x.type,onChange:e=>S({...x,type:e.target.value,error:void 0}),children:[(0,B.jsx)(`option`,{value:`text`,children:`Text`}),(0,B.jsx)(`option`,{value:`integer`,children:`Integer`}),(0,B.jsx)(`option`,{value:`number`,children:`Number`}),(0,B.jsx)(`option`,{value:`decimal`,children:`Decimal`}),(0,B.jsx)(`option`,{value:`money`,children:`Money`}),(0,B.jsx)(`option`,{value:`bigint`,children:`Big integer`}),(0,B.jsx)(`option`,{value:`boolean`,children:`Boolean`}),(0,B.jsx)(`option`,{value:`datetime`,children:`Date & time`}),(0,B.jsx)(`option`,{value:`date`,children:`Date`}),(0,B.jsx)(`option`,{value:`time`,children:`Time`}),(0,B.jsx)(`option`,{value:`uuid`,children:`UUID`}),(0,B.jsx)(`option`,{value:`email`,children:`Email`}),(0,B.jsx)(`option`,{value:`url`,children:`URL`}),(0,B.jsx)(`option`,{value:`phone`,children:`Phone`}),(0,B.jsx)(`option`,{value:`json`,children:`JSON`}),(0,B.jsx)(`option`,{value:`object`,children:`Object`}),(0,B.jsx)(`option`,{value:`binary`,children:`Binary`}),(0,B.jsx)(`option`,{value:`file`,children:`File`}),(0,B.jsx)(`option`,{value:`geo`,children:`Geo point`}),(0,B.jsx)(`option`,{value:`enum`,children:`Enum`}),(0,B.jsx)(`option`,{value:`array`,children:`Array`}),(0,B.jsx)(`option`,{value:`map`,children:`Typed map`}),(0,B.jsx)(`option`,{value:`vector`,children:`Vector`}),(0,B.jsx)(`option`,{value:`ref`,children:`Reference`})]})]}),x.type===`ref`&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Collection`}),(0,B.jsx)(`select`,{value:x.reference,onChange:e=>S({...x,reference:e.target.value,error:void 0}),children:u.collections.filter(t=>t.name!==e.name).map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),x.type===`enum`&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Values`}),(0,B.jsx)(`input`,{placeholder:`draft,active,done`,value:x.reference,onChange:e=>S({...x,reference:e.target.value,error:void 0})})]}),(x.type===`array`||x.type===`map`)&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Item type`}),(0,B.jsx)(`input`,{placeholder:`text, uuid, ref Project…`,value:x.reference,onChange:e=>S({...x,reference:e.target.value,error:void 0})})]}),x.type===`vector`&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Dimensions`}),(0,B.jsx)(`input`,{type:`number`,min:`1`,placeholder:`1536`,value:x.reference,onChange:e=>S({...x,reference:e.target.value,error:void 0})})]})]}),(0,B.jsxs)(`label`,{className:`field-optional`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:x.optional,onChange:e=>S({...x,optional:e.target.checked})}),(0,B.jsx)(`span`,{children:`Optional field`})]}),x.error&&(0,B.jsx)(`div`,{className:`field-error`,role:`alert`,children:x.error}),(0,B.jsxs)(`div`,{className:`field-editor-actions`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>S(null),children:`Cancel`}),(0,B.jsx)(`button`,{className:`field-save`,type:`submit`,children:`Add field`})]})]}):(0,B.jsx)(`button`,{className:`node-add`,onClick:()=>re(e.name),children:`+ field`})]},e.name)),u.workflows.map(e=>(0,B.jsxs)(`article`,{className:`model-node workflow-node`,children:[(0,B.jsx)(`div`,{className:`node-kind`,children:`workflow`}),(0,B.jsx)(`h3`,{children:e.name}),e.steps.map(e=>(0,B.jsx)(`div`,{className:`node-step`,children:e.name},e.name))]},e.name)),u.agents.map(e=>(0,B.jsxs)(`article`,{className:`model-node agent-node`,children:[(0,B.jsx)(`div`,{className:`node-kind`,children:`agent`}),(0,B.jsx)(`h3`,{children:e.name}),e.statements.map(e=>(0,B.jsx)(`div`,{className:`node-step`,children:e},e))]},e.name))]}),(0,B.jsxs)(`div`,{className:`change-strip`,children:[(0,B.jsx)(`strong`,{children:`Model diff`}),(0,B.jsxs)(`span`,{className:`added`,children:[`+ `,M.added.join(`, `)||`none`]}),(0,B.jsxs)(`span`,{className:`changed`,children:[`~ `,M.changed.join(`, `)||`none`]}),(0,B.jsxs)(`span`,{className:`removed`,children:[`− `,M.removed.join(`, `)||`none`]})]})]}),(0,B.jsxs)(`section`,{className:`dsl-panel`,children:[(0,B.jsxs)(`div`,{className:`panel-title`,children:[(0,B.jsx)(`span`,{children:`Flow DSL`}),(0,B.jsx)(`span`,{children:`feltdb.flow`})]}),(0,B.jsx)(`textarea`,{"aria-label":`Flow DSL`,spellCheck:!1,value:c,onChange:e=>P(e.target.value)}),f.length>0&&(0,B.jsx)(`div`,{className:`diagnostics`,children:f.map((e,t)=>(0,B.jsxs)(`div`,{className:e.severity,children:[e.severity,`: `,e.message]},t))})]})]})]})}function oa({configuration:e,onApplied:t,onProposalCreated:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(),[s,c]=(0,g.useState)(),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(0),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)([]),v=typeof navigator<`u`&&`gpu`in navigator,y=e?.aiModel?.provider===`openai-compatible`,b=!!(e?.enabled&&(y?e.aiModel?.credentialConfigured:e.webllmEnabled&&v)),S=async()=>{if(!(!b||!e)){u(`Loading local model…`),c(void 0),o(void 0);try{let t=await fetch(`/_feltdb/contract`,{cache:`no-store`}),i=await t.json();if(!t.ok)throw Error(i.error||`Could not load contract`);if(i.drift&&!i.drift.synchronized)throw Error(`Contract drift detected. Review feltdb status before generating.`);let a;if(y){u(`Asking ${e.aiModel?.model} through the local CLI…`);let t=await fetch(`/_feltdb/ai/generate`,{method:`POST`,headers:{"content-type":`application/json`,"x-feltdb-studio-token":e.token},body:JSON.stringify({intent:r})}),n=await t.json();if(!t.ok)throw Error(n.error||`Configured model failed`);a=n.proposal}else{let{WebLLMProvider:t}=await x(async()=>{let{WebLLMProvider:e}=await import(`./dist-CCOk39Uc.js`);return{WebLLMProvider:e}},[]),n=new t({model:e.aiModel?.model,contract:i.snapshot,onProgress:e=>{f(e.progress),u(e.text)}});try{a=await n.generateFlow(r,{currentFlow:i.source})}finally{await n.shutdown()}}let s=await fetch(`/_feltdb/proposals`,{method:`POST`,headers:{"content-type":`application/json`,"x-feltdb-studio-token":e.token},body:JSON.stringify({proposal:a})}),l=await s.json();if(!s.ok)throw Error(l.error||`Proposal validation failed`);o(a),c(l),l.proposalId&&l.proposalId!==`ephemeral`&&n?.(l.proposalId),_(ai(a.proposedFlow).collections.map(e=>({name:e.name,fields:e.fields.map(e=>e.name)}))),u(`Validated proposal ready for review`)}catch(e){u(e instanceof Error?e.message:String(e))}}},C=async t=>{if(!(!s||!e)){u(t===`approve`?`Recording approval…`:`Rejecting preview…`);try{let n=await fetch(`/_feltdb/proposals/${t}`,{method:`POST`,headers:{"content-type":`application/json`,"x-feltdb-studio-token":e.token},body:JSON.stringify({proposalId:s.proposalId,confirm:!0,approveAuthorization:p})}),r=await n.json();if(!n.ok)throw Error(r.error||`Proposal decision failed`);t===`approve`?u(`Approved. Run ${r.command} in your project to synchronize the repository.`):(o(void 0),c(void 0),_([]),u(`Preview rejected. The application and repository are unchanged.`))}catch(e){u(e instanceof Error?e.message:String(e))}}};return(0,B.jsxs)(`section`,{className:`ask-feltdb`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Contract-aware proposal engine`}),(0,B.jsx)(`h2`,{children:`Ask FeltDB`}),(0,B.jsx)(`p`,{children:`Describe a contract change. Your selected model proposes; FeltDB validates, and the CLI owns source synchronization.`})]}),(0,B.jsxs)(`p`,{className:`ai-model-choice`,children:[`Model: `,(0,B.jsx)(`strong`,{children:e?.aiModel?.model??`SmolLM2-360M-Instruct`}),` (`,y?`bring-your-own provider; credential held by CLI`:`private local WebLLM`,`). Change it with `,(0,B.jsx)(`code`,{children:`feltdb ai model set`}),`.`]}),y&&!e?.aiModel?.credentialConfigured?(0,B.jsxs)(`p`,{className:`ai-unavailable`,children:[`The selected hosted model needs a credential. Pipe it securely with `,(0,B.jsx)(`code`,{children:`printf %s "$KEY" | feltdb ai model set ... --api-key-stdin`}),`.`]}):!y&&!e?.webllmEnabled?(0,B.jsxs)(`p`,{className:`ai-unavailable`,children:[`Local AI is not enabled for this project. Install `,(0,B.jsx)(`code`,{children:`@feltdb/webllm`}),` to opt in, or configure your own model with `,(0,B.jsx)(`code`,{children:`feltdb ai model set`}),`.`]}):!y&&!v?(0,B.jsx)(`p`,{className:`ai-unavailable`,children:`Local FeltDB AI is unavailable because WebGPU is not available. You can configure an OpenAI-compatible model instead.`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`textarea`,{"aria-label":`Ask FeltDB`,value:r,onChange:e=>i(e.target.value),placeholder:`Add invitations so organization owners can invite users.`}),(0,B.jsx)(`button`,{className:`btn btn-primary`,disabled:!r.trim(),onClick:()=>void S(),children:`Generate proposal`})]}),d>0&&d<1&&(0,B.jsx)(`progress`,{value:d,max:1}),` `,l&&(0,B.jsx)(`p`,{className:`ai-status`,children:l}),a&&s&&(0,B.jsxs)(`div`,{className:`proposal-review`,children:[(0,B.jsx)(`h3`,{children:`Ephemeral application preview`}),(0,B.jsx)(`p`,{children:a.summary}),(0,B.jsx)(`ul`,{children:s.changes.map(e=>(0,B.jsx)(`li`,{children:e},e))}),(0,B.jsxs)(`div`,{className:`proposal-app-preview`,"aria-label":`Proposed application preview`,children:[(0,B.jsx)(`nav`,{children:h.map(e=>(0,B.jsx)(`span`,{children:e.name},e.name))}),h.map(e=>(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`strong`,{children:e.name}),(0,B.jsx)(`small`,{children:e.fields.join(` · `)||`No fields`})]},e.name))]}),a.implementation&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h4`,{children:`Module implementation`}),(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:a.implementation.module.name}),` · owner `,a.implementation.owner]}),(0,B.jsx)(`pre`,{children:a.implementation.stateFlow.join(` → `)}),(0,B.jsx)(`p`,{children:a.implementation.applicationModels.map(e=>`${e.name}: ${e.ownership}`).join(` · `)})]}),(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Source impact`}),`: `,s.sourcePlan.join(`, `)]}),a.warnings.length>0&&(0,B.jsx)(`div`,{className:`proposal-warning`,children:a.warnings.join(` · `)}),s.authorizationChanges.length>0&&(0,B.jsxs)(`div`,{children:[s.authorizationChanges.map(e=>(0,B.jsxs)(`div`,{className:`proposal-warning`,children:[(0,B.jsxs)(`strong`,{children:[`AUTHORIZATION CHANGE`,e.widening?` — POSSIBLE WIDENING`:``]}),(0,B.jsx)(`br`,{}),e.policy,(0,B.jsx)(`br`,{}),(0,B.jsxs)(`code`,{children:[(e.before??[`<absent>`]).join(` | `),` → `,(e.after??[`<removed>`]).join(` | `)]})]},e.policy)),(0,B.jsxs)(`label`,{className:`authorization-approval`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),(0,B.jsx)(`span`,{children:`I explicitly approve this authorization change.`})]})]}),(0,B.jsxs)(`details`,{children:[(0,B.jsx)(`summary`,{children:`Proposed feltdb.flow`}),(0,B.jsx)(`pre`,{children:a.proposedFlow})]}),!e?.previewOnly&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{className:`btn btn-primary`,disabled:s.authorizationChanges.length>0&&!p,onClick:()=>void C(`approve`),children:`Approve proposal`}),(0,B.jsx)(`button`,{className:`btn`,onClick:()=>void C(`reject`),children:`Reject preview`})]}),e?.previewOnly&&(0,B.jsxs)(`p`,{className:`proposal-boundary`,children:[(0,B.jsx)(`strong`,{children:`Preview-only session:`}),` no proposal artifact or source file will be written.`]}),(0,B.jsx)(`p`,{className:`proposal-boundary`,children:`This preview is ephemeral. Approval records a proposal artifact; Studio never writes application source, changes the running contract, or publishes.`})]})]})}var sa=class{constructor(e){this.options=e,this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}scope(e={}){return{application_id:this.options.applicationId,environment:this.options.environment,...e}}async request(e,t={},n={}){let r=new URL(e,`${this.options.baseUrl||window.location.origin}/`);for(let[e,t]of Object.entries(this.scope(n)))t&&r.searchParams.set(e,t);let i=await this.fetcher(r,{cache:`no-store`,...t,headers:{...t.body?{"content-type":`application/json`}:{},...this.options.token?{authorization:`Bearer ${this.options.token}`}:{},...t.headers}}),a=await i.json().catch(()=>({}));if(!i.ok)throw new An(a.code||a.error||`proposal_request_failed`,a.message||a.error||`Proposal request failed.`,i.status);return a}list(e,t,n=25){return this.request(`/v1/proposals`,{},{status:e||void 0,cursor:t,limit:String(n)})}get(e){return this.request(`/v1/proposals/${encodeURIComponent(e)}`)}history(e){return this.request(`/v1/proposals/${encodeURIComponent(e)}/history`)}status(e){return this.request(`/v1/proposals/${encodeURIComponent(e)}/status`)}preview(e){return this.request(`/v1/previews/${encodeURIComponent(e)}`)}validate(e){return this.request(`/v1/proposals/${encodeURIComponent(e)}/validate`,{method:`POST`,body:JSON.stringify(this.scope())})}createPreview(e){return this.request(`/v1/proposals/${encodeURIComponent(e)}/preview`,{method:`POST`,body:JSON.stringify(this.scope())})}approve(e,t=!1){return this.request(`/v1/proposals/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify({...this.scope(),approve_authorization:t})})}reject(e,t){return this.request(`/v1/proposals/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify({...this.scope(),reason:t})})}},ca=e=>({State:e.module_impact.models,Relationships:e.module_impact.relationships,Events:e.module_impact.events,Workflows:e.module_impact.workflows,Capabilities:e.module_impact.capabilities,Authorization:e.module_impact.authorization,Configuration:e.module_impact.configuration});function la(e){return e instanceof An?e.code===`invalid_cursor`?`The proposal cursor expired. Refreshed from the first page.`:[`stale_proposal`,`STALE_PROPOSAL`].includes(e.code)?`This Proposal is stale. Regenerate it against the current application.`:[`preview_expired`,`PREVIEW_EXPIRED`].includes(e.code)?`The proposed preview expired. Generate a new preview before approval.`:e.code===`forbidden`||e.code===`unauthorized`?`You don't have access to these proposals.`:e.message:`Unable to load proposals.`}var ua=[``,`proposed`,`validated`,`previewed`,`approved`,`applied`,`rejected`,`expired`],da=e=>e?`${e.slice(0,12)}…`:`Not recorded`,fa=e=>new Date(typeof e==`number`&&e<1e10?e*1e3:e).toLocaleString();function pa({name:e,values:t}){return t.length?(0,B.jsxs)(`section`,{className:`semantic-section`,children:[(0,B.jsx)(`h4`,{children:e}),t.map((e,t)=>(0,B.jsxs)(`div`,{children:[`+ `,e]},`${e}-${t}`))]}):null}function ma({value:e}){let t={contract_changed:`Contract changed since Proposal creation.`,flow_changed:`Flow changed since Proposal creation.`,module_versions_changed:`Resolved module versions changed.`,expired:`Proposal expired.`};return(0,B.jsxs)(`section`,{className:`proposal-readiness ${e.readiness}`,children:[(0,B.jsx)(`h3`,{children:`Readiness`}),(0,B.jsx)(`strong`,{children:e.readiness===`ready`?`✓ READY`:`⚠ BLOCKED`}),e.readiness===`ready`?(0,B.jsxs)(`ul`,{children:[(0,B.jsx)(`li`,{children:`✓ Contract current`}),(0,B.jsx)(`li`,{children:`✓ Flow current`}),(0,B.jsx)(`li`,{children:`✓ Modules resolved`}),(0,B.jsx)(`li`,{children:`No blockers`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`ul`,{children:e.blockers.map(e=>(0,B.jsx)(`li`,{children:t[e]||e},e))}),(0,B.jsxs)(`dl`,{children:[(0,B.jsx)(`dt`,{children:`Proposal`}),(0,B.jsx)(`dd`,{children:(0,B.jsx)(`code`,{children:e.proposal_contract_hash})}),(0,B.jsx)(`dt`,{children:`Current`}),(0,B.jsx)(`dd`,{children:(0,B.jsx)(`code`,{children:e.current_contract_hash})})]}),(0,B.jsx)(`p`,{children:`Regenerate this Proposal.`})]}),e.notes.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{children:`Notes`}),(0,B.jsx)(`ul`,{children:e.notes.map(e=>(0,B.jsx)(`li`,{children:e},e))})]})]})}function ha({artifact:e}){let t=e.current_contract??e.current,n=e.proposed_contract??e.proposed;return(0,B.jsxs)(`section`,{className:`proposal-runtime-preview`,children:[(0,B.jsxs)(`div`,{className:`preview-banner`,children:[(0,B.jsx)(`b`,{children:`PROPOSED PREVIEW`}),(0,B.jsx)(`br`,{}),`Synthetic, isolated state. This is not the live application or repository.`]}),(0,B.jsxs)(`div`,{className:`preview-comparison`,children:[(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h4`,{children:`Current`}),t.schema.map(e=>(0,B.jsx)(`span`,{children:e.name},e.name))]}),(0,B.jsx)(`i`,{children:`→`}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h4`,{children:`Proposed`}),n.schema.map(e=>(0,B.jsx)(`span`,{children:e.name},e.name)),n.workflows.map(e=>(0,B.jsx)(`span`,{children:e.name},e.name))]})]})]})}function ga({value:e}){return(0,B.jsxs)(`section`,{className:`repository-readiness ${e?.ready?`ready`:`blocked`}`,children:[(0,B.jsx)(`h3`,{children:`Repository`}),e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`strong`,{children:e.ready?`✓ READY FOR CLI APPLY`:`⚠ BLOCKED`}),(0,B.jsxs)(`ul`,{children:[(0,B.jsxs)(`li`,{children:[e.contractMatches?`✓`:`⚠`,` Contract `,e.contractMatches?`matches Proposal`:`does not match`]}),(0,B.jsxs)(`li`,{children:[e.flowMatches?`✓`:`⚠`,` Flow `,e.flowMatches?`matches Proposal`:`does not match`]}),(0,B.jsx)(`li`,{children:e.gitClean?`✓ Clean`:`⚠ Local source conflicts`}),e.conflicts.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`code`,{children:e})},e))]})]}):(0,B.jsxs)(`p`,{children:[`Repository context is available when Studio is opened through `,(0,B.jsx)(`code`,{children:`feltdb studio`}),`.`]})]})}function _a({serviceUrl:e=``,token:t=``,applicationId:n,environment:r,applicationName:i,sourceSync:a}){let o=(0,g.useMemo)(()=>new sa({baseUrl:e,token:t,applicationId:n,environment:r}),[e,t,n,r]),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(),[d,f]=(0,g.useState)([]),[p,m]=(0,g.useState)(),[h,_]=(0,g.useState)(),[v,y]=(0,g.useState)(),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(),[w,T]=(0,g.useState)(null),[E,ee]=(0,g.useState)([]),[D,O]=(0,g.useState)(!0),[k,A]=(0,g.useState)(``),[j,M]=(0,g.useState)(!1),[N,P]=(0,g.useState)(!1),[te,ne]=(0,g.useState)(``),[re,F]=(0,g.useState)(!1),ie=(0,g.useCallback)(async(e,t=!0)=>{O(!0);try{let t=await o.list(b,e);c(t.proposals),C(e),T(t.pagination?.nextCursor??null),A(``)}catch(n){if(t&&e&&n instanceof An&&n.code===`invalid_cursor`){ee([]),await ie(void 0,!1),A(la(n));return}A(la(n))}finally{O(!1)}},[o,b]),ae=(0,g.useCallback)(async e=>{A(``);try{let[t,n,r]=await Promise.all([o.get(e),o.status(e),o.history(e)]);u(t),m(n),f(r.events),fetch(`/_feltdb/repository-readiness?proposal=${encodeURIComponent(e)}`,{cache:`no-store`}).then(e=>e.ok?e.json():void 0).then(y).catch(()=>y(void 0)),t.preview_id?o.preview(t.preview_id).then(_).catch(e=>A(la(e))):_(void 0)}catch(e){A(la(e))}},[o]);(0,g.useEffect)(()=>{ee([]),ie()},[ie]),(0,g.useEffect)(()=>{if(!l?.id)return;let e=window.setInterval(()=>{ae(l.id),ie(S)},5e3);return()=>window.clearInterval(e)},[l?.id,ae,ie,S]);let oe=async()=>{await ie(S),l&&await ae(l.id)},se=async e=>{if(l)try{e===`approve`?await o.approve(l.id,re):await o.reject(l.id,te||void 0),M(!1),P(!1),await oe()}catch(e){A(la(e))}},ce=async()=>{if(l)try{l.status===`proposed`?await o.validate(l.id):await o.createPreview(l.id),await oe()}catch(e){A(la(e))}},le=l?ca(l):void 0,ue=l?.warnings.some(e=>e.startsWith(`Authorization `));return(0,B.jsxs)(`div`,{className:`proposal-workspace`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Visual control plane`}),(0,B.jsx)(`h1`,{children:`Proposals`}),(0,B.jsxs)(`p`,{children:[i||n,` · `,r,` · Service API authoritative`]})]}),(0,B.jsx)(oa,{configuration:a,onProposalCreated:()=>void ie()}),k&&(0,B.jsxs)(`div`,{className:`data-error`,role:`alert`,children:[k,(0,B.jsx)(`button`,{onClick:()=>void oe(),children:`Refresh`})]}),(0,B.jsxs)(`div`,{className:`proposal-workspace-layout`,children:[(0,B.jsxs)(`aside`,{className:`studio-card`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`h2`,{children:`Proposals`}),(0,B.jsx)(`select`,{"aria-label":`Proposal status`,value:b,onChange:e=>x(e.target.value),children:ua.map(e=>(0,B.jsx)(`option`,{value:e,children:e?e.toUpperCase():`ALL STATUSES`},e||`all`))})]}),D?(0,B.jsx)(`p`,{children:`Loading…`}):s.length?s.map(e=>(0,B.jsxs)(`button`,{className:`proposal-list-row ${l?.id===e.id?`active`:``}`,onClick:()=>void ae(e.id),children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e.summary}),(0,B.jsxs)(`small`,{children:[e.id,` · `,fa(e.created_at)]})]}),(0,B.jsx)(`b`,{children:e.status})]},e.id)):(0,B.jsx)(`p`,{children:`No Proposals yet. Ask FeltDB AI to propose an application change.`}),(0,B.jsxs)(`footer`,{className:`data-pagination`,children:[(0,B.jsx)(`button`,{disabled:!E.length,onClick:()=>{let e=E.at(-1);ee(e=>e.slice(0,-1)),ie(e)},children:`←`}),(0,B.jsx)(`button`,{disabled:!w,onClick:()=>{ee(e=>[...e,S]),ie(w||void 0)},children:`→`})]})]}),(0,B.jsx)(`main`,{className:`studio-card proposal-detail`,children:l?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`header`,{children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`proposal-status ${l.status}`,children:l.status}),(0,B.jsx)(`h2`,{children:l.summary}),l.parent_proposal_id&&(0,B.jsxs)(`p`,{children:[`Incremental Proposal · Based on `,(0,B.jsx)(`button`,{className:`reference-value`,onClick:()=>void ae(l.parent_proposal_id),children:l.parent_proposal_id})]})]}),(0,B.jsxs)(`dl`,{children:[(0,B.jsx)(`dt`,{children:`Application`}),(0,B.jsx)(`dd`,{children:i||l.application_id}),(0,B.jsx)(`dt`,{children:`Environment`}),(0,B.jsx)(`dd`,{children:l.environment}),(0,B.jsx)(`dt`,{children:`Contract`}),(0,B.jsxs)(`dd`,{children:[`v`,l.base_contract_version,` · `,(0,B.jsx)(`code`,{children:da(l.base_contract_hash)})]}),(0,B.jsx)(`dt`,{children:`Flow`}),(0,B.jsx)(`dd`,{children:(0,B.jsx)(`code`,{children:da(l.base_flow_hash)})})]})]}),l.module_versions.length>0&&(0,B.jsx)(pa,{name:`Modules`,values:l.module_versions.map(e=>`${e.id} (${e.provider}) ${e.version}`)}),(0,B.jsxs)(`section`,{className:`semantic-diff`,children:[(0,B.jsx)(`h3`,{children:`Current application → Semantic diff → Proposed application`}),le&&Object.entries(le).map(([e,t])=>(0,B.jsx)(pa,{name:e,values:t},e)),(0,B.jsx)(pa,{name:`Semantic Diff`,values:l.contract_diff})]}),Object.keys(l.module_impact.ownership).length>0&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`State ownership`}),(0,B.jsx)(`div`,{className:`ownership-grid`,children:Object.entries(l.module_impact.ownership).map(([e,t])=>(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:e}),(0,B.jsx)(`small`,{children:t.replace(/_/g,` `)})]},e))})]}),l.module_impact.state_flow.length>0&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`Reconciliation`}),l.module_impact.state_flow.map(e=>(0,B.jsx)(`div`,{className:`reconciliation-flow`,children:e.split(/\s*->\s*/).map((t,n)=>(0,B.jsxs)(g.Fragment,{children:[(0,B.jsx)(`span`,{children:t}),n<e.split(/\s*->\s*/).length-1&&(0,B.jsx)(`i`,{children:`↓`})]},`${t}-${n}`))},e))]}),(l.module_impact.configuration.length>0||l.module_impact.secrets.length>0)&&(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`Configuration`}),l.module_impact.configuration.map(e=>(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:e}),(0,B.jsx)(`br`,{}),(0,B.jsx)(`small`,{children:`Required · Configuration`})]},e)),l.module_impact.secrets.map(e=>(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:e}),(0,B.jsx)(`br`,{}),(0,B.jsx)(`small`,{children:`Required · Secret · Value never exposed`})]},e))]}),p&&(0,B.jsx)(ma,{value:p}),h&&(0,B.jsx)(ha,{artifact:h}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`Source plan`}),l.source_plan.files.map(e=>(0,B.jsx)(`p`,{children:(0,B.jsxs)(`code`,{children:[e.operation,` `,e.path]})},e.path))]}),(0,B.jsx)(ga,{value:v}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`History`}),(0,B.jsx)(`ol`,{className:`proposal-history`,children:d.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:e.to_status}),(0,B.jsx)(`span`,{children:fa(e.created_at)}),(0,B.jsx)(`small`,{children:e.actor})]},e.id))})]}),l.status===`proposed`&&(0,B.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>void ce(),children:`Validate Proposal`}),l.status===`validated`&&(0,B.jsx)(`button`,{className:`btn btn-primary`,onClick:()=>void ce(),children:`Create Proposed Preview`}),l.status===`previewed`&&(0,B.jsxs)(`div`,{className:`proposal-actions`,children:[(0,B.jsx)(`button`,{className:`btn btn-primary`,disabled:p?.readiness===`blocked`,onClick:()=>M(!0),children:`Approve Proposal`}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>P(!0),children:`Reject`})]}),[`proposed`,`validated`].includes(l.status)&&(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>P(!0),children:`Reject`}),l.status===`approved`&&(0,B.jsxs)(`section`,{className:`proposal-boundary`,children:[(0,B.jsx)(`strong`,{children:`Approved · Ready for repository application.`}),(0,B.jsxs)(`code`,{children:[`feltdb ai apply `,l.id]}),(0,B.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>void navigator.clipboard.writeText(`feltdb ai apply ${l.id}`),children:`Copy command`}),(0,B.jsx)(`p`,{children:`Studio cannot mutate repository source.`})]})]}):(0,B.jsx)(`div`,{className:`model-empty`,children:`Select a Proposal to inspect its canonical semantics.`})})]}),j&&l&&(0,B.jsx)(`div`,{className:`proposal-modal`,role:`dialog`,"aria-modal":`true`,children:(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h2`,{children:`Approve this Proposal?`}),(0,B.jsx)(`p`,{children:l.summary}),l.contract_diff.slice(0,6).map(e=>(0,B.jsx)(`div`,{children:e},e)),(0,B.jsx)(`p`,{children:(0,B.jsx)(`strong`,{children:`Repository source will not be modified.`})}),ue&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:re,onChange:e=>F(e.target.checked)}),` I explicitly approve the authorization change.`]}),(0,B.jsxs)(`footer`,{children:[(0,B.jsx)(`button`,{onClick:()=>M(!1),children:`Cancel`}),(0,B.jsx)(`button`,{disabled:ue&&!re,onClick:()=>void se(`approve`),children:`Approve`})]})]})}),N&&l&&(0,B.jsx)(`div`,{className:`proposal-modal`,role:`dialog`,"aria-modal":`true`,children:(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h2`,{children:`Reject Proposal?`}),(0,B.jsx)(`textarea`,{"aria-label":`Rejection reason`,value:te,onChange:e=>ne(e.target.value),placeholder:`Optional reason`}),(0,B.jsxs)(`footer`,{children:[(0,B.jsx)(`button`,{onClick:()=>P(!1),children:`Cancel`}),(0,B.jsx)(`button`,{onClick:()=>void se(`reject`),children:`Reject`})]})]})})]})}function va({model:e}){let t=$r(e?.modules??[]);return(0,B.jsxs)(`section`,{className:`module-explorer`,children:[(0,B.jsx)(`h1`,{children:`Modules`}),!t.length&&(0,B.jsx)(`p`,{children:`No modules are declared. Add a module block to feltdb.flow.`}),t.map(t=>(0,B.jsxs)(`article`,{className:`proposal-card`,children:[(0,B.jsx)(`h2`,{children:t.name}),(0,B.jsxs)(`p`,{children:[(0,B.jsxs)(`code`,{children:[t.id,`@`,t.version]}),` · provider `,(0,B.jsx)(`code`,{children:t.provider})]}),(0,B.jsx)(`h3`,{children:`Models`}),(0,B.jsx)(`p`,{children:t.models.map(e=>e.name).join(`, `)}),(0,B.jsx)(`ul`,{children:t.models.map(e=>(0,B.jsxs)(`li`,{children:[e.name,`: `,e.ownership]},e.name))}),(0,B.jsx)(`h3`,{children:`Application References`}),(0,B.jsx)(`ul`,{children:(e?.collections??[]).flatMap(e=>e.fields.filter(e=>e.type.startsWith(`ref ${t.id}.`)).map(t=>(0,B.jsxs)(`li`,{children:[e.name,`.`,t.name,` → `,t.type.slice(4)]},`${e.name}.${t.name}`)))}),(0,B.jsx)(`h3`,{children:`Relationships`}),(0,B.jsx)(`ul`,{children:t.relationships.map(e=>(0,B.jsxs)(`li`,{children:[e.from,` → `,e.to,` (`,e.kind,`)`]},`${e.from}-${e.to}`))}),(0,B.jsx)(`h3`,{children:`Events`}),(0,B.jsx)(`p`,{children:t.events.join(`, `)}),(0,B.jsx)(`h3`,{children:`Capabilities`}),(0,B.jsx)(`p`,{children:t.capabilities.join(`, `)}),(0,B.jsx)(`h3`,{children:`Configuration`}),(0,B.jsx)(`p`,{children:t.configuration.map(e=>e.name).join(`, `)||`None`}),(0,B.jsx)(`h3`,{children:`Secrets`}),(0,B.jsxs)(`p`,{children:[t.secrets.map(e=>e.name).join(`, `),` (values are never included in the contract)`]}),(0,B.jsx)(`h3`,{children:`Reconciliation`}),(0,B.jsx)(`ul`,{children:t.reconciliation.map(e=>(0,B.jsxs)(`li`,{children:[e.event,` → `,e.workflow,` → `,e.writes.join(`, `)]},e.event))})]},`${t.id}@${t.version}`))]})}function ya({model:e,section:t}){return e?(0,B.jsxs)(`div`,{className:`studio-model-page`,children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`span`,{className:`eyebrow`,children:`Contract`}),(0,B.jsx)(`h1`,{children:t===`schema`?`Schema`:`Policies`})]}),t===`schema`?e.collections.map(e=>(0,B.jsxs)(`article`,{className:`studio-card`,children:[(0,B.jsx)(`h2`,{children:e.name}),(0,B.jsx)(`p`,{children:e.fields.map(e=>`${e.name}: ${e.type}${e.optional?`?`:``}`).join(` · `)}),(0,B.jsx)(z,{to:{pathname:`/data`,search:window.location.search},children:`Inspect records →`})]},e.name)):e.policies.map(e=>(0,B.jsxs)(`article`,{className:`studio-card`,children:[(0,B.jsx)(`h2`,{children:e.name}),(0,B.jsx)(`pre`,{children:e.statements.join(`
|
|
43
|
+
`)})]},e.name))]}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No active application contract.`})}var K={panel:`_panel_1cbba_1`,header:`_header_1cbba_8`,createButton:`_createButton_1cbba_23`,error:`_error_1cbba_38`,createForm:`_createForm_1cbba_47`,formGroup:`_formGroup_1cbba_55`,scopeList:`_scopeList_1cbba_76`,scopeCheckbox:`_scopeCheckbox_1cbba_82`,submitButton:`_submitButton_1cbba_94`,empty:`_empty_1cbba_109`,keysList:`_keysList_1cbba_117`,keyCard:`_keyCard_1cbba_123`,keyHeader:`_keyHeader_1cbba_135`,namespace:`_namespace_1cbba_150`,status:`_status_1cbba_156`,active:`_active_1cbba_163`,expired:`_expired_1cbba_168`,keyDetails:`_keyDetails_1cbba_173`,detail:`_detail_1cbba_179`,copyBtn:`_copyBtn_1cbba_203`,daysLeft:`_daysLeft_1cbba_217`,scopes:`_scopes_1cbba_223`,scopeTags:`_scopeTags_1cbba_227`,scopeTag:`_scopeTag_1cbba_227`,keyActions:`_keyActions_1cbba_243`,revokeBtn:`_revokeBtn_1cbba_250`,info:`_info_1cbba_265`},ba=({apiUrl:e,token:t,namespace:n=`app-store-sherpa`,onConfigure:r})=>{let[i,a]=(0,g.useState)([]),[o,s]=(0,g.useState)(!0),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)([`state:read`,`state:write`,`events:read`]),y=[`state:read`,`state:write`,`events:read`,`backup:create`,`backup:restore`,`admin:logs`,`admin:restart`],b=[`state:read`,`state:write`,`events:read`,`backup:create`,`backup:restore`,`admin:logs`,`admin:restart`];(0,g.useEffect)(()=>{x()},[e,t]);let x=async()=>{try{if(s(!0),l(null),!e){l(`A server or managed API URL is not configured.`),s(!1);return}let n=await fetch(`${e}/api/keys`,{headers:t?{Authorization:`Bearer ${t}`}:{},signal:AbortSignal.timeout(1e4)});if(n.status===401)throw Error(`Unauthorized: Invalid or expired API token`);if(n.status===403)throw Error(`Forbidden: Your account does not have permission to manage API keys`);if(!n.ok)throw Error(`Failed to fetch keys: ${n.status} ${n.statusText}`);let r=await n.json();a(r.tokens||[])}catch(t){let n=t instanceof TypeError?`Connection error: Unable to reach ${e}. Is the server running?`:t instanceof Error?t.message:`Failed to fetch keys`;l(n),console.error(`Error fetching API keys:`,t)}finally{s(!1)}},S=async r=>{r.preventDefault();try{let r=await fetch(`${e}/api/keys`,{method:`POST`,headers:{...t?{Authorization:`Bearer ${t}`}:{},"Content-Type":`application/json`},body:JSON.stringify({id:m||`key-${Date.now()}`,namespace:n,scopes:_.length>0?_:b}),signal:AbortSignal.timeout(1e4)});if(r.status===401)throw Error(`Unauthorized: Invalid or expired API token`);if(r.status===409)throw Error(`A key with this name already exists`);if(!r.ok)throw Error(`Failed to create key: ${r.status} ${r.statusText}`);let i=await r.json();E(i.secret),h(``),v(b),d(!1),await x()}catch(e){let t=e instanceof TypeError?`Connection error: Unable to reach the API server`:e instanceof Error?e.message:`Failed to create key`;l(t),console.error(`Error creating API key:`,e)}},C=async n=>{if(confirm(`Revoke key "${n}"? This cannot be undone.`))try{let r=await fetch(`${e}/api/keys/${n}`,{method:`DELETE`,headers:t?{Authorization:`Bearer ${t}`}:{},signal:AbortSignal.timeout(1e4)});if(r.status===404)throw Error(`Key not found`);if(r.status===401)throw Error(`Unauthorized: Invalid or expired API token`);if(!r.ok)throw Error(`Failed to revoke key: ${r.status} ${r.statusText}`);await x()}catch(e){let t=e instanceof TypeError?`Connection error: Unable to reach the API server`:e instanceof Error?e.message:`Failed to revoke key`;l(t),console.error(`Error revoking API key:`,e)}},w=(e,t)=>{navigator.clipboard.writeText(e),p(t),setTimeout(()=>p(null),2e3)},[T,E]=(0,g.useState)(null);return o?(0,B.jsx)(`div`,{className:K.panel,children:`Loading keys...`}):(0,B.jsxs)(`div`,{className:K.panel,children:[(0,B.jsxs)(`div`,{className:K.header,children:[(0,B.jsx)(`h2`,{children:`API Key Management`}),(0,B.jsx)(`button`,{className:K.createButton,onClick:()=>d(!u),disabled:!e,children:u?`✕ Cancel`:`+ New Key`})]}),c&&(0,B.jsxs)(`div`,{className:K.error,children:[(0,B.jsxs)(`strong`,{children:[`⚠ `,c]}),(0,B.jsx)(`div`,{style:{fontSize:`12px`,marginTop:`8px`,lineHeight:`1.5`},children:c.includes(`Connection error`)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{children:`To use API key management, ensure:`}),(0,B.jsxs)(`ul`,{style:{margin:`4px 0`,paddingLeft:`20px`},children:[(0,B.jsxs)(`li`,{children:[`FeltDB server is running on `,(0,B.jsx)(`code`,{children:e})]}),(0,B.jsx)(`li`,{children:`VITE_FELTDB_URL environment variable is set correctly`}),(0,B.jsx)(`li`,{children:`Your API token has proper scopes`})]}),(0,B.jsx)(`button`,{onClick:()=>x(),style:{marginTop:`8px`,padding:`4px 12px`,fontSize:`12px`,background:`#667eea`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`},children:`Retry`})]})})]}),!e&&(0,B.jsxs)(`div`,{className:K.error,children:[(0,B.jsx)(`strong`,{children:`Connect Studio to a server or managed runtime before managing keys.`}),r&&(0,B.jsx)(`button`,{onClick:r,children:`Open connection settings`})]}),T&&(0,B.jsxs)(`div`,{className:K.info,children:[(0,B.jsx)(`strong`,{children:`New secret — copy it now; it will not be shown again.`}),(0,B.jsx)(`code`,{children:T}),(0,B.jsx)(`button`,{onClick:()=>w(T,`created`),children:f===`created`?`✓ Copied`:`Copy secret`})]}),u&&(0,B.jsxs)(`form`,{onSubmit:S,className:K.createForm,children:[(0,B.jsxs)(`div`,{className:K.formGroup,children:[(0,B.jsx)(`label`,{children:`Key Name (optional)`}),(0,B.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`e.g., staging-key-001`})]}),(0,B.jsxs)(`div`,{className:K.formGroup,children:[(0,B.jsx)(`label`,{children:`Scopes`}),(0,B.jsx)(`div`,{className:K.scopeList,children:y.map(e=>(0,B.jsxs)(`label`,{className:K.scopeCheckbox,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:_.includes(e),onChange:t=>{t.target.checked?v([..._,e]):v(_.filter(t=>t!==e))}}),e]},e))})]}),(0,B.jsx)(`button`,{type:`submit`,className:K.submitButton,children:`Create Key`})]}),i.length===0?(0,B.jsx)(`div`,{className:K.empty,children:`No API keys configured. Create one to get started.`}):(0,B.jsx)(`div`,{className:K.keysList,children:i.map(e=>(0,B.jsxs)(`div`,{className:K.keyCard,children:[(0,B.jsxs)(`div`,{className:K.keyHeader,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{children:e.name||e.id}),(0,B.jsxs)(`p`,{className:K.namespace,children:[`Namespaces: `,e.namespaces.join(`, `)]})]}),(0,B.jsx)(`span`,{className:`${K.status} ${e.revoked?K.expired:K.active}`,children:e.revoked?`Revoked`:`Active`})]}),(0,B.jsx)(`div`,{className:K.keyDetails,children:(0,B.jsxs)(`div`,{className:K.scopes,children:[(0,B.jsx)(`strong`,{children:`Scopes:`}),(0,B.jsx)(`div`,{className:K.scopeTags,children:e.scopes.map(e=>(0,B.jsx)(`span`,{className:K.scopeTag,children:e},e))})]})}),(0,B.jsx)(`div`,{className:K.keyActions,children:(0,B.jsx)(`button`,{className:K.revokeBtn,onClick:()=>C(e.id),disabled:e.revoked,children:`Revoke`})})]},e.id))}),(0,B.jsx)(`div`,{className:K.info,children:(0,B.jsxs)(`p`,{children:[(0,B.jsx)(`strong`,{children:`Security:`}),` Store tokens securely. Never commit to version control. Secrets are shown once. Revoke and replace a key if its secret is lost.`]})})]})};function xa({db:e,remoteUrl:t=``,token:n=``,namespace:r=`default`,deploymentRuntime:i=`browser`,applicationUrl:a=``,applicationId:o=``,environment:s=`production`,developmentSession:c,managedPublish:l,sourceSync:u,onConnect:d}){let[f,p]=(0,g.useState)(null),m=Un(e||null,r),h=Wn(e||null,f,r),{diagnostics:_}=Gn(e||null),v=qn(e||null),[y,b]=(0,g.useState)(),x=i!==`browser`||!!t,[S,C]=(0,g.useState)([]),[w,T]=(0,g.useState)([]),[E,ee]=(0,g.useState)(0),D=e=>({pathname:e,search:window.location.search});return(0,g.useEffect)(()=>{let t=!0;return fetch(`/_feltdb/project`,{cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(`No project model endpoint`);let n=await e.json();t&&p(ai(n.source))}).catch(async()=>{let n=e?await e.collection(`_flow_apps`).all():[];t&&n[0]?.spec&&p(n[0].spec)}),()=>{t=!1}},[e]),(0,g.useEffect)(()=>{if(!c?.sessionId)return;let e=!0,t=()=>void fetch(`/_feltdb/runtime`,{cache:`no-store`}).then(e=>e.ok?e.json():{runtimes:[]}).then(t=>{e&&C(t.runtimes||[])}).catch(()=>{e&&C([])});t();let n=window.setInterval(t,2e3);return()=>{e=!1,window.clearInterval(n)}},[c?.sessionId]),(0,g.useEffect)(()=>{let e=S[0]?.runtimeInstanceId;if(!e){T([]);return}let t=!0,n=0,r=()=>void fetch(`/_feltdb/observations?runtimeInstanceId=${encodeURIComponent(e)}&cursor=${n}&limit=100`,{cache:`no-store`}).then(e=>e.ok?e.json():{observations:[]}).then(e=>{t&&(n=e.nextCursor??n,ee(e.dropped||0),T(t=>[...t,...e.observations||[]].slice(-200)))}).catch(()=>void 0);r();let i=window.setInterval(r,1e3);return()=>{t=!1,window.clearInterval(i)}},[S[0]?.runtimeInstanceId]),(0,B.jsx)(_n,{children:(0,B.jsxs)(`div`,{className:`studio-app`,children:[(0,B.jsxs)(`nav`,{className:`studio-nav`,children:[(0,B.jsxs)(`div`,{className:`nav-header`,children:[(0,B.jsx)(`h1`,{children:`FeltDB Studio`}),m&&(0,B.jsx)(`div`,{className:`instance-info`,children:m.namespace})]}),(0,B.jsx)(`div`,{className:`nav-search`,children:(0,B.jsx)(nr,{db:e,model:f})}),(0,B.jsxs)(`ul`,{className:`nav-menu`,children:[(0,B.jsx)(`li`,{className:`nav-section`,children:`Design`}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/`),children:`Application`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/capabilities`),children:`Capabilities`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/schema`),children:`Schema`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/policies`),children:`Policies`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/workflows`),children:`Workflows`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/agents`),children:`Agents`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/modules`),children:`Modules`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/proposals`),children:`Proposals`})}),(0,B.jsx)(`li`,{className:`nav-section`,children:`Observe`}),c?.sessionId&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/activity`),children:`Live Activity`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/overview`),children:`Overview`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/data`),children:`Data`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/references`),children:`References`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/operations`),children:`Operations`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/executions`),children:`Executions`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/peers`),children:`Peers`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/provenance`),children:`Provenance`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/conflicts`),children:`Conflicts`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/health`),children:`Health`})}),(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/settings`),children:`Settings`})}),x&&(0,B.jsx)(`li`,{children:(0,B.jsx)(z,{to:D(`/api-keys`),children:`API Keys`})})]})]}),(0,B.jsxs)(`main`,{className:`studio-content`,children:[c?.sessionId&&(0,B.jsxs)(`div`,{className:`runtime-notice`,children:[`Application runtime: `,S.length?`Connected ✓ (${S[0].runtime}, ${S[0].namespace})`:`Not connected`]}),!x&&(0,B.jsx)(`div`,{className:`runtime-notice`,children:`Browser data is read live from the generated application origin through the local Studio bridge.`}),(0,B.jsxs)(Nt,{children:[(0,B.jsx)(L,{path:`/`,element:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(oa,{configuration:u,onApplied:()=>window.location.reload()}),(0,B.jsx)(aa,{db:e,namespace:r,projectSpec:f,managedPublish:l,onSpecChange:p})]})}),(0,B.jsx)(L,{path:`/overview`,element:(0,B.jsx)(kn,{stats:h})}),(0,B.jsx)(L,{path:`/activity`,element:(0,B.jsxs)(`div`,{className:`runtime-activity`,children:[(0,B.jsx)(`h1`,{children:`Live Activity`}),(0,B.jsxs)(`p`,{children:[w.some(e=>Date.now()-e.timestamp<5e3)?`Active`:`Idle`,` · Runtime `,S[0]?.runtimeInstanceId||`not connected`]}),E>0&&(0,B.jsxs)(`p`,{className:`runtime-notice`,children:[`Observation is incomplete: `,E,` events dropped.`]}),(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Time`}),(0,B.jsx)(`th`,{children:`Operation`}),(0,B.jsx)(`th`,{children:`Collection`}),(0,B.jsx)(`th`,{children:`Status`}),(0,B.jsx)(`th`,{children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:[...w].reverse().map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:new Date(e.timestamp).toLocaleTimeString()}),(0,B.jsx)(`td`,{children:e.operation?.type}),(0,B.jsx)(`td`,{children:e.operation?.collection||`—`}),(0,B.jsx)(`td`,{children:e.status}),(0,B.jsx)(`td`,{children:e.durationMs===void 0?`—`:`${e.durationMs} ms`})]},e.cursor||e.eventId))})]})]})}),(0,B.jsx)(L,{path:`/data`,element:o?(0,B.jsx)(Ln,{serviceUrl:t,token:n,applicationId:o,environment:s}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No active application is selected. Open Studio from a FeltDB application environment.`})}),(0,B.jsx)(L,{path:`/state`,element:o?(0,B.jsx)(Ln,{serviceUrl:t,token:n,applicationId:o,environment:s}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No active application is selected. Open Studio from a FeltDB application environment.`})}),(0,B.jsx)(L,{path:`/references`,element:(0,B.jsx)(zn,{db:e,model:f,namespace:r})}),(0,B.jsx)(L,{path:`/operations`,element:(0,B.jsx)(Bn,{db:e,model:f,namespace:r})}),(0,B.jsx)(L,{path:`/peers`,element:(0,B.jsx)(Vn,{peers:v,localInstance:m?.instanceId})}),(0,B.jsx)(L,{path:`/capabilities`,element:(0,B.jsx)(Hn,{db:e,model:f})}),(0,B.jsx)(L,{path:`/executions`,element:(0,B.jsx)(Yn,{db:e,model:f})}),(0,B.jsx)(L,{path:`/workflows`,element:(0,B.jsx)(Zn,{db:e,model:f})}),(0,B.jsx)(L,{path:`/agents`,element:(0,B.jsx)(Qn,{db:e,model:f})}),(0,B.jsx)(L,{path:`/proposals`,element:o?(0,B.jsx)(_a,{serviceUrl:t,token:n,applicationId:o,environment:s,applicationName:f?.app,sourceSync:u}):(0,B.jsx)(`div`,{className:`model-empty`,children:`No active application is selected.`})}),(0,B.jsx)(L,{path:`/modules`,element:(0,B.jsx)(va,{model:f})}),(0,B.jsx)(L,{path:`/schema`,element:(0,B.jsx)(ya,{model:f,section:`schema`})}),(0,B.jsx)(L,{path:`/policies`,element:(0,B.jsx)(ya,{model:f,section:`policies`})}),(0,B.jsx)(L,{path:`/provenance`,element:(0,B.jsx)($n,{db:e,model:f,namespace:r,reference:y})}),(0,B.jsx)(L,{path:`/conflicts`,element:(0,B.jsx)(Xn,{db:e,diagnostics:_})}),(0,B.jsx)(L,{path:`/health`,element:(0,B.jsx)(er,{diagnostics:_,model:f})}),(0,B.jsx)(L,{path:`/settings`,element:(0,B.jsx)(tr,{db:e,remoteUrl:t,token:n,onConnect:d})}),(0,B.jsx)(L,{path:`/api-keys`,element:(0,B.jsxs)(`div`,{style:{padding:`2rem`},children:[(0,B.jsx)(`h1`,{children:`API Key Management`}),(0,B.jsx)(ba,{apiUrl:t,token:n,namespace:r,onConfigure:()=>window.location.assign(`/settings`)})]})})]})]})]})})}var q=new URLSearchParams(window.location.search),Sa=q.get(`connect`)||``,Ca=q.get(`namespace`)||`default`,wa=q.get(`runtime`)||(Sa?`remote`:`browser`),Ta=q.get(`app`)||``,Ea=q.get(`application_id`)||q.get(`application`)||``,Da=q.get(`environment`)||`production`,Oa=Object.freeze({sessionId:q.get(`session`)||``,workspaceId:q.get(`workspace`)||``,namespace:Ca,runtime:wa,authorityUrl:q.get(`authority`)||Sa,pairingUrl:q.get(`pairing`)||``,bridgeUrl:q.get(`pairing`)||``,applicationUrl:Ta});Object.defineProperty(window,"feltdbDevelopmentSession",{value:Oa,configurable:!1});function ka(){let[e,t]=(0,g.useState)(Sa),[n,r]=(0,g.useState)(()=>Sa?window.sessionStorage.getItem(`feltdb-token:${Sa}`):``),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null);g.useEffect(()=>{let e=!0;return fetch(`/_feltdb/config`,{cache:`no-store`}).then(async e=>e.ok?e.json():{}).then(t=>{if(!e)return;a(t.managedPublish||null),s(t.sourceSync||null);let i=t.token||``;i&&window.sessionStorage.setItem(`feltdb-token:${Sa}`,i),n===null&&r(i)}).catch(()=>{e&&r(``)}),()=>{e=!1}},[]);let c=(0,g.useMemo)(()=>n===null?null:window.feltdb||Qi(e?{namespace:Ca,server:{url:e,token:n}}:{namespace:Ca,browser:!0}),[e,n]);return n===null?(0,B.jsx)(`div`,{style:{padding:`2rem`},children:`Connecting Studio…`}):(0,B.jsx)(xa,{db:c||void 0,remoteUrl:e,token:n,namespace:Ca,deploymentRuntime:wa,applicationUrl:Ta,applicationId:i?.applicationId||Ea,environment:i?.environment||Da,developmentSession:Oa,managedPublish:i||void 0,sourceSync:o||void 0,onConnect:(e,n)=>{let i=e.trim().replace(/\/$/,``);i&&n&&window.sessionStorage.setItem(`feltdb-token:${i}`,n),t(i),r(n)}})}_.createRoot(document.getElementById(`root`)).render((0,B.jsx)(g.StrictMode,{children:(0,B.jsx)(ka,{})}));export{Li as n,x as r,Fi as t};
|