likec4 1.55.1 → 1.57.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/__app__/chunks/AIChat2.mjs +2 -0
- package/__app__/chunks/DiagramActorProvider.mjs +10 -0
- package/__app__/chunks/EmbedPage.mjs +1 -0
- package/__app__/chunks/ExportPage.mjs +2 -0
- package/__app__/chunks/LikeC4Diagram.mjs +19 -0
- package/__app__/chunks/LikeC4Styles.mjs +48 -0
- package/__app__/chunks/Markdown.mjs +1 -0
- package/__app__/chunks/NavigationPanel.mjs +1 -0
- package/__app__/chunks/ViewReact.mjs +1 -0
- package/__app__/chunks/adhoc-editor.mjs +1 -0
- package/__app__/chunks/aichat.mjs +1 -0
- package/__app__/chunks/box.mjs +1 -0
- package/__app__/chunks/create-style-context.mjs +1 -0
- package/__app__/chunks/css.mjs +1 -0
- package/__app__/chunks/factory.mjs +1 -0
- package/__app__/chunks/hooks.mjs +1 -0
- package/__app__/chunks/hstack.mjs +1 -0
- package/__app__/chunks/libs/@dagrejs/dagre.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/core.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/dom.mjs +1 -0
- package/__app__/chunks/libs/@floating-ui/react.mjs +1 -0
- package/__app__/chunks/libs/@mantine/core.mjs +41 -0
- package/__app__/chunks/libs/@mantine/hooks.mjs +1 -0
- package/__app__/chunks/libs/@nanostores/react.mjs +1 -0
- package/__app__/chunks/libs/@react-hookz/web.mjs +1 -0
- package/__app__/chunks/libs/@tabler/icons-react.mjs +358 -0
- package/__app__/chunks/libs/@tanstack/ai-client.mjs +2 -0
- package/__app__/chunks/libs/@tanstack/ai-react-ui.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/ai-react.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/ai.mjs +2 -0
- package/__app__/chunks/libs/@tanstack/history.mjs +1 -0
- package/__app__/chunks/libs/@tanstack/react-router.mjs +3 -0
- package/__app__/chunks/libs/@tanstack/router-core.mjs +1 -0
- package/__app__/chunks/libs/@xstate/react.mjs +1 -0
- package/__app__/chunks/libs/@xstate/store.mjs +1 -0
- package/__app__/chunks/libs/@xyflow/react.mjs +7 -0
- package/__app__/chunks/libs/@zag-js/anatomy.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/collection.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/core.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/react.mjs +1 -0
- package/__app__/chunks/libs/@zag-js/tree-view.mjs +1 -0
- package/__app__/chunks/libs/bezier-js.mjs +1 -0
- package/__app__/chunks/libs/copy-anything.mjs +1 -0
- package/__app__/chunks/libs/d3-path.mjs +1 -0
- package/__app__/chunks/libs/d3-shape.mjs +1 -0
- package/__app__/chunks/libs/fast-equals.mjs +1 -0
- package/__app__/chunks/libs/framer-motion.mjs +9 -0
- package/__app__/chunks/libs/html-to-image.mjs +2 -0
- package/__app__/chunks/libs/motion-dom.mjs +1 -0
- package/__app__/chunks/libs/nanostores.mjs +1 -0
- package/__app__/chunks/libs/react-error-boundary.mjs +1 -0
- package/__app__/chunks/libs/react-resizable-panels.mjs +1 -0
- package/__app__/chunks/libs/remeda.mjs +1 -0
- package/__app__/chunks/libs/superjson.mjs +1 -0
- package/__app__/chunks/libs/zod.mjs +64 -0
- package/__app__/chunks/rolldown-runtime.mjs +1 -0
- package/__app__/chunks/styles.css.mjs +1 -0
- package/__app__/chunks/txt.mjs +1 -0
- package/__app__/chunks/useLikeC4Project.mjs +1 -0
- package/__app__/codegen/react.mjs +11 -0
- package/__app__/codegen/webcomponent.mjs +942 -0
- package/__app__/src/aichat/index.mjs +1 -0
- package/__app__/src/fonts.css +1 -1
- package/__app__/src/main.mjs +45 -0
- package/__app__/src/pages/AdHocViewEditor.mjs +1 -0
- package/__app__/src/pages/EmbedPage.mjs +1 -0
- package/__app__/src/pages/ExportPage.mjs +1 -0
- package/__app__/src/pages/ProjectsOverview.mjs +1 -0
- package/__app__/src/pages/ViewAsD2.mjs +1 -0
- package/__app__/src/pages/ViewAsDot.mjs +1 -0
- package/__app__/src/pages/ViewAsMmd.mjs +1 -0
- package/__app__/src/pages/ViewAsPuml.mjs +1 -0
- package/__app__/src/pages/ViewEditor.mjs +1 -0
- package/__app__/src/pages/ViewReact.mjs +1 -0
- package/__app__/src/style.css +1 -1
- package/config/schema.json +14 -41
- package/dist/chunks/enableServer.mjs +1 -0
- package/dist/chunks/filenames.mjs +17 -0
- package/dist/{_chunks → chunks}/index.d.mts +2 -1
- package/dist/{_chunks → chunks}/index2.d.mts +639 -388
- package/dist/chunks/libs/@chevrotain/gast.mjs +1 -0
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
- package/dist/chunks/libs/@chevrotain/utils.mjs +1 -0
- package/dist/chunks/libs/@hono/mcp.mjs +70 -0
- package/dist/chunks/libs/@hono/node-server.mjs +1 -0
- package/dist/{_chunks → chunks}/libs/@logtape/logtape.d.mts +2 -0
- package/dist/chunks/libs/@logtape/logtape.mjs +4 -0
- package/dist/chunks/libs/@lume/kiwi.mjs +1 -0
- package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +12 -0
- package/dist/chunks/libs/@ts-graphviz/ast.mjs +3 -0
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +9 -0
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -0
- package/dist/chunks/libs/ajv.mjs +1 -0
- package/dist/chunks/libs/ansi-align.mjs +2 -0
- package/dist/chunks/libs/ansi-regex.mjs +1 -0
- package/dist/chunks/libs/ansi-styles.mjs +1 -0
- package/dist/chunks/libs/atomically.mjs +1 -0
- package/dist/chunks/libs/birpc.mjs +1 -0
- package/dist/chunks/libs/boxen.mjs +22 -0
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -0
- package/dist/chunks/libs/chevrotain.mjs +58 -0
- package/dist/chunks/libs/conf.mjs +1 -0
- package/dist/chunks/libs/defu.mjs +1 -0
- package/dist/chunks/libs/destr.mjs +1 -0
- package/dist/chunks/libs/eventemitter3.mjs +1 -0
- package/dist/chunks/libs/find-up-simple.mjs +1 -0
- package/dist/chunks/libs/get-port.mjs +1 -0
- package/dist/chunks/libs/hono.mjs +1 -0
- package/dist/chunks/libs/is-docker.mjs +1 -0
- package/dist/chunks/libs/is-error-instance.mjs +1 -0
- package/dist/chunks/libs/is-inside-container.mjs +1 -0
- package/dist/chunks/libs/is-plain-obj.mjs +1 -0
- package/dist/chunks/libs/isexe.mjs +1 -0
- package/dist/chunks/libs/json5.mjs +14 -0
- package/dist/chunks/libs/khroma.mjs +1 -0
- package/dist/chunks/libs/ky.mjs +3 -0
- package/dist/{_chunks → chunks}/libs/langium.d.mts +9 -9
- package/dist/chunks/libs/langium.mjs +32 -0
- package/dist/chunks/libs/merge-error-cause.mjs +2 -0
- package/dist/chunks/libs/p-debounce.mjs +1 -0
- package/dist/chunks/libs/p-limit.mjs +1 -0
- package/dist/chunks/libs/p-queue.mjs +1 -0
- package/dist/chunks/libs/p-timeout.mjs +1 -0
- package/dist/chunks/libs/package-manager-detector.mjs +1 -0
- package/dist/chunks/libs/package-up.mjs +1 -0
- package/dist/chunks/libs/pako.mjs +3 -0
- package/dist/chunks/libs/parse-ms.mjs +1 -0
- package/dist/chunks/libs/pathe.mjs +1 -0
- package/dist/chunks/libs/picomatch.mjs +1 -0
- package/dist/chunks/libs/pretty-ms.mjs +1 -0
- package/dist/chunks/libs/remeda.mjs +1 -0
- package/dist/chunks/libs/safe-stringify.mjs +1 -0
- package/dist/chunks/libs/strip-indent.mjs +1 -0
- package/dist/chunks/libs/tinyrainbow.mjs +1 -0
- package/dist/chunks/libs/ts-graphviz.mjs +1 -0
- package/dist/chunks/libs/ufo.mjs +1 -0
- package/dist/chunks/libs/unctx.mjs +1 -0
- package/dist/chunks/libs/unstorage.mjs +1 -0
- package/dist/chunks/libs/vscode-languageserver.mjs +1 -0
- package/dist/chunks/libs/which.mjs +1 -0
- package/dist/chunks/libs/word-wrap.mjs +12 -0
- package/dist/{_chunks → chunks}/libs/zod.d.mts +62 -25
- package/dist/chunks/node.mjs +93 -0
- package/dist/chunks/plugin.mjs +593 -0
- package/dist/chunks/rolldown-runtime.mjs +1 -0
- package/dist/chunks/sequence-view.mjs +1 -0
- package/dist/cli/index.mjs +188 -59
- package/dist/config/index.d.mts +1 -2
- package/dist/config/index.mjs +1 -1
- package/dist/index.d.mts +2 -135
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +3 -2
- package/dist/model/index.mjs +1 -1
- package/dist/vite-plugin/index.d.mts +90 -9
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +1 -0
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -0
- package/dist/{_chunks/libs/@nanostores/react.d.mts → vite-plugin/internal/index.d.mts} +103 -45
- package/dist/vite-plugin/internal/index.mjs +1 -0
- package/package.json +74 -80
- package/react/index.d.mts +84 -78
- package/react/index.mjs +51954 -53701
- package/vite-plugin/internal/package.json +2 -2
- package/vite-plugin-modules.d.ts +18 -0
- package/__app__/react/likec4.tsx +0 -25
- package/__app__/src/ProjectsOverview.js +0 -16
- package/__app__/src/const.js +0 -19
- package/__app__/src/likec4.js +0 -21254
- package/__app__/src/main.js +0 -7
- package/__app__/src/routes/index.js +0 -324
- package/__app__/src/routes/projects.js +0 -193
- package/__app__/src/routes/single.js +0 -1983
- package/__app__/src/vendors.js +0 -52683
- package/__app__/src/webcomponent.js +0 -68
- package/dist/THIRD-PARTY-LICENSES.md +0 -1609
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -30
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
- package/dist/_chunks/libs/@chevrotain/types.d.mts +0 -1
- package/dist/_chunks/libs/@chevrotain/utils.mjs +0 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +0 -45
- package/dist/_chunks/libs/@hono/node-server.mjs +0 -1
- package/dist/_chunks/libs/@logtape/logtape.mjs +0 -4
- package/dist/_chunks/libs/@lume/kiwi.mjs +0 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
- package/dist/_chunks/libs/@nanostores/react.mjs +0 -1
- package/dist/_chunks/libs/ajv.mjs +0 -1
- package/dist/_chunks/libs/ansi-align.mjs +0 -2
- package/dist/_chunks/libs/ansi-regex.mjs +0 -1
- package/dist/_chunks/libs/ansi-styles.mjs +0 -1
- package/dist/_chunks/libs/atomically.mjs +0 -1
- package/dist/_chunks/libs/birpc.mjs +0 -1
- package/dist/_chunks/libs/boxen.mjs +0 -22
- package/dist/_chunks/libs/chevrotain-allstar.mjs +0 -2
- package/dist/_chunks/libs/chevrotain.mjs +0 -58
- package/dist/_chunks/libs/conf.mjs +0 -1
- package/dist/_chunks/libs/defu.mjs +0 -1
- package/dist/_chunks/libs/destr.mjs +0 -1
- package/dist/_chunks/libs/esm-env.mjs +0 -1
- package/dist/_chunks/libs/eventemitter3.mjs +0 -1
- package/dist/_chunks/libs/fast-equals.mjs +0 -1
- package/dist/_chunks/libs/find-up-simple.mjs +0 -1
- package/dist/_chunks/libs/get-port.mjs +0 -1
- package/dist/_chunks/libs/is-docker.mjs +0 -1
- package/dist/_chunks/libs/is-error-instance.mjs +0 -1
- package/dist/_chunks/libs/is-inside-container.mjs +0 -1
- package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
- package/dist/_chunks/libs/isexe.mjs +0 -1
- package/dist/_chunks/libs/json5.mjs +0 -14
- package/dist/_chunks/libs/khroma.mjs +0 -1
- package/dist/_chunks/libs/ky.mjs +0 -3
- package/dist/_chunks/libs/langium.mjs +0 -33
- package/dist/_chunks/libs/merge-error-cause.mjs +0 -2
- package/dist/_chunks/libs/p-limit.mjs +0 -1
- package/dist/_chunks/libs/p-queue.mjs +0 -1
- package/dist/_chunks/libs/p-timeout.mjs +0 -1
- package/dist/_chunks/libs/package-manager-detector.mjs +0 -1
- package/dist/_chunks/libs/package-up.mjs +0 -1
- package/dist/_chunks/libs/pako.mjs +0 -1
- package/dist/_chunks/libs/parse-ms.mjs +0 -1
- package/dist/_chunks/libs/pathe.mjs +0 -1
- package/dist/_chunks/libs/picomatch.mjs +0 -1
- package/dist/_chunks/libs/pretty-ms.mjs +0 -1
- package/dist/_chunks/libs/remeda.mjs +0 -2
- package/dist/_chunks/libs/safe-stringify.mjs +0 -1
- package/dist/_chunks/libs/strip-indent.mjs +0 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +0 -1
- package/dist/_chunks/libs/ts-graphviz.d.mts +0 -10
- package/dist/_chunks/libs/ts-graphviz.mjs +0 -4
- package/dist/_chunks/libs/ufo.mjs +0 -1
- package/dist/_chunks/libs/unstorage.mjs +0 -1
- package/dist/_chunks/libs/vscode-languageserver.mjs +0 -1
- package/dist/_chunks/libs/which.mjs +0 -1
- package/dist/_chunks/libs/word-wrap.mjs +0 -12
- package/dist/_chunks/node.mjs +0 -76
- package/dist/_chunks/rolldown-runtime.mjs +0 -1
- package/dist/_chunks/sequence.mjs +0 -1
- package/dist/_chunks/src.mjs +0 -17
- package/dist/_chunks/src2.mjs +0 -499
- package/dist/vite-plugin/internal.d.mts +0 -44
- package/dist/vite-plugin/internal.mjs +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{t as e}from"../../rolldown-runtime.mjs";import{i as t,r as n,t as r}from"./history.mjs";import*as i from"react";import{useRef as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";import{useSyncExternalStoreWithSelector as l}from"use-sync-external-store/shim/with-selector.js";import{flushSync as u}from"react-dom";var d=!0,f=`Invariant failed`;function p(e,t){if(!e){if(d)throw Error(f);var n=typeof t==`function`?t():t,r=n?`${f}: ${n}`:f;throw Error(r)}}var m=!0;function h(e,t){if(!m){if(e)return;var n=`Warning: `+t;typeof console<`u`&&console.warn(n);try{throw Error(n)}catch{}}}const g=new WeakMap,_=new WeakMap,v={current:[]};let y=!1,b=0;const x=new Set,S=new Map;function C(e){let t=Array.from(e).sort((e,t)=>e instanceof k&&e.options.deps.includes(t)?1:t instanceof k&&t.options.deps.includes(e)?-1:0);for(let e of t){if(v.current.includes(e))continue;v.current.push(e),e.recompute();let t=_.get(e);if(t)for(let e of t){let t=g.get(e);t&&C(t)}}}function w(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function T(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function E(e){if(b>0&&!S.has(e)&&S.set(e,e.prevState),x.add(e),!(b>0)&&!y)try{for(y=!0;x.size>0;){let e=Array.from(x);x.clear();for(let t of e)t.prevState=S.get(t)??t.prevState,w(t);for(let t of e){let e=g.get(t);e&&(v.current.push(t),C(e))}for(let t of e){let e=g.get(t);if(e)for(let t of e)T(t)}}}finally{y=!1,v.current=[],S.clear()}}function D(e){b++;try{e()}finally{if(b--,b===0){let e=Array.from(x)[0];e&&E(e)}}}var O=class{constructor(e,t){this.listeners=new Set,this.subscribe=e=>{var t;this.listeners.add(e);let n=((t=this.options)?.onSubscribe)?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.setState=e=>{var t,n;this.prevState=this.state,this.state=this.options?.updateFn?this.options.updateFn(this.prevState)(e):e(this.prevState),(n=(t=this.options)?.onUpdate)==null||n.call(t),E(this)},this.prevState=e,this.state=e,this.options=t}},k=class e{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{let e=[],t=[];for(let n of this.options.deps)e.push(n.prevState),t.push(n.state);return this.lastSeenDepValues=t,{prevDepVals:e,currDepVals:t,prevVal:this.prevState??void 0}},this.recompute=()=>{var e,t;this.prevState=this.state;let{prevDepVals:n,currDepVals:r,prevVal:i}=this.getDepVals();this.state=this.options.fn({prevDepVals:n,currDepVals:r,prevVal:i}),(t=(e=this.options).onUpdate)==null||t.call(e)},this.checkIfRecalculationNeededDeeply=()=>{for(let t of this.options.deps)t instanceof e&&t.checkIfRecalculationNeededDeeply();let t=!1,n=this.lastSeenDepValues,{currDepVals:r}=this.getDepVals();for(let e=0;e<r.length;e++)if(r[e]!==n[e]){t=!0;break}t&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(let e of this._subscriptions)e()}),this.subscribe=e=>{var t;this.listeners.add(e);let n=(t=this.options).onSubscribe?.call(t,e,this);return()=>{this.listeners.delete(e),n?.()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(let n of t)if(n instanceof e)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof O){let e=g.get(n);e||(e=new Set,g.set(n,e)),e.add(this);let t=_.get(this);t||(t=new Set,_.set(this,t)),t.add(n)}}unregisterFromGraph(t=this.options.deps){for(let n of t)if(n instanceof e)this.unregisterFromGraph(n.options.deps);else if(n instanceof O){let e=g.get(n);e&&e.delete(this);let t=_.get(this);t&&t.delete(n)}}};function A(e){return e[e.length-1]}function ee(e){return typeof e==`function`}function j(e,t){return ee(e)?e(t):e}function M(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function N(e,t){if(e===t)return e;let n=t,r=ne(e)&&ne(n);if(r||P(e)&&P(n)){let t=r?e:Object.keys(e),i=t.length,a=r?n:Object.keys(n),o=a.length,s=r?[]:{},c=0;for(let i=0;i<o;i++){let o=r?i:a[i];(!r&&t.includes(o)||r)&&e[o]===void 0&&n[o]===void 0?(s[o]=void 0,c++):(s[o]=N(e[o],n[o]),s[o]===e[o]&&e[o]!==void 0&&c++)}return i===o&&c===i?e:s}return n}function P(e){if(!te(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!te(n)||!n.hasOwnProperty(`isPrototypeOf`))}function te(e){return Object.prototype.toString.call(e)===`[object Object]`}function ne(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function re(e,t){let n=Object.keys(e);return t&&(n=n.filter(t=>e[t]!==void 0)),n}function F(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(P(e)&&P(t)){let r=n?.ignoreUndefined??!0,i=re(e,r),a=re(t,r);return!n?.partial&&i.length!==a.length?!1:a.every(r=>F(e[r],t[r],n))}return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length?!e.some((e,r)=>!F(e,t[r],n)):!1}function I(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function ie(e){return/%[0-9A-Fa-f]{2}/.test(e)}function L(e){return R(e.filter(e=>e!==void 0).join(`/`))}function R(e){return e.replace(/\/{2,}/g,`/`)}function z(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function B(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function V(e){return B(z(e))}function ae(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function oe(e,t,n){return ae(e,n)===ae(t,n)}function se({basepath:e,base:t,to:n,trailingSlash:r=`never`,caseSensitive:i}){t=G(e,t,i),n=G(e,n,i);let a=H(t),o=H(n);return a.length>1&&A(a)?.value===`/`&&a.pop(),o.forEach((e,t)=>{e.value===`/`?t?t===o.length-1&&a.push(e):a=[e]:e.value===`..`?a.pop():e.value===`.`||a.push(e)}),a.length>1&&(A(a)?.value===`/`?r===`never`&&a.pop():r===`always`&&a.push({type:`pathname`,value:`/`})),R(L([e,...a.map(e=>e.value)]))}function H(e){if(!e)return[];e=R(e);let t=[];if(e.slice(0,1)===`/`&&(e=e.substring(1),t.push({type:`pathname`,value:`/`})),!e)return t;let n=e.split(`/`).filter(Boolean);return t.push(...n.map(e=>e===`$`||e===`*`?{type:`wildcard`,value:e}:e.charAt(0)===`$`?{type:`param`,value:e}:{type:`pathname`,value:e.includes(`%25`)?e.split(`%25`).map(e=>decodeURI(e)).join(`%25`):decodeURI(e)})),e.slice(-1)===`/`&&(e=e.substring(1),t.push({type:`pathname`,value:`/`})),t}function U({path:e,params:t,leaveWildcards:n,leaveParams:r,decodeCharMap:i}){let a=H(e);function o(e){let n=t[e],r=typeof n==`string`;return[`*`,`_splat`].includes(e)?r?encodeURI(n):n:r?ce(n,i):n}let s={};return{usedParams:s,interpolatedPath:L(a.map(e=>{if(e.type===`wildcard`){s._splat=t._splat;let r=o(`_splat`);return n?`${e.value}${r??``}`:r}if(e.type===`param`){let n=e.value.substring(1);if(s[n]=t[n],r){let t=o(e.value);return`${e.value}${t??``}`}return o(n)??`undefined`}return e.value}))}}function ce(e,t){let n=encodeURIComponent(e);if(t)for(let[e,r]of t)n=n.replaceAll(e,r);return n}function W(e,t,n){let r=le(e,t,n);if(!(n.to&&!r))return r??{}}function G(e,t,n=!1){let r=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();switch(!0){case r===`/`:return t;case i===r:return``;case t.length<e.length:return t;case i[r.length]!==`/`:return t;case i.startsWith(r):return t.slice(e.length);default:return t}}function le(e,t,n){if(e!==`/`&&!t.startsWith(e))return;t=G(e,t,n.caseSensitive);let r=G(e,`${n.to??`$`}`,n.caseSensitive),i=H(t),a=H(r);t.startsWith(`/`)||i.unshift({type:`pathname`,value:`/`}),r.startsWith(`/`)||a.unshift({type:`pathname`,value:`/`});let o={};return(()=>{for(let e=0;e<Math.max(i.length,a.length);e++){let t=i[e],r=a[e],s=e>=i.length-1,c=e>=a.length-1;if(r){if(r.type===`wildcard`){let t=decodeURI(L(i.slice(e).map(e=>e.value)));return o[`*`]=t,o._splat=t,!0}if(r.type===`pathname`){if(r.value===`/`&&!t?.value)return!0;if(t){if(n.caseSensitive){if(r.value!==t.value)return!1}else if(r.value.toLowerCase()!==t.value.toLowerCase())return!1}}if(!t)return!1;if(r.type===`param`){if(t.value===`/`)return!1;t.value.charAt(0)!==`$`&&(o[r.value.substring(1)]=decodeURIComponent(t.value))}}if(!s&&c)return o[`**`]=L(i.slice(e+1).map(e=>e.value)),!!n.fuzzy&&r?.value!==`/`}return!0})()?o:void 0}function ue(e={}){if(e.isNotFound=!0,e.throw)throw e;return e}function K(e){return!!e?.isNotFound}const q=`tsr-scroll-restoration-v1_3`;let de=!1;try{de=typeof window<`u`&&typeof window.sessionStorage==`object`}catch{}const fe=(e,t)=>{let n;return(...r)=>{n||=setTimeout(()=>{e(...r),n=null},t)}},J=de?{state:JSON.parse(window.sessionStorage.getItem(`tsr-scroll-restoration-v1_3`)||`null`)||{},set:e=>(J.state=j(e,J.state)||J.state,window.sessionStorage.setItem(q,JSON.stringify(J.state)))}:void 0,pe=e=>e.state.key||e.href;function me(e){let t=[],n;for(;n=e.parentNode;)t.unshift(`${e.tagName}:nth-child(${[].indexOf.call(n.children,e)+1})`),e=n;return`${t.join(` > `)}`.toLowerCase()}let he=!1;function ge(e,t,n,r,i){let a;try{a=JSON.parse(sessionStorage.getItem(e)||`{}`)}catch(e){console.error(e);return}let o=t||window.history.state?.key,s=a[o];he=!0,(()=>{if(r&&s){for(let e in s){let t=s[e];if(e===`window`)window.scrollTo({top:t.scrollY,left:t.scrollX,behavior:n});else if(e){let n=document.querySelector(e);n&&(n.scrollLeft=t.scrollX,n.scrollTop=t.scrollY)}}return}let e=window.location.hash.split(`#`)[1];if(e){let t=(window.history.state||{}).__hashScrollIntoViewOptions??!0;if(t){let n=document.getElementById(e);n&&n.scrollIntoView(t)}return}[`window`,...i?.filter(e=>e!==`window`)??[]].forEach(e=>{let t=e===`window`?window:document.querySelector(e);t&&t.scrollTo({top:0,left:0,behavior:n})})})(),he=!1}function _e(e,t){if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),typeof document>`u`||e.isScrollRestorationSetup)return;e.isScrollRestorationSetup=!0,he=!1;let n=e.options.getScrollRestorationKey||pe;window.history.scrollRestoration=`manual`,typeof document<`u`&&document.addEventListener(`scroll`,fe(t=>{if(he||!e.isScrollRestoring)return;let r=``;if(t.target===document||t.target===window)r=`window`;else{let e=t.target.getAttribute(`data-scroll-restoration-id`);r=e?`[data-scroll-restoration-id="${e}"]`:me(t.target)}let i=n(e.state.location);J.set(e=>{let t=e[i]=e[i]||{},n=t[r]=t[r]||{};if(r===`window`)n.scrollX=window.scrollX||0,n.scrollY=window.scrollY||0;else if(r){let e=document.querySelector(r);e&&(n.scrollX=e.scrollLeft||0,n.scrollY=e.scrollTop||0)}return e})},100),!0),e.subscribe(`onRendered`,t=>{let r=n(t.toLocation);if(!e.resetNextScroll){e.resetNextScroll=!0;return}ge(q,r,e.options.scrollRestorationBehavior||void 0,e.isScrollRestoring||void 0,e.options.scrollToTopSelectors||void 0),e.isScrollRestoring&&J.set(e=>(e[r]=e[r]||{},e))})}function ve(e,t){let n,r,i,a=``;for(n in e)if((i=e[n])!==void 0)if(Array.isArray(i))for(r=0;r<i.length;r++)a&&(a+=`&`),a+=encodeURIComponent(n)+`=`+encodeURIComponent(i[r]);else a&&(a+=`&`),a+=encodeURIComponent(n)+`=`+encodeURIComponent(i);return(t||``)+a}function ye(e){if(!e)return``;let t=ie(e)?decodeURIComponent(e):decodeURIComponent(encodeURIComponent(e));return t===`false`?!1:t===`true`?!0:t*0==0&&+t+``===t?+t:t}function be(e,t){let n,r,i={},a=(t?e.substr(t.length):e).split(`&`);for(;n=a.shift();){let e=n.indexOf(`=`);if(e!==-1){r=n.slice(0,e),r=decodeURIComponent(r);let t=n.slice(e+1);i[r]===void 0?i[r]=ye(t):i[r]=[].concat(i[r],ye(t))}else r=n,r=decodeURIComponent(r),i[r]=``}return i}const xe=Ce(JSON.parse),Se=we(JSON.stringify,JSON.parse);function Ce(e){return t=>{t.substring(0,1)===`?`&&(t=t.substring(1));let n=be(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function we(e,t){function n(n){if(typeof n==`object`&&n)try{return e(n)}catch{}else if(typeof n==`string`&&typeof t==`function`)try{return t(n),e(n)}catch{}return n}return e=>{e={...e},Object.keys(e).forEach(t=>{let r=e[t];r===void 0||r===void 0?delete e[t]:e[t]=n(r)});let t=ve(e).toString();return t?`?${t}`:``}}const Te=`__root__`;function Ee(e){if(e.isRedirect=!0,e.statusCode=e.statusCode||e.code||307,e.headers=e.headers||{},!e.reloadDocument){e.reloadDocument=!1;try{new URL(`${e.href}`),e.reloadDocument=!0}catch{}}if(e.throw)throw e;return e}function Y(e){return!!e?.isRedirect}function De(e){return!!e?.isRedirect&&e.href}function X(e){let t=e.resolvedLocation,n=e.location;return{fromLocation:t,toLocation:n,pathChanged:t?.pathname!==n.pathname,hrefChanged:t?.href!==n.href,hashChanged:t?.hash!==n.hash}}var Oe=class{constructor(e){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{e.notFoundRoute&&console.warn(`The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.`);let t=this.options;this.options={...this.options,...e},this.isServer=this.options.isServer??typeof document>`u`,this.pathParamsDecodeCharMap=this.options.pathParamsAllowedCharacters?new Map(this.options.pathParamsAllowedCharacters.map(e=>[encodeURIComponent(e),e])):void 0,(!this.basepath||e.basepath&&e.basepath!==t.basepath)&&(e.basepath===void 0||e.basepath===``||e.basepath===`/`?this.basepath=`/`:this.basepath=`/${V(e.basepath)}`),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??(this.isServer?n({initialEntries:[this.basepath||`/`]}):r()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.__store||(this.__store=new O(je(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,cachedMatches:this.state.cachedMatches.filter(e=>![`redirected`].includes(e.status))}}}),_e(this)),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a)`))},this.buildRouteTree=()=>{this.routesById={},this.routesByPath={};let e=this.options.notFoundRoute;e&&(e.init({originalIndex:99999999999,defaultSsr:this.options.defaultSsr}),this.routesById[e.id]=e);let t=e=>{e.forEach((e,n)=>{e.init({originalIndex:n,defaultSsr:this.options.defaultSsr});let r=this.routesById[e.id];if(p(!r,`Duplicate routes found with id: ${String(e.id)}`),this.routesById[e.id]=e,!e.isRoot&&e.path){let t=B(e.fullPath);(!this.routesByPath[t]||e.fullPath.endsWith(`/`))&&(this.routesByPath[t]=e)}let i=e.children;i?.length&&t(i)})};t([this.routeTree]);let n=[];Object.values(this.routesById).forEach((e,t)=>{if(e.isRoot||!e.path)return;let r=z(e.fullPath),i=H(r);for(;i.length>1&&i[0]?.value===`/`;)i.shift();let a=i.map(e=>e.value===`/`?.75:e.type===`param`?.5:e.type===`wildcard`?.25:1);n.push({child:e,trimmed:r,parsed:i,index:t,scores:a})}),this.flatRoutes=n.sort((e,t)=>{let n=Math.min(e.scores.length,t.scores.length);for(let r=0;r<n;r++)if(e.scores[r]!==t.scores[r])return t.scores[r]-e.scores[r];if(e.scores.length!==t.scores.length)return t.scores.length-e.scores.length;for(let r=0;r<n;r++)if(e.parsed[r].value!==t.parsed[r].value)return e.parsed[r].value>t.parsed[r].value?1:-1;return e.index-t.index}).map((e,t)=>(e.child.rank=t,e.child))},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:t,search:n,hash:r,state:i})=>{let a=this.options.parseSearch(n),o=this.options.stringifySearch(a);return{pathname:t,searchStr:o,search:N(e?.search,a),hash:r.split(`#`).reverse()[0]??``,href:`${t}${o}${r}`,state:N(e?.state,i)}},r=n(t??this.history.location),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>se({basepath:this.basepath,base:e,to:R(t),trailingSlash:this.options.trailingSlash,caseSensitive:this.options.caseSensitive}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=(e,t)=>{let n={},r=B(e.pathname),i=e=>W(this.basepath,r,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!0}),a=t?.to===void 0?void 0:this.routesByPath[t.to];a?n=i(a):a=this.flatRoutes.find(e=>{let t=i(e);return t?(n=t,!0):!1});let o=a||this.routesById.__root__,s=[o];for(;o.parentRoute;)o=o.parentRoute,s.unshift(o);return{matchedRoutes:s,routeParams:n,foundRoute:a}},this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t.pendingTimeout))},this.cancelMatches=()=>{var e;(e=this.state.pendingMatches)==null||e.forEach(e=>{this.cancelMatch(e.id)})},this.buildLocation=e=>{let t=(t={},n)=>{let r=t._fromLocation?this.matchRoutes(t._fromLocation,{_buildLocation:!0}):this.state.matches,i=t.from==null?void 0:r.find(e=>W(this.basepath,B(e.pathname),{to:t.from,caseSensitive:!1,fuzzy:!1})),a=i?.pathname||this.latestLocation.pathname;p(t.from==null||i!=null,`Could not find match for from: `+t.from);let o=this.state.pendingMatches?.length?A(this.state.pendingMatches)?.search:A(r)?.search||this.latestLocation.search,s=n?.matchedRoutes.filter(e=>r.find(t=>t.routeId===e.id)),c;if(t.to){let e=i?.fullPath||A(r)?.fullPath||this.latestLocation.pathname;c=this.resolvePathWithBase(e,`${t.to}`)}else{let e=this.routesById[s?.find(e=>{let t=U({path:e.fullPath,params:n?.routeParams??{},decodeCharMap:this.pathParamsDecodeCharMap}).interpolatedPath;return L([this.basepath,t])===a})?.id];c=this.resolvePathWithBase(a,e?.to??a)}let l={...A(r)?.params},u=(t.params??!0)===!0?l:{...l,...j(t.params,l)};Object.keys(u).length>0&&n?.matchedRoutes.map(e=>e.options.params?.stringify??e.options.stringifyParams).filter(Boolean).forEach(e=>{u={...u,...e(u)}}),c=U({path:c,params:u??{},leaveWildcards:!1,leaveParams:e.leaveParams,decodeCharMap:this.pathParamsDecodeCharMap}).interpolatedPath;let d=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};n?.matchedRoutes.forEach(t=>{try{t.options.validateSearch&&(e={...e,...Me(t.options.validateSearch,{...e,...d})??{}})}catch{}}),d=e}d=(r=>{let i=n?.matchedRoutes.reduce((t,n)=>{let r=[];return`search`in n.options?n.options.search?.middlewares&&r.push(...n.options.search.middlewares):(n.options.preSearchFilters||n.options.postSearchFilters)&&r.push(({search:e,next:t})=>{let r=e;`preSearchFilters`in n.options&&n.options.preSearchFilters&&(r=n.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=t(r);return`postSearchFilters`in n.options&&n.options.postSearchFilters?n.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),e._includeValidateSearch&&n.options.validateSearch&&r.push(({search:e,next:t})=>{let r=t(e);try{return{...r,...Me(n.options.validateSearch,r)??{}}}catch{return r}}),t.concat(r)},[])??[];i.push(({search:e})=>t.search?t.search===!0?e:j(t.search,e):{});let a=(e,t)=>{if(e>=i.length)return t;let n=i[e];return n({search:t,next:t=>a(e+1,t)})};return a(0,r)})(d),d=N(o,d);let f=this.options.stringifySearch(d),m=t.hash===!0?this.latestLocation.hash:t.hash?j(t.hash,this.latestLocation.hash):void 0,h=m?`#${m}`:``,g=t.state===!0?this.latestLocation.state:t.state?j(t.state,this.latestLocation.state):{};return g=N(this.latestLocation.state,g),{pathname:c,search:d,searchStr:f,state:g,hash:m??``,href:`${c}${f}${h}`,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n={},o=this.options.routeMasks?.find(e=>{let t=W(this.basepath,i.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return t?(n=t,!0):!1});if(o){let{from:i,...s}=o;r={...M(e,[`from`]),...s,params:n},a=t(r)}}let o=t(n,this.getMatchedRoutes(i,n));if(a){let e=this.getMatchedRoutes(a,r);o.maskedLocation=t(r,e)}return o};return e.mask?n(e,{...M(e,[`from`]),...e.mask}):n(e)},this.commitLocation=({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=F(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=this.latestLocation.href===n.href,a=this.commitLocationPromise;if(this.commitLocationPromise=I(()=>{a?.resolve()}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.href,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:n,hashScrollIntoView:r,viewTransition:i,ignoreBlocker:a,href:o,...s}={})=>{if(o){let n=this.history.location.state.__TSR_index,r=t(o,{__TSR_index:e?n:n+1});s.to=r.pathname,s.search=this.options.parseSearch(r.search),s.hash=r.hash.slice(1)}let c=this.buildLocation({...s,_includeValidateSearch:!0});return this.commitLocation({...c,viewTransition:i,replace:e,resetScroll:n,hashScrollIntoView:r,ignoreBlocker:a})},this.navigate=({to:e,reloadDocument:t,href:n,...r})=>{if(t){if(!n){let t=this.buildLocation({to:e,...r});n=this.history.createHref(t.href)}r.replace?window.location.replace(n):window.location.href=n;return}return this.buildAndCommitLocation({...r,href:n,to:e})},this.load=async e=>{this.latestLocation=this.parseLocation(this.latestLocation);let t,n,r;for(r=new Promise(i=>{this.startTransition(async()=>{var a;try{let t=this.latestLocation,n=this.state.resolvedLocation;this.cancelMatches();let r;D(()=>{r=this.matchRoutes(t),this.__store.setState(e=>({...e,status:`pending`,isLoading:!0,location:t,pendingMatches:r,cachedMatches:e.cachedMatches.filter(e=>!r.find(t=>t.id===e.id))}))}),this.state.redirect||this.emit({type:`onBeforeNavigate`,...X({resolvedLocation:n,location:t})}),this.emit({type:`onBeforeLoad`,...X({resolvedLocation:n,location:t})}),await this.loadMatches({sync:e?.sync,matches:r,location:t,onReady:async()=>{this.startViewTransition(async()=>{let e,t,n;D(()=>{this.__store.setState(r=>{let i=r.matches,a=r.pendingMatches||r.matches;return e=i.filter(e=>!a.find(t=>t.id===e.id)),t=a.filter(e=>!i.find(t=>t.id===e.id)),n=i.filter(e=>a.find(t=>t.id===e.id)),{...r,isLoading:!1,loadedAt:Date.now(),matches:a,pendingMatches:void 0,cachedMatches:[...r.cachedMatches,...e.filter(e=>e.status!==`error`)]}}),this.clearExpiredCache()}),[[e,`onLeave`],[t,`onEnter`],[n,`onStay`]].forEach(([e,t])=>{e.forEach(e=>{var n,r;(r=(n=this.looseRoutesById[e.routeId].options)[t])==null||r.call(n,e)})})})}})}catch(e){De(e)?(t=e,this.isServer||this.navigate({...t,replace:!0,ignoreBlocker:!0})):K(e)&&(n=e),this.__store.setState(e=>({...e,statusCode:t?t.statusCode:n?404:e.matches.some(e=>e.status===`error`)?500:200,redirect:t}))}this.latestLoadPromise===r&&((a=this.commitLocationPromise)==null||a.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),i()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;this.hasNotFoundMatch()&&this.__store.setState(e=>({...e,statusCode:404}))},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(delete this.shouldViewTransition,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;n=typeof t==`object`&&this.isViewTransitionTypesSupported?{update:e,types:t.types}:e,document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{let n,r=this.state.pendingMatches?.find(t=>t.id===e),i=this.state.matches.find(t=>t.id===e),a=this.state.cachedMatches.find(t=>t.id===e),o=r?`pendingMatches`:i?`matches`:a?`cachedMatches`:``;return o&&this.__store.setState(r=>({...r,[o]:r[o]?.map(r=>r.id===e?n=t(r):r)})),n},this.getMatch=e=>[...this.state.cachedMatches,...this.state.pendingMatches??[],...this.state.matches].find(t=>t.id===e),this.loadMatches=async({location:e,matches:t,preload:n,onReady:r,updateMatch:i=this.updateMatch,sync:a})=>{let o,s=!1,c=async()=>{s||(s=!0,await r?.())},l=e=>!!(n&&!this.state.matches.find(t=>t.id===e));!this.isServer&&!this.state.matches.length&&c();let u=(n,r)=>{var a,o,c,l;if(De(r)&&!r.reloadDocument)throw r;if(Y(r)||K(r)){if(i(n.id,e=>({...e,status:Y(r)?`redirected`:K(r)?`notFound`:`error`,isFetching:!1,error:r,beforeLoadPromise:void 0,loaderPromise:void 0})),r.routeId||=n.routeId,(a=n.beforeLoadPromise)==null||a.resolve(),(o=n.loaderPromise)==null||o.resolve(),(c=n.loadPromise)==null||c.resolve(),Y(r))throw s=!0,r=this.resolveRedirect({...r,_fromLocation:e}),r;if(K(r))throw this._handleNotFound(t,r,{updateMatch:i}),(l=this.serverSsr)==null||l.onMatchSettled({router:this,match:this.getMatch(n.id)}),r}};try{await new Promise((n,s)=>{(async()=>{var d;try{let s=(e,n,r)=>{var a,s;let{id:c,routeId:l}=t[e],d=this.looseRoutesById[l];if(n instanceof Promise)throw n;n.routerCode=r,o??=e,u(this.getMatch(c),n);try{(s=(a=d.options).onError)==null||s.call(a,n)}catch(e){n=e,u(this.getMatch(c),n)}i(c,e=>{var t,r;return(t=e.beforeLoadPromise)==null||t.resolve(),(r=e.loadPromise)==null||r.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController,beforeLoadPromise:void 0}})};for(let[n,{id:a,routeId:o}]of t.entries()){let u=this.getMatch(a),f=t[n-1]?.id,p=this.looseRoutesById[o],m=p.options.pendingMs??this.options.defaultPendingMs,h=!!(r&&!this.isServer&&!l(a)&&(p.options.loader||p.options.beforeLoad)&&typeof m==`number`&&m!==1/0&&(p.options.pendingComponent??this.options?.defaultPendingComponent)),g=!0;if((u.beforeLoadPromise||u.loaderPromise)&&(h&&setTimeout(()=>{try{c()}catch{}},m),await u.beforeLoadPromise,g=this.getMatch(a).status!==`success`),g){try{i(a,e=>{let t=e.loadPromise;return{...e,loadPromise:I(()=>{t?.resolve()}),beforeLoadPromise:I()}});let r=new AbortController,o;h&&(o=setTimeout(()=>{try{c()}catch{}},m));let{paramsError:u,searchError:g}=this.getMatch(a);u&&s(n,u,`PARSE_PARAMS`),g&&s(n,g,`VALIDATE_SEARCH`);let _=()=>f?this.getMatch(f).context:this.options.context??{};i(a,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:r,pendingTimeout:o,context:{..._(),...e.__routeContext}}));let{search:v,params:y,context:b,cause:x}=this.getMatch(a),S=l(a),C={search:v,abortController:r,params:y,preload:S,context:b,location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:S?`preload`:x,matches:t},w=await(d=p.options).beforeLoad?.call(d,C)??{};(Y(w)||K(w))&&s(n,w,`BEFORE_LOAD`),i(a,e=>({...e,__beforeLoadContext:w,context:{..._(),...e.__routeContext,...w},abortController:r}))}catch(e){s(n,e,`BEFORE_LOAD`)}i(a,e=>{var t;return(t=e.beforeLoadPromise)==null||t.resolve(),{...e,beforeLoadPromise:void 0,isFetching:!1}})}}let f=t.slice(0,o),p=[];f.forEach(({id:n,routeId:r},o)=>{p.push((async()=>{let{loaderPromise:s}=this.getMatch(n),c=!1,d=!1;if(s){await s;let e=this.getMatch(n);e.error&&u(e,e.error)}else{let s=p[o-1],f=this.looseRoutesById[r],m=()=>{let{params:t,loaderDeps:r,abortController:i,context:a,cause:o}=this.getMatch(n),c=l(n);return{params:t,deps:r,preload:!!c,parentMatchPromise:s,abortController:i,context:a,location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),cause:c?`preload`:o,route:f}},h=Date.now()-this.getMatch(n).updatedAt,g=l(n),_=g?f.options.preloadStaleTime??this.options.defaultPreloadStaleTime??3e4:f.options.staleTime??this.options.defaultStaleTime??0,v=f.options.shouldReload,y=typeof v==`function`?v(m()):v;i(n,e=>({...e,loaderPromise:I(),preload:!!g&&!this.state.matches.find(e=>e.id===n)}));let b=async()=>{var e,r,a,o,s,c,l;try{let d=async()=>{let e=this.getMatch(n);e.minPendingPromise&&await e.minPendingPromise};try{this.loadRouteChunk(f),i(n,e=>({...e,isFetching:`loader`}));let s=await(e=f.options).loader?.call(e,m());u(this.getMatch(n),s),await f._lazyPromise,await d();let c={matches:t,match:this.getMatch(n),params:this.getMatch(n).params,loaderData:s},l=(r=f.options).head?.call(r,c),p=l?.meta,h=l?.links,g=l?.scripts,_=(a=f.options).scripts?.call(a,c),v=(o=f.options).headers?.call(o,{loaderData:s});i(n,e=>({...e,error:void 0,status:`success`,isFetching:!1,updatedAt:Date.now(),loaderData:s,meta:p,links:h,headScripts:g,headers:v,scripts:_}))}catch(e){let t=e;await d(),u(this.getMatch(n),e);try{(c=(s=f.options).onError)==null||c.call(s,e)}catch(e){t=e,u(this.getMatch(n),e)}i(n,e=>({...e,error:t,status:`error`,isFetching:!1}))}(l=this.serverSsr)==null||l.onMatchSettled({router:this,match:this.getMatch(n)}),await f._componentsPromise}catch(e){i(n,e=>({...e,loaderPromise:void 0})),u(this.getMatch(n),e)}},{status:x,invalid:S}=this.getMatch(n);c=x===`success`&&(S||(y??h>_)),g&&f.options.preload===!1||(c&&!a?(d=!0,(async()=>{try{await b();let{loaderPromise:e,loadPromise:t}=this.getMatch(n);e?.resolve(),t?.resolve(),i(n,e=>({...e,loaderPromise:void 0}))}catch(e){De(e)&&await this.navigate(e)}})()):(x!==`success`||c&&a)&&await b())}if(!d){let{loaderPromise:e,loadPromise:t}=this.getMatch(n);e?.resolve(),t?.resolve()}return i(n,e=>({...e,isFetching:d?e.isFetching:!1,loaderPromise:d?e.loaderPromise:void 0,invalid:!1})),this.getMatch(n)})())}),await Promise.all(p),n()}catch(e){s(e)}})()}),await c()}catch(e){if(Y(e)||K(e))throw K(e)&&!n&&await c(),e}return t},this.invalidate=e=>{let t=t=>(e?.filter)?.call(e,t)??!0?{...t,invalid:!0,...t.status===`error`?{status:`pending`,error:void 0}:{}}:t;return this.__store.setState(e=>({...e,matches:e.matches.map(t),cachedMatches:e.cachedMatches.map(t),pendingMatches:e.pendingMatches?.map(t)})),this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e;return t.href||=this.buildLocation(t).href,t},this.clearCache=e=>{let t=e?.filter;t===void 0?this.__store.setState(e=>({...e,cachedMatches:[]})):this.__store.setState(e=>({...e,cachedMatches:e.cachedMatches.filter(e=>!t(e))}))},this.clearExpiredCache=()=>{this.clearCache({filter:e=>{let t=this.looseRoutesById[e.routeId];if(!t.options.loader)return!0;let n=(e.preload?t.options.preloadGcTime??this.options.defaultPreloadGcTime:t.options.gcTime??this.options.defaultGcTime)??300*1e3;return!(e.status!==`error`&&Date.now()-e.updatedAt<n)}})},this.loadRouteChunk=e=>(e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r)}):e._lazyPromise=Promise.resolve()),e._componentsPromise===void 0&&(e._componentsPromise=e._lazyPromise.then(()=>Promise.all(Ne.map(async t=>{let n=e.options[t];n?.preload&&await n.preload()})))),e._componentsPromise),this.preloadRoute=async e=>{let t=this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.state.matches,...this.state.pendingMatches??[]].map(e=>e.id)),i=new Set([...r,...this.state.cachedMatches.map(e=>e.id)]);D(()=>{n.forEach(e=>{i.has(e.id)||this.__store.setState(t=>({...t,cachedMatches:[...t.cachedMatches,e]}))})});try{return n=await this.loadMatches({matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Y(e))return e.reloadDocument?void 0:await this.preloadRoute({...e,_fromLocation:t});K(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.state.status!==`pending`)return!1;let i=(t?.pending===void 0?!this.state.isLoading:t.pending)?this.latestLocation:this.state.resolvedLocation||this.state.location,a=W(this.basepath,i.pathname,{...t,to:r.pathname});return!a||e.params&&!F(a,e.params,{partial:!0})?!1:a&&(t?.includeSearch??!0)?F(i.search,r.search,{partial:!0})?a:!1:a},this._handleNotFound=(e,t,{updateMatch:n=this.updateMatch}={})=>{let r=this.routesById[t.routeId??``]??this.routeTree,i={};for(let t of e)i[t.routeId]=t;!r.options.notFoundComponent&&this.options?.defaultNotFoundComponent&&(r.options.notFoundComponent=this.options.defaultNotFoundComponent),p(r.options.notFoundComponent,`No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router.`);let a=i[r.id];p(a,`Could not find match for route: `+r.id),n(a.id,e=>({...e,status:`notFound`,error:t,isFetching:!1})),t.routerCode===`BEFORE_LOAD`&&r.parentRoute&&(t.routeId=r.parentRoute.id,this._handleNotFound(e,t,{updateMatch:n}))},this.hasNotFoundMatch=()=>this.__store.state.matches.some(e=>e.status===`notFound`||e.globalNotFound),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??Se,parseSearch:e.parseSearch??xe}),typeof document<`u`&&(window.__TSR_ROUTER__=this)}get state(){return this.__store.state}get looseRoutesById(){return this.routesById}matchRoutesInternal(e,t){let{foundRoute:n,matchedRoutes:r,routeParams:i}=this.getMatchedRoutes(e,t?.dest),a=!1;(n?n.path!==`/`&&i[`**`]:B(e.pathname))&&(this.options.notFoundRoute?r.push(this.options.notFoundRoute):a=!0);let o=(()=>{if(a){if(this.options.notFoundMode!==`root`)for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.children)return t.id}return Te}})(),s=r.map(e=>{let n,r=e.options.params?.parse??e.options.parseParams;if(r)try{let e=r(i);Object.assign(i,e)}catch(e){if(n=new Ae(e.message,{cause:e}),t?.throwOnError)throw n;return n}}),c=[],l=e=>e?.id?e.context??this.options.context??{}:this.options.context??{};return r.forEach((n,r)=>{var a;let u=c[r-1],[d,f,p]=(()=>{let r=u?.search??e.search,i=u?._strictSearch??{};try{let e=Me(n.options.validateSearch,{...r})??{};return[{...r,...e},{...i,...e},void 0]}catch(e){let n=e;if(e instanceof ke||(n=new ke(e.message,{cause:e})),t?.throwOnError)throw n;return[r,{},n]}})(),m=(a=n.options).loaderDeps?.call(a,{search:d})??``,h=m?JSON.stringify(m):``,{usedParams:g,interpolatedPath:_}=U({path:n.fullPath,params:i,decodeCharMap:this.pathParamsDecodeCharMap}),v=U({path:n.id,params:i,leaveWildcards:!0,decodeCharMap:this.pathParamsDecodeCharMap}).interpolatedPath+h,y=this.getMatch(v),b=this.state.matches.find(e=>e.routeId===n.id),x=b?`stay`:`enter`,S;if(y)S={...y,cause:x,params:b?N(b.params,i):i,_strictParams:g,search:N(b?b.search:y.search,d),_strictSearch:f};else{let e=n.options.loader||n.options.beforeLoad||n.lazyFn||Pe(n)?`pending`:`success`;S={id:v,index:r,routeId:n.id,params:b?N(b.params,i):i,_strictParams:g,pathname:L([this.basepath,_]),updatedAt:Date.now(),search:b?N(b.search,d):d,_strictSearch:f,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:s[r],__routeContext:{},__beforeLoadContext:{},context:{},abortController:new AbortController,fetchCount:0,cause:x,loaderDeps:b?N(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:n.options.staticData||{},loadPromise:I(),fullPath:n.fullPath}}t?.preload||(S.globalNotFound=o===n.id),S.searchError=p;let C=l(u);S.context={...C,...S.__routeContext,...S.__beforeLoadContext},c.push(S)}),c.forEach((n,r)=>{var i,a,o,s;let u=this.looseRoutesById[n.routeId];if(!this.getMatch(n.id)&&t?._buildLocation!==!0){let t=c[r-1],a=l(t),o={deps:n.loaderDeps,params:n.params,context:a,location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c};n.__routeContext=(i=u.options).context?.call(i,o)??{},n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}if(n.status===`success`){n.headers=(a=u.options).headers?.call(a,{loaderData:n.loaderData});let e={matches:c,match:n,params:n.params,loaderData:n.loaderData},t=(o=u.options).head?.call(o,e);n.links=t?.links,n.headScripts=t?.scripts,n.meta=t?.meta,n.scripts=(s=u.options).scripts?.call(s,e)}}),c}},ke=class extends Error{},Ae=class extends Error{};function je(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],pendingMatches:[],cachedMatches:[],statusCode:200}}function Me(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new ke(`Async validation not supported`);if(n.issues)throw new ke(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}const Ne=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`];function Pe(e){for(let t of Ne)if(e.options[t]?.preload)return!0;return!1}var Fe=class{constructor(e){if(this.init=e=>{var t;this.originalIndex=e.originalIndex;let n=this.options,r=!n?.path&&!n?.id;if(this.parentRoute=(t=this.options).getParentRoute?.call(t),r)this._path=Te;else if(!this.parentRoute)throw Error(`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);let i=r?Te:n?.path;i&&i!==`/`&&(i=z(i));let a=n?.id||i,o=r?Te:L([this.parentRoute.id===`__root__`?``:this.parentRoute.id,a]);i===`__root__`&&(i=`/`),o!==`__root__`&&(o=L([`/`,o]));let s=o===`__root__`?`/`:L([this.parentRoute.fullPath,i]);this._path=i,this._id=o,this._fullPath=s,this._to=s,this._ssr=n?.ssr??e.defaultSsr??!0},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}get ssr(){return this._ssr}},Ie=class extends Fe{constructor(e){super(e)}};function Le(e){let t=e.errorComponent??ze;return s(Re,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?i.createElement(t,{error:n,reset:r}):e.children})}var Re=class extends i.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,t){t.error&&t.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.resetKey===this.props.getResetKey()?this.state.error:null,reset:()=>{this.reset()}})}};function ze({error:e}){let[t,n]=i.useState(!1);return c(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[c(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[s(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),s(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),s(`div`,{style:{height:`.25rem`}}),t?s(`div`,{children:s(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?s(`code`,{children:e.message}):null})}):null]})}function Be(e,t=e=>e){return l(e.subscribe,()=>e.state,()=>e.state,t,Ve)}function Ve(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}const He=i.createContext(null);function Ue(){return typeof document>`u`?He:window.__TSR_ROUTER_CONTEXT__?window.__TSR_ROUTER_CONTEXT__:(window.__TSR_ROUTER_CONTEXT__=He,He)}function Z(e){let t=i.useContext(Ue());return h(!((e?.warn??!0)&&!t),`useRouter must be used inside a <RouterProvider> component!`),t}function Q(e){let t=Z({warn:e?.router===void 0}),n=e?.router||t,r=a(void 0);return Be(n.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=N(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}const We=i.createContext(void 0),Ge=i.createContext(void 0);function $(e){let t=i.useContext(e.from?Ge:We);return Q({select:n=>{let r=n.matches.find(n=>e.from?e.from===n.routeId:n.id===t);if(p(!((e.shouldThrow??!0)&&!r),`Could not find ${e.from?`an active match from "${e.from}"`:`a nearest match!`}`),r!==void 0)return e.select?e.select(r):r},structuralSharing:e.structuralSharing})}function Ke(e){return $({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function qe(e){let{select:t,...n}=e;return $({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Je(e){return $({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.params):t.params})}function Ye(e){return $({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Xe(e){let{navigate:t}=Z();return i.useCallback(n=>t({from:e?.from,...n}),[e?.from,t])}function Ze(e){let t=Z(),n=i.useRef(null);return i.useEffect(()=>{n.current!==e&&(t.navigate({...e}),n.current=e)},[t,e]),null}var Qe=class extends Fe{constructor(e){super(e),this.useMatch=e=>$({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>$({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>Ye({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Je({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>qe({...e,from:this.id}),this.useLoaderData=e=>Ke({...e,from:this.id}),this.useNavigate=()=>Xe({from:this.fullPath}),this.$$typeof=Symbol.for(`react.memo`)}};function $e(e){return new Qe(e)}function et(){return e=>nt(e)}var tt=class extends Ie{constructor(e){super(e),this.useMatch=e=>$({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>$({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context}),this.useSearch=e=>Ye({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Je({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>qe({...e,from:this.id}),this.useLoaderData=e=>Ke({...e,from:this.id}),this.useNavigate=()=>Xe({from:this.fullPath})}};function nt(e){return new tt(e)}function rt(e){return new it(e,{silent:!0}).createRoute}var it=class{constructor(e,t){this.path=e,this.createRoute=e=>{h(this.silent,`FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.`);let t=$e(e);return t.isRoot=!1,t},this.silent=t?.silent}};function at(e){let t=Q({select:e=>`not-found-${e.location.pathname}-${e.status}`});return s(Le,{getResetKey:()=>t,onCatch:(t,n)=>{var r;if(K(t))(r=e.onCatch)==null||r.call(e,t,n);else throw t},errorComponent:({error:t})=>{if(K(t))return e.fallback?.call(e,t);throw t},children:e.children})}function ot(){return s(`p`,{children:`Not Found`})}function st(e){return s(o,{children:e.children})}function ct(e,t,n){return t.options.notFoundComponent?s(t.options.notFoundComponent,{data:n}):e.options.defaultNotFoundComponent?s(e.options.defaultNotFoundComponent,{data:n}):s(ot,{})}e(((e,t)=>{let n={},r=n.hasOwnProperty,i=(e,t)=>{for(let n in e)r.call(e,n)&&t(n,e[n])},a=(e,t)=>(t&&i(t,(t,n)=>{e[t]=n}),e),o=(e,t)=>{let n=e.length,r=-1;for(;++r<n;)t(e[r])},s=e=>`\\u`+(`0000`+e).slice(-4),c=(e,t)=>{let n=e.toString(16);return t?n:n.toUpperCase()},l=n.toString,u=Array.isArray,d=e=>typeof Buffer==`function`&&Buffer.isBuffer(e),f=e=>l.call(e)==`[object Object]`,p=e=>typeof e==`string`||l.call(e)==`[object String]`,m=e=>typeof e==`number`||l.call(e)==`[object Number]`,h=e=>typeof e==`bigint`,g=e=>typeof e==`function`,_=e=>l.call(e)==`[object Map]`,v=e=>l.call(e)==`[object Set]`,y={"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`},b=/[\\\b\f\n\r\t]/,x=/[0-9]/,S=/[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,C=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g,w=/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g,T=(e,t)=>{let n=()=>{A=k,++t.indentLevel,k=t.indent.repeat(t.indentLevel)},r={escapeEverything:!1,minimal:!1,isScriptContext:!1,quotes:`single`,wrap:!1,es6:!1,json:!1,compact:!0,lowercaseHex:!1,numbers:`decimal`,indent:` `,indentLevel:0,__inline1__:!1,__inline2__:!1},l=t&&t.json;l&&(r.quotes=`double`,r.wrap=!0),t=a(r,t),t.quotes!=`single`&&t.quotes!=`double`&&t.quotes!=`backtick`&&(t.quotes=`single`);let E=t.quotes==`double`?`"`:t.quotes==`backtick`?"`":`'`,D=t.compact,O=t.lowercaseHex,k=t.indent.repeat(t.indentLevel),A=``,ee=t.__inline1__,j=t.__inline2__,M=D?``:`
|
|
2
|
+
`,N,P=!0,te=t.numbers==`binary`,ne=t.numbers==`octal`,re=t.numbers==`decimal`,F=t.numbers==`hexadecimal`;if(l&&e&&g(e.toJSON)&&(e=e.toJSON()),!p(e)){if(_(e))return e.size==0?`new Map()`:(D||(t.__inline1__=!0,t.__inline2__=!1),`new Map(`+T(Array.from(e),t)+`)`);if(v(e))return e.size==0?`new Set()`:`new Set(`+T(Array.from(e),t)+`)`;if(d(e))return e.length==0?`Buffer.from([])`:`Buffer.from(`+T(Array.from(e),t)+`)`;if(u(e))return N=[],t.wrap=!0,ee&&(t.__inline1__=!1,t.__inline2__=!0),j||n(),o(e,e=>{P=!1,j&&(t.__inline2__=!1),N.push((D||j?``:k)+T(e,t))}),P?`[]`:j?`[`+N.join(`, `)+`]`:`[`+M+N.join(`,`+M)+M+(D?``:A)+`]`;if(m(e)||h(e)){if(l)return JSON.stringify(Number(e));let t;if(re)t=String(e);else if(F){let n=e.toString(16);O||(n=n.toUpperCase()),t=`0x`+n}else te?t=`0b`+e.toString(2):ne&&(t=`0o`+e.toString(8));return h(e)?t+`n`:t}else if(h(e))return l?JSON.stringify(Number(e)):e+`n`;else if(f(e))return N=[],t.wrap=!0,n(),i(e,(e,n)=>{P=!1,N.push((D?``:k)+T(e,t)+`:`+(D?``:` `)+T(n,t))}),P?`{}`:`{`+M+N.join(`,`+M)+M+(D?``:A)+`}`;else return l?JSON.stringify(e)||`null`:String(e)}let I=t.escapeEverything?C:w;return N=e.replace(I,(e,n,r,i,a,o)=>{if(n){if(t.minimal)return n;let e=n.charCodeAt(0),r=n.charCodeAt(1);return t.es6?`\\u{`+c((e-55296)*1024+r-56320+65536,O)+`}`:s(c(e,O))+s(c(r,O))}if(r)return s(c(r.charCodeAt(0),O));if(e==`\0`&&!l&&!x.test(o.charAt(a+1)))return`\\0`;if(i)return i==E||t.escapeEverything?`\\`+i:i;if(b.test(e))return y[e];if(t.minimal&&!S.test(e))return e;let u=c(e.charCodeAt(0),O);return l||u.length>2?s(u):`\\x`+(`00`+u).slice(-2)}),E=="`"&&(N=N.replace(/\$\{/g,"\\${")),t.isScriptContext&&(N=N.replace(/<\/(script|style)/gi,`<\\/$1`).replace(/<!--/g,l?`\\u003C!--`:`\\x3C!--`)),t.wrap&&(N=E+N+E),N};T.version=`3.0.2`,t.exports=T}))();function lt({children:e,log:t}){return typeof document<`u`?null:s(`script`,{className:`tsr-once`,dangerouslySetInnerHTML:{__html:[e,``,`if (typeof __TSR_SSR__ !== "undefined") __TSR_SSR__.cleanScripts()`].filter(Boolean).join(`
|
|
3
|
+
`)}})}function ut(){let e=Z(),t=(e.options.getScrollRestorationKey||pe)(e.latestLocation),n=t===pe(e.latestLocation)?null:t;return!e.isScrollRestoring||!e.isServer?null:s(lt,{children:`(${ge.toString()})(${JSON.stringify(q)},${JSON.stringify(n)}, undefined, true)`,log:!1})}const dt=i.memo(function({matchId:e}){let t=Z(),n=Q({select:t=>t.matches.find(t=>t.id===e)?.routeId});p(n,`Could not find routeId for matchId "${e}". Please file an issue!`);let r=t.routesById[n],a=r.options.pendingComponent??t.options.defaultPendingComponent,l=a?s(a,{}):null,u=r.options.errorComponent??t.options.defaultErrorComponent,d=r.options.onCatch??t.options.defaultOnCatch,f=r.isRoot?r.options.notFoundComponent??t.options.notFoundRoute?.options.component:r.options.notFoundComponent,m=(!r.isRoot||r.options.wrapInSuspense)&&(r.options.wrapInSuspense??a??r.options.errorComponent?.preload)?i.Suspense:st,g=u?Le:st,_=f?at:st,v=Q({select:e=>e.loadedAt}),y=Q({select:t=>{let n=t.matches.findIndex(t=>t.id===e);return t.matches[n-1]?.routeId}});return c(o,{children:[s(We.Provider,{value:e,children:s(m,{fallback:l,children:s(g,{getResetKey:()=>v,errorComponent:u||ze,onCatch:(t,n)=>{if(K(t))throw t;h(!1,`Error in route match: ${e}`),d?.(t,n)},children:s(_,{fallback:e=>{if(!f||e.routeId&&e.routeId!==n||!e.routeId&&!r.isRoot)throw e;return i.createElement(f,e)},children:s(pt,{matchId:e})})})})}),y===`__root__`&&t.options.scrollRestoration?c(o,{children:[s(ft,{}),s(ut,{})]}):null]})});function ft(){let e=Z(),t=i.useRef(void 0);return s(`script`,{suppressHydrationWarning:!0,ref:n=>{n&&(t.current===void 0||t.current.href!==e.state.resolvedLocation?.href)&&(e.emit({type:`onRendered`,...X(e.state)}),t.current=e.state.resolvedLocation)}},e.state.resolvedLocation?.state.key)}const pt=i.memo(function({matchId:e}){let t=Z(),{match:n,key:r,routeId:a}=Q({select:n=>{let r=n.matches.findIndex(t=>t.id===e),i=n.matches[r],a=i.routeId,o=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return{key:o?JSON.stringify(o):void 0,routeId:a,match:M(i,[`id`,`status`,`error`])}},structuralSharing:!0}),o=t.routesById[a],c=i.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?s(e,{},r):s(mt,{})},[r,o.options.component,t.options.defaultComponent]),l=(o.options.errorComponent??t.options.defaultErrorComponent)||ze;if(n.status===`notFound`)return p(K(n.error),`Expected a notFound error`),ct(t,o,n.error);if(n.status===`redirected`)throw p(Y(n.error),`Expected a redirect error`),t.getMatch(n.id)?.loadPromise;if(n.status===`error`){if(t.isServer)return s(l,{error:n.error,reset:void 0,info:{componentStack:``}});throw n.error}if(n.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e&&!t.getMatch(n.id)?.minPendingPromise&&!t.isServer){let r=I();Promise.resolve().then(()=>{t.updateMatch(n.id,e=>({...e,minPendingPromise:r}))}),setTimeout(()=>{r.resolve(),t.updateMatch(n.id,e=>({...e,minPendingPromise:void 0}))},e)}throw t.getMatch(n.id)?.loadPromise}return c}),mt=i.memo(function(){let e=Z(),t=i.useContext(We),n=Q({select:e=>e.matches.find(e=>e.id===t)?.routeId}),r=e.routesById[n],a=Q({select:e=>{let n=e.matches.find(e=>e.id===t);return p(n,`Could not find parent match for matchId "${t}"`),n.globalNotFound}}),o=Q({select:e=>{let n=e.matches;return n[n.findIndex(e=>e.id===t)+1]?.id}});if(a)return ct(e,r,void 0);if(!o)return null;let c=s(dt,{matchId:o}),l=e.options.defaultPendingComponent?s(e.options.defaultPendingComponent,{}):null;return t===`__root__`?s(i.Suspense,{fallback:l,children:c}):c}),ht=typeof window<`u`?i.useLayoutEffect:i.useEffect;function gt(e){let t=i.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function _t(e,t,n={},r={}){let a=i.useRef(typeof IntersectionObserver==`function`),o=i.useRef(null);return i.useEffect(()=>{if(!(!e.current||!a.current||r.disabled))return o.current=new IntersectionObserver(([e])=>{t(e)},n),o.current.observe(e.current),()=>{var e;(e=o.current)==null||e.disconnect()}},[t,n,r.disabled,e]),o.current}function vt(e){let t=i.useRef(null);return i.useImperativeHandle(e,()=>t.current,[]),t}function yt(){let e=Z(),t=i.useRef({router:e,mounted:!1}),n=Q({select:({isLoading:e})=>e}),[r,a]=i.useState(!1),o=Q({select:e=>e.matches.some(e=>e.status===`pending`),structuralSharing:!0}),s=gt(n),c=n||r||o,l=gt(c),u=n||o,d=gt(u);return e.isServer||(e.startTransition=e=>{a(!0),i.startTransition(()=>{e(),a(!1)})}),i.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return B(e.latestLocation.href)!==B(n.href)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),ht(()=>{typeof window<`u`&&e.clientSsr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),ht(()=>{s&&!n&&e.emit({type:`onLoad`,...X(e.state)})},[s,e,n]),ht(()=>{d&&!u&&e.emit({type:`onBeforeRouteMount`,...X(e.state)})},[u,d,e]),ht(()=>{l&&!c&&(e.emit({type:`onResolved`,...X(e.state)}),e.__store.setState(e=>({...e,status:`idle`,resolvedLocation:e.location})))},[c,l,e]),null}function bt(){let e=Z(),t=e.options.defaultPendingComponent?s(e.options.defaultPendingComponent,{}):null,n=c(e.isServer||typeof document<`u`&&e.clientSsr?st:i.Suspense,{fallback:t,children:[s(yt,{}),s(xt,{})]});return e.options.InnerWrap?s(e.options.InnerWrap,{children:n}):n}function xt(){let e=Q({select:e=>e.matches[0]?.id}),t=Q({select:e=>e.loadedAt});return s(We.Provider,{value:e,children:s(Le,{getResetKey:()=>t,errorComponent:ze,onCatch:e=>{h(!1,`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`),h(!1,e.message||e.toString())},children:e?s(dt,{matchId:e}):null})})}function St(e){return Q({select:t=>{let n=t.matches;return e?.select?e.select(n):n},structuralSharing:e?.structuralSharing})}function Ct(e,t){let n=Z(),[r,a]=i.useState(!1),o=i.useRef(!1),s=vt(t),{activeProps:c=()=>({className:`active`}),inactiveProps:l=()=>({}),activeOptions:d,to:f,preload:p,preloadDelay:m,hashScrollIntoView:h,replace:g,startTransition:_,resetScroll:v,viewTransition:y,children:b,target:x,disabled:S,style:C,className:w,onClick:T,onFocus:E,onMouseEnter:D,onMouseLeave:O,onTouchStart:k,ignoreBlocker:A,...ee}=e,{params:M,search:N,hash:P,state:te,mask:ne,reloadDocument:re,...I}=ee,ie=i.useMemo(()=>{try{return new URL(`${f}`),`external`}catch{}return`internal`},[f]),L=Q({select:e=>e.location.search,structuralSharing:!0}),R=St({select:t=>e.from??t[t.length-1]?.fullPath}),z=i.useMemo(()=>({...e,from:R}),[e,R]),B=i.useMemo(()=>n.buildLocation(z),[n,z,L]),V=i.useMemo(()=>z.reloadDocument?!1:p??n.options.defaultPreload,[n.options.defaultPreload,p,z.reloadDocument]),se=m??n.options.defaultPreloadDelay??0,H=Q({select:e=>{if(d?.exact){if(!oe(e.location.pathname,B.pathname,n.basepath))return!1}else{let t=ae(e.location.pathname,n.basepath).split(`/`);if(!ae(B.pathname,n.basepath).split(`/`).every((e,n)=>e===t[n]))return!1}return(d?.includeSearch??!0)&&!F(e.location.search,B.search,{partial:!d?.exact,ignoreUndefined:!d?.explicitUndefined})?!1:d?.includeHash?e.location.hash===B.hash:!0}}),U=i.useCallback(()=>{n.preloadRoute(z).catch(e=>{console.warn(e),console.warn(`Error preloading route! ☝️`)})},[z,n]);if(_t(s,i.useCallback(e=>{e?.isIntersecting&&U()},[U]),{rootMargin:`100px`},{disabled:!!S||V!==`viewport`}),ht(()=>{o.current||!S&&V===`render`&&(U(),o.current=!0)},[S,U,V]),ie===`external`)return{...I,ref:s,type:ie,href:f,...b&&{children:b},...x&&{target:x},...S&&{disabled:S},...C&&{style:C},...w&&{className:w},...T&&{onClick:T},...E&&{onFocus:E},...D&&{onMouseEnter:D},...O&&{onMouseLeave:O},...k&&{onTouchStart:k}};let ce=e=>{if(!S&&!Tt(e)&&!e.defaultPrevented&&(!x||x===`_self`)&&e.button===0){e.preventDefault(),u(()=>{a(!0)});let t=n.subscribe(`onResolved`,()=>{t(),a(!1)});return n.navigate({...z,replace:g,resetScroll:v,hashScrollIntoView:h,startTransition:_,viewTransition:y,ignoreBlocker:A})}},W=e=>{S||V&&U()},G=W,le=e=>{if(S)return;let t=e.target||{};if(V){if(t.preloadTimeout)return;t.preloadTimeout=setTimeout(()=>{t.preloadTimeout=null,U()},se)}},ue=e=>{if(S)return;let t=e.target||{};t.preloadTimeout&&=(clearTimeout(t.preloadTimeout),null)},K=e=>t=>{var n;(n=t.persist)==null||n.call(t),e.filter(Boolean).forEach(e=>{t.defaultPrevented||e(t)})},q=H?j(c,{})??{}:{},de=H?{}:j(l,{}),fe=[w,q.className,de.className].filter(Boolean).join(` `),J={...C,...q.style,...de.style};return{...I,...q,...de,href:S?void 0:B.maskedLocation?n.history.createHref(B.maskedLocation.href):n.history.createHref(B.href),ref:s,onClick:K([T,ce]),onFocus:K([E,W]),onMouseEnter:K([D,le]),onMouseLeave:K([O,ue]),onTouchStart:K([k,G]),disabled:!!S,target:x,...Object.keys(J).length&&{style:J},...fe&&{className:fe},...S&&{role:`link`,"aria-disabled":!0},...H&&{"data-status":`active`,"aria-current":`page`},...r&&{"data-transitioning":`transitioning`}}}const wt=i.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:a,ref:o,...s}=Ct(r,t),c=typeof r.children==`function`?r.children({isActive:s[`data-status`]===`active`}):r.children;return n===void 0&&delete s.disabled,i.createElement(n||`a`,{...s,ref:o},c)});function Tt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}const Et=e=>new Dt(e);var Dt=class extends Oe{constructor(e){super(e)}};function Ot({router:e,children:t,...n}){e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=s(Ue().Provider,{value:e,children:t});return e.options.Wrap?s(e.options.Wrap,{children:r}):r}function kt({router:e,...t}){return s(Ot,{router:e,...t,children:s(bt,{})})}export{mt as a,Ze as c,Je as d,Z as f,F as g,ue as h,St as i,Xe as l,K as m,Et as n,rt as o,Ee as p,wt as r,et as s,kt as t,Ye as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./react-router.mjs";function t(t){return({search:n,next:r})=>{if(t===!0)return{};let i=r(n);return Array.isArray(t)?t.forEach(e=>{delete i[e]}):Object.entries(t).forEach(([t,n])=>{e(i[t],n)&&delete i[t]}),i}}export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as e,useEffect as t,useLayoutEffect as n,useState as r}from"react";import{useSyncExternalStoreWithSelector as i}from"use-sync-external-store/shim/with-selector";import"use-sync-external-store/shim";var a=n;function o(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global}function s(){let e=o();if(e.__xstate__)return e.__xstate__}const c=e=>{if(typeof window>`u`)return;let t=s();t&&t.register(e)};var l=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}};const u=`xstate.init`,d=`xstate.stop`;function f(e,t){return{type:`xstate.after.${e}.${t}`}}function p(e,t){return{type:`xstate.done.state.${e}`,output:t}}function m(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function ee(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function te(e){return{type:u,input:e}}function h(e){setTimeout(()=>{throw e})}const ne=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function re(e,t){let n=ae(e),r=ae(t);return typeof r==`string`?typeof n==`string`?r===n:!1:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r?re(n[e],r[e]):!1)}function ie(e){if(ue(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function ae(e){return dt(e)?e.value:typeof e==`string`?oe(ie(e)):e}function oe(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function se(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function ce(e){return ue(e)?e:[e]}function g(e){return e===void 0?[]:ce(e)}function le(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function ue(e){return Array.isArray(e)}function de(e){return e.type.startsWith(`xstate.error.actor`)}function _(e){return ce(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function fe(e){if(!(e===void 0||e===``))return g(e)}function v(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function pe(e,t){return`${t}.${e}`}function y(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function me(e,t){if(t===e||t===`*`)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function he(e,t){return`${e.sessionId}.${t}`}let ge=0;function _e(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=he(e,i);u._snapshot._scheduledEvents[c]=a,o[c]=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r)},cancel:(e,t)=>{let n=he(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${ge++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=v(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}let b=!1,x=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({});const ve={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};var ye=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new l(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=x.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let n={...ve,...t},{clock:r,logger:i,parent:a,syncSnapshot:o,id:s,systemId:c,inspect:u}=n;this.system=a?a.system:_e(this,{clock:r,logger:i}),u&&!a&&this.system.inspect(v(u)),this.sessionId=this.system._bookId(),this.id=s??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=a,this._syncSnapshot=o,this.options=n,this.src=n.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){h(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=b;try{b=!0,e.exec(e.info,e.params)}finally{b=t}};this._processingStatus===x.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){h(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){h(e)}this._stopProcedure(),this._complete(),this._doneEvent=m(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=v(e,t,n);if(this._processingStatus!==x.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){h(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)h(e);else try{r.error(e)}catch(e){h(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=v(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===x.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=x.Running;let e=te(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e);return}this.update(t,e),e.type===`xstate.stop`&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===x.Stopped?this:(this.mailbox.clear(),this._processingStatus===x.NotStarted?(this._processingStatus=x.Stopped,this):(this.mailbox.enqueue({type:d}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){h(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||h(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){h(e)}}this.observers.clear(),this.eventListeners.clear(),t&&h(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,ee(this.id,e))}_stopProcedure(){return this._processingStatus===x.Running?(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new l(this._process.bind(this)),this._processingStatus=x.Stopped,this.system._unregister(this),this):this}_send(e){this._processingStatus!==x.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:c)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[ne](){return this}getSnapshot(){return this._snapshot}};function S(e,...[t]){return new ye(e,t)}function be(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function xe(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function C(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=be,t.execute=xe,t}function Se(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?y(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=S(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[q(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function Ce(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==x.Stopped&&t.start()})}function w(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=Se,a.execute=Ce,a}function we(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[q(t,{children:s}),o,void 0]}function Te(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))Te(e,t);e.system._unregister(t)}function Ee(e,t){if(t){if(Te(e,t),t._processingStatus!==x.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function T(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=we,t.execute=Ee,t}function De(e,{context:t,event:n},{guards:r}){return r.every(r=>E(r,t,n,e))}function Oe(e){function t(e,t){return!1}return t.check=De,t.guards=e,t}function ke(e,{context:t,event:n},{guards:r}){return r.some(r=>E(r,t,n,e))}function Ae(e){function t(e,t){return!1}return t.check=ke,t.guards=e,t}function E(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return E(o,t,n,r);let s={context:t,event:n},c=a||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:t,event:n}):e.params:void 0;return`check`in o?o.check(r,s,o):o(s,c)}function D(e){return e.type===`atomic`||e.type===`final`}function O(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function k(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function A(e){let t=new Set(e),n=Me(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))He(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of O(e))if(n.type!==`history`&&!t.has(n)){let e=He(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function je(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(D(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=je(e,t);return r}function Me(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function Ne(e,t){return je(e,Me(A(t)))}function Pe(e,t){return t.type===`compound`?O(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?O(t).every(t=>Pe(e,t)):t.type===`final`}const j=e=>e[0]===`#`;function Fe(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(e=>me(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t))}function Ie(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=f(t,e.id),r=n.type;return e.entry.push(J(n,{id:r,delay:t})),e.exit.push(C(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return g(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...M(e,t.event,t),delay:n}})}function M(e,t,n){let r=fe(n.target),i=n.reenter??!1,a=Be(e,r),o={...n,actions:g(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function Le(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===``)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,_(r).map(t=>M(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,_(e.config.onDone).map(t=>M(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,_(n.onDone).map(t=>M(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,_(n.onError).map(t=>M(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,_(n.onSnapshot).map(t=>M(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function Re(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=(e,t)=>e.event.to===`#${n}`?i&&typeof i==`function`?i(e,t):!0:!1,o={...r.config.route,guard:a,target:`#${n}`};t.push(M(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function ze(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:g(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function Be(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if(j(t))return e.machine.getStateNodeById(t);let n=t[0]===`.`;if(n&&!e.parent)return F(e,t.slice(1));let r=n?e.key+t:t;if(e.parent)try{return F(e.parent,r)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}else throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function Ve(e){let t=fe(e.config.target);return t?{target:t.map(t=>typeof t==`string`?F(e.parent,t):t)}:e.parent.initial}function N(e){return e.type===`history`}function He(e){let t=Ue(e);for(let n of t)for(let r of k(n,e))t.add(r);return t}function Ue(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of O(e))n(t)}}return n(e),t}function P(e,t){if(j(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function F(e,t){if(typeof t==`string`&&j(t))try{return e.machine.getStateNodeById(t)}catch{}let n=ie(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=P(r,e)}return r}function I(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>P(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=P(e,r);if(!i)return n;let a=I(i,t[r]);return n.concat(a)},[]))}function We(e,t,n,r){let i=P(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function Ge(e,t,n,r){let i=Object.keys(t),a=L(P(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function Ke(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=L(P(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function L(e,t,n,r){return typeof t==`string`?We(e,t,n,r):Object.keys(t).length===1?Ge(e,t,n,r):Ke(e,t,n,r)}function qe(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function R(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function Je(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function Ye(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(Je(B([i],t,n),B([o],t,n)))if(R(i.source,o.source))a.add(o);else{e=!0;break}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function Xe(e){let[t,...n]=e;for(let e of k(t,void 0))if(n.every(t=>R(t,e)))return e}function z(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if(N(r))if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of z(Ve(r),t))n.add(e);else n.add(r);return[...n]}function Ze(e,t){let n=z(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||R(t,e.source)))return e.source;let r=Xe(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function B(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=Ze(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)R(n,e)&&r.add(n)}return[...r]}function Qe(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function $e(e,t,n,r,i){return V([{target:[...Ue(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function V(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=Ye(e,s,c),u=t;i||([u,c]=it(u,r,n,l,s,c,a,n.actionExecutor)),u=W(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=tt(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=W(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&Qe(t._nodes,s)?[u,o]:[q(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function et(e,t,n,r,i){if(r.output===void 0)return;let a=p(i.id,i.output!==void 0&&i.parent?le(i.output,e.context,t,n.self):void 0);return le(r.output,e.context,a,n.self)}function tt(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;nt(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(w(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=W(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(p(r.id,e.output===void 0?void 0:le(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Pe(i,o);)d.add(o),a.push(p(o.id)),s=o,o=o.parent;if(o)continue;c=q(c,{status:`done`,output:et(c,t,n,c.machine.root,s)})}}return c}function nt(e,t,n,r){for(let i of e){let e=Ze(i,t);for(let a of i.target||[])!N(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),H(a,t,n,r);let a=z(i,t);for(let o of a){let a=k(o,e);e?.type===`parallel`&&a.push(e),rt(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function H(e,t,n,r){if(N(e))if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),H(e,t,n,r);for(let a of i)U(a,e.parent,r,t,n)}else{let i=Ve(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),H(a,t,n,r);for(let a of i.target)U(a,e.parent,r,t,n)}else if(e.type===`compound`){let[i]=e.initial.target;N(i)||(r.add(i),n.add(i)),H(i,t,n,r),U(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of O(e).filter(e=>!N(e)))[...r].some(e=>R(e,i))||(N(i)||(r.add(i),n.add(i)),H(i,t,n,r))}function rt(e,t,n,r,i){for(let a of r)if((!i||R(a,i))&&e.add(a),a.type===`parallel`)for(let r of O(a).filter(e=>!N(e)))[...e].some(e=>R(e,r))||(e.add(r),H(r,t,n,e))}function U(e,t,n,r,i){rt(n,r,i,k(e,t))}function it(e,t,n,r,i,a,o,s){let c=e,l=B(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of qe(e)){let n;n=t.history===`deep`?t=>D(t)&&R(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=W(c,t,n,[...e.exit,...e.invoke.map(e=>T(e.id))],o,void 0),i.delete(e);return[c,u||a]}function at(e,t){return e.implementations.actions[t]}function ot(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:at(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=ot(s,t,n,m,i,a))}return s}function W(e,t,n,r,i,a){let o=a?[]:void 0,s=ot(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function G(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===`xstate.stop`)return i=q(st(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==u){let t=s,c=de(t),l=ct(t,i);if(c&&!l.length)return i=q(e,{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=V(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let c=!0;for(;i.status===`active`;){let e=c?lt(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=ct(s,i)}let a=V(e,i,n,s,!1,r);i=a[0],c=i!==t,o(a,s,e)}return i.status!==`active`&&st(i,s,n),{snapshot:i,microsteps:a}}function st(e,t,n){return W(e,t,n,Object.values(e.children).map(e=>T(e)),[],void 0)}function ct(e,t){return t.machine.getTransitionData(t,e)}function lt(e,t){let n=new Set,r=e._nodes.filter(D);for(let i of r)loop:for(let r of[i].concat(k(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||E(i.guard,e.context,t,e)){n.add(i);break loop}}return Ye(Array.from(n),new Set(e._nodes),e.historyValue)}function ut(e,t){return Ne(e,[...A(I(e,t))])}function dt(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}const ft=function(e){return re(e,this.value)},pt=function(e){return this.tags.has(e)},mt=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},ht=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},gt=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function K(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Ne(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:ft,hasTag:pt,can:mt,getMeta:gt,toJSON:ht}}function q(e,t={}){return K({...e,...t},e.machine)}function _t(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function vt(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:yt(o),children:p,historyValue:_t(f.historyValue)}}function yt(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`)if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:1,id:r.id};else{let i=yt(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}return t??e}function bt(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function xt(e,t){let{event:n,delay:r,id:i}=t;if(typeof r==`number`){e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)});return}}function J(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=bt,n.execute=xt,n}const St=new WeakMap;function Ct(e){return{config:e,start:(t,n)=>{let{self:r,system:i,emit:a}=n,o={receivers:void 0,dispose:void 0};St.set(r,o),o.dispose=e({input:t.input,system:i,self:r,sendBack:e=>{r.getSnapshot().status!==`stopped`&&r._parent&&i._relay(r,r._parent,e)},receive:e=>{o.receivers??=new Set,o.receivers.add(e)},emit:a})},transition:(e,t,n)=>{let r=St.get(n.self);return t.type===`xstate.stop`?(e={...e,status:`stopped`,error:void 0},St.delete(n.self),r.receivers?.clear(),r.dispose?.(),e):(r.receivers?.forEach(e=>e(t)),e)},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}const wt=`xstate.promise.resolve`,Tt=`xstate.promise.reject`,Y=new WeakMap;function Et(e){return{config:e,transition:(e,t,n)=>{if(e.status!==`active`)return e;switch(t.type){case wt:{let n=t.data;return{...e,status:`done`,output:n,input:void 0}}case Tt:return{...e,status:`error`,error:t.data,input:void 0};case d:return Y.get(n.self)?.abort(),Y.delete(n.self),{...e,status:`stopped`,input:void 0};default:return e}},start:(t,{self:n,system:r,emit:i})=>{if(t.status!==`active`)return;let a=new AbortController;Y.set(n,a),Promise.resolve(e({input:t.input,system:r,self:n,signal:a.signal,emit:i})).then(e=>{n.getSnapshot().status===`active`&&(Y.delete(n),r._relay(n,n,{type:wt,data:e}))},e=>{n.getSnapshot().status===`active`&&(Y.delete(n),r._relay(n,n,{type:Tt,data:e}))})},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}function Dt(e,{machine:t,context:n},r,i){let a=(a,o)=>{if(typeof a==`string`){let s=y(t,a);if(!s)throw Error(`Actor logic '${a}' not implemented in machine '${t.id}'`);let c=S(s,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:typeof o?.input==`function`?o.input({context:n,event:r,self:e.self}):o?.input,src:a,systemId:o?.systemId});return i[c.id]=c,c}else return S(a,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:a,systemId:o?.systemId})};return(t,n)=>{let r=a(t,n);return i[r.id]=r,e.defer(()=>{r._processingStatus!==x.Stopped&&r.start()}),r}}function Ot(e,t,n,r,{assignment:i}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let a={},o={context:t.context,event:n.event,spawn:Dt(e,t,n.event,a),self:e.self,system:e.system},s={};if(typeof i==`function`)s=i(o,r);else for(let e of Object.keys(i)){let t=i[e];s[e]=typeof t==`function`?t(o,r):t}return[q(t,{context:Object.assign({},t.context,s),children:Object.keys(a).length?{...t.children,...a}:t.children}),void 0,void 0]}function X(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=Ot,t}const kt=new WeakMap;function Z(e,t,n){let r=kt.get(e);return r?t in r||(r[t]=n()):(r={[t]:n()},kt.set(e,r)),r[t]}const At={},Q=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e;var jt=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(`.`),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?`compound`:this.config.history?`history`:`atomic`),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?se(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):At,this.type===`compound`&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=g(this.config.entry).slice(),this.exit=g(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=g(t.tags).slice()}_initialize(){this.transitions=Le(this),this.config.always&&(this.always=_(this.config.always).map(e=>M(this,``,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(Q),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(Q),eventType:null})}:void 0,history:this.history,states:se(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(Q)})),entry:this.entry.map(Q),exit:this.exit.map(Q),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Z(this,`invoke`,()=>g(this.config.invoke).map((e,t)=>{let{src:n,systemId:r}=e,i=e.id??pe(this.id,t),a=typeof n==`string`?n:`xstate.invoke.${pe(this.id,t)}`;return{...e,src:a,id:i,systemId:r,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:a,id:i}}}}))}get on(){return Z(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return Z(this,`delayedTransitions`,()=>Ie(this))}get initial(){return Z(this,`initial`,()=>ze(this,this.config.initial))}next(e,t){let n=t.type,r=[],i,a=Z(this,`candidates-${n}`,()=>Fe(this,n));for(let o of a){let{guard:a}=o,s=e.context,c=!1;try{c=!a||E(a,s,t,e)}catch(e){let t=typeof a==`string`?a:typeof a==`object`?a.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${n}' in state node '${this.id}':\n${e.message}`)}if(c){r.push(...o.actions),i=o;break}}return i?[i]:void 0}get events(){return Z(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}},Mt=class e{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new jt(e,{_key:this.id,_machine:this}),this.root._initialize(),Re(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let t=ut(this.root,e.value),n=A(I(this.root,t));return K({_nodes:[...n],context:e.context||{},children:{},status:Pe(n,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,n){return G(e,t,n,[]).snapshot}microstep(e,t,n){return G(e,t,n,[]).microsteps.map(([e])=>e)}getTransitionData(e,t){return L(this.root,e.value,e,t)||[]}_getPreInitialState(e,t,n){let{context:r}=this.config,i=K({context:typeof r!=`function`&&r?r:{},_nodes:[this.root],children:{},status:`active`},this);return typeof r==`function`?W(i,t,e,[X(({spawn:e,event:t,self:n})=>r({spawn:e,input:t.input,self:n}))],n,void 0):i}getInitialSnapshot(e,t){let n=te(t),r=[],i=this._getPreInitialState(e,n,r),[a]=$e(this.root,i,e,n,r),{snapshot:o}=G(a,n,e,r);return o}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let t=ie(e),n=t.slice(1),r=j(t[0])?t[0].slice(1):t[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return F(i,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return vt(e,t)}restoreSnapshot(e,t){let n={},r=e.children;Object.keys(r).forEach(e=>{let i=r[e],a=i.snapshot,o=i.src,s=typeof o==`string`?y(this,o):o;s&&(n[e]=S(s,{id:e,parent:t.self,syncSnapshot:i.syncSnapshot,snapshot:a,src:o,systemId:i.systemId}))});function i(e,t){if(t instanceof jt)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function a(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let a=t[r];for(let t of a){let a=i(e,t);a&&(n[r]??=[],n[r].push(a))}}return n}let o=a(this.root,e.historyValue),s=K({...e,children:n,_nodes:Array.from(A(I(this.root,e.value))),historyValue:o},this),c=new Set;function l(e,t){if(!c.has(e)){c.add(e);for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`xstate$$type`in r&&r.xstate$$type===1){e[n]=t[r.id];continue}l(r,t)}}}}return l(s.context,n),s}};function Nt(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function Pt(e,{event:t}){e.defer(()=>e.emit(t))}function Ft(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=Nt,t.execute=Pt,t}let It=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function Lt(e,t,n,r,{to:i,event:a,id:o,delay:s},c){let l=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let u=typeof a==`function`?a(n,r):a,d;if(typeof s==`string`){let e=l&&l[s];d=typeof e==`function`?e(n,r):e}else d=typeof s==`function`?s(n,r):s;let f=typeof i==`function`?i(n,r):i,p;if(typeof f==`string`){if(p=f===It.Parent?e.self._parent:f===It.Internal?e.self:f.startsWith(`#_`)?t.children[f.slice(2)]:c.deferredActorIds?.includes(f)?f:t.children[f],!p)throw Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f==`string`?f:void 0,event:u,id:o,delay:d},void 0]}function Rt(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function zt(e,t){e.defer(()=>{let{to:n,event:r,delay:i,id:a}=t;if(typeof i==`number`){e.system.scheduler.schedule(e.self,n,r,i,a);return}e.system._relay(e.self,n,r.type===`xstate.error`?ee(e.self.id,r.data):r)})}function $(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=Lt,r.retryResolve=Rt,r.execute=zt,r}function Bt(e,t){return $(It.Parent,e,t)}function Vt(e,t,n,r,{collect:i}){let a=[],o=function(e){a.push(e)};return o.assign=(...e)=>{a.push(X(...e))},o.cancel=(...e)=>{a.push(C(...e))},o.raise=(...e)=>{a.push(J(...e))},o.sendTo=(...e)=>{a.push($(...e))},o.sendParent=(...e)=>{a.push(Bt(...e))},o.spawnChild=(...e)=>{a.push(w(...e))},o.stopChild=(...e)=>{a.push(T(...e))},o.emit=(...e)=>{a.push(Ft(...e))},i({context:n.context,event:n.event,enqueue:o,check:e=>E(e,t.context,n.event,t),self:e.self,system:e.system},r),[t,void 0,a]}function Ht(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=Vt,t}function Ut(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function Wt({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function Gt(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=Ut,n.execute=Wt,n}function Kt(e,t){let n=g(t);if(!n.some(t=>me(e.type,t))){let t=n.length===1?`type matching "${n[0]}"`:`one of types matching "${n.join(`", "`)}"`;throw Error(`Expected event ${JSON.stringify(e)} to have ${t}`)}}function qt(e,t){return new Mt(e,t)}function Jt({schemas:e,actors:t,actions:n,guards:r,delays:i}){return{assign:X,sendTo:$,raise:J,log:Gt,cancel:C,stopChild:T,enqueueActions:Ht,emit:Ft,spawnChild:w,createStateConfig:e=>e,createAction:e=>e,createMachine:a=>qt({...a,schemas:e},{actors:t,actions:n,guards:r,delays:i}),extend:a=>Jt({schemas:e,actors:t,actions:{...n,...a.actions},guards:{...r,...a.guards},delays:{...i,...a.delays}})}}const Yt=(e,t)=>{t(e);let n=e.getSnapshot().children;n&&Object.values(n).forEach(e=>{Yt(e,t)})};function Xt(e){let t=[];Yt(e,e=>{t.push([e,e.getSnapshot()]),e.observers=new Set});let n=e.system.getSnapshot?.();e.stop(),e.system._snapshot=n,t.forEach(([e,t])=>{e._processingStatus=0,e._snapshot=t})}function Zt(e,...[t]){let[[n,i],o]=r(()=>{let n=S(e,t);return[e.config,n]});if(e.config!==n){let n=S(e,{...t,snapshot:i.getPersistedSnapshot({__unsafeAllowInlineActors:!0})});o([e.config,n]),i=n}return a(()=>{i.logic.implementations=e.implementations}),i}function Qt(e,...[n,r]){let i=Zt(e,n);return t(()=>{if(!r)return;let e=i.subscribe(v(r));return()=>{e.unsubscribe()}},[r]),t(()=>(i.start(),()=>{Xt(i)}),[i]),i}function $t(e,t){return e===t}function en(t,n,r=$t){let a=e(e=>{if(!t)return()=>{};let{unsubscribe:n}=t.subscribe({next:e,error:e});return n},[t]),o=e(()=>{let e=t?.getSnapshot();if(e&&`status`in e&&e.status===`error`)throw e.error;return e},[t]);return i(a,o,o,n,r)}export{T as _,Ft as a,$ as c,Et as d,Oe as f,w as g,J as h,Jt as i,X as l,Ae as m,en as n,Ht as o,C as p,Kt as r,Gt as s,Qt as t,Ct as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as e,useRef as t,useSyncExternalStore as n}from"react";let r=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function i({update:e,notify:t,unwatched:n}){return{link:i,unlink:a,propagate:o,checkDirty:s,shallowPropagate:c};function i(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function a(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function o(e){let n=e.nextSub,i;top:do{let a=e.sub,o=a.flags;if(o&(r.RecursedCheck|r.Recursed|r.Dirty|r.Pending)?o&(r.RecursedCheck|r.Recursed)?o&r.RecursedCheck?!(o&(r.Dirty|r.Pending))&&l(e,a)?(a.flags=o|(r.Recursed|r.Pending),o&=r.Mutable):o=r.None:a.flags=o&~r.Recursed|r.Pending:o=r.None:a.flags=o|r.Pending,o&r.Watching&&t(a),o&r.Mutable){let t=a.subs;if(t!==void 0){let r=(e=t).nextSub;r!==void 0&&(i={value:n,prev:i},n=r);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;i!==void 0;)if(e=i.value,i=i.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function s(t,n){let i,a=0,o=!1;top:do{let s=t.dep,l=s.flags;if(n.flags&r.Dirty)o=!0;else if((l&(r.Mutable|r.Dirty))===(r.Mutable|r.Dirty)){if(e(s)){let e=s.subs;e.nextSub!==void 0&&c(e),o=!0}}else if((l&(r.Mutable|r.Pending))===(r.Mutable|r.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(i={value:t,prev:i}),t=s.deps,n=s,++a;continue}if(!o){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;a--;){let a=n.subs,s=a.nextSub!==void 0;if(s?(t=i.value,i=i.prev):t=a,o){if(e(n)){s&&c(a),n=t.sub;continue}o=!1}else n.flags&=~r.Pending;n=t.sub;let l=t.nextDep;if(l!==void 0){t=l;continue top}}return o}while(!0)}function c(e){do{let n=e.sub,i=n.flags;(i&(r.Pending|r.Dirty))===r.Pending&&(n.flags=i|r.Dirty,(i&(r.Watching|r.RecursedCheck))===r.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function l(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function a(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}const o=[];let s=0;const{link:c,unlink:l,propagate:u,checkDirty:d,shallowPropagate:f}=i({update(e){return e._update()},notify(e){o[m++]=e,e.flags&=~r.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=r.Mutable|r.Dirty,g(e))}});let p=0,m=0,h;function g(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=l(n,e)}function _(){for(;p<m;){let e=o[p];o[p++]=void 0,e.notify()}p=0,m=0}function v(e,t){let n=typeof e==`function`,i=e,o={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?r.None:r.Mutable,get(){return h!==void 0&&c(o,h,s),o._snapshot},subscribe(e){let t=a(e),n={current:!1},r=y(()=>{o.get(),n.current?t.next?.(o._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=h,c=t?.compare??Object.is;h=o,++s,o.depsTail=void 0,n&&(o.flags=r.Mutable|r.RecursedCheck);try{let t=o._snapshot,r=typeof e==`function`?e(t):e===void 0&&n?i(e=>e.get(),t):e;return t===void 0||!c(t,r)?(o._snapshot=r,!0):!1}finally{h=a,n&&(o.flags&=~r.RecursedCheck),g(o)}}};return n?(o.flags=r.Mutable|r.Dirty,o.get=function(){let e=o.flags;if(e&r.Dirty||e&r.Pending&&d(o.deps,o)){if(o._update()){let e=o.subs;e!==void 0&&f(e)}}else e&r.Pending&&(o.flags=e&~r.Pending);return h!==void 0&&c(o,h,s),o._snapshot}):o.set=function(e){if(o._update(e)){let e=o.subs;e!==void 0&&(u(e),f(e),_())}},o}function y(e){let t=()=>{let t=h;h=n,++s,n.depsTail=void 0,n.flags=r.Watching|r.RecursedCheck;try{return e()}finally{h=t,n.flags&=~r.RecursedCheck,g(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:r.Watching|r.RecursedCheck,notify(){let e=this.flags;e&r.Dirty||e&r.Pending&&d(this.deps,this)?t():this.flags=r.Watching},stop(){this.flags=r.None,this.depsTail=void 0,g(this)}};return t(),n}const b=typeof Symbol==`function`&&Symbol.observable||`@@observable`,x=new WeakMap;function S(e,t){let n,r=e.getInitialSnapshot(),i=r,o=v(i),s=e=>{if(!n)return;let t=e.type,r=n.get(t);r&&r.forEach(t=>t(e));let i=n.get(`*`);i&&i.forEach(t=>t(e))},c=e.transition;function l(e){let[n,r]=c(i,e);i=n,x.get(u)?.forEach(t=>{t.next?.({type:`@xstate.snapshot`,event:e,snapshot:n,actorRef:u,rootId:u.sessionId})}),o.set(n);for(let e of r)typeof e==`function`?e():(t?.[e.type]?.(e),s(e))}let u={get _snapshot(){return o._snapshot},on(e,t){n||=new Map;let r=n.get(e);r||(r=new Set,n.set(e,r));let i=t.bind(void 0);return r.add(i),{unsubscribe(){r.delete(i)}}},transition:e.transition,sessionId:T(),send(e){x.get(u)?.forEach(t=>{t.next?.({type:`@xstate.event`,event:e,sourceRef:void 0,actorRef:u,rootId:u.sessionId})}),l(e)},getSnapshot(){return i},get(){return o.get()},getInitialSnapshot(){return r},subscribe:o.subscribe.bind(o),[b](){return this},inspect:e=>{let t=a(e);return x.set(u,x.get(u)??new Set),x.get(u).add(t),t.next?.({type:`@xstate.actor`,actorRef:u,rootId:u.sessionId}),t.next?.({type:`@xstate.snapshot`,snapshot:r,event:{type:`@xstate.init`},actorRef:u,rootId:u.sessionId}),{unsubscribe(){return x.get(u)?.delete(t)}}},trigger:new Proxy({},{get:(e,t)=>e=>{u.send({...e,type:t})}}),select(e,t=Object.is){return v(()=>e(u.get().context),{compare:t})},with(n){return S(n(e),t)}};return u}function C(e){return`transition`in e?S(e):S({getInitialSnapshot:()=>({status:`active`,context:e.context,output:void 0,error:void 0}),transition:w(e.on)},e.emits)}function w(e,t){return(n,r)=>{let i=n.context,a=e?.[r.type],o=[],s={emit:new Proxy({},{get:(e,t)=>e=>{o.push({...e,type:t})}}),effect:e=>{o.push(e)}};if(!a)return[n,o];let c=t?t(i,e=>a(e,r,s)):a(i,r,s)??i;return[c===i?n:{...n,context:c},o]}}function T(){return Math.random().toString(36).slice(6)}function E(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}function D(e,t){if(E(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!E(e[n[r]],t[n[r]]))return!1;return!0}function O(e,t){return e===t}function k(e){return e}function A(e,n){let r=t(void 0);return t=>{let i=e(t);return r.current&&n(r.current,i)?r.current:r.current=i}}function j(t,r=k,i=O){let a=A(r,i);return n(e(e=>t.subscribe(e).unsubscribe,[t]),()=>a(t.get()),()=>a(t.get()))}export{D as n,C as r,j as t};
|