diff --git a/README.md b/README.md index af0a716dc..1368b63bc 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ const res = await fetch('https://api.urbackend.bitbros.in/api/data/products', { }); ``` +By default, publishable keys are read-focused. Write operations require a secret key unless you enable collection-level RLS (owner-write-only), in which case publishable writes also require `Authorization: Bearer `. + --- ## 🏗️ How it Works (The Visual Flow) diff --git a/apps/dashboard-api/src/controllers/project.controller.js b/apps/dashboard-api/src/controllers/project.controller.js index 63f0e3d28..dd24feb2e 100644 --- a/apps/dashboard-api/src/controllers/project.controller.js +++ b/apps/dashboard-api/src/controllers/project.controller.js @@ -25,6 +25,27 @@ const validateUsersSchema = (schema) => { return !!(hasEmail && hasPassword); }; +const getDefaultRlsForCollection = (collectionName, schema = []) => { + const normalizedName = String(collectionName || '').toLowerCase(); + const keys = Array.isArray(schema) ? schema.map(f => f?.key).filter(Boolean) : []; + + let ownerField = 'userId'; + if (normalizedName === 'users') { + ownerField = '_id'; + } else if (keys.includes('userId')) { + ownerField = 'userId'; + } else if (keys.includes('ownerId')) { + ownerField = 'ownerId'; + } + + return { + enabled: false, + mode: 'owner-write-only', + ownerField, + requireAuthForWrite: true + }; +}; + @@ -124,10 +145,19 @@ module.exports.getSingleProject = async (req, res) => { if (col.name === 'users' && col.model) { return { ...col, - model: col.model.filter(m => m.key !== 'password') + model: col.model.filter(m => m.key !== 'password'), + rls: col.rls || { + enabled: false, + mode: 'owner-write-only', + ownerField: '_id', + requireAuthForWrite: true + } }; } - return col; + return { + ...col, + rls: col.rls || getDefaultRlsForCollection(col.name, col.model) + }; }); } @@ -324,7 +354,11 @@ module.exports.createCollection = async (req, res) => { } } - project.collections.push({ name: collectionName, model: schema }); + project.collections.push({ + name: collectionName, + model: schema, + rls: getDefaultRlsForCollection(collectionName, schema) + }); await project.save(); await deleteProjectById(projectId); @@ -930,10 +964,19 @@ module.exports.toggleAuth = async (req, res) => { if (col.name === 'users' && col.model) { return { ...col, - model: col.model.filter(m => m.key !== 'password') + model: col.model.filter(m => m.key !== 'password'), + rls: col.rls || { + enabled: false, + mode: 'owner-write-only', + ownerField: '_id', + requireAuthForWrite: true + } }; } - return col; + return { + ...col, + rls: col.rls || getDefaultRlsForCollection(col.name, col.model) + }; }); } @@ -945,4 +988,66 @@ module.exports.toggleAuth = async (req, res) => { } catch (err) { res.status(500).json({ error: err.message }); } -} \ No newline at end of file +} + +// PATCH REQ - UPDATE COLLECTION RLS (V1) +module.exports.updateCollectionRls = async (req, res) => { + try { + const { projectId, collectionName } = req.params; + const { enabled, mode, ownerField, requireAuthForWrite } = req.body || {}; + + const project = await Project.findOne({ _id: projectId, owner: req.user._id }); + if (!project) return res.status(404).json({ error: "Project not found" }); + + const collection = project.collections.find(c => c.name === collectionName); + if (!collection) return res.status(404).json({ error: "Collection not found" }); + + const validMode = mode || collection?.rls?.mode || 'owner-write-only'; + if (validMode !== 'owner-write-only') { + return res.status(400).json({ error: "Unsupported RLS mode. Only 'owner-write-only' is allowed in V1." }); + } + + const modelKeys = (collection.model || []).map(f => f.key); + const nextOwnerField = ownerField || collection?.rls?.ownerField || 'userId'; + + if (nextOwnerField !== '_id' && !modelKeys.includes(nextOwnerField)) { + return res.status(400).json({ + error: "Invalid owner field", + message: `ownerField '${nextOwnerField}' not found in collection schema` + }); + } + + // Restrict use of '_id' as ownerField to the 'users' collection only. + if (nextOwnerField === '_id' && collection.name !== 'users') { + return res.status(400).json({ + error: "Invalid owner field", + message: "ownerField '_id' is only allowed for the 'users' collection" + }); + } + + collection.rls = { + enabled: typeof enabled === 'boolean' ? enabled : !!collection?.rls?.enabled, + mode: validMode, + ownerField: nextOwnerField, + requireAuthForWrite: typeof requireAuthForWrite === 'boolean' + ? requireAuthForWrite + : (collection?.rls?.requireAuthForWrite ?? true) + }; + + await project.save(); + + await deleteProjectById(projectId); + await deleteProjectByApiKeyCache(project.publishableKey); + await deleteProjectByApiKeyCache(project.secretKey); + + res.json({ + message: "Collection RLS updated", + collection: { + name: collection.name, + rls: collection.rls + } + }); + } catch (err) { + res.status(500).json({ error: err.message }); + } +} diff --git a/apps/dashboard-api/src/controllers/userAuth.controller.js b/apps/dashboard-api/src/controllers/userAuth.controller.js index 07677cb2b..c40d51f95 100644 --- a/apps/dashboard-api/src/controllers/userAuth.controller.js +++ b/apps/dashboard-api/src/controllers/userAuth.controller.js @@ -9,6 +9,49 @@ const { loginSchema, signupSchema, userSignupSchema, resetPasswordSchema, onlyEm const { getConnection } = require('@urbackend/common'); const { getCompiledModel } = require('@urbackend/common'); +const hasRequiredField = (usersColConfig, fieldKey) => { + const model = usersColConfig?.model || []; + return model.some((f) => f?.key === fieldKey && !!f?.required); +}; + +const getVerificationField = (usersColConfig) => { + const modelKeys = (usersColConfig?.model || []).map((f) => f?.key); + if (modelKeys.includes('emailVerified')) return 'emailVerified'; + if (modelKeys.includes('isVerified')) return 'isVerified'; + if (modelKeys.includes('isverified')) return 'isverified'; + return null; +}; + +const buildAuthUserPayload = (usersColConfig, parsedData, hashedPassword, verifiedValue) => { + const { email, password: _password, username, ...otherData } = parsedData; + + const payload = { + email, + password: hashedPassword, + ...otherData, + createdAt: new Date() + }; + + if (username !== undefined) { + payload.username = username; + } + + const verificationField = getVerificationField(usersColConfig); + if (verificationField !== null) { + payload[verificationField] = verifiedValue; + } + + if (hasRequiredField(usersColConfig, 'name') && (payload.name === undefined || payload.name === null || payload.name === '')) { + payload.name = username || email.split('@')[0]; + } + + if (hasRequiredField(usersColConfig, 'username') && (payload.username === undefined || payload.username === null || payload.username === '')) { + payload.username = payload.name || email.split('@')[0]; + } + + return payload; +}; + // POST REQ FOR SIGNUP module.exports.signup = async (req, res) => { @@ -34,14 +77,12 @@ module.exports.signup = async (req, res) => { const otp = Math.floor(100000 + Math.random() * 900000).toString(); - const newUserPayload = { - username, - email, - password: hashedPassword, - emailVerified: false, - ...otherData, - createdAt: new Date() - }; + const newUserPayload = buildAuthUserPayload( + usersColConfig, + { email, password, username, ...otherData }, + hashedPassword, + false + ); // Model.create handles validation and default values const result = await Model.create(newUserPayload); @@ -167,14 +208,12 @@ module.exports.createAdminUser = async (req, res) => { const salt = await bcrypt.genSalt(10); const hashedPassword = await bcrypt.hash(password, salt); - const newUserPayload = { - username, - email, - password: hashedPassword, - emailVerified: true, - ...otherData, - createdAt: new Date() - }; + const newUserPayload = buildAuthUserPayload( + usersColConfig, + { email, password, username, ...otherData }, + hashedPassword, + true + ); const result = await Model.create(newUserPayload); @@ -248,9 +287,13 @@ module.exports.verifyEmail = async (req, res) => { const connection = await getConnection(project._id); const Model = getCompiledModel(connection, usersColConfig, project._id, project.resources.db.isExternal); + const verificationField = getVerificationField(usersColConfig); + if (!verificationField) { + return res.status(500).json({ error: "No verification field found in users schema" }); + } const result = await Model.updateOne( { email }, - { $set: { emailVerified: true } } + { $set: { [verificationField]: true } } ); if (result.matchedCount === 0) return res.status(404).json({ error: "User not found" }); @@ -465,4 +508,4 @@ module.exports.updateAdminUser = async (req, res) => { } catch (err) { res.status(500).json({ error: err.message }); } -}; \ No newline at end of file +}; diff --git a/apps/dashboard-api/src/routes/projects.js b/apps/dashboard-api/src/routes/projects.js index 931a48693..1286a3995 100644 --- a/apps/dashboard-api/src/routes/projects.js +++ b/apps/dashboard-api/src/routes/projects.js @@ -27,7 +27,8 @@ const { deleteExternalStorageConfig, analytics, updateAllowedDomains, - toggleAuth + toggleAuth, + updateCollectionRls } = require("../controllers/project.controller") const { createAdminUser, resetPassword, getUserDetails, updateAdminUser } = require('../controllers/userAuth.controller'); @@ -101,6 +102,9 @@ router.get('/:projectId/analytics', authMiddleware, analytics); // PATCH REQ FOR TOGGLE AUTH router.patch('/:projectId/auth/toggle', authMiddleware, verifyEmail, toggleAuth); +// PATCH REQ FOR COLLECTION RLS SETTINGS +router.patch('/:projectId/collections/:collectionName/rls', authMiddleware, verifyEmail, updateCollectionRls); + // ADMIN AUTH ROUTES const {checkAuthEnabled} = require('@urbackend/common'); const {loadProjectForAdmin} = require('@urbackend/common'); @@ -110,4 +114,4 @@ router.patch('/:projectId/admin/users/:userId/password', authMiddleware, loadPro router.get('/:projectId/admin/users/:userId', authMiddleware, loadProjectForAdmin, checkAuthEnabled, getUserDetails); router.put('/:projectId/admin/users/:userId', authMiddleware, loadProjectForAdmin, checkAuthEnabled, updateAdminUser); -module.exports = router; \ No newline at end of file +module.exports = router; diff --git a/apps/public-api/src/controllers/userAuth.controller.js b/apps/public-api/src/controllers/userAuth.controller.js index 8dc7fd7ab..5236893d3 100644 --- a/apps/public-api/src/controllers/userAuth.controller.js +++ b/apps/public-api/src/controllers/userAuth.controller.js @@ -9,6 +9,49 @@ const { loginSchema, userSignupSchema, resetPasswordSchema, onlyEmailSchema, ver const { getConnection } = require('@urbackend/common'); const { getCompiledModel } = require('@urbackend/common'); +const hasRequiredField = (usersColConfig, fieldKey) => { + const model = usersColConfig?.model || []; + return model.some((f) => f?.key === fieldKey && !!f?.required); +}; + +const getVerificationField = (usersColConfig) => { + const modelKeys = (usersColConfig?.model || []).map((f) => f?.key); + if (modelKeys.includes('emailVerified')) return 'emailVerified'; + if (modelKeys.includes('isVerified')) return 'isVerified'; + if (modelKeys.includes('isverified')) return 'isverified'; + return null; +}; + +const buildAuthUserPayload = (usersColConfig, parsedData, hashedPassword, verifiedValue) => { + const { email, password: _password, username, ...otherData } = parsedData; + + const payload = { + email, + password: hashedPassword, + ...otherData, + createdAt: new Date() + }; + + if (username !== undefined) { + payload.username = username; + } + + const verificationField = getVerificationField(usersColConfig); + if (verificationField !== null) { + payload[verificationField] = verifiedValue; + } + + if (hasRequiredField(usersColConfig, 'name') && (payload.name === undefined || payload.name === null || payload.name === '')) { + payload.name = username || email.split('@')[0]; + } + + if (hasRequiredField(usersColConfig, 'username') && (payload.username === undefined || payload.username === null || payload.username === '')) { + payload.username = payload.name || email.split('@')[0]; + } + + return payload; +}; + // POST REQ FOR SIGNUP module.exports.signup = async (req, res) => { @@ -34,14 +77,12 @@ module.exports.signup = async (req, res) => { const otp = Math.floor(100000 + Math.random() * 900000).toString(); - const newUserPayload = { - username, - email, - password: hashedPassword, - emailVerified: false, - ...otherData, - createdAt: new Date() - }; + const newUserPayload = buildAuthUserPayload( + usersColConfig, + { email, password, username, ...otherData }, + hashedPassword, + false + ); // Model.create handles validation and default values const result = await Model.create(newUserPayload); @@ -167,14 +208,12 @@ module.exports.createAdminUser = async (req, res) => { const salt = await bcrypt.genSalt(10); const hashedPassword = await bcrypt.hash(password, salt); - const newUserPayload = { - username, - email, - password: hashedPassword, - emailVerified: true, - ...otherData, - createdAt: new Date() - }; + const newUserPayload = buildAuthUserPayload( + usersColConfig, + { email, password, username, ...otherData }, + hashedPassword, + true + ); const result = await Model.create(newUserPayload); @@ -248,9 +287,13 @@ module.exports.verifyEmail = async (req, res) => { const connection = await getConnection(project._id); const Model = getCompiledModel(connection, usersColConfig, project._id, project.resources.db.isExternal); + const verificationField = getVerificationField(usersColConfig); + if (!verificationField) { + return res.status(500).json({ error: "No verification field found in users schema" }); + } const result = await Model.updateOne( { email }, - { $set: { emailVerified: true } } + { $set: { [verificationField]: true } } ); if (result.matchedCount === 0) return res.status(404).json({ error: "User not found" }); @@ -479,4 +522,4 @@ module.exports.updateAdminUser = async (req, res) => { } catch (err) { res.status(500).json({ error: err.message }); } -}; \ No newline at end of file +}; diff --git a/apps/public-api/src/middlewares/authorizeWriteOperation.js b/apps/public-api/src/middlewares/authorizeWriteOperation.js new file mode 100644 index 000000000..7bb8c748e --- /dev/null +++ b/apps/public-api/src/middlewares/authorizeWriteOperation.js @@ -0,0 +1,109 @@ +const { getConnection } = require('@urbackend/common'); +const { getCompiledModel } = require('@urbackend/common'); +const mongoose = require('mongoose'); + +module.exports = async (req, res, next) => { + try { + if (req.keyRole === 'secret') { + return next(); + } + + const { collectionName, id } = req.params; + const project = req.project; + const collectionConfig = project.collections.find(c => c.name === collectionName); + + if (!collectionConfig) { + return res.status(404).json({ error: 'Collection not found' }); + } + + const rls = collectionConfig.rls || {}; + if (!rls.enabled) { + return res.status(403).json({ + error: 'Write blocked for publishable key', + message: 'Enable RLS for this collection to allow publishable-key writes.' + }); + } + + if (rls.requireAuthForWrite && !req.authUser?.userId) { + return res.status(401).json({ + error: 'Authentication required', + message: 'Provide a valid user Bearer token for write operations.' + }); + } + + if ((rls.mode || 'owner-write-only') !== 'owner-write-only') { + return res.status(403).json({ error: 'Unsupported RLS mode' }); + } + + const ownerField = rls.ownerField || 'userId'; + + if (!req.authUser?.userId) { + return res.status(401).json({ + error: 'Authentication required', + message: 'Provide a valid user Bearer token for write operations.' + }); + } + + const authUserId = String(req.authUser.userId); + const method = String(req.method || '').toUpperCase(); + + if (method === 'POST') { + const incomingOwner = req.body?.[ownerField]; + + if (ownerField === '_id') { + return res.status(403).json({ + error: 'Insert denied', + message: "RLS ownerField '_id' is not valid for insert ownership checks." + }); + } + + if (incomingOwner === undefined || incomingOwner === null || incomingOwner === '') { + req.body[ownerField] = authUserId; + return next(); + } + + if (String(incomingOwner) !== authUserId) { + return res.status(403).json({ + error: 'RLS owner mismatch', + message: `You can only create documents with ${ownerField} equal to your user id.` + }); + } + + return next(); + } + + if (method === 'PUT' || method === 'PATCH' || method === 'DELETE') { + if (!id || !mongoose.Types.ObjectId.isValid(id)) { + return res.status(400).json({ error: 'Invalid ID format.' }); + } + + const connection = await getConnection(project._id); + const Model = getCompiledModel(connection, collectionConfig, project._id, project.resources.db.isExternal); + const doc = await Model.findById(id).select(ownerField).lean(); + + if (!doc) { + return res.status(404).json({ error: 'Document not found.' }); + } + + if (ownerField === '_id') { + if (String(doc._id) !== authUserId) { + return res.status(403).json({ error: 'RLS owner mismatch', message: 'You can only modify your own document.' }); + } + } else { + if (req.body && Object.prototype.hasOwnProperty.call(req.body, ownerField) && String(req.body[ownerField]) !== String(doc[ownerField])) { + return res.status(403).json({ error: 'Owner field immutable', message: `${ownerField} cannot be changed under RLS.` }); + } + + if (doc[ownerField] === undefined || doc[ownerField] === null || String(doc[ownerField]) !== authUserId) { + return res.status(403).json({ error: 'RLS owner mismatch', message: 'You can only modify your own document.' }); + } + } + + return next(); + } + + return next(); + } catch (err) { + return res.status(500).json({ error: err.message }); + } +}; diff --git a/apps/public-api/src/middlewares/resolvePublicAuthContext.js b/apps/public-api/src/middlewares/resolvePublicAuthContext.js new file mode 100644 index 000000000..4d20ed524 --- /dev/null +++ b/apps/public-api/src/middlewares/resolvePublicAuthContext.js @@ -0,0 +1,30 @@ +const jwt = require('jsonwebtoken'); + +module.exports = (req, res, next) => { + req.authUser = null; + + if (req.keyRole === 'secret') { + return next(); + } + + const authHeader = req.header('Authorization'); + + if (!authHeader || !authHeader.startsWith('Bearer ')) { + return next(); + } + + const token = authHeader.slice(7).trim(); + if (!token) return next(); + + try { + const decoded = jwt.verify(token, req.project.jwtSecret); + req.authUser = { + userId: decoded.userId || decoded._id || decoded.id, + claims: decoded + }; + } catch { + req.authUser = null; + } + + next(); +}; diff --git a/apps/public-api/src/routes/data.js b/apps/public-api/src/routes/data.js index ef6668db5..e83732e6d 100644 --- a/apps/public-api/src/routes/data.js +++ b/apps/public-api/src/routes/data.js @@ -1,13 +1,14 @@ const express = require('express'); const router = express.Router(); const verifyApiKey = require('../middlewares/verifyApiKey'); -const requireSecretKey = require('../middlewares/requireSecretKey'); +const resolvePublicAuthContext = require('../middlewares/resolvePublicAuthContext'); +const authorizeWriteOperation = require('../middlewares/authorizeWriteOperation'); const projectRateLimiter = require('../middlewares/projectRateLimiter'); const { insertData, getAllData, getSingleDoc, updateSingleData, deleteSingleDoc } = require("../controllers/data.controller") // POST REQ TO INSERT DATA -router.post('/:collectionName', verifyApiKey, projectRateLimiter, requireSecretKey, insertData); +router.post('/:collectionName', verifyApiKey, resolvePublicAuthContext, projectRateLimiter, authorizeWriteOperation, insertData); // GET REQ ALL DATA @@ -19,12 +20,15 @@ router.get('/:collectionName/:id', verifyApiKey, projectRateLimiter, getSingleDo // DELETE REQ SINGLE DATA -router.delete('/:collectionName/:id', verifyApiKey, projectRateLimiter, requireSecretKey, deleteSingleDoc); +router.delete('/:collectionName/:id', verifyApiKey, resolvePublicAuthContext, projectRateLimiter, authorizeWriteOperation, deleteSingleDoc); // PUT REQ SINGLE DATA -router.put('/:collectionName/:id', verifyApiKey, projectRateLimiter, requireSecretKey, updateSingleData); +router.put('/:collectionName/:id', verifyApiKey, resolvePublicAuthContext, projectRateLimiter, authorizeWriteOperation, updateSingleData); +// PATCH REQ SINGLE DATA +router.patch('/:collectionName/:id', verifyApiKey, resolvePublicAuthContext, projectRateLimiter, authorizeWriteOperation, updateSingleData); -module.exports = router; \ No newline at end of file + +module.exports = router; diff --git a/apps/web-dashboard/dist/assets/index-BEgJJAWh.js b/apps/web-dashboard/dist/assets/index-CystpbmR.js similarity index 67% rename from apps/web-dashboard/dist/assets/index-BEgJJAWh.js rename to apps/web-dashboard/dist/assets/index-CystpbmR.js index a676fc9a3..6db7f478c 100644 --- a/apps/web-dashboard/dist/assets/index-BEgJJAWh.js +++ b/apps/web-dashboard/dist/assets/index-CystpbmR.js @@ -1,14 +1,14 @@ -function G9(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function mi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k0={exports:{}},Ic={};var nT;function K9(){if(nT)return Ic;nT=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,a){var l=null;if(a!==void 0&&(l=""+a),i.key!==void 0&&(l=""+i.key),"key"in i){a={};for(var u in i)u!=="key"&&(a[u]=i[u])}else a=i;return i=a.ref,{$$typeof:e,type:r,key:l,ref:i!==void 0?i:null,props:a}}return Ic.Fragment=t,Ic.jsx=n,Ic.jsxs=n,Ic}var rT;function Y9(){return rT||(rT=1,k0.exports=K9()),k0.exports}var p=Y9(),A0={exports:{}},Ie={};var iT;function X9(){if(iT)return Ie;iT=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),y=Symbol.iterator;function v(L){return L===null||typeof L!="object"?null:(L=y&&L[y]||L["@@iterator"],typeof L=="function"?L:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,C={};function k(L,G,P){this.props=L,this.context=G,this.refs=C,this.updater=P||b}k.prototype.isReactComponent={},k.prototype.setState=function(L,G){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,G,"setState")},k.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function E(){}E.prototype=k.prototype;function A(L,G,P){this.props=L,this.context=G,this.refs=C,this.updater=P||b}var R=A.prototype=new E;R.constructor=A,j(R,k.prototype),R.isPureReactComponent=!0;var D=Array.isArray;function O(){}var M={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function $(L,G,P){var he=P.ref;return{$$typeof:e,type:L,key:G,ref:he!==void 0?he:null,props:P}}function N(L,G){return $(L.type,G,L.props)}function F(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function H(L){var G={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(P){return G[P]})}var ae=/\/+/g;function Z(L,G){return typeof L=="object"&&L!==null&&L.key!=null?H(""+L.key):G.toString(36)}function re(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(O,O):(L.status="pending",L.then(function(G){L.status==="pending"&&(L.status="fulfilled",L.value=G)},function(G){L.status==="pending"&&(L.status="rejected",L.reason=G)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function U(L,G,P,he,xe){var ve=typeof L;(ve==="undefined"||ve==="boolean")&&(L=null);var ce=!1;if(L===null)ce=!0;else switch(ve){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(L.$$typeof){case e:case t:ce=!0;break;case h:return ce=L._init,U(ce(L._payload),G,P,he,xe)}}if(ce)return xe=xe(L),ce=he===""?"."+Z(L,0):he,D(xe)?(P="",ce!=null&&(P=ce.replace(ae,"$&/")+"/"),U(xe,G,P,"",function(ye){return ye})):xe!=null&&(F(xe)&&(xe=N(xe,P+(xe.key==null||L&&L.key===xe.key?"":(""+xe.key).replace(ae,"$&/")+"/")+ce)),G.push(xe)),1;ce=0;var be=he===""?".":he+":";if(D(L))for(var Q=0;Q>>1,z=U[de];if(0>>1;dei(P,ie))hei(xe,P)?(U[de]=xe,U[he]=ie,de=he):(U[de]=P,U[G]=ie,de=G);else if(hei(xe,ie))U[de]=xe,U[he]=ie,de=he;else break e}}return W}function i(U,W){var ie=U.sortIndex-W.sortIndex;return ie!==0?ie:U.id-W.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var c=[],d=[],h=1,m=null,y=3,v=!1,b=!1,j=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function R(U){for(var W=n(d);W!==null;){if(W.callback===null)r(d);else if(W.startTime<=U)r(d),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(d)}}function D(U){if(j=!1,R(U),!b)if(n(c)!==null)b=!0,O||(O=!0,H());else{var W=n(d);W!==null&&re(D,W.startTime-U)}}var O=!1,M=-1,I=5,$=-1;function N(){return C?!0:!(e.unstable_now()-$U&&N());){var de=m.callback;if(typeof de=="function"){m.callback=null,y=m.priorityLevel;var z=de(m.expirationTime<=U);if(U=e.unstable_now(),typeof z=="function"){m.callback=z,R(U),W=!0;break t}m===n(c)&&r(c),R(U)}else r(c);m=n(c)}if(m!==null)W=!0;else{var L=n(d);L!==null&&re(D,L.startTime-U),W=!1}}break e}finally{m=null,y=ie,v=!1}W=void 0}}finally{W?H():O=!1}}}var H;if(typeof A=="function")H=function(){A(F)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,Z=ae.port2;ae.port1.onmessage=F,H=function(){Z.postMessage(null)}}else H=function(){k(F,0)};function re(U,W){M=k(function(){U(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125de?(U.sortIndex=ie,t(d,U),n(c)===null&&U===n(d)&&(j?(E(M),M=-1):j=!0,re(D,ie-de))):(U.sortIndex=z,t(c,U),b||v||(b=!0,O||(O=!0,H()))),U},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(U){var W=y;return function(){var ie=y;y=W;try{return U.apply(this,arguments)}finally{y=ie}}}})(O0)),O0}var lT;function J9(){return lT||(lT=1,T0.exports=Q9()),T0.exports}var R0={exports:{}},Pn={};var sT;function e$(){if(sT)return Pn;sT=1;var e=Cu();function t(c){var d="https://react.dev/errors/"+c;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),R0.exports=e$(),R0.exports}var cT;function t$(){if(cT)return Lc;cT=1;var e=J9(),t=Cu(),n=j5();function r(o){var s="https://react.dev/errors/"+o;if(1z||(o.current=de[z],de[z]=null,z--)}function P(o,s){z++,de[z]=o.current,o.current=s}var he=L(null),xe=L(null),ve=L(null),ce=L(null);function be(o,s){switch(P(ve,s),P(xe,o),P(he,null),s.nodeType){case 9:case 11:o=(o=s.documentElement)&&(o=o.namespaceURI)?kE(o):0;break;default:if(o=s.tagName,s=s.namespaceURI)s=kE(s),o=AE(s,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}G(he),P(he,o)}function Q(){G(he),G(xe),G(ve)}function ye(o){o.memoizedState!==null&&P(ce,o);var s=he.current,f=AE(s,o.type);s!==f&&(P(xe,o),P(he,f))}function pe(o){xe.current===o&&(G(he),G(xe)),ce.current===o&&(G(ce),Mc._currentValue=ie)}var J,Ae;function je(o){if(J===void 0)try{throw Error()}catch(f){var s=f.stack.trim().match(/\n( *(at )?)/);J=s&&s[1]||"",Ae=-1r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function wi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k0={exports:{}},Ic={};var nT;function K9(){if(nT)return Ic;nT=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,a){var l=null;if(a!==void 0&&(l=""+a),i.key!==void 0&&(l=""+i.key),"key"in i){a={};for(var u in i)u!=="key"&&(a[u]=i[u])}else a=i;return i=a.ref,{$$typeof:e,type:r,key:l,ref:i!==void 0?i:null,props:a}}return Ic.Fragment=t,Ic.jsx=n,Ic.jsxs=n,Ic}var rT;function Y9(){return rT||(rT=1,k0.exports=K9()),k0.exports}var p=Y9(),A0={exports:{}},Be={};var iT;function X9(){if(iT)return Be;iT=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),y=Symbol.iterator;function v(L){return L===null||typeof L!="object"?null:(L=y&&L[y]||L["@@iterator"],typeof L=="function"?L:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,C={};function k(L,G,P){this.props=L,this.context=G,this.refs=C,this.updater=P||b}k.prototype.isReactComponent={},k.prototype.setState=function(L,G){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,G,"setState")},k.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function E(){}E.prototype=k.prototype;function A(L,G,P){this.props=L,this.context=G,this.refs=C,this.updater=P||b}var R=A.prototype=new E;R.constructor=A,j(R,k.prototype),R.isPureReactComponent=!0;var D=Array.isArray;function O(){}var M={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function $(L,G,P){var he=P.ref;return{$$typeof:e,type:L,key:G,ref:he!==void 0?he:null,props:P}}function N(L,G){return $(L.type,G,L.props)}function F(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function H(L){var G={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(P){return G[P]})}var ie=/\/+/g;function Z(L,G){return typeof L=="object"&&L!==null&&L.key!=null?H(""+L.key):G.toString(36)}function ne(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(O,O):(L.status="pending",L.then(function(G){L.status==="pending"&&(L.status="fulfilled",L.value=G)},function(G){L.status==="pending"&&(L.status="rejected",L.reason=G)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function U(L,G,P,he,xe){var ve=typeof L;(ve==="undefined"||ve==="boolean")&&(L=null);var ue=!1;if(L===null)ue=!0;else switch(ve){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(L.$$typeof){case e:case t:ue=!0;break;case h:return ue=L._init,U(ue(L._payload),G,P,he,xe)}}if(ue)return xe=xe(L),ue=he===""?"."+Z(L,0):he,D(xe)?(P="",ue!=null&&(P=ue.replace(ie,"$&/")+"/"),U(xe,G,P,"",function(ge){return ge})):xe!=null&&(F(xe)&&(xe=N(xe,P+(xe.key==null||L&&L.key===xe.key?"":(""+xe.key).replace(ie,"$&/")+"/")+ue)),G.push(xe)),1;ue=0;var be=he===""?".":he+":";if(D(L))for(var Q=0;Q>>1,z=U[de];if(0>>1;dei(P,re))hei(xe,P)?(U[de]=xe,U[he]=re,de=he):(U[de]=P,U[G]=re,de=G);else if(hei(xe,re))U[de]=xe,U[he]=re,de=he;else break e}}return W}function i(U,W){var re=U.sortIndex-W.sortIndex;return re!==0?re:U.id-W.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var c=[],d=[],h=1,m=null,y=3,v=!1,b=!1,j=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function R(U){for(var W=n(d);W!==null;){if(W.callback===null)r(d);else if(W.startTime<=U)r(d),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(d)}}function D(U){if(j=!1,R(U),!b)if(n(c)!==null)b=!0,O||(O=!0,H());else{var W=n(d);W!==null&&ne(D,W.startTime-U)}}var O=!1,M=-1,I=5,$=-1;function N(){return C?!0:!(e.unstable_now()-$U&&N());){var de=m.callback;if(typeof de=="function"){m.callback=null,y=m.priorityLevel;var z=de(m.expirationTime<=U);if(U=e.unstable_now(),typeof z=="function"){m.callback=z,R(U),W=!0;break t}m===n(c)&&r(c),R(U)}else r(c);m=n(c)}if(m!==null)W=!0;else{var L=n(d);L!==null&&ne(D,L.startTime-U),W=!1}}break e}finally{m=null,y=re,v=!1}W=void 0}}finally{W?H():O=!1}}}var H;if(typeof A=="function")H=function(){A(F)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,Z=ie.port2;ie.port1.onmessage=F,H=function(){Z.postMessage(null)}}else H=function(){k(F,0)};function ne(U,W){M=k(function(){U(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125de?(U.sortIndex=re,t(d,U),n(c)===null&&U===n(d)&&(j?(E(M),M=-1):j=!0,ne(D,re-de))):(U.sortIndex=z,t(c,U),b||v||(b=!0,O||(O=!0,H()))),U},e.unstable_shouldYield=N,e.unstable_wrapCallback=function(U){var W=y;return function(){var re=y;y=W;try{return U.apply(this,arguments)}finally{y=re}}}})(O0)),O0}var lT;function J9(){return lT||(lT=1,T0.exports=Q9()),T0.exports}var R0={exports:{}},Fn={};var sT;function e$(){if(sT)return Fn;sT=1;var e=ku();function t(c){var d="https://react.dev/errors/"+c;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),R0.exports=e$(),R0.exports}var cT;function t$(){if(cT)return Lc;cT=1;var e=J9(),t=ku(),n=j5();function r(o){var s="https://react.dev/errors/"+o;if(1z||(o.current=de[z],de[z]=null,z--)}function P(o,s){z++,de[z]=o.current,o.current=s}var he=L(null),xe=L(null),ve=L(null),ue=L(null);function be(o,s){switch(P(ve,s),P(xe,o),P(he,null),s.nodeType){case 9:case 11:o=(o=s.documentElement)&&(o=o.namespaceURI)?kE(o):0;break;default:if(o=s.tagName,s=s.namespaceURI)s=kE(s),o=AE(s,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}G(he),P(he,o)}function Q(){G(he),G(xe),G(ve)}function ge(o){o.memoizedState!==null&&P(ue,o);var s=he.current,f=AE(s,o.type);s!==f&&(P(xe,o),P(he,f))}function De(o){xe.current===o&&(G(he),G(xe)),ue.current===o&&(G(ue),Mc._currentValue=re)}var fe,ft;function ze(o){if(fe===void 0)try{throw Error()}catch(f){var s=f.stack.trim().match(/\n( *(at )?)/);fe=s&&s[1]||"",ft=-1)":-1x||B[g]!==Y[x]){var oe=` -`+B[g].replace(" at new "," at ");return o.displayName&&oe.includes("")&&(oe=oe.replace("",o.displayName)),oe}while(1<=g&&0<=x);break}}}finally{Be=!1,Error.prepareStackTrace=f}return(f=o?o.displayName||o.name:"")?je(f):""}function Vn(o,s){switch(o.tag){case 26:case 27:case 5:return je(o.type);case 16:return je("Lazy");case 13:return o.child!==s&&s!==null?je("Suspense Fallback"):je("Suspense");case 19:return je("SuspenseList");case 0:case 15:return ft(o.type,!1);case 11:return ft(o.type.render,!1);case 1:return ft(o.type,!0);case 31:return je("Activity");default:return""}}function $i(o){try{var s="",f=null;do s+=Vn(o,f),f=o,o=o.return;while(o);return s}catch(g){return` +`+B[g].replace(" at new "," at ");return o.displayName&&oe.includes("")&&(oe=oe.replace("",o.displayName)),oe}while(1<=g&&0<=x);break}}}finally{lt=!1,Error.prepareStackTrace=f}return(f=o?o.displayName||o.name:"")?ze(f):""}function An(o,s){switch(o.tag){case 26:case 27:case 5:return ze(o.type);case 16:return ze("Lazy");case 13:return o.child!==s&&s!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return at(o.type,!1);case 11:return at(o.type.render,!1);case 1:return at(o.type,!0);case 31:return ze("Activity");default:return""}}function Gr(o){try{var s="",f=null;do s+=An(o,f),f=o,o=o.return;while(o);return s}catch(g){return` Error generating stack: `+g.message+` -`+g.stack}}var Ui=Object.prototype.hasOwnProperty,Hn=e.unstable_scheduleCallback,Vi=e.unstable_cancelCallback,fo=e.unstable_shouldYield,Jl=e.unstable_requestPaint,un=e.unstable_now,Gu=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Oe=e.unstable_NormalPriority,Le=e.unstable_LowPriority,Ze=e.unstable_IdlePriority,Ot=e.log,Vr=e.unstable_setDisableYieldValue,Sn=null,Pt=null;function cn(o){if(typeof Ot=="function"&&Vr(o),Pt&&typeof Pt.setStrictMode=="function")try{Pt.setStrictMode(Sn,o)}catch{}}var rt=Math.clz32?Math.clz32:my,Hi=Math.log,tr=Math.LN2;function my(o){return o>>>=0,o===0?32:31-(Hi(o)/tr|0)|0}var es=256,ts=262144,Nt=4194304;function zt(o){var s=o&42;if(s!==0)return s;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function dn(o,s,f){var g=o.pendingLanes;if(g===0)return 0;var x=0,S=o.suspendedLanes,T=o.pingedLanes;o=o.warmLanes;var _=g&134217727;return _!==0?(g=_&~S,g!==0?x=zt(g):(T&=_,T!==0?x=zt(T):f||(f=_&~o,f!==0&&(x=zt(f))))):(_=g&~S,_!==0?x=zt(_):T!==0?x=zt(T):f||(f=g&~o,f!==0&&(x=zt(f)))),x===0?0:s!==0&&s!==x&&(s&S)===0&&(S=x&-x,f=s&-s,S>=f||S===32&&(f&4194048)!==0)?s:x}function nr(o,s){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&s)===0}function rr(o,s){switch(o){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mn(){var o=Nt;return Nt<<=1,(Nt&62914560)===0&&(Nt=4194304),o}function ir(o){for(var s=[],f=0;31>f;f++)s.push(o);return s}function Hr(o,s){o.pendingLanes|=s,s!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Zt(o,s,f,g,x,S){var T=o.pendingLanes;o.pendingLanes=f,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=f,o.entangledLanes&=f,o.errorRecoveryDisabledLanes&=f,o.shellSuspendCounter=0;var _=o.entanglements,B=o.expirationTimes,Y=o.hiddenUpdates;for(f=T&~f;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var $8=/[\n"\\]/g;function Kr(o){return o.replace($8,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function xy(o,s,f,g,x,S,T,_){o.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?o.type=T:o.removeAttribute("type"),s!=null?T==="number"?(s===0&&o.value===""||o.value!=s)&&(o.value=""+Gr(s)):o.value!==""+Gr(s)&&(o.value=""+Gr(s)):T!=="submit"&&T!=="reset"||o.removeAttribute("value"),s!=null?by(o,T,Gr(s)):f!=null?by(o,T,Gr(f)):g!=null&&o.removeAttribute("value"),x==null&&S!=null&&(o.defaultChecked=!!S),x!=null&&(o.checked=x&&typeof x!="function"&&typeof x!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?o.name=""+Gr(_):o.removeAttribute("name")}function xC(o,s,f,g,x,S,T,_){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(o.type=S),s!=null||f!=null){if(!(S!=="submit"&&S!=="reset"||s!=null)){vy(o);return}f=f!=null?""+Gr(f):"",s=s!=null?""+Gr(s):f,_||s===o.value||(o.value=s),o.defaultValue=s}g=g??x,g=typeof g!="function"&&typeof g!="symbol"&&!!g,o.checked=_?o.checked:!!g,o.defaultChecked=!!g,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(o.name=T),vy(o)}function by(o,s,f){s==="number"&&Lf(o.ownerDocument)===o||o.defaultValue===""+f||(o.defaultValue=""+f)}function ls(o,s,f,g){if(o=o.options,s){s={};for(var x=0;x"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ky=!1;if(pa)try{var Zu={};Object.defineProperty(Zu,"passive",{get:function(){ky=!0}}),window.addEventListener("test",Zu,Zu),window.removeEventListener("test",Zu,Zu)}catch{ky=!1}var po=null,Ay=null,Ff=null;function AC(){if(Ff)return Ff;var o,s=Ay,f=s.length,g,x="value"in po?po.value:po.textContent,S=x.length;for(o=0;o=ec),_C=" ",MC=!1;function PC(o,s){switch(o){case"keyup":return mF.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NC(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var ds=!1;function yF(o,s){switch(o){case"compositionend":return NC(s);case"keypress":return s.which!==32?null:(MC=!0,_C);case"textInput":return o=s.data,o===_C&&MC?null:o;default:return null}}function vF(o,s){if(ds)return o==="compositionend"||!Dy&&PC(o,s)?(o=AC(),Ff=Ay=po=null,ds=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:f,offset:s-o};o=g}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=VC(f)}}function qC(o,s){return o&&s?o===s?!0:o&&o.nodeType===3?!1:s&&s.nodeType===3?qC(o,s.parentNode):"contains"in o?o.contains(s):o.compareDocumentPosition?!!(o.compareDocumentPosition(s)&16):!1:!1}function WC(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var s=Lf(o.document);s instanceof o.HTMLIFrameElement;){try{var f=typeof s.contentWindow.location.href=="string"}catch{f=!1}if(f)o=s.contentWindow;else break;s=Lf(o.document)}return s}function Py(o){var s=o&&o.nodeName&&o.nodeName.toLowerCase();return s&&(s==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||s==="textarea"||o.contentEditable==="true")}var AF=pa&&"documentMode"in document&&11>=document.documentMode,fs=null,Ny=null,ic=null,zy=!1;function GC(o,s,f){var g=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;zy||fs==null||fs!==Lf(g)||(g=fs,"selectionStart"in g&&Py(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),ic&&rc(ic,g)||(ic=g,g=Mh(Ny,"onSelect"),0>=T,x-=T,qi=1<<32-rt(s)+x|f<Ue?(Ke=Ee,Ee=null):Ke=Ee.sibling;var Je=X(q,Ee,K[Ue],se);if(Je===null){Ee===null&&(Ee=Ke);break}o&&Ee&&Je.alternate===null&&s(q,Ee),V=S(Je,V,Ue),Qe===null?Re=Je:Qe.sibling=Je,Qe=Je,Ee=Ke}if(Ue===K.length)return f(q,Ee),Ye&&ga(q,Ue),Re;if(Ee===null){for(;UeUe?(Ke=Ee,Ee=null):Ke=Ee.sibling;var zo=X(q,Ee,Je.value,se);if(zo===null){Ee===null&&(Ee=Ke);break}o&&Ee&&zo.alternate===null&&s(q,Ee),V=S(zo,V,Ue),Qe===null?Re=zo:Qe.sibling=zo,Qe=zo,Ee=Ke}if(Je.done)return f(q,Ee),Ye&&ga(q,Ue),Re;if(Ee===null){for(;!Je.done;Ue++,Je=K.next())Je=ue(q,Je.value,se),Je!==null&&(V=S(Je,V,Ue),Qe===null?Re=Je:Qe.sibling=Je,Qe=Je);return Ye&&ga(q,Ue),Re}for(Ee=g(Ee);!Je.done;Ue++,Je=K.next())Je=te(Ee,q,Ue,Je.value,se),Je!==null&&(o&&Je.alternate!==null&&Ee.delete(Je.key===null?Ue:Je.key),V=S(Je,V,Ue),Qe===null?Re=Je:Qe.sibling=Je,Qe=Je);return o&&Ee.forEach(function(W9){return s(q,W9)}),Ye&&ga(q,Ue),Re}function ct(q,V,K,se){if(typeof K=="object"&&K!==null&&K.type===j&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case v:e:{for(var Re=K.key;V!==null;){if(V.key===Re){if(Re=K.type,Re===j){if(V.tag===7){f(q,V.sibling),se=x(V,K.props.children),se.return=q,q=se;break e}}else if(V.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===I&&ml(Re)===V.type){f(q,V.sibling),se=x(V,K.props),cc(se,K),se.return=q,q=se;break e}f(q,V);break}else s(q,V);V=V.sibling}K.type===j?(se=cl(K.props.children,q.mode,se,K.key),se.return=q,q=se):(se=Xf(K.type,K.key,K.props,null,q.mode,se),cc(se,K),se.return=q,q=se)}return T(q);case b:e:{for(Re=K.key;V!==null;){if(V.key===Re)if(V.tag===4&&V.stateNode.containerInfo===K.containerInfo&&V.stateNode.implementation===K.implementation){f(q,V.sibling),se=x(V,K.children||[]),se.return=q,q=se;break e}else{f(q,V);break}else s(q,V);V=V.sibling}se=Vy(K,q.mode,se),se.return=q,q=se}return T(q);case I:return K=ml(K),ct(q,V,K,se)}if(re(K))return Se(q,V,K,se);if(H(K)){if(Re=H(K),typeof Re!="function")throw Error(r(150));return K=Re.call(K),Me(q,V,K,se)}if(typeof K.then=="function")return ct(q,V,rh(K),se);if(K.$$typeof===A)return ct(q,V,Jf(q,K),se);ih(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,V!==null&&V.tag===6?(f(q,V.sibling),se=x(V,K),se.return=q,q=se):(f(q,V),se=Uy(K,q.mode,se),se.return=q,q=se),T(q)):f(q,V)}return function(q,V,K,se){try{uc=0;var Re=ct(q,V,K,se);return js=null,Re}catch(Ee){if(Ee===Ss||Ee===th)throw Ee;var Qe=Cr(29,Ee,null,q.mode);return Qe.lanes=se,Qe.return=q,Qe}finally{}}}var yl=gk(!0),yk=gk(!1),xo=!1;function tv(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function nv(o,s){o=o.updateQueue,s.updateQueue===o&&(s.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function bo(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function wo(o,s,f){var g=o.updateQueue;if(g===null)return null;if(g=g.shared,(tt&2)!==0){var x=g.pending;return x===null?s.next=s:(s.next=x.next,x.next=s),g.pending=s,s=Yf(o),ek(o,null,f),s}return Kf(o,g,s,f),Yf(o)}function dc(o,s,f){if(s=s.updateQueue,s!==null&&(s=s.shared,(f&4194048)!==0)){var g=s.lanes;g&=o.pendingLanes,f|=g,s.lanes=f,Sr(o,f)}}function rv(o,s){var f=o.updateQueue,g=o.alternate;if(g!==null&&(g=g.updateQueue,f===g)){var x=null,S=null;if(f=f.firstBaseUpdate,f!==null){do{var T={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};S===null?x=S=T:S=S.next=T,f=f.next}while(f!==null);S===null?x=S=s:S=S.next=s}else x=S=s;f={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:S,shared:g.shared,callbacks:g.callbacks},o.updateQueue=f;return}o=f.lastBaseUpdate,o===null?f.firstBaseUpdate=s:o.next=s,f.lastBaseUpdate=s}var iv=!1;function fc(){if(iv){var o=ws;if(o!==null)throw o}}function hc(o,s,f,g){iv=!1;var x=o.updateQueue;xo=!1;var S=x.firstBaseUpdate,T=x.lastBaseUpdate,_=x.shared.pending;if(_!==null){x.shared.pending=null;var B=_,Y=B.next;B.next=null,T===null?S=Y:T.next=Y,T=B;var oe=o.alternate;oe!==null&&(oe=oe.updateQueue,_=oe.lastBaseUpdate,_!==T&&(_===null?oe.firstBaseUpdate=Y:_.next=Y,oe.lastBaseUpdate=B))}if(S!==null){var ue=x.baseState;T=0,oe=Y=B=null,_=S;do{var X=_.lane&-536870913,te=X!==_.lane;if(te?(Ge&X)===X:(g&X)===X){X!==0&&X===bs&&(iv=!0),oe!==null&&(oe=oe.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Se=o,Me=_;X=s;var ct=f;switch(Me.tag){case 1:if(Se=Me.payload,typeof Se=="function"){ue=Se.call(ct,ue,X);break e}ue=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=Me.payload,X=typeof Se=="function"?Se.call(ct,ue,X):Se,X==null)break e;ue=m({},ue,X);break e;case 2:xo=!0}}X=_.callback,X!==null&&(o.flags|=64,te&&(o.flags|=8192),te=x.callbacks,te===null?x.callbacks=[X]:te.push(X))}else te={lane:X,tag:_.tag,payload:_.payload,callback:_.callback,next:null},oe===null?(Y=oe=te,B=ue):oe=oe.next=te,T|=X;if(_=_.next,_===null){if(_=x.shared.pending,_===null)break;te=_,_=te.next,te.next=null,x.lastBaseUpdate=te,x.shared.pending=null}}while(!0);oe===null&&(B=ue),x.baseState=B,x.firstBaseUpdate=Y,x.lastBaseUpdate=oe,S===null&&(x.shared.lanes=0),Ao|=T,o.lanes=T,o.memoizedState=ue}}function vk(o,s){if(typeof o!="function")throw Error(r(191,o));o.call(s)}function xk(o,s){var f=o.callbacks;if(f!==null)for(o.callbacks=null,o=0;oS?S:8;var T=U.T,_={};U.T=_,jv(o,!1,s,f);try{var B=x(),Y=U.S;if(Y!==null&&Y(_,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var oe=NF(B,g);gc(o,s,oe,Or(o))}else gc(o,s,g,Or(o))}catch(ue){gc(o,s,{then:function(){},status:"rejected",reason:ue},Or())}finally{W.p=S,T!==null&&_.types!==null&&(T.types=_.types),U.T=T}}function $F(){}function wv(o,s,f,g){if(o.tag!==5)throw Error(r(476));var x=Zk(o).queue;Xk(o,x,s,ie,f===null?$F:function(){return Qk(o),f(g)})}function Zk(o){var s=o.memoizedState;if(s!==null)return s;s={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:ie},next:null};var f={};return s.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ba,lastRenderedState:f},next:null},o.memoizedState=s,o=o.alternate,o!==null&&(o.memoizedState=s),s}function Qk(o){var s=Zk(o);s.next===null&&(s=o.alternate.memoizedState),gc(o,s.next.queue,{},Or())}function Sv(){return kn(Mc)}function Jk(){return Lt().memoizedState}function eA(){return Lt().memoizedState}function UF(o){for(var s=o.return;s!==null;){switch(s.tag){case 24:case 3:var f=Or();o=bo(f);var g=wo(s,o,f);g!==null&&(dr(g,s,f),dc(g,s,f)),s={cache:Zy()},o.payload=s;return}s=s.return}}function VF(o,s,f){var g=Or();f={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},ph(o)?nA(s,f):(f=Fy(o,s,f,g),f!==null&&(dr(f,o,g),rA(f,s,g)))}function tA(o,s,f){var g=Or();gc(o,s,f,g)}function gc(o,s,f,g){var x={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(ph(o))nA(s,x);else{var S=o.alternate;if(o.lanes===0&&(S===null||S.lanes===0)&&(S=s.lastRenderedReducer,S!==null))try{var T=s.lastRenderedState,_=S(T,f);if(x.hasEagerState=!0,x.eagerState=_,jr(_,T))return Kf(o,s,x,0),ht===null&&Gf(),!1}catch{}finally{}if(f=Fy(o,s,x,g),f!==null)return dr(f,o,g),rA(f,s,g),!0}return!1}function jv(o,s,f,g){if(g={lane:2,revertLane:t0(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},ph(o)){if(s)throw Error(r(479))}else s=Fy(o,f,g,2),s!==null&&dr(s,o,2)}function ph(o){var s=o.alternate;return o===Fe||s!==null&&s===Fe}function nA(o,s){ks=lh=!0;var f=o.pending;f===null?s.next=s:(s.next=f.next,f.next=s),o.pending=s}function rA(o,s,f){if((f&4194048)!==0){var g=s.lanes;g&=o.pendingLanes,f|=g,s.lanes=f,Sr(o,f)}}var yc={readContext:kn,use:ch,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};yc.useEffectEvent=Rt;var iA={readContext:kn,use:ch,useCallback:function(o,s){return qn().memoizedState=[o,s===void 0?null:s],o},useContext:kn,useEffect:$k,useImperativeHandle:function(o,s,f){f=f!=null?f.concat([o]):null,fh(4194308,4,qk.bind(null,s,o),f)},useLayoutEffect:function(o,s){return fh(4194308,4,o,s)},useInsertionEffect:function(o,s){fh(4,2,o,s)},useMemo:function(o,s){var f=qn();s=s===void 0?null:s;var g=o();if(vl){cn(!0);try{o()}finally{cn(!1)}}return f.memoizedState=[g,s],g},useReducer:function(o,s,f){var g=qn();if(f!==void 0){var x=f(s);if(vl){cn(!0);try{f(s)}finally{cn(!1)}}}else x=s;return g.memoizedState=g.baseState=x,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:x},g.queue=o,o=o.dispatch=VF.bind(null,Fe,o),[g.memoizedState,o]},useRef:function(o){var s=qn();return o={current:o},s.memoizedState=o},useState:function(o){o=gv(o);var s=o.queue,f=tA.bind(null,Fe,s);return s.dispatch=f,[o.memoizedState,f]},useDebugValue:xv,useDeferredValue:function(o,s){var f=qn();return bv(f,o,s)},useTransition:function(){var o=gv(!1);return o=Xk.bind(null,Fe,o.queue,!0,!1),qn().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,s,f){var g=Fe,x=qn();if(Ye){if(f===void 0)throw Error(r(407));f=f()}else{if(f=s(),ht===null)throw Error(r(349));(Ge&127)!==0||kk(g,s,f)}x.memoizedState=f;var S={value:f,getSnapshot:s};return x.queue=S,$k(Ek.bind(null,g,S,o),[o]),g.flags|=2048,Es(9,{destroy:void 0},Ak.bind(null,g,S,f,s),null),f},useId:function(){var o=qn(),s=ht.identifierPrefix;if(Ye){var f=Wi,g=qi;f=(g&~(1<<32-rt(g)-1)).toString(32)+f,s="_"+s+"R_"+f,f=sh++,0<\/script>",S=S.removeChild(S.firstChild);break;case"select":S=typeof g.is=="string"?T.createElement("select",{is:g.is}):T.createElement("select"),g.multiple?S.multiple=!0:g.size&&(S.size=g.size);break;default:S=typeof g.is=="string"?T.createElement(x,{is:g.is}):T.createElement(x)}}S[jn]=s,S[ar]=g;e:for(T=s.child;T!==null;){if(T.tag===5||T.tag===6)S.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===s)break e;for(;T.sibling===null;){if(T.return===null||T.return===s)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}s.stateNode=S;e:switch(En(S,x,g),x){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&Sa(s)}}return wt(s),Iv(s,s.type,o===null?null:o.memoizedProps,s.pendingProps,f),null;case 6:if(o&&s.stateNode!=null)o.memoizedProps!==g&&Sa(s);else{if(typeof g!="string"&&s.stateNode===null)throw Error(r(166));if(o=ve.current,vs(s)){if(o=s.stateNode,f=s.memoizedProps,g=null,x=Cn,x!==null)switch(x.tag){case 27:case 5:g=x.memoizedProps}o[jn]=s,o=!!(o.nodeValue===f||g!==null&&g.suppressHydrationWarning===!0||jE(o.nodeValue,f)),o||yo(s,!0)}else o=Ph(o).createTextNode(g),o[jn]=s,s.stateNode=o}return wt(s),null;case 31:if(f=s.memoizedState,o===null||o.memoizedState!==null){if(g=vs(s),f!==null){if(o===null){if(!g)throw Error(r(318));if(o=s.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(r(557));o[jn]=s}else dl(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;wt(s),o=!1}else f=Gy(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=f),o=!0;if(!o)return s.flags&256?(Ar(s),s):(Ar(s),null);if((s.flags&128)!==0)throw Error(r(558))}return wt(s),null;case 13:if(g=s.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(x=vs(s),g!==null&&g.dehydrated!==null){if(o===null){if(!x)throw Error(r(318));if(x=s.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(r(317));x[jn]=s}else dl(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;wt(s),x=!1}else x=Gy(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=x),x=!0;if(!x)return s.flags&256?(Ar(s),s):(Ar(s),null)}return Ar(s),(s.flags&128)!==0?(s.lanes=f,s):(f=g!==null,o=o!==null&&o.memoizedState!==null,f&&(g=s.child,x=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(x=g.alternate.memoizedState.cachePool.pool),S=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(S=g.memoizedState.cachePool.pool),S!==x&&(g.flags|=2048)),f!==o&&f&&(s.child.flags|=8192),xh(s,s.updateQueue),wt(s),null);case 4:return Q(),o===null&&a0(s.stateNode.containerInfo),wt(s),null;case 10:return va(s.type),wt(s),null;case 19:if(G(It),g=s.memoizedState,g===null)return wt(s),null;if(x=(s.flags&128)!==0,S=g.rendering,S===null)if(x)xc(g,!1);else{if(Dt!==0||o!==null&&(o.flags&128)!==0)for(o=s.child;o!==null;){if(S=oh(o),S!==null){for(s.flags|=128,xc(g,!1),o=S.updateQueue,s.updateQueue=o,xh(s,o),s.subtreeFlags=0,o=f,f=s.child;f!==null;)tk(f,o),f=f.sibling;return P(It,It.current&1|2),Ye&&ga(s,g.treeForkCount),s.child}o=o.sibling}g.tail!==null&&un()>Ch&&(s.flags|=128,x=!0,xc(g,!1),s.lanes=4194304)}else{if(!x)if(o=oh(S),o!==null){if(s.flags|=128,x=!0,o=o.updateQueue,s.updateQueue=o,xh(s,o),xc(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ye)return wt(s),null}else 2*un()-g.renderingStartTime>Ch&&f!==536870912&&(s.flags|=128,x=!0,xc(g,!1),s.lanes=4194304);g.isBackwards?(S.sibling=s.child,s.child=S):(o=g.last,o!==null?o.sibling=S:s.child=S,g.last=S)}return g.tail!==null?(o=g.tail,g.rendering=o,g.tail=o.sibling,g.renderingStartTime=un(),o.sibling=null,f=It.current,P(It,x?f&1|2:f&1),Ye&&ga(s,g.treeForkCount),o):(wt(s),null);case 22:case 23:return Ar(s),ov(),g=s.memoizedState!==null,o!==null?o.memoizedState!==null!==g&&(s.flags|=8192):g&&(s.flags|=8192),g?(f&536870912)!==0&&(s.flags&128)===0&&(wt(s),s.subtreeFlags&6&&(s.flags|=8192)):wt(s),f=s.updateQueue,f!==null&&xh(s,f.retryQueue),f=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(f=o.memoizedState.cachePool.pool),g=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(g=s.memoizedState.cachePool.pool),g!==f&&(s.flags|=2048),o!==null&&G(pl),null;case 24:return f=null,o!==null&&(f=o.memoizedState.cache),s.memoizedState.cache!==f&&(s.flags|=2048),va(Vt),wt(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function KF(o,s){switch(qy(s),s.tag){case 1:return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 3:return va(Vt),Q(),o=s.flags,(o&65536)!==0&&(o&128)===0?(s.flags=o&-65537|128,s):null;case 26:case 27:case 5:return pe(s),null;case 31:if(s.memoizedState!==null){if(Ar(s),s.alternate===null)throw Error(r(340));dl()}return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 13:if(Ar(s),o=s.memoizedState,o!==null&&o.dehydrated!==null){if(s.alternate===null)throw Error(r(340));dl()}return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 19:return G(It),null;case 4:return Q(),null;case 10:return va(s.type),null;case 22:case 23:return Ar(s),ov(),o!==null&&G(pl),o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 24:return va(Vt),null;case 25:return null;default:return null}}function TA(o,s){switch(qy(s),s.tag){case 3:va(Vt),Q();break;case 26:case 27:case 5:pe(s);break;case 4:Q();break;case 31:s.memoizedState!==null&&Ar(s);break;case 13:Ar(s);break;case 19:G(It);break;case 10:va(s.type);break;case 22:case 23:Ar(s),ov(),o!==null&&G(pl);break;case 24:va(Vt)}}function bc(o,s){try{var f=s.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var x=g.next;f=x;do{if((f.tag&o)===o){g=void 0;var S=f.create,T=f.inst;g=S(),T.destroy=g}f=f.next}while(f!==x)}}catch(_){at(s,s.return,_)}}function Co(o,s,f){try{var g=s.updateQueue,x=g!==null?g.lastEffect:null;if(x!==null){var S=x.next;g=S;do{if((g.tag&o)===o){var T=g.inst,_=T.destroy;if(_!==void 0){T.destroy=void 0,x=s;var B=f,Y=_;try{Y()}catch(oe){at(x,B,oe)}}}g=g.next}while(g!==S)}}catch(oe){at(s,s.return,oe)}}function OA(o){var s=o.updateQueue;if(s!==null){var f=o.stateNode;try{xk(s,f)}catch(g){at(o,o.return,g)}}}function RA(o,s,f){f.props=xl(o.type,o.memoizedProps),f.state=o.memoizedState;try{f.componentWillUnmount()}catch(g){at(o,s,g)}}function wc(o,s){try{var f=o.ref;if(f!==null){switch(o.tag){case 26:case 27:case 5:var g=o.stateNode;break;case 30:g=o.stateNode;break;default:g=o.stateNode}typeof f=="function"?o.refCleanup=f(g):f.current=g}}catch(x){at(o,s,x)}}function Gi(o,s){var f=o.ref,g=o.refCleanup;if(f!==null)if(typeof g=="function")try{g()}catch(x){at(o,s,x)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(x){at(o,s,x)}else f.current=null}function DA(o){var s=o.type,f=o.memoizedProps,g=o.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":f.autoFocus&&g.focus();break e;case"img":f.src?g.src=f.src:f.srcSet&&(g.srcset=f.srcSet)}}catch(x){at(o,o.return,x)}}function Lv(o,s,f){try{var g=o.stateNode;g9(g,o.type,f,s),g[ar]=s}catch(x){at(o,o.return,x)}}function _A(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&Do(o.type)||o.tag===4}function Bv(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||_A(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&Do(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Fv(o,s,f){var g=o.tag;if(g===5||g===6)o=o.stateNode,s?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(o,s):(s=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,s.appendChild(o),f=f._reactRootContainer,f!=null||s.onclick!==null||(s.onclick=ha));else if(g!==4&&(g===27&&Do(o.type)&&(f=o.stateNode,s=null),o=o.child,o!==null))for(Fv(o,s,f),o=o.sibling;o!==null;)Fv(o,s,f),o=o.sibling}function bh(o,s,f){var g=o.tag;if(g===5||g===6)o=o.stateNode,s?f.insertBefore(o,s):f.appendChild(o);else if(g!==4&&(g===27&&Do(o.type)&&(f=o.stateNode),o=o.child,o!==null))for(bh(o,s,f),o=o.sibling;o!==null;)bh(o,s,f),o=o.sibling}function MA(o){var s=o.stateNode,f=o.memoizedProps;try{for(var g=o.type,x=s.attributes;x.length;)s.removeAttributeNode(x[0]);En(s,g,f),s[jn]=o,s[ar]=f}catch(S){at(o,o.return,S)}}var ja=!1,Wt=!1,$v=!1,PA=typeof WeakSet=="function"?WeakSet:Set,hn=null;function YF(o,s){if(o=o.containerInfo,s0=$h,o=WC(o),Py(o)){if("selectionStart"in o)var f={start:o.selectionStart,end:o.selectionEnd};else e:{f=(f=o.ownerDocument)&&f.defaultView||window;var g=f.getSelection&&f.getSelection();if(g&&g.rangeCount!==0){f=g.anchorNode;var x=g.anchorOffset,S=g.focusNode;g=g.focusOffset;try{f.nodeType,S.nodeType}catch{f=null;break e}var T=0,_=-1,B=-1,Y=0,oe=0,ue=o,X=null;t:for(;;){for(var te;ue!==f||x!==0&&ue.nodeType!==3||(_=T+x),ue!==S||g!==0&&ue.nodeType!==3||(B=T+g),ue.nodeType===3&&(T+=ue.nodeValue.length),(te=ue.firstChild)!==null;)X=ue,ue=te;for(;;){if(ue===o)break t;if(X===f&&++Y===x&&(_=T),X===S&&++oe===g&&(B=T),(te=ue.nextSibling)!==null)break;ue=X,X=ue.parentNode}ue=te}f=_===-1||B===-1?null:{start:_,end:B}}else f=null}f=f||{start:0,end:0}}else f=null;for(u0={focusedElem:o,selectionRange:f},$h=!1,hn=s;hn!==null;)if(s=hn,o=s.child,(s.subtreeFlags&1028)!==0&&o!==null)o.return=s,hn=o;else for(;hn!==null;){switch(s=hn,S=s.alternate,o=s.flags,s.tag){case 0:if((o&4)!==0&&(o=s.updateQueue,o=o!==null?o.events:null,o!==null))for(f=0;f title"))),En(S,g,f),S[jn]=o,fn(S),g=S;break e;case"link":var T=FE("link","href",x).get(g+(f.href||""));if(T){for(var _=0;_ct&&(T=ct,ct=Me,Me=T);var q=HC(_,Me),V=HC(_,ct);if(q&&V&&(te.rangeCount!==1||te.anchorNode!==q.node||te.anchorOffset!==q.offset||te.focusNode!==V.node||te.focusOffset!==V.offset)){var K=ue.createRange();K.setStart(q.node,q.offset),te.removeAllRanges(),Me>ct?(te.addRange(K),te.extend(V.node,V.offset)):(K.setEnd(V.node,V.offset),te.addRange(K))}}}}for(ue=[],te=_;te=te.parentNode;)te.nodeType===1&&ue.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_f?32:f,U.T=null,f=Kv,Kv=null;var S=To,T=Ta;if(Qt=0,_s=To=null,Ta=0,(tt&6)!==0)throw Error(r(331));var _=tt;if(tt|=4,qA(S.current),UA(S,S.current,T,f),tt=_,Ec(0,!1),Pt&&typeof Pt.onPostCommitFiberRoot=="function")try{Pt.onPostCommitFiberRoot(Sn,S)}catch{}return!0}finally{W.p=x,U.T=g,uE(o,s)}}function dE(o,s,f){s=Xr(f,s),s=Ev(o.stateNode,s,2),o=wo(o,s,2),o!==null&&(Hr(o,2),Ki(o))}function at(o,s,f){if(o.tag===3)dE(o,o,f);else for(;s!==null;){if(s.tag===3){dE(s,o,f);break}else if(s.tag===1){var g=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Eo===null||!Eo.has(g))){o=Xr(f,o),f=fA(2),g=wo(s,f,2),g!==null&&(hA(f,g,s,o),Hr(g,2),Ki(g));break}}s=s.return}}function Qv(o,s,f){var g=o.pingCache;if(g===null){g=o.pingCache=new QF;var x=new Set;g.set(s,x)}else x=g.get(s),x===void 0&&(x=new Set,g.set(s,x));x.has(f)||(Hv=!0,x.add(f),o=r9.bind(null,o,s,f),s.then(o,o))}function r9(o,s,f){var g=o.pingCache;g!==null&&g.delete(s),o.pingedLanes|=o.suspendedLanes&f,o.warmLanes&=~f,ht===o&&(Ge&f)===f&&(Dt===4||Dt===3&&(Ge&62914560)===Ge&&300>un()-jh?(tt&2)===0&&Ms(o,0):qv|=f,Ds===Ge&&(Ds=0)),Ki(o)}function fE(o,s){s===0&&(s=Mn()),o=ul(o,s),o!==null&&(Hr(o,s),Ki(o))}function i9(o){var s=o.memoizedState,f=0;s!==null&&(f=s.retryLane),fE(o,f)}function a9(o,s){var f=0;switch(o.tag){case 31:case 13:var g=o.stateNode,x=o.memoizedState;x!==null&&(f=x.retryLane);break;case 19:g=o.stateNode;break;case 22:g=o.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(s),fE(o,f)}function o9(o,s){return Hn(o,s)}var Rh=null,Ns=null,Jv=!1,Dh=!1,e0=!1,Ro=0;function Ki(o){o!==Ns&&o.next===null&&(Ns===null?Rh=Ns=o:Ns=Ns.next=o),Dh=!0,Jv||(Jv=!0,s9())}function Ec(o,s){if(!e0&&Dh){e0=!0;do for(var f=!1,g=Rh;g!==null;){if(o!==0){var x=g.pendingLanes;if(x===0)var S=0;else{var T=g.suspendedLanes,_=g.pingedLanes;S=(1<<31-rt(42|o)+1)-1,S&=x&~(T&~_),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(f=!0,gE(g,S))}else S=Ge,S=dn(g,g===ht?S:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(S&3)===0||nr(g,S)||(f=!0,gE(g,S));g=g.next}while(f);e0=!1}}function l9(){hE()}function hE(){Dh=Jv=!1;var o=0;Ro!==0&&v9()&&(o=Ro);for(var s=un(),f=null,g=Rh;g!==null;){var x=g.next,S=pE(g,s);S===0?(g.next=null,f===null?Rh=x:f.next=x,x===null&&(Ns=f)):(f=g,(o!==0||(S&3)!==0)&&(Dh=!0)),g=x}Qt!==0&&Qt!==5||Ec(o),Ro!==0&&(Ro=0)}function pE(o,s){for(var f=o.suspendedLanes,g=o.pingedLanes,x=o.expirationTimes,S=o.pendingLanes&-62914561;0_)break;var oe=B.transferSize,ue=B.initiatorType;oe&&CE(ue)&&(B=B.responseEnd,T+=oe*(B<_?1:(_-Y)/(B-Y)))}if(--g,s+=8*(S+T)/(x.duration/1e3),o++,10"u"?null:document;function zE(o,s,f){var g=zs;if(g&&typeof s=="string"&&s){var x=Kr(s);x='link[rel="'+o+'"][href="'+x+'"]',typeof f=="string"&&(x+='[crossorigin="'+f+'"]'),NE.has(x)||(NE.add(x),o={rel:o,crossOrigin:f,href:s},g.querySelector(x)===null&&(s=g.createElement("link"),En(s,"link",o),fn(s),g.head.appendChild(s)))}}function E9(o){Oa.D(o),zE("dns-prefetch",o,null)}function T9(o,s){Oa.C(o,s),zE("preconnect",o,s)}function O9(o,s,f){Oa.L(o,s,f);var g=zs;if(g&&o&&s){var x='link[rel="preload"][as="'+Kr(s)+'"]';s==="image"&&f&&f.imageSrcSet?(x+='[imagesrcset="'+Kr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(x+='[imagesizes="'+Kr(f.imageSizes)+'"]')):x+='[href="'+Kr(o)+'"]';var S=x;switch(s){case"style":S=Is(o);break;case"script":S=Ls(o)}ni.has(S)||(o=m({rel:"preload",href:s==="image"&&f&&f.imageSrcSet?void 0:o,as:s},f),ni.set(S,o),g.querySelector(x)!==null||s==="style"&&g.querySelector(Dc(S))||s==="script"&&g.querySelector(_c(S))||(s=g.createElement("link"),En(s,"link",o),fn(s),g.head.appendChild(s)))}}function R9(o,s){Oa.m(o,s);var f=zs;if(f&&o){var g=s&&typeof s.as=="string"?s.as:"script",x='link[rel="modulepreload"][as="'+Kr(g)+'"][href="'+Kr(o)+'"]',S=x;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=Ls(o)}if(!ni.has(S)&&(o=m({rel:"modulepreload",href:o},s),ni.set(S,o),f.querySelector(x)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(_c(S)))return}g=f.createElement("link"),En(g,"link",o),fn(g),f.head.appendChild(g)}}}function D9(o,s,f){Oa.S(o,s,f);var g=zs;if(g&&o){var x=as(g).hoistableStyles,S=Is(o);s=s||"default";var T=x.get(S);if(!T){var _={loading:0,preload:null};if(T=g.querySelector(Dc(S)))_.loading=5;else{o=m({rel:"stylesheet",href:o,"data-precedence":s},f),(f=ni.get(S))&&g0(o,f);var B=T=g.createElement("link");fn(B),En(B,"link",o),B._p=new Promise(function(Y,oe){B.onload=Y,B.onerror=oe}),B.addEventListener("load",function(){_.loading|=1}),B.addEventListener("error",function(){_.loading|=2}),_.loading|=4,zh(T,s,g)}T={type:"stylesheet",instance:T,count:1,state:_},x.set(S,T)}}}function _9(o,s){Oa.X(o,s);var f=zs;if(f&&o){var g=as(f).hoistableScripts,x=Ls(o),S=g.get(x);S||(S=f.querySelector(_c(x)),S||(o=m({src:o,async:!0},s),(s=ni.get(x))&&y0(o,s),S=f.createElement("script"),fn(S),En(S,"link",o),f.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},g.set(x,S))}}function M9(o,s){Oa.M(o,s);var f=zs;if(f&&o){var g=as(f).hoistableScripts,x=Ls(o),S=g.get(x);S||(S=f.querySelector(_c(x)),S||(o=m({src:o,async:!0,type:"module"},s),(s=ni.get(x))&&y0(o,s),S=f.createElement("script"),fn(S),En(S,"link",o),f.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},g.set(x,S))}}function IE(o,s,f,g){var x=(x=ve.current)?Nh(x):null;if(!x)throw Error(r(446));switch(o){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(s=Is(f.href),f=as(x).hoistableStyles,g=f.get(s),g||(g={type:"style",instance:null,count:0,state:null},f.set(s,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){o=Is(f.href);var S=as(x).hoistableStyles,T=S.get(o);if(T||(x=x.ownerDocument||x,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(o,T),(S=x.querySelector(Dc(o)))&&!S._p&&(T.instance=S,T.state.loading=5),ni.has(o)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},ni.set(o,f),S||P9(x,o,f,T.state))),s&&g===null)throw Error(r(528,""));return T}if(s&&g!==null)throw Error(r(529,""));return null;case"script":return s=f.async,f=f.src,typeof f=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Ls(f),f=as(x).hoistableScripts,g=f.get(s),g||(g={type:"script",instance:null,count:0,state:null},f.set(s,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,o))}}function Is(o){return'href="'+Kr(o)+'"'}function Dc(o){return'link[rel="stylesheet"]['+o+"]"}function LE(o){return m({},o,{"data-precedence":o.precedence,precedence:null})}function P9(o,s,f,g){o.querySelector('link[rel="preload"][as="style"]['+s+"]")?g.loading=1:(s=o.createElement("link"),g.preload=s,s.addEventListener("load",function(){return g.loading|=1}),s.addEventListener("error",function(){return g.loading|=2}),En(s,"link",f),fn(s),o.head.appendChild(s))}function Ls(o){return'[src="'+Kr(o)+'"]'}function _c(o){return"script[async]"+o}function BE(o,s,f){if(s.count++,s.instance===null)switch(s.type){case"style":var g=o.querySelector('style[data-href~="'+Kr(f.href)+'"]');if(g)return s.instance=g,fn(g),g;var x=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return g=(o.ownerDocument||o).createElement("style"),fn(g),En(g,"style",x),zh(g,f.precedence,o),s.instance=g;case"stylesheet":x=Is(f.href);var S=o.querySelector(Dc(x));if(S)return s.state.loading|=4,s.instance=S,fn(S),S;g=LE(f),(x=ni.get(x))&&g0(g,x),S=(o.ownerDocument||o).createElement("link"),fn(S);var T=S;return T._p=new Promise(function(_,B){T.onload=_,T.onerror=B}),En(S,"link",g),s.state.loading|=4,zh(S,f.precedence,o),s.instance=S;case"script":return S=Ls(f.src),(x=o.querySelector(_c(S)))?(s.instance=x,fn(x),x):(g=f,(x=ni.get(S))&&(g=m({},f),y0(g,x)),o=o.ownerDocument||o,x=o.createElement("script"),fn(x),En(x,"link",g),o.head.appendChild(x),s.instance=x);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(g=s.instance,s.state.loading|=4,zh(g,f.precedence,o));return s.instance}function zh(o,s,f){for(var g=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=g.length?g[g.length-1]:null,S=x,T=0;T title"):null)}function N9(o,s,f){if(f===1||s.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return o=s.disabled,typeof s.precedence=="string"&&o==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function UE(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function z9(o,s,f,g){if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var x=Is(g.href),S=s.querySelector(Dc(x));if(S){s=S._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(o.count++,o=Lh.bind(o),s.then(o,o)),f.state.loading|=4,f.instance=S,fn(S);return}S=s.ownerDocument||s,g=LE(g),(x=ni.get(x))&&g0(g,x),S=S.createElement("link"),fn(S);var T=S;T._p=new Promise(function(_,B){T.onload=_,T.onerror=B}),En(S,"link",g),f.instance=S}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(f,s),(s=f.state.preload)&&(f.state.loading&3)===0&&(o.count++,f=Lh.bind(o),s.addEventListener("load",f),s.addEventListener("error",f))}}var v0=0;function I9(o,s){return o.stylesheets&&o.count===0&&Fh(o,o.stylesheets),0v0?50:800)+s);return o.unsuspend=f,function(){o.unsuspend=null,clearTimeout(g),clearTimeout(x)}}:null}function Lh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fh(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var Bh=null;function Fh(o,s){o.stylesheets=null,o.unsuspend!==null&&(o.count++,Bh=new Map,s.forEach(L9,o),Bh=null,Lh.call(o))}function L9(o,s){if(!(s.state.loading&4)){var f=Bh.get(o);if(f)var g=f.get(null);else{f=new Map,Bh.set(o,f);for(var x=o.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),E0.exports=t$(),E0.exports}var r$=n$();const i$=mi(r$);var fT="popstate";function a$(e={}){function t(r,i){let{pathname:a,search:l,hash:u}=r.location;return a1("",{pathname:a,search:l,hash:u},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:xd(i)}return l$(t,n,null,e)}function Et(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ir(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function o$(){return Math.random().toString(36).substring(2,10)}function hT(e,t){return{usr:e.state,key:e.key,idx:t}}function a1(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?ku(t):t,state:n,key:t&&t.key||r||o$()}}function xd({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ku(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function l$(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,l=i.history,u="POP",c=null,d=h();d==null&&(d=0,l.replaceState({...l.state,idx:d},""));function h(){return(l.state||{idx:null}).idx}function m(){u="POP";let C=h(),k=C==null?null:C-d;d=C,c&&c({action:u,location:j.location,delta:k})}function y(C,k){u="PUSH";let E=a1(j.location,C,k);d=h()+1;let A=hT(E,d),R=j.createHref(E);try{l.pushState(A,"",R)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;i.location.assign(R)}a&&c&&c({action:u,location:j.location,delta:1})}function v(C,k){u="REPLACE";let E=a1(j.location,C,k);d=h();let A=hT(E,d),R=j.createHref(E);l.replaceState(A,"",R),a&&c&&c({action:u,location:j.location,delta:0})}function b(C){return s$(C)}let j={get action(){return u},get location(){return e(i,l)},listen(C){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(fT,m),c=C,()=>{i.removeEventListener(fT,m),c=null}},createHref(C){return t(i,C)},createURL:b,encodeLocation(C){let k=b(C);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:y,replace:v,go(C){return l.go(C)}};return j}function s$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Et(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:xd(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function C5(e,t,n="/"){return u$(e,t,n,!1)}function u$(e,t,n,r){let i=typeof t=="string"?ku(t):t,a=Ua(i.pathname||"/",n);if(a==null)return null;let l=k5(e);c$(l);let u=null;for(let c=0;u==null&&c{let h={relativePath:d===void 0?l.path||"":d,caseSensitive:l.caseSensitive===!0,childrenIndex:u,route:l};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&c)return;Et(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let m=La([r,h.relativePath]),y=n.concat(h);l.children&&l.children.length>0&&(Et(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),k5(l.children,t,y,m,c)),!(l.path==null&&!l.index)&&t.push({path:m,score:y$(m,l.index),routesMeta:y})};return e.forEach((l,u)=>{if(l.path===""||!l.path?.includes("?"))a(l,u);else for(let c of A5(l.path))a(l,u,!0,c)}),t}function A5(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let l=A5(r.join("/")),u=[];return u.push(...l.map(c=>c===""?a:[a,c].join("/"))),i&&u.push(...l),u.map(c=>e.startsWith("/")&&c===""?"/":c)}function c$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:v$(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var d$=/^:[\w-]+$/,f$=3,h$=2,p$=1,m$=10,g$=-2,pT=e=>e==="*";function y$(e,t){let n=e.split("/"),r=n.length;return n.some(pT)&&(r+=g$),t&&(r+=h$),n.filter(i=>!pT(i)).reduce((i,a)=>i+(d$.test(a)?f$:a===""?p$:m$),r)}function v$(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function x$(e,t,n=!1){let{routesMeta:r}=e,i={},a="/",l=[];for(let u=0;u{if(h==="*"){let b=u[y]||"";l=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const v=u[y];return m&&!v?d[h]=void 0:d[h]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function b$(e,t=!1,n=!0){Ir(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,u,c)=>(r.push({paramName:u,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function w$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ir(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ua(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var S$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,j$=e=>S$.test(e);function C$(e,t="/"){let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?ku(e):e,a;if(n)if(j$(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Ir(!1,`Pathnames cannot have embedded double slashes - normalizing ${l} -> ${n}`)}n.startsWith("/")?a=mT(n.substring(1),"/"):a=mT(n,t)}else a=t;return{pathname:a,search:E$(r),hash:T$(i)}}function mT(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function D0(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function k$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function cS(e){let t=k$(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function dS(e,t,n,r=!1){let i;typeof e=="string"?i=ku(e):(i={...e},Et(!i.pathname||!i.pathname.includes("?"),D0("?","pathname","search",i)),Et(!i.pathname||!i.pathname.includes("#"),D0("#","pathname","hash",i)),Et(!i.search||!i.search.includes("#"),D0("#","search","hash",i)));let a=e===""||i.pathname==="",l=a?"/":i.pathname,u;if(l==null)u=n;else{let m=t.length-1;if(!r&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),m-=1;i.pathname=y.join("/")}u=m>=0?t[m]:"/"}let c=C$(i,u),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}var La=e=>e.join("/").replace(/\/\/+/g,"/"),A$=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),E$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,T$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function O$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var E5=["POST","PUT","PATCH","DELETE"];new Set(E5);var R$=["GET",...E5];new Set(R$);var Au=w.createContext(null);Au.displayName="DataRouter";var lg=w.createContext(null);lg.displayName="DataRouterState";w.createContext(!1);var T5=w.createContext({isTransitioning:!1});T5.displayName="ViewTransition";var D$=w.createContext(new Map);D$.displayName="Fetchers";var _$=w.createContext(null);_$.displayName="Await";var Ii=w.createContext(null);Ii.displayName="Navigation";var Yd=w.createContext(null);Yd.displayName="Location";var Li=w.createContext({outlet:null,matches:[],isDataRoute:!1});Li.displayName="Route";var fS=w.createContext(null);fS.displayName="RouteError";function M$(e,{relative:t}={}){Et(Eu(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=w.useContext(Ii),{hash:i,pathname:a,search:l}=Xd(e,{relative:t}),u=a;return n!=="/"&&(u=a==="/"?n:La([n,a])),r.createHref({pathname:u,search:l,hash:i})}function Eu(){return w.useContext(Yd)!=null}function $r(){return Et(Eu(),"useLocation() may be used only in the context of a component."),w.useContext(Yd).location}var O5="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function R5(e){w.useContext(Ii).static||w.useLayoutEffect(e)}function _n(){let{isDataRoute:e}=w.useContext(Li);return e?W$():P$()}function P$(){Et(Eu(),"useNavigate() may be used only in the context of a component.");let e=w.useContext(Au),{basename:t,navigator:n}=w.useContext(Ii),{matches:r}=w.useContext(Li),{pathname:i}=$r(),a=JSON.stringify(cS(r)),l=w.useRef(!1);return R5(()=>{l.current=!0}),w.useCallback((c,d={})=>{if(Ir(l.current,O5),!l.current)return;if(typeof c=="number"){n.go(c);return}let h=dS(c,JSON.parse(a),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:La([t,h.pathname])),(d.replace?n.replace:n.push)(h,d.state,d)},[t,n,a,i,e])}w.createContext(null);function to(){let{matches:e}=w.useContext(Li),t=e[e.length-1];return t?t.params:{}}function Xd(e,{relative:t}={}){let{matches:n}=w.useContext(Li),{pathname:r}=$r(),i=JSON.stringify(cS(n));return w.useMemo(()=>dS(e,JSON.parse(i),r,t==="path"),[e,i,r,t])}function N$(e,t){return D5(e,t)}function D5(e,t,n,r,i){Et(Eu(),"useRoutes() may be used only in the context of a component.");let{navigator:a}=w.useContext(Ii),{matches:l}=w.useContext(Li),u=l[l.length-1],c=u?u.params:{},d=u?u.pathname:"/",h=u?u.pathnameBase:"/",m=u&&u.route;{let E=m&&m.path||"";_5(d,!m||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${d}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. +`+g.stack}}var Kr=Object.prototype.hasOwnProperty,En=e.unstable_scheduleCallback,ye=e.unstable_cancelCallback,Re=e.unstable_shouldYield,_e=e.unstable_requestPaint,qe=e.unstable_now,bt=e.unstable_getCurrentPriorityLevel,ae=e.unstable_ImmediatePriority,me=e.unstable_UserBlockingPriority,Ee=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,Je=e.unstable_IdlePriority,Pt=e.log,Yr=e.unstable_setDisableYieldValue,Tn=null,Bt=null;function pn(o){if(typeof Pt=="function"&&Yr(o),Bt&&typeof Bt.setStrictMode=="function")try{Bt.setStrictMode(Tn,o)}catch{}}var ot=Math.clz32?Math.clz32:my,Ki=Math.log,ar=Math.LN2;function my(o){return o>>>=0,o===0?32:31-(Ki(o)/ar|0)|0}var ts=256,ns=262144,Ft=4194304;function $t(o){var s=o&42;if(s!==0)return s;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function mn(o,s,f){var g=o.pendingLanes;if(g===0)return 0;var x=0,S=o.suspendedLanes,T=o.pingedLanes;o=o.warmLanes;var _=g&134217727;return _!==0?(g=_&~S,g!==0?x=$t(g):(T&=_,T!==0?x=$t(T):f||(f=_&~o,f!==0&&(x=$t(f))))):(_=g&~S,_!==0?x=$t(_):T!==0?x=$t(T):f||(f=g&~o,f!==0&&(x=$t(f)))),x===0?0:s!==0&&s!==x&&(s&S)===0&&(S=x&-x,f=s&-s,S>=f||S===32&&(f&4194048)!==0)?s:x}function or(o,s){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&s)===0}function lr(o,s){switch(o){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Bn(){var o=Ft;return Ft<<=1,(Ft&62914560)===0&&(Ft=4194304),o}function sr(o){for(var s=[],f=0;31>f;f++)s.push(o);return s}function Xr(o,s){o.pendingLanes|=s,s!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function nn(o,s,f,g,x,S){var T=o.pendingLanes;o.pendingLanes=f,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=f,o.entangledLanes&=f,o.errorRecoveryDisabledLanes&=f,o.shellSuspendCounter=0;var _=o.entanglements,B=o.expirationTimes,Y=o.hiddenUpdates;for(f=T&~f;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var $8=/[\n"\\]/g;function ei(o){return o.replace($8,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function xy(o,s,f,g,x,S,T,_){o.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?o.type=T:o.removeAttribute("type"),s!=null?T==="number"?(s===0&&o.value===""||o.value!=s)&&(o.value=""+Jr(s)):o.value!==""+Jr(s)&&(o.value=""+Jr(s)):T!=="submit"&&T!=="reset"||o.removeAttribute("value"),s!=null?by(o,T,Jr(s)):f!=null?by(o,T,Jr(f)):g!=null&&o.removeAttribute("value"),x==null&&S!=null&&(o.defaultChecked=!!S),x!=null&&(o.checked=x&&typeof x!="function"&&typeof x!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?o.name=""+Jr(_):o.removeAttribute("name")}function xC(o,s,f,g,x,S,T,_){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(o.type=S),s!=null||f!=null){if(!(S!=="submit"&&S!=="reset"||s!=null)){vy(o);return}f=f!=null?""+Jr(f):"",s=s!=null?""+Jr(s):f,_||s===o.value||(o.value=s),o.defaultValue=s}g=g??x,g=typeof g!="function"&&typeof g!="symbol"&&!!g,o.checked=_?o.checked:!!g,o.defaultChecked=!!g,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(o.name=T),vy(o)}function by(o,s,f){s==="number"&&Lf(o.ownerDocument)===o||o.defaultValue===""+f||(o.defaultValue=""+f)}function ss(o,s,f,g){if(o=o.options,s){s={};for(var x=0;x"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ky=!1;if(xa)try{var Zu={};Object.defineProperty(Zu,"passive",{get:function(){ky=!0}}),window.addEventListener("test",Zu,Zu),window.removeEventListener("test",Zu,Zu)}catch{ky=!1}var go=null,Ay=null,Ff=null;function AC(){if(Ff)return Ff;var o,s=Ay,f=s.length,g,x="value"in go?go.value:go.textContent,S=x.length;for(o=0;o=ec),_C=" ",MC=!1;function PC(o,s){switch(o){case"keyup":return mF.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NC(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var fs=!1;function yF(o,s){switch(o){case"compositionend":return NC(s);case"keypress":return s.which!==32?null:(MC=!0,_C);case"textInput":return o=s.data,o===_C&&MC?null:o;default:return null}}function vF(o,s){if(fs)return o==="compositionend"||!Dy&&PC(o,s)?(o=AC(),Ff=Ay=go=null,fs=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:f,offset:s-o};o=g}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=VC(f)}}function qC(o,s){return o&&s?o===s?!0:o&&o.nodeType===3?!1:s&&s.nodeType===3?qC(o,s.parentNode):"contains"in o?o.contains(s):o.compareDocumentPosition?!!(o.compareDocumentPosition(s)&16):!1:!1}function WC(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var s=Lf(o.document);s instanceof o.HTMLIFrameElement;){try{var f=typeof s.contentWindow.location.href=="string"}catch{f=!1}if(f)o=s.contentWindow;else break;s=Lf(o.document)}return s}function Py(o){var s=o&&o.nodeName&&o.nodeName.toLowerCase();return s&&(s==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||s==="textarea"||o.contentEditable==="true")}var AF=xa&&"documentMode"in document&&11>=document.documentMode,hs=null,Ny=null,ic=null,zy=!1;function GC(o,s,f){var g=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;zy||hs==null||hs!==Lf(g)||(g=hs,"selectionStart"in g&&Py(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),ic&&rc(ic,g)||(ic=g,g=Mh(Ny,"onSelect"),0>=T,x-=T,Yi=1<<32-ot(s)+x|f<Ve?(Xe=ke,ke=null):Xe=ke.sibling;var tt=X(q,ke,K[Ve],le);if(tt===null){ke===null&&(ke=Xe);break}o&&ke&&tt.alternate===null&&s(q,ke),V=S(tt,V,Ve),et===null?Te=tt:et.sibling=tt,et=tt,ke=Xe}if(Ve===K.length)return f(q,ke),Ze&&wa(q,Ve),Te;if(ke===null){for(;VeVe?(Xe=ke,ke=null):Xe=ke.sibling;var Lo=X(q,ke,tt.value,le);if(Lo===null){ke===null&&(ke=Xe);break}o&&ke&&Lo.alternate===null&&s(q,ke),V=S(Lo,V,Ve),et===null?Te=Lo:et.sibling=Lo,et=Lo,ke=Xe}if(tt.done)return f(q,ke),Ze&&wa(q,Ve),Te;if(ke===null){for(;!tt.done;Ve++,tt=K.next())tt=se(q,tt.value,le),tt!==null&&(V=S(tt,V,Ve),et===null?Te=tt:et.sibling=tt,et=tt);return Ze&&wa(q,Ve),Te}for(ke=g(ke);!tt.done;Ve++,tt=K.next())tt=ee(ke,q,Ve,tt.value,le),tt!==null&&(o&&tt.alternate!==null&&ke.delete(tt.key===null?Ve:tt.key),V=S(tt,V,Ve),et===null?Te=tt:et.sibling=tt,et=tt);return o&&ke.forEach(function(W9){return s(q,W9)}),Ze&&wa(q,Ve),Te}function mt(q,V,K,le){if(typeof K=="object"&&K!==null&&K.type===j&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case v:e:{for(var Te=K.key;V!==null;){if(V.key===Te){if(Te=K.type,Te===j){if(V.tag===7){f(q,V.sibling),le=x(V,K.props.children),le.return=q,q=le;break e}}else if(V.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===I&&yl(Te)===V.type){f(q,V.sibling),le=x(V,K.props),cc(le,K),le.return=q,q=le;break e}f(q,V);break}else s(q,V);V=V.sibling}K.type===j?(le=fl(K.props.children,q.mode,le,K.key),le.return=q,q=le):(le=Xf(K.type,K.key,K.props,null,q.mode,le),cc(le,K),le.return=q,q=le)}return T(q);case b:e:{for(Te=K.key;V!==null;){if(V.key===Te)if(V.tag===4&&V.stateNode.containerInfo===K.containerInfo&&V.stateNode.implementation===K.implementation){f(q,V.sibling),le=x(V,K.children||[]),le.return=q,q=le;break e}else{f(q,V);break}else s(q,V);V=V.sibling}le=Vy(K,q.mode,le),le.return=q,q=le}return T(q);case I:return K=yl(K),mt(q,V,K,le)}if(ne(K))return Se(q,V,K,le);if(H(K)){if(Te=H(K),typeof Te!="function")throw Error(r(150));return K=Te.call(K),Ne(q,V,K,le)}if(typeof K.then=="function")return mt(q,V,rh(K),le);if(K.$$typeof===A)return mt(q,V,Jf(q,K),le);ih(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,V!==null&&V.tag===6?(f(q,V.sibling),le=x(V,K),le.return=q,q=le):(f(q,V),le=Uy(K,q.mode,le),le.return=q,q=le),T(q)):f(q,V)}return function(q,V,K,le){try{uc=0;var Te=mt(q,V,K,le);return Cs=null,Te}catch(ke){if(ke===js||ke===th)throw ke;var et=Tr(29,ke,null,q.mode);return et.lanes=le,et.return=q,et}finally{}}}var xl=gk(!0),yk=gk(!1),wo=!1;function tv(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function nv(o,s){o=o.updateQueue,s.updateQueue===o&&(s.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function So(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function jo(o,s,f){var g=o.updateQueue;if(g===null)return null;if(g=g.shared,(rt&2)!==0){var x=g.pending;return x===null?s.next=s:(s.next=x.next,x.next=s),g.pending=s,s=Yf(o),ek(o,null,f),s}return Kf(o,g,s,f),Yf(o)}function dc(o,s,f){if(s=s.updateQueue,s!==null&&(s=s.shared,(f&4194048)!==0)){var g=s.lanes;g&=o.pendingLanes,f|=g,s.lanes=f,Ar(o,f)}}function rv(o,s){var f=o.updateQueue,g=o.alternate;if(g!==null&&(g=g.updateQueue,f===g)){var x=null,S=null;if(f=f.firstBaseUpdate,f!==null){do{var T={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};S===null?x=S=T:S=S.next=T,f=f.next}while(f!==null);S===null?x=S=s:S=S.next=s}else x=S=s;f={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:S,shared:g.shared,callbacks:g.callbacks},o.updateQueue=f;return}o=f.lastBaseUpdate,o===null?f.firstBaseUpdate=s:o.next=s,f.lastBaseUpdate=s}var iv=!1;function fc(){if(iv){var o=Ss;if(o!==null)throw o}}function hc(o,s,f,g){iv=!1;var x=o.updateQueue;wo=!1;var S=x.firstBaseUpdate,T=x.lastBaseUpdate,_=x.shared.pending;if(_!==null){x.shared.pending=null;var B=_,Y=B.next;B.next=null,T===null?S=Y:T.next=Y,T=B;var oe=o.alternate;oe!==null&&(oe=oe.updateQueue,_=oe.lastBaseUpdate,_!==T&&(_===null?oe.firstBaseUpdate=Y:_.next=Y,oe.lastBaseUpdate=B))}if(S!==null){var se=x.baseState;T=0,oe=Y=B=null,_=S;do{var X=_.lane&-536870913,ee=X!==_.lane;if(ee?(Ye&X)===X:(g&X)===X){X!==0&&X===ws&&(iv=!0),oe!==null&&(oe=oe.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Se=o,Ne=_;X=s;var mt=f;switch(Ne.tag){case 1:if(Se=Ne.payload,typeof Se=="function"){se=Se.call(mt,se,X);break e}se=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=Ne.payload,X=typeof Se=="function"?Se.call(mt,se,X):Se,X==null)break e;se=m({},se,X);break e;case 2:wo=!0}}X=_.callback,X!==null&&(o.flags|=64,ee&&(o.flags|=8192),ee=x.callbacks,ee===null?x.callbacks=[X]:ee.push(X))}else ee={lane:X,tag:_.tag,payload:_.payload,callback:_.callback,next:null},oe===null?(Y=oe=ee,B=se):oe=oe.next=ee,T|=X;if(_=_.next,_===null){if(_=x.shared.pending,_===null)break;ee=_,_=ee.next,ee.next=null,x.lastBaseUpdate=ee,x.shared.pending=null}}while(!0);oe===null&&(B=se),x.baseState=B,x.firstBaseUpdate=Y,x.lastBaseUpdate=oe,S===null&&(x.shared.lanes=0),To|=T,o.lanes=T,o.memoizedState=se}}function vk(o,s){if(typeof o!="function")throw Error(r(191,o));o.call(s)}function xk(o,s){var f=o.callbacks;if(f!==null)for(o.callbacks=null,o=0;oS?S:8;var T=U.T,_={};U.T=_,jv(o,!1,s,f);try{var B=x(),Y=U.S;if(Y!==null&&Y(_,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var oe=NF(B,g);gc(o,s,oe,Mr(o))}else gc(o,s,g,Mr(o))}catch(se){gc(o,s,{then:function(){},status:"rejected",reason:se},Mr())}finally{W.p=S,T!==null&&_.types!==null&&(T.types=_.types),U.T=T}}function $F(){}function wv(o,s,f,g){if(o.tag!==5)throw Error(r(476));var x=Zk(o).queue;Xk(o,x,s,re,f===null?$F:function(){return Qk(o),f(g)})}function Zk(o){var s=o.memoizedState;if(s!==null)return s;s={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:re},next:null};var f={};return s.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ka,lastRenderedState:f},next:null},o.memoizedState=s,o=o.alternate,o!==null&&(o.memoizedState=s),s}function Qk(o){var s=Zk(o);s.next===null&&(s=o.alternate.memoizedState),gc(o,s.next.queue,{},Mr())}function Sv(){return Dn(Mc)}function Jk(){return Vt().memoizedState}function eA(){return Vt().memoizedState}function UF(o){for(var s=o.return;s!==null;){switch(s.tag){case 24:case 3:var f=Mr();o=So(f);var g=jo(s,o,f);g!==null&&(mr(g,s,f),dc(g,s,f)),s={cache:Zy()},o.payload=s;return}s=s.return}}function VF(o,s,f){var g=Mr();f={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},ph(o)?nA(s,f):(f=Fy(o,s,f,g),f!==null&&(mr(f,o,g),rA(f,s,g)))}function tA(o,s,f){var g=Mr();gc(o,s,f,g)}function gc(o,s,f,g){var x={lane:g,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(ph(o))nA(s,x);else{var S=o.alternate;if(o.lanes===0&&(S===null||S.lanes===0)&&(S=s.lastRenderedReducer,S!==null))try{var T=s.lastRenderedState,_=S(T,f);if(x.hasEagerState=!0,x.eagerState=_,Er(_,T))return Kf(o,s,x,0),yt===null&&Gf(),!1}catch{}finally{}if(f=Fy(o,s,x,g),f!==null)return mr(f,o,g),rA(f,s,g),!0}return!1}function jv(o,s,f,g){if(g={lane:2,revertLane:t0(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},ph(o)){if(s)throw Error(r(479))}else s=Fy(o,f,g,2),s!==null&&mr(s,o,2)}function ph(o){var s=o.alternate;return o===$e||s!==null&&s===$e}function nA(o,s){As=lh=!0;var f=o.pending;f===null?s.next=s:(s.next=f.next,f.next=s),o.pending=s}function rA(o,s,f){if((f&4194048)!==0){var g=s.lanes;g&=o.pendingLanes,f|=g,s.lanes=f,Ar(o,f)}}var yc={readContext:Dn,use:ch,useCallback:Nt,useContext:Nt,useEffect:Nt,useImperativeHandle:Nt,useLayoutEffect:Nt,useInsertionEffect:Nt,useMemo:Nt,useReducer:Nt,useRef:Nt,useState:Nt,useDebugValue:Nt,useDeferredValue:Nt,useTransition:Nt,useSyncExternalStore:Nt,useId:Nt,useHostTransitionStatus:Nt,useFormState:Nt,useActionState:Nt,useOptimistic:Nt,useMemoCache:Nt,useCacheRefresh:Nt};yc.useEffectEvent=Nt;var iA={readContext:Dn,use:ch,useCallback:function(o,s){return Yn().memoizedState=[o,s===void 0?null:s],o},useContext:Dn,useEffect:$k,useImperativeHandle:function(o,s,f){f=f!=null?f.concat([o]):null,fh(4194308,4,qk.bind(null,s,o),f)},useLayoutEffect:function(o,s){return fh(4194308,4,o,s)},useInsertionEffect:function(o,s){fh(4,2,o,s)},useMemo:function(o,s){var f=Yn();s=s===void 0?null:s;var g=o();if(bl){pn(!0);try{o()}finally{pn(!1)}}return f.memoizedState=[g,s],g},useReducer:function(o,s,f){var g=Yn();if(f!==void 0){var x=f(s);if(bl){pn(!0);try{f(s)}finally{pn(!1)}}}else x=s;return g.memoizedState=g.baseState=x,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:x},g.queue=o,o=o.dispatch=VF.bind(null,$e,o),[g.memoizedState,o]},useRef:function(o){var s=Yn();return o={current:o},s.memoizedState=o},useState:function(o){o=gv(o);var s=o.queue,f=tA.bind(null,$e,s);return s.dispatch=f,[o.memoizedState,f]},useDebugValue:xv,useDeferredValue:function(o,s){var f=Yn();return bv(f,o,s)},useTransition:function(){var o=gv(!1);return o=Xk.bind(null,$e,o.queue,!0,!1),Yn().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,s,f){var g=$e,x=Yn();if(Ze){if(f===void 0)throw Error(r(407));f=f()}else{if(f=s(),yt===null)throw Error(r(349));(Ye&127)!==0||kk(g,s,f)}x.memoizedState=f;var S={value:f,getSnapshot:s};return x.queue=S,$k(Ek.bind(null,g,S,o),[o]),g.flags|=2048,Ts(9,{destroy:void 0},Ak.bind(null,g,S,f,s),null),f},useId:function(){var o=Yn(),s=yt.identifierPrefix;if(Ze){var f=Xi,g=Yi;f=(g&~(1<<32-ot(g)-1)).toString(32)+f,s="_"+s+"R_"+f,f=sh++,0<\/script>",S=S.removeChild(S.firstChild);break;case"select":S=typeof g.is=="string"?T.createElement("select",{is:g.is}):T.createElement("select"),g.multiple?S.multiple=!0:g.size&&(S.size=g.size);break;default:S=typeof g.is=="string"?T.createElement(x,{is:g.is}):T.createElement(x)}}S[On]=s,S[ur]=g;e:for(T=s.child;T!==null;){if(T.tag===5||T.tag===6)S.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===s)break e;for(;T.sibling===null;){if(T.return===null||T.return===s)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}s.stateNode=S;e:switch(Mn(S,x,g),x){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&Ea(s)}}return At(s),Iv(s,s.type,o===null?null:o.memoizedProps,s.pendingProps,f),null;case 6:if(o&&s.stateNode!=null)o.memoizedProps!==g&&Ea(s);else{if(typeof g!="string"&&s.stateNode===null)throw Error(r(166));if(o=ve.current,xs(s)){if(o=s.stateNode,f=s.memoizedProps,g=null,x=Rn,x!==null)switch(x.tag){case 27:case 5:g=x.memoizedProps}o[On]=s,o=!!(o.nodeValue===f||g!==null&&g.suppressHydrationWarning===!0||jE(o.nodeValue,f)),o||xo(s,!0)}else o=Ph(o).createTextNode(g),o[On]=s,s.stateNode=o}return At(s),null;case 31:if(f=s.memoizedState,o===null||o.memoizedState!==null){if(g=xs(s),f!==null){if(o===null){if(!g)throw Error(r(318));if(o=s.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(r(557));o[On]=s}else hl(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;At(s),o=!1}else f=Gy(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=f),o=!0;if(!o)return s.flags&256?(Rr(s),s):(Rr(s),null);if((s.flags&128)!==0)throw Error(r(558))}return At(s),null;case 13:if(g=s.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(x=xs(s),g!==null&&g.dehydrated!==null){if(o===null){if(!x)throw Error(r(318));if(x=s.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(r(317));x[On]=s}else hl(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;At(s),x=!1}else x=Gy(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=x),x=!0;if(!x)return s.flags&256?(Rr(s),s):(Rr(s),null)}return Rr(s),(s.flags&128)!==0?(s.lanes=f,s):(f=g!==null,o=o!==null&&o.memoizedState!==null,f&&(g=s.child,x=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(x=g.alternate.memoizedState.cachePool.pool),S=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(S=g.memoizedState.cachePool.pool),S!==x&&(g.flags|=2048)),f!==o&&f&&(s.child.flags|=8192),xh(s,s.updateQueue),At(s),null);case 4:return Q(),o===null&&a0(s.stateNode.containerInfo),At(s),null;case 10:return ja(s.type),At(s),null;case 19:if(G(Ut),g=s.memoizedState,g===null)return At(s),null;if(x=(s.flags&128)!==0,S=g.rendering,S===null)if(x)xc(g,!1);else{if(zt!==0||o!==null&&(o.flags&128)!==0)for(o=s.child;o!==null;){if(S=oh(o),S!==null){for(s.flags|=128,xc(g,!1),o=S.updateQueue,s.updateQueue=o,xh(s,o),s.subtreeFlags=0,o=f,f=s.child;f!==null;)tk(f,o),f=f.sibling;return P(Ut,Ut.current&1|2),Ze&&wa(s,g.treeForkCount),s.child}o=o.sibling}g.tail!==null&&qe()>Ch&&(s.flags|=128,x=!0,xc(g,!1),s.lanes=4194304)}else{if(!x)if(o=oh(S),o!==null){if(s.flags|=128,x=!0,o=o.updateQueue,s.updateQueue=o,xh(s,o),xc(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ze)return At(s),null}else 2*qe()-g.renderingStartTime>Ch&&f!==536870912&&(s.flags|=128,x=!0,xc(g,!1),s.lanes=4194304);g.isBackwards?(S.sibling=s.child,s.child=S):(o=g.last,o!==null?o.sibling=S:s.child=S,g.last=S)}return g.tail!==null?(o=g.tail,g.rendering=o,g.tail=o.sibling,g.renderingStartTime=qe(),o.sibling=null,f=Ut.current,P(Ut,x?f&1|2:f&1),Ze&&wa(s,g.treeForkCount),o):(At(s),null);case 22:case 23:return Rr(s),ov(),g=s.memoizedState!==null,o!==null?o.memoizedState!==null!==g&&(s.flags|=8192):g&&(s.flags|=8192),g?(f&536870912)!==0&&(s.flags&128)===0&&(At(s),s.subtreeFlags&6&&(s.flags|=8192)):At(s),f=s.updateQueue,f!==null&&xh(s,f.retryQueue),f=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(f=o.memoizedState.cachePool.pool),g=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(g=s.memoizedState.cachePool.pool),g!==f&&(s.flags|=2048),o!==null&&G(gl),null;case 24:return f=null,o!==null&&(f=o.memoizedState.cache),s.memoizedState.cache!==f&&(s.flags|=2048),ja(Kt),At(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function KF(o,s){switch(qy(s),s.tag){case 1:return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 3:return ja(Kt),Q(),o=s.flags,(o&65536)!==0&&(o&128)===0?(s.flags=o&-65537|128,s):null;case 26:case 27:case 5:return De(s),null;case 31:if(s.memoizedState!==null){if(Rr(s),s.alternate===null)throw Error(r(340));hl()}return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 13:if(Rr(s),o=s.memoizedState,o!==null&&o.dehydrated!==null){if(s.alternate===null)throw Error(r(340));hl()}return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 19:return G(Ut),null;case 4:return Q(),null;case 10:return ja(s.type),null;case 22:case 23:return Rr(s),ov(),o!==null&&G(gl),o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 24:return ja(Kt),null;case 25:return null;default:return null}}function TA(o,s){switch(qy(s),s.tag){case 3:ja(Kt),Q();break;case 26:case 27:case 5:De(s);break;case 4:Q();break;case 31:s.memoizedState!==null&&Rr(s);break;case 13:Rr(s);break;case 19:G(Ut);break;case 10:ja(s.type);break;case 22:case 23:Rr(s),ov(),o!==null&&G(gl);break;case 24:ja(Kt)}}function bc(o,s){try{var f=s.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var x=g.next;f=x;do{if((f.tag&o)===o){g=void 0;var S=f.create,T=f.inst;g=S(),T.destroy=g}f=f.next}while(f!==x)}}catch(_){ut(s,s.return,_)}}function Ao(o,s,f){try{var g=s.updateQueue,x=g!==null?g.lastEffect:null;if(x!==null){var S=x.next;g=S;do{if((g.tag&o)===o){var T=g.inst,_=T.destroy;if(_!==void 0){T.destroy=void 0,x=s;var B=f,Y=_;try{Y()}catch(oe){ut(x,B,oe)}}}g=g.next}while(g!==S)}}catch(oe){ut(s,s.return,oe)}}function OA(o){var s=o.updateQueue;if(s!==null){var f=o.stateNode;try{xk(s,f)}catch(g){ut(o,o.return,g)}}}function RA(o,s,f){f.props=wl(o.type,o.memoizedProps),f.state=o.memoizedState;try{f.componentWillUnmount()}catch(g){ut(o,s,g)}}function wc(o,s){try{var f=o.ref;if(f!==null){switch(o.tag){case 26:case 27:case 5:var g=o.stateNode;break;case 30:g=o.stateNode;break;default:g=o.stateNode}typeof f=="function"?o.refCleanup=f(g):f.current=g}}catch(x){ut(o,s,x)}}function Zi(o,s){var f=o.ref,g=o.refCleanup;if(f!==null)if(typeof g=="function")try{g()}catch(x){ut(o,s,x)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(x){ut(o,s,x)}else f.current=null}function DA(o){var s=o.type,f=o.memoizedProps,g=o.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":f.autoFocus&&g.focus();break e;case"img":f.src?g.src=f.src:f.srcSet&&(g.srcset=f.srcSet)}}catch(x){ut(o,o.return,x)}}function Lv(o,s,f){try{var g=o.stateNode;g9(g,o.type,f,s),g[ur]=s}catch(x){ut(o,o.return,x)}}function _A(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&Mo(o.type)||o.tag===4}function Bv(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||_A(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&Mo(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Fv(o,s,f){var g=o.tag;if(g===5||g===6)o=o.stateNode,s?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(o,s):(s=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,s.appendChild(o),f=f._reactRootContainer,f!=null||s.onclick!==null||(s.onclick=va));else if(g!==4&&(g===27&&Mo(o.type)&&(f=o.stateNode,s=null),o=o.child,o!==null))for(Fv(o,s,f),o=o.sibling;o!==null;)Fv(o,s,f),o=o.sibling}function bh(o,s,f){var g=o.tag;if(g===5||g===6)o=o.stateNode,s?f.insertBefore(o,s):f.appendChild(o);else if(g!==4&&(g===27&&Mo(o.type)&&(f=o.stateNode),o=o.child,o!==null))for(bh(o,s,f),o=o.sibling;o!==null;)bh(o,s,f),o=o.sibling}function MA(o){var s=o.stateNode,f=o.memoizedProps;try{for(var g=o.type,x=s.attributes;x.length;)s.removeAttributeNode(x[0]);Mn(s,g,f),s[On]=o,s[ur]=f}catch(S){ut(o,o.return,S)}}var Ta=!1,Zt=!1,$v=!1,PA=typeof WeakSet=="function"?WeakSet:Set,yn=null;function YF(o,s){if(o=o.containerInfo,s0=$h,o=WC(o),Py(o)){if("selectionStart"in o)var f={start:o.selectionStart,end:o.selectionEnd};else e:{f=(f=o.ownerDocument)&&f.defaultView||window;var g=f.getSelection&&f.getSelection();if(g&&g.rangeCount!==0){f=g.anchorNode;var x=g.anchorOffset,S=g.focusNode;g=g.focusOffset;try{f.nodeType,S.nodeType}catch{f=null;break e}var T=0,_=-1,B=-1,Y=0,oe=0,se=o,X=null;t:for(;;){for(var ee;se!==f||x!==0&&se.nodeType!==3||(_=T+x),se!==S||g!==0&&se.nodeType!==3||(B=T+g),se.nodeType===3&&(T+=se.nodeValue.length),(ee=se.firstChild)!==null;)X=se,se=ee;for(;;){if(se===o)break t;if(X===f&&++Y===x&&(_=T),X===S&&++oe===g&&(B=T),(ee=se.nextSibling)!==null)break;se=X,X=se.parentNode}se=ee}f=_===-1||B===-1?null:{start:_,end:B}}else f=null}f=f||{start:0,end:0}}else f=null;for(u0={focusedElem:o,selectionRange:f},$h=!1,yn=s;yn!==null;)if(s=yn,o=s.child,(s.subtreeFlags&1028)!==0&&o!==null)o.return=s,yn=o;else for(;yn!==null;){switch(s=yn,S=s.alternate,o=s.flags,s.tag){case 0:if((o&4)!==0&&(o=s.updateQueue,o=o!==null?o.events:null,o!==null))for(f=0;f title"))),Mn(S,g,f),S[On]=o,gn(S),g=S;break e;case"link":var T=FE("link","href",x).get(g+(f.href||""));if(T){for(var _=0;_mt&&(T=mt,mt=Ne,Ne=T);var q=HC(_,Ne),V=HC(_,mt);if(q&&V&&(ee.rangeCount!==1||ee.anchorNode!==q.node||ee.anchorOffset!==q.offset||ee.focusNode!==V.node||ee.focusOffset!==V.offset)){var K=se.createRange();K.setStart(q.node,q.offset),ee.removeAllRanges(),Ne>mt?(ee.addRange(K),ee.extend(V.node,V.offset)):(K.setEnd(V.node,V.offset),ee.addRange(K))}}}}for(se=[],ee=_;ee=ee.parentNode;)ee.nodeType===1&&se.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_f?32:f,U.T=null,f=Kv,Kv=null;var S=Ro,T=Ma;if(rn=0,Ms=Ro=null,Ma=0,(rt&6)!==0)throw Error(r(331));var _=rt;if(rt|=4,qA(S.current),UA(S,S.current,T,f),rt=_,Ec(0,!1),Bt&&typeof Bt.onPostCommitFiberRoot=="function")try{Bt.onPostCommitFiberRoot(Tn,S)}catch{}return!0}finally{W.p=x,U.T=g,uE(o,s)}}function dE(o,s,f){s=ni(f,s),s=Ev(o.stateNode,s,2),o=jo(o,s,2),o!==null&&(Xr(o,2),Qi(o))}function ut(o,s,f){if(o.tag===3)dE(o,o,f);else for(;s!==null;){if(s.tag===3){dE(s,o,f);break}else if(s.tag===1){var g=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Oo===null||!Oo.has(g))){o=ni(f,o),f=fA(2),g=jo(s,f,2),g!==null&&(hA(f,g,s,o),Xr(g,2),Qi(g));break}}s=s.return}}function Qv(o,s,f){var g=o.pingCache;if(g===null){g=o.pingCache=new QF;var x=new Set;g.set(s,x)}else x=g.get(s),x===void 0&&(x=new Set,g.set(s,x));x.has(f)||(Hv=!0,x.add(f),o=r9.bind(null,o,s,f),s.then(o,o))}function r9(o,s,f){var g=o.pingCache;g!==null&&g.delete(s),o.pingedLanes|=o.suspendedLanes&f,o.warmLanes&=~f,yt===o&&(Ye&f)===f&&(zt===4||zt===3&&(Ye&62914560)===Ye&&300>qe()-jh?(rt&2)===0&&Ps(o,0):qv|=f,_s===Ye&&(_s=0)),Qi(o)}function fE(o,s){s===0&&(s=Bn()),o=dl(o,s),o!==null&&(Xr(o,s),Qi(o))}function i9(o){var s=o.memoizedState,f=0;s!==null&&(f=s.retryLane),fE(o,f)}function a9(o,s){var f=0;switch(o.tag){case 31:case 13:var g=o.stateNode,x=o.memoizedState;x!==null&&(f=x.retryLane);break;case 19:g=o.stateNode;break;case 22:g=o.stateNode._retryCache;break;default:throw Error(r(314))}g!==null&&g.delete(s),fE(o,f)}function o9(o,s){return En(o,s)}var Rh=null,zs=null,Jv=!1,Dh=!1,e0=!1,_o=0;function Qi(o){o!==zs&&o.next===null&&(zs===null?Rh=zs=o:zs=zs.next=o),Dh=!0,Jv||(Jv=!0,s9())}function Ec(o,s){if(!e0&&Dh){e0=!0;do for(var f=!1,g=Rh;g!==null;){if(o!==0){var x=g.pendingLanes;if(x===0)var S=0;else{var T=g.suspendedLanes,_=g.pingedLanes;S=(1<<31-ot(42|o)+1)-1,S&=x&~(T&~_),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(f=!0,gE(g,S))}else S=Ye,S=mn(g,g===yt?S:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(S&3)===0||or(g,S)||(f=!0,gE(g,S));g=g.next}while(f);e0=!1}}function l9(){hE()}function hE(){Dh=Jv=!1;var o=0;_o!==0&&v9()&&(o=_o);for(var s=qe(),f=null,g=Rh;g!==null;){var x=g.next,S=pE(g,s);S===0?(g.next=null,f===null?Rh=x:f.next=x,x===null&&(zs=f)):(f=g,(o!==0||(S&3)!==0)&&(Dh=!0)),g=x}rn!==0&&rn!==5||Ec(o),_o!==0&&(_o=0)}function pE(o,s){for(var f=o.suspendedLanes,g=o.pingedLanes,x=o.expirationTimes,S=o.pendingLanes&-62914561;0_)break;var oe=B.transferSize,se=B.initiatorType;oe&&CE(se)&&(B=B.responseEnd,T+=oe*(B<_?1:(_-Y)/(B-Y)))}if(--g,s+=8*(S+T)/(x.duration/1e3),o++,10"u"?null:document;function zE(o,s,f){var g=Is;if(g&&typeof s=="string"&&s){var x=ei(s);x='link[rel="'+o+'"][href="'+x+'"]',typeof f=="string"&&(x+='[crossorigin="'+f+'"]'),NE.has(x)||(NE.add(x),o={rel:o,crossOrigin:f,href:s},g.querySelector(x)===null&&(s=g.createElement("link"),Mn(s,"link",o),gn(s),g.head.appendChild(s)))}}function E9(o){Pa.D(o),zE("dns-prefetch",o,null)}function T9(o,s){Pa.C(o,s),zE("preconnect",o,s)}function O9(o,s,f){Pa.L(o,s,f);var g=Is;if(g&&o&&s){var x='link[rel="preload"][as="'+ei(s)+'"]';s==="image"&&f&&f.imageSrcSet?(x+='[imagesrcset="'+ei(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(x+='[imagesizes="'+ei(f.imageSizes)+'"]')):x+='[href="'+ei(o)+'"]';var S=x;switch(s){case"style":S=Ls(o);break;case"script":S=Bs(o)}si.has(S)||(o=m({rel:"preload",href:s==="image"&&f&&f.imageSrcSet?void 0:o,as:s},f),si.set(S,o),g.querySelector(x)!==null||s==="style"&&g.querySelector(Dc(S))||s==="script"&&g.querySelector(_c(S))||(s=g.createElement("link"),Mn(s,"link",o),gn(s),g.head.appendChild(s)))}}function R9(o,s){Pa.m(o,s);var f=Is;if(f&&o){var g=s&&typeof s.as=="string"?s.as:"script",x='link[rel="modulepreload"][as="'+ei(g)+'"][href="'+ei(o)+'"]',S=x;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=Bs(o)}if(!si.has(S)&&(o=m({rel:"modulepreload",href:o},s),si.set(S,o),f.querySelector(x)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(_c(S)))return}g=f.createElement("link"),Mn(g,"link",o),gn(g),f.head.appendChild(g)}}}function D9(o,s,f){Pa.S(o,s,f);var g=Is;if(g&&o){var x=os(g).hoistableStyles,S=Ls(o);s=s||"default";var T=x.get(S);if(!T){var _={loading:0,preload:null};if(T=g.querySelector(Dc(S)))_.loading=5;else{o=m({rel:"stylesheet",href:o,"data-precedence":s},f),(f=si.get(S))&&g0(o,f);var B=T=g.createElement("link");gn(B),Mn(B,"link",o),B._p=new Promise(function(Y,oe){B.onload=Y,B.onerror=oe}),B.addEventListener("load",function(){_.loading|=1}),B.addEventListener("error",function(){_.loading|=2}),_.loading|=4,zh(T,s,g)}T={type:"stylesheet",instance:T,count:1,state:_},x.set(S,T)}}}function _9(o,s){Pa.X(o,s);var f=Is;if(f&&o){var g=os(f).hoistableScripts,x=Bs(o),S=g.get(x);S||(S=f.querySelector(_c(x)),S||(o=m({src:o,async:!0},s),(s=si.get(x))&&y0(o,s),S=f.createElement("script"),gn(S),Mn(S,"link",o),f.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},g.set(x,S))}}function M9(o,s){Pa.M(o,s);var f=Is;if(f&&o){var g=os(f).hoistableScripts,x=Bs(o),S=g.get(x);S||(S=f.querySelector(_c(x)),S||(o=m({src:o,async:!0,type:"module"},s),(s=si.get(x))&&y0(o,s),S=f.createElement("script"),gn(S),Mn(S,"link",o),f.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},g.set(x,S))}}function IE(o,s,f,g){var x=(x=ve.current)?Nh(x):null;if(!x)throw Error(r(446));switch(o){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(s=Ls(f.href),f=os(x).hoistableStyles,g=f.get(s),g||(g={type:"style",instance:null,count:0,state:null},f.set(s,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){o=Ls(f.href);var S=os(x).hoistableStyles,T=S.get(o);if(T||(x=x.ownerDocument||x,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(o,T),(S=x.querySelector(Dc(o)))&&!S._p&&(T.instance=S,T.state.loading=5),si.has(o)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},si.set(o,f),S||P9(x,o,f,T.state))),s&&g===null)throw Error(r(528,""));return T}if(s&&g!==null)throw Error(r(529,""));return null;case"script":return s=f.async,f=f.src,typeof f=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Bs(f),f=os(x).hoistableScripts,g=f.get(s),g||(g={type:"script",instance:null,count:0,state:null},f.set(s,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,o))}}function Ls(o){return'href="'+ei(o)+'"'}function Dc(o){return'link[rel="stylesheet"]['+o+"]"}function LE(o){return m({},o,{"data-precedence":o.precedence,precedence:null})}function P9(o,s,f,g){o.querySelector('link[rel="preload"][as="style"]['+s+"]")?g.loading=1:(s=o.createElement("link"),g.preload=s,s.addEventListener("load",function(){return g.loading|=1}),s.addEventListener("error",function(){return g.loading|=2}),Mn(s,"link",f),gn(s),o.head.appendChild(s))}function Bs(o){return'[src="'+ei(o)+'"]'}function _c(o){return"script[async]"+o}function BE(o,s,f){if(s.count++,s.instance===null)switch(s.type){case"style":var g=o.querySelector('style[data-href~="'+ei(f.href)+'"]');if(g)return s.instance=g,gn(g),g;var x=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return g=(o.ownerDocument||o).createElement("style"),gn(g),Mn(g,"style",x),zh(g,f.precedence,o),s.instance=g;case"stylesheet":x=Ls(f.href);var S=o.querySelector(Dc(x));if(S)return s.state.loading|=4,s.instance=S,gn(S),S;g=LE(f),(x=si.get(x))&&g0(g,x),S=(o.ownerDocument||o).createElement("link"),gn(S);var T=S;return T._p=new Promise(function(_,B){T.onload=_,T.onerror=B}),Mn(S,"link",g),s.state.loading|=4,zh(S,f.precedence,o),s.instance=S;case"script":return S=Bs(f.src),(x=o.querySelector(_c(S)))?(s.instance=x,gn(x),x):(g=f,(x=si.get(S))&&(g=m({},f),y0(g,x)),o=o.ownerDocument||o,x=o.createElement("script"),gn(x),Mn(x,"link",g),o.head.appendChild(x),s.instance=x);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(g=s.instance,s.state.loading|=4,zh(g,f.precedence,o));return s.instance}function zh(o,s,f){for(var g=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),x=g.length?g[g.length-1]:null,S=x,T=0;T title"):null)}function N9(o,s,f){if(f===1||s.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return o=s.disabled,typeof s.precedence=="string"&&o==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function UE(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function z9(o,s,f,g){if(f.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var x=Ls(g.href),S=s.querySelector(Dc(x));if(S){s=S._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(o.count++,o=Lh.bind(o),s.then(o,o)),f.state.loading|=4,f.instance=S,gn(S);return}S=s.ownerDocument||s,g=LE(g),(x=si.get(x))&&g0(g,x),S=S.createElement("link"),gn(S);var T=S;T._p=new Promise(function(_,B){T.onload=_,T.onerror=B}),Mn(S,"link",g),f.instance=S}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(f,s),(s=f.state.preload)&&(f.state.loading&3)===0&&(o.count++,f=Lh.bind(o),s.addEventListener("load",f),s.addEventListener("error",f))}}var v0=0;function I9(o,s){return o.stylesheets&&o.count===0&&Fh(o,o.stylesheets),0v0?50:800)+s);return o.unsuspend=f,function(){o.unsuspend=null,clearTimeout(g),clearTimeout(x)}}:null}function Lh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fh(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var Bh=null;function Fh(o,s){o.stylesheets=null,o.unsuspend!==null&&(o.count++,Bh=new Map,s.forEach(L9,o),Bh=null,Lh.call(o))}function L9(o,s){if(!(s.state.loading&4)){var f=Bh.get(o);if(f)var g=f.get(null);else{f=new Map,Bh.set(o,f);for(var x=o.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),E0.exports=t$(),E0.exports}var r$=n$();const i$=wi(r$);var fT="popstate";function a$(e={}){function t(r,i){let{pathname:a,search:l,hash:u}=r.location;return a1("",{pathname:a,search:l,hash:u},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:xd(i)}return l$(t,n,null,e)}function _t(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function $r(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function o$(){return Math.random().toString(36).substring(2,10)}function hT(e,t){return{usr:e.state,key:e.key,idx:t}}function a1(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Au(t):t,state:n,key:t&&t.key||r||o$()}}function xd({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Au(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function l$(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,l=i.history,u="POP",c=null,d=h();d==null&&(d=0,l.replaceState({...l.state,idx:d},""));function h(){return(l.state||{idx:null}).idx}function m(){u="POP";let C=h(),k=C==null?null:C-d;d=C,c&&c({action:u,location:j.location,delta:k})}function y(C,k){u="PUSH";let E=a1(j.location,C,k);d=h()+1;let A=hT(E,d),R=j.createHref(E);try{l.pushState(A,"",R)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;i.location.assign(R)}a&&c&&c({action:u,location:j.location,delta:1})}function v(C,k){u="REPLACE";let E=a1(j.location,C,k);d=h();let A=hT(E,d),R=j.createHref(E);l.replaceState(A,"",R),a&&c&&c({action:u,location:j.location,delta:0})}function b(C){return s$(C)}let j={get action(){return u},get location(){return e(i,l)},listen(C){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(fT,m),c=C,()=>{i.removeEventListener(fT,m),c=null}},createHref(C){return t(i,C)},createURL:b,encodeLocation(C){let k=b(C);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:y,replace:v,go(C){return l.go(C)}};return j}function s$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),_t(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:xd(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function C5(e,t,n="/"){return u$(e,t,n,!1)}function u$(e,t,n,r){let i=typeof t=="string"?Au(t):t,a=qa(i.pathname||"/",n);if(a==null)return null;let l=k5(e);c$(l);let u=null;for(let c=0;u==null&&c{let h={relativePath:d===void 0?l.path||"":d,caseSensitive:l.caseSensitive===!0,childrenIndex:u,route:l};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&c)return;_t(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let m=Ua([r,h.relativePath]),y=n.concat(h);l.children&&l.children.length>0&&(_t(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),k5(l.children,t,y,m,c)),!(l.path==null&&!l.index)&&t.push({path:m,score:y$(m,l.index),routesMeta:y})};return e.forEach((l,u)=>{if(l.path===""||!l.path?.includes("?"))a(l,u);else for(let c of A5(l.path))a(l,u,!0,c)}),t}function A5(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let l=A5(r.join("/")),u=[];return u.push(...l.map(c=>c===""?a:[a,c].join("/"))),i&&u.push(...l),u.map(c=>e.startsWith("/")&&c===""?"/":c)}function c$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:v$(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var d$=/^:[\w-]+$/,f$=3,h$=2,p$=1,m$=10,g$=-2,pT=e=>e==="*";function y$(e,t){let n=e.split("/"),r=n.length;return n.some(pT)&&(r+=g$),t&&(r+=h$),n.filter(i=>!pT(i)).reduce((i,a)=>i+(d$.test(a)?f$:a===""?p$:m$),r)}function v$(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function x$(e,t,n=!1){let{routesMeta:r}=e,i={},a="/",l=[];for(let u=0;u{if(h==="*"){let b=u[y]||"";l=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const v=u[y];return m&&!v?d[h]=void 0:d[h]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function b$(e,t=!1,n=!0){$r(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,u,c)=>(r.push({paramName:u,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function w$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $r(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function qa(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var S$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,j$=e=>S$.test(e);function C$(e,t="/"){let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?Au(e):e,a;if(n)if(j$(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$r(!1,`Pathnames cannot have embedded double slashes - normalizing ${l} -> ${n}`)}n.startsWith("/")?a=mT(n.substring(1),"/"):a=mT(n,t)}else a=t;return{pathname:a,search:E$(r),hash:T$(i)}}function mT(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function D0(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function k$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function cS(e){let t=k$(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function dS(e,t,n,r=!1){let i;typeof e=="string"?i=Au(e):(i={...e},_t(!i.pathname||!i.pathname.includes("?"),D0("?","pathname","search",i)),_t(!i.pathname||!i.pathname.includes("#"),D0("#","pathname","hash",i)),_t(!i.search||!i.search.includes("#"),D0("#","search","hash",i)));let a=e===""||i.pathname==="",l=a?"/":i.pathname,u;if(l==null)u=n;else{let m=t.length-1;if(!r&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),m-=1;i.pathname=y.join("/")}u=m>=0?t[m]:"/"}let c=C$(i,u),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}var Ua=e=>e.join("/").replace(/\/\/+/g,"/"),A$=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),E$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,T$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function O$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var E5=["POST","PUT","PATCH","DELETE"];new Set(E5);var R$=["GET",...E5];new Set(R$);var Eu=w.createContext(null);Eu.displayName="DataRouter";var lg=w.createContext(null);lg.displayName="DataRouterState";w.createContext(!1);var T5=w.createContext({isTransitioning:!1});T5.displayName="ViewTransition";var D$=w.createContext(new Map);D$.displayName="Fetchers";var _$=w.createContext(null);_$.displayName="Await";var Hi=w.createContext(null);Hi.displayName="Navigation";var Yd=w.createContext(null);Yd.displayName="Location";var qi=w.createContext({outlet:null,matches:[],isDataRoute:!1});qi.displayName="Route";var fS=w.createContext(null);fS.displayName="RouteError";function M$(e,{relative:t}={}){_t(Tu(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=w.useContext(Hi),{hash:i,pathname:a,search:l}=Xd(e,{relative:t}),u=a;return n!=="/"&&(u=a==="/"?n:Ua([n,a])),r.createHref({pathname:u,search:l,hash:i})}function Tu(){return w.useContext(Yd)!=null}function qr(){return _t(Tu(),"useLocation() may be used only in the context of a component."),w.useContext(Yd).location}var O5="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function R5(e){w.useContext(Hi).static||w.useLayoutEffect(e)}function Ln(){let{isDataRoute:e}=w.useContext(qi);return e?W$():P$()}function P$(){_t(Tu(),"useNavigate() may be used only in the context of a component.");let e=w.useContext(Eu),{basename:t,navigator:n}=w.useContext(Hi),{matches:r}=w.useContext(qi),{pathname:i}=qr(),a=JSON.stringify(cS(r)),l=w.useRef(!1);return R5(()=>{l.current=!0}),w.useCallback((c,d={})=>{if($r(l.current,O5),!l.current)return;if(typeof c=="number"){n.go(c);return}let h=dS(c,JSON.parse(a),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:Ua([t,h.pathname])),(d.replace?n.replace:n.push)(h,d.state,d)},[t,n,a,i,e])}w.createContext(null);function io(){let{matches:e}=w.useContext(qi),t=e[e.length-1];return t?t.params:{}}function Xd(e,{relative:t}={}){let{matches:n}=w.useContext(qi),{pathname:r}=qr(),i=JSON.stringify(cS(n));return w.useMemo(()=>dS(e,JSON.parse(i),r,t==="path"),[e,i,r,t])}function N$(e,t){return D5(e,t)}function D5(e,t,n,r,i){_t(Tu(),"useRoutes() may be used only in the context of a component.");let{navigator:a}=w.useContext(Hi),{matches:l}=w.useContext(qi),u=l[l.length-1],c=u?u.params:{},d=u?u.pathname:"/",h=u?u.pathnameBase:"/",m=u&&u.route;{let E=m&&m.path||"";_5(d,!m||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${d}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. -Please change the parent to .`)}let y=$r(),v;if(t){let E=typeof t=="string"?ku(t):t;Et(h==="/"||E.pathname?.startsWith(h),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${E.pathname}" was given in the \`location\` prop.`),v=E}else v=y;let b=v.pathname||"/",j=b;if(h!=="/"){let E=h.replace(/^\//,"").split("/");j="/"+b.replace(/^\//,"").split("/").slice(E.length).join("/")}let C=C5(e,{pathname:j});Ir(m||C!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Ir(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let k=F$(C&&C.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:La([h,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?h:La([h,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,n,r,i);return t&&k?w.createElement(Yd.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},k):k}function z$(){let e=q$(),t=O$(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:a},"ErrorBoundary")," or"," ",w.createElement("code",{style:a},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},t),n?w.createElement("pre",{style:i},n):null,l)}var I$=w.createElement(z$,null),L$=class extends w.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?w.createElement(Li.Provider,{value:this.props.routeContext},w.createElement(fS.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function B$({routeContext:e,match:t,children:n}){let r=w.useContext(Au);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),w.createElement(Li.Provider,{value:e},n)}function F$(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,l=n?.errors;if(l!=null){let h=a.findIndex(m=>m.route.id&&l?.[m.route.id]!==void 0);Et(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),a=a.slice(0,Math.min(a.length,h+1))}let u=!1,c=-1;if(n)for(let h=0;h=0?a=a.slice(0,c+1):a=[a[0]];break}}}let d=n&&r?(h,m)=>{r(h,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:m})}:void 0;return a.reduceRight((h,m,y)=>{let v,b=!1,j=null,C=null;n&&(v=l&&m.route.id?l[m.route.id]:void 0,j=m.route.errorElement||I$,u&&(c<0&&y===0?(_5("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,C=null):c===y&&(b=!0,C=m.route.hydrateFallbackElement||null)));let k=t.concat(a.slice(0,y+1)),E=()=>{let A;return v?A=j:b?A=C:m.route.Component?A=w.createElement(m.route.Component,null):m.route.element?A=m.route.element:A=h,w.createElement(B$,{match:m,routeContext:{outlet:h,matches:k,isDataRoute:n!=null},children:A})};return n&&(m.route.ErrorBoundary||m.route.errorElement||y===0)?w.createElement(L$,{location:n.location,revalidation:n.revalidation,component:j,error:v,children:E(),routeContext:{outlet:null,matches:k,isDataRoute:!0},onError:d}):E()},null)}function hS(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $$(e){let t=w.useContext(Au);return Et(t,hS(e)),t}function U$(e){let t=w.useContext(lg);return Et(t,hS(e)),t}function V$(e){let t=w.useContext(Li);return Et(t,hS(e)),t}function pS(e){let t=V$(e),n=t.matches[t.matches.length-1];return Et(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function H$(){return pS("useRouteId")}function q$(){let e=w.useContext(fS),t=U$("useRouteError"),n=pS("useRouteError");return e!==void 0?e:t.errors?.[n]}function W$(){let{router:e}=$$("useNavigate"),t=pS("useNavigate"),n=w.useRef(!1);return R5(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Ir(n.current,O5),n.current&&(typeof i=="number"?e.navigate(i):await e.navigate(i,{fromRouteId:t,...a}))},[e,t])}var gT={};function _5(e,t,n){!t&&!gT[e]&&(gT[e]=!0,Ir(!1,n))}w.memo(G$);function G$({routes:e,future:t,state:n,unstable_onError:r}){return D5(e,void 0,n,r,t)}function K$({to:e,replace:t,state:n,relative:r}){Et(Eu()," may be used only in the context of a component.");let{static:i}=w.useContext(Ii);Ir(!i," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:a}=w.useContext(Li),{pathname:l}=$r(),u=_n(),c=dS(e,cS(a),l,r==="path"),d=JSON.stringify(c);return w.useEffect(()=>{u(JSON.parse(d),{replace:t,state:n,relative:r})},[u,d,r,t,n]),null}function Jt(e){Et(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Y$({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Et(!Eu(),"You cannot render a inside another . You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),u=w.useMemo(()=>({basename:l,navigator:i,static:a,future:{}}),[l,i,a]);typeof n=="string"&&(n=ku(n));let{pathname:c="/",search:d="",hash:h="",state:m=null,key:y="default"}=n,v=w.useMemo(()=>{let b=Ua(c,l);return b==null?null:{location:{pathname:b,search:d,hash:h,state:m,key:y},navigationType:r}},[l,c,d,h,m,y,r]);return Ir(v!=null,` is not able to match the URL "${c}${d}${h}" because it does not start with the basename, so the won't render anything.`),v==null?null:w.createElement(Ii.Provider,{value:u},w.createElement(Yd.Provider,{children:t,value:v}))}function X$({children:e,location:t}){return N$(o1(e),t)}function o1(e,t=[]){let n=[];return w.Children.forEach(e,(r,i)=>{if(!w.isValidElement(r))return;let a=[...t,i];if(r.type===w.Fragment){n.push.apply(n,o1(r.props.children,a));return}Et(r.type===Jt,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),Et(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=o1(r.props.children,a)),n.push(l)}),n}var Op="get",Rp="application/x-www-form-urlencoded";function sg(e){return e!=null&&typeof e.tagName=="string"}function Z$(e){return sg(e)&&e.tagName.toLowerCase()==="button"}function Q$(e){return sg(e)&&e.tagName.toLowerCase()==="form"}function J$(e){return sg(e)&&e.tagName.toLowerCase()==="input"}function eU(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function tU(e,t){return e.button===0&&(!t||t==="_self")&&!eU(e)}function l1(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function nU(e,t){let n=l1(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(a=>{n.append(i,a)})}),n}var Kh=null;function rU(){if(Kh===null)try{new FormData(document.createElement("form"),0),Kh=!1}catch{Kh=!0}return Kh}var iU=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function _0(e){return e!=null&&!iU.has(e)?(Ir(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Rp}"`),null):e}function aU(e,t){let n,r,i,a,l;if(Q$(e)){let u=e.getAttribute("action");r=u?Ua(u,t):null,n=e.getAttribute("method")||Op,i=_0(e.getAttribute("enctype"))||Rp,a=new FormData(e)}else if(Z$(e)||J$(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a + + + + +

+ Collection: {activeCollection.name} | Mode: owner-write-only +

+ + + +
+ + +

+ `userId` means the field in each document that stores the logged-in user's id. + Example: `posts.userId` or `orders.ownerId`. For the users collection, `_id` is usually the correct owner field. +

+

+ When RLS is enabled, publishable-key writes also require `Authorization: Bearer <user_jwt>`. +

+
+ +
+ + +
+ + + )} + ); -} \ No newline at end of file +} diff --git a/docs/api-reference.md b/docs/api-reference.md index 62321efe9..14e2d43c7 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -9,6 +9,7 @@ | **Data** | `GET` | `/api/data/:collectionName/:id` | Get document by ID | | **Data** | `POST` | `/api/data/:collectionName` | Insert new document | | **Data** | `PUT` | `/api/data/:collectionName/:id` | Update document by ID | +| **Data** | `PATCH` | `/api/data/:collectionName/:id` | Partially update document by ID | | **Data** | `DELETE` | `/api/data/:collectionName/:id` | Delete document by ID | | **Storage** | `POST` | `/api/storage/upload` | Upload a file | | **Storage** | `DELETE` | `/api/storage/file` | Delete a file by path | @@ -19,6 +20,6 @@ - `201 Created`: Document/User/File created successfully. - `400 Bad Request`: Validation failure or malformed JSON. - `401 Unauthorized`: Missing/Invalid API Key or expired JWT. -- `403 Forbidden`: Resource limit (Quota) exceeded. +- `403 Forbidden`: Resource limit (Quota) exceeded or blocked by RLS policy. - `404 Not Found`: Collection, document, or file does not exist. - `500 Server Error`: Unexpected problem on our end. diff --git a/docs/database.md b/docs/database.md index be89702cd..309b98f4d 100644 --- a/docs/database.md +++ b/docs/database.md @@ -13,6 +13,15 @@ Replace `:collectionName` with the name of your collection (e.g., `posts`, `comm **Endpoint**: `POST /api/data/:collectionName` +By default, write operations require your **secret key**. + +If you enable **RLS (owner-write-only)** for a collection from the dashboard, publishable-key writes are also allowed but must include a valid user token: + +- `x-api-key: pk_live_...` +- `Authorization: Bearer ` + +Under RLS, writes are permitted only for documents owned by the authenticated user (based on configured `ownerField`). + ```javascript await fetch('https://api.ub.bitbros.in/api/data/posts', { method: 'POST', @@ -51,6 +60,9 @@ await fetch(`https://api.ub.bitbros.in/api/data/posts/${postId}`, { }); ``` +### Partial Update +**Endpoint**: `PATCH /api/data/:collectionName/:id` + ## 4. Delete a Document **Endpoint**: `DELETE /api/data/:collectionName/:id` diff --git a/docs/getting-started.md b/docs/getting-started.md index c05aa7107..46f2e8e3c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -8,7 +8,7 @@ urBackend is built for speed and developer freedom. Whether you're using our man Head over to the [urBackend Dashboard](https://urbackend.bitbros.in) and create a new project. You'll instantly receive two keys: -- **Publishable Key (`pk_live_...`)**: Used for frontend requests (Read-Only). +- **Publishable Key (`pk_live_...`)**: Used for frontend-safe requests (Read by default; writes only when collection RLS is enabled and user Bearer token is provided). - **Secret Key (`sk_live_...`)**: Used for server-side or administrative actions (Full Access). ## 2. Your First Request @@ -19,7 +19,9 @@ To get started, navigate to the **Database** tab in your dashboard and click **" > **💡 Pro Tip**: You can define a detailed schema during creation, or simply create the collection and start POSTing arbitrary JSON right away—urBackend will handle the rest. -> **⚠️ Note**: Write operations (POST, PUT, DELETE) require your **Secret Key** and should only be performed from a secure backend environment, never from client-side code. +> **⚠️ Note**: Write operations (POST, PUT, PATCH, DELETE) require your **Secret Key** by default and should be performed from a secure backend environment. +> +> If you enable collection-level **RLS** in the dashboard, publishable-key writes are allowed with `Authorization: Bearer `, but only for the authenticated owner. ### Example: Storing a Product diff --git a/docs/rls-implementation-roadmap.md b/docs/rls-implementation-roadmap.md new file mode 100644 index 000000000..f12b94a21 --- /dev/null +++ b/docs/rls-implementation-roadmap.md @@ -0,0 +1,291 @@ +# RLS Implementation Roadmap (V1 -> Best Version) + +This roadmap explains how to implement Supabase-style Row Level Security (RLS) for `urBackend` in progressive versions. + +Goal: +- Allow **publishable key** to perform `POST/PUT/PATCH/DELETE` only when RLS policy permits. +- Keep **secret key** behavior unchanged (full admin bypass). +- Start simple, safe, low-latency in V1, then evolve to advanced policy engine. + +--- + +## 0) Current State (Baseline) + +Today in `public-api`: +- Read routes (`GET`) work with publishable key. +- Write routes (`POST/PUT/DELETE`) require secret key via `requireSecretKey`. +- No per-row policy evaluation on user identity. + +Implication: +- Public client apps cannot securely do user-scoped writes with publishable key. + +--- + +## 1) V1 (Recommended First Release) + +### 1.1 What V1 Will Support + +For each collection, enable an RLS mode: +- `owner-write-only` policy: + - Publishable key writes are allowed only if authenticated end-user is writing their own document. + - Ownership is checked by a configured field (e.g. `userId`, `ownerId`, `_id` for users collection). + +Write ops covered in V1: +- `POST` +- `PUT` +- `PATCH` +- `DELETE` + +Read behavior in V1: +- Keep existing behavior unchanged initially (to reduce risk). + +### 1.2 Data Model Changes + +Add RLS config to `Project` -> collection level. + +Suggested shape: +```js +collection.rls = { + enabled: Boolean, + mode: "owner-write-only", + ownerField: "userId", + requireAuthForWrite: true +} +``` + +Defaults: +- `enabled: false` for existing projects. +- No behavior change unless explicitly enabled. + +### 1.3 Request Context Changes (public-api) + +Add middleware to resolve end-user auth context for publishable key writes: +- Read `Authorization: Bearer `. +- Verify token using `project.jwtSecret`. +- Set `req.authUser = { userId, ...claims }`. + +Failure behavior: +- If collection RLS write requires auth and token missing/invalid -> `401`. + +### 1.4 Route Guard Changes + +In `apps/public-api/src/routes/data.js`: +- Replace hard `requireSecretKey` on write routes with new `authorizeWriteOperation`. + +`authorizeWriteOperation` logic: +- If key is secret -> allow. +- If key is publishable: + - Ensure collection exists. + - Ensure collection RLS enabled. + - Ensure user token valid. + - Evaluate owner policy for operation. + +### 1.5 Policy Evaluation Rules (V1) + +For `POST`: +- Incoming payload must set `ownerField` equal to `req.authUser.userId`. +- Optionally auto-inject ownerField server-side if missing. + +For `PUT/PATCH/DELETE`: +- Load target doc by id. +- Compare `doc[ownerField]` with `req.authUser.userId`. +- Permit only on match. + +### 1.6 Dashboard UI (V1) + +In web dashboard: +- Add collection-level RLS section: + - Enable/disable RLS toggle. + - Mode selector (only `owner-write-only` in V1). + - Owner field selector (from schema fields). + - Save config. + +UX defaults: +- If user enables RLS but ownerField invalid -> block save with clear error. + +### 1.7 Security Guarantees (V1) + +With publishable key: +- No write without valid user JWT. +- No cross-user writes if owner check fails. + +With secret key: +- Existing admin behavior preserved. + +### 1.8 Performance Impact (V1) + +Expected overhead: +- JWT verify: small (few ms typically). +- For update/delete: one document fetch for owner check. + +Mitigation: +- Keep logic in middleware + targeted DB fetch only for write ops. +- No extra overhead on read routes in V1. + +--- + +## 2) V1.1 Hardening + +After V1 stable: +- Add PATCH route support if not already present everywhere. +- Prevent owner field tampering on update: + - Ignore or reject attempts to change ownerField. +- Add explicit structured error codes: + - `RLS_NOT_ENABLED` + - `RLS_AUTH_REQUIRED` + - `RLS_OWNER_MISMATCH` + - `RLS_OWNER_FIELD_MISSING` +- Add audit logs for denied operations. + +--- + +## 3) V2 (Operation-wise Policies) + +Introduce per-operation allow rules: +```js +rls: { + enabled: true, + write: { + insert: { mode: "owner" }, + update: { mode: "owner" }, + delete: { mode: "owner" } + } +} +``` + +Benefits: +- Allow insert but block delete, etc. +- Better product control without full policy language complexity. + +--- + +## 4) V3 (Role-Based Rules) + +Add role-aware policy checks using JWT claims: +- Example: `admin`, `manager`, `user`. +- Rule examples: + - `admin` can update any doc. + - `user` only own docs. + +Policy shape can support: +```js +allowRoles: ["admin"] +fallbackMode: "owner" +``` + +--- + +## 5) V4 (Field-Level Controls) + +Support column-level restrictions: +- Publishable writes cannot modify protected fields (`role`, `plan`, `isAdmin`, etc). +- Allowlist/denylist by operation. + +Example: +```js +update: { + mode: "owner", + denyFields: ["role", "billingTier"] +} +``` + +--- + +## 6) V5 (Advanced Policy Engine / “Best Version”) + +Supabase-like expressive policy model: +- Separate policies for `select/insert/update/delete`. +- Boolean expressions on: + - `auth` claims + - `doc` fields + - request payload + - optional org/team context + +Examples: +- `auth.userId == doc.ownerId` +- `auth.orgId == doc.orgId && auth.role in ["admin","editor"]` +- `request.data.status != "archived"` + +Implementation approach: +- Build safe expression evaluator (no raw `eval`). +- Precompile policy AST and cache per collection. + +--- + +## 7) Migration Strategy + +### Existing projects +- All existing collections default to `rls.enabled = false`. +- No breaking behavior after deploy. + +### Opt-in rollout +- Users explicitly enable RLS per collection. +- Show warning banner before enable: + - “Publishable key writes will require user auth token.” + +### Backward compatibility +- Secret key flows unchanged in all versions. + +--- + +## 8) Testing Strategy + +### Unit tests +- Middleware token parsing/validation. +- Policy evaluator outcomes for all branches. + +### Integration tests +- Publishable + no token -> denied write. +- Publishable + wrong owner token -> denied write. +- Publishable + correct owner token -> allowed. +- Secret key write -> allowed. + +### Regression checks +- Existing dashboard admin flows unaffected. +- Read endpoints unaffected in V1. + +--- + +## 9) Observability & Ops + +Add metrics counters: +- `rls_allowed_total` +- `rls_denied_total` +- denied reason tags (`owner_mismatch`, `token_missing`, etc.) + +Add request logs for denied writes with: +- project id +- collection +- operation +- denial reason + +--- + +## 10) Recommended Execution Order + +1. V1 backend model + middleware + route guard + controller checks. +2. V1 dashboard toggle/settings UI. +3. Tests + staged rollout on a few projects. +4. V1.1 hardening. +5. V2/V3/V4 in small increments. +6. V5 advanced policy engine when product demand is clear. + +--- + +## 11) Non-Goals for V1 + +To keep V1 low-risk: +- No complex expression parser. +- No read-side row filtering yet. +- No multi-policy conflict resolution engine. + +--- + +## 12) Success Criteria + +V1 is successful when: +- Publishable key can do write ops securely for authenticated owner only. +- Secret key behavior remains fully compatible. +- P95 latency impact stays low and predictable. +- Dashboard UX clearly communicates why a write is denied. + diff --git a/packages/common/src/models/Project.js b/packages/common/src/models/Project.js index 4afd7a2c7..58ea46605 100644 --- a/packages/common/src/models/Project.js +++ b/packages/common/src/models/Project.js @@ -25,7 +25,17 @@ fieldSchema.add({ fields: [fieldSchema] }); const collectionSchema = new mongoose.Schema({ name: { type: String, required: true }, - model: [fieldSchema] + model: [fieldSchema], + rls: { + enabled: { type: Boolean, default: false }, + mode: { + type: String, + enum: ['owner-write-only'], + default: 'owner-write-only' + }, + ownerField: { type: String, default: 'userId' }, + requireAuthForWrite: { type: Boolean, default: true } + } }); const projectSchema = new mongoose.Schema({ @@ -81,4 +91,4 @@ const projectSchema = new mongoose.Schema({ projectSchema.index({ owner: 1 }); -module.exports = mongoose.model('Project', projectSchema); \ No newline at end of file +module.exports = mongoose.model('Project', projectSchema);