@suveren/gateway 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control-plane/index.mjs +182 -37
- package/dist/mcp-server/http.mjs +356 -72
- package/dist/ui/assets/index-CO-dj98E.js +123 -0
- package/dist/ui/assets/index-DM9WXky8.css +1 -0
- package/dist/ui/index.html +2 -2
- package/node_modules/@hap/core/README.md +3 -3
- package/node_modules/@hap/core/dist/index.d.mts +567 -123
- package/node_modules/@hap/core/dist/index.d.ts +567 -123
- package/node_modules/@hap/core/dist/index.js +869 -23
- package/node_modules/@hap/core/dist/index.mjs +829 -22
- package/node_modules/@hap/core/node_modules/@hpke/core/LICENSE +21 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/README.md +263 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.js +167 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.js +56 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.js +326 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.js +68 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.js +62 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.js +112 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.js +28 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.js +235 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.js +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.js +45 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/package.json +46 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.js +47 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.js +183 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.js +70 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.js +340 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.js +82 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.js +78 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.js +128 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.js +42 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.js +255 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.js +52 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.js +59 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.js +19 -0
- package/node_modules/@hap/core/package.json +2 -1
- package/node_modules/@hap/core/src/canonicalize.ts +9 -0
- package/node_modules/@hap/core/src/commitment-modes.ts +21 -9
- package/node_modules/@hap/core/src/errors.ts +24 -8
- package/node_modules/@hap/core/src/gatekeeper.ts +52 -8
- package/node_modules/@hap/core/src/index.ts +5 -1
- package/node_modules/@hap/core/src/issuance.ts +250 -0
- package/node_modules/@hap/core/src/mandate.ts +52 -14
- package/node_modules/@hap/core/src/owner-signature.ts +86 -39
- package/node_modules/@hap/core/src/profile.ts +45 -0
- package/node_modules/@hap/core/src/proposal-content.ts +219 -0
- package/node_modules/@hap/core/src/ticket-projection.ts +167 -0
- package/node_modules/@hap/core/src/ticket.ts +254 -20
- package/node_modules/@hap/core/src/types.ts +33 -5
- package/node_modules/@hap/core/src/verifier-policy.ts +178 -0
- package/node_modules/@hap/core/src/versions.ts +50 -19
- package/node_modules/@hono/node-server/dist/index.cjs +31 -6
- package/node_modules/@hono/node-server/dist/index.mjs +31 -6
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@hpke/common/esm/package.json +5 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.js +41 -26
- package/node_modules/@hpke/common/esm/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.js +14 -3
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/misc.js +43 -10
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.js +21 -10
- package/node_modules/@hpke/common/package.json +5 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.js +40 -25
- package/node_modules/@hpke/common/script/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.js +13 -2
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/misc.js +43 -9
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.js +22 -11
- package/node_modules/@hpke/core/README.md +56 -56
- package/node_modules/@hpke/core/esm/package.json +2 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.js +216 -0
- package/node_modules/@hpke/core/package.json +6 -2
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.js +230 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +752 -0
- package/node_modules/encodeurl/README.md +14 -0
- package/node_modules/encodeurl/index.js +5 -10
- package/node_modules/encodeurl/package.json +10 -6
- package/node_modules/express-rate-limit/dist/index.cjs +7 -3
- package/node_modules/express-rate-limit/dist/index.mjs +7 -3
- package/node_modules/express-rate-limit/package.json +10 -10
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +1 -5
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/hono/README.md +2 -3
- package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +1 -1
- package/node_modules/hono/dist/cjs/helper/css/common.js +11 -8
- package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
- package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
- package/node_modules/hono/dist/cjs/hono-base.js +4 -10
- package/node_modules/hono/dist/cjs/hono.js +0 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
- package/node_modules/hono/dist/cjs/utils/url.js +21 -6
- package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
- package/node_modules/hono/dist/context.js +1 -1
- package/node_modules/hono/dist/helper/css/common.js +11 -8
- package/node_modules/hono/dist/helper/css/index.js +1 -1
- package/node_modules/hono/dist/helper/route/index.js +3 -1
- package/node_modules/hono/dist/hono-base.js +4 -10
- package/node_modules/hono/dist/hono.js +0 -1
- package/node_modules/hono/dist/jsx/base.js +1 -1
- package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/middleware/language/language.js +1 -1
- package/node_modules/hono/dist/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
- package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +21 -9
- package/node_modules/hono/dist/types/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
- package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/utils/mount.js +34 -0
- package/node_modules/hono/dist/utils/url.js +21 -7
- package/node_modules/hono/dist/validator/validator.js +1 -1
- package/node_modules/hono/package.json +1 -1
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body.js +2 -2
- package/node_modules/http-proxy-middleware/package.json +1 -1
- package/node_modules/ip-address/README.md +39 -39
- package/node_modules/ip-address/dist/common.js +2 -2
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.js +1 -1
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -2
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
- package/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
- package/node_modules/jose/dist/types/types.d.ts +8 -0
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
- package/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
- package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/postcss/lib/input.js +1 -1
- package/node_modules/postcss/lib/lazy-result.js +1 -1
- package/node_modules/postcss/lib/no-work-result.js +1 -1
- package/node_modules/postcss/lib/node.js +2 -2
- package/node_modules/postcss/lib/processor.js +1 -1
- package/node_modules/postcss/lib/warning.js +1 -0
- package/node_modules/postcss/package.json +1 -1
- package/node_modules/qs/CHANGELOG.md +29 -22
- package/node_modules/qs/dist/qs.js +14 -14
- package/node_modules/qs/eslint.config.mjs +6 -0
- package/node_modules/qs/lib/stringify.js +1 -1
- package/node_modules/qs/package.json +5 -5
- package/node_modules/qs/test/stringify.js +74 -0
- package/node_modules/zod/README.md +34 -24
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +22 -3
- package/node_modules/zod/index.d.cts +3 -4
- package/node_modules/zod/index.d.ts +3 -4
- package/node_modules/zod/index.js +7 -4
- package/node_modules/zod/locales/index.cjs +36 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +51 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +44 -15
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +7 -4
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +23 -13
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/complex.test.ts +17 -3
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +7 -3
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/nan.test.ts +5 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +10 -13
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +8 -2
- package/node_modules/zod/src/v3/types.ts +8 -6
- package/node_modules/zod/src/v4/classic/checks.ts +3 -0
- package/node_modules/zod/src/v4/classic/compat.ts +30 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +61 -39
- package/node_modules/zod/src/v4/classic/external.ts +18 -11
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +944 -0
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +57 -2
- package/node_modules/zod/src/v4/classic/schemas.ts +1258 -375
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +86 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +35 -8
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +192 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +43 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +357 -5
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +572 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +704 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +27 -5
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +67 -6
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +37 -17
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +142 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +221 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +333 -10
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +394 -4
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +9 -4
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +4 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +1467 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +160 -37
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +67 -0
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +134 -5
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +93 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +168 -5
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +4 -3
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +37 -1
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +153 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +15 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +161 -7
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +457 -14
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +255 -12
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +350 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +89 -5
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +25 -5
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +107 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +74 -21
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +1 -69
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +553 -10
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +352 -1
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +229 -68
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +40 -1
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +20 -3
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +16 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +568 -9
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +58 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +70 -16
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3409 -990
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +128 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +353 -5
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +219 -3
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +442 -161
- package/node_modules/zod/src/v4/core/checks.ts +134 -151
- package/node_modules/zod/src/v4/core/compile.ts +2322 -0
- package/node_modules/zod/src/v4/core/core.ts +146 -50
- package/node_modules/zod/src/v4/core/doc.ts +18 -10
- package/node_modules/zod/src/v4/core/errors.ts +221 -102
- package/node_modules/zod/src/v4/core/index.ts +5 -1
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +131 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +934 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +9 -4
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +252 -37
- package/node_modules/zod/src/v4/core/regexes.ts +112 -30
- package/node_modules/zod/src/v4/core/registries.ts +19 -10
- package/node_modules/zod/src/v4/core/schemas.ts +1972 -588
- package/node_modules/zod/src/v4/core/standard-schema.ts +114 -19
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +214 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +1 -1
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +180 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +2 -2
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +706 -826
- package/node_modules/zod/src/v4/core/util.ts +675 -157
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +22 -27
- package/node_modules/zod/src/v4/locales/az.ts +22 -27
- package/node_modules/zod/src/v4/locales/be.ts +31 -27
- package/node_modules/zod/src/v4/locales/bg.ts +133 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +22 -28
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +26 -45
- package/node_modules/zod/src/v4/locales/da.ts +128 -0
- package/node_modules/zod/src/v4/locales/de.ts +24 -27
- package/node_modules/zod/src/v4/locales/el.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +38 -29
- package/node_modules/zod/src/v4/locales/eo.ts +25 -27
- package/node_modules/zod/src/v4/locales/es.ts +53 -33
- package/node_modules/zod/src/v4/locales/fa.ts +24 -27
- package/node_modules/zod/src/v4/locales/fi.ts +22 -27
- package/node_modules/zod/src/v4/locales/fr-CA.ts +22 -27
- package/node_modules/zod/src/v4/locales/fr.ts +58 -43
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +208 -80
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +135 -0
- package/node_modules/zod/src/v4/locales/hu.ts +24 -28
- package/node_modules/zod/src/v4/locales/hy.ts +175 -0
- package/node_modules/zod/src/v4/locales/id.ts +22 -27
- package/node_modules/zod/src/v4/locales/index.ts +24 -0
- package/node_modules/zod/src/v4/locales/is.ts +124 -0
- package/node_modules/zod/src/v4/locales/it.ts +24 -28
- package/node_modules/zod/src/v4/locales/ja.ts +24 -27
- package/node_modules/zod/src/v4/locales/ka.ts +128 -0
- package/node_modules/zod/src/v4/locales/kh.ts +3 -122
- package/node_modules/zod/src/v4/locales/km.ts +124 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +22 -27
- package/node_modules/zod/src/v4/locales/lt.ts +243 -0
- package/node_modules/zod/src/v4/locales/mk.ts +24 -28
- package/node_modules/zod/src/v4/locales/ms.ts +23 -27
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +37 -37
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +26 -29
- package/node_modules/zod/src/v4/locales/ota.ts +25 -28
- package/node_modules/zod/src/v4/locales/pl.ts +24 -27
- package/node_modules/zod/src/v4/locales/ps.ts +24 -26
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +107 -71
- package/node_modules/zod/src/v4/locales/ro.ts +132 -0
- package/node_modules/zod/src/v4/locales/ru.ts +31 -27
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +24 -27
- package/node_modules/zod/src/v4/locales/sv.ts +26 -29
- package/node_modules/zod/src/v4/locales/ta.ts +25 -27
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +25 -27
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +22 -27
- package/node_modules/zod/src/v4/locales/ua.ts +3 -122
- package/node_modules/zod/src/v4/locales/uk.ts +122 -0
- package/node_modules/zod/src/v4/locales/ur.ts +25 -27
- package/node_modules/zod/src/v4/locales/uz.ts +120 -0
- package/node_modules/zod/src/v4/locales/vi.ts +24 -27
- package/node_modules/zod/src/v4/locales/yo.ts +129 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +25 -27
- package/node_modules/zod/src/v4/locales/zh-TW.ts +22 -27
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +5 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +15 -3
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/iso.ts +8 -4
- package/node_modules/zod/src/v4/mini/parse.ts +16 -1
- package/node_modules/zod/src/v4/mini/schemas.ts +586 -114
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +57 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +63 -2
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +582 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +12 -18
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +24 -5
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +7 -36
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +281 -6
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +15 -1
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +116 -9
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +1 -1
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +68 -2
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +98 -1
- package/node_modules/zod/src/v4-mini/index.ts +3 -1
- package/node_modules/zod/v3/ZodError.cjs +42 -13
- package/node_modules/zod/v3/ZodError.d.cts +6 -6
- package/node_modules/zod/v3/ZodError.d.ts +6 -6
- package/node_modules/zod/v3/ZodError.js +23 -13
- package/node_modules/zod/v3/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/locales/en.cjs +1 -0
- package/node_modules/zod/v3/locales/en.d.cts +1 -1
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +28 -5
- package/node_modules/zod/v3/types.d.cts +4 -1
- package/node_modules/zod/v3/types.d.ts +4 -1
- package/node_modules/zod/v3/types.js +9 -5
- package/node_modules/zod/v4/classic/checks.cjs +22 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +24 -1
- package/node_modules/zod/v4/classic/compat.d.cts +13 -11
- package/node_modules/zod/v4/classic/compat.d.ts +13 -11
- package/node_modules/zod/v4/classic/compat.js +4 -0
- package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +63 -28
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +45 -29
- package/node_modules/zod/v4/classic/external.cjs +55 -28
- package/node_modules/zod/v4/classic/external.d.cts +8 -2
- package/node_modules/zod/v4/classic/external.d.ts +8 -2
- package/node_modules/zod/v4/classic/external.js +7 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +926 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +32 -1
- package/node_modules/zod/v4/classic/parse.d.cts +21 -0
- package/node_modules/zod/v4/classic/parse.d.ts +21 -0
- package/node_modules/zod/v4/classic/parse.js +10 -0
- package/node_modules/zod/v4/classic/schemas.cjs +805 -238
- package/node_modules/zod/v4/classic/schemas.d.cts +241 -55
- package/node_modules/zod/v4/classic/schemas.d.ts +241 -55
- package/node_modules/zod/v4/classic/schemas.js +766 -237
- package/node_modules/zod/v4/core/api.cjs +284 -54
- package/node_modules/zod/v4/core/api.d.cts +133 -82
- package/node_modules/zod/v4/core/api.d.ts +133 -82
- package/node_modules/zod/v4/core/api.js +255 -54
- package/node_modules/zod/v4/core/checks.cjs +100 -130
- package/node_modules/zod/v4/core/checks.d.cts +32 -16
- package/node_modules/zod/v4/core/checks.d.ts +32 -16
- package/node_modules/zod/v4/core/checks.js +80 -129
- package/node_modules/zod/v4/core/compile.cjs +1916 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1866 -0
- package/node_modules/zod/v4/core/core.cjs +120 -20
- package/node_modules/zod/v4/core/core.d.cts +40 -7
- package/node_modules/zod/v4/core/core.d.ts +40 -7
- package/node_modules/zod/v4/core/core.js +101 -21
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- package/node_modules/zod/v4/core/doc.d.cts +4 -2
- package/node_modules/zod/v4/core/doc.d.ts +4 -2
- package/node_modules/zod/v4/core/doc.js +12 -9
- package/node_modules/zod/v4/core/errors.cjs +151 -60
- package/node_modules/zod/v4/core/errors.d.cts +41 -24
- package/node_modules/zod/v4/core/errors.d.ts +41 -24
- package/node_modules/zod/v4/core/errors.js +132 -60
- package/node_modules/zod/v4/core/index.cjs +28 -2
- package/node_modules/zod/v4/core/index.d.cts +5 -1
- package/node_modules/zod/v4/core/index.d.ts +5 -1
- package/node_modules/zod/v4/core/index.js +5 -1
- package/node_modules/zod/v4/core/json-schema-generator.cjs +122 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +929 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +6 -4
- package/node_modules/zod/v4/core/json-schema.d.ts +6 -4
- package/node_modules/zod/v4/core/memoizer.cjs +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +183 -37
- package/node_modules/zod/v4/core/parse.d.cts +34 -7
- package/node_modules/zod/v4/core/parse.d.ts +34 -7
- package/node_modules/zod/v4/core/parse.js +154 -36
- package/node_modules/zod/v4/core/regexes.cjs +137 -31
- package/node_modules/zod/v4/core/regexes.d.cts +30 -2
- package/node_modules/zod/v4/core/regexes.d.ts +30 -2
- package/node_modules/zod/v4/core/regexes.js +90 -29
- package/node_modules/zod/v4/core/registries.cjs +26 -7
- package/node_modules/zod/v4/core/registries.d.cts +2 -2
- package/node_modules/zod/v4/core/registries.d.ts +2 -2
- package/node_modules/zod/v4/core/registries.js +9 -9
- package/node_modules/zod/v4/core/schemas.cjs +1373 -422
- package/node_modules/zod/v4/core/schemas.d.cts +276 -42
- package/node_modules/zod/v4/core/schemas.d.ts +276 -42
- package/node_modules/zod/v4/core/schemas.js +1341 -422
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +90 -19
- package/node_modules/zod/v4/core/standard-schema.d.ts +90 -19
- package/node_modules/zod/v4/core/to-json-schema.cjs +628 -801
- package/node_modules/zod/v4/core/to-json-schema.d.cts +103 -37
- package/node_modules/zod/v4/core/to-json-schema.d.ts +103 -37
- package/node_modules/zod/v4/core/to-json-schema.js +602 -800
- package/node_modules/zod/v4/core/util.cjs +580 -155
- package/node_modules/zod/v4/core/util.d.cts +98 -1
- package/node_modules/zod/v4/core/util.d.ts +98 -1
- package/node_modules/zod/v4/core/util.js +536 -156
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +20 -24
- package/node_modules/zod/v4/locales/ar.d.cts +2 -1
- package/node_modules/zod/v4/locales/ar.js +19 -24
- package/node_modules/zod/v4/locales/az.cjs +20 -24
- package/node_modules/zod/v4/locales/az.d.cts +2 -1
- package/node_modules/zod/v4/locales/az.js +19 -24
- package/node_modules/zod/v4/locales/be.cjs +29 -24
- package/node_modules/zod/v4/locales/be.d.cts +2 -1
- package/node_modules/zod/v4/locales/be.js +28 -24
- package/node_modules/zod/v4/locales/bg.cjs +152 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +125 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +20 -25
- package/node_modules/zod/v4/locales/ca.d.cts +2 -1
- package/node_modules/zod/v4/locales/ca.js +19 -25
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +24 -42
- package/node_modules/zod/v4/locales/cs.d.cts +2 -1
- package/node_modules/zod/v4/locales/cs.js +23 -42
- package/node_modules/zod/v4/locales/da.cjs +147 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +120 -0
- package/node_modules/zod/v4/locales/de.cjs +22 -24
- package/node_modules/zod/v4/locales/de.d.cts +2 -1
- package/node_modules/zod/v4/locales/de.js +21 -24
- package/node_modules/zod/v4/locales/el.cjs +139 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +112 -0
- package/node_modules/zod/v4/locales/en.cjs +35 -28
- package/node_modules/zod/v4/locales/en.d.cts +2 -2
- package/node_modules/zod/v4/locales/en.d.ts +0 -1
- package/node_modules/zod/v4/locales/en.js +34 -26
- package/node_modules/zod/v4/locales/eo.cjs +23 -26
- package/node_modules/zod/v4/locales/eo.d.cts +2 -2
- package/node_modules/zod/v4/locales/eo.d.ts +0 -1
- package/node_modules/zod/v4/locales/eo.js +22 -24
- package/node_modules/zod/v4/locales/es.cjs +51 -31
- package/node_modules/zod/v4/locales/es.d.cts +2 -1
- package/node_modules/zod/v4/locales/es.js +50 -31
- package/node_modules/zod/v4/locales/fa.cjs +22 -24
- package/node_modules/zod/v4/locales/fa.d.cts +2 -1
- package/node_modules/zod/v4/locales/fa.js +21 -24
- package/node_modules/zod/v4/locales/fi.cjs +20 -24
- package/node_modules/zod/v4/locales/fi.d.cts +2 -1
- package/node_modules/zod/v4/locales/fi.js +19 -24
- package/node_modules/zod/v4/locales/fr-CA.cjs +20 -24
- package/node_modules/zod/v4/locales/fr-CA.d.cts +2 -1
- package/node_modules/zod/v4/locales/fr-CA.js +19 -24
- package/node_modules/zod/v4/locales/fr.cjs +53 -39
- package/node_modules/zod/v4/locales/fr.d.cts +2 -1
- package/node_modules/zod/v4/locales/fr.js +52 -39
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +183 -78
- package/node_modules/zod/v4/locales/he.d.cts +2 -1
- package/node_modules/zod/v4/locales/he.js +182 -78
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +153 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +126 -0
- package/node_modules/zod/v4/locales/hu.cjs +22 -25
- package/node_modules/zod/v4/locales/hu.d.cts +2 -1
- package/node_modules/zod/v4/locales/hu.js +21 -25
- package/node_modules/zod/v4/locales/hy.cjs +185 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +158 -0
- package/node_modules/zod/v4/locales/id.cjs +20 -24
- package/node_modules/zod/v4/locales/id.d.cts +2 -1
- package/node_modules/zod/v4/locales/id.js +19 -24
- package/node_modules/zod/v4/locales/index.cjs +69 -1
- package/node_modules/zod/v4/locales/index.d.cts +24 -0
- package/node_modules/zod/v4/locales/index.d.ts +24 -0
- package/node_modules/zod/v4/locales/index.js +24 -0
- package/node_modules/zod/v4/locales/is.cjs +141 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +114 -0
- package/node_modules/zod/v4/locales/it.cjs +22 -25
- package/node_modules/zod/v4/locales/it.d.cts +2 -1
- package/node_modules/zod/v4/locales/it.js +21 -25
- package/node_modules/zod/v4/locales/ja.cjs +22 -24
- package/node_modules/zod/v4/locales/ja.d.cts +2 -1
- package/node_modules/zod/v4/locales/ja.js +21 -24
- package/node_modules/zod/v4/locales/ka.cjs +144 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +117 -0
- package/node_modules/zod/v4/locales/kh.cjs +6 -137
- package/node_modules/zod/v4/locales/kh.d.cts +2 -1
- package/node_modules/zod/v4/locales/kh.d.ts +1 -0
- package/node_modules/zod/v4/locales/kh.js +3 -115
- package/node_modules/zod/v4/locales/km.cjs +142 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +115 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +20 -24
- package/node_modules/zod/v4/locales/ko.d.cts +2 -1
- package/node_modules/zod/v4/locales/ko.js +19 -24
- package/node_modules/zod/v4/locales/lt.cjs +234 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +207 -0
- package/node_modules/zod/v4/locales/mk.cjs +22 -25
- package/node_modules/zod/v4/locales/mk.d.cts +2 -1
- package/node_modules/zod/v4/locales/mk.js +21 -25
- package/node_modules/zod/v4/locales/ms.cjs +21 -24
- package/node_modules/zod/v4/locales/ms.d.cts +2 -1
- package/node_modules/zod/v4/locales/ms.js +20 -24
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +31 -32
- package/node_modules/zod/v4/locales/nl.d.cts +2 -1
- package/node_modules/zod/v4/locales/nl.js +30 -32
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +24 -26
- package/node_modules/zod/v4/locales/no.d.cts +2 -1
- package/node_modules/zod/v4/locales/no.js +23 -26
- package/node_modules/zod/v4/locales/ota.cjs +23 -25
- package/node_modules/zod/v4/locales/ota.d.cts +2 -1
- package/node_modules/zod/v4/locales/ota.js +22 -25
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +22 -24
- package/node_modules/zod/v4/locales/pl.d.cts +2 -1
- package/node_modules/zod/v4/locales/pl.js +21 -24
- package/node_modules/zod/v4/locales/ps.cjs +22 -24
- package/node_modules/zod/v4/locales/ps.d.cts +2 -1
- package/node_modules/zod/v4/locales/ps.js +21 -24
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +95 -68
- package/node_modules/zod/v4/locales/pt.d.cts +2 -1
- package/node_modules/zod/v4/locales/pt.js +94 -68
- package/node_modules/zod/v4/locales/ro.cjs +149 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +122 -0
- package/node_modules/zod/v4/locales/ru.cjs +29 -24
- package/node_modules/zod/v4/locales/ru.d.cts +2 -1
- package/node_modules/zod/v4/locales/ru.js +28 -24
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +22 -24
- package/node_modules/zod/v4/locales/sl.d.cts +2 -1
- package/node_modules/zod/v4/locales/sl.js +21 -24
- package/node_modules/zod/v4/locales/sv.cjs +24 -26
- package/node_modules/zod/v4/locales/sv.d.cts +2 -1
- package/node_modules/zod/v4/locales/sv.js +23 -26
- package/node_modules/zod/v4/locales/ta.cjs +23 -24
- package/node_modules/zod/v4/locales/ta.d.cts +2 -1
- package/node_modules/zod/v4/locales/ta.js +22 -24
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +23 -24
- package/node_modules/zod/v4/locales/th.d.cts +2 -1
- package/node_modules/zod/v4/locales/th.js +22 -24
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +20 -26
- package/node_modules/zod/v4/locales/tr.d.cts +2 -2
- package/node_modules/zod/v4/locales/tr.d.ts +0 -1
- package/node_modules/zod/v4/locales/tr.js +19 -24
- package/node_modules/zod/v4/locales/ua.cjs +6 -137
- package/node_modules/zod/v4/locales/ua.d.cts +2 -1
- package/node_modules/zod/v4/locales/ua.d.ts +1 -0
- package/node_modules/zod/v4/locales/ua.js +3 -115
- package/node_modules/zod/v4/locales/uk.cjs +140 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +113 -0
- package/node_modules/zod/v4/locales/ur.cjs +23 -24
- package/node_modules/zod/v4/locales/ur.d.cts +2 -1
- package/node_modules/zod/v4/locales/ur.js +22 -24
- package/node_modules/zod/v4/locales/uz.cjs +140 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +113 -0
- package/node_modules/zod/v4/locales/vi.cjs +22 -24
- package/node_modules/zod/v4/locales/vi.d.cts +2 -1
- package/node_modules/zod/v4/locales/vi.js +21 -24
- package/node_modules/zod/v4/locales/yo.cjs +139 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +112 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +23 -24
- package/node_modules/zod/v4/locales/zh-CN.d.cts +2 -1
- package/node_modules/zod/v4/locales/zh-CN.js +22 -24
- package/node_modules/zod/v4/locales/zh-TW.cjs +20 -24
- package/node_modules/zod/v4/locales/zh-TW.d.cts +2 -1
- package/node_modules/zod/v4/locales/zh-TW.js +19 -24
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +24 -0
- package/node_modules/zod/v4/mini/coerce.js +5 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +36 -3
- package/node_modules/zod/v4/mini/external.d.cts +7 -2
- package/node_modules/zod/v4/mini/external.d.ts +7 -2
- package/node_modules/zod/v4/mini/external.js +4 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +27 -4
- package/node_modules/zod/v4/mini/iso.js +8 -4
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +30 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +390 -82
- package/node_modules/zod/v4/mini/schemas.d.cts +156 -32
- package/node_modules/zod/v4/mini/schemas.d.ts +156 -32
- package/node_modules/zod/v4/mini/schemas.js +329 -59
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +35 -1
- package/node_modules/zod/v4-mini/index.d.cts +3 -1
- package/node_modules/zod/v4-mini/index.d.ts +3 -1
- package/node_modules/zod/v4-mini/index.js +3 -1
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/package.json +4 -4
- package/dist/ui/assets/index-DNNXeRpZ.js +0 -123
- package/dist/ui/assets/index-Osk4E49r.css +0 -1
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- package/node_modules/zod/src/v4/core/function.ts +0 -176
- package/node_modules/zod/v4/core/function.cjs +0 -102
- package/node_modules/zod/v4/core/function.d.cts +0 -52
- package/node_modules/zod/v4/core/function.d.ts +0 -52
- package/node_modules/zod/v4/core/function.js +0 -75
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var Rv=Object.defineProperty;var $v=(e,r,a)=>r in e?Rv(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var ia=(e,r,a)=>$v(e,typeof r!="symbol"?r+"":r,a);(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Zl={exports:{}},oa={},ec={exports:{}},Ye={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Gf;function Pv(){if(Gf)return Ye;Gf=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),j=Symbol.iterator;function x(I){return I===null||typeof I!="object"?null:(I=j&&I[j]||I["@@iterator"],typeof I=="function"?I:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,b={};function k(I,F,pe){this.props=I,this.context=F,this.refs=b,this.updater=pe||S}k.prototype.isReactComponent={},k.prototype.setState=function(I,F){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,F,"setState")},k.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function C(){}C.prototype=k.prototype;function E(I,F,pe){this.props=I,this.context=F,this.refs=b,this.updater=pe||S}var R=E.prototype=new C;R.constructor=E,N(R,k.prototype),R.isPureReactComponent=!0;var A=Array.isArray,z=Object.prototype.hasOwnProperty,M={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function te(I,F,pe){var fe,we={},ve=null,Q=null;if(F!=null)for(fe in F.ref!==void 0&&(Q=F.ref),F.key!==void 0&&(ve=""+F.key),F)z.call(F,fe)&&!H.hasOwnProperty(fe)&&(we[fe]=F[fe]);var de=arguments.length-2;if(de===1)we.children=pe;else if(1<de){for(var le=Array(de),ne=0;ne<de;ne++)le[ne]=arguments[ne+2];we.children=le}if(I&&I.defaultProps)for(fe in de=I.defaultProps,de)we[fe]===void 0&&(we[fe]=de[fe]);return{$$typeof:e,type:I,key:ve,ref:Q,props:we,_owner:M.current}}function X(I,F){return{$$typeof:e,type:I.type,key:F,ref:I.ref,props:I.props,_owner:I._owner}}function L(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function q(I){var F={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(pe){return F[pe]})}var U=/\/+/g;function K(I,F){return typeof I=="object"&&I!==null&&I.key!=null?q(""+I.key):F.toString(36)}function ce(I,F,pe,fe,we){var ve=typeof I;(ve==="undefined"||ve==="boolean")&&(I=null);var Q=!1;if(I===null)Q=!0;else switch(ve){case"string":case"number":Q=!0;break;case"object":switch(I.$$typeof){case e:case r:Q=!0}}if(Q)return Q=I,we=we(Q),I=fe===""?"."+K(Q,0):fe,A(we)?(pe="",I!=null&&(pe=I.replace(U,"$&/")+"/"),ce(we,F,pe,"",function(ne){return ne})):we!=null&&(L(we)&&(we=X(we,pe+(!we.key||Q&&Q.key===we.key?"":(""+we.key).replace(U,"$&/")+"/")+I)),F.push(we)),1;if(Q=0,fe=fe===""?".":fe+":",A(I))for(var de=0;de<I.length;de++){ve=I[de];var le=fe+K(ve,de);Q+=ce(ve,F,pe,le,we)}else if(le=x(I),typeof le=="function")for(I=le.call(I),de=0;!(ve=I.next()).done;)ve=ve.value,le=fe+K(ve,de++),Q+=ce(ve,F,pe,le,we);else if(ve==="object")throw F=String(I),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return Q}function ee(I,F,pe){if(I==null)return I;var fe=[],we=0;return ce(I,fe,"","",function(ve){return F.call(pe,ve,we++)}),fe}function Se(I){if(I._status===-1){var F=I._result;F=F(),F.then(function(pe){(I._status===0||I._status===-1)&&(I._status=1,I._result=pe)},function(pe){(I._status===0||I._status===-1)&&(I._status=2,I._result=pe)}),I._status===-1&&(I._status=0,I._result=F)}if(I._status===1)return I._result.default;throw I._result}var Ae={current:null},Z={transition:null},G={ReactCurrentDispatcher:Ae,ReactCurrentBatchConfig:Z,ReactCurrentOwner:M};function Y(){throw Error("act(...) is not supported in production builds of React.")}return Ye.Children={map:ee,forEach:function(I,F,pe){ee(I,function(){F.apply(this,arguments)},pe)},count:function(I){var F=0;return ee(I,function(){F++}),F},toArray:function(I){return ee(I,function(F){return F})||[]},only:function(I){if(!L(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},Ye.Component=k,Ye.Fragment=a,Ye.Profiler=l,Ye.PureComponent=E,Ye.StrictMode=i,Ye.Suspense=m,Ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,Ye.act=Y,Ye.cloneElement=function(I,F,pe){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var fe=N({},I.props),we=I.key,ve=I.ref,Q=I._owner;if(F!=null){if(F.ref!==void 0&&(ve=F.ref,Q=M.current),F.key!==void 0&&(we=""+F.key),I.type&&I.type.defaultProps)var de=I.type.defaultProps;for(le in F)z.call(F,le)&&!H.hasOwnProperty(le)&&(fe[le]=F[le]===void 0&&de!==void 0?de[le]:F[le])}var le=arguments.length-2;if(le===1)fe.children=pe;else if(1<le){de=Array(le);for(var ne=0;ne<le;ne++)de[ne]=arguments[ne+2];fe.children=de}return{$$typeof:e,type:I.type,key:we,ref:ve,props:fe,_owner:Q}},Ye.createContext=function(I){return I={$$typeof:d,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:u,_context:I},I.Consumer=I},Ye.createElement=te,Ye.createFactory=function(I){var F=te.bind(null,I);return F.type=I,F},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(I){return{$$typeof:p,render:I}},Ye.isValidElement=L,Ye.lazy=function(I){return{$$typeof:y,_payload:{_status:-1,_result:I},_init:Se}},Ye.memo=function(I,F){return{$$typeof:v,type:I,compare:F===void 0?null:F}},Ye.startTransition=function(I){var F=Z.transition;Z.transition={};try{I()}finally{Z.transition=F}},Ye.unstable_act=Y,Ye.useCallback=function(I,F){return Ae.current.useCallback(I,F)},Ye.useContext=function(I){return Ae.current.useContext(I)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(I){return Ae.current.useDeferredValue(I)},Ye.useEffect=function(I,F){return Ae.current.useEffect(I,F)},Ye.useId=function(){return Ae.current.useId()},Ye.useImperativeHandle=function(I,F,pe){return Ae.current.useImperativeHandle(I,F,pe)},Ye.useInsertionEffect=function(I,F){return Ae.current.useInsertionEffect(I,F)},Ye.useLayoutEffect=function(I,F){return Ae.current.useLayoutEffect(I,F)},Ye.useMemo=function(I,F){return Ae.current.useMemo(I,F)},Ye.useReducer=function(I,F,pe){return Ae.current.useReducer(I,F,pe)},Ye.useRef=function(I){return Ae.current.useRef(I)},Ye.useState=function(I){return Ae.current.useState(I)},Ye.useSyncExternalStore=function(I,F,pe){return Ae.current.useSyncExternalStore(I,F,pe)},Ye.useTransition=function(){return Ae.current.useTransition()},Ye.version="18.3.1",Ye}var qf;function Dc(){return qf||(qf=1,ec.exports=Pv()),ec.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Kf;function _v(){if(Kf)return oa;Kf=1;var e=Dc(),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function d(p,m,v){var y,j={},x=null,S=null;v!==void 0&&(x=""+v),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(S=m.ref);for(y in m)i.call(m,y)&&!u.hasOwnProperty(y)&&(j[y]=m[y]);if(p&&p.defaultProps)for(y in m=p.defaultProps,m)j[y]===void 0&&(j[y]=m[y]);return{$$typeof:r,type:p,key:x,ref:S,props:j,_owner:l.current}}return oa.Fragment=a,oa.jsx=d,oa.jsxs=d,oa}var Yf;function Lv(){return Yf||(Yf=1,Zl.exports=_v()),Zl.exports}var n=Lv(),h=Dc(),Ei={},tc={exports:{}},Zt={},nc={exports:{}},rc={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var Jf;function Mv(){return Jf||(Jf=1,(function(e){function r(Z,G){var Y=Z.length;Z.push(G);e:for(;0<Y;){var I=Y-1>>>1,F=Z[I];if(0<l(F,G))Z[I]=G,Z[Y]=F,Y=I;else break e}}function a(Z){return Z.length===0?null:Z[0]}function i(Z){if(Z.length===0)return null;var G=Z[0],Y=Z.pop();if(Y!==G){Z[0]=Y;e:for(var I=0,F=Z.length,pe=F>>>1;I<pe;){var fe=2*(I+1)-1,we=Z[fe],ve=fe+1,Q=Z[ve];if(0>l(we,Y))ve<F&&0>l(Q,we)?(Z[I]=Q,Z[ve]=Y,I=ve):(Z[I]=we,Z[fe]=Y,I=fe);else if(ve<F&&0>l(Q,Y))Z[I]=Q,Z[ve]=Y,I=ve;else break e}}return G}function l(Z,G){var Y=Z.sortIndex-G.sortIndex;return Y!==0?Y:Z.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],v=[],y=1,j=null,x=3,S=!1,N=!1,b=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(Z){for(var G=a(v);G!==null;){if(G.callback===null)i(v);else if(G.startTime<=Z)i(v),G.sortIndex=G.expirationTime,r(m,G);else break;G=a(v)}}function A(Z){if(b=!1,R(Z),!N)if(a(m)!==null)N=!0,Se(z);else{var G=a(v);G!==null&&Ae(A,G.startTime-Z)}}function z(Z,G){N=!1,b&&(b=!1,C(te),te=-1),S=!0;var Y=x;try{for(R(G),j=a(m);j!==null&&(!(j.expirationTime>G)||Z&&!q());){var I=j.callback;if(typeof I=="function"){j.callback=null,x=j.priorityLevel;var F=I(j.expirationTime<=G);G=e.unstable_now(),typeof F=="function"?j.callback=F:j===a(m)&&i(m),R(G)}else i(m);j=a(m)}if(j!==null)var pe=!0;else{var fe=a(v);fe!==null&&Ae(A,fe.startTime-G),pe=!1}return pe}finally{j=null,x=Y,S=!1}}var M=!1,H=null,te=-1,X=5,L=-1;function q(){return!(e.unstable_now()-L<X)}function U(){if(H!==null){var Z=e.unstable_now();L=Z;var G=!0;try{G=H(!0,Z)}finally{G?K():(M=!1,H=null)}}else M=!1}var K;if(typeof E=="function")K=function(){E(U)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,ee=ce.port2;ce.port1.onmessage=U,K=function(){ee.postMessage(null)}}else K=function(){k(U,0)};function Se(Z){H=Z,M||(M=!0,K())}function Ae(Z,G){te=k(function(){Z(e.unstable_now())},G)}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(Z){Z.callback=null},e.unstable_continueExecution=function(){N||S||(N=!0,Se(z))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return a(m)},e.unstable_next=function(Z){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var Y=x;x=G;try{return Z()}finally{x=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,G){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var Y=x;x=Z;try{return G()}finally{x=Y}},e.unstable_scheduleCallback=function(Z,G,Y){var I=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?I+Y:I):Y=I,Z){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=Y+F,Z={id:y++,callback:G,priorityLevel:Z,startTime:Y,expirationTime:F,sortIndex:-1},Y>I?(Z.sortIndex=Y,r(v,Z),a(m)===null&&Z===a(v)&&(b?(C(te),te=-1):b=!0,Ae(A,Y-I))):(Z.sortIndex=F,r(m,Z),N||S||(N=!0,Se(z))),Z},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(Z){var G=x;return function(){var Y=x;x=G;try{return Z.apply(this,arguments)}finally{x=Y}}}})(rc)),rc}var Qf;function Fv(){return Qf||(Qf=1,nc.exports=Mv()),nc.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Xf;function Ov(){if(Xf)return Zt;Xf=1;var e=Dc(),r=Fv();function a(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,l={};function u(t,s){d(t,s),d(t+"Capture",s)}function d(t,s){for(l[t]=s,t=0;t<s.length;t++)i.add(s[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},j={};function x(t){return m.call(j,t)?!0:m.call(y,t)?!1:v.test(t)?j[t]=!0:(y[t]=!0,!1)}function S(t,s,o,c){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function N(t,s,o,c){if(s===null||typeof s>"u"||S(t,s,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function b(t,s,o,c,f,g,w){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=c,this.attributeNamespace=f,this.mustUseProperty=o,this.propertyName=t,this.type=s,this.sanitizeURL=g,this.removeEmptyString=w}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){k[t]=new b(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];k[s]=new b(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){k[t]=new b(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){k[t]=new b(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){k[t]=new b(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){k[t]=new b(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){k[t]=new b(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){k[t]=new b(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){k[t]=new b(t,5,!1,t.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function E(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new b(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(C,E);k[s]=new b(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(C,E);k[s]=new b(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){k[t]=new b(t,1,!1,t.toLowerCase(),null,!1,!1)}),k.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){k[t]=new b(t,1,!1,t.toLowerCase(),null,!0,!0)});function R(t,s,o,c){var f=k.hasOwnProperty(s)?k[s]:null;(f!==null?f.type!==0:c||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(N(s,o,f,c)&&(o=null),c||f===null?x(s)&&(o===null?t.removeAttribute(s):t.setAttribute(s,""+o)):f.mustUseProperty?t[f.propertyName]=o===null?f.type===3?!1:"":o:(s=f.attributeName,c=f.attributeNamespace,o===null?t.removeAttribute(s):(f=f.type,o=f===3||f===4&&o===!0?"":""+o,c?t.setAttributeNS(c,s,o):t.setAttribute(s,o))))}var A=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,z=Symbol.for("react.element"),M=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),q=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ce=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),Se=Symbol.for("react.lazy"),Ae=Symbol.for("react.offscreen"),Z=Symbol.iterator;function G(t){return t===null||typeof t!="object"?null:(t=Z&&t[Z]||t["@@iterator"],typeof t=="function"?t:null)}var Y=Object.assign,I;function F(t){if(I===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);I=s&&s[1]||""}return`
|
|
34
|
-
`+I+t}var pe=!1;function fe(t,s){if(!t||pe)return"";pe=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(V){var c=V}Reflect.construct(t,[],s)}else{try{s.call()}catch(V){c=V}t.call(s.prototype)}else{try{throw Error()}catch(V){c=V}t()}}catch(V){if(V&&c&&typeof V.stack=="string"){for(var f=V.stack.split(`
|
|
35
|
-
`),g=c.stack.split(`
|
|
36
|
-
`),w=f.length-1,T=g.length-1;1<=w&&0<=T&&f[w]!==g[T];)T--;for(;1<=w&&0<=T;w--,T--)if(f[w]!==g[T]){if(w!==1||T!==1)do if(w--,T--,0>T||f[w]!==g[T]){var $=`
|
|
37
|
-
`+f[w].replace(" at new "," at ");return t.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",t.displayName)),$}while(1<=w&&0<=T);break}}}finally{pe=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?F(t):""}function we(t){switch(t.tag){case 5:return F(t.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return t=fe(t.type,!1),t;case 11:return t=fe(t.type.render,!1),t;case 1:return t=fe(t.type,!0),t;default:return""}}function ve(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case H:return"Fragment";case M:return"Portal";case X:return"Profiler";case te:return"StrictMode";case K:return"Suspense";case ce:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case q:return(t.displayName||"Context")+".Consumer";case L:return(t._context.displayName||"Context")+".Provider";case U:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ee:return s=t.displayName||null,s!==null?s:ve(t.type)||"Memo";case Se:s=t._payload,t=t._init;try{return ve(t(s))}catch{}}return null}function Q(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(s);case 8:return s===te?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function de(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function le(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ne(t){var s=le(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),c=""+t[s];if(!t.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,g=o.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return f.call(this)},set:function(w){c=""+w,g.call(this,w)}}),Object.defineProperty(t,s,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function Be(t){t._valueTracker||(t._valueTracker=ne(t))}function Me(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var o=s.getValue(),c="";return t&&(c=le(t)?t.checked?"true":"false":t.value),t=c,t!==o?(s.setValue(t),!0):!1}function ae(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function We(t,s){var o=s.checked;return Y({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function Re(t,s){var o=s.defaultValue==null?"":s.defaultValue,c=s.checked!=null?s.checked:s.defaultChecked;o=de(s.value!=null?s.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function ze(t,s){s=s.checked,s!=null&&R(t,"checked",s,!1)}function Ve(t,s){ze(t,s);var o=de(s.value),c=s.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?tt(t,s.type,o):s.hasOwnProperty("defaultValue")&&tt(t,s.type,de(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function ct(t,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var c=s.type;if(!(c!=="submit"&&c!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,o||s===t.value||(t.value=s),t.defaultValue=s}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function tt(t,s,o){(s!=="number"||ae(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var Qe=Array.isArray;function De(t,s,o,c){if(t=t.options,s){s={};for(var f=0;f<o.length;f++)s["$"+o[f]]=!0;for(o=0;o<t.length;o++)f=s.hasOwnProperty("$"+t[o].value),t[o].selected!==f&&(t[o].selected=f),f&&c&&(t[o].defaultSelected=!0)}else{for(o=""+de(o),s=null,f=0;f<t.length;f++){if(t[f].value===o){t[f].selected=!0,c&&(t[f].defaultSelected=!0);return}s!==null||t[f].disabled||(s=t[f])}s!==null&&(s.selected=!0)}}function gt(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(a(91));return Y({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function st(t,s){var o=s.value;if(o==null){if(o=s.children,s=s.defaultValue,o!=null){if(s!=null)throw Error(a(92));if(Qe(o)){if(1<o.length)throw Error(a(93));o=o[0]}s=o}s==null&&(s=""),o=s}t._wrapperState={initialValue:de(o)}}function Oe(t,s){var o=de(s.value),c=de(s.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),s.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function J(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function ge(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ee(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?ge(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var $e,he=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,o,c,f){MSApp.execUnsafeLocalFunction(function(){return t(s,o,c,f)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for($e=$e||document.createElement("div"),$e.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=$e.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function Fe(t,s){if(s){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=s;return}}t.textContent=s}var Ke={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Xe=["Webkit","ms","Moz","O"];Object.keys(Ke).forEach(function(t){Xe.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),Ke[s]=Ke[t]})});function at(t,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||Ke.hasOwnProperty(t)&&Ke[t]?(""+s).trim():s+"px"}function yt(t,s){t=t.style;for(var o in s)if(s.hasOwnProperty(o)){var c=o.indexOf("--")===0,f=at(o,s[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,f):t[o]=f}}var Nt=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qe(t,s){if(s){if(Nt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(a(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(a(61))}if(s.style!=null&&typeof s.style!="object")throw Error(a(62))}}function W(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ye=null;function Ne(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ze=null,dt=null,Ge=null;function be(t){if(t=Vs(t)){if(typeof Ze!="function")throw Error(a(280));var s=t.stateNode;s&&(s=Ua(s),Ze(t.stateNode,t.type,s))}}function it(t){dt?Ge?Ge.push(t):Ge=[t]:dt=t}function bt(){if(dt){var t=dt,s=Ge;if(Ge=dt=null,be(t),s)for(t=0;t<s.length;t++)be(s[t])}}function re(t,s){return t(s)}function xe(){}var B=!1;function oe(t,s,o){if(B)return t(s,o);B=!0;try{return re(t,s,o)}finally{B=!1,(dt!==null||Ge!==null)&&(xe(),bt())}}function Te(t,s){var o=t.stateNode;if(o===null)return null;var c=Ua(o);if(c===null)return null;o=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(a(231,s,typeof o));return o}var rt=!1;if(p)try{var ot={};Object.defineProperty(ot,"passive",{get:function(){rt=!0}}),window.addEventListener("test",ot,ot),window.removeEventListener("test",ot,ot)}catch{rt=!1}function Fn(t,s,o,c,f,g,w,T,$){var V=Array.prototype.slice.call(arguments,3);try{s.apply(o,V)}catch(ie){this.onError(ie)}}var tn=!1,nn=null,qt=!1,wr=null,vo={onError:function(t){tn=!0,nn=t}};function xa(t,s,o,c,f,g,w,T,$){tn=!1,nn=null,Fn.apply(vo,arguments)}function ja(t,s,o,c,f,g,w,T,$){if(xa.apply(this,arguments),tn){if(tn){var V=nn;tn=!1,nn=null}else throw Error(a(198));qt||(qt=!0,wr=V)}}function En(t){var s=t,o=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(o=s.return),t=s.return;while(t)}return s.tag===3?o:null}function Cs(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function wa(t){if(En(t)!==t)throw Error(a(188))}function Wr(t){var s=t.alternate;if(!s){if(s=En(t),s===null)throw Error(a(188));return s!==t?null:t}for(var o=t,c=s;;){var f=o.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){o=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===o)return wa(f),t;if(g===c)return wa(f),s;g=g.sibling}throw Error(a(188))}if(o.return!==c.return)o=f,c=g;else{for(var w=!1,T=f.child;T;){if(T===o){w=!0,o=f,c=g;break}if(T===c){w=!0,c=f,o=g;break}T=T.sibling}if(!w){for(T=g.child;T;){if(T===o){w=!0,o=g,c=f;break}if(T===c){w=!0,c=g,o=f;break}T=T.sibling}if(!w)throw Error(a(189))}}if(o.alternate!==c)throw Error(a(190))}if(o.tag!==3)throw Error(a(188));return o.stateNode.current===o?t:s}function Tn(t){return t=Wr(t),t!==null?yu(t):null}function yu(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=yu(t);if(s!==null)return s;t=t.sibling}return null}var vu=r.unstable_scheduleCallback,xu=r.unstable_cancelCallback,Ug=r.unstable_shouldYield,Wg=r.unstable_requestPaint,Ct=r.unstable_now,Hg=r.unstable_getCurrentPriorityLevel,xo=r.unstable_ImmediatePriority,ju=r.unstable_UserBlockingPriority,ba=r.unstable_NormalPriority,Vg=r.unstable_LowPriority,wu=r.unstable_IdlePriority,Sa=null,An=null;function Gg(t){if(An&&typeof An.onCommitFiberRoot=="function")try{An.onCommitFiberRoot(Sa,t,void 0,(t.current.flags&128)===128)}catch{}}var yn=Math.clz32?Math.clz32:Yg,qg=Math.log,Kg=Math.LN2;function Yg(t){return t>>>=0,t===0?32:31-(qg(t)/Kg|0)|0}var ka=64,Na=4194304;function Es(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ca(t,s){var o=t.pendingLanes;if(o===0)return 0;var c=0,f=t.suspendedLanes,g=t.pingedLanes,w=o&268435455;if(w!==0){var T=w&~f;T!==0?c=Es(T):(g&=w,g!==0&&(c=Es(g)))}else w=o&~f,w!==0?c=Es(w):g!==0&&(c=Es(g));if(c===0)return 0;if(s!==0&&s!==c&&(s&f)===0&&(f=c&-c,g=s&-s,f>=g||f===16&&(g&4194240)!==0))return s;if((c&4)!==0&&(c|=o&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=c;0<s;)o=31-yn(s),f=1<<o,c|=t[o],s&=~f;return c}function Jg(t,s){switch(t){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Qg(t,s){for(var o=t.suspendedLanes,c=t.pingedLanes,f=t.expirationTimes,g=t.pendingLanes;0<g;){var w=31-yn(g),T=1<<w,$=f[w];$===-1?((T&o)===0||(T&c)!==0)&&(f[w]=Jg(T,s)):$<=s&&(t.expiredLanes|=T),g&=~T}}function jo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function bu(){var t=ka;return ka<<=1,(ka&4194240)===0&&(ka=64),t}function wo(t){for(var s=[],o=0;31>o;o++)s.push(t);return s}function Ts(t,s,o){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-yn(s),t[s]=o}function Xg(t,s){var o=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var f=31-yn(o),g=1<<f;s[f]=0,c[f]=-1,t[f]=-1,o&=~g}}function bo(t,s){var o=t.entangledLanes|=s;for(t=t.entanglements;o;){var c=31-yn(o),f=1<<c;f&s|t[c]&s&&(t[c]|=s),o&=~f}}var lt=0;function Su(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var ku,So,Nu,Cu,Eu,ko=!1,Ea=[],Xn=null,Zn=null,er=null,As=new Map,Is=new Map,tr=[],Zg="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Tu(t,s){switch(t){case"focusin":case"focusout":Xn=null;break;case"dragenter":case"dragleave":Zn=null;break;case"mouseover":case"mouseout":er=null;break;case"pointerover":case"pointerout":As.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Is.delete(s.pointerId)}}function Rs(t,s,o,c,f,g){return t===null||t.nativeEvent!==g?(t={blockedOn:s,domEventName:o,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},s!==null&&(s=Vs(s),s!==null&&So(s)),t):(t.eventSystemFlags|=c,s=t.targetContainers,f!==null&&s.indexOf(f)===-1&&s.push(f),t)}function ey(t,s,o,c,f){switch(s){case"focusin":return Xn=Rs(Xn,t,s,o,c,f),!0;case"dragenter":return Zn=Rs(Zn,t,s,o,c,f),!0;case"mouseover":return er=Rs(er,t,s,o,c,f),!0;case"pointerover":var g=f.pointerId;return As.set(g,Rs(As.get(g)||null,t,s,o,c,f)),!0;case"gotpointercapture":return g=f.pointerId,Is.set(g,Rs(Is.get(g)||null,t,s,o,c,f)),!0}return!1}function Au(t){var s=br(t.target);if(s!==null){var o=En(s);if(o!==null){if(s=o.tag,s===13){if(s=Cs(o),s!==null){t.blockedOn=s,Eu(t.priority,function(){Nu(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ta(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var o=Co(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);ye=c,o.target.dispatchEvent(c),ye=null}else return s=Vs(o),s!==null&&So(s),t.blockedOn=o,!1;s.shift()}return!0}function Iu(t,s,o){Ta(t)&&o.delete(s)}function ty(){ko=!1,Xn!==null&&Ta(Xn)&&(Xn=null),Zn!==null&&Ta(Zn)&&(Zn=null),er!==null&&Ta(er)&&(er=null),As.forEach(Iu),Is.forEach(Iu)}function $s(t,s){t.blockedOn===s&&(t.blockedOn=null,ko||(ko=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,ty)))}function Ps(t){function s(f){return $s(f,t)}if(0<Ea.length){$s(Ea[0],t);for(var o=1;o<Ea.length;o++){var c=Ea[o];c.blockedOn===t&&(c.blockedOn=null)}}for(Xn!==null&&$s(Xn,t),Zn!==null&&$s(Zn,t),er!==null&&$s(er,t),As.forEach(s),Is.forEach(s),o=0;o<tr.length;o++)c=tr[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<tr.length&&(o=tr[0],o.blockedOn===null);)Au(o),o.blockedOn===null&&tr.shift()}var Hr=A.ReactCurrentBatchConfig,Aa=!0;function ny(t,s,o,c){var f=lt,g=Hr.transition;Hr.transition=null;try{lt=1,No(t,s,o,c)}finally{lt=f,Hr.transition=g}}function ry(t,s,o,c){var f=lt,g=Hr.transition;Hr.transition=null;try{lt=4,No(t,s,o,c)}finally{lt=f,Hr.transition=g}}function No(t,s,o,c){if(Aa){var f=Co(t,s,o,c);if(f===null)Wo(t,s,c,Ia,o),Tu(t,c);else if(ey(f,t,s,o,c))c.stopPropagation();else if(Tu(t,c),s&4&&-1<Zg.indexOf(t)){for(;f!==null;){var g=Vs(f);if(g!==null&&ku(g),g=Co(t,s,o,c),g===null&&Wo(t,s,c,Ia,o),g===f)break;f=g}f!==null&&c.stopPropagation()}else Wo(t,s,c,null,o)}}var Ia=null;function Co(t,s,o,c){if(Ia=null,t=Ne(c),t=br(t),t!==null)if(s=En(t),s===null)t=null;else if(o=s.tag,o===13){if(t=Cs(s),t!==null)return t;t=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return Ia=t,null}function Ru(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Hg()){case xo:return 1;case ju:return 4;case ba:case Vg:return 16;case wu:return 536870912;default:return 16}default:return 16}}var nr=null,Eo=null,Ra=null;function $u(){if(Ra)return Ra;var t,s=Eo,o=s.length,c,f="value"in nr?nr.value:nr.textContent,g=f.length;for(t=0;t<o&&s[t]===f[t];t++);var w=o-t;for(c=1;c<=w&&s[o-c]===f[g-c];c++);return Ra=f.slice(t,1<c?1-c:void 0)}function $a(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function Pa(){return!0}function Pu(){return!1}function rn(t){function s(o,c,f,g,w){this._reactName=o,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=w,this.currentTarget=null;for(var T in t)t.hasOwnProperty(T)&&(o=t[T],this[T]=o?o(g):g[T]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Pa:Pu,this.isPropagationStopped=Pu,this}return Y(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Pa)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Pa)},persist:function(){},isPersistent:Pa}),s}var Vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},To=rn(Vr),_s=Y({},Vr,{view:0,detail:0}),sy=rn(_s),Ao,Io,Ls,_a=Y({},_s,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$o,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ls&&(Ls&&t.type==="mousemove"?(Ao=t.screenX-Ls.screenX,Io=t.screenY-Ls.screenY):Io=Ao=0,Ls=t),Ao)},movementY:function(t){return"movementY"in t?t.movementY:Io}}),_u=rn(_a),ay=Y({},_a,{dataTransfer:0}),iy=rn(ay),oy=Y({},_s,{relatedTarget:0}),Ro=rn(oy),ly=Y({},Vr,{animationName:0,elapsedTime:0,pseudoElement:0}),cy=rn(ly),uy=Y({},Vr,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),dy=rn(uy),fy=Y({},Vr,{data:0}),Lu=rn(fy),hy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},my={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},py={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gy(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=py[t])?!!s[t]:!1}function $o(){return gy}var yy=Y({},_s,{key:function(t){if(t.key){var s=hy[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=$a(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?my[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$o,charCode:function(t){return t.type==="keypress"?$a(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?$a(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),vy=rn(yy),xy=Y({},_a,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Mu=rn(xy),jy=Y({},_s,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$o}),wy=rn(jy),by=Y({},Vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sy=rn(by),ky=Y({},_a,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Ny=rn(ky),Cy=[9,13,27,32],Po=p&&"CompositionEvent"in window,Ms=null;p&&"documentMode"in document&&(Ms=document.documentMode);var Ey=p&&"TextEvent"in window&&!Ms,Fu=p&&(!Po||Ms&&8<Ms&&11>=Ms),Ou=" ",zu=!1;function Bu(t,s){switch(t){case"keyup":return Cy.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Du(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Gr=!1;function Ty(t,s){switch(t){case"compositionend":return Du(s);case"keypress":return s.which!==32?null:(zu=!0,Ou);case"textInput":return t=s.data,t===Ou&&zu?null:t;default:return null}}function Ay(t,s){if(Gr)return t==="compositionend"||!Po&&Bu(t,s)?(t=$u(),Ra=Eo=nr=null,Gr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Fu&&s.locale!=="ko"?null:s.data;default:return null}}var Iy={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Uu(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!Iy[t.type]:s==="textarea"}function Wu(t,s,o,c){it(c),s=za(s,"onChange"),0<s.length&&(o=new To("onChange","change",null,o,c),t.push({event:o,listeners:s}))}var Fs=null,Os=null;function Ry(t){od(t,0)}function La(t){var s=Qr(t);if(Me(s))return t}function $y(t,s){if(t==="change")return s}var Hu=!1;if(p){var _o;if(p){var Lo="oninput"in document;if(!Lo){var Vu=document.createElement("div");Vu.setAttribute("oninput","return;"),Lo=typeof Vu.oninput=="function"}_o=Lo}else _o=!1;Hu=_o&&(!document.documentMode||9<document.documentMode)}function Gu(){Fs&&(Fs.detachEvent("onpropertychange",qu),Os=Fs=null)}function qu(t){if(t.propertyName==="value"&&La(Os)){var s=[];Wu(s,Os,t,Ne(t)),oe(Ry,s)}}function Py(t,s,o){t==="focusin"?(Gu(),Fs=s,Os=o,Fs.attachEvent("onpropertychange",qu)):t==="focusout"&&Gu()}function _y(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return La(Os)}function Ly(t,s){if(t==="click")return La(s)}function My(t,s){if(t==="input"||t==="change")return La(s)}function Fy(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var vn=typeof Object.is=="function"?Object.is:Fy;function zs(t,s){if(vn(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var o=Object.keys(t),c=Object.keys(s);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var f=o[c];if(!m.call(s,f)||!vn(t[f],s[f]))return!1}return!0}function Ku(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Yu(t,s){var o=Ku(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=s&&c>=s)return{node:o,offset:s-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Ku(o)}}function Ju(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?Ju(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function Qu(){for(var t=window,s=ae();s instanceof t.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)t=s.contentWindow;else break;s=ae(t.document)}return s}function Mo(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function Oy(t){var s=Qu(),o=t.focusedElem,c=t.selectionRange;if(s!==o&&o&&o.ownerDocument&&Ju(o.ownerDocument.documentElement,o)){if(c!==null&&Mo(o)){if(s=c.start,t=c.end,t===void 0&&(t=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(t,o.value.length);else if(t=(s=o.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var f=o.textContent.length,g=Math.min(c.start,f);c=c.end===void 0?g:Math.min(c.end,f),!t.extend&&g>c&&(f=c,c=g,g=f),f=Yu(o,g);var w=Yu(o,c);f&&w&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==w.node||t.focusOffset!==w.offset)&&(s=s.createRange(),s.setStart(f.node,f.offset),t.removeAllRanges(),g>c?(t.addRange(s),t.extend(w.node,w.offset)):(s.setEnd(w.node,w.offset),t.addRange(s)))}}for(s=[],t=o;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<s.length;o++)t=s[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var zy=p&&"documentMode"in document&&11>=document.documentMode,qr=null,Fo=null,Bs=null,Oo=!1;function Xu(t,s,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Oo||qr==null||qr!==ae(c)||(c=qr,"selectionStart"in c&&Mo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Bs&&zs(Bs,c)||(Bs=c,c=za(Fo,"onSelect"),0<c.length&&(s=new To("onSelect","select",null,s,o),t.push({event:s,listeners:c}),s.target=qr)))}function Ma(t,s){var o={};return o[t.toLowerCase()]=s.toLowerCase(),o["Webkit"+t]="webkit"+s,o["Moz"+t]="moz"+s,o}var Kr={animationend:Ma("Animation","AnimationEnd"),animationiteration:Ma("Animation","AnimationIteration"),animationstart:Ma("Animation","AnimationStart"),transitionend:Ma("Transition","TransitionEnd")},zo={},Zu={};p&&(Zu=document.createElement("div").style,"AnimationEvent"in window||(delete Kr.animationend.animation,delete Kr.animationiteration.animation,delete Kr.animationstart.animation),"TransitionEvent"in window||delete Kr.transitionend.transition);function Fa(t){if(zo[t])return zo[t];if(!Kr[t])return t;var s=Kr[t],o;for(o in s)if(s.hasOwnProperty(o)&&o in Zu)return zo[t]=s[o];return t}var ed=Fa("animationend"),td=Fa("animationiteration"),nd=Fa("animationstart"),rd=Fa("transitionend"),sd=new Map,ad="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function rr(t,s){sd.set(t,s),u(s,[t])}for(var Bo=0;Bo<ad.length;Bo++){var Do=ad[Bo],By=Do.toLowerCase(),Dy=Do[0].toUpperCase()+Do.slice(1);rr(By,"on"+Dy)}rr(ed,"onAnimationEnd"),rr(td,"onAnimationIteration"),rr(nd,"onAnimationStart"),rr("dblclick","onDoubleClick"),rr("focusin","onFocus"),rr("focusout","onBlur"),rr(rd,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ds="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Uy=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ds));function id(t,s,o){var c=t.type||"unknown-event";t.currentTarget=o,ja(c,s,void 0,t),t.currentTarget=null}function od(t,s){s=(s&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],f=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var w=c.length-1;0<=w;w--){var T=c[w],$=T.instance,V=T.currentTarget;if(T=T.listener,$!==g&&f.isPropagationStopped())break e;id(f,T,V),g=$}else for(w=0;w<c.length;w++){if(T=c[w],$=T.instance,V=T.currentTarget,T=T.listener,$!==g&&f.isPropagationStopped())break e;id(f,T,V),g=$}}}if(qt)throw t=wr,qt=!1,wr=null,t}function mt(t,s){var o=s[Yo];o===void 0&&(o=s[Yo]=new Set);var c=t+"__bubble";o.has(c)||(ld(s,t,2,!1),o.add(c))}function Uo(t,s,o){var c=0;s&&(c|=4),ld(o,t,c,s)}var Oa="_reactListening"+Math.random().toString(36).slice(2);function Us(t){if(!t[Oa]){t[Oa]=!0,i.forEach(function(o){o!=="selectionchange"&&(Uy.has(o)||Uo(o,!1,t),Uo(o,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[Oa]||(s[Oa]=!0,Uo("selectionchange",!1,s))}}function ld(t,s,o,c){switch(Ru(s)){case 1:var f=ny;break;case 4:f=ry;break;default:f=No}o=f.bind(null,s,o,t),f=void 0,!rt||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(f=!0),c?f!==void 0?t.addEventListener(s,o,{capture:!0,passive:f}):t.addEventListener(s,o,!0):f!==void 0?t.addEventListener(s,o,{passive:f}):t.addEventListener(s,o,!1)}function Wo(t,s,o,c,f){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var w=c.tag;if(w===3||w===4){var T=c.stateNode.containerInfo;if(T===f||T.nodeType===8&&T.parentNode===f)break;if(w===4)for(w=c.return;w!==null;){var $=w.tag;if(($===3||$===4)&&($=w.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;w=w.return}for(;T!==null;){if(w=br(T),w===null)return;if($=w.tag,$===5||$===6){c=g=w;continue e}T=T.parentNode}}c=c.return}oe(function(){var V=g,ie=Ne(o),ue=[];e:{var se=sd.get(t);if(se!==void 0){var je=To,Ce=t;switch(t){case"keypress":if($a(o)===0)break e;case"keydown":case"keyup":je=vy;break;case"focusin":Ce="focus",je=Ro;break;case"focusout":Ce="blur",je=Ro;break;case"beforeblur":case"afterblur":je=Ro;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=_u;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=iy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=wy;break;case ed:case td:case nd:je=cy;break;case rd:je=Sy;break;case"scroll":je=sy;break;case"wheel":je=Ny;break;case"copy":case"cut":case"paste":je=dy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Mu}var Ie=(s&4)!==0,Et=!Ie&&t==="scroll",O=Ie?se!==null?se+"Capture":null:se;Ie=[];for(var _=V,D;_!==null;){D=_;var me=D.stateNode;if(D.tag===5&&me!==null&&(D=me,O!==null&&(me=Te(_,O),me!=null&&Ie.push(Ws(_,me,D)))),Et)break;_=_.return}0<Ie.length&&(se=new je(se,Ce,null,o,ie),ue.push({event:se,listeners:Ie}))}}if((s&7)===0){e:{if(se=t==="mouseover"||t==="pointerover",je=t==="mouseout"||t==="pointerout",se&&o!==ye&&(Ce=o.relatedTarget||o.fromElement)&&(br(Ce)||Ce[On]))break e;if((je||se)&&(se=ie.window===ie?ie:(se=ie.ownerDocument)?se.defaultView||se.parentWindow:window,je?(Ce=o.relatedTarget||o.toElement,je=V,Ce=Ce?br(Ce):null,Ce!==null&&(Et=En(Ce),Ce!==Et||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(je=null,Ce=V),je!==Ce)){if(Ie=_u,me="onMouseLeave",O="onMouseEnter",_="mouse",(t==="pointerout"||t==="pointerover")&&(Ie=Mu,me="onPointerLeave",O="onPointerEnter",_="pointer"),Et=je==null?se:Qr(je),D=Ce==null?se:Qr(Ce),se=new Ie(me,_+"leave",je,o,ie),se.target=Et,se.relatedTarget=D,me=null,br(ie)===V&&(Ie=new Ie(O,_+"enter",Ce,o,ie),Ie.target=D,Ie.relatedTarget=Et,me=Ie),Et=me,je&&Ce)t:{for(Ie=je,O=Ce,_=0,D=Ie;D;D=Yr(D))_++;for(D=0,me=O;me;me=Yr(me))D++;for(;0<_-D;)Ie=Yr(Ie),_--;for(;0<D-_;)O=Yr(O),D--;for(;_--;){if(Ie===O||O!==null&&Ie===O.alternate)break t;Ie=Yr(Ie),O=Yr(O)}Ie=null}else Ie=null;je!==null&&cd(ue,se,je,Ie,!1),Ce!==null&&Et!==null&&cd(ue,Et,Ce,Ie,!0)}}e:{if(se=V?Qr(V):window,je=se.nodeName&&se.nodeName.toLowerCase(),je==="select"||je==="input"&&se.type==="file")var Pe=$y;else if(Uu(se))if(Hu)Pe=My;else{Pe=_y;var _e=Py}else(je=se.nodeName)&&je.toLowerCase()==="input"&&(se.type==="checkbox"||se.type==="radio")&&(Pe=Ly);if(Pe&&(Pe=Pe(t,V))){Wu(ue,Pe,o,ie);break e}_e&&_e(t,se,V),t==="focusout"&&(_e=se._wrapperState)&&_e.controlled&&se.type==="number"&&tt(se,"number",se.value)}switch(_e=V?Qr(V):window,t){case"focusin":(Uu(_e)||_e.contentEditable==="true")&&(qr=_e,Fo=V,Bs=null);break;case"focusout":Bs=Fo=qr=null;break;case"mousedown":Oo=!0;break;case"contextmenu":case"mouseup":case"dragend":Oo=!1,Xu(ue,o,ie);break;case"selectionchange":if(zy)break;case"keydown":case"keyup":Xu(ue,o,ie)}var Le;if(Po)e:{switch(t){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else Gr?Bu(t,o)&&(Ue="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(Ue="onCompositionStart");Ue&&(Fu&&o.locale!=="ko"&&(Gr||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&Gr&&(Le=$u()):(nr=ie,Eo="value"in nr?nr.value:nr.textContent,Gr=!0)),_e=za(V,Ue),0<_e.length&&(Ue=new Lu(Ue,t,null,o,ie),ue.push({event:Ue,listeners:_e}),Le?Ue.data=Le:(Le=Du(o),Le!==null&&(Ue.data=Le)))),(Le=Ey?Ty(t,o):Ay(t,o))&&(V=za(V,"onBeforeInput"),0<V.length&&(ie=new Lu("onBeforeInput","beforeinput",null,o,ie),ue.push({event:ie,listeners:V}),ie.data=Le))}od(ue,s)})}function Ws(t,s,o){return{instance:t,listener:s,currentTarget:o}}function za(t,s){for(var o=s+"Capture",c=[];t!==null;){var f=t,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=Te(t,o),g!=null&&c.unshift(Ws(t,g,f)),g=Te(t,s),g!=null&&c.push(Ws(t,g,f))),t=t.return}return c}function Yr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function cd(t,s,o,c,f){for(var g=s._reactName,w=[];o!==null&&o!==c;){var T=o,$=T.alternate,V=T.stateNode;if($!==null&&$===c)break;T.tag===5&&V!==null&&(T=V,f?($=Te(o,g),$!=null&&w.unshift(Ws(o,$,T))):f||($=Te(o,g),$!=null&&w.push(Ws(o,$,T)))),o=o.return}w.length!==0&&t.push({event:s,listeners:w})}var Wy=/\r\n?/g,Hy=/\u0000|\uFFFD/g;function ud(t){return(typeof t=="string"?t:""+t).replace(Wy,`
|
|
38
|
-
`).replace(Hy,"")}function Ba(t,s,o){if(s=ud(s),ud(t)!==s&&o)throw Error(a(425))}function Da(){}var Ho=null,Vo=null;function Go(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var qo=typeof setTimeout=="function"?setTimeout:void 0,Vy=typeof clearTimeout=="function"?clearTimeout:void 0,dd=typeof Promise=="function"?Promise:void 0,Gy=typeof queueMicrotask=="function"?queueMicrotask:typeof dd<"u"?function(t){return dd.resolve(null).then(t).catch(qy)}:qo;function qy(t){setTimeout(function(){throw t})}function Ko(t,s){var o=s,c=0;do{var f=o.nextSibling;if(t.removeChild(o),f&&f.nodeType===8)if(o=f.data,o==="/$"){if(c===0){t.removeChild(f),Ps(s);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=f}while(o);Ps(s)}function sr(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function fd(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(s===0)return t;s--}else o==="/$"&&s++}t=t.previousSibling}return null}var Jr=Math.random().toString(36).slice(2),In="__reactFiber$"+Jr,Hs="__reactProps$"+Jr,On="__reactContainer$"+Jr,Yo="__reactEvents$"+Jr,Ky="__reactListeners$"+Jr,Yy="__reactHandles$"+Jr;function br(t){var s=t[In];if(s)return s;for(var o=t.parentNode;o;){if(s=o[On]||o[In]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(t=fd(t);t!==null;){if(o=t[In])return o;t=fd(t)}return s}t=o,o=t.parentNode}return null}function Vs(t){return t=t[In]||t[On],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Qr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Ua(t){return t[Hs]||null}var Jo=[],Xr=-1;function ar(t){return{current:t}}function pt(t){0>Xr||(t.current=Jo[Xr],Jo[Xr]=null,Xr--)}function ft(t,s){Xr++,Jo[Xr]=t.current,t.current=s}var ir={},zt=ar(ir),Kt=ar(!1),Sr=ir;function Zr(t,s){var o=t.type.contextTypes;if(!o)return ir;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===s)return c.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in o)f[g]=s[g];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=f),f}function Yt(t){return t=t.childContextTypes,t!=null}function Wa(){pt(Kt),pt(zt)}function hd(t,s,o){if(zt.current!==ir)throw Error(a(168));ft(zt,s),ft(Kt,o)}function md(t,s,o){var c=t.stateNode;if(s=s.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var f in c)if(!(f in s))throw Error(a(108,Q(t)||"Unknown",f));return Y({},o,c)}function Ha(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||ir,Sr=zt.current,ft(zt,t),ft(Kt,Kt.current),!0}function pd(t,s,o){var c=t.stateNode;if(!c)throw Error(a(169));o?(t=md(t,s,Sr),c.__reactInternalMemoizedMergedChildContext=t,pt(Kt),pt(zt),ft(zt,t)):pt(Kt),ft(Kt,o)}var zn=null,Va=!1,Qo=!1;function gd(t){zn===null?zn=[t]:zn.push(t)}function Jy(t){Va=!0,gd(t)}function or(){if(!Qo&&zn!==null){Qo=!0;var t=0,s=lt;try{var o=zn;for(lt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}zn=null,Va=!1}catch(f){throw zn!==null&&(zn=zn.slice(t+1)),vu(xo,or),f}finally{lt=s,Qo=!1}}return null}var es=[],ts=0,Ga=null,qa=0,cn=[],un=0,kr=null,Bn=1,Dn="";function Nr(t,s){es[ts++]=qa,es[ts++]=Ga,Ga=t,qa=s}function yd(t,s,o){cn[un++]=Bn,cn[un++]=Dn,cn[un++]=kr,kr=t;var c=Bn;t=Dn;var f=32-yn(c)-1;c&=~(1<<f),o+=1;var g=32-yn(s)+f;if(30<g){var w=f-f%5;g=(c&(1<<w)-1).toString(32),c>>=w,f-=w,Bn=1<<32-yn(s)+f|o<<f|c,Dn=g+t}else Bn=1<<g|o<<f|c,Dn=t}function Xo(t){t.return!==null&&(Nr(t,1),yd(t,1,0))}function Zo(t){for(;t===Ga;)Ga=es[--ts],es[ts]=null,qa=es[--ts],es[ts]=null;for(;t===kr;)kr=cn[--un],cn[un]=null,Dn=cn[--un],cn[un]=null,Bn=cn[--un],cn[un]=null}var sn=null,an=null,vt=!1,xn=null;function vd(t,s){var o=mn(5,null,null,0);o.elementType="DELETED",o.stateNode=s,o.return=t,s=t.deletions,s===null?(t.deletions=[o],t.flags|=16):s.push(o)}function xd(t,s){switch(t.tag){case 5:var o=t.type;return s=s.nodeType!==1||o.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,sn=t,an=sr(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,sn=t,an=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(o=kr!==null?{id:Bn,overflow:Dn}:null,t.memoizedState={dehydrated:s,treeContext:o,retryLane:1073741824},o=mn(18,null,null,0),o.stateNode=s,o.return=t,t.child=o,sn=t,an=null,!0):!1;default:return!1}}function el(t){return(t.mode&1)!==0&&(t.flags&128)===0}function tl(t){if(vt){var s=an;if(s){var o=s;if(!xd(t,s)){if(el(t))throw Error(a(418));s=sr(o.nextSibling);var c=sn;s&&xd(t,s)?vd(c,o):(t.flags=t.flags&-4097|2,vt=!1,sn=t)}}else{if(el(t))throw Error(a(418));t.flags=t.flags&-4097|2,vt=!1,sn=t}}}function jd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;sn=t}function Ka(t){if(t!==sn)return!1;if(!vt)return jd(t),vt=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!Go(t.type,t.memoizedProps)),s&&(s=an)){if(el(t))throw wd(),Error(a(418));for(;s;)vd(t,s),s=sr(s.nextSibling)}if(jd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(s===0){an=sr(t.nextSibling);break e}s--}else o!=="$"&&o!=="$!"&&o!=="$?"||s++}t=t.nextSibling}an=null}}else an=sn?sr(t.stateNode.nextSibling):null;return!0}function wd(){for(var t=an;t;)t=sr(t.nextSibling)}function ns(){an=sn=null,vt=!1}function nl(t){xn===null?xn=[t]:xn.push(t)}var Qy=A.ReactCurrentBatchConfig;function Gs(t,s,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(a(309));var c=o.stateNode}if(!c)throw Error(a(147,t));var f=c,g=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===g?s.ref:(s=function(w){var T=f.refs;w===null?delete T[g]:T[g]=w},s._stringRef=g,s)}if(typeof t!="string")throw Error(a(284));if(!o._owner)throw Error(a(290,t))}return t}function Ya(t,s){throw t=Object.prototype.toString.call(s),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function bd(t){var s=t._init;return s(t._payload)}function Sd(t){function s(O,_){if(t){var D=O.deletions;D===null?(O.deletions=[_],O.flags|=16):D.push(_)}}function o(O,_){if(!t)return null;for(;_!==null;)s(O,_),_=_.sibling;return null}function c(O,_){for(O=new Map;_!==null;)_.key!==null?O.set(_.key,_):O.set(_.index,_),_=_.sibling;return O}function f(O,_){return O=pr(O,_),O.index=0,O.sibling=null,O}function g(O,_,D){return O.index=D,t?(D=O.alternate,D!==null?(D=D.index,D<_?(O.flags|=2,_):D):(O.flags|=2,_)):(O.flags|=1048576,_)}function w(O){return t&&O.alternate===null&&(O.flags|=2),O}function T(O,_,D,me){return _===null||_.tag!==6?(_=ql(D,O.mode,me),_.return=O,_):(_=f(_,D),_.return=O,_)}function $(O,_,D,me){var Pe=D.type;return Pe===H?ie(O,_,D.props.children,me,D.key):_!==null&&(_.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===Se&&bd(Pe)===_.type)?(me=f(_,D.props),me.ref=Gs(O,_,D),me.return=O,me):(me=xi(D.type,D.key,D.props,null,O.mode,me),me.ref=Gs(O,_,D),me.return=O,me)}function V(O,_,D,me){return _===null||_.tag!==4||_.stateNode.containerInfo!==D.containerInfo||_.stateNode.implementation!==D.implementation?(_=Kl(D,O.mode,me),_.return=O,_):(_=f(_,D.children||[]),_.return=O,_)}function ie(O,_,D,me,Pe){return _===null||_.tag!==7?(_=Pr(D,O.mode,me,Pe),_.return=O,_):(_=f(_,D),_.return=O,_)}function ue(O,_,D){if(typeof _=="string"&&_!==""||typeof _=="number")return _=ql(""+_,O.mode,D),_.return=O,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case z:return D=xi(_.type,_.key,_.props,null,O.mode,D),D.ref=Gs(O,null,_),D.return=O,D;case M:return _=Kl(_,O.mode,D),_.return=O,_;case Se:var me=_._init;return ue(O,me(_._payload),D)}if(Qe(_)||G(_))return _=Pr(_,O.mode,D,null),_.return=O,_;Ya(O,_)}return null}function se(O,_,D,me){var Pe=_!==null?_.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Pe!==null?null:T(O,_,""+D,me);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case z:return D.key===Pe?$(O,_,D,me):null;case M:return D.key===Pe?V(O,_,D,me):null;case Se:return Pe=D._init,se(O,_,Pe(D._payload),me)}if(Qe(D)||G(D))return Pe!==null?null:ie(O,_,D,me,null);Ya(O,D)}return null}function je(O,_,D,me,Pe){if(typeof me=="string"&&me!==""||typeof me=="number")return O=O.get(D)||null,T(_,O,""+me,Pe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case z:return O=O.get(me.key===null?D:me.key)||null,$(_,O,me,Pe);case M:return O=O.get(me.key===null?D:me.key)||null,V(_,O,me,Pe);case Se:var _e=me._init;return je(O,_,D,_e(me._payload),Pe)}if(Qe(me)||G(me))return O=O.get(D)||null,ie(_,O,me,Pe,null);Ya(_,me)}return null}function Ce(O,_,D,me){for(var Pe=null,_e=null,Le=_,Ue=_=0,_t=null;Le!==null&&Ue<D.length;Ue++){Le.index>Ue?(_t=Le,Le=null):_t=Le.sibling;var nt=se(O,Le,D[Ue],me);if(nt===null){Le===null&&(Le=_t);break}t&&Le&&nt.alternate===null&&s(O,Le),_=g(nt,_,Ue),_e===null?Pe=nt:_e.sibling=nt,_e=nt,Le=_t}if(Ue===D.length)return o(O,Le),vt&&Nr(O,Ue),Pe;if(Le===null){for(;Ue<D.length;Ue++)Le=ue(O,D[Ue],me),Le!==null&&(_=g(Le,_,Ue),_e===null?Pe=Le:_e.sibling=Le,_e=Le);return vt&&Nr(O,Ue),Pe}for(Le=c(O,Le);Ue<D.length;Ue++)_t=je(Le,O,Ue,D[Ue],me),_t!==null&&(t&&_t.alternate!==null&&Le.delete(_t.key===null?Ue:_t.key),_=g(_t,_,Ue),_e===null?Pe=_t:_e.sibling=_t,_e=_t);return t&&Le.forEach(function(gr){return s(O,gr)}),vt&&Nr(O,Ue),Pe}function Ie(O,_,D,me){var Pe=G(D);if(typeof Pe!="function")throw Error(a(150));if(D=Pe.call(D),D==null)throw Error(a(151));for(var _e=Pe=null,Le=_,Ue=_=0,_t=null,nt=D.next();Le!==null&&!nt.done;Ue++,nt=D.next()){Le.index>Ue?(_t=Le,Le=null):_t=Le.sibling;var gr=se(O,Le,nt.value,me);if(gr===null){Le===null&&(Le=_t);break}t&&Le&&gr.alternate===null&&s(O,Le),_=g(gr,_,Ue),_e===null?Pe=gr:_e.sibling=gr,_e=gr,Le=_t}if(nt.done)return o(O,Le),vt&&Nr(O,Ue),Pe;if(Le===null){for(;!nt.done;Ue++,nt=D.next())nt=ue(O,nt.value,me),nt!==null&&(_=g(nt,_,Ue),_e===null?Pe=nt:_e.sibling=nt,_e=nt);return vt&&Nr(O,Ue),Pe}for(Le=c(O,Le);!nt.done;Ue++,nt=D.next())nt=je(Le,O,Ue,nt.value,me),nt!==null&&(t&&nt.alternate!==null&&Le.delete(nt.key===null?Ue:nt.key),_=g(nt,_,Ue),_e===null?Pe=nt:_e.sibling=nt,_e=nt);return t&&Le.forEach(function(Iv){return s(O,Iv)}),vt&&Nr(O,Ue),Pe}function Et(O,_,D,me){if(typeof D=="object"&&D!==null&&D.type===H&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case z:e:{for(var Pe=D.key,_e=_;_e!==null;){if(_e.key===Pe){if(Pe=D.type,Pe===H){if(_e.tag===7){o(O,_e.sibling),_=f(_e,D.props.children),_.return=O,O=_;break e}}else if(_e.elementType===Pe||typeof Pe=="object"&&Pe!==null&&Pe.$$typeof===Se&&bd(Pe)===_e.type){o(O,_e.sibling),_=f(_e,D.props),_.ref=Gs(O,_e,D),_.return=O,O=_;break e}o(O,_e);break}else s(O,_e);_e=_e.sibling}D.type===H?(_=Pr(D.props.children,O.mode,me,D.key),_.return=O,O=_):(me=xi(D.type,D.key,D.props,null,O.mode,me),me.ref=Gs(O,_,D),me.return=O,O=me)}return w(O);case M:e:{for(_e=D.key;_!==null;){if(_.key===_e)if(_.tag===4&&_.stateNode.containerInfo===D.containerInfo&&_.stateNode.implementation===D.implementation){o(O,_.sibling),_=f(_,D.children||[]),_.return=O,O=_;break e}else{o(O,_);break}else s(O,_);_=_.sibling}_=Kl(D,O.mode,me),_.return=O,O=_}return w(O);case Se:return _e=D._init,Et(O,_,_e(D._payload),me)}if(Qe(D))return Ce(O,_,D,me);if(G(D))return Ie(O,_,D,me);Ya(O,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,_!==null&&_.tag===6?(o(O,_.sibling),_=f(_,D),_.return=O,O=_):(o(O,_),_=ql(D,O.mode,me),_.return=O,O=_),w(O)):o(O,_)}return Et}var rs=Sd(!0),kd=Sd(!1),Ja=ar(null),Qa=null,ss=null,rl=null;function sl(){rl=ss=Qa=null}function al(t){var s=Ja.current;pt(Ja),t._currentValue=s}function il(t,s,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),t===o)break;t=t.return}}function as(t,s){Qa=t,rl=ss=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(Jt=!0),t.firstContext=null)}function dn(t){var s=t._currentValue;if(rl!==t)if(t={context:t,memoizedValue:s,next:null},ss===null){if(Qa===null)throw Error(a(308));ss=t,Qa.dependencies={lanes:0,firstContext:t}}else ss=ss.next=t;return s}var Cr=null;function ol(t){Cr===null?Cr=[t]:Cr.push(t)}function Nd(t,s,o,c){var f=s.interleaved;return f===null?(o.next=o,ol(s)):(o.next=f.next,f.next=o),s.interleaved=o,Un(t,c)}function Un(t,s){t.lanes|=s;var o=t.alternate;for(o!==null&&(o.lanes|=s),o=t,t=t.return;t!==null;)t.childLanes|=s,o=t.alternate,o!==null&&(o.childLanes|=s),o=t,t=t.return;return o.tag===3?o.stateNode:null}var lr=!1;function ll(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cd(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Wn(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function cr(t,s,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(et&2)!==0){var f=c.pending;return f===null?s.next=s:(s.next=f.next,f.next=s),c.pending=s,Un(t,o)}return f=c.interleaved,f===null?(s.next=s,ol(c)):(s.next=f.next,f.next=s),c.interleaved=s,Un(t,o)}function Xa(t,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,bo(t,o)}}function Ed(t,s){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var f=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var w={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};g===null?f=g=w:g=g.next=w,o=o.next}while(o!==null);g===null?f=g=s:g=g.next=s}else f=g=s;o={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=s:t.next=s,o.lastBaseUpdate=s}function Za(t,s,o,c){var f=t.updateQueue;lr=!1;var g=f.firstBaseUpdate,w=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var $=T,V=$.next;$.next=null,w===null?g=V:w.next=V,w=$;var ie=t.alternate;ie!==null&&(ie=ie.updateQueue,T=ie.lastBaseUpdate,T!==w&&(T===null?ie.firstBaseUpdate=V:T.next=V,ie.lastBaseUpdate=$))}if(g!==null){var ue=f.baseState;w=0,ie=V=$=null,T=g;do{var se=T.lane,je=T.eventTime;if((c&se)===se){ie!==null&&(ie=ie.next={eventTime:je,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Ce=t,Ie=T;switch(se=s,je=o,Ie.tag){case 1:if(Ce=Ie.payload,typeof Ce=="function"){ue=Ce.call(je,ue,se);break e}ue=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Ie.payload,se=typeof Ce=="function"?Ce.call(je,ue,se):Ce,se==null)break e;ue=Y({},ue,se);break e;case 2:lr=!0}}T.callback!==null&&T.lane!==0&&(t.flags|=64,se=f.effects,se===null?f.effects=[T]:se.push(T))}else je={eventTime:je,lane:se,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ie===null?(V=ie=je,$=ue):ie=ie.next=je,w|=se;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;se=T,T=se.next,se.next=null,f.lastBaseUpdate=se,f.shared.pending=null}}while(!0);if(ie===null&&($=ue),f.baseState=$,f.firstBaseUpdate=V,f.lastBaseUpdate=ie,s=f.shared.interleaved,s!==null){f=s;do w|=f.lane,f=f.next;while(f!==s)}else g===null&&(f.shared.lanes=0);Ar|=w,t.lanes=w,t.memoizedState=ue}}function Td(t,s,o){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var c=t[s],f=c.callback;if(f!==null){if(c.callback=null,c=o,typeof f!="function")throw Error(a(191,f));f.call(c)}}}var qs={},Rn=ar(qs),Ks=ar(qs),Ys=ar(qs);function Er(t){if(t===qs)throw Error(a(174));return t}function cl(t,s){switch(ft(Ys,s),ft(Ks,t),ft(Rn,qs),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Ee(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=Ee(s,t)}pt(Rn),ft(Rn,s)}function is(){pt(Rn),pt(Ks),pt(Ys)}function Ad(t){Er(Ys.current);var s=Er(Rn.current),o=Ee(s,t.type);s!==o&&(ft(Ks,t),ft(Rn,o))}function ul(t){Ks.current===t&&(pt(Rn),pt(Ks))}var jt=ar(0);function ei(t){for(var s=t;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var dl=[];function fl(){for(var t=0;t<dl.length;t++)dl[t]._workInProgressVersionPrimary=null;dl.length=0}var ti=A.ReactCurrentDispatcher,hl=A.ReactCurrentBatchConfig,Tr=0,wt=null,At=null,$t=null,ni=!1,Js=!1,Qs=0,Xy=0;function Bt(){throw Error(a(321))}function ml(t,s){if(s===null)return!1;for(var o=0;o<s.length&&o<t.length;o++)if(!vn(t[o],s[o]))return!1;return!0}function pl(t,s,o,c,f,g){if(Tr=g,wt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,ti.current=t===null||t.memoizedState===null?nv:rv,t=o(c,f),Js){g=0;do{if(Js=!1,Qs=0,25<=g)throw Error(a(301));g+=1,$t=At=null,s.updateQueue=null,ti.current=sv,t=o(c,f)}while(Js)}if(ti.current=ai,s=At!==null&&At.next!==null,Tr=0,$t=At=wt=null,ni=!1,s)throw Error(a(300));return t}function gl(){var t=Qs!==0;return Qs=0,t}function $n(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?wt.memoizedState=$t=t:$t=$t.next=t,$t}function fn(){if(At===null){var t=wt.alternate;t=t!==null?t.memoizedState:null}else t=At.next;var s=$t===null?wt.memoizedState:$t.next;if(s!==null)$t=s,At=t;else{if(t===null)throw Error(a(310));At=t,t={memoizedState:At.memoizedState,baseState:At.baseState,baseQueue:At.baseQueue,queue:At.queue,next:null},$t===null?wt.memoizedState=$t=t:$t=$t.next=t}return $t}function Xs(t,s){return typeof s=="function"?s(t):s}function yl(t){var s=fn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=At,f=c.baseQueue,g=o.pending;if(g!==null){if(f!==null){var w=f.next;f.next=g.next,g.next=w}c.baseQueue=f=g,o.pending=null}if(f!==null){g=f.next,c=c.baseState;var T=w=null,$=null,V=g;do{var ie=V.lane;if((Tr&ie)===ie)$!==null&&($=$.next={lane:0,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),c=V.hasEagerState?V.eagerState:t(c,V.action);else{var ue={lane:ie,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null};$===null?(T=$=ue,w=c):$=$.next=ue,wt.lanes|=ie,Ar|=ie}V=V.next}while(V!==null&&V!==g);$===null?w=c:$.next=T,vn(c,s.memoizedState)||(Jt=!0),s.memoizedState=c,s.baseState=w,s.baseQueue=$,o.lastRenderedState=c}if(t=o.interleaved,t!==null){f=t;do g=f.lane,wt.lanes|=g,Ar|=g,f=f.next;while(f!==t)}else f===null&&(o.lanes=0);return[s.memoizedState,o.dispatch]}function vl(t){var s=fn(),o=s.queue;if(o===null)throw Error(a(311));o.lastRenderedReducer=t;var c=o.dispatch,f=o.pending,g=s.memoizedState;if(f!==null){o.pending=null;var w=f=f.next;do g=t(g,w.action),w=w.next;while(w!==f);vn(g,s.memoizedState)||(Jt=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),o.lastRenderedState=g}return[g,c]}function Id(){}function Rd(t,s){var o=wt,c=fn(),f=s(),g=!vn(c.memoizedState,f);if(g&&(c.memoizedState=f,Jt=!0),c=c.queue,xl(_d.bind(null,o,c,t),[t]),c.getSnapshot!==s||g||$t!==null&&$t.memoizedState.tag&1){if(o.flags|=2048,Zs(9,Pd.bind(null,o,c,f,s),void 0,null),Pt===null)throw Error(a(349));(Tr&30)!==0||$d(o,s,f)}return f}function $d(t,s,o){t.flags|=16384,t={getSnapshot:s,value:o},s=wt.updateQueue,s===null?(s={lastEffect:null,stores:null},wt.updateQueue=s,s.stores=[t]):(o=s.stores,o===null?s.stores=[t]:o.push(t))}function Pd(t,s,o,c){s.value=o,s.getSnapshot=c,Ld(s)&&Md(t)}function _d(t,s,o){return o(function(){Ld(s)&&Md(t)})}function Ld(t){var s=t.getSnapshot;t=t.value;try{var o=s();return!vn(t,o)}catch{return!0}}function Md(t){var s=Un(t,1);s!==null&&Sn(s,t,1,-1)}function Fd(t){var s=$n();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Xs,lastRenderedState:t},s.queue=t,t=t.dispatch=tv.bind(null,wt,t),[s.memoizedState,t]}function Zs(t,s,o,c){return t={tag:t,create:s,destroy:o,deps:c,next:null},s=wt.updateQueue,s===null?(s={lastEffect:null,stores:null},wt.updateQueue=s,s.lastEffect=t.next=t):(o=s.lastEffect,o===null?s.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,s.lastEffect=t)),t}function Od(){return fn().memoizedState}function ri(t,s,o,c){var f=$n();wt.flags|=t,f.memoizedState=Zs(1|s,o,void 0,c===void 0?null:c)}function si(t,s,o,c){var f=fn();c=c===void 0?null:c;var g=void 0;if(At!==null){var w=At.memoizedState;if(g=w.destroy,c!==null&&ml(c,w.deps)){f.memoizedState=Zs(s,o,g,c);return}}wt.flags|=t,f.memoizedState=Zs(1|s,o,g,c)}function zd(t,s){return ri(8390656,8,t,s)}function xl(t,s){return si(2048,8,t,s)}function Bd(t,s){return si(4,2,t,s)}function Dd(t,s){return si(4,4,t,s)}function Ud(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function Wd(t,s,o){return o=o!=null?o.concat([t]):null,si(4,4,Ud.bind(null,s,t),o)}function jl(){}function Hd(t,s){var o=fn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&ml(s,c[1])?c[0]:(o.memoizedState=[t,s],t)}function Vd(t,s){var o=fn();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&ml(s,c[1])?c[0]:(t=t(),o.memoizedState=[t,s],t)}function Gd(t,s,o){return(Tr&21)===0?(t.baseState&&(t.baseState=!1,Jt=!0),t.memoizedState=o):(vn(o,s)||(o=bu(),wt.lanes|=o,Ar|=o,t.baseState=!0),s)}function Zy(t,s){var o=lt;lt=o!==0&&4>o?o:4,t(!0);var c=hl.transition;hl.transition={};try{t(!1),s()}finally{lt=o,hl.transition=c}}function qd(){return fn().memoizedState}function ev(t,s,o){var c=hr(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Kd(t))Yd(s,o);else if(o=Nd(t,s,o,c),o!==null){var f=Gt();Sn(o,t,c,f),Jd(o,s,c)}}function tv(t,s,o){var c=hr(t),f={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Kd(t))Yd(s,f);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var w=s.lastRenderedState,T=g(w,o);if(f.hasEagerState=!0,f.eagerState=T,vn(T,w)){var $=s.interleaved;$===null?(f.next=f,ol(s)):(f.next=$.next,$.next=f),s.interleaved=f;return}}catch{}finally{}o=Nd(t,s,f,c),o!==null&&(f=Gt(),Sn(o,t,c,f),Jd(o,s,c))}}function Kd(t){var s=t.alternate;return t===wt||s!==null&&s===wt}function Yd(t,s){Js=ni=!0;var o=t.pending;o===null?s.next=s:(s.next=o.next,o.next=s),t.pending=s}function Jd(t,s,o){if((o&4194240)!==0){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,bo(t,o)}}var ai={readContext:dn,useCallback:Bt,useContext:Bt,useEffect:Bt,useImperativeHandle:Bt,useInsertionEffect:Bt,useLayoutEffect:Bt,useMemo:Bt,useReducer:Bt,useRef:Bt,useState:Bt,useDebugValue:Bt,useDeferredValue:Bt,useTransition:Bt,useMutableSource:Bt,useSyncExternalStore:Bt,useId:Bt,unstable_isNewReconciler:!1},nv={readContext:dn,useCallback:function(t,s){return $n().memoizedState=[t,s===void 0?null:s],t},useContext:dn,useEffect:zd,useImperativeHandle:function(t,s,o){return o=o!=null?o.concat([t]):null,ri(4194308,4,Ud.bind(null,s,t),o)},useLayoutEffect:function(t,s){return ri(4194308,4,t,s)},useInsertionEffect:function(t,s){return ri(4,2,t,s)},useMemo:function(t,s){var o=$n();return s=s===void 0?null:s,t=t(),o.memoizedState=[t,s],t},useReducer:function(t,s,o){var c=$n();return s=o!==void 0?o(s):s,c.memoizedState=c.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},c.queue=t,t=t.dispatch=ev.bind(null,wt,t),[c.memoizedState,t]},useRef:function(t){var s=$n();return t={current:t},s.memoizedState=t},useState:Fd,useDebugValue:jl,useDeferredValue:function(t){return $n().memoizedState=t},useTransition:function(){var t=Fd(!1),s=t[0];return t=Zy.bind(null,t[1]),$n().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,o){var c=wt,f=$n();if(vt){if(o===void 0)throw Error(a(407));o=o()}else{if(o=s(),Pt===null)throw Error(a(349));(Tr&30)!==0||$d(c,s,o)}f.memoizedState=o;var g={value:o,getSnapshot:s};return f.queue=g,zd(_d.bind(null,c,g,t),[t]),c.flags|=2048,Zs(9,Pd.bind(null,c,g,o,s),void 0,null),o},useId:function(){var t=$n(),s=Pt.identifierPrefix;if(vt){var o=Dn,c=Bn;o=(c&~(1<<32-yn(c)-1)).toString(32)+o,s=":"+s+"R"+o,o=Qs++,0<o&&(s+="H"+o.toString(32)),s+=":"}else o=Xy++,s=":"+s+"r"+o.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},rv={readContext:dn,useCallback:Hd,useContext:dn,useEffect:xl,useImperativeHandle:Wd,useInsertionEffect:Bd,useLayoutEffect:Dd,useMemo:Vd,useReducer:yl,useRef:Od,useState:function(){return yl(Xs)},useDebugValue:jl,useDeferredValue:function(t){var s=fn();return Gd(s,At.memoizedState,t)},useTransition:function(){var t=yl(Xs)[0],s=fn().memoizedState;return[t,s]},useMutableSource:Id,useSyncExternalStore:Rd,useId:qd,unstable_isNewReconciler:!1},sv={readContext:dn,useCallback:Hd,useContext:dn,useEffect:xl,useImperativeHandle:Wd,useInsertionEffect:Bd,useLayoutEffect:Dd,useMemo:Vd,useReducer:vl,useRef:Od,useState:function(){return vl(Xs)},useDebugValue:jl,useDeferredValue:function(t){var s=fn();return At===null?s.memoizedState=t:Gd(s,At.memoizedState,t)},useTransition:function(){var t=vl(Xs)[0],s=fn().memoizedState;return[t,s]},useMutableSource:Id,useSyncExternalStore:Rd,useId:qd,unstable_isNewReconciler:!1};function jn(t,s){if(t&&t.defaultProps){s=Y({},s),t=t.defaultProps;for(var o in t)s[o]===void 0&&(s[o]=t[o]);return s}return s}function wl(t,s,o,c){s=t.memoizedState,o=o(c,s),o=o==null?s:Y({},s,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var ii={isMounted:function(t){return(t=t._reactInternals)?En(t)===t:!1},enqueueSetState:function(t,s,o){t=t._reactInternals;var c=Gt(),f=hr(t),g=Wn(c,f);g.payload=s,o!=null&&(g.callback=o),s=cr(t,g,f),s!==null&&(Sn(s,t,f,c),Xa(s,t,f))},enqueueReplaceState:function(t,s,o){t=t._reactInternals;var c=Gt(),f=hr(t),g=Wn(c,f);g.tag=1,g.payload=s,o!=null&&(g.callback=o),s=cr(t,g,f),s!==null&&(Sn(s,t,f,c),Xa(s,t,f))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var o=Gt(),c=hr(t),f=Wn(o,c);f.tag=2,s!=null&&(f.callback=s),s=cr(t,f,c),s!==null&&(Sn(s,t,c,o),Xa(s,t,c))}};function Qd(t,s,o,c,f,g,w){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,w):s.prototype&&s.prototype.isPureReactComponent?!zs(o,c)||!zs(f,g):!0}function Xd(t,s,o){var c=!1,f=ir,g=s.contextType;return typeof g=="object"&&g!==null?g=dn(g):(f=Yt(s)?Sr:zt.current,c=s.contextTypes,g=(c=c!=null)?Zr(t,f):ir),s=new s(o,g),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=ii,t.stateNode=s,s._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=f,t.__reactInternalMemoizedMaskedChildContext=g),s}function Zd(t,s,o,c){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,c),s.state!==t&&ii.enqueueReplaceState(s,s.state,null)}function bl(t,s,o,c){var f=t.stateNode;f.props=o,f.state=t.memoizedState,f.refs={},ll(t);var g=s.contextType;typeof g=="object"&&g!==null?f.context=dn(g):(g=Yt(s)?Sr:zt.current,f.context=Zr(t,g)),f.state=t.memoizedState,g=s.getDerivedStateFromProps,typeof g=="function"&&(wl(t,s,g,o),f.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(s=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),s!==f.state&&ii.enqueueReplaceState(f,f.state,null),Za(t,o,f,c),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308)}function os(t,s){try{var o="",c=s;do o+=we(c),c=c.return;while(c);var f=o}catch(g){f=`
|
|
39
|
-
Error generating stack: `+g.message+`
|
|
40
|
-
`+g.stack}return{value:t,source:s,stack:f,digest:null}}function Sl(t,s,o){return{value:t,source:null,stack:o??null,digest:s??null}}function kl(t,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var av=typeof WeakMap=="function"?WeakMap:Map;function ef(t,s,o){o=Wn(-1,o),o.tag=3,o.payload={element:null};var c=s.value;return o.callback=function(){hi||(hi=!0,zl=c),kl(t,s)},o}function tf(t,s,o){o=Wn(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var f=s.value;o.payload=function(){return c(f)},o.callback=function(){kl(t,s)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(o.callback=function(){kl(t,s),typeof c!="function"&&(dr===null?dr=new Set([this]):dr.add(this));var w=s.stack;this.componentDidCatch(s.value,{componentStack:w!==null?w:""})}),o}function nf(t,s,o){var c=t.pingCache;if(c===null){c=t.pingCache=new av;var f=new Set;c.set(s,f)}else f=c.get(s),f===void 0&&(f=new Set,c.set(s,f));f.has(o)||(f.add(o),t=xv.bind(null,t,s,o),s.then(t,t))}function rf(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function sf(t,s,o,c,f){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=Wn(-1,1),s.tag=2,cr(o,s,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=f,t)}var iv=A.ReactCurrentOwner,Jt=!1;function Vt(t,s,o,c){s.child=t===null?kd(s,null,o,c):rs(s,t.child,o,c)}function af(t,s,o,c,f){o=o.render;var g=s.ref;return as(s,f),c=pl(t,s,o,c,g,f),o=gl(),t!==null&&!Jt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,Hn(t,s,f)):(vt&&o&&Xo(s),s.flags|=1,Vt(t,s,c,f),s.child)}function of(t,s,o,c,f){if(t===null){var g=o.type;return typeof g=="function"&&!Gl(g)&&g.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=g,lf(t,s,g,c,f)):(t=xi(o.type,null,c,s,s.mode,f),t.ref=s.ref,t.return=s,s.child=t)}if(g=t.child,(t.lanes&f)===0){var w=g.memoizedProps;if(o=o.compare,o=o!==null?o:zs,o(w,c)&&t.ref===s.ref)return Hn(t,s,f)}return s.flags|=1,t=pr(g,c),t.ref=s.ref,t.return=s,s.child=t}function lf(t,s,o,c,f){if(t!==null){var g=t.memoizedProps;if(zs(g,c)&&t.ref===s.ref)if(Jt=!1,s.pendingProps=c=g,(t.lanes&f)!==0)(t.flags&131072)!==0&&(Jt=!0);else return s.lanes=t.lanes,Hn(t,s,f)}return Nl(t,s,o,c,f)}function cf(t,s,o){var c=s.pendingProps,f=c.children,g=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},ft(cs,on),on|=o;else{if((o&1073741824)===0)return t=g!==null?g.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,ft(cs,on),on|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:o,ft(cs,on),on|=c}else g!==null?(c=g.baseLanes|o,s.memoizedState=null):c=o,ft(cs,on),on|=c;return Vt(t,s,f,o),s.child}function uf(t,s){var o=s.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function Nl(t,s,o,c,f){var g=Yt(o)?Sr:zt.current;return g=Zr(s,g),as(s,f),o=pl(t,s,o,c,g,f),c=gl(),t!==null&&!Jt?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~f,Hn(t,s,f)):(vt&&c&&Xo(s),s.flags|=1,Vt(t,s,o,f),s.child)}function df(t,s,o,c,f){if(Yt(o)){var g=!0;Ha(s)}else g=!1;if(as(s,f),s.stateNode===null)li(t,s),Xd(s,o,c),bl(s,o,c,f),c=!0;else if(t===null){var w=s.stateNode,T=s.memoizedProps;w.props=T;var $=w.context,V=o.contextType;typeof V=="object"&&V!==null?V=dn(V):(V=Yt(o)?Sr:zt.current,V=Zr(s,V));var ie=o.getDerivedStateFromProps,ue=typeof ie=="function"||typeof w.getSnapshotBeforeUpdate=="function";ue||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(T!==c||$!==V)&&Zd(s,w,c,V),lr=!1;var se=s.memoizedState;w.state=se,Za(s,c,w,f),$=s.memoizedState,T!==c||se!==$||Kt.current||lr?(typeof ie=="function"&&(wl(s,o,ie,c),$=s.memoizedState),(T=lr||Qd(s,o,T,c,se,$,V))?(ue||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(s.flags|=4194308)):(typeof w.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=$),w.props=c,w.state=$,w.context=V,c=T):(typeof w.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{w=s.stateNode,Cd(t,s),T=s.memoizedProps,V=s.type===s.elementType?T:jn(s.type,T),w.props=V,ue=s.pendingProps,se=w.context,$=o.contextType,typeof $=="object"&&$!==null?$=dn($):($=Yt(o)?Sr:zt.current,$=Zr(s,$));var je=o.getDerivedStateFromProps;(ie=typeof je=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(T!==ue||se!==$)&&Zd(s,w,c,$),lr=!1,se=s.memoizedState,w.state=se,Za(s,c,w,f);var Ce=s.memoizedState;T!==ue||se!==Ce||Kt.current||lr?(typeof je=="function"&&(wl(s,o,je,c),Ce=s.memoizedState),(V=lr||Qd(s,o,V,c,se,Ce,$)||!1)?(ie||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,Ce,$),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,Ce,$)),typeof w.componentDidUpdate=="function"&&(s.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof w.componentDidUpdate!="function"||T===t.memoizedProps&&se===t.memoizedState||(s.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===t.memoizedProps&&se===t.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=Ce),w.props=c,w.state=Ce,w.context=$,c=V):(typeof w.componentDidUpdate!="function"||T===t.memoizedProps&&se===t.memoizedState||(s.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===t.memoizedProps&&se===t.memoizedState||(s.flags|=1024),c=!1)}return Cl(t,s,o,c,g,f)}function Cl(t,s,o,c,f,g){uf(t,s);var w=(s.flags&128)!==0;if(!c&&!w)return f&&pd(s,o,!1),Hn(t,s,g);c=s.stateNode,iv.current=s;var T=w&&typeof o.getDerivedStateFromError!="function"?null:c.render();return s.flags|=1,t!==null&&w?(s.child=rs(s,t.child,null,g),s.child=rs(s,null,T,g)):Vt(t,s,T,g),s.memoizedState=c.state,f&&pd(s,o,!0),s.child}function ff(t){var s=t.stateNode;s.pendingContext?hd(t,s.pendingContext,s.pendingContext!==s.context):s.context&&hd(t,s.context,!1),cl(t,s.containerInfo)}function hf(t,s,o,c,f){return ns(),nl(f),s.flags|=256,Vt(t,s,o,c),s.child}var El={dehydrated:null,treeContext:null,retryLane:0};function Tl(t){return{baseLanes:t,cachePool:null,transitions:null}}function mf(t,s,o){var c=s.pendingProps,f=jt.current,g=!1,w=(s.flags&128)!==0,T;if((T=w)||(T=t!==null&&t.memoizedState===null?!1:(f&2)!==0),T?(g=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(f|=1),ft(jt,f&1),t===null)return tl(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(w=c.children,t=c.fallback,g?(c=s.mode,g=s.child,w={mode:"hidden",children:w},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=w):g=ji(w,c,0,null),t=Pr(t,c,o,null),g.return=s,t.return=s,g.sibling=t,s.child=g,s.child.memoizedState=Tl(o),s.memoizedState=El,t):Al(s,w));if(f=t.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return ov(t,s,w,c,T,f,o);if(g){g=c.fallback,w=s.mode,f=t.child,T=f.sibling;var $={mode:"hidden",children:c.children};return(w&1)===0&&s.child!==f?(c=s.child,c.childLanes=0,c.pendingProps=$,s.deletions=null):(c=pr(f,$),c.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=pr(T,g):(g=Pr(g,w,o,null),g.flags|=2),g.return=s,c.return=s,c.sibling=g,s.child=c,c=g,g=s.child,w=t.child.memoizedState,w=w===null?Tl(o):{baseLanes:w.baseLanes|o,cachePool:null,transitions:w.transitions},g.memoizedState=w,g.childLanes=t.childLanes&~o,s.memoizedState=El,c}return g=t.child,t=g.sibling,c=pr(g,{mode:"visible",children:c.children}),(s.mode&1)===0&&(c.lanes=o),c.return=s,c.sibling=null,t!==null&&(o=s.deletions,o===null?(s.deletions=[t],s.flags|=16):o.push(t)),s.child=c,s.memoizedState=null,c}function Al(t,s){return s=ji({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function oi(t,s,o,c){return c!==null&&nl(c),rs(s,t.child,null,o),t=Al(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function ov(t,s,o,c,f,g,w){if(o)return s.flags&256?(s.flags&=-257,c=Sl(Error(a(422))),oi(t,s,w,c)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(g=c.fallback,f=s.mode,c=ji({mode:"visible",children:c.children},f,0,null),g=Pr(g,f,w,null),g.flags|=2,c.return=s,g.return=s,c.sibling=g,s.child=c,(s.mode&1)!==0&&rs(s,t.child,null,w),s.child.memoizedState=Tl(w),s.memoizedState=El,g);if((s.mode&1)===0)return oi(t,s,w,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var T=c.dgst;return c=T,g=Error(a(419)),c=Sl(g,c,void 0),oi(t,s,w,c)}if(T=(w&t.childLanes)!==0,Jt||T){if(c=Pt,c!==null){switch(w&-w){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(c.suspendedLanes|w))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,Un(t,f),Sn(c,t,f,-1))}return Vl(),c=Sl(Error(a(421))),oi(t,s,w,c)}return f.data==="$?"?(s.flags|=128,s.child=t.child,s=jv.bind(null,t),f._reactRetry=s,null):(t=g.treeContext,an=sr(f.nextSibling),sn=s,vt=!0,xn=null,t!==null&&(cn[un++]=Bn,cn[un++]=Dn,cn[un++]=kr,Bn=t.id,Dn=t.overflow,kr=s),s=Al(s,c.children),s.flags|=4096,s)}function pf(t,s,o){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s),il(t.return,s,o)}function Il(t,s,o,c,f){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:f}:(g.isBackwards=s,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=o,g.tailMode=f)}function gf(t,s,o){var c=s.pendingProps,f=c.revealOrder,g=c.tail;if(Vt(t,s,c.children,o),c=jt.current,(c&2)!==0)c=c&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&pf(t,o,s);else if(t.tag===19)pf(t,o,s);else if(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}c&=1}if(ft(jt,c),(s.mode&1)===0)s.memoizedState=null;else switch(f){case"forwards":for(o=s.child,f=null;o!==null;)t=o.alternate,t!==null&&ei(t)===null&&(f=o),o=o.sibling;o=f,o===null?(f=s.child,s.child=null):(f=o.sibling,o.sibling=null),Il(s,!1,f,o,g);break;case"backwards":for(o=null,f=s.child,s.child=null;f!==null;){if(t=f.alternate,t!==null&&ei(t)===null){s.child=f;break}t=f.sibling,f.sibling=o,o=f,f=t}Il(s,!0,o,null,g);break;case"together":Il(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function li(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function Hn(t,s,o){if(t!==null&&(s.dependencies=t.dependencies),Ar|=s.lanes,(o&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(a(153));if(s.child!==null){for(t=s.child,o=pr(t,t.pendingProps),s.child=o,o.return=s;t.sibling!==null;)t=t.sibling,o=o.sibling=pr(t,t.pendingProps),o.return=s;o.sibling=null}return s.child}function lv(t,s,o){switch(s.tag){case 3:ff(s),ns();break;case 5:Ad(s);break;case 1:Yt(s.type)&&Ha(s);break;case 4:cl(s,s.stateNode.containerInfo);break;case 10:var c=s.type._context,f=s.memoizedProps.value;ft(Ja,c._currentValue),c._currentValue=f;break;case 13:if(c=s.memoizedState,c!==null)return c.dehydrated!==null?(ft(jt,jt.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?mf(t,s,o):(ft(jt,jt.current&1),t=Hn(t,s,o),t!==null?t.sibling:null);ft(jt,jt.current&1);break;case 19:if(c=(o&s.childLanes)!==0,(t.flags&128)!==0){if(c)return gf(t,s,o);s.flags|=128}if(f=s.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),ft(jt,jt.current),c)break;return null;case 22:case 23:return s.lanes=0,cf(t,s,o)}return Hn(t,s,o)}var yf,Rl,vf,xf;yf=function(t,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},Rl=function(){},vf=function(t,s,o,c){var f=t.memoizedProps;if(f!==c){t=s.stateNode,Er(Rn.current);var g=null;switch(o){case"input":f=We(t,f),c=We(t,c),g=[];break;case"select":f=Y({},f,{value:void 0}),c=Y({},c,{value:void 0}),g=[];break;case"textarea":f=gt(t,f),c=gt(t,c),g=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Da)}qe(o,c);var w;o=null;for(V in f)if(!c.hasOwnProperty(V)&&f.hasOwnProperty(V)&&f[V]!=null)if(V==="style"){var T=f[V];for(w in T)T.hasOwnProperty(w)&&(o||(o={}),o[w]="")}else V!=="dangerouslySetInnerHTML"&&V!=="children"&&V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(l.hasOwnProperty(V)?g||(g=[]):(g=g||[]).push(V,null));for(V in c){var $=c[V];if(T=f!=null?f[V]:void 0,c.hasOwnProperty(V)&&$!==T&&($!=null||T!=null))if(V==="style")if(T){for(w in T)!T.hasOwnProperty(w)||$&&$.hasOwnProperty(w)||(o||(o={}),o[w]="");for(w in $)$.hasOwnProperty(w)&&T[w]!==$[w]&&(o||(o={}),o[w]=$[w])}else o||(g||(g=[]),g.push(V,o)),o=$;else V==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,T=T?T.__html:void 0,$!=null&&T!==$&&(g=g||[]).push(V,$)):V==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(V,""+$):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&(l.hasOwnProperty(V)?($!=null&&V==="onScroll"&&mt("scroll",t),g||T===$||(g=[])):(g=g||[]).push(V,$))}o&&(g=g||[]).push("style",o);var V=g;(s.updateQueue=V)&&(s.flags|=4)}},xf=function(t,s,o,c){o!==c&&(s.flags|=4)};function ea(t,s){if(!vt)switch(t.tailMode){case"hidden":s=t.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Dt(t){var s=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(s)for(var f=t.child;f!==null;)o|=f.lanes|f.childLanes,c|=f.subtreeFlags&14680064,c|=f.flags&14680064,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)o|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=c,t.childLanes=o,s}function cv(t,s,o){var c=s.pendingProps;switch(Zo(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Dt(s),null;case 1:return Yt(s.type)&&Wa(),Dt(s),null;case 3:return c=s.stateNode,is(),pt(Kt),pt(zt),fl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ka(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,xn!==null&&(Ul(xn),xn=null))),Rl(t,s),Dt(s),null;case 5:ul(s);var f=Er(Ys.current);if(o=s.type,t!==null&&s.stateNode!=null)vf(t,s,o,c,f),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!c){if(s.stateNode===null)throw Error(a(166));return Dt(s),null}if(t=Er(Rn.current),Ka(s)){c=s.stateNode,o=s.type;var g=s.memoizedProps;switch(c[In]=s,c[Hs]=g,t=(s.mode&1)!==0,o){case"dialog":mt("cancel",c),mt("close",c);break;case"iframe":case"object":case"embed":mt("load",c);break;case"video":case"audio":for(f=0;f<Ds.length;f++)mt(Ds[f],c);break;case"source":mt("error",c);break;case"img":case"image":case"link":mt("error",c),mt("load",c);break;case"details":mt("toggle",c);break;case"input":Re(c,g),mt("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},mt("invalid",c);break;case"textarea":st(c,g),mt("invalid",c)}qe(o,g),f=null;for(var w in g)if(g.hasOwnProperty(w)){var T=g[w];w==="children"?typeof T=="string"?c.textContent!==T&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,T,t),f=["children",T]):typeof T=="number"&&c.textContent!==""+T&&(g.suppressHydrationWarning!==!0&&Ba(c.textContent,T,t),f=["children",""+T]):l.hasOwnProperty(w)&&T!=null&&w==="onScroll"&&mt("scroll",c)}switch(o){case"input":Be(c),ct(c,g,!0);break;case"textarea":Be(c),J(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=Da)}c=f,s.updateQueue=c,c!==null&&(s.flags|=4)}else{w=f.nodeType===9?f:f.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=ge(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=w.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=w.createElement(o,{is:c.is}):(t=w.createElement(o),o==="select"&&(w=t,c.multiple?w.multiple=!0:c.size&&(w.size=c.size))):t=w.createElementNS(t,o),t[In]=s,t[Hs]=c,yf(t,s,!1,!1),s.stateNode=t;e:{switch(w=W(o,c),o){case"dialog":mt("cancel",t),mt("close",t),f=c;break;case"iframe":case"object":case"embed":mt("load",t),f=c;break;case"video":case"audio":for(f=0;f<Ds.length;f++)mt(Ds[f],t);f=c;break;case"source":mt("error",t),f=c;break;case"img":case"image":case"link":mt("error",t),mt("load",t),f=c;break;case"details":mt("toggle",t),f=c;break;case"input":Re(t,c),f=We(t,c),mt("invalid",t);break;case"option":f=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},f=Y({},c,{value:void 0}),mt("invalid",t);break;case"textarea":st(t,c),f=gt(t,c),mt("invalid",t);break;default:f=c}qe(o,f),T=f;for(g in T)if(T.hasOwnProperty(g)){var $=T[g];g==="style"?yt(t,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&he(t,$)):g==="children"?typeof $=="string"?(o!=="textarea"||$!=="")&&Fe(t,$):typeof $=="number"&&Fe(t,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(l.hasOwnProperty(g)?$!=null&&g==="onScroll"&&mt("scroll",t):$!=null&&R(t,g,$,w))}switch(o){case"input":Be(t),ct(t,c,!1);break;case"textarea":Be(t),J(t);break;case"option":c.value!=null&&t.setAttribute("value",""+de(c.value));break;case"select":t.multiple=!!c.multiple,g=c.value,g!=null?De(t,!!c.multiple,g,!1):c.defaultValue!=null&&De(t,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(t.onclick=Da)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Dt(s),null;case 6:if(t&&s.stateNode!=null)xf(t,s,t.memoizedProps,c);else{if(typeof c!="string"&&s.stateNode===null)throw Error(a(166));if(o=Er(Ys.current),Er(Rn.current),Ka(s)){if(c=s.stateNode,o=s.memoizedProps,c[In]=s,(g=c.nodeValue!==o)&&(t=sn,t!==null))switch(t.tag){case 3:Ba(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ba(c.nodeValue,o,(t.mode&1)!==0)}g&&(s.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[In]=s,s.stateNode=c}return Dt(s),null;case 13:if(pt(jt),c=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(vt&&an!==null&&(s.mode&1)!==0&&(s.flags&128)===0)wd(),ns(),s.flags|=98560,g=!1;else if(g=Ka(s),c!==null&&c.dehydrated!==null){if(t===null){if(!g)throw Error(a(318));if(g=s.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(a(317));g[In]=s}else ns(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Dt(s),g=!1}else xn!==null&&(Ul(xn),xn=null),g=!0;if(!g)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=o,s):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(jt.current&1)!==0?It===0&&(It=3):Vl())),s.updateQueue!==null&&(s.flags|=4),Dt(s),null);case 4:return is(),Rl(t,s),t===null&&Us(s.stateNode.containerInfo),Dt(s),null;case 10:return al(s.type._context),Dt(s),null;case 17:return Yt(s.type)&&Wa(),Dt(s),null;case 19:if(pt(jt),g=s.memoizedState,g===null)return Dt(s),null;if(c=(s.flags&128)!==0,w=g.rendering,w===null)if(c)ea(g,!1);else{if(It!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(w=ei(t),w!==null){for(s.flags|=128,ea(g,!1),c=w.updateQueue,c!==null&&(s.updateQueue=c,s.flags|=4),s.subtreeFlags=0,c=o,o=s.child;o!==null;)g=o,t=c,g.flags&=14680066,w=g.alternate,w===null?(g.childLanes=0,g.lanes=t,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=w.childLanes,g.lanes=w.lanes,g.child=w.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=w.memoizedProps,g.memoizedState=w.memoizedState,g.updateQueue=w.updateQueue,g.type=w.type,t=w.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return ft(jt,jt.current&1|2),s.child}t=t.sibling}g.tail!==null&&Ct()>us&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304)}else{if(!c)if(t=ei(w),t!==null){if(s.flags|=128,c=!0,o=t.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),ea(g,!0),g.tail===null&&g.tailMode==="hidden"&&!w.alternate&&!vt)return Dt(s),null}else 2*Ct()-g.renderingStartTime>us&&o!==1073741824&&(s.flags|=128,c=!0,ea(g,!1),s.lanes=4194304);g.isBackwards?(w.sibling=s.child,s.child=w):(o=g.last,o!==null?o.sibling=w:s.child=w,g.last=w)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=Ct(),s.sibling=null,o=jt.current,ft(jt,c?o&1|2:o&1),s):(Dt(s),null);case 22:case 23:return Hl(),c=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(s.flags|=8192),c&&(s.mode&1)!==0?(on&1073741824)!==0&&(Dt(s),s.subtreeFlags&6&&(s.flags|=8192)):Dt(s),null;case 24:return null;case 25:return null}throw Error(a(156,s.tag))}function uv(t,s){switch(Zo(s),s.tag){case 1:return Yt(s.type)&&Wa(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return is(),pt(Kt),pt(zt),fl(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return ul(s),null;case 13:if(pt(jt),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(a(340));ns()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return pt(jt),null;case 4:return is(),null;case 10:return al(s.type._context),null;case 22:case 23:return Hl(),null;case 24:return null;default:return null}}var ci=!1,Ut=!1,dv=typeof WeakSet=="function"?WeakSet:Set,ke=null;function ls(t,s){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){St(t,s,c)}else o.current=null}function $l(t,s,o){try{o()}catch(c){St(t,s,c)}}var jf=!1;function fv(t,s){if(Ho=Aa,t=Qu(),Mo(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var w=0,T=-1,$=-1,V=0,ie=0,ue=t,se=null;t:for(;;){for(var je;ue!==o||f!==0&&ue.nodeType!==3||(T=w+f),ue!==g||c!==0&&ue.nodeType!==3||($=w+c),ue.nodeType===3&&(w+=ue.nodeValue.length),(je=ue.firstChild)!==null;)se=ue,ue=je;for(;;){if(ue===t)break t;if(se===o&&++V===f&&(T=w),se===g&&++ie===c&&($=w),(je=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=je}o=T===-1||$===-1?null:{start:T,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(Vo={focusedElem:t,selectionRange:o},Aa=!1,ke=s;ke!==null;)if(s=ke,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,ke=t;else for(;ke!==null;){s=ke;try{var Ce=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Ie=Ce.memoizedProps,Et=Ce.memoizedState,O=s.stateNode,_=O.getSnapshotBeforeUpdate(s.elementType===s.type?Ie:jn(s.type,Ie),Et);O.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var D=s.stateNode.containerInfo;D.nodeType===1?D.textContent="":D.nodeType===9&&D.documentElement&&D.removeChild(D.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(me){St(s,s.return,me)}if(t=s.sibling,t!==null){t.return=s.return,ke=t;break}ke=s.return}return Ce=jf,jf=!1,Ce}function ta(t,s,o){var c=s.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&t)===t){var g=f.destroy;f.destroy=void 0,g!==void 0&&$l(s,o,g)}f=f.next}while(f!==c)}}function ui(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==s)}}function Pl(t){var s=t.ref;if(s!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof s=="function"?s(t):s.current=t}}function wf(t){var s=t.alternate;s!==null&&(t.alternate=null,wf(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[In],delete s[Hs],delete s[Yo],delete s[Ky],delete s[Yy])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function bf(t){return t.tag===5||t.tag===3||t.tag===4}function Sf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||bf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function _l(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(t,s):o.insertBefore(t,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(t,o)):(s=o,s.appendChild(t)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Da));else if(c!==4&&(t=t.child,t!==null))for(_l(t,s,o),t=t.sibling;t!==null;)_l(t,s,o),t=t.sibling}function Ll(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.insertBefore(t,s):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Ll(t,s,o),t=t.sibling;t!==null;)Ll(t,s,o),t=t.sibling}var Mt=null,wn=!1;function ur(t,s,o){for(o=o.child;o!==null;)kf(t,s,o),o=o.sibling}function kf(t,s,o){if(An&&typeof An.onCommitFiberUnmount=="function")try{An.onCommitFiberUnmount(Sa,o)}catch{}switch(o.tag){case 5:Ut||ls(o,s);case 6:var c=Mt,f=wn;Mt=null,ur(t,s,o),Mt=c,wn=f,Mt!==null&&(wn?(t=Mt,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):Mt.removeChild(o.stateNode));break;case 18:Mt!==null&&(wn?(t=Mt,o=o.stateNode,t.nodeType===8?Ko(t.parentNode,o):t.nodeType===1&&Ko(t,o),Ps(t)):Ko(Mt,o.stateNode));break;case 4:c=Mt,f=wn,Mt=o.stateNode.containerInfo,wn=!0,ur(t,s,o),Mt=c,wn=f;break;case 0:case 11:case 14:case 15:if(!Ut&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var g=f,w=g.destroy;g=g.tag,w!==void 0&&((g&2)!==0||(g&4)!==0)&&$l(o,s,w),f=f.next}while(f!==c)}ur(t,s,o);break;case 1:if(!Ut&&(ls(o,s),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(T){St(o,s,T)}ur(t,s,o);break;case 21:ur(t,s,o);break;case 22:o.mode&1?(Ut=(c=Ut)||o.memoizedState!==null,ur(t,s,o),Ut=c):ur(t,s,o);break;default:ur(t,s,o)}}function Nf(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new dv),s.forEach(function(c){var f=wv.bind(null,t,c);o.has(c)||(o.add(c),c.then(f,f))})}}function bn(t,s){var o=s.deletions;if(o!==null)for(var c=0;c<o.length;c++){var f=o[c];try{var g=t,w=s,T=w;e:for(;T!==null;){switch(T.tag){case 5:Mt=T.stateNode,wn=!1;break e;case 3:Mt=T.stateNode.containerInfo,wn=!0;break e;case 4:Mt=T.stateNode.containerInfo,wn=!0;break e}T=T.return}if(Mt===null)throw Error(a(160));kf(g,w,f),Mt=null,wn=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(V){St(f,s,V)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Cf(s,t),s=s.sibling}function Cf(t,s){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(bn(s,t),Pn(t),c&4){try{ta(3,t,t.return),ui(3,t)}catch(Ie){St(t,t.return,Ie)}try{ta(5,t,t.return)}catch(Ie){St(t,t.return,Ie)}}break;case 1:bn(s,t),Pn(t),c&512&&o!==null&&ls(o,o.return);break;case 5:if(bn(s,t),Pn(t),c&512&&o!==null&&ls(o,o.return),t.flags&32){var f=t.stateNode;try{Fe(f,"")}catch(Ie){St(t,t.return,Ie)}}if(c&4&&(f=t.stateNode,f!=null)){var g=t.memoizedProps,w=o!==null?o.memoizedProps:g,T=t.type,$=t.updateQueue;if(t.updateQueue=null,$!==null)try{T==="input"&&g.type==="radio"&&g.name!=null&&ze(f,g),W(T,w);var V=W(T,g);for(w=0;w<$.length;w+=2){var ie=$[w],ue=$[w+1];ie==="style"?yt(f,ue):ie==="dangerouslySetInnerHTML"?he(f,ue):ie==="children"?Fe(f,ue):R(f,ie,ue,V)}switch(T){case"input":Ve(f,g);break;case"textarea":Oe(f,g);break;case"select":var se=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var je=g.value;je!=null?De(f,!!g.multiple,je,!1):se!==!!g.multiple&&(g.defaultValue!=null?De(f,!!g.multiple,g.defaultValue,!0):De(f,!!g.multiple,g.multiple?[]:"",!1))}f[Hs]=g}catch(Ie){St(t,t.return,Ie)}}break;case 6:if(bn(s,t),Pn(t),c&4){if(t.stateNode===null)throw Error(a(162));f=t.stateNode,g=t.memoizedProps;try{f.nodeValue=g}catch(Ie){St(t,t.return,Ie)}}break;case 3:if(bn(s,t),Pn(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{Ps(s.containerInfo)}catch(Ie){St(t,t.return,Ie)}break;case 4:bn(s,t),Pn(t);break;case 13:bn(s,t),Pn(t),f=t.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Ol=Ct())),c&4&&Nf(t);break;case 22:if(ie=o!==null&&o.memoizedState!==null,t.mode&1?(Ut=(V=Ut)||ie,bn(s,t),Ut=V):bn(s,t),Pn(t),c&8192){if(V=t.memoizedState!==null,(t.stateNode.isHidden=V)&&!ie&&(t.mode&1)!==0)for(ke=t,ie=t.child;ie!==null;){for(ue=ke=ie;ke!==null;){switch(se=ke,je=se.child,se.tag){case 0:case 11:case 14:case 15:ta(4,se,se.return);break;case 1:ls(se,se.return);var Ce=se.stateNode;if(typeof Ce.componentWillUnmount=="function"){c=se,o=se.return;try{s=c,Ce.props=s.memoizedProps,Ce.state=s.memoizedState,Ce.componentWillUnmount()}catch(Ie){St(c,o,Ie)}}break;case 5:ls(se,se.return);break;case 22:if(se.memoizedState!==null){Af(ue);continue}}je!==null?(je.return=se,ke=je):Af(ue)}ie=ie.sibling}e:for(ie=null,ue=t;;){if(ue.tag===5){if(ie===null){ie=ue;try{f=ue.stateNode,V?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(T=ue.stateNode,$=ue.memoizedProps.style,w=$!=null&&$.hasOwnProperty("display")?$.display:null,T.style.display=at("display",w))}catch(Ie){St(t,t.return,Ie)}}}else if(ue.tag===6){if(ie===null)try{ue.stateNode.nodeValue=V?"":ue.memoizedProps}catch(Ie){St(t,t.return,Ie)}}else if((ue.tag!==22&&ue.tag!==23||ue.memoizedState===null||ue===t)&&ue.child!==null){ue.child.return=ue,ue=ue.child;continue}if(ue===t)break e;for(;ue.sibling===null;){if(ue.return===null||ue.return===t)break e;ie===ue&&(ie=null),ue=ue.return}ie===ue&&(ie=null),ue.sibling.return=ue.return,ue=ue.sibling}}break;case 19:bn(s,t),Pn(t),c&4&&Nf(t);break;case 21:break;default:bn(s,t),Pn(t)}}function Pn(t){var s=t.flags;if(s&2){try{e:{for(var o=t.return;o!==null;){if(bf(o)){var c=o;break e}o=o.return}throw Error(a(160))}switch(c.tag){case 5:var f=c.stateNode;c.flags&32&&(Fe(f,""),c.flags&=-33);var g=Sf(t);Ll(t,g,f);break;case 3:case 4:var w=c.stateNode.containerInfo,T=Sf(t);_l(t,T,w);break;default:throw Error(a(161))}}catch($){St(t,t.return,$)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function hv(t,s,o){ke=t,Ef(t)}function Ef(t,s,o){for(var c=(t.mode&1)!==0;ke!==null;){var f=ke,g=f.child;if(f.tag===22&&c){var w=f.memoizedState!==null||ci;if(!w){var T=f.alternate,$=T!==null&&T.memoizedState!==null||Ut;T=ci;var V=Ut;if(ci=w,(Ut=$)&&!V)for(ke=f;ke!==null;)w=ke,$=w.child,w.tag===22&&w.memoizedState!==null?If(f):$!==null?($.return=w,ke=$):If(f);for(;g!==null;)ke=g,Ef(g),g=g.sibling;ke=f,ci=T,Ut=V}Tf(t)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,ke=g):Tf(t)}}function Tf(t){for(;ke!==null;){var s=ke;if((s.flags&8772)!==0){var o=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:Ut||ui(5,s);break;case 1:var c=s.stateNode;if(s.flags&4&&!Ut)if(o===null)c.componentDidMount();else{var f=s.elementType===s.type?o.memoizedProps:jn(s.type,o.memoizedProps);c.componentDidUpdate(f,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=s.updateQueue;g!==null&&Td(s,g,c);break;case 3:var w=s.updateQueue;if(w!==null){if(o=null,s.child!==null)switch(s.child.tag){case 5:o=s.child.stateNode;break;case 1:o=s.child.stateNode}Td(s,w,o)}break;case 5:var T=s.stateNode;if(o===null&&s.flags&4){o=T;var $=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&o.focus();break;case"img":$.src&&(o.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var V=s.alternate;if(V!==null){var ie=V.memoizedState;if(ie!==null){var ue=ie.dehydrated;ue!==null&&Ps(ue)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Ut||s.flags&512&&Pl(s)}catch(se){St(s,s.return,se)}}if(s===t){ke=null;break}if(o=s.sibling,o!==null){o.return=s.return,ke=o;break}ke=s.return}}function Af(t){for(;ke!==null;){var s=ke;if(s===t){ke=null;break}var o=s.sibling;if(o!==null){o.return=s.return,ke=o;break}ke=s.return}}function If(t){for(;ke!==null;){var s=ke;try{switch(s.tag){case 0:case 11:case 15:var o=s.return;try{ui(4,s)}catch($){St(s,o,$)}break;case 1:var c=s.stateNode;if(typeof c.componentDidMount=="function"){var f=s.return;try{c.componentDidMount()}catch($){St(s,f,$)}}var g=s.return;try{Pl(s)}catch($){St(s,g,$)}break;case 5:var w=s.return;try{Pl(s)}catch($){St(s,w,$)}}}catch($){St(s,s.return,$)}if(s===t){ke=null;break}var T=s.sibling;if(T!==null){T.return=s.return,ke=T;break}ke=s.return}}var mv=Math.ceil,di=A.ReactCurrentDispatcher,Ml=A.ReactCurrentOwner,hn=A.ReactCurrentBatchConfig,et=0,Pt=null,Tt=null,Ft=0,on=0,cs=ar(0),It=0,na=null,Ar=0,fi=0,Fl=0,ra=null,Qt=null,Ol=0,us=1/0,Vn=null,hi=!1,zl=null,dr=null,mi=!1,fr=null,pi=0,sa=0,Bl=null,gi=-1,yi=0;function Gt(){return(et&6)!==0?Ct():gi!==-1?gi:gi=Ct()}function hr(t){return(t.mode&1)===0?1:(et&2)!==0&&Ft!==0?Ft&-Ft:Qy.transition!==null?(yi===0&&(yi=bu()),yi):(t=lt,t!==0||(t=window.event,t=t===void 0?16:Ru(t.type)),t)}function Sn(t,s,o,c){if(50<sa)throw sa=0,Bl=null,Error(a(185));Ts(t,o,c),((et&2)===0||t!==Pt)&&(t===Pt&&((et&2)===0&&(fi|=o),It===4&&mr(t,Ft)),Xt(t,c),o===1&&et===0&&(s.mode&1)===0&&(us=Ct()+500,Va&&or()))}function Xt(t,s){var o=t.callbackNode;Qg(t,s);var c=Ca(t,t===Pt?Ft:0);if(c===0)o!==null&&xu(o),t.callbackNode=null,t.callbackPriority=0;else if(s=c&-c,t.callbackPriority!==s){if(o!=null&&xu(o),s===1)t.tag===0?Jy($f.bind(null,t)):gd($f.bind(null,t)),Gy(function(){(et&6)===0&&or()}),o=null;else{switch(Su(c)){case 1:o=xo;break;case 4:o=ju;break;case 16:o=ba;break;case 536870912:o=wu;break;default:o=ba}o=Bf(o,Rf.bind(null,t))}t.callbackPriority=s,t.callbackNode=o}}function Rf(t,s){if(gi=-1,yi=0,(et&6)!==0)throw Error(a(327));var o=t.callbackNode;if(ds()&&t.callbackNode!==o)return null;var c=Ca(t,t===Pt?Ft:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||s)s=vi(t,c);else{s=c;var f=et;et|=2;var g=_f();(Pt!==t||Ft!==s)&&(Vn=null,us=Ct()+500,Rr(t,s));do try{yv();break}catch(T){Pf(t,T)}while(!0);sl(),di.current=g,et=f,Tt!==null?s=0:(Pt=null,Ft=0,s=It)}if(s!==0){if(s===2&&(f=jo(t),f!==0&&(c=f,s=Dl(t,f))),s===1)throw o=na,Rr(t,0),mr(t,c),Xt(t,Ct()),o;if(s===6)mr(t,c);else{if(f=t.current.alternate,(c&30)===0&&!pv(f)&&(s=vi(t,c),s===2&&(g=jo(t),g!==0&&(c=g,s=Dl(t,g))),s===1))throw o=na,Rr(t,0),mr(t,c),Xt(t,Ct()),o;switch(t.finishedWork=f,t.finishedLanes=c,s){case 0:case 1:throw Error(a(345));case 2:$r(t,Qt,Vn);break;case 3:if(mr(t,c),(c&130023424)===c&&(s=Ol+500-Ct(),10<s)){if(Ca(t,0)!==0)break;if(f=t.suspendedLanes,(f&c)!==c){Gt(),t.pingedLanes|=t.suspendedLanes&f;break}t.timeoutHandle=qo($r.bind(null,t,Qt,Vn),s);break}$r(t,Qt,Vn);break;case 4:if(mr(t,c),(c&4194240)===c)break;for(s=t.eventTimes,f=-1;0<c;){var w=31-yn(c);g=1<<w,w=s[w],w>f&&(f=w),c&=~g}if(c=f,c=Ct()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*mv(c/1960))-c,10<c){t.timeoutHandle=qo($r.bind(null,t,Qt,Vn),c);break}$r(t,Qt,Vn);break;case 5:$r(t,Qt,Vn);break;default:throw Error(a(329))}}}return Xt(t,Ct()),t.callbackNode===o?Rf.bind(null,t):null}function Dl(t,s){var o=ra;return t.current.memoizedState.isDehydrated&&(Rr(t,s).flags|=256),t=vi(t,s),t!==2&&(s=Qt,Qt=o,s!==null&&Ul(s)),t}function Ul(t){Qt===null?Qt=t:Qt.push.apply(Qt,t)}function pv(t){for(var s=t;;){if(s.flags&16384){var o=s.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var f=o[c],g=f.getSnapshot;f=f.value;try{if(!vn(g(),f))return!1}catch{return!1}}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function mr(t,s){for(s&=~Fl,s&=~fi,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var o=31-yn(s),c=1<<o;t[o]=-1,s&=~c}}function $f(t){if((et&6)!==0)throw Error(a(327));ds();var s=Ca(t,0);if((s&1)===0)return Xt(t,Ct()),null;var o=vi(t,s);if(t.tag!==0&&o===2){var c=jo(t);c!==0&&(s=c,o=Dl(t,c))}if(o===1)throw o=na,Rr(t,0),mr(t,s),Xt(t,Ct()),o;if(o===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,$r(t,Qt,Vn),Xt(t,Ct()),null}function Wl(t,s){var o=et;et|=1;try{return t(s)}finally{et=o,et===0&&(us=Ct()+500,Va&&or())}}function Ir(t){fr!==null&&fr.tag===0&&(et&6)===0&&ds();var s=et;et|=1;var o=hn.transition,c=lt;try{if(hn.transition=null,lt=1,t)return t()}finally{lt=c,hn.transition=o,et=s,(et&6)===0&&or()}}function Hl(){on=cs.current,pt(cs)}function Rr(t,s){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,Vy(o)),Tt!==null)for(o=Tt.return;o!==null;){var c=o;switch(Zo(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Wa();break;case 3:is(),pt(Kt),pt(zt),fl();break;case 5:ul(c);break;case 4:is();break;case 13:pt(jt);break;case 19:pt(jt);break;case 10:al(c.type._context);break;case 22:case 23:Hl()}o=o.return}if(Pt=t,Tt=t=pr(t.current,null),Ft=on=s,It=0,na=null,Fl=fi=Ar=0,Qt=ra=null,Cr!==null){for(s=0;s<Cr.length;s++)if(o=Cr[s],c=o.interleaved,c!==null){o.interleaved=null;var f=c.next,g=o.pending;if(g!==null){var w=g.next;g.next=f,c.next=w}o.pending=c}Cr=null}return t}function Pf(t,s){do{var o=Tt;try{if(sl(),ti.current=ai,ni){for(var c=wt.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}ni=!1}if(Tr=0,$t=At=wt=null,Js=!1,Qs=0,Ml.current=null,o===null||o.return===null){It=1,na=s,Tt=null;break}e:{var g=t,w=o.return,T=o,$=s;if(s=Ft,T.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var V=$,ie=T,ue=ie.tag;if((ie.mode&1)===0&&(ue===0||ue===11||ue===15)){var se=ie.alternate;se?(ie.updateQueue=se.updateQueue,ie.memoizedState=se.memoizedState,ie.lanes=se.lanes):(ie.updateQueue=null,ie.memoizedState=null)}var je=rf(w);if(je!==null){je.flags&=-257,sf(je,w,T,g,s),je.mode&1&&nf(g,V,s),s=je,$=V;var Ce=s.updateQueue;if(Ce===null){var Ie=new Set;Ie.add($),s.updateQueue=Ie}else Ce.add($);break e}else{if((s&1)===0){nf(g,V,s),Vl();break e}$=Error(a(426))}}else if(vt&&T.mode&1){var Et=rf(w);if(Et!==null){(Et.flags&65536)===0&&(Et.flags|=256),sf(Et,w,T,g,s),nl(os($,T));break e}}g=$=os($,T),It!==4&&(It=2),ra===null?ra=[g]:ra.push(g),g=w;do{switch(g.tag){case 3:g.flags|=65536,s&=-s,g.lanes|=s;var O=ef(g,$,s);Ed(g,O);break e;case 1:T=$;var _=g.type,D=g.stateNode;if((g.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(dr===null||!dr.has(D)))){g.flags|=65536,s&=-s,g.lanes|=s;var me=tf(g,T,s);Ed(g,me);break e}}g=g.return}while(g!==null)}Mf(o)}catch(Pe){s=Pe,Tt===o&&o!==null&&(Tt=o=o.return);continue}break}while(!0)}function _f(){var t=di.current;return di.current=ai,t===null?ai:t}function Vl(){(It===0||It===3||It===2)&&(It=4),Pt===null||(Ar&268435455)===0&&(fi&268435455)===0||mr(Pt,Ft)}function vi(t,s){var o=et;et|=2;var c=_f();(Pt!==t||Ft!==s)&&(Vn=null,Rr(t,s));do try{gv();break}catch(f){Pf(t,f)}while(!0);if(sl(),et=o,di.current=c,Tt!==null)throw Error(a(261));return Pt=null,Ft=0,It}function gv(){for(;Tt!==null;)Lf(Tt)}function yv(){for(;Tt!==null&&!Ug();)Lf(Tt)}function Lf(t){var s=zf(t.alternate,t,on);t.memoizedProps=t.pendingProps,s===null?Mf(t):Tt=s,Ml.current=null}function Mf(t){var s=t;do{var o=s.alternate;if(t=s.return,(s.flags&32768)===0){if(o=cv(o,s,on),o!==null){Tt=o;return}}else{if(o=uv(o,s),o!==null){o.flags&=32767,Tt=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{It=6,Tt=null;return}}if(s=s.sibling,s!==null){Tt=s;return}Tt=s=t}while(s!==null);It===0&&(It=5)}function $r(t,s,o){var c=lt,f=hn.transition;try{hn.transition=null,lt=1,vv(t,s,o,c)}finally{hn.transition=f,lt=c}return null}function vv(t,s,o,c){do ds();while(fr!==null);if((et&6)!==0)throw Error(a(327));o=t.finishedWork;var f=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var g=o.lanes|o.childLanes;if(Xg(t,g),t===Pt&&(Tt=Pt=null,Ft=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||mi||(mi=!0,Bf(ba,function(){return ds(),null})),g=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||g){g=hn.transition,hn.transition=null;var w=lt;lt=1;var T=et;et|=4,Ml.current=null,fv(t,o),Cf(o,t),Oy(Vo),Aa=!!Ho,Vo=Ho=null,t.current=o,hv(o),Wg(),et=T,lt=w,hn.transition=g}else t.current=o;if(mi&&(mi=!1,fr=t,pi=f),g=t.pendingLanes,g===0&&(dr=null),Gg(o.stateNode),Xt(t,Ct()),s!==null)for(c=t.onRecoverableError,o=0;o<s.length;o++)f=s[o],c(f.value,{componentStack:f.stack,digest:f.digest});if(hi)throw hi=!1,t=zl,zl=null,t;return(pi&1)!==0&&t.tag!==0&&ds(),g=t.pendingLanes,(g&1)!==0?t===Bl?sa++:(sa=0,Bl=t):sa=0,or(),null}function ds(){if(fr!==null){var t=Su(pi),s=hn.transition,o=lt;try{if(hn.transition=null,lt=16>t?16:t,fr===null)var c=!1;else{if(t=fr,fr=null,pi=0,(et&6)!==0)throw Error(a(331));var f=et;for(et|=4,ke=t.current;ke!==null;){var g=ke,w=g.child;if((ke.flags&16)!==0){var T=g.deletions;if(T!==null){for(var $=0;$<T.length;$++){var V=T[$];for(ke=V;ke!==null;){var ie=ke;switch(ie.tag){case 0:case 11:case 15:ta(8,ie,g)}var ue=ie.child;if(ue!==null)ue.return=ie,ke=ue;else for(;ke!==null;){ie=ke;var se=ie.sibling,je=ie.return;if(wf(ie),ie===V){ke=null;break}if(se!==null){se.return=je,ke=se;break}ke=je}}}var Ce=g.alternate;if(Ce!==null){var Ie=Ce.child;if(Ie!==null){Ce.child=null;do{var Et=Ie.sibling;Ie.sibling=null,Ie=Et}while(Ie!==null)}}ke=g}}if((g.subtreeFlags&2064)!==0&&w!==null)w.return=g,ke=w;else e:for(;ke!==null;){if(g=ke,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:ta(9,g,g.return)}var O=g.sibling;if(O!==null){O.return=g.return,ke=O;break e}ke=g.return}}var _=t.current;for(ke=_;ke!==null;){w=ke;var D=w.child;if((w.subtreeFlags&2064)!==0&&D!==null)D.return=w,ke=D;else e:for(w=_;ke!==null;){if(T=ke,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:ui(9,T)}}catch(Pe){St(T,T.return,Pe)}if(T===w){ke=null;break e}var me=T.sibling;if(me!==null){me.return=T.return,ke=me;break e}ke=T.return}}if(et=f,or(),An&&typeof An.onPostCommitFiberRoot=="function")try{An.onPostCommitFiberRoot(Sa,t)}catch{}c=!0}return c}finally{lt=o,hn.transition=s}}return!1}function Ff(t,s,o){s=os(o,s),s=ef(t,s,1),t=cr(t,s,1),s=Gt(),t!==null&&(Ts(t,1,s),Xt(t,s))}function St(t,s,o){if(t.tag===3)Ff(t,t,o);else for(;s!==null;){if(s.tag===3){Ff(s,t,o);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(dr===null||!dr.has(c))){t=os(o,t),t=tf(s,t,1),s=cr(s,t,1),t=Gt(),s!==null&&(Ts(s,1,t),Xt(s,t));break}}s=s.return}}function xv(t,s,o){var c=t.pingCache;c!==null&&c.delete(s),s=Gt(),t.pingedLanes|=t.suspendedLanes&o,Pt===t&&(Ft&o)===o&&(It===4||It===3&&(Ft&130023424)===Ft&&500>Ct()-Ol?Rr(t,0):Fl|=o),Xt(t,s)}function Of(t,s){s===0&&((t.mode&1)===0?s=1:(s=Na,Na<<=1,(Na&130023424)===0&&(Na=4194304)));var o=Gt();t=Un(t,s),t!==null&&(Ts(t,s,o),Xt(t,o))}function jv(t){var s=t.memoizedState,o=0;s!==null&&(o=s.retryLane),Of(t,o)}function wv(t,s){var o=0;switch(t.tag){case 13:var c=t.stateNode,f=t.memoizedState;f!==null&&(o=f.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(s),Of(t,o)}var zf;zf=function(t,s,o){if(t!==null)if(t.memoizedProps!==s.pendingProps||Kt.current)Jt=!0;else{if((t.lanes&o)===0&&(s.flags&128)===0)return Jt=!1,lv(t,s,o);Jt=(t.flags&131072)!==0}else Jt=!1,vt&&(s.flags&1048576)!==0&&yd(s,qa,s.index);switch(s.lanes=0,s.tag){case 2:var c=s.type;li(t,s),t=s.pendingProps;var f=Zr(s,zt.current);as(s,o),f=pl(null,s,c,t,f,o);var g=gl();return s.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Yt(c)?(g=!0,Ha(s)):g=!1,s.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,ll(s),f.updater=ii,s.stateNode=f,f._reactInternals=s,bl(s,c,t,o),s=Cl(null,s,c,!0,g,o)):(s.tag=0,vt&&g&&Xo(s),Vt(null,s,f,o),s=s.child),s;case 16:c=s.elementType;e:{switch(li(t,s),t=s.pendingProps,f=c._init,c=f(c._payload),s.type=c,f=s.tag=Sv(c),t=jn(c,t),f){case 0:s=Nl(null,s,c,t,o);break e;case 1:s=df(null,s,c,t,o);break e;case 11:s=af(null,s,c,t,o);break e;case 14:s=of(null,s,c,jn(c.type,t),o);break e}throw Error(a(306,c,""))}return s;case 0:return c=s.type,f=s.pendingProps,f=s.elementType===c?f:jn(c,f),Nl(t,s,c,f,o);case 1:return c=s.type,f=s.pendingProps,f=s.elementType===c?f:jn(c,f),df(t,s,c,f,o);case 3:e:{if(ff(s),t===null)throw Error(a(387));c=s.pendingProps,g=s.memoizedState,f=g.element,Cd(t,s),Za(s,c,null,o);var w=s.memoizedState;if(c=w.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){f=os(Error(a(423)),s),s=hf(t,s,c,o,f);break e}else if(c!==f){f=os(Error(a(424)),s),s=hf(t,s,c,o,f);break e}else for(an=sr(s.stateNode.containerInfo.firstChild),sn=s,vt=!0,xn=null,o=kd(s,null,c,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ns(),c===f){s=Hn(t,s,o);break e}Vt(t,s,c,o)}s=s.child}return s;case 5:return Ad(s),t===null&&tl(s),c=s.type,f=s.pendingProps,g=t!==null?t.memoizedProps:null,w=f.children,Go(c,f)?w=null:g!==null&&Go(c,g)&&(s.flags|=32),uf(t,s),Vt(t,s,w,o),s.child;case 6:return t===null&&tl(s),null;case 13:return mf(t,s,o);case 4:return cl(s,s.stateNode.containerInfo),c=s.pendingProps,t===null?s.child=rs(s,null,c,o):Vt(t,s,c,o),s.child;case 11:return c=s.type,f=s.pendingProps,f=s.elementType===c?f:jn(c,f),af(t,s,c,f,o);case 7:return Vt(t,s,s.pendingProps,o),s.child;case 8:return Vt(t,s,s.pendingProps.children,o),s.child;case 12:return Vt(t,s,s.pendingProps.children,o),s.child;case 10:e:{if(c=s.type._context,f=s.pendingProps,g=s.memoizedProps,w=f.value,ft(Ja,c._currentValue),c._currentValue=w,g!==null)if(vn(g.value,w)){if(g.children===f.children&&!Kt.current){s=Hn(t,s,o);break e}}else for(g=s.child,g!==null&&(g.return=s);g!==null;){var T=g.dependencies;if(T!==null){w=g.child;for(var $=T.firstContext;$!==null;){if($.context===c){if(g.tag===1){$=Wn(-1,o&-o),$.tag=2;var V=g.updateQueue;if(V!==null){V=V.shared;var ie=V.pending;ie===null?$.next=$:($.next=ie.next,ie.next=$),V.pending=$}}g.lanes|=o,$=g.alternate,$!==null&&($.lanes|=o),il(g.return,o,s),T.lanes|=o;break}$=$.next}}else if(g.tag===10)w=g.type===s.type?null:g.child;else if(g.tag===18){if(w=g.return,w===null)throw Error(a(341));w.lanes|=o,T=w.alternate,T!==null&&(T.lanes|=o),il(w,o,s),w=g.sibling}else w=g.child;if(w!==null)w.return=g;else for(w=g;w!==null;){if(w===s){w=null;break}if(g=w.sibling,g!==null){g.return=w.return,w=g;break}w=w.return}g=w}Vt(t,s,f.children,o),s=s.child}return s;case 9:return f=s.type,c=s.pendingProps.children,as(s,o),f=dn(f),c=c(f),s.flags|=1,Vt(t,s,c,o),s.child;case 14:return c=s.type,f=jn(c,s.pendingProps),f=jn(c.type,f),of(t,s,c,f,o);case 15:return lf(t,s,s.type,s.pendingProps,o);case 17:return c=s.type,f=s.pendingProps,f=s.elementType===c?f:jn(c,f),li(t,s),s.tag=1,Yt(c)?(t=!0,Ha(s)):t=!1,as(s,o),Xd(s,c,f),bl(s,c,f,o),Cl(null,s,c,!0,t,o);case 19:return gf(t,s,o);case 22:return cf(t,s,o)}throw Error(a(156,s.tag))};function Bf(t,s){return vu(t,s)}function bv(t,s,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mn(t,s,o,c){return new bv(t,s,o,c)}function Gl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Sv(t){if(typeof t=="function")return Gl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===U)return 11;if(t===ee)return 14}return 2}function pr(t,s){var o=t.alternate;return o===null?(o=mn(t.tag,s,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=s,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,s=t.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function xi(t,s,o,c,f,g){var w=2;if(c=t,typeof t=="function")Gl(t)&&(w=1);else if(typeof t=="string")w=5;else e:switch(t){case H:return Pr(o.children,f,g,s);case te:w=8,f|=8;break;case X:return t=mn(12,o,s,f|2),t.elementType=X,t.lanes=g,t;case K:return t=mn(13,o,s,f),t.elementType=K,t.lanes=g,t;case ce:return t=mn(19,o,s,f),t.elementType=ce,t.lanes=g,t;case Ae:return ji(o,f,g,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case L:w=10;break e;case q:w=9;break e;case U:w=11;break e;case ee:w=14;break e;case Se:w=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return s=mn(w,o,s,f),s.elementType=t,s.type=c,s.lanes=g,s}function Pr(t,s,o,c){return t=mn(7,t,c,s),t.lanes=o,t}function ji(t,s,o,c){return t=mn(22,t,c,s),t.elementType=Ae,t.lanes=o,t.stateNode={isHidden:!1},t}function ql(t,s,o){return t=mn(6,t,null,s),t.lanes=o,t}function Kl(t,s,o){return s=mn(4,t.children!==null?t.children:[],t.key,s),s.lanes=o,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function kv(t,s,o,c,f){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=wo(0),this.expirationTimes=wo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wo(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Yl(t,s,o,c,f,g,w,T,$){return t=new kv(t,s,o,T,$),s===1?(s=1,g===!0&&(s|=8)):s=0,g=mn(3,null,null,s),t.current=g,g.stateNode=t,g.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},ll(g),t}function Nv(t,s,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:c==null?null:""+c,children:t,containerInfo:s,implementation:o}}function Df(t){if(!t)return ir;t=t._reactInternals;e:{if(En(t)!==t||t.tag!==1)throw Error(a(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(Yt(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(a(171))}if(t.tag===1){var o=t.type;if(Yt(o))return md(t,o,s)}return s}function Uf(t,s,o,c,f,g,w,T,$){return t=Yl(o,c,!0,t,f,g,w,T,$),t.context=Df(null),o=t.current,c=Gt(),f=hr(o),g=Wn(c,f),g.callback=s??null,cr(o,g,f),t.current.lanes=f,Ts(t,f,c),Xt(t,c),t}function wi(t,s,o,c){var f=s.current,g=Gt(),w=hr(f);return o=Df(o),s.context===null?s.context=o:s.pendingContext=o,s=Wn(g,w),s.payload={element:t},c=c===void 0?null:c,c!==null&&(s.callback=c),t=cr(f,s,w),t!==null&&(Sn(t,f,w,g),Xa(t,f,w)),w}function bi(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Wf(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<s?o:s}}function Jl(t,s){Wf(t,s),(t=t.alternate)&&Wf(t,s)}function Cv(){return null}var Hf=typeof reportError=="function"?reportError:function(t){console.error(t)};function Ql(t){this._internalRoot=t}Si.prototype.render=Ql.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(a(409));wi(t,s,null,null)},Si.prototype.unmount=Ql.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;Ir(function(){wi(null,t,null,null)}),s[On]=null}};function Si(t){this._internalRoot=t}Si.prototype.unstable_scheduleHydration=function(t){if(t){var s=Cu();t={blockedOn:null,target:t,priority:s};for(var o=0;o<tr.length&&s!==0&&s<tr[o].priority;o++);tr.splice(o,0,t),o===0&&Au(t)}};function Xl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function ki(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Vf(){}function Ev(t,s,o,c,f){if(f){if(typeof c=="function"){var g=c;c=function(){var V=bi(w);g.call(V)}}var w=Uf(s,c,t,0,null,!1,!1,"",Vf);return t._reactRootContainer=w,t[On]=w.current,Us(t.nodeType===8?t.parentNode:t),Ir(),w}for(;f=t.lastChild;)t.removeChild(f);if(typeof c=="function"){var T=c;c=function(){var V=bi($);T.call(V)}}var $=Yl(t,0,!1,null,null,!1,!1,"",Vf);return t._reactRootContainer=$,t[On]=$.current,Us(t.nodeType===8?t.parentNode:t),Ir(function(){wi(s,$,o,c)}),$}function Ni(t,s,o,c,f){var g=o._reactRootContainer;if(g){var w=g;if(typeof f=="function"){var T=f;f=function(){var $=bi(w);T.call($)}}wi(s,w,t,f)}else w=Ev(o,s,t,f,c);return bi(w)}ku=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var o=Es(s.pendingLanes);o!==0&&(bo(s,o|1),Xt(s,Ct()),(et&6)===0&&(us=Ct()+500,or()))}break;case 13:Ir(function(){var c=Un(t,1);if(c!==null){var f=Gt();Sn(c,t,1,f)}}),Jl(t,1)}},So=function(t){if(t.tag===13){var s=Un(t,134217728);if(s!==null){var o=Gt();Sn(s,t,134217728,o)}Jl(t,134217728)}},Nu=function(t){if(t.tag===13){var s=hr(t),o=Un(t,s);if(o!==null){var c=Gt();Sn(o,t,s,c)}Jl(t,s)}},Cu=function(){return lt},Eu=function(t,s){var o=lt;try{return lt=t,s()}finally{lt=o}},Ze=function(t,s,o){switch(s){case"input":if(Ve(t,o),s=o.name,o.type==="radio"&&s!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<o.length;s++){var c=o[s];if(c!==t&&c.form===t.form){var f=Ua(c);if(!f)throw Error(a(90));Me(c),Ve(c,f)}}}break;case"textarea":Oe(t,o);break;case"select":s=o.value,s!=null&&De(t,!!o.multiple,s,!1)}},re=Wl,xe=Ir;var Tv={usingClientEntryPoint:!1,Events:[Vs,Qr,Ua,it,bt,Wl]},aa={findFiberByHostInstance:br,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Av={bundleType:aa.bundleType,version:aa.version,rendererPackageName:aa.rendererPackageName,rendererConfig:aa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Tn(t),t===null?null:t.stateNode},findFiberByHostInstance:aa.findFiberByHostInstance||Cv,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ci=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ci.isDisabled&&Ci.supportsFiber)try{Sa=Ci.inject(Av),An=Ci}catch{}}return Zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tv,Zt.createPortal=function(t,s){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Xl(s))throw Error(a(200));return Nv(t,s,null,o)},Zt.createRoot=function(t,s){if(!Xl(t))throw Error(a(299));var o=!1,c="",f=Hf;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onRecoverableError!==void 0&&(f=s.onRecoverableError)),s=Yl(t,1,!1,null,null,o,!1,c,f),t[On]=s.current,Us(t.nodeType===8?t.parentNode:t),new Ql(s)},Zt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=Tn(s),t=t===null?null:t.stateNode,t},Zt.flushSync=function(t){return Ir(t)},Zt.hydrate=function(t,s,o){if(!ki(s))throw Error(a(200));return Ni(null,t,s,!0,o)},Zt.hydrateRoot=function(t,s,o){if(!Xl(t))throw Error(a(405));var c=o!=null&&o.hydratedSources||null,f=!1,g="",w=Hf;if(o!=null&&(o.unstable_strictMode===!0&&(f=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(w=o.onRecoverableError)),s=Uf(s,null,t,1,o??null,f,!1,g,w),t[On]=s.current,Us(t),c)for(t=0;t<c.length;t++)o=c[t],f=o._getVersion,f=f(o._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[o,f]:s.mutableSourceEagerHydrationData.push(o,f);return new Si(s)},Zt.render=function(t,s,o){if(!ki(s))throw Error(a(200));return Ni(null,t,s,!1,o)},Zt.unmountComponentAtNode=function(t){if(!ki(t))throw Error(a(40));return t._reactRootContainer?(Ir(function(){Ni(null,null,t,!1,function(){t._reactRootContainer=null,t[On]=null})}),!0):!1},Zt.unstable_batchedUpdates=Wl,Zt.unstable_renderSubtreeIntoContainer=function(t,s,o,c){if(!ki(o))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return Ni(t,s,o,!1,c)},Zt.version="18.3.1-next-f1338f8080-20240426",Zt}var Zf;function Sm(){if(Zf)return tc.exports;Zf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),tc.exports=Ov(),tc.exports}var eh;function zv(){if(eh)return Ei;eh=1;var e=Sm();return Ei.createRoot=e.createRoot,Ei.hydrateRoot=e.hydrateRoot,Ei}var Bv=zv();/**
|
|
41
|
-
* react-router v7.18.4
|
|
42
|
-
*
|
|
43
|
-
* Copyright (c) Remix Software Inc.
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the MIT license found in the
|
|
46
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
47
|
-
*
|
|
48
|
-
* @license MIT
|
|
49
|
-
*/var Uc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,km=/^[\\/]{2}/;function Dv(e,r){return r+e.replace(/\\/g,"/")}var th="popstate";function nh(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Uv(e={}){function r(i,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:d,search:p,hash:m}=u||i.location;return bc("",{pathname:d,search:p,hash:m},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function a(i,l){return typeof l=="string"?l:zr(l)}return Hv(r,a,null,e)}function xt(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function pn(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Wv(){return Math.random().toString(36).substring(2,10)}function rh(e,r){return{usr:e.state,key:e.key,idx:r,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function bc(e,r,a=null,i,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof r=="string"?ws(r):r,state:a,key:r&&r.key||i||Wv(),mask:l}}function zr({pathname:e="/",search:r="",hash:a=""}){return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function ws(e){let r={};if(e){let a=e.indexOf("#");a>=0&&(r.hash=e.substring(a),e=e.substring(0,a));let i=e.indexOf("?");i>=0&&(r.search=e.substring(i),e=e.substring(0,i)),e&&(r.pathname=e)}return r}function Hv(e,r,a,i={}){let{window:l=document.defaultView,v5Compat:u=!1}=i,d=l.history,p="POP",m=null,v=y();v==null&&(v=0,d.replaceState({...d.state,idx:v},""));function y(){return(d.state||{idx:null}).idx}function j(){p="POP";let k=y(),C=k==null?null:k-v;v=k,m&&m({action:p,location:b.location,delta:C})}function x(k,C){p="PUSH";let E=nh(k)?k:bc(b.location,k,C);v=y()+1;let R=rh(E,v),A=b.createHref(E.mask||E);try{d.pushState(R,"",A)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;l.location.assign(A)}u&&m&&m({action:p,location:b.location,delta:1})}function S(k,C){p="REPLACE";let E=nh(k)?k:bc(b.location,k,C);v=y();let R=rh(E,v),A=b.createHref(E.mask||E);d.replaceState(R,"",A),u&&m&&m({action:p,location:b.location,delta:0})}function N(k){return Vv(l,k)}let b={get action(){return p},get location(){return e(l,d)},listen(k){if(m)throw new Error("A history only accepts one active listener");return l.addEventListener(th,j),m=k,()=>{l.removeEventListener(th,j),m=null}},createHref(k){return r(l,k)},createURL:N,encodeLocation(k){let C=N(k);return{pathname:C.pathname,search:C.search,hash:C.hash}},push:x,replace:S,go(k){return d.go(k)}};return b}function Vv(e,r,a=!1){let i="http://localhost";e&&(i=e.location.origin!=="null"?e.location.origin:e.location.href),xt(i,"No window.location.(origin|href) available to create URL");let l=typeof r=="string"?r:zr(r);return l=l.replace(/ $/,"%20"),!a&&km.test(l)&&(l=i+l),new URL(l,i)}function Nm(e,r,a="/"){return Gv(e,r,a,!1)}function Gv(e,r,a,i,l){let u=typeof r=="string"?ws(r):r,d=qn(u.pathname||"/",a);if(d==null)return null;let p=qv(e),m=null,v=sx(d);for(let y=0;m==null&&y<p.length;++y)m=rx(p[y],v,i);return m}function qv(e){let r=Cm(e);return Kv(r),r}function Cm(e,r=[],a=[],i="",l=!1){let u=(d,p,m=l,v)=>{let y={relativePath:v===void 0?d.path||"":v,caseSensitive:d.caseSensitive===!0,childrenIndex:p,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(i)&&m)return;xt(y.relativePath.startsWith(i),`Absolute route path "${y.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(i.length)}let j=kn([i,y.relativePath]),x=a.concat(y);d.children&&d.children.length>0&&(xt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${j}".`),Cm(d.children,r,x,j,m)),!(d.path==null&&!d.index)&&r.push({path:j,score:tx(j,d.index),routesMeta:x.map((S,N)=>{let[b,k]=Am(S.relativePath,S.caseSensitive,N===x.length-1);return{...S,matcher:b,compiledParams:k}})})};return e.forEach((d,p)=>{var m;if(d.path===""||!((m=d.path)!=null&&m.includes("?")))u(d,p);else for(let v of Em(d.path))u(d,p,!0,v)}),r}function Em(e){let r=e.split("/");if(r.length===0)return[];let[a,...i]=r,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(i.length===0)return l?[u,""]:[u];let d=Em(i.join("/")),p=[];return p.push(...d.map(m=>m===""?u:[u,m].join("/"))),l&&p.push(...d),p.map(m=>e.startsWith("/")&&m===""?"/":m)}function Kv(e){e.sort((r,a)=>r.score!==a.score?a.score-r.score:nx(r.routesMeta.map(i=>i.childrenIndex),a.routesMeta.map(i=>i.childrenIndex)))}var Yv=/^:[\w-]+$/,Jv=3,Qv=2,Xv=1,Zv=10,ex=-2,sh=e=>e==="*";function tx(e,r){let a=e.split("/"),i=a.length;return a.some(sh)&&(i+=ex),r&&(i+=Qv),a.filter(l=>!sh(l)).reduce((l,u)=>l+(Yv.test(u)?Jv:u===""?Xv:Zv),i)}function nx(e,r){return e.length===r.length&&e.slice(0,-1).every((i,l)=>i===r[l])?e[e.length-1]-r[r.length-1]:0}function rx(e,r,a=!1){let{routesMeta:i}=e,l={},u="/",d=[];for(let p=0;p<i.length;++p){let m=i[p],v=p===i.length-1,y=u==="/"?r:r.slice(u.length)||"/",j={path:m.relativePath,caseSensitive:m.caseSensitive,end:v},x=m.matcher&&m.compiledParams?Tm(j,y,m.matcher,m.compiledParams):Ui(j,y),S=m.route;if(!x&&v&&a&&!i[i.length-1].route.index&&(x=Ui({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},y)),!x)return null;Object.assign(l,x.params),d.push({params:l,pathname:kn([u,x.pathname]),pathnameBase:ox(kn([u,x.pathnameBase])),route:S}),x.pathnameBase!=="/"&&(u=kn([u,x.pathnameBase]))}return d}function Ui(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,i]=Am(e.path,e.caseSensitive,e.end);return Tm(e,r,a,i)}function Tm(e,r,a,i){let l=r.match(a);if(!l)return null;let u=l[0],d=gs(u,1),p=l.slice(1);return{params:i.reduce((v,{paramName:y,isOptional:j},x)=>{if(y==="*"){let N=p[x]||"";d=gs(u.slice(0,u.length-N.length),1)}const S=p[x];return j&&!S?v[y]=void 0:v[y]=(S||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:d,pattern:e}}function Am(e,r=!1,a=!0){pn(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 i=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,p,m,v,y)=>{if(i.push({paramName:p,isOptional:m!=null}),m){let j=y.charAt(v+d.length);return j&&j!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(i.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,r?void 0:"i"),i]}function sx(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return pn(!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 (${r}).`),e}}function qn(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let a=r.endsWith("/")?r.length-1:r.length,i=e.charAt(a);return i&&i!=="/"?null:e.slice(a)||"/"}function ax(e,r="/"){let{pathname:a,search:i="",hash:l=""}=typeof e=="string"?ws(e):e,u;return a?(a=Im(a),a.startsWith("/")||a.startsWith("\\")?u=ah(a.substring(1),"/"):u=ah(a,r)):u=r,{pathname:u,search:lx(i),hash:cx(l)}}function ah(e,r){let a=gs(r).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function sc(e,r,a,i){return`Cannot include a '${e}' character in a manually specified \`to.${r}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ix(e){return e.filter((r,a)=>a===0||r.route.path&&r.route.path.length>0)}function Wc(e){let r=ix(e);return r.map((a,i)=>i===r.length-1?a.pathname:a.pathnameBase)}function lo(e,r,a,i=!1){let l;typeof e=="string"?l=ws(e):(l={...e},xt(!l.pathname||!l.pathname.includes("?"),sc("?","pathname","search",l)),xt(!l.pathname||!l.pathname.includes("#"),sc("#","pathname","hash",l)),xt(!l.search||!l.search.includes("#"),sc("#","search","hash",l)));let u=e===""||l.pathname==="",d=u?"/":l.pathname,p;if(d==null)p=a;else{let j=r.length-1;if(!i&&d.startsWith("..")){let x=d.split("/");for(;x[0]==="..";)x.shift(),j-=1;l.pathname=x.join("/")}p=j>=0?r[j]:"/"}let m=ax(l,p),v=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&a.endsWith("/");return!m.pathname.endsWith("/")&&(v||y)&&(m.pathname+="/"),m}var Im=e=>e.replace(/[\\/]{2,}/g,"/"),kn=e=>Im(e.join("/"));function gs(e,r=0){let a=e.length;for(;a>r&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var ox=e=>gs(e).replace(/^\/*/,"/"),lx=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,cx=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ux=class{constructor(e,r,a,i=!1){this.status=e,this.statusText=r||"",this.internal=i,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function dx(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function fx(e){let r=e.map(a=>a.route.path).filter(Boolean);return kn(r)||"/"}var Rm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $m(e,r){let a=e;if(typeof a!="string"||!Uc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let i=a,l=!1;if(Rm)try{let u=new URL(window.location.href),d=km.test(a)?new URL(Dv(a,u.protocol)):new URL(a),p=qn(d.pathname,r);d.origin===u.origin&&p!=null?a=p+d.search+d.hash:l=!0}catch{pn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ih=new URL("http://localhost");function Hc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),ih)}catch{return ih}}function ac(e,r){return e.origin===r.origin&&(e.origin!=="null"||e.protocol===r.protocol&&e.host===r.host)}function hx(e,r){if(e.startsWith("//"))return!0;let a=r.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?r.host===""||e.slice(a.length).startsWith("//"):!1}function Vc(e,r,a,i){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(r,a),d=l!=null&&!ac(l,a),p=!ac(u,a);if(i==="reject"){if(d||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!hx(e,l)||!ac(l,u)))throw new Error("External navigation is not allowed")}var Pm=["POST","PUT","PATCH","DELETE"];new Set(Pm);var mx=["GET",...Pm];new Set(mx);var px=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function gx(e){try{return px.includes(new URL(e).protocol)}catch{return!1}}var bs=h.createContext(null);bs.displayName="DataRouter";var co=h.createContext(null);co.displayName="DataRouterState";var _m=h.createContext(!1);function yx(){return h.useContext(_m)}var Lm=h.createContext({isTransitioning:!1});Lm.displayName="ViewTransition";var vx=h.createContext(new Map);vx.displayName="Fetchers";var xx=h.createContext(null);xx.displayName="Await";var ln=h.createContext(null);ln.displayName="Navigation";var pa=h.createContext(null);pa.displayName="Location";var Cn=h.createContext({outlet:null,matches:[],isDataRoute:!1});Cn.displayName="Route";var Gc=h.createContext(null);Gc.displayName="RouteError";var Mm="REACT_ROUTER_ERROR",jx="REDIRECT",wx="ROUTE_ERROR_RESPONSE";function bx(e){if(e.startsWith(`${Mm}:${jx}:{`))try{let r=JSON.parse(e.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function Sx(e){if(e.startsWith(`${Mm}:${wx}:{`))try{let r=JSON.parse(e.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new ux(r.status,r.statusText,r.data)}catch{}}function kx(e,{relative:r}={}){xt(Ss(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:i}=h.useContext(ln),{hash:l,pathname:u,search:d}=ga(e,{relative:r}),p=u;return a!=="/"&&(p=u==="/"?a:kn([a,u])),i.createHref({pathname:p,search:d,hash:l})}function Ss(){return h.useContext(pa)!=null}function en(){return xt(Ss(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(pa).location}var Fm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Om(e){h.useContext(ln).static||h.useLayoutEffect(e)}function gn(){let{isDataRoute:e}=h.useContext(Cn);return e?zx():Nx()}function Nx(){xt(Ss(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext(bs),{basename:r,navigator:a}=h.useContext(ln),{matches:i}=h.useContext(Cn),{pathname:l}=en(),u=JSON.stringify(Wc(i)),d=h.useRef(!1);return Om(()=>{d.current=!0}),h.useCallback((m,v={})=>{if(pn(d.current,Fm),!d.current)return;if(typeof m=="number"){a.go(m);return}let y=lo(m,JSON.parse(u),l,v.relative==="path");e==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:kn([r,y.pathname])),Vc(typeof m=="string"?m:zr(m),a.createHref(y),Hc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[r,a,u,l,e])}var Cx=h.createContext(null);function Ex(e){let r=h.useContext(Cn).outlet;return h.useMemo(()=>r&&h.createElement(Cx.Provider,{value:e},r),[r,e])}function ga(e,{relative:r}={}){let{matches:a}=h.useContext(Cn),{pathname:i}=en(),l=JSON.stringify(Wc(a));return h.useMemo(()=>lo(e,JSON.parse(l),i,r==="path"),[e,l,i,r])}function Tx(e,r){return zm(e,r)}function zm(e,r,a){var k;xt(Ss(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=h.useContext(ln),{matches:l}=h.useContext(Cn),u=l[l.length-1],d=u?u.params:{},p=u?u.pathname:"/",m=u?u.pathnameBase:"/",v=u&&u.route;{let C=v&&v.path||"";Dm(p,!v||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${C}">) 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.
|
|
50
|
-
|
|
51
|
-
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=en(),j;if(r){let C=typeof r=="string"?ws(r):r;xt(m==="/"||((k=C.pathname)==null?void 0:k.startsWith(m)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${C.pathname}" was given in the \`location\` prop.`),j=C}else j=y;let x=j.pathname||"/",S=x;if(m!=="/"){let C=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(C.length).join("/")}let N=a&&a.state.matches.length?a.state.matches.map(C=>Object.assign(C,{route:a.manifest[C.route.id]||C.route})):Nm(e,{pathname:S});pn(v||N!=null,`No routes matched location "${j.pathname}${j.search}${j.hash}" `),pn(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${j.pathname}${j.search}${j.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=Px(N&&N.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:kn([m,i.encodeLocation?i.encodeLocation(C.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?m:kn([m,i.encodeLocation?i.encodeLocation(C.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),l,a);return r&&b?h.createElement(pa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...j},navigationType:"POP"}},b):b}function Ax(){let e=Ox(),r=dx(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,i="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},d=null;return console.error("Error handled by React Router default ErrorBoundary:",e),d=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},r),a?h.createElement("pre",{style:l},a):null,d)}var Ix=h.createElement(Ax,null),Bm=class extends h.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,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){this.props.onError?this.props.onError(e,r):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=Sx(e.digest);a&&(e=a)}let r=e!==void 0?h.createElement(Cn.Provider,{value:this.props.routeContext},h.createElement(Gc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(Rx,{error:e},r):r}};Bm.contextType=_m;var ic=new WeakMap;function Rx({children:e,error:r}){let{basename:a,navigator:i}=h.useContext(ln);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let l=bx(r.digest);if(l){let u=ic.get(r);if(u)throw u;let d=$m(l.location,a),p=d.absoluteURL||d.to;if(Vc(l.location,p,Hc(i),"allow-explicit"),gx(p))throw new Error("Invalid redirect location");if(Rm&&!ic.get(r))if(d.isExternal||l.reloadDocument)window.location.href=p;else{const m=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:l.replace}));throw ic.set(r,m),m}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function $x({routeContext:e,match:r,children:a}){let i=h.useContext(bs);return i&&i.static&&i.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=r.route.id),h.createElement(Cn.Provider,{value:e},a)}function Px(e,r=[],a){let i=a==null?void 0:a.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(r.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let l=e,u=i==null?void 0:i.errors;if(u!=null){let y=l.findIndex(j=>j.route.id&&(u==null?void 0:u[j.route.id])!==void 0);xt(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let d=!1,p=-1;if(a&&i){d=i.renderFallback;for(let y=0;y<l.length;y++){let j=l[y];if((j.route.HydrateFallback||j.route.hydrateFallbackElement)&&(p=y),j.route.id){let{loaderData:x,errors:S}=i,N=j.route.loader&&!x.hasOwnProperty(j.route.id)&&(!S||S[j.route.id]===void 0);if(j.route.lazy||N){a.isStatic&&(d=!0),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let m=a==null?void 0:a.onError,v=i&&m?(y,j)=>{var x,S;m(y,{location:i.location,params:((S=(x=i.matches)==null?void 0:x[0])==null?void 0:S.params)??{},pattern:fx(i.matches),errorInfo:j})}:void 0;return l.reduceRight((y,j,x)=>{let S,N=!1,b=null,k=null;i&&(S=u&&j.route.id?u[j.route.id]:void 0,b=j.route.errorElement||Ix,d&&(p<0&&x===0?(Dm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,k=null):p===x&&(N=!0,k=j.route.hydrateFallbackElement||null)));let C=r.concat(l.slice(0,x+1)),E=()=>{let R;return S?R=b:N?R=k:j.route.Component?R=h.createElement(j.route.Component,null):j.route.element?R=j.route.element:R=y,h.createElement($x,{match:j,routeContext:{outlet:y,matches:C,isDataRoute:i!=null},children:R})};return i&&(j.route.ErrorBoundary||j.route.errorElement||x===0)?h.createElement(Bm,{location:i.location,revalidation:i.revalidation,component:b,error:S,children:E(),routeContext:{outlet:null,matches:C,isDataRoute:!0},onError:v}):E()},null)}function qc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function _x(e){let r=h.useContext(bs);return xt(r,qc(e)),r}function Lx(e){let r=h.useContext(co);return xt(r,qc(e)),r}function Mx(e){let r=h.useContext(Cn);return xt(r,qc(e)),r}function Kc(e){let r=Mx(e),a=r.matches[r.matches.length-1];return xt(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Fx(){return Kc("useRouteId")}function Ox(){var i;let e=h.useContext(Gc),r=Lx("useRouteError"),a=Kc("useRouteError");return e!==void 0?e:(i=r.errors)==null?void 0:i[a]}function zx(){let{router:e}=_x("useNavigate"),r=Kc("useNavigate"),a=h.useRef(!1);return Om(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{pn(a.current,Fm),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:r,...u}))},[e,r])}var oh={};function Dm(e,r,a){!r&&!oh[e]&&(oh[e]=!0,pn(!1,a))}h.memo(Bx);function Bx({routes:e,manifest:r,future:a,state:i,isStatic:l,onError:u}){return zm(e,void 0,{manifest:r,state:i,isStatic:l,onError:u})}function Gn({to:e,replace:r,state:a,relative:i}){xt(Ss(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(ln);pn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=h.useContext(Cn),{pathname:p}=en(),m=gn(),v=lo(e,Wc(d),p,i==="path");Vc(typeof e=="string"?e:zr(e),u.createHref(v),Hc(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{m(JSON.parse(y),{replace:r,state:a,relative:i})},[m,y,i,r,a]),null}function Dx(e){return Ex(e.context)}function ht(e){xt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ux({basename:e="/",children:r=null,location:a,navigationType:i="POP",navigator:l,static:u=!1,useTransitions:d}){xt(!Ss(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=e.replace(/^\/*/,"/"),m=h.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:d,future:{}}),[p,l,u,d]);typeof a=="string"&&(a=ws(a));let{pathname:v="/",search:y="",hash:j="",state:x=null,key:S="default",mask:N}=a,b=h.useMemo(()=>{let k=qn(v,p);return k==null?null:{location:{pathname:k,search:y,hash:j,state:x,key:S,mask:N},navigationType:i}},[p,v,y,j,x,S,i,N]);return pn(b!=null,`<Router basename="${p}"> is not able to match the URL "${v}${y}${j}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:h.createElement(ln.Provider,{value:m},h.createElement(pa.Provider,{children:r,value:b}))}function Wx({children:e,location:r}){return Tx(Sc(e),r)}function Sc(e,r=[]){let a=[];return h.Children.forEach(e,(i,l)=>{if(!h.isValidElement(i))return;let u=[...r,l];if(i.type===h.Fragment){a.push.apply(a,Sc(i.props.children,u));return}xt(i.type===ht,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xt(!i.props.index||!i.props.children,"An index route cannot have child routes.");let d={id:i.props.id||u.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(d.children=Sc(i.props.children,u)),a.push(d)}),a}var Mi="get",Fi="application/x-www-form-urlencoded";function uo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Hx(e){return uo(e)&&e.tagName.toLowerCase()==="button"}function Vx(e){return uo(e)&&e.tagName.toLowerCase()==="form"}function Gx(e){return uo(e)&&e.tagName.toLowerCase()==="input"}function qx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Kx(e,r){return e.button===0&&(!r||r==="_self")&&!qx(e)}function kc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((r,a)=>{let i=e[a];return r.concat(Array.isArray(i)?i.map(l=>[a,l]):[[a,i]])},[]))}function Yx(e,r){let a=kc(e);return r&&r.forEach((i,l)=>{a.has(l)||r.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ti=null;function Jx(){if(Ti===null)try{new FormData(document.createElement("form"),0),Ti=!1}catch{Ti=!0}return Ti}var Qx=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oc(e){return e!=null&&!Qx.has(e)?(pn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Fi}"`),null):e}function Xx(e,r){let a,i,l,u,d;if(Vx(e)){let p=e.getAttribute("action");i=p?qn(p,r):null,a=e.getAttribute("method")||Mi,l=oc(e.getAttribute("enctype"))||Fi,u=new FormData(e)}else if(Hx(e)||Gx(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=e.getAttribute("formaction")||p.getAttribute("action");if(i=m?qn(m,r):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||Mi,l=oc(e.getAttribute("formenctype"))||oc(p.getAttribute("enctype"))||Fi,u=new FormData(p,e),!Jx()){let{name:v,type:y,value:j}=e;if(y==="image"){let x=v?`${v}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else v&&u.append(v,j)}}else{if(uo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Mi,i=null,l=Fi,d=e}return u&&l==="text/plain"&&(d=u,u=void 0),{action:i,method:a.toLowerCase(),encType:l,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Yc(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Um(e,r,a,i){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${i}`:l.pathname=`${l.pathname}.${i}`:l.pathname==="/"?l.pathname=`_root.${i}`:r&&qn(l.pathname,r)==="/"?l.pathname=`${gs(r)}/_root.${i}`:l.pathname=`${gs(l.pathname)}.${i}`,l}async function Zx(e,r){if(e.id in r)return r[e.id];try{let a=await import(e.module);return r[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function ej(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function tj(e,r,a){let i=await Promise.all(e.map(async l=>{let u=r.routes[l.route.id];if(u){let d=await Zx(u,a);return d.links?d.links():[]}return[]}));return aj(i.flat(1).filter(ej).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function lh(e,r,a,i,l,u){let d=(m,v)=>a[v]?m.route.id!==a[v].route.id:!0,p=(m,v)=>{var y;return a[v].pathname!==m.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==m.params["*"]};return u==="assets"?r.filter((m,v)=>d(m,v)||p(m,v)):u==="data"?r.filter((m,v)=>{var j;let y=i.routes[m.route.id];if(!y||!y.hasLoader)return!1;if(d(m,v)||p(m,v))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((j=a[0])==null?void 0:j.params)||{},nextUrl:new URL(e,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function nj(e,r,{includeHydrateFallback:a}={}){return rj(e.map(i=>{let l=r.routes[i.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function rj(e){return[...new Set(e)]}function sj(e){let r={},a=Object.keys(e).sort();for(let i of a)r[i]=e[i];return r}function aj(e,r){let a=new Set;return new Set(r),e.reduce((i,l)=>{let u=JSON.stringify(sj(l));return a.has(u)||(a.add(u),i.push({key:u,link:l})),i},[])}function Jc(){let e=h.useContext(bs);return Yc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ij(){let e=h.useContext(co);return Yc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Qc=h.createContext(void 0);Qc.displayName="FrameworkContext";function fo(){let e=h.useContext(Qc);return Yc(e,"You must render this element inside a <HydratedRouter> element"),e}function oj(e,r){let a=h.useContext(Qc),[i,l]=h.useState(!1),[u,d]=h.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:v,onMouseLeave:y,onTouchStart:j}=r,x=h.useRef(null);h.useEffect(()=>{if(e==="render"&&d(!0),e==="viewport"){let b=C=>{C.forEach(E=>{d(E.isIntersecting)})},k=new IntersectionObserver(b,{threshold:.5});return x.current&&k.observe(x.current),()=>{k.disconnect()}}},[e]),h.useEffect(()=>{if(i){let b=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(b)}}},[i]);let S=()=>{l(!0)},N=()=>{l(!1),d(!1)};return a?e!=="intent"?[u,x,{}]:[u,x,{onFocus:la(p,S),onBlur:la(m,N),onMouseEnter:la(v,S),onMouseLeave:la(y,N),onTouchStart:la(j,S)}]:[!1,x,{}]}function la(e,r){return a=>{e&&e(a),a.defaultPrevented||r(a)}}function lj({page:e,...r}){let a=yx(),{nonce:i}=fo(),{router:l}=Jc(),u=h.useMemo(()=>Nm(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(r.nonce==null&&i&&(r={...r,nonce:i}),a?h.createElement(uj,{page:e,matches:u,...r}):h.createElement(dj,{page:e,matches:u,...r})):null}function cj(e){let{manifest:r,routeModules:a}=fo(),[i,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return tj(e,r,a).then(d=>{u||l(d)}),()=>{u=!0}},[e,r,a]),i}function uj({page:e,matches:r,...a}){let i=en(),{future:l}=fo(),{basename:u}=Jc(),d=h.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let p=Um(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),m=!1,v=[];for(let y of r)typeof y.route.shouldRevalidate=="function"?m=!0:v.push(y.route.id);return m&&v.length>0&&p.searchParams.set("_routes",v.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,i,r]);return h.createElement(h.Fragment,null,d.map(p=>h.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function dj({page:e,matches:r,...a}){let i=en(),{future:l,manifest:u,routeModules:d}=fo(),{basename:p}=Jc(),{loaderData:m,matches:v}=ij(),y=h.useMemo(()=>lh(e,r,v,u,i,"data"),[e,r,v,u,i]),j=h.useMemo(()=>lh(e,r,v,u,i,"assets"),[e,r,v,u,i]),x=h.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let b=new Set,k=!1;if(r.forEach(E=>{var A;let R=u.routes[E.route.id];!R||!R.hasLoader||(!y.some(z=>z.route.id===E.route.id)&&E.route.id in m&&((A=d[E.route.id])!=null&&A.shouldRevalidate)||R.hasClientLoader?k=!0:b.add(E.route.id))}),b.size===0)return[];let C=Um(e,p,l.v8_trailingSlashAwareDataRequests,"data");return k&&b.size>0&&C.searchParams.set("_routes",r.filter(E=>b.has(E.route.id)).map(E=>E.route.id).join(",")),[C.pathname+C.search]},[p,l.v8_trailingSlashAwareDataRequests,m,i,u,y,r,e,d]),S=h.useMemo(()=>nj(j,u),[j,u]),N=cj(j);return h.createElement(h.Fragment,null,x.map(b=>h.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...a})),S.map(b=>h.createElement("link",{key:b,rel:"modulepreload",href:b,...a})),N.map(({key:b,link:k})=>h.createElement("link",{key:b,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function fj(...e){return r=>{e.forEach(a=>{typeof a=="function"?a(r):a!=null&&(a.current=r)})}}var hj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{hj&&(window.__reactRouterVersion="7.18.4")}catch{}function mj({basename:e,children:r,useTransitions:a,window:i}){let l=h.useRef();l.current==null&&(l.current=Uv({window:i,v5Compat:!0}));let u=l.current,[d,p]=h.useState({action:u.action,location:u.location}),m=h.useCallback(v=>{a===!1?p(v):h.startTransition(()=>p(v))},[a]);return h.useLayoutEffect(()=>u.listen(m),[u,m]),h.createElement(Ux,{basename:e,children:r,location:d.location,navigationType:d.action,navigator:u,useTransitions:a})}var ut=h.forwardRef(function({onClick:r,discover:a="render",prefetch:i="none",relative:l,reloadDocument:u,replace:d,mask:p,state:m,target:v,to:y,preventScrollReset:j,viewTransition:x,defaultShouldRevalidate:S,...N},b){let{basename:k,navigator:C,useTransitions:E}=h.useContext(ln),R=typeof y=="string"&&Uc.test(y),A=$m(y,k);y=A.to;let z=kx(y,{relative:l}),M=en(),H=null;if(p){let ee=lo(p,[],M.mask?M.mask.pathname:"/",!0);k!=="/"&&(ee.pathname=ee.pathname==="/"?k:kn([k,ee.pathname])),H=C.createHref(ee)}let[te,X,L]=oj(i,N),q=yj(y,{replace:d,mask:p,state:m,target:v,preventScrollReset:j,relative:l,viewTransition:x,defaultShouldRevalidate:S,useTransitions:E});function U(ee){r&&r(ee),ee.defaultPrevented||q(ee)}let K=!(A.isExternal||u),ce=h.createElement("a",{...N,...L,href:(K?H:void 0)||A.absoluteURL||z,onClick:K?U:r,ref:fj(b,X),target:v,"data-discover":!R&&a==="render"?"true":void 0});return te&&!R?h.createElement(h.Fragment,null,ce,h.createElement(lj,{page:z})):ce});ut.displayName="Link";var Xc=h.forwardRef(function({"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:u,to:d,viewTransition:p,children:m,...v},y){let j=ga(d,{relative:v.relative}),x=en(),S=h.useContext(co),{navigator:N,basename:b}=h.useContext(ln),k=S!=null&&bj(j)&&p===!0,C=N.encodeLocation?N.encodeLocation(j).pathname:j.pathname,E=x.pathname,R=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;a||(E=E.toLowerCase(),R=R?R.toLowerCase():null,C=C.toLowerCase()),R&&b&&(R=qn(R,b)||R);const A=C!=="/"&&C.endsWith("/")?C.length-1:C.length;let z=E===C||!l&&E.startsWith(C)&&E.charAt(A)==="/",M=R!=null&&(R===C||!l&&R.startsWith(C)&&R.charAt(C.length)==="/"),H={isActive:z,isPending:M,isTransitioning:k},te=z?r:void 0,X;typeof i=="function"?X=i(H):X=[i,z?"active":null,M?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let L=typeof u=="function"?u(H):u;return h.createElement(ut,{...v,"aria-current":te,className:X,ref:y,style:L,to:d,viewTransition:p},typeof m=="function"?m(H):m)});Xc.displayName="NavLink";var pj=h.forwardRef(({discover:e="render",fetcherKey:r,navigate:a,reloadDocument:i,replace:l,state:u,method:d=Mi,action:p,onSubmit:m,relative:v,preventScrollReset:y,viewTransition:j,defaultShouldRevalidate:x,...S},N)=>{let{useTransitions:b}=h.useContext(ln),k=jj(),C=wj(p,{relative:v}),E=d.toLowerCase()==="get"?"get":"post",R=typeof p=="string"&&Uc.test(p),A=z=>{if(m&&m(z),z.defaultPrevented)return;z.preventDefault();let M=z.nativeEvent.submitter,H=(M==null?void 0:M.getAttribute("formmethod"))||d,te=()=>k(M||z.currentTarget,{fetcherKey:r,method:H,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:j,defaultShouldRevalidate:x});b&&a!==!1?h.startTransition(()=>te()):te()};return h.createElement("form",{ref:N,method:E,action:C,onSubmit:i?m:A,...S,"data-discover":!R&&e==="render"?"true":void 0})});pj.displayName="Form";function gj(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wm(e){let r=h.useContext(bs);return xt(r,gj(e)),r}function yj(e,{target:r,replace:a,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m,useTransitions:v}={}){let y=gn(),j=en(),x=ga(e,{relative:d});return h.useCallback(S=>{if(Kx(S,r)){S.preventDefault();let N=a!==void 0?a:zr(j)===zr(x),b=()=>y(e,{replace:N,mask:i,state:l,preventScrollReset:u,relative:d,viewTransition:p,defaultShouldRevalidate:m});v?h.startTransition(()=>b()):b()}},[j,y,x,a,i,l,r,e,u,d,p,m,v])}function ks(e){pn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let r=h.useRef(kc(e)),a=h.useRef(!1),i=en(),l=h.useMemo(()=>Yx(i.search,a.current?null:r.current),[i.search]),u=gn(),d=h.useCallback((p,m)=>{const v=kc(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+v,m)},[u,l]);return[l,d]}var vj=0,xj=()=>`__${String(++vj)}__`;function jj(){let{router:e}=Wm("useSubmit"),{basename:r}=h.useContext(ln),a=Fx(),i=e.fetch,l=e.navigate;return h.useCallback(async(u,d={})=>{let{action:p,method:m,encType:v,formData:y,body:j}=Xx(u,r);if(d.navigate===!1){let x=d.fetcherKey||xj();await i(x,a,d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:j,formMethod:d.method||m,formEncType:d.encType||v,flushSync:d.flushSync})}else await l(d.action||p,{defaultShouldRevalidate:d.defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:j,formMethod:d.method||m,formEncType:d.encType||v,replace:d.replace,state:d.state,fromRouteId:a,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,l,r,a])}function wj(e,{relative:r}={}){let{basename:a}=h.useContext(ln),i=h.useContext(Cn);xt(i,"useFormAction must be used inside a RouteContext");let[l]=i.matches.slice(-1),u={...ga(e||".",{relative:r})},d=en();if(e==null){u.search=d.search;let p=new URLSearchParams(u.search),m=p.getAll("index");if(m.some(y=>y==="")){p.delete("index"),m.filter(j=>j).forEach(j=>p.append("index",j));let y=p.toString();u.search=y?`?${y}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:kn([a,u.pathname])),zr(u)}function bj(e,{relative:r}={}){let a=h.useContext(Lm);xt(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Wm("useViewTransitionState"),l=ga(e,{relative:r});if(!a.isTransitioning)return!1;let u=qn(a.currentLocation.pathname,i)||a.currentLocation.pathname,d=qn(a.nextLocation.pathname,i)||a.nextLocation.pathname;return Ui(l.pathname,d)!=null||Ui(l.pathname,u)!=null}var Sj=Sm();const Mr="owner";function kj(e){const r=e||Mr;return r===Mr?[Mr]:[r,Mr]}function Nj(e){const r=new Map;for(const a of e)for(const i of a)r.has(i.id)||r.set(i.id,i);return[...r.values()].sort((a,i)=>i.createdAt-a.createdAt)}function Cj(e,r){const a=r||Mr,i=(e==null?void 0:e.pendingDomains)??[];return i.includes(a)?a:i.includes(Mr)?Mr:a}function Ej(e){const r=Array.isArray(e)?e.map(i=>i==null?void 0:i.expiresAt).filter(i=>typeof i=="number"):[];if(r.length===0)return{earliest_expiry:null,remaining_seconds:null};const a=Math.min(...r);return{earliest_expiry:new Date(a*1e3).toISOString(),remaining_seconds:Math.max(0,a-Math.floor(Date.now()/1e3))}}class Hm extends Error{constructor(a){super("different_account");ia(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Vm(e){return e.grantors??e.approvers}function Tj(e){return e.approvals??1}function Je(e,r){const a=e??{},i=Array.isArray(a.errors)?a.errors[0]:void 0;return i!=null&&i.message?i.code?`${i.message} (${i.code})`:i.message:i!=null&&i.code?i.code:a.error||a.detail||r}function Aj(e){const r=e==null?void 0:e.pubkeys;return!r||typeof r!="object"||Array.isArray(r)?[]:Object.entries(r).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,i])=>({userId:a,publicKey:i}))}class Ij{constructor(){ia(this,"apiKey",null)}setApiKey(r){this.apiKey=r}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(r,a){return globalThis.fetch(r,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(r,a={}){const i=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":r,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(i.status===409){const u=await i.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Hm(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!i.ok){const u=await i.json().catch(()=>({error:"Invalid API key"}));throw new Error(Je(u,`Login failed: ${i.status}`))}return(await i.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const r=await this.fetch("/api/groups");if(!r.ok)throw new Error(`Failed to fetch groups: ${r.status}`);const a=await r.json();return a.groups??a}async listProfiles(){const r=await this.fetch("/api/profiles");if(!r.ok)throw new Error(`Failed to fetch profiles: ${r.status}`);return(await r.json()).profiles}async getProfile(r){const a=await this.fetch(`/api/profiles/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(r){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(i,`Signing failed: ${a.status}`))}return a.json()}async getPending(r){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const i=await a.json();return i.pending??i}async getMyAttestations(r){const a=r?`?status=${encodeURIComponent(r)}`:"",i=await this.fetch(`/api/mandates/mine${a}`);if(!i.ok)throw new Error(`Failed to fetch attestations: ${i.status}`);return((await i.json()).mandates??[]).map(u=>({authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(d=>!(u.attestedDomains??[]).includes(d)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",...Ej(u.mandates??u.attestations)}))}async getDenials(r){const a=new URLSearchParams;r!=null&&r.since&&a.set("since",String(r.since)),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${i}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(r){const a=new URLSearchParams;r!=null&&r.date&&a.set("date",r.date),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const r=await this.fetch("/api/evidence-export"),a=await r.json();if(!r.ok)throw new Error(Je(a,`Export failed (${r.status})`));const i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:i}}async getLocalAuthorizations(){const r=await this.fetch("/api/evidence/authorizations");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(r){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const r=await this.fetch("/api/evidence/headlines");if(!r.ok)throw new Error(`Local evidence unavailable (${r.status})`);const a=await r.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const r=await this.fetch("/api/report");if(!r.ok){const a=await r.json().catch(()=>({error:`Report unavailable (${r.status})`}));throw new Error(Je(a,`Report unavailable (${r.status})`))}return r.json()}async saveReport(r){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:r})});if(!a.ok){const i=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(Je(i,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const r=await this.fetch("/api/report/recheck",{method:"POST"});if(!r.ok){const a=await r.json().catch(()=>({error:`Recheck failed (${r.status})`}));throw new Error(Je(a,`Recheck failed (${r.status})`))}return r.json()}async exportReportWithProof(){var l;const r=await this.fetch("/api/report/export");if(!r.ok){const u=await r.json().catch(()=>({error:`Export failed (${r.status})`}));throw new Error(Je(u,`Export failed (${r.status})`))}const a=await r.text(),i=((l=/filename="([^"]+)"/.exec(r.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:i}}async revokeAttestation(r,a){const i=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to revoke"}));throw new Error(Je(l,`Revoke failed: ${i.status}`))}}async getAttestations(r){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const i=await a.json();return{...i,attestations:i.mandates??i.attestations??[]}}async getGroupById(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(r){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:r})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(u,`Create group failed: ${a.status}`))}const i=await a.json(),l=i.group||i;return{id:l.id,name:l.name,myDomains:l.myDomains||[],isAdmin:!0,ended:i.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const r=await this.fetch("/api/groups/create/preview");if(!r.ok){const a=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(a,`Failed to preview team creation: ${r.status}`))}return r.json()}async getJoinPreview(r){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(r)}`);if(!a.ok){const i=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(Je(i,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(r){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:r})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(l,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const r=await this.fetch("/api/groups/join",{method:"DELETE"});if(r.status===404)return!1;if(!r.ok){const i=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(i,`Withdraw failed: ${r.status}`))}return(await r.json()).withdrawn===!0}async inviteToGroup(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/invite`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Je(i,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const r=await this.fetch("/api/groups/me");if(!r.ok)return{group:null,membership:null,pendingRequest:null};const a=await r.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const r=await this.fetch("/api/users");return r.ok?(await r.json()).users??[]:[]}async setPubkey(r){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(Je(i,`setPubkey failed: ${a.status}`))}}async getPubkey(r){const a=await this.fetch(`/api/users/${encodeURIComponent(r)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/leave`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(Je(i,`Leave failed: ${a.status}`))}}async getVaultStatus(){const r=await this.fetch("/vault/status");if(!r.ok)throw new Error(`Failed to fetch vault status: ${r.status}`);return r.json()}async getGatewaySettings(){const r=await this.fetch("/api/gateway-settings");if(!r.ok)throw new Error(`Failed to load settings: ${r.status}`);return r.json()}async setGatewaySettings(r){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const r=await this.fetch("/api/archived-mandates");if(!r.ok)throw new Error(`Failed to load archived mandates: ${r.status}`);return(await r.json()).archived}async setMandateArchived(r,a){const i=await this.fetch(`/api/archived-mandates/${encodeURIComponent(r)}`,{method:a?"PUT":"DELETE"});if(!i.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${i.status}`);return(await i.json()).archived}async getLastSeenBlockedAt(){const r=await this.fetch("/api/blocked-seen");if(!r.ok)throw new Error(`Failed to load last-seen: ${r.status}`);return(await r.json()).lastSeenBlockedAt}async markBlockedSeen(r=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const r=await this.fetch("/api/report-seen");if(!r.ok)throw new Error(`Failed to load last-seen report: ${r.status}`);return(await r.json()).lastSeenReportAt}async markReportSeen(r=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const r=await this.fetch("/api/tickets-seen");if(!r.ok)throw new Error(`Failed to load last-seen tickets: ${r.status}`);return(await r.json()).lastSeenTicketsAt}async markTicketsSeen(r=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:r})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(r){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(r,a){const i=await this.fetch(`/vault/credentials/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to save credential: ${i.status}`)}async testCredential(r){const a=await this.fetch(`/vault/test/${encodeURIComponent(r)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(r){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Je(i,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(r){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Je(i,"AI request failed")}}return a.json()}async aiTest(r){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(r){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(r??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const r=await this.fetch("/mcp/health");if(!r.ok)throw new Error(`MCP server unreachable: ${r.status}`);return r.json()}async getAgentContact(){const r=await this.fetch("/mcp/agent-contact");if(!r.ok)throw new Error(`Failed to fetch agent contact: ${r.status}`);return r.json()}async getMcpIntegrations(){const r=await this.fetch("/mcp/integrations");if(!r.ok)throw new Error(`Failed to fetch integrations: ${r.status}`);return r.json()}async getOAuthHealth(r){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(r)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const r=await this.fetch("/mcp/integrations/manifests");if(!r.ok)throw new Error(`Failed to fetch manifests: ${r.status}`);return r.json()}async getLabelManifests(){const{manifests:r,builtins:a}=await this.getIntegrationManifests();return[...r??[],...a??[]]}async discoverScopeField(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/discover/${encodeURIComponent(a)}`);if(!i.ok){const l=await i.json().catch(()=>({error:`Discovery failed: ${i.status}`}));throw new Error(Je(l,`Discovery failed: ${i.status}`))}return i.json()}async activateIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}/activate`,{method:"POST"});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(Je(i,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(r){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(r)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(r,a){const i=await this.fetch(`/integrations/${encodeURIComponent(r)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!i.ok){const l=await i.json().catch(()=>({error:`HTTP ${i.status}`}));throw new Error(Je(l,`HTTP ${i.status}`))}}async getTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`);if(i.status===404||!i.ok)return null;const l=await i.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(r,a,i){const l=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(i)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(Je(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(r,a){const i=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:r,recipients:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Je(l,`encryptIntent failed: ${i.status}`))}return i.json()}async getToolDisplay(){const r=await this.fetch("/tool-display");if(!r.ok)return{};const a=await r.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return i.ok?Aj(await i.json()):[]}async deleteTeamProfileConfig(r,a){const i=await this.fetch(`/api/groups/${encodeURIComponent(r)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(Je(l,`deleteTeamProfileConfig failed: ${i.status}`))}}async getIdentityDisclosure(){const r=await this.fetch("/api/users/me/identity-disclosure");if(!r.ok)throw new Error(`Failed to read identity setting: ${r.status}`);return r.json()}async setIdentityDisclosure(r){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:r})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(r,a="pending"){const i=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(r)}${i}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(r,a="pending"){const i=await Promise.all(kj(r).map(l=>this.getProposals(l,a)));return Nj(i)}async resolveProposal(r,a,i,l){const{noteEncrypted:u,contentHash:d,shownHash:p,note:m,...v}=l??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:i,...v,...u?{note_encrypted:u}:m?{note:m}:{},...d?{content_hash:d}:{},...p?{shown_hash:p}:{}})});if(!y.ok){const j=await y.json().catch(()=>({error:"Failed"}));throw new Error(Je(j,`Failed: ${y.status}`))}return y.json()}async getProposal(r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(r)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(Je(l,`getProposal failed: ${a.status}`))}const i=await a.json();return i.proposal??i}async getProposalsForApprover(){const r=await this.fetch("/api/proposals?approver=me");if(!r.ok)throw new Error(`Failed to fetch approver proposals: ${r.status}`);return(await r.json()).proposals??[]}async approveProposal(r,a,i){const l={};a&&(l.content_hash=a),i&&(l.shown_hash=i);const u=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const d=await u.json().catch(()=>({error:"Failed"}));throw new Error(Je(d,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(r,a,i,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:p,note:m,...v}=a??{};u={...v,...p?{note_encrypted:p}:m?{note:m}:{}}}i&&(u.content_hash=i),l&&(u.shown_hash=l);const d=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!d.ok){const p=await d.json().catch(()=>({error:"Failed"}));throw new Error(Je(p,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalsCreatedByMe(){const r=await this.fetch("/api/proposals?creator=me");if(r.status===400)return null;if(!r.ok)throw new Error(`Failed to fetch my proposals: ${r.status}`);return(await r.json()).proposals??[]}async withdrawProposal(r,a,i,l){const{noteEncrypted:u,note:d}=a??{},p={...u?{note_encrypted:u}:d?{note:d}:{}};i&&(p.content_hash=i),l&&(p.shown_hash=l);const m=await this.fetch(`/api/proposals/${encodeURIComponent(r)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!m.ok){const v=await m.json().catch(()=>({error:"Failed"}));throw new Error(Je(v,`withdrawProposal failed: ${m.status}`))}return m.json()}async getProposalPreview(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!i.ok)throw new Error(`Failed to store the shown snapshot: ${i.status}`);return i.json()}async getShownSnapshot(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(r){const a=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getProposalAttachmentPreview(r,a){const i=await this.fetch(`/proposal-status/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getReceiptAttachmentPreview(r,a){const i=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(r)}/attachment-preview/${encodeURIComponent(a)}`);if(!i.ok)throw new Error(`Failed to fetch attachment preview: ${i.status}`);return i.json()}async getAttestationIntent(r){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(r)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(r){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Je(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(r){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Je(i,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(r,a){const i=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:r,recipientUserIds:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Encryption failed"}));throw new Error(Je(l,`encryptProposalNote failed: ${i.status}`))}return i.json()}async storeApprovedIntent(r,a){const i=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:r,intent:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Failed"}));throw new Error(Je(l,`storeApprovedIntent failed: ${i.status}`))}}async listTeamAuthorizations(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var p,m;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(v=>!(l.attestedDomains??l.attested_domains??[]).includes(v)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(m=l.mandates)!=null&&m.length?Math.max(0,Math.min(...l.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(r){const a=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(r){const a=new URLSearchParams;r!=null&&r.before&&a.set("before",r.before),r!=null&&r.profile&&a.set("profile",r.profile),r!=null&&r.limit&&a.set("limit",String(r.limit));const i=a.toString(),l=await this.fetch(`/api/tickets/mine${i?"?"+i:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(r,a){const i=new URLSearchParams;a!=null&&a.before&&i.set("before",a.before),a!=null&&a.profile&&i.set("profile",a.profile),a!=null&&a.limit&&i.set("limit",String(a.limit));const l=i.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(r)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const d=await u.json();return{receipts:d.tickets??[],nextBefore:d.nextBefore??null}}async getThread(r){const a=r.sinceDays??7,i=r.status??"pending",l=await this.getMyProposals(r.domain,i);let u=[];if(i==="all"){const d=[],p=new Date;for(let v=0;v<a;v++){const y=new Date(p);y.setUTCDate(p.getUTCDate()-v),d.push(y.toISOString().slice(0,10))}u=(await Promise.all(d.map(v=>this.getMyReceipts({date:v,profile:r.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const r=await this.fetch("/autostart");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async setAutostart(r){const a=await this.fetch("/autostart",{method:r?"POST":"DELETE"});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.message||`HTTP ${a.status}`)}}async getAsPairing(){const r=await this.fetch("/as-pairing");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getSkippedCommitments(){const r=await this.fetch("/skipped-commitments");if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async getMyPendingProposals(){const r=await this.fetch("/my-pending-proposals");return r.ok?(await r.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(r){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(r)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const r=await this.fetch("/resync-gates",{method:"POST"});if(!r.ok)throw new Error(`Failed to resync gates: ${r.status}`)}async getEnrichedAuthorizations(){const r=await this.fetch("/active-authorizations");if(!r.ok)throw new Error(`Failed to fetch authorizations: ${r.status}`);return(await r.json()).authorizations??[]}async pushGateContent(r){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(Je(i,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const r=await this.fetch("/agent-brief/context");if(!r.ok)throw new Error(`Failed to fetch agent context: ${r.status}`);return(await r.json()).content}async saveAgentContext(r){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(Je(i,`Save failed: ${a.status}`))}}async aiChat(r){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:Je(i,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const r=await this.fetch("/ai-prompts");if(!r.ok)throw new Error(`Failed to load AI prompts: ${r.status}`);return r.json()}async setAIPrompt(r,a){const i=await this.fetch(`/ai-prompts/${r}`,{method:"PUT",body:JSON.stringify({value:a})});if(!i.ok){const l=await i.json().catch(()=>({error:"Save failed"}));throw new Error(Je(l,`Save failed: ${i.status}`))}}}const P=new Ij,Gm=h.createContext(null);function Rj({children:e}){const[r,a]=h.useState(null),[i,l]=h.useState("personal"),[u,d]=h.useState(null),[p,m]=h.useState(""),[v,y]=h.useState(null),[j,x]=h.useState(null),[S,N]=h.useState(null),[b,k]=h.useState(!1),[C,E]=h.useState(""),R=h.useRef(!1),A=h.useRef(null),z=h.useCallback(async()=>{if(R.current)try{const q=await P.getMyTeam();if(N(q.pendingRequest),q.group&&q.membership){const{group:U,membership:K}=q;y(U),x(K),l("team"),d(U);const ce=A.current??K.domains[0]??"owner";m(ce)}else y(null),x(null),l("personal")}catch{}},[]);h.useEffect(()=>{const q=()=>{document.visibilityState==="visible"&&z()};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[z]),h.useEffect(()=>{fetch("/health").then(q=>q.json()).then(q=>{var U;((U=q.session)==null?void 0:U.lockedReason)==="as-url-changed"&&E(`Authority Server changed to ${q.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const M=h.useCallback(async(q,U={})=>{k(!0),E("");try{P.setApiKey(q),R.current=!0;const K=await P.login(q,U);a(K),A.current=K.id;const ce=await P.getGroups(),ee=ce.find(Se=>Se.isPersonal)??ce[0]??null;d(ee),m("owner"),await z()}catch(K){throw P.clearApiKey(),R.current=!1,E(K instanceof Error?K.message:"Login failed"),K}finally{k(!1)}},[z]),H=h.useCallback(async()=>{await P.logout(),P.clearApiKey(),R.current=!1,A.current=null,a(null),d(null),m(""),y(null),x(null),N(null),l("personal"),E("")},[]),te=h.useCallback(q=>{P.clearApiKey(),R.current=!1,A.current=null,a(null),d(null),m(""),y(null),x(null),N(null),l("personal"),E(q??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),X=h.useCallback(()=>E(""),[]),L=h.useCallback((q,U)=>{d(q),m(U)},[]);return n.jsx(Gm.Provider,{value:{user:r,mode:i,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:j,pendingRequest:S,isLoading:b,error:C,login:M,logout:H,clearError:X,handleSessionLocked:te,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:L,refreshGroups:z},children:e})}function kt(){const e=h.useContext(Gm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const $j={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},Pj=Object.keys($j),qm=h.createContext(null);function _j({children:e}){const{user:r}=kt(),a=h.useRef(null),[i,l]=h.useState(!1),u=h.useRef(new Map),d=h.useCallback((p,m)=>{const v=u.current;return v.has(p)||v.set(p,new Set),v.get(p).add(m),()=>{var y;(y=v.get(p))==null||y.delete(m)}},[]);return h.useEffect(()=>{if(!r){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=P.getApiKey();if(!p)return;const m=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=m,m.onopen=()=>l(!0),m.onerror=()=>l(!1);for(const v of Pj)m.addEventListener(v,y=>{let j;try{j=JSON.parse(y.data)}catch{j=null}const x=u.current.get(v);if(x)for(const S of x)try{S(j)}catch(N){console.error(`[EventSource] handler for "${v}" threw:`,N)}});return()=>{m.close(),a.current=null,l(!1)}},[r]),n.jsx(qm.Provider,{value:{connected:i,addListener:d},children:e})}function He(e,r){const a=h.useContext(qm);if(!a)return;const{addListener:i}=a;h.useEffect(()=>i(e,r),[e,r,i])}const ha="suveren-theme",ch="hap-theme";function Ai(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const r=localStorage.getItem(ch);r!==null&&localStorage.getItem(ha)===null&&localStorage.setItem(ha,r),r!==null&&localStorage.removeItem(ch)})();function Km(){const[e,r]=h.useState(()=>{const u=localStorage.getItem(ha);return u==="light"||u==="dark"?u:"system"}),[a,i]=h.useState(()=>Ai(e));h.useEffect(()=>{const u=document.documentElement,d=Ai(e);u.setAttribute("data-theme",d),e==="system"?localStorage.removeItem(ha):localStorage.setItem(ha,e),i(Ai(e))},[e]),h.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>i(Ai("system"));return u.addEventListener("change",d),()=>u.removeEventListener("change",d)},[e]);const l=h.useCallback(()=>{r(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const Lj=300*1e3,Mj=2e3;function Zc(){const[e,r]=h.useState(!1),[a,i]=h.useState("docker"),[l,u]=h.useState(""),[d,p]=h.useState(null),[m,v]=h.useState(!1),[y,j]=h.useState(!1),[x,S]=h.useState(!1),N=h.useRef(null);return h.useEffect(()=>{let b=!1;const k=(R=!1)=>{fetch(R?"/health?refresh=1":"/health").then(A=>A.json()).then(A=>{b||(A.installMethod&&i(A.installMethod),typeof A.latestVersion<"u"&&p(A.latestVersion),A.updateAvailable&&r(!0),A.version&&(u(A.version),N.current===null?N.current=A.version:A.version!==N.current&&A.version!=="dev"&&v(!0)))}).catch(()=>{})};k(!0);const C=setInterval(()=>k(!1),x?Mj:Lj),E=()=>{document.visibilityState==="visible"&&k(!1)};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",E),()=>{b=!0,clearInterval(C),document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",E)}},[x]),{updateAvailable:e&&!y,installMethod:a,version:l,latestVersion:d,serverRestarted:m,startFastPolling:()=>S(!0),dismiss:()=>j(!0)}}function Fj(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Oj(){const[e,r]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(Fj(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function zj({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Bj(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const uh={system:"◑",light:"☀",dark:"☾"};function eu({onMenuToggle:e}){const{user:r,logout:a,mode:i,activeTeam:l}=kt(),{theme:u,toggle:d}=Km(),{version:p,updateAvailable:m,latestVersion:v}=Zc(),{managed:y}=Oj(),j=Bj(p),x=i==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(zj,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),j&&n.jsxs("span",{className:"gw-version",title:m&&v?`Running v${j} — v${v} is available`:"Running gateway version","data-stale":m?"true":void 0,children:["v",j,m&&v?` → ${v}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:r?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${x} — set by your IT`:x,children:[x,y&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:r.name})}),n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:uh[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:d,title:`Theme: ${u}`,children:uh[u]})}),r&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function tu(e,r){var a;if((a=r==null?void 0:r.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Ym(e){return e==="expired"||e==="revoked"}function Jm(e,r){var a;return!!((a=r==null?void 0:r.archivedSet)!=null&&a.has(e.authorization_id))&&Ym(tu(e,r))}function Wi(e,r){return Jm(e,r)?"archived":tu(e,r)}function Qm(e,r){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const i of e)a[Wi(i,r)].push(i);return a}function Dj(e,r){return r==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Wt(e,r,a){const i=h.useRef(e);i.current=e,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",d=()=>{u()&&i.current()},p=()=>{l===null&&(l=setInterval(d,r))},m=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(i.current(),p()):m()};return u()&&(i.current(),p()),document.addEventListener("visibilitychange",v),()=>{m(),document.removeEventListener("visibilitychange",v)}},[r,a])}function nu(){const[e,r]=h.useState(!1);return h.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(d.simulation===!0)}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function Uj(e,r){const a=e.simulation;return a?(((r==null?void 0:r[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Hi(e){return!!(e!=null&&e.simulation)}function dh(e,r){return Xm(e,e.modeLabels,r)}function fh(e,r){return Xm(e,e.modeNotes,r)}function Xm(e,r,a){const i=e.simulation;if(!r||!i)return;const l=((a==null?void 0:a[i.field])??"").trim().toLowerCase()||i.default.trim().toLowerCase(),u=r[l];if(u===void 0)return;if(typeof u=="string")return u;const d=e.adapterField,p=d?((a==null?void 0:a[d])??"").trim().toLowerCase():"";return p?u[p]:void 0}function Vi(e,r){var a;return r&&(!Hi(e.manifest)||((a=e.integration)==null?void 0:a.paused)==="simulation")}function Wj(e,r=!1){var i;const a=[];for(const l of e)Vi(l,r)||(l.state==="error"?a.push({label:"Integration error",detail:(i=l.integration)!=null&&i.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(Hi(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function Hj(e){const r=e.filter(a=>a.state==="paused");return r.length===0?null:{count:r.length,namesText:r.map(a=>a.manifest.name).join(", ")}}const Zm=h.createContext(null),Vj=3e4,Gj=5e3,qj=3e5;function Kj(e,r,a){return r===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function Yj({children:e}){const[r,a]=h.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),i=h.useRef(null),l=h.useCallback(async()=>{let y=!1;const[j,x]=await Promise.all([P.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),P.getMcpHealth().catch(()=>null)]);a(N=>({...N,manifests:j.manifests,integrations:(x==null?void 0:x.integrations)??N.integrations,activeSessions:(x==null?void 0:x.activeSessions)??N.activeSessions,mcpServerUp:!!x,manifestsError:y,fetchCount:N.fetchCount+1}));const S=j.manifests.filter(N=>N.oauth);if(S.length>0){const N=await Promise.all(S.map(async b=>[b.id,await P.getOAuthHealth(b.id)]));a(b=>({...b,authHealth:Object.fromEntries(N)}))}},[]),u=r.fetchCount>0&&r.manifests.some(y=>{const j=r.integrations.find(x=>x.id===y.id);return j&&!j.running&&!j.paused});He("integration-changed",l),Wt(l,u?Gj:qj);const d=h.useMemo(()=>{const y=new Map(r.integrations.map(S=>[S.id,S])),j=Date.now();u&&i.current===null?i.current=j:u||(i.current=null);const x=i.current!==null&&j-i.current<Vj;return r.manifests.map(S=>{const N=y.get(S.id),b=Kj(N,r.fetchCount,x),k=r.authHealth[S.id];return{id:S.id,manifest:S,integration:N,state:b,authStatus:k==null?void 0:k.status,authAccount:k==null?void 0:k.account,authError:k==null?void 0:k.error}})},[r,u]),p=nu(),m=h.useMemo(()=>d.filter(y=>!Vi(y,p)&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[d,p]),v={loading:r.fetchCount===0,mcpServerUp:r.mcpServerUp,manifestsError:r.manifestsError,entries:d,attentionCount:m,activeSessions:r.activeSessions,refresh:l};return n.jsx(Zm.Provider,{value:v,children:e})}function ru(){const e=h.useContext(Zm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const hh=40;function Ht(e,r){const a=e.lastIndexOf("/"),i=a>=0?e.slice(a+1):e,l=i.indexOf("@"),u=l>=0?i.slice(0,l):i;return r?r.slice(0,hh):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,hh)}function Nn(e){const r=e.lastIndexOf("/"),a=r>=0?e.slice(r+1):e,i=a.indexOf("@");return(i>=0?a.slice(0,i):a).toLowerCase()}function xr(e,r){const a=Nn(e),i=Kn(e),l=Ht(e,r==null?void 0:r.name);return{icon:i,name:l,testSetup:a==="delegation"}}function ho(e){return e.startsWith("setup__")}const Jj={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup",invoicing:"invoicing","master-data":"masterData"};function Kn(e){return Jj[Nn(e)]??"unknown"}function mh(e){const r=e.indexOf("@");return r>=0?e.slice(r+1):""}function Yn(e,r){const a=Nn(e),i=r.filter(l=>Nn(l.id)===a).sort((l,u)=>mh(u.id).localeCompare(mh(l.id),void 0,{numeric:!0}))[0];return Ht(e,i==null?void 0:i.name)}function Nc(e,r){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==r.trim().toLowerCase():!1}function ep(e){return e&&e.trim()?e.trim():null}function tp(e,r){return r===null||Nn(e)===r}let lc=null;function np(){return lc||(lc=P.listProfiles().catch(()=>[])),lc}function Mn(){const[e,r]=h.useState([]);return h.useEffect(()=>{let a=!0;return np().then(i=>{a&&r(i)}),()=>{a=!1}},[]),e}function Qj(e){const r=Mn();return Yn(e,r)}const Xj={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),invoicing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2-1.3-2 1.3-2-1.3-2 1.3-2-1.3L6 21z"}),n.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),masterData:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.5 7.5h15a1.5 1.5 0 0 1 1.5 1.5v9.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18.5V9a1.5 1.5 0 0 1 1.5-1.5z"}),n.jsx("path",{d:"M6 7.5V5h6v2.5M7 12h10M7 16h6"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function Br({icon:e,className:r}){return n.jsx("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Xj[e]})}function rp(){return n.jsxs("svg",{className:"ob-i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]})}function Zj(){return n.jsx("svg",{className:"ob-i ob-chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function Fr({tag:e,parts:r,className:a,profileId:i}){return n.jsxs("div",{className:`ob-type${a?` ${a}`:""}`,children:[n.jsx("span",{className:"ob-tag",children:e}),r.filter(Boolean).map((l,u)=>n.jsxs("span",{className:u===0&&i?"ob-area":void 0,children:[u===0&&i&&n.jsx(Br,{icon:Kn(i)}),l]},u))]})}function Jn({title:e,summary:r,children:a,open:i,testId:l,attrs:u,onToggle:d}){return n.jsxs("details",{className:"ob-fold","data-testid":l,...u,open:i,onToggle:d?p=>d(p.currentTarget.open):void 0,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:e}),r!=null&&n.jsx("span",{className:"one",children:r}),n.jsx(Zj,{})]}),n.jsx("div",{className:"ob-fold-body",children:a})]})}function su(){const e=h.useRef(null);return h.useCallback(r=>{var i;if((i=e.current)==null||i.call(e),e.current=null,!r)return;const a=l=>{var d;const u=l.target;!u.open||!((d=u.classList)!=null&&d.contains("ob-fold"))||r.querySelectorAll("details.ob-fold[open]").forEach(p=>{p!==u&&(p.open=!1)})};r.addEventListener("toggle",a,!0),e.current=()=>r.removeEventListener("toggle",a,!0)},[])}const e0={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},ys=e=>e0[e]??e,t0={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function n0(e){return(e&&t0[e])??{chip:"Blocked",sev:"info"}}function r0(e){const r=ys(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",r]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",r," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",r," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",r," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",r," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function s0(e,r){const a=Math.max(0,(r-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const i=Math.floor(a/86400);return i===1?"Yesterday":`${i} days ago`}const a0=5,i0=1440*60*1e3,o0=7;function l0(e,r){const a=r-o0*i0;return{recent:e.filter(i=>i.ts>=a),all:e}}function c0(){const[e,r]=h.useState(null),[a,i]=h.useState(!1),[l,u]=h.useState(null),d=Mn(),p=h.useCallback(()=>{P.getDenials({limit:200}).then(({records:x})=>{r(x),i(!1)}).catch(()=>i(!0)),P.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(h.useEffect(()=>{p()},[p]),Wt(p,12e4),He("denial-recorded",p),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",p),()=>window.removeEventListener("suveren:blocked-seen-changed",p)),[p]),a||e===null||l===null)return null;const{all:m}=l0(e,Date.now()),v=m.filter(x=>x.ts>l);if(v.length===0)return null;const y=v.slice(0,a0),j=(x,S)=>{const N=x.profile?Yn(x.profile,d):ys(x.integrationId),b=n0(x.reason);return n.jsxs(ut,{className:"ob-card dash-row",to:"/blocked","data-testid":"dash-blocked",children:[n.jsx(Fr,{tag:"Blocked",className:"obj-line",profileId:x.profile??void 0,parts:[N,`via ${ys(x.integrationId)}`,cp(x.ts,Date.now())]}),n.jsx("span",{className:"ob-title",children:x.reason?r0(x):up(x)}),n.jsxs("span",{className:"ob-one ob-check-x",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",n.jsx("b",{children:dp(x)})," ",n.jsx("span",{className:"ob-quiet-inline",children:x.reason?b.chip:lp(x).sentence})]})]},`${x.ts}-${S}`)};return n.jsxs("section",{className:"dash-sec","aria-label":"Blocked — new since you looked","data-testid":"dash-blocked-sec",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Blocked — new since you looked"}),n.jsx("span",{className:"pill-count",children:v.length})]}),n.jsx("div",{className:"dash-rows",children:y.map(j)}),v.length>y.length&&n.jsx(ut,{className:"ob-btn dash-btn",to:"/blocked",children:"All blocked"})]})}function mo(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const sp=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function Ot(e){const r=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return r.charAt(0).toUpperCase()+r.slice(1)}function Ln(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function u0(e){const{integrationId:r,toolName:a}=Ln(e);return r?`${r} · ${a}`:a}function jr(e,r){const a=r==null?void 0:r.find(i=>i.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function d0(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
52
|
-
`)||e.length>120)?"markdown":"text"}function ap(e,r){var d,p;const a=(r==null?void 0:r.approvalView)??{},i=((d=r==null?void 0:r.inputSchema)==null?void 0:d.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(i),...Object.keys(e)])],u=[];for(const m of l){if(!(m in e)||sp.has(m)||m===(r==null?void 0:r.aiTextArg))continue;const v=e[m],y=a[m]??{},j=y.kind??d0(v),x={key:m,label:y.label??Ot(m),kind:j,value:v,hint:(p=i[m])==null?void 0:p.description};j==="money"&&y.currencyArg&&typeof e[y.currencyArg]=="string"&&(x.currency=e[y.currencyArg]),j==="profile"&&typeof v=="string"&&(x.profileRef=v),(j==="profile-limits"||j==="profile-scope")&&y.profileArg&&typeof e[y.profileArg]=="string"&&(x.profileRef=e[y.profileArg]),u.push(x)}return u}function ph(e,r){const a=r==null?void 0:r.aiTextArg;if(!a)return;const i=e[a];return typeof i=="string"&&i.length>0?i:void 0}function gh(e,r){var i,l;const a=(l=(i=r==null?void 0:r.scopeSchema)==null?void 0:i.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function ip(e,r,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const i=a==="limits"?r==null?void 0:r.boundsSchema:r==null?void 0:r.scopeSchema,l=(i==null?void 0:i.fields)??{},u=[...new Set([...(i==null?void 0:i.keyOrder)??[],...Object.keys(e)])],d=[];for(const p of u){if(p==="profile"||!(p in e))continue;const m=e[p],v=l[p],y=mo(v==null?void 0:v.unit),j=Array.isArray(m)?m.join(", "):String(m);d.push({key:p,label:(v==null?void 0:v.displayName)??Ot(p),value:y?`${j} ${y}`:j,hint:v==null?void 0:v.description,unknown:r?!v:void 0})}return d}function ya(e){return e.kind??"read"}function f0(e,r){var u,d,p,m;if(!r)return"";if(!e)return r;const a=(d=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:d[r];if(a!=null&&a.displayName)return a.displayName;const i=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((m=i[r])!=null&&m.displayName)return i[r].displayName;const l=Object.values(i).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===r);return l!=null&&l.displayName?l.displayName:r}const h0={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",check:"Blocked — a check failed",read:"Read blocked"},m0={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",check:"Nothing ran and no approval was asked for. The check reads the system's own data — correct the request or that data.",read:"Nothing was read."};function p0(e){const r=e.includes("_")?e.replace(/_/g," "):e;return r.charAt(0).toLowerCase()+r.slice(1)}function yh(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function g0(e,r){const a=ya(e),i=yh(e.value),l=yh(e.limit);switch(a){case"bound":return i&&l?`${r||"Value"} ${i} is above the limit ${l}.`:e.detail;case"scope":return i?`"${i}" is not within your mandate's ${r?p0(r):"scope"}.`:e.detail;case"cumulative":return i&&l?`${i} of ${l} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function op(e,r){if(e.mandateId){const a=r==null?void 0:r[e.mandateId];if(a)return a}return e.mandateTitle}function y0(e,r){const a=op(e,r);if(a){const i=[{text:` · mandate "${a}"`}];return e.mandateId&&i.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),i}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function v0(e,r){const a=ya(e),i=ys(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${i} · ${e.tool}`},...y0(e,r),{text:` · ${l}${u}`}]}function lp(e,r,a){const i=ya(e),l=f0(r,e.field);return{title:h0[i],sentence:g0(e,l),sourceLine:v0(e,a),whatYouCanDo:m0[i]}}function x0(e,r){const a=new Date(r);return a.setHours(0,0,0,0),e.filter(i=>i.ts>=a.getTime()).length}function j0(e,r){return e.filter(a=>a.ts>r).length}const w0=1440*60*1e3;function cp(e,r){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),i=new Date(r);i.setHours(0,0,0,0);const l=i.getTime();return e>=l?`Today · ${a}`:e>=l-w0?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function up(e){var i;const r=Ot(Ln(e.tool).toolName),a=(i=e.target)==null?void 0:i.trim();return a?`${r} · ${a}`:r}const b0={bound:"Above your limit:",scope:"Outside your mandate:",cumulative:"Limit reached:",simulation:"Simulation mode:",not_authorized:"Not authorized:",check:"A check failed:",read:"Read blocked:"};function dp(e){return b0[ya(e)]}function S0(e){return e.who==="authority-server"?"Refused by the Authority Server before anything ran.":"Refused by this gateway before anything ran."}function fp(e,r){return!!e&&e.savedAt*1e3>r}function k0(e){const r=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=r?r[1].replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function N0(e){var r,a;return{verified:((a=(r=e.proof)==null?void 0:r.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(i=>i.status==="unverifiable").length}}const vh=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),xh=(e,r)=>new Date(e*1e3).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Gi(e,r){const a=e==null?void 0:e.window;return a?{text:`Covers ${vh(a.start,r)} → ${vh(a.end,r)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${xh(a.start,r)} to ${xh(a.end,r)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function hp(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((r-e*1e3)/864e5);if(new Date(r).toDateString()===i.toDateString())return`today ${l}`;const p=`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}function mp(e){const r=e.indexOf("__");return r<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,r),toolName:e.slice(r+2)}}function vs(e,r){var m,v,y;const{integrationId:a,toolName:i}=mp(e.action),l=r.find(j=>j.id===a),u=(v=(m=l==null?void 0:l.toolGating)==null?void 0:m.overrides)==null?void 0:v[i];if(u!=null&&u.actionLabel)return u.actionLabel;const d=Ht(e.profileId),p=(y=e.executionContext)==null?void 0:y.action_type;return typeof p=="string"&&p?`${d} · ${p}`:`${d} · ${i}`}function C0(e,r){var l;const a=(l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields;if(!a)return"";const i=[];for(const[u,d]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(d??"").trim();p&&i.push(p.split(",").map(m=>m.trim()).filter(Boolean).join(", "))}return i.join(" · ")}function E0(e,r){var l,u;if(!e)return"";const a=((l=r==null?void 0:r.scopeSchema)==null?void 0:l.fields)??{},i=[];for(const[d,p]of Object.entries(e)){if(d==="action_type")continue;const m=String(p??"").trim();if(!m)continue;const v=((u=a[d])==null?void 0:u.displayName)??d;i.push(`${v} ${m.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return i.join(" · ")}function jh(e){return e.appliesTo}function pp(e,r,a,i){var v,y,j;const l=(v=a==null?void 0:a.boundsSchema)==null?void 0:v.fields;if(!l||!r)return;const u=e.actionType??(typeof((y=e.executionContext)==null?void 0:y.action_type)=="string"?e.executionContext.action_type:void 0),d=Object.entries(l).filter(([x,S])=>{if(!(x in r))return!1;const N=S.boundType;if(!N||N.kind!=="cumulative_sum"&&N.kind!=="cumulative_count"||N.window!==i)return!1;const b=jh(S);return!b||!u||b.includes(u)}),m=(u?d.find(([,x])=>{var S;return(S=jh(x))==null?void 0:S.includes(u)}):void 0)??(d.length===1?d[0]:void 0);return m?{key:m[0],isAmount:((j=m[1].boundType)==null?void 0:j.kind)==="cumulative_sum"}:void 0}function au(e,r,a,i){var p;const l=(p=e.cumulativeState)==null?void 0:p[i];if(!l)return null;const u=pp(e,r,a,i),d=u?Number(r==null?void 0:r[u.key]):NaN;return u&&Number.isFinite(d)?{used:u.isAmount?l.amount:l.count,limit:d}:{count:l.count}}function T0(e,r,a){const i=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:d}of i){const p=au(e,r,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${d}`:`${p.count} ${p.count===1?"call":"calls"} ${d}`)}return l.join(" · ")}function A0(e,r,a){var u;const i=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!r||!i)return[];const l=[];for(const[d,p]of Object.entries(i)){const m=p.boundType;if(!m||m.kind!=="per_transaction")continue;const v=m.of;if(!(v in e)||!(d in r))continue;const y=Number(e[v]),j=Number(r[d]);if(!Number.isFinite(y)||!Number.isFinite(j))continue;const x=mo(p.unit),S=p.displayName??Ot(v),N=b=>x?`${b.toLocaleString()} ${x}`:b.toLocaleString();l.push({key:d,label:S,ok:y<=j,valueText:N(y),limitText:N(j)})}return l}function qi(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function I0(e){const r=Ht(e),a=e.split("@")[1];return a?`${r}@${a}`:r}const R0=["automatic","approved","all"];function $0(e){return e==="automatic"||e==="approved"?e:"all"}function Ki(e,r){return r==="all"?!0:r==="approved"?qi(e):!qi(e)}function Dr(e,r){return Yn(e,r)}function po(e,r){return jr(mp(e).integrationId,r)}function gp(e,r){const a=Math.max(0,Math.floor((r-e)/1e3));if(a<60)return"just now";const i=Math.floor(a/60);if(i<60)return`${i} min`;const l=Math.floor(i/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}const P0=24*3600;function yp(e,r,a){const i=e-Math.floor(r/1e3);return i<=0||i>P0?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function iu(e){return e.replace(/-/g,"").slice(0,8)}function _0(e,r){const a=new Date(e),i=new Date(r);return a.getFullYear()===i.getFullYear()&&a.getMonth()===i.getMonth()&&a.getDate()===i.getDate()}function Ur(e,r){return _0(e*1e3,r)}function Yi(e,r){return e.timestamp*1e3>r}function L0(e,r){var l;const a=new Map;for(const u of e){if(qi(u))continue;const d=vs(u,r.manifests),m=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(m);v||(v={key:m,area:Dr(u.profileId,r.catalog),system:po(u.action,r.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=r.titles)==null?void 0:l[u.authorizationId]:void 0,label:d,count:0,newCount:0,latestSec:0,tickets:[]},a.set(m,v)),v.count+=1,Yi(u,r.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const i=[...a.values()];for(const u of i)u.tickets.sort((d,p)=>p.timestamp-d.timestamp);return i.sort((u,d)=>+(d.newCount>0)-+(u.newCount>0)||d.latestSec-u.latestSec)}function M0(e,r){var l,u,d,p,m;const a=new Map;for(const v of e){if(!v.authorizationId||!Ur(v.timestamp,r.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=y.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&a.set(v.authorizationId,v)}const i=[];for(const[v,y]of a){const j=au(y,r.boundsOf(v)??y.limits,r.profileOf(y.profileId),"daily"),x={authorizationId:v,area:Dr(y.profileId,r.catalog),system:po(y.action,r.manifests),profileId:y.profileId,mandateTitle:(m=r.titles)==null?void 0:m[v]};j&&"limit"in j?i.push({...x,used:j.used,limit:j.limit,ratio:j.limit>0?j.used/j.limit:0}):i.push({...x,used:j?j.count:1,ratio:0})}return i.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function F0(e){return e.ratio>=.8}function ma(e,r,a){const i=new Date(e*1e3),l=i.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Ur(e,r)?`today ${l}`:`${i.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}function O0(e,r){return e==="approve"?r?"Signing":"Approving":e==="reject"?"Rejecting":"Sending"}function z0(e,r){return e==="approve"?r?"Signed":"Approved":e==="reject"?"Rejected":"Sent back to the AI"}function B0(e,r){return r!=null&&r.detail?r.detail:e==="approve"&&(r!=null&&r.ticketId)?`Ticket ${iu(r.ticketId)}`:"Recorded"}function vp(e){if(!e||typeof e!="object")return;const r=e,a=r.id??r.receiptId??r.ticketId;return typeof a=="string"&&a.length>0?a:void 0}function D0(e,r){const a=e.indexOf(r),i=e.filter(l=>l!==r);return i.length===0?null:a<0?i[0]:i[Math.min(a,i.length-1)]}function U0(e,r){if(!r)return null;const a=e.indexOf(r);return a<0?null:`${a+1} of ${e.length}`}function W0(e,r){const a=U0(e,r);return a?`Next · ${a}`:null}const H0=[{id:"me",label:"For me"},{id:"others",label:"Others"},{id:"all",label:"All"}];function V0(e){return e==="ArrowLeft"?"prev":e==="ArrowRight"?"next":e==="Escape"?"list":null}const Cc="suveren:approvals-changed";function wh(e=typeof window<"u"?window:void 0){e==null||e.dispatchEvent(new Event(Cc))}const G0=[{to:"/",icon:"□",label:"Dashboard",group:"top"},{to:"/approvals",icon:"▷",iconClass:"nav-ic-approval",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"☰",iconClass:"nav-ic-mandate",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",group:"core"},{to:"/reports",icon:"▥",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"⊘",iconClass:"nav-ic-blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function q0(){const{activeDomain:e}=kt(),[r,a]=h.useState({}),i=h.useCallback(async()=>{try{const[l,u,d,p,m,v,y,j,x,S]=await Promise.all([P.getCredential("ai-config").catch(()=>null),P.getMyAttestations().catch(()=>null),P.getMyProposals(e).catch(()=>null),P.getProposalsForApprover().catch(()=>null),P.getAgentContext().catch(()=>""),P.getArchivedMandates().catch(()=>[]),P.getDenials({limit:200}).catch(()=>null),P.getLastSeenBlockedAt().catch(()=>0),P.getReport().catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),N={};if(l&&!l.configured&&(N.assistant=1),u){const E=Qm(u,{archivedSet:new Set(v)}).expired.length;E>0&&(N.authorizations=E)}const b=(d==null?void 0:d.length)??0,k=(p==null?void 0:p.length)??0,C=b+k;if(C>0&&(N.proposals=C),(!m||!m.trim())&&(N.brief=1),y){const E=j0(y.records,j);E>0&&(N.blocked=E)}fp(x==null?void 0:x.report,S)&&(N.report=1),a(N)}catch{}},[e]);return He("attestation-changed",i),He("proposal-added",i),He("proposal-resolved",i),He("proposal-approved",i),He("proposal-rejected",i),He("team-membership-changed",i),He("denial-recorded",i),He("report-written",i),h.useEffect(()=>(window.addEventListener("suveren:archived-changed",i),()=>window.removeEventListener("suveren:archived-changed",i)),[i]),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",i),window.addEventListener("suveren:report-seen-changed",i),window.addEventListener(Cc,i),()=>{window.removeEventListener(Cc,i),window.removeEventListener("suveren:blocked-seen-changed",i),window.removeEventListener("suveren:report-seen-changed",i)}),[i]),Wt(i,3e5,e),r}const K0={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--neutral)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},Y0={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"var(--elevation-2)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function J0(){const{mode:e,activeTeam:r}=kt(),a=q0(),{attentionCount:i}=ru(),l={...a};i>0&&(l.integrations=i);const u=G0.filter(y=>!y.teamOnly||e==="team"),d=h.useRef(null),[p,m]=h.useState(null),v=en();return h.useEffect(()=>{if(d.current===null){d.current=e;return}d.current!==e&&(e==="team"&&r?m(`You are now acting in team context — ${r.name}`):e==="personal"&&m("You have left the team — back to personal context"),d.current=e)},[e,r]),h.useEffect(()=>{m(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const j=u.filter(x=>(x.group??"setup")===y);return j.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:j.map(x=>{const S=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(Xc,{to:x.to,end:x.to==="/",className:({isActive:N})=>`sidebar-item${N?" active":""}`,children:[n.jsx("span",{className:"icon",children:x.iconClass?n.jsx("span",{className:`nav-ic ${x.iconClass}`,"aria-hidden":"true"}):x.icon}),n.jsx("span",{className:"sidebar-label",children:x.label}),S?x.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${x.statusKey}`,children:"New"}):n.jsx("span",{style:K0,className:x.quietCount?"nav-count-quiet":void 0,title:x.quietCount?"Expired mandates":void 0,children:S}):null]})},x.to)})})]},y)}),p&&n.jsx("div",{style:Y0,role:"status","aria-live":"polite",children:p})]})}const cc="suveren:updatedTo";function Q0(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const X0="Updates for this gateway come from your company's IT — no action needed here.";function Z0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const ew="Download the new installer and run it. Your settings and mandates stay.";function tw(e){const r="https://github.com/suverenai/suveren-gateway/releases";return e?`${r}/tag/v${e}`:`${r}/latest`}function nw(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const r=document.activeElement;if(r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)){const a=r.value;if(a&&a.trim())return!0}return!1}function xp(){const{updateAvailable:e,installMethod:r,version:a,latestVersion:i,serverRestarted:l,startFastPolling:u,dismiss:d}=Zc(),[p,m]=h.useState(!1),[v,y]=h.useState(!1),[j,x]=h.useState(()=>{try{const R=sessionStorage.getItem(cc);if(R)return sessionStorage.removeItem(cc),R}catch{}return null}),S=Q0(r),N=h.useRef(null),b=R=>{try{sessionStorage.setItem(cc,R||i||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!j)return;const R=setTimeout(()=>x(null),6e3);return()=>clearTimeout(R)},[j]),h.useEffect(()=>{if(!p||!l)return;const R=()=>nw()?!1:(b(a),!0);if(R())return;const A=setInterval(R,1500);return()=>clearInterval(A)},[p,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const k=e&&!p&&!j||!!j&&!p;h.useEffect(()=>{if(!k){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const R=()=>{var M;const z=((M=N.current)==null?void 0:M.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${z}px`)};R();const A=new ResizeObserver(R);return N.current&&A.observe(N.current),()=>{A.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[k]);const C=()=>{m(!0),u()},E=async()=>{if(S)try{await navigator.clipboard.writeText(S),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[j&&!p&&n.jsx("div",{ref:N,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",j&&j!=="✓"?` — ${j} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>x(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!p&&!j&&n.jsxs("div",{ref:N,className:Z0(r),role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"update-banner-row",children:[n.jsx("span",{className:"update-banner-text",children:r==="msi"&&i?`Update available — version ${i}.`:"Update available."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r==="msi"&&n.jsx("a",{className:"btn btn-sm btn-secondary",href:tw(i),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),r!=="managed"&&r!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:C,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:d,"aria-label":"Dismiss",children:"×"})]})]}),r==="managed"&&n.jsx("p",{className:"update-banner-hint",children:X0}),r==="msi"&&n.jsx("p",{className:"update-banner-hint",children:ew})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:S}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:E,children:v?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>b(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>m(!1),children:"Cancel"})]})]})})]})}function jp(){const e=nu(),r=h.useRef(null);return h.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=r.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const i=new ResizeObserver(a);return r.current&&i.observe(r.current),()=>{i.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:r,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const rw={system:"◑",light:"☀",dark:"☾"},sw=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function aw({open:e,onClose:r}){const{user:a,activeGroup:i,activeDomain:l,logout:u}=kt(),{theme:d,toggle:p}=Km(),m=en();return h.useEffect(()=>{r()},[m.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:r}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:i?`${i.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:sw.map(v=>n.jsxs(Xc,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:r,children:[n.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:rw[d]}),"Theme: ",d]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),r()},children:"Logout"})]})]})]}):null}function wp(e){return e.status==="pending"}function iw(e,r){return e.filter(wp).length+r.length}const _r=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],ow=500;function bp(){const{user:e,domain:r}=kt(),[a,i]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!e){i(0);return}try{const[p,m]=await Promise.all([P.getMyProposals(r).catch(()=>[]),P.getProposalsForApprover().catch(()=>[])]);i(iw(p,m))}catch{i(0)}},[e,r]),d=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},ow)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),He(_r[0],d),He(_r[1],d),He(_r[2],d),He(_r[3],d),He(_r[4],d),He(_r[5],d),He(_r[6],d),a}const bh="Suveren",lw="/favicon.svg",cw="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ii={x1:74.54,y1:22.74,x2:94.46,y2:34.24},uw=14,dw="#f59e0b";function fw(e){const r=ou(e);return r>0?`(${r}) ${bh}`:bh}function ou(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function hw(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
53
|
-
<path class="m" d="${cw}"/>
|
|
54
|
-
<line class="m" x1="${Ii.x1}" y1="${Ii.y1}" x2="${Ii.x2}" y2="${Ii.y2}"/>
|
|
55
|
-
<circle cx="103" cy="103" r="25" fill="${dw}"/>
|
|
56
|
-
<style>.m{stroke:#111111;stroke-width:${uw};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
|
|
57
|
-
</svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function mw(){return document.querySelector('link[rel="icon"]')}function Sp(e){const r=ou(e);document.title=fw(r),kp(r);const a=mw();if(!a)return;const i=r>0?hw():lw;a.getAttribute("href")!==i&&a.setAttribute("href",i)}function pw(){Sp(0)}function kp(e,r=globalThis.navigator){var l;if(!r||typeof r.setAppBadge!="function")return;const a=ou(e),i=a>0?r.setAppBadge(a):r.clearAppBadge?r.clearAppBadge():r.setAppBadge(0);(l=i==null?void 0:i.catch)==null||l.call(i,()=>{})}function gw(){const e=bp();return h.useEffect(()=>{Sp(e)},[e]),h.useEffect(()=>pw,[]),null}const Np="suveren:dockBadgePrompt";function yw(){var i;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((i=window.matchMedia)==null?void 0:i.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const r=navigator.userAgent;if(!(/Safari\//.test(r)&&!/Chrome\/|Chromium\/|Edg\//.test(r))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(Np))return!1}catch{}return!0}function vw(){const[e,r]=h.useState(!1),a=bp();if(h.useEffect(()=>{r(yw())},[]),!e)return null;const i=()=>{try{localStorage.setItem(Np,"1")}catch{}r(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&kp(a)}catch{}i()};return n.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:l,children:"Allow"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,"aria-label":"Not now",children:"Not now"})]})}function xw(){const[e,r]=h.useState(!1);return n.jsxs(Yj,{children:[n.jsx(gw,{}),n.jsx(eu,{onMenuToggle:()=>r(!e)}),n.jsx(xp,{}),n.jsx(jp,{}),n.jsx(J0,{}),n.jsx(aw,{open:e,onClose:()=>r(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(vw,{}),n.jsx(Dx,{})]})})]})}function jw({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Cp(){return typeof navigator<"u"&&navigator.webdriver===!0}const Ep="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function ww(){const[e,r]=h.useState(""),{login:a,isLoading:i,error:l,clearError:u}=kt(),[d,p]=h.useState(null),m=Cp(),v=async()=>{if(!(!e.trim()||m)){u();try{await a(e)}catch(x){if(x instanceof Hm){p(x.summary);return}}}},y=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},j=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(eu,{}),n.jsx(xp,{}),n.jsx(jp,{}),n.jsxs("div",{className:"login-split",children:[n.jsx("div",{className:"login-split-left",children:n.jsxs("div",{style:{maxWidth:"28rem"},children:[n.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),n.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your tickets."})]})}),n.jsx("div",{className:"login-split-right",children:n.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),n.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),n.jsx(jw,{what:"sign-in"}),m&&n.jsx("div",{className:"error-message",children:Ep}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>r(x.target.value),onKeyDown:x=>x.key==="Enter"&&v(),disabled:i,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:v,disabled:i||m,style:{marginBottom:"2rem"},children:i?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start giving mandates"].map((x,S)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:S<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[S+1,"."]}),x]},S))})]})]})})]}),d&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:j,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[d.credentialCount," stored service credential",d.credentialCount===1?"":"s",d.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",d.credentialIds.slice(0,5).join(", "),d.credentialIds.length>5?`, +${d.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[d.serviceCount," configured integration",d.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:i,children:i?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function bw(e,r){return!r&&e!=null}function Sw(e,r){return e==="join-waiting"&&r==="team"}function kw(e,r,a,i){return a!=null||e!=="join-waiting"||r==="team"?null:i}function Nw(e){return`${e} personal mandate${e===1?"":"s"}`}function Cw({mandates:e,pendingProposals:r}){return e.length===0&&r===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",r>0&&` ${r} personal proposal${r===1?"":"s"} waiting for approval end${r===1?"s":""} too.`]})]})}function Ew(){const{mode:e,pendingRequest:r,refreshGroups:a}=kt(),i=gn(),[l,u]=h.useState("choose"),[d,p]=h.useState(""),[m,v]=h.useState(""),[y,j]=h.useState(null),[x,S]=h.useState(null),[N,b]=h.useState(""),[k,C]=h.useState(""),[E,R]=h.useState(!1),A=h.useRef(!1);h.useEffect(()=>{bw(r,A.current)&&(A.current=!0,u("join-waiting"))},[r]),h.useEffect(()=>{Sw(l,e)&&i("/")},[l,e,i]);const z=h.useRef(null);h.useEffect(()=>{if(r){z.current=r.groupName;return}const U=kw(l,e,r,z.current);U&&(b(U),u("join-declined"),z.current=null)},[r,l,e]),h.useEffect(()=>{if(l!=="join-waiting")return;const U=setInterval(()=>{a()},5e3);return()=>clearInterval(U)},[l,a]);const M=h.useCallback(()=>{u("choose"),C(""),j(null),S(null),p(""),v("")},[]),H=async()=>{if(d.trim()){R(!0),C("");try{const U=await P.getJoinPreview(d.trim());j(U),u("join-preview")}catch(U){C(U instanceof Error?U.message:"Invalid or expired invite code")}finally{R(!1)}}},te=async()=>{R(!0),C("");try{await P.requestToJoinGroup(d.trim()),await a(),u("join-waiting")}catch(U){C(U instanceof Error?U.message:"Failed to join group")}finally{R(!1)}},X=async()=>{R(!0),C("");try{await P.withdrawJoinRequest(),await a(),M()}catch(U){C(U instanceof Error?U.message:"Failed to withdraw request")}finally{R(!1)}},L=async()=>{u("create"),C(""),R(!0);try{const U=await P.getCreatePreview();S(U)}catch(U){C(U instanceof Error?U.message:"Failed to load preview")}finally{R(!1)}},q=async()=>{if(m.trim()){R(!0),C("");try{await P.createGroup(m.trim()),await a(),i("/")}catch(U){C(U instanceof Error?U.message:"Failed to create group")}finally{R(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(eu,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[k&&n.jsx("div",{className:"error-message",children:k}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:d,onChange:U=>p(U.target.value),onKeyDown:U=>U.key==="Enter"&&H(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:E}),n.jsx("button",{className:"btn btn-primary",onClick:H,disabled:E||!d.trim(),children:E?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:L,disabled:E,children:"Create a team"})]})]}),l==="join-preview"&&y&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",y.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(Cw,{mandates:y.personalMandates,pendingProposals:y.pendingPersonalProposals}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",y.admin.name,") confirms your request. Nothing changes until then."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:te,disabled:E,children:E?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(r==null?void 0:r.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:X,disabled:E,children:E?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",N," ended"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),n.jsx("button",{className:"btn btn-primary",onClick:M,disabled:E,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:m,onChange:U=>v(U.target.value),onKeyDown:U=>U.key==="Enter"&&q(),disabled:E,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",Nw(x.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:q,disabled:E||!m.trim(),children:E?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]})]})})]})}const Sh={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
|
|
58
|
-
|
|
59
|
-
${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
|
|
60
|
-
|
|
61
|
-
[mcp_servers.suveren]
|
|
62
|
-
url = "${e}/mcp"
|
|
63
|
-
|
|
64
|
-
Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
65
|
-
SSE transport: GET ${e}/sse
|
|
66
|
-
Health check: GET ${e}/health`}},kh=["claude-code","claude-desktop","chatgpt-codex","other"];function Ec({mcpEndpoint:e}){const[r,a]=h.useState(kh[0]),[i,l]=h.useState(!1),u=h.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),d=Sh[r].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:kh.map(p=>n.jsx("button",{className:`mcp-tab${r===p?" active":""}`,onClick:()=>a(p),children:Sh[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:d}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(d),children:i?"Copied":"Copy"})]})}const Tc="suveren-setup-ai-skipped",Ac="suveren-setup-agent-done",Ic="suveren-setup-dismissed",Tw={"hap-setup-ai-skipped":Tc,"hap-setup-agent-done":Ac,"hap-setup-dismissed":Ic};function Aw(){for(const[e,r]of Object.entries(Tw)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(r)===null&&localStorage.setItem(r,a),a!==null&&localStorage.removeItem(e)}}Aw();function Iw({aiConfigured:e,hasRunningIntegration:r,hasActiveAuth:a,hasAgentConnected:i,mcpEndpoint:l}){const[u,d]=h.useState(()=>localStorage.getItem(Tc)==="true"),[p,m]=h.useState(()=>localStorage.getItem(Ac)==="true"),[v,y]=h.useState(()=>localStorage.getItem(Ic)==="true"),[j,x]=h.useState(null),S=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:r?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:i||p?"done":"pending"}],N=S.filter(A=>A.status==="done"||A.status==="skipped").length,b=N===S.length,k=h.useCallback(()=>{localStorage.setItem(Tc,"true"),d(!0)},[]),C=h.useCallback(()=>{localStorage.setItem(Ac,"true"),m(!0),x(null)},[]),E=h.useCallback(()=>{localStorage.setItem(Ic,"true"),y(!0)},[]);if(v||b)return null;const R=S.findIndex(A=>A.status==="pending");return n.jsxs("div",{className:"setup-guide",style:{borderRadius:"var(--radius-xl)",boxShadow:"var(--elevation-2)",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get started"}),n.jsx("button",{onClick:E,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.2rem"},children:S.map((A,z)=>{const M=z===R,H=A.status==="done"?"✓":A.status==="skipped"?"–":"○",te=A.status==="pending"?"var(--text-primary)":"var(--text-muted)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.45rem 0.75rem",borderRadius:"var(--radius-md)",background:M?"var(--bg-sunken)":void 0},children:[n.jsx("span",{style:{color:te,fontSize:"0.85rem",width:"1rem",textAlign:"center",flexShrink:0},children:H}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A.to&&A.status==="pending"?n.jsx(ut,{to:A.to,style:{fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)",textDecoration:"none"},children:A.label}):A.status==="pending"&&z===3?n.jsx("button",{onClick:()=>x(j===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:M?600:500,color:"var(--text-primary)"},children:A.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:A.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:A.label}),A.optional&&A.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),A.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),A.detail&&A.status==="pending"&&M&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:A.detail})]}),A.optional&&A.status==="pending"&&n.jsx("button",{onClick:k,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),A.to&&A.status==="pending"&&n.jsx(ut,{to:A.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),z===3&&j===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(Ec,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:C,children:"Done"})]})]},z)})}),n.jsxs("div",{style:{fontSize:"var(--text-caption)",color:"var(--text-muted)",marginTop:"var(--space-3)"},children:[N," of ",S.length," done"]})]})}function Tp(e,r=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],i=a.every(Boolean),l=e.otherMandateCount===0&&!i,u=a.findIndex(v=>!v),d=r!==null&&a[r]===!1?r:u,p=e.managed?"managed":"self",m=v=>a[v]?{status:"done"}:v!==d?{status:"todo"}:v===1?{status:"open",variant:p,simulationOn:e.simulationOn}:v===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:m(0),step2:m(1),step3:m(2)}}const Rw="/mandates?new=1&profile=delegation";function Nh({text:e}){const[r,a]=h.useState(!1),i=h.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:i,children:r?"Copied":"Copy"})}function uc({todo:e,onOpen:r,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:r,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function $w({contact:e,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u,mcpEndpoint:d}){const p={hasContact:e!==null,hasDelegationMandate:r,otherMandateCount:a,delegationProposalCount:i,managed:l,simulationOn:u},[m,v]=h.useState(null),y=Tp(p,m);if(!y.visible)return null;const j=`Please connect to the Suveren gateway: MCP server at ${d}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",s0(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(uc,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Ec,{mcpEndpoint:d})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:j}),n.jsx(Nh,{text:j})]})}),n.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(Ec,{mcpEndpoint:d})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(ut,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(uc,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(ut,{to:Rw,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(uc,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(Nh,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(ut,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function Pw(){const[e,r]=h.useState(null);return h.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{!a&&typeof i.mcpPort=="number"&&r(`http://localhost:${i.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function _w(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const r=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:r}}function Ap(){const[e,r]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(i=>i.json()).then(i=>{a||r(_w(i))}).catch(()=>{}),()=>{a=!0}},[]),e}function Lw(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function Mw(){const[e,r]=h.useState(!1);return h.useEffect(()=>{let a=!1;const i=()=>{fetch("/health").then(d=>d.json()).then(d=>{a||r(Lw(d))}).catch(()=>{})};i();const l=setInterval(i,3e4),u=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const Ch=new Map;function go(e){let r=Ch.get(e);return r||(r=(async()=>{try{let a=e;if(!e.includes("@")){const i=await P.listProfiles(),l=d=>d.replace(/@.*$/,"").split("/").pop(),u=i.filter(d=>l(d.id)===e).sort((d,p)=>(p.id.split("@")[1]??"").localeCompare(d.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await P.getProfile(a)}catch{return null}})(),Ch.set(e,r)),r}function Ns(e){const[r,a]=h.useState(null);return h.useEffect(()=>{let i=!0;return e&&go(e).then(l=>{i&&a(l)}),()=>{i=!1}},[e]),r}function Ri(e){return typeof e=="string"&&e.length>0}function Fw(e){if(e===null||typeof e!="object")return!1;const r=e;return!(!Ri(r.filename)||!Ri(r.contentType)||!Ri(r.contentBase64)||!Ri(r.sha256)||r.pages!==void 0&&typeof r.pages!="number")}function Ip(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function Ow(e){return`data:${e.contentType};base64,${e.contentBase64}`}function zw(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function Bw(e){const r=atob(e.contentBase64),a=new Uint8Array(new ArrayBuffer(r.length));for(let i=0;i<r.length;i++)a[i]=r.charCodeAt(i);return a}function Rp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}function Ji(e){return e==null||e===""?"—":Array.isArray(e)?e.length===0?"—":e.map(Ji).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}function Dw(e,r){return new Date(e).toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Uw(e,r,a){var v;if(!e.displayOnly||!e.attach)return null;const i=e.result;if(!i||i.status!=="ok")return null;const l=(v=Qn(i.body))==null?void 0:v.obj;if(!l)return null;const u=`${e.attach}.`,d=new Set((r==null?void 0:r.hidden)??[]),p=[];for(const[y,j]of Object.entries((r==null?void 0:r.labels)??{})){if(!y.startsWith(u)||d.has(y))continue;const x=Rp(l,y.slice(u.length));x==null||x===""||p.push({key:y,label:j,value:Ji(x)})}if(p.length===0)return null;const m=e.label??e.tool;return{key:e.tool,heading:`From ${m}${a?` — checked ${Dw(a)}`:""}`,rows:p}}function Ww(e,r,a){var l;const i=[];for(const[u,d]of Object.entries((r==null?void 0:r.compare)??{})){if(!(u in e))continue;const[p,...m]=d.split("."),v=m.length>0?Rp(a(p),m.join(".")):void 0;i.push({key:u,label:((l=r==null?void 0:r.labels)==null?void 0:l[u])??u,now:Ji(v),next:Ji(e[u])})}return i}function Lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Rt(e,r=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?r||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function Hw(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function $p(e,r){return e.length===0?"—":e.every(a=>!Lt(a)&&!Array.isArray(a))?e.map(a=>Rt(a,r)).join(", "):e.length===1?"1 entry":`${e.length} entries`}function _n(e,r,a){const i=r?Object.keys(r).filter(l=>l in e):Object.keys(e);return i.length===0?"—":i.map(l=>{var m,v;const u=e[l],d=((m=r==null?void 0:r[l])==null?void 0:m.title)??Ot(l),p=Lt(u)?_n(u,(v=r==null?void 0:r[l])==null?void 0:v.properties,a):Array.isArray(u)?$p(u,a):Rt(u,a);return`${d}: ${p}`}).join(" · ")}function Pp(e,r,a){const i=m=>m==null||m==="",l=(r?Object.keys(r).filter(m=>e.some(v=>m in v)):[...new Set(e.flatMap(m=>Object.keys(m)))]).filter(m=>e.some(v=>!i(v[m]))),u=l.map(m=>{var v,y,j;return{key:m,label:(a&&((y=(v=a.hints)==null?void 0:v.labels)==null?void 0:y[`${a.pathPrefix}.${m}`]))??((j=r==null?void 0:r[m])==null?void 0:j.title)??Ot(m)}}),d=!!a,p=e.map(m=>({cells:l.map(v=>{var S,N,b;const y=m[v];if(i(y))return{value:"",sealed:d};if(a&&!Lt(y)&&xs((S=a.hints)==null?void 0:S.money,`${a.pathPrefix}.${v}`))return{...Fp(y,a.currency),sealed:d};const j=Lt(y)?_n(y,(N=r==null?void 0:r[v])==null?void 0:N.properties,!1):Rt(y),x=Lt(y)?_n(y,(b=r==null?void 0:r[v])==null?void 0:b.properties,!0):Rt(y,!0);return x===j?{value:j,sealed:d}:{value:j,valueTitle:x,sealed:d}})}));return{columns:u,rows:p}}function Vw(e){return Lt(e)?_n(e,void 0,!1):Array.isArray(e)?$p(e,!1):Rt(e)}function _p(e,r){return Array.isArray(e)&&e.length>0&&e.every(Lt)?{table:Pp(e,void 0,{hints:r==null?void 0:r.hints,pathPrefix:`${(r==null?void 0:r.key)??""}[]`,currency:r==null?void 0:r.currency})}:Lt(e)?{text:_n(e,void 0,!1)}:null}function Gw(e){return e.split(`
|
|
67
|
-
`).map(r=>r.startsWith("+")&&!r.startsWith("+++")?{text:r,kind:"add"}:r.startsWith("-")&&!r.startsWith("---")?{text:r,kind:"remove"}:{text:r,kind:"context"})}function qw(e,r){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(y=>!Lt(y)&&!Array.isArray(y))){if(e.every(x=>typeof x=="string"))return{lines:e};const y=e.map(x=>Rt(x)).join(", "),j=e.map(x=>Rt(x,!0)).join(", ");return j===y?{value:y}:{value:y,valueTitle:j}}const u=(l=r==null?void 0:r.items)==null?void 0:l.properties,d=e.map(y=>Lt(y)?_n(y,u,!1):Rt(y)),p=e.map(y=>Lt(y)?_n(y,u,!0):Rt(y,!0)),m=d.map((y,j)=>y===p[j]?void 0:p[j]),v=e.every(Lt)?Pp(e,u):void 0;return{lines:d,...m.some(y=>y!==void 0)?{lineTitles:m}:{},...v?{table:v}:{}}}if(Lt(e)){const u=r==null?void 0:r.properties,d=u?Object.keys(u).filter(v=>v in e):Object.keys(e);if(d.length>0&&d.every(v=>!Lt(e[v])&&!Array.isArray(e[v])))return{sublist:d.map(y=>{var b;const j=e[y],x=((b=u==null?void 0:u[y])==null?void 0:b.title)??Ot(y),S=Rt(j),N=Rt(j,!0);return N===S?{key:y,label:x,value:S}:{key:y,label:x,value:S,valueTitle:N}})};const p=_n(e,u,!1),m=_n(e,u,!0);return m===p?{value:p}:{value:p,valueTitle:m}}if(typeof e=="string"&&(r==null?void 0:r.contentMediaType)==="text/x-diff")return{diffLines:Gw(e)};const a=Rt(e),i=Rt(e,!0);return i===a?{value:a}:{value:a,valueTitle:i}}function Kw(e){let r;try{r=JSON.parse(e)}catch{return null}return Lt(r)?r:null}function Qn(e){const r=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(r)return{obj:r,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?Kw(e.text):null;return a?{obj:a}:null}function Qi(e){const r=Qn(e);if(!r)return[];const{obj:a,schema:i}=r,l=(i==null?void 0:i.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],d=[];for(const p of u){if(!(p in a))continue;const m=l[p],v=(m==null?void 0:m.title)??Ot(p),y={key:p,label:v,...qw(a[p],m)};m!=null&&m.description&&(y.description=m.description),d.push(y)}return d}function Lp(e,r){const a=Qn(e);if(a){const l=Qi(e),u=r==null?void 0:r.fields;let d;if(u&&u.length>0){const v=new Map(l.map(y=>[y.key,y]));d=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else d=l.filter(v=>Hw(a.obj[v.key]));const p=new Set(d.map(v=>v.key)),m=l.filter(v=>!p.has(v.key));return{kind:"structured",fields:d,moreFields:m,totalFields:l.length}}const i=e==null?void 0:e.text;return i&&i.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:i}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Eh(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(r=>[r.key,r.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function $i(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function Yw(e,r,a){const i=Qn(e),l=Qn(r);if(!i&&!l){const x=(e==null?void 0:e.text)??"",S=(r==null?void 0:r.text)??"";return x===S?{approved:$i([]),current:$i([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:S},unchanged:!1}}const u=new Map(Qi(e).map(x=>[x.key,x])),d=new Map(Qi(r).map(x=>[x.key,x])),m=[...new Set([...u.keys(),...d.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:Eh(u.get(x))!==Eh(d.get(x))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>m.includes(x)),...m.filter(x=>!a.fields.includes(x))]:m,y=v.map(x=>u.get(x)).filter(x=>x!==void 0),j=v.map(x=>d.get(x)).filter(x=>x!==void 0);return{approved:$i(y),current:$i(j),unchanged:m.length===0}}function Jw(e){const r=e==null?void 0:e.structured;if(Array.isArray(r)&&r.every(Lt))return r;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(Lt))return a}return null}function yo(e){const r=Rt(e),a=Rt(e,!0);return a===r?{value:r}:{value:r,valueTitle:a}}function Mp(e){return!e||e.status!=="ok"?[]:Qi(e.body)}function Rc(e){if(!e)return"Not read.";switch(e.status){case"not_found":return e.message?`The system answered: ${e.message}`:"Not found in the system.";case"none":return"Nothing to read.";case"refused":return e.message?sb(e.message):"The system refused to answer.";default:return"Not available right now."}}function lu(e,r,a){var y,j,x;const i=Mp(e);if(i.length===0)return{rawId:Rt(r),context:[],unresolved:Rc(e)};const l=e&&e.status==="ok"?(y=Qn(e.body))==null?void 0:y.obj:void 0,u=a==null?void 0:a.pathPrefix,d=u?(x=(j=a==null?void 0:a.displayHints)==null?void 0:j.names)==null?void 0:x[u]:void 0,p=d?$c(l,d):void 0;if(typeof p=="string"&&p.length>0){const S=i.filter(N=>N.key!=="id"&&!Zi(a==null?void 0:a.displayHints,`${u}.${N.key}`)).map(N=>({...N,label:Or(a==null?void 0:a.displayHints,`${u}.${N.key}`,N.label)}));return{name:p,rawId:Rt(r),context:Th(S,l,u,a)}}const m=i.find(S=>["name","title","label"].includes(S.key))??i.find(S=>typeof(l==null?void 0:l[S.key])=="string"&&!S.lines&&!S.sublist&&!S.diffLines),v=i.filter(S=>S.key!==(m==null?void 0:m.key)&&S.key!=="id").filter(S=>!u||!Zi(a==null?void 0:a.displayHints,`${u}.${S.key}`)).map(S=>{var E,R;if(!u)return S;const N=`${u}.${S.key}`,b=Or(a==null?void 0:a.displayHints,N,S.label);if(!xs((E=a==null?void 0:a.displayHints)==null?void 0:E.money,N)&&!xs((R=a==null?void 0:a.displayHints)==null?void 0:R.percent,N))return b===S.label?S:{...S,label:b};const{value:k,valueTitle:C}=Xi(l==null?void 0:l[S.key],a==null?void 0:a.displayHints,N,a==null?void 0:a.currency);return{...S,label:b,value:k,valueTitle:C}});return{name:m==null?void 0:m.value,rawId:Rt(r),context:Th(v,l,u,a)}}const Qw=new Set(["id","name","title","label"]);function xs(e,r){return!!(e!=null&&e.includes(r))}function Or(e,r,a){var i;return((i=e==null?void 0:e.labels)==null?void 0:i[r])??a}function Fp(e,r){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${r?` ${r}`:""}`}:yo(e)}function Xw(e){return typeof e!="number"&&typeof e!="string"?yo(e):{value:`${e} %`}}function Xi(e,r,a,i){return xs(r==null?void 0:r.money,a)?Fp(e,i):xs(r==null?void 0:r.percent,a)?Xw(e):yo(e)}function Zi(e,r){return xs(e==null?void 0:e.hidden,r)}function Zw(e,r,a){var d;const i=e==null?void 0:e.currencyField;if(!i)return;const l=i.indexOf(".");if(l<0){const p=r[i];return typeof p=="string"?p:void 0}const u=(d=a(i.slice(0,l)))==null?void 0:d[i.slice(l+1)];return typeof u=="string"?u:void 0}function eb(e,r,a,i){const l=e.forEach??"",u=e.attach,d=e.elements??[],p=Math.min(r.length,d.length),m=r.slice(0,p),v=d.slice(0,p),y=[...new Set(m.flatMap(k=>Object.keys(k)))].filter(k=>k!==e.sourceArg).filter(k=>!Zi(a,`${l}[].${k}`)),j=new Map;if(u)for(const k of v)for(const C of Mp(k))j.has(C.key)||j.set(C.key,C.label);const x=u?[...j.keys()].filter(k=>!Qw.has(k)):[],S=!!u&&v.some(k=>k&&k.status!=="none"),N=[];S&&N.push({key:`__attach:${u}`,label:Or(a,`${l}[].${u}`,Ot(e.sourceArg??u))});for(const k of y)N.push({key:`bound:${k}`,label:Or(a,`${l}[].${k}`,Ot(k))});for(const k of x)N.push({key:`attached:${k}`,label:Or(a,`${l}[].${u}.${k}`,j.get(k)??Ot(k))});const b=m.map((k,C)=>{var z;const E=v[C],R=[];if(S){const M=lu(E,e.sourceArg?k[e.sourceArg]:void 0),H=(E==null?void 0:E.status)==="none"?"":M.name?`${M.name} (${M.rawId})`:M.unresolved?`${M.rawId} — ${M.unresolved}`:M.rawId;R.push({value:H,sealed:!1})}for(const M of y){const{value:H,valueTitle:te}=k[M]===void 0||k[M]===null?{value:"",valueTitle:void 0}:Xi(k[M],a,`${l}[].${M}`,i);R.push({value:H,valueTitle:te,sealed:!0})}const A=E&&E.status==="ok"?(z=Qn(E.body))==null?void 0:z.obj:void 0;for(const M of x){const H=A==null?void 0:A[M],{value:te,valueTitle:X}=H!=null?Xi(H,a,`${l}[].${u}.${M}`,i):{value:"",valueTitle:void 0};R.push({value:te,valueTitle:X,sealed:!1})}return{cells:R}});return{columns:N,rows:b,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function tb(e){return`${Ot(e)} — from the system`}function nb(e){var l;const r=tb(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=Qn(a.body))==null?void 0:l.obj;return u&&Fw(u)?{heading:r,document:u}:{heading:r,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:r,note:Rc(a)}}if(!a||a.status!=="ok")return{heading:r,note:Rc(a)};const i=Jw(a.body);if(i){if(i.length===0)return{heading:r,note:"Nothing found."};const u=[...new Set(i.flatMap(m=>Object.keys(m)))],d=u.map(m=>({key:m,label:Ot(m)})),p=i.map(m=>({cells:u.map(v=>({...yo(m[v]),sealed:!1}))}));return{heading:r,table:{columns:d,rows:p}}}return{heading:r,body:Lp(a.body,{fields:e.fields})}}function rb(e,r,a,i={}){const l=new Map(r.filter(b=>b.attach&&!b.forEach&&!b.displayOnly).map(b=>[b.attach,b])),u=new Map(r.filter(b=>b.forEach).map(b=>[b.forEach,b])),d=r.filter(b=>!b.attach&&!b.forEach&&!b.as&&!b.displayOnly),p=r.map(b=>Uw(b,a,i.readAt)).filter(b=>b!==null),m=b=>{var C,E;const k=(C=l.get(b))==null?void 0:C.result;return k&&k.status==="ok"?(E=Qn(k.body))==null?void 0:E.obj:void 0},v=Zw(a,e,m),y=(a==null?void 0:a.order)??[],j=[...new Set([...y,...Object.keys(e)])],x=[],S=new Set(Object.keys((a==null?void 0:a.compare)??{}));for(const b of j){if(!(b in e)||sp.has(b)||Zi(a,b))continue;if(S.has(b)){x.some(H=>H.kind==="compare")||x.push({kind:"compare",key:"compare",label:"",lines:Ww(e,a,m)});continue}const k=Or(a,b,Ot(b)),C=u.get(b);if(C){const H=Array.isArray(e[b])?e[b]:[];x.push({kind:"table",key:b,label:k,table:eb(C,H,a,v)});continue}const E=l.get(b);if(E){const H=lu(E.result,e[b],{pathPrefix:b,displayHints:a,currency:v,fields:E.fields});x.push({kind:"identity",key:b,label:k,identity:H});continue}const R=e[b],A=_p(R,{key:b,hints:a,currency:v});if(A&&"table"in A){x.push({kind:"table",key:b,label:k,table:A.table});continue}if(A&&Lt(R)){const H=_n(R,void 0,!0);x.push({kind:"scalar",key:b,label:k,value:A.text,...H!==A.text?{valueTitle:H}:{}});continue}if(Array.isArray(R)){x.push({kind:"scalar",key:b,label:k,value:R.length===0?"—":R.map(H=>Rt(H)).join(", ")});continue}const{value:z,valueTitle:M}=Xi(R,a,b,v);x.push({kind:"scalar",key:b,label:k,value:z,valueTitle:M})}const N=d.map(nb).filter(b=>b!==null);return{rows:x,sections:N,systemBoxes:p}}function sb(e){return e.length>300?`${e.slice(0,299)}…`:e}function $c(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object"||Array.isArray(a))return;a=a[i]}return a}const ab=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;function ib(e,r){const a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString(r,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Th(e,r,a,i){var u;let l=e;return(u=i==null?void 0:i.fields)!=null&&u.length&&(l=i.fields.flatMap(d=>{const p=e.find(y=>y.key===d);if(p)return[p];if(!d.includes("."))return[];const m=$c(r,d);if(m==null||typeof m=="object")return[];const v=Or(i.displayHints,a?`${a}.${d}`:d,Ot(d.split(".").pop()));return[{key:d,label:v,value:String(m)}]})),l.filter(d=>{var p,m,v;return((p=d.lines)==null?void 0:p.length)||((m=d.sublist)==null?void 0:m.length)||d.table||((v=d.diffLines)==null?void 0:v.length)||d.value!==void 0&&d.value!==""&&d.value!=="—"}).map(d=>{const p=d.key.includes(".")?$c(r,d.key):r==null?void 0:r[d.key];return typeof p=="string"&&ab.test(p)?{...d,value:ib(p),valueTitle:p}:d})}const Op=new Map,Pc=new Set;function ob(e,r){r!==null&&(Op.set(e,r),Pc.forEach(a=>a()))}function lb(e){return Pc.add(e),()=>Pc.delete(e)}function zp(e){return h.useSyncExternalStore(lb,()=>Op.get(e))}function Bp(e,r){return a=>{if(!e||e.status!=="ok"||!("reads"in e)||!r)return;const i=e.reads.find(l=>l.attach===a&&!l.forEach&&!l.displayOnly);if(i)return lu(i.result,r[a],{pathPrefix:a,displayHints:e.display}).name}}function cb(e){if(!e||e.status!=="ok")return;const r=e.checks;if(!r||r.length===0)return;const a=r.find(u=>u.status==="fail");if(a)return{text:`✕ ${a.label}: failed`,status:"fail"};const i=r.find(u=>u.status==="not_checked");if(i)return{text:`${i.label}: not checked`,status:"not_checked"};const l=r.find(u=>u.status==="notice");if(l)return{text:l.label,status:"notice"}}async function Ah(e){const r=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(a)).map(i=>i.toString(16).padStart(2,"0")).join("")}function ub(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
68
|
-
`).split(`
|
|
69
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
70
|
-
`).replace(/\n+$/,"")}function _c(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":_c(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+_c(l))}return"{"+a.join(",")+"}"}async function Dp(e,r){if(e==="jcs"){if(typeof r=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Ah(_c(r))}`}if(typeof r!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Ah(ub(r))}`}async function Up(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:r}=await P.decryptProposalContent(e.content),a=JSON.parse(r);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function db(e){if(!e.content)return[];const r=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(r).filter(i=>!a.has(i))}function fb(e){return!e.loading&&e.readable}function Wp(e,r){const a=new Set;if(e.content)for(const i of Object.keys(e.content.keys))a.add(i);else{e.createdBy&&a.add(e.createdBy);for(const i of e.pendingApprovers??[])a.add(i)}return r&&a.add(r),Array.from(a)}async function cu(e){const r=await Up(e);if(r)return Dp("jcs",r)}function hb(e){var i;const[r,a]=h.useState((e==null?void 0:e.note)??null);return h.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),P.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(i=e==null?void 0:e.noteEncrypted)==null?void 0:i.ciphertext]),r}const mb={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function va(e){var i;const[r,a]=h.useState(mb);return h.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Up(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(i=e.content)==null?void 0:i.ciphertext,e.toolArgs]),r}const Ih=140,Rh=60,pb=/\{([^{}]+)\}/g;function Hp(e,r){var u,d;const{integrationId:a,toolName:i}=Ln(e),l=r==null?void 0:r.find(p=>p.id===a);return((d=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:d[i])??void 0}function Vp(e,r){let a=e;for(const i of r.split(".")){if(a===null||typeof a!="object")return;a=a[i]}return a}function $h(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function gb(e,r,a,i){if(r==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(i,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(i,{maximumFractionDigits:2}).format(u)}if(r==="percent")return`${e}%`;if(r==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(i,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(d=>typeof d=="object"&&d!==null?JSON.stringify(d):String(d));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return r==="short"&&l.length>Rh?`${l.slice(0,Rh-1).trimEnd()}…`:l}function Ph(e,r,a,i,l){let u=!1;const d=e.replace(pb,(p,m)=>{const[v,y]=m.split("|").map(x=>x.trim()),j=v.split(",").map(x=>Vp(r,x.trim())).find($h);if(!$h(j))return u=!0,"";if(y==="ref"){const x=l==null?void 0:l(v.split(",")[0].trim()),S=String(j),N=S.length>12?`${S.slice(0,8)}…`:S;return x?`${x} (${N})`:S}return gb(j,y,a,i)});return u?null:d}function Gp(e,r,a={}){const i=Vp(r,a.currencyField??"currency"),l=typeof i=="string"?i:void 0,u=e.replace(/\[([^[\]]*)\]/g,(m,v)=>Ph(v,r,l,a.locale,a.refName)??""),d=Ph(u,r,l,a.locale,a.refName);if(d===null)return null;const p=d.replace(/\s+/g," ").trim();return p.length>Ih?`${p.slice(0,Ih-1).trimEnd()}…`:p}function qp(e,r,a,i,l){var p;const u=Ot(Ln(e).toolName),d=Hp(e,a);return!(d!=null&&d.summary)||!r?u:Gp(d.summary,r,{currencyField:(p=d.display)==null?void 0:p.currencyField,locale:i,refName:l})??u}function yb(e,r,a,i){var u;const l=Hp(e,a);return!(l!=null&&l.summary)||!r?null:Gp(l.summary,r,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:i})}const Oi="Commitment",eo={title:"Review Each Action",text:"You review and approve each action before it executes."},to={title:"Automatic",text:"Agent acts freely within your limits."},Kp="setup__create_mandate",vb=["proposal","profile_version","workspace","mode","intent","checks","title"];function xb(e){if(typeof e!="string"||!e.trim())return null;switch(e.trim()){case"review":return{label:Oi,...eo};case"automatic":return{label:Oi,...to};default:return{label:Oi,title:e.trim(),text:""}}}function jb(e){const r=a=>typeof a=="string"&&a.trim()?a.trim():void 0;return{intent:r(e==null?void 0:e.intent),mode:r(e==null?void 0:e.mode),proposal:r(e==null?void 0:e.proposal),profileVersion:r(e==null?void 0:e.profile_version),workspace:r(e==null?void 0:e.workspace),title:r(e==null?void 0:e.title),checks:Array.isArray(e==null?void 0:e.checks)?e.checks.filter(a=>typeof a=="string"&&a.trim()!==""):[]}}function wb(e){return[e.proposal,e.profileVersion].filter(Boolean).join(" · ")||"new mandate"}function Yp(e,r){const a=r==null?void 0:r.title;return{area:e,name:typeof a=="string"&&a.trim()?a.trim():null}}function no(e,r){const a=e==null?void 0:e.profile;return typeof a=="string"&&a?a:r}function bb({proposal:e,manifests:r}){const a=va(e),i=zp(e.id),l=Mn();if(e.tool===Kp&&a.toolArgs){const u=Yp(Dr(no(a.toolArgs,e.profileId),l),a.toolArgs);return n.jsxs(n.Fragment,{children:[u.area," · ",u.name??"new mandate"]})}return n.jsx(n.Fragment,{children:qp(e.tool,a.toolArgs,r,void 0,Bp(i,a.toolArgs))})}const Sb="setup__create_mandate";function Jp({proposal:e,manifests:r,titles:a,selected:i=!1,onOpen:l,who:u}){const d=Date.now(),p=yp(e.expiresAt,d),m=Mn(),v=zp(e.id),y=cb(v),j=va(e),x=e.tool===Sb,S=x?no(j.toolArgs,e.profileId):e.profileId,N=Dr(S,m),b=e.authorizationId?a[e.authorizationId]:void 0,k=Nc(b,N)?b:void 0,C=[k,y==null?void 0:y.text].filter(Boolean);return n.jsx("div",{className:`av3-row${i?" is-selected":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:n.jsxs("button",{type:"button",className:"appr-item-head av3-row-head","aria-current":i||void 0,onClick:l,children:[n.jsxs("span",{className:"av3-type",children:[x?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Br,{icon:Kn(S)}),N]}),n.jsx("span",{children:gp(e.createdAt*1e3,d)})]}),n.jsx("span",{className:"av3-row-title","data-testid":"approval-row-summary",children:n.jsx(bb,{proposal:e,manifests:r})}),(C.length>0||u||p)&&n.jsxs("span",{className:"av3-row-meta",children:[k&&n.jsx("span",{children:k}),y&&n.jsx("b",{className:y.status==="fail"?"av3-flag-fail":void 0,children:y.text}),p&&n.jsx("span",{children:p}),u&&n.jsx("span",{children:u})]})]})})}function dc({variant:e="base",style:r,className:a,...i}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:r,role:"status","aria-busy":"true","aria-label":i["aria-label"]??"Loading"})}const yr=5;function _h(e){return e.replace(/^today\s+/i,"")}function fc(e,r){return e&&e.trim().toLowerCase()!==r.trim().toLowerCase()?`via ${e}`:null}function kb({auths:e,activeCount:r,waiting:a,waitingReady:i}){const[l,u]=h.useState(null),[d,p]=h.useState(null),[m,v]=h.useState([]),[y,j]=h.useState({}),[x,S]=h.useState({}),N=h.useCallback(()=>{P.getMyReceiptsPage({limit:200}).then(L=>u(L.receipts)).catch(()=>u(L=>L??[])),P.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Wt(N,3e5),He("ticket-recorded",N),h.useEffect(()=>{P.getLabelManifests().then(v).catch(()=>{}),P.getLocalAuthorizations().then(({authorizations:L})=>j(L)).catch(()=>{})},[]);const b=Mn(),k=h.useMemo(()=>{const L={};for(const q of e)q.authorization_id&&q.title&&(L[q.authorization_id]=q.title);return L},[e]),C=Date.now(),E=h.useMemo(()=>{const L=Date.now();return(l??[]).filter(q=>Ur(q.timestamp,L))},[l]);h.useEffect(()=>{const L=[...new Set(E.map(q=>q.profileId))].filter(q=>!(q in x));L.length!==0&&Promise.all(L.map(q=>go(q).then(U=>[q,U]).catch(()=>[q,null]))).then(q=>S(U=>({...U,...Object.fromEntries(q)})))},[E,x]);const R=h.useMemo(()=>L0(E,{catalog:b,manifests:m,titles:k,lastSeenMs:d??Number.POSITIVE_INFINITY}),[E,b,m,k,d]),A=E.filter(L=>Ki(L,"approved")).length,z=h.useMemo(()=>M0(E,{nowMs:Date.now(),catalog:b,manifests:m,titles:k,boundsOf:L=>{var q;return(q=y[L])==null?void 0:q.bounds},profileOf:L=>x[L]}),[E,b,m,k,y,x]),M=R.filter(L=>L.newCount>0).length,H=[...a].sort((L,q)=>L.createdAt-q.createdAt),te=E.filter(L=>Ki(L,"approved")).sort((L,q)=>q.timestamp-L.timestamp).slice(0,Math.max(0,yr-Math.min(R.length,yr))),X=gn();return n.jsxs("div",{className:"core-cols dash-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),i?H.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):n.jsx("div",{className:"dash-rows",children:H.slice(0,yr).map(L=>n.jsx("div",{"data-testid":"dash-approval",children:n.jsx(Jp,{proposal:L,manifests:m,titles:k,onOpen:()=>X(`/approvals?open=${encodeURIComponent(L.id)}`)})},L.id))}):n.jsx(dc,{variant:"line"}),H.length>0&&n.jsx(ut,{to:"/approvals",className:"ob-btn dash-btn",children:"All approvals"})]}),n.jsxs("section",{"aria-label":"Done today","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done today"}),M>0&&n.jsxs("span",{className:"meta",children:[R.reduce((L,q)=>L+q.newCount,0)," new"]})]}),l===null?n.jsx(dc,{variant:"line"}):R.length===0&&te.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done today."}):n.jsxs("div",{className:"dash-rows",children:[R.slice(0,yr).map(L=>n.jsxs("details",{className:`ob-card dash-row auto-grp${L.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx(Fr,{tag:"Ticket",className:"obj-line",profileId:L.profileId,parts:[n.jsx("span",{className:"sr-only",children:L.area},"a"),fc(L.system,L.area),_h(ma(L.latestSec,C)),n.jsx("span",{className:"ob-st",children:"Automatic"},"st")]}),n.jsxs("span",{className:"ob-title",children:[L.area," · ",L.count," × ",L.label]}),n.jsxs("span",{className:"ob-one",children:[Nc(L.mandateTitle,L.area)&&n.jsxs("span",{"data-testid":"mandate-line",children:["Mandate: ",L.mandateTitle]}),n.jsx("span",{children:L.newCount>0?n.jsxs("b",{className:"ob-bold",children:[L.newCount," new"]}):"seen"})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[L.tickets.slice(0,yr).map(q=>n.jsxs("div",{className:"auto-grp-row",children:[vs(q,m),n.jsxs("span",{className:"t",children:[ma(q.timestamp,C)," · ",iu(q.id),Yi(q,d??Number.POSITIVE_INFINITY)?" · new":""]})]},q.id)),L.tickets.length>yr&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",L.tickets.length-yr," more in Tickets"]})]})]},L.key)),te.map(L=>{const q=Dr(L.profileId,b),U=po(L.action,m),K=L.authorizationId?k[L.authorizationId]:void 0;return n.jsxs(ut,{to:"/tickets?filter=approved",className:"ob-card dash-row","data-testid":"dash-approved-ticket",children:[n.jsx(Fr,{tag:"Ticket",className:"obj-line",profileId:L.profileId,parts:[n.jsx("span",{className:"sr-only",children:q},"a"),fc(U,q),_h(ma(L.timestamp,C)),n.jsx("span",{className:"ob-st",children:"Approved"},"st")]}),n.jsxs("span",{className:"ob-title",children:[q," · ",vs(L,m)]}),Nc(K,q)&&n.jsxs("span",{className:"ob-one","data-testid":"mandate-line",children:["Mandate: ",K]})]},L.id)})]}),(R.length>0||te.length>0)&&n.jsx(ut,{to:R.length>0?"/tickets?filter=automatic":"/tickets",className:"ob-btn dash-btn","data-testid":"btn-automatic-tickets",children:"All tickets"}),A>te.length&&n.jsxs("div",{className:"core-quiet-line",children:[A," approved today — ",n.jsx(ut,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(dc,{variant:"line"}):z.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):n.jsx("div",{className:"dash-rows",children:z.slice(0,yr).map(L=>{var q;return n.jsxs(ut,{to:"/mandates",className:"ob-card dash-row mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(Fr,{tag:"Mandate",className:"obj-line",profileId:L.profileId,parts:[L.area,fc(L.system,L.area)]}),n.jsx("span",{className:"ob-title",children:(q=L.mandateTitle)!=null&&q.trim()?L.mandateTitle:L.area}),n.jsx("span",{className:"ob-one",children:L.limit!==void 0?F0(L)?n.jsxs("b",{className:"ob-bold",children:[L.used," of ",L.limit," used today"]}):`${L.used} of ${L.limit} used today`:`${L.used} ${L.used===1?"action":"actions"} today`})]},L.authorizationId)})}),l!==null&&r>z.length&&n.jsxs("p",{className:"core-quiet-line",children:[r-z.length," more mandate",r-z.length===1?"":"s"," in force — no actions today."]}),r>0&&n.jsx(ut,{to:"/mandates",className:"ob-btn dash-btn",children:"All mandates"})]})]})}function Nb(){const[e,r]=h.useState(null),[a,i]=h.useState(Number.POSITIVE_INFINITY),l=h.useCallback(()=>{Promise.all([P.getReport().then(p=>p.report).catch(()=>null),P.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,m])=>{r(p),i(m)})},[]);if(Wt(l,3e5),He("report-written",l),!e||!fp(e,a))return null;const{verified:u,unchecked:d}=N0(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:k0(e.renderedHtml)})," — ",n.jsx("span",{title:Gi(e.coverage).title,children:Gi(e.coverage).text})," · written ",hp(e.savedAt,Date.now()),d===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",d," could not be checked"]})]})]}),n.jsx(ut,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function Cb(){const[e,r]=h.useState([]);return Wt(async()=>{try{const{skipped:i}=await P.getSkippedCommitments();r(i)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(i=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:i.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",i.id,")"]})]},i.id))})]})}const Eb=1800;function ca(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Tb(){const{domain:e}=kt(),[r,a]=h.useState([]),[i,l]=h.useState([]),[u,d]=h.useState([]),[p,m]=h.useState(!0),[v,y]=h.useState(!1),[j,x]=h.useState([]),[S,N]=h.useState(!1),[b,k]=h.useState(!1),[C,E]=h.useState(null),[R,A]=h.useState(!1),{entries:z,activeSessions:M,loading:H}=ru(),te=Pw(),X=!H,{simulation:L}=Ap(),q=L===!0,U=Mw(),K=h.useCallback(()=>{P.getMyAttestations().then(ne=>{a(ne),y(!0)}).catch(()=>y(!0)),P.getArchivedMandates().then(x).catch(()=>x([])),P.getMyProposals(e).then(ne=>{l(ne),N(!0)}).catch(()=>N(!0)),P.getProposalsForApprover().then(ne=>d(ne)).catch(()=>d([])),P.getCredential("ai-config").then(ne=>{m(ne.configured),k(!0)}).catch(()=>k(!0)),P.getAgentContact().then(ne=>{E(ne.contact),A(!0)}).catch(()=>A(!0))},[e]);He("attestation-changed",K),He("proposal-added",K),He("proposal-resolved",K),He("proposal-approved",K),He("proposal-rejected",K),He("execution-failed",K),Wt(K,3e5,e);const ce=v&&S&&b&&X&&R&&L!==null,ee=Qm(r,{archivedSet:new Set(j)}),Se=ee.active,Ae=ee.expired,Z=Se.some(ne=>ca(ne.profile_id)==="delegation"),G=Se.filter(ne=>ca(ne.profile_id)!=="delegation").length,Y=i.filter(ne=>ca(ne.profileId)==="delegation").length,I=Tp({hasContact:C!==null,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:Y,managed:U,simulationOn:q}),F=q&&I.visible,pe=Se.filter(ne=>ne.remaining_seconds!==null&&ne.remaining_seconds<=Eb),fe=i.filter(wp),we=z.filter(ne=>ne.state==="running"),ve=z.filter(ne=>ne.state==="starting"),Q=Hj(z),de=[...fe,...u.filter(ne=>!fe.some(Be=>Be.id===ne.id))],le=[];for(const ne of pe){const Be=Math.ceil((ne.remaining_seconds??0)/60);le.push({label:"Expiring soon",detail:`${ne.title??ca(ne.profile_id)} — ${Be} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const ne of Ae)le.push({label:"Expired",detail:ne.title??ca(ne.profile_id),to:"/mandates",color:"var(--text-primary)"});le.push(...Wj(z,q));for(const ne of ve)le.push({label:"Integration starting",detail:`${ne.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const ne of z)ne.authStatus==="failed"&&ne.state!=="not-running"&&ne.state!=="error"&&ne.state!=="paused"&&le.push({label:"Reconnect needed",detail:`${ne.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return p||le.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),n.jsxs("div",{className:"dash-page",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Dashboard"})}),ce&&te&&(F?n.jsx($w,{contact:C,hasDelegationMandate:Z,otherMandateCount:G,delegationProposalCount:Y,managed:U,simulationOn:q,mcpEndpoint:te}):!q&&n.jsx(Iw,{aiConfigured:p,hasRunningIntegration:we.length>0,hasActiveAuth:Se.length>0,hasAgentConnected:M>0,mcpEndpoint:te})),!F&&n.jsxs(n.Fragment,{children:[n.jsx(kb,{auths:r,activeCount:Se.length,waiting:de,waitingReady:S}),n.jsx(Nb,{})]}),Q&&n.jsxs("div",{className:"sim-paused-summary",role:"status",children:[n.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),n.jsxs("span",{children:[n.jsxs("b",{children:[Q.count," real system",Q.count===1?"":"s"," ",Q.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Q.namesText,"."]})]}),n.jsx(Cb,{}),n.jsx(c0,{}),!F&&le.length>0&&n.jsxs("section",{className:"dash-sec","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Setup — needs attention"}),n.jsx("span",{className:"pill-count",children:le.length})]}),n.jsx("div",{className:"ob-card dash-att",children:le.map((ne,Be)=>n.jsxs(ut,{to:ne.to,className:"dash-att-row",children:[n.jsx("b",{children:ne.label}),n.jsx("span",{children:ne.detail}),n.jsx("i",{"aria-hidden":"true",children:"›"})]},Be))})]})]})}const Ab=["Scope & Limits","Intent","Sign"];function Qp({currentStep:e,onStepClick:r}){const a=gn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:Ab.map((i,l)=>{const u=l+2,d=u<e,p=u===e,m=u-1<e,v=d&&!!r;return n.jsxs("li",{className:`wizard-step${m?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${d?" completed":""}${p?" current":""}`,onClick:v?()=>r(u):void 0,disabled:!v,"aria-label":`${i}${d?" (done)":p?" (current)":""}`,children:d?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":d?" completed":""}`,children:i})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function Ib({profileId:e,bounds:r,groupName:a,domain:i,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),i?` / ${i}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Ht(e)]}),r&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",r]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function Rb({integrationId:e,field:r,value:a,onChange:i,disabled:l,onLabels:u}){const[d,p]=h.useState(null),[m,v]=h.useState(null),[y,j]=h.useState(!0);h.useEffect(()=>{let N=!1;return P.discoverScopeField(e,r).then(b=>{var k;N||(p(b.options),j(!1),(k=b.options)!=null&&k.length&&(u==null||u(Object.fromEntries(b.options.map(C=>[C.value,C.label])))))}).catch(b=>{N||(v(b instanceof Error?b.message:String(b)),j(!1))}),()=>{N=!0}},[e,r]);const x=new Set(a.split(",").map(N=>N.trim()).filter(Boolean)),S=N=>{const b=new Set(x);b.has(N)?b.delete(N):b.add(N),i(Array.from(b).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):m||!d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",m??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:N=>i(N.target.value),disabled:l})]}):d.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:d.map(N=>{const b=N.extras??{},k=typeof b.access=="string"?b.access:void 0,C=k==="reader",E=b.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:C?"var(--text-tertiary)":"var(--text-primary)",cursor:l||C?"not-allowed":"pointer"},title:C?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(N.value)),onChange:()=>S(String(N.value)),disabled:l||C}),n.jsx("span",{children:N.label||N.value}),E&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),k&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",k]})]},N.value)})})}function uu(e){if(e.type!=="number")return 0;const r=e.boundType,a=e.unit;return(r==null?void 0:r.kind)==="per_transaction"&&a==="count"?1:0}function Lh(e,r){if(r!==void 0)return String(r);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):uu(e)===1?"1":""}function Lc(e){const r=e.maximum;return typeof r=="number"&&Number.isFinite(r)?r:void 0}function Mh(e,r){const a=uu(e),i=Lc(e),l=r===""?a:Math.max(a,Number(r));return i!==void 0?Math.min(i,l):l}function $b(e,r){var i;const a=(i=e.capKinds)==null?void 0:i[r];return a||(e.approvers.length>0?"approval":"hard")}function du(e,r,a){var i;return e.approvers.length===0||(r==null?void 0:r.enforcedBy)==="gatekeeper"||((i=r==null?void 0:r.boundType)==null?void 0:i.kind)==="enum"?"hard":$b(e,a)}function Xp(e,r,a){const i=e.indexOf(r),l=e.indexOf(a);return i===-1||l===-1?!1:l<i}function ro(e,r){var a;return((a=e.caps)==null?void 0:a[r])!==void 0}function Pb(e,r,a){const i=Object.entries(r.caps??{}).filter(([u])=>du(r,a[u],u)==="approval");if(i.length===0)return null;const l=u=>{var d;return((d=a[u])==null?void 0:d.displayName)??u};for(const[u,d]of i){const p=a[u],m=p==null?void 0:p.boundType,v=(m==null?void 0:m.kind)==="per_transaction"||(m==null?void 0:m.kind)==="cumulative_sum"?m.of:void 0,y=v?e[v]:void 0;if(typeof d=="number"&&typeof y=="number"&&y>d)return{field:u,fieldLabel:l(u),cap:d,value:y}}if(i.length===1){const[u,d]=i[0];return{field:u,fieldLabel:l(u),cap:d}}return null}function _b(e){return(e==null?void 0:e.valuesFrom)==="profiles"}const Zp=e=>(e.replace(/@.*$/,"").split("/").pop()??e).toLowerCase(),Fh=e=>e.split("@")[1]??"";function Lb(e){const r=new Map;for(const{id:a}of e){const i=Zp(a),l=r.get(i);(!l||Fh(a).localeCompare(Fh(l),void 0,{numeric:!0})>0)&&r.set(i,a)}return[...r.values()]}function Mb(e,r,a){var l;const i=((l=e.constraint)==null?void 0:l.requiredFor)??[];return r.filter(u=>a(u.id)).filter(u=>{var d;return!(((d=u.boundsSchema)==null?void 0:d.actionTypes)??[]).some(p=>i.includes(p))}).map(u=>Zp(u.id)).sort((u,d)=>u.localeCompare(d))}function Fb(e,r){var m;const[a,i]=h.useState({}),l=Object.entries(((m=e.scopeSchema)==null?void 0:m.fields)??{}).filter(([,v])=>_b(v)),u=l.length>0,d=r==null?void 0:r.groupId,p=!!(r!=null&&r.isPersonal);return h.useEffect(()=>{if(!u)return;let v=!0;return(async()=>{const y=Lb(await np()),j=(await Promise.all(y.map(N=>go(N)))).filter(N=>!!N);let x;if(p)x=()=>!0;else if(d){const N=await Promise.all(j.map(k=>P.getTeamProfileConfig(d,k.id).catch(()=>null))),b=new Set(j.filter((k,C)=>N[C]).map(k=>k.id));x=k=>b.has(k)}else x=()=>!1;const S={};for(const[N,b]of l)S[N]=Mb(b,j,x);v&&i(S)})(),()=>{v=!1}},[e.id,u,d,p]),a}function Ob(e){return e.replace(/@.*$/,"").split("/").pop()??e}function fu(e,r){return r.displayName?r.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function zb(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Bb(e){var a;const r=e;return!!(r.enum&&((a=r.constraint)!=null&&a.enforceable.includes("subset")))}function Db(e,r){if(!e)return;const a=(r??"").split(",").map(i=>i.trim()).filter(Boolean);return[...e,...a.filter(i=>!e.includes(i))]}function Oh(e,r){const a=e.trim();return a?r==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:r==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Ub(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Wb(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Hb(e,r){if(!e||!r)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(r==="minutes"&&a>=60){const i=Math.floor(a/60),l=a%60;return l===0?`${i} hour${i!==1?"s":""}`:`${i}h ${l}m`}if(r==="hours"&&a>=24&&a%24===0){const i=a/24;return`${i} day${i!==1?"s":""}`}if(r==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function Vb({id:e,value:r,onChange:a,disabled:i,placeholder:l,unit:u,min:d=0,max:p}){const m=Ub(u),v=Wb(u).filter(b=>p===void 0||b.value<=p),y=mo(u),j=Hb(r,u),x=r===""?null:Number(r),S=()=>{const b=r===""?0:Number(r),k=b%m,C=k===0?b+m:b+(m-k);a(String(p!==void 0?Math.min(p,C):C))},N=()=>{const b=r===""?0:Number(r);if(b<=d)return;const k=b%m,C=k===0?b-m:b-k;a(String(Math.max(d,C)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:N,disabled:i||r===""||Number(r)<=d,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:d,max:p,step:m,value:r,placeholder:l??String(d),onChange:b=>{const k=b.target.value;a(p!==void 0&&k!==""&&Number(k)>p?String(p):k)},onFocus:b=>b.target.select(),disabled:i}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:S,disabled:i||p!==void 0&&r!==""&&Number(r)>=p,"aria-label":"Increase",children:"+"}),y&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!i&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(b=>n.jsx("button",{type:"button",className:`preset-chip${x===b.value?" preset-chip-selected":""}`,onClick:()=>a(String(b.value)),children:b.label},b.value))}),j&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",j]})]})}function zh({htmlFor:e,label:r,description:a}){const[i,l]=h.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:r}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${r}" mean?`,"aria-expanded":i,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),i&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function Gb({id:e,value:r,onChange:a,disabled:i,format:l,placeholder:u}){const[d,p]=h.useState(""),[m,v]=h.useState(!1),y=h.useRef(null),j=r?r.split(",").map(C=>C.trim()).filter(Boolean):[],x=C=>{const E=C.trim();if(!E)return;if(!Oh(E,l)){v(!0);return}v(!1);const R=j.includes(E)?j:[...j,E];a(R.join(",")),p("")},S=C=>{const E=j.filter((R,A)=>A!==C);a(E.join(","))},N=C=>{C.key==="Enter"||C.key===","||C.key==="Tab"?d.trim()&&(C.preventDefault(),x(d)):C.key==="Backspace"&&!d&&j.length>0&&S(j.length-1)},b=C=>{const E=C.clipboardData.getData("text");if(E.includes(",")){C.preventDefault();const A=E.split(",").map(M=>M.trim()).filter(Boolean).filter(M=>Oh(M,l)),z=[...new Set([...j,...A])];a(z.join(",")),p(""),v(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${m?" tag-input-invalid":""}`,onClick:()=>{var C;return(C=y.current)==null?void 0:C.focus()},children:[j.map((C,E)=>n.jsxs("span",{className:"tag-pill",children:[C,!i&&n.jsx("button",{type:"button",className:"tag-remove",onClick:R=>{R.stopPropagation(),S(E)},"aria-label":`Remove ${C}`,children:"×"})]},C)),!i&&n.jsx("input",{ref:y,id:e,className:"tag-input-field",type:"text",value:d,onChange:C=>{p(C.target.value),v(!1)},onKeyDown:N,onPaste:b,onBlur:()=>{d.trim()&&x(d)},placeholder:j.length===0?u??k:""})]})}function qb({id:e,options:r,value:a,onChange:i,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],d=p=>{const m=u.includes(p)?u.filter(v=>v!==p):[...u,p];i(m.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:r.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>d(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function Bh({fieldKey:e,fieldDef:r,value:a,onChange:i,prefix:l,readOnly:u,twoColumn:d,discoveryIntegrationId:p,onLabels:m,capMax:v,enumAllowedFrom:y,options:j}){const x=fu(e,r),S=`${l}-field-${e}`,N=n.jsx(n.Fragment,{children:Bb(r)||j?n.jsx(qb,{id:S,options:j??r.enum,value:a,onChange:b=>i(e,b),disabled:u}):(()=>{const b=r.boundType;return(b==null?void 0:b.kind)==="enum"&&Array.isArray(b.values)})()?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:b=>i(e,b.target.value),disabled:u||y!==void 0&&r.boundType.values.length-y<=1,children:[n.jsx("option",{value:"",children:"Select..."}),r.boundType.values.map((b,k)=>n.jsx("option",{value:b,disabled:y!==void 0&&k<y,children:b},b))]}):r.enum?n.jsxs("select",{id:S,className:"form-select",value:a,onChange:b=>i(e,b.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),r.enum.map(b=>n.jsx("option",{value:b,children:b},b))]}):r.type==="number"?n.jsx(Vb,{id:S,value:a,onChange:b=>i(e,b),disabled:u,unit:r.unit,min:uu(r),max:v!==void 0?Math.min(v,Lc(r)??v):Lc(r)}):zb(r)?n.jsx(Gb,{id:S,value:a,onChange:b=>i(e,b),disabled:u,format:r.format}):p?n.jsx(Rb,{integrationId:p,field:e,value:a,onChange:b=>i(e,b),disabled:u,onLabels:b=>m==null?void 0:m(e,b)}):n.jsx("input",{id:S,className:"form-input",type:"text",value:a,onChange:b=>i(e,b.target.value),disabled:u})});return d?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(zh,{htmlFor:S,label:x,description:r.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(zh,{htmlFor:S,label:x,description:r.description}),N]},`${l}-${e}`)}function Kb(e,r,a,i){if(!i||!ro(i,e))return null;const l=i.caps[e],u=du(i,r,e);let d=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);d=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=r.boundType;d=(p==null?void 0:p.kind)==="enum"?Xp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:d}}function Dh(e,r,a,i){if(!i||!ro(i,e))return a;const l=du(i,r,e),u=i.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const d=a===""?NaN:Number(a);return String(Number.isNaN(d)?u:Math.min(d,u))}if(typeof u=="string"){const d=r.boundType,p=(d==null?void 0:d.kind)==="enum"?d.values??[]:[];return a!==""&&Xp(p,u,a)?u:a}return a}function Yb(e,r){if(typeof r!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const i=(a.values??[]).indexOf(r);return i===-1?void 0:i}function Jb(e,r){return mo(r.unit)||fu(e,r).toLowerCase()}function eg(e,r){if(r&&r.length>0)return r.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Qb(e,r,a,i,l){var v;const u=r.enforcedBy==="gatekeeper",d=((v=r.boundType)==null?void 0:v.kind)==="enum";if(a.kind==="hard")return d?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",fu(e,r).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=Jb(e,r),m=eg(i,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",m," for approval."]})}function Xb({profile:e,onConfirm:r,onCancel:a,readOnly:i,initialBounds:l,initialContext:u,initialFrame:d,profileConfig:p,approverNames:m,adminName:v,workspace:y}){var ve;const j=e.boundsSchema,x=Fb(e,y),S=e.scopeSchema,N=Q=>!!p&&ro(p,Q),b=j?Object.entries(j.fields).filter(([Q,de])=>!(Q==="profile"||Q==="path"||de.enforced===!1||de.enforcedBy==="gatekeeper"&&!N(Q))):[],k=j?Object.entries(j.fields).filter(([Q,de])=>de.enforcedBy==="gatekeeper"&&!N(Q)).filter(([,Q])=>Q.enforced!==!1).map(([Q,de])=>de.displayName??Q):[],C=S&&S.keyOrder.length>0?Object.entries(S.fields):[],E=l??d??{},R=u??{},A={};for(const[Q,de]of b)A[Q]=Dh(Q,de,Lh(de,E[Q]),p);const z={};for(const[Q]of C)z[Q]=R[Q]!==void 0?String(R[Q]):"";const[M,H]=h.useState(A),[te,X]=h.useState(z),[L,q]=h.useState({}),U=h.useRef(new Set);h.useEffect(()=>{H(Q=>{let de=!1;const le={...Q};for(const[ne,Be]of b){if(U.current.has(ne))continue;const Me=Q[ne]!==void 0?Q[ne]:Lh(Be,E[ne]),ae=Dh(ne,Be,Me,p);le[ne]!==ae&&(le[ne]=ae,de=!0)}return de?le:Q})},[p]);const[K,ce]=h.useState(null);h.useEffect(()=>{const Q=Ob(e.id);P.getIntegrationManifests().then(({manifests:de})=>{const le=de.find(ne=>ne.profile===Q&&ne.contextDiscovery&&Object.keys(ne.contextDiscovery).length>0);ce(le??null)}).catch(()=>ce(null))},[e.id]);const ee={};for(const[Q,de]of b)ee[Q]=Kb(Q,de,M[Q]??"",p);const Se=Object.entries(ee).filter(([,Q])=>(Q==null?void 0:Q.kind)==="hard"&&Q.violating).map(([Q])=>Q),Ae=!!p&&(((ve=p.approvers)==null?void 0:ve.length)??0)>0&&b.every(([Q])=>!ro(p,Q)),Z=(Q,de)=>{U.current.add(Q),H(le=>({...le,[Q]:de}))},G=(Q,de)=>{X(le=>({...le,[Q]:de}))},Y=()=>{const Q={profile:e.id};for(const[le,ne]of b)ne.type==="number"?Q[le]=Mh(ne,M[le]):Q[le]=M[le];const de={};for(const[le,ne]of C)ne.type==="number"?de[le]=te[le]===""?0:Number(te[le]):de[le]=te[le];return[Q,de]},I=()=>{const[Q,de]=Y();r(Q,de,L)},F=()=>{var ne;const Q={...M};for(const Be of Se){const Me=(ne=ee[Be])==null?void 0:ne.cap;Me!==void 0&&(Q[Be]=String(Me))}H(Q);const de={profile:e.id};for(const[Be,Me]of b)Me.type==="number"?de[Be]=Mh(Me,Q[Be]??""):de[Be]=Q[Be]??"";const le={};for(const[Be,Me]of C)Me.type==="number"?le[Be]=te[Be]===""?0:Number(te[Be]):le[Be]=te[Be];r(de,le,L)},pe=()=>{if(!Ae)return null;const Q=eg(p,m);return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",Q]}),n.jsxs("div",{children:["No caps are set on this profile, so ",Q," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})},fe=()=>{if(Se.length===0)return null;const Q=v??"the team admin";return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"2px solid var(--border-strong)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsx("div",{className:"msg-error",style:{marginBottom:"0.25rem"},children:"Hard team ceiling."}),n.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Lower the bound(s) above, or ask ",Q," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:F,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},we=Se.length>0;return n.jsxs("div",{children:[C.length>0&&n.jsxs("div",{className:"context-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🛡"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),C.map(([Q,de])=>{var ne;const le=!!((ne=K==null?void 0:K.contextDiscovery)!=null&&ne[Q]);return n.jsx(Bh,{fieldKey:Q,fieldDef:de,value:te[Q],onChange:G,prefix:"context",readOnly:i,discoveryIntegrationId:le?K.id:void 0,onLabels:(Be,Me)=>q(ae=>({...ae,[Be]:Me})),options:Db(x[Q],te[Q])},`context-${Q}`)})]}),b.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:b.map(([Q,de])=>{const le=ee[Q];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(Bh,{fieldKey:Q,fieldDef:de,value:M[Q],onChange:Z,prefix:"bounds",readOnly:i,twoColumn:!0,capMax:(le==null?void 0:le.kind)==="hard"&&typeof le.cap=="number"?le.cap:void 0,enumAllowedFrom:(le==null?void 0:le.kind)==="hard"?Yb(de,le.cap):void 0}),le&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Qb(Q,de,le,p,m)})]},`bounds-${Q}`)})}),pe(),fe(),k.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[k.join(", ")," ",k.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",n.jsx(ut,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:I,disabled:we,style:{marginTop:"0.5rem"},children:i?"Next: Gates":"Next: Problem Statement"})]})}function Zb(e){var a;const r=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=r==null?void 0:r[1])==null?void 0:a.trim())??null}function eS(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const tS="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function so({target:e,currentText:r,onApply:a,greeting:i,placeholder:l,title:u}){const[d,p]=h.useState([{role:"assistant",content:i??tS}]),[m,v]=h.useState(""),[y,j]=h.useState(!1),[x,S]=h.useState(null),N=h.useRef(null),b=h.useRef(null);h.useEffect(()=>{const E=N.current;if(!E)return;const R=d[d.length-1],A=b.current;!y&&(R==null?void 0:R.role)==="assistant"&&d.length>1&&A?E.scrollTop=A.offsetTop:E.scrollTop=E.scrollHeight},[d,y]);const k=async()=>{const E=m.trim();if(!E||y)return;const R=[...d,{role:"user",content:E}];p(R),v(""),S(null),j(!0);try{const A=await P.aiChat({target:e,currentText:r,messages:R.filter((z,M)=>!(M===0&&z.role==="assistant"))});A.success&&A.reply?p(z=>[...z,{role:"assistant",content:A.reply}]):S(A.error??"AI returned no reply")}catch(A){S(A instanceof Error?A.message:"Chat failed")}finally{j(!1)}},C=E=>{E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),k())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:N,className:"chat-messages",children:[d.map((E,R)=>{const A=E.role==="assistant"?Zb(E.content):null,z=A?eS(E.content):E.content;return n.jsx("div",{className:`chat-msg ${E.role}`,ref:R===d.length-1?b:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[z&&n.jsx("div",{className:"chat-msg-prose",children:z}),A!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:A}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(A),children:"Apply this draft"})]})]})},R)}),y&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:m,onChange:E=>v(E.target.value),onKeyDown:C,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:y}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:k,disabled:y||!m.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function tg({open:e,onClose:r,children:a,ariaLabel:i}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,r]),Sj.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:r,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:r,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function nS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rS(e,r,a){if(r.length===0)return[{text:e,label:e,matched:null}];const i=[],l=new Set;for(const m of r)if(!(!m.scope||m.scope==="all (unscoped)"))for(const v of[m.scope,...m.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),i.push(v))}i.sort((m,v)=>v.length-m.length);const u=m=>{const v=m.toLowerCase();return r.filter(y=>{var j,x;return((j=y.scope)==null?void 0:j.toLowerCase())===v||((x=y.scope)==null?void 0:x.split(",").map(S=>S.trim().toLowerCase()).includes(v))})},d=["\\[\\d+\\]",...i.map(nS)],p=new RegExp(`(${d.join("|")})`,"gi");return e.split(p).filter(m=>m!=="").map(m=>{const v=/^\[(\d+)\]$/.exec(m);if(v){const y=r[Number(v[1])-1];if(y){const j=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",x=a?`${a}: ${j}`:j;return{text:m,label:x,matched:[y]}}}else if(i.some(y=>y.toLowerCase()===m.toLowerCase())){const y=u(m);if(y.length>0)return{text:m,label:m,matched:y}}return{text:m,label:m,matched:null}})}const Uh=`Why — What's the situation? Why does this need to happen?
|
|
71
|
-
|
|
72
|
-
Goal — What should the agent try to achieve?
|
|
73
|
-
|
|
74
|
-
Watch out — What should the agent avoid or be careful about?`;function sS(e,r,a,i){return rS(e,r,i).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const d=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(d),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function aS(){var Me;const e=gn(),[r]=ks(),a=Number(r.get("step"))||2,[i,l]=h.useState(null),[u,d]=h.useState(null),[p,m]=h.useState(a),[v,y]=h.useState(null),[j,x]=h.useState(null),[S,N]=h.useState({}),[b,k]=h.useState(Uh),[C,E]=h.useState(!1),[R,A]=h.useState(null),[z,M]=h.useState(!0),[H,te]=h.useState(null),[X,L]=h.useState([]),[q,U]=h.useState(void 0),[K,ce]=h.useState(!1),[ee,Se]=h.useState(null),[Ae,Z]=h.useState(null),[G,Y]=h.useState(null),[I,F]=h.useState([]),[pe,fe]=h.useState(null);h.useEffect(()=>{var ze;const ae=sessionStorage.getItem("agentAuth");if(!ae){e("/mandates?new=1");return}const We=JSON.parse(ae);l(We),We.intentHint&&k(We.intentHint),P.getCredential("ai-config").then(Ve=>A(Ve.configured)).catch(()=>A(!1));const Re=sessionStorage.getItem("agentGate");if(Re){const Ve=JSON.parse(Re);Ve.bounds&&y(Ve.bounds),Ve.context&&x(Ve.context),(ze=Ve.gateContent)!=null&&ze.intent&&k(Ve.gateContent.intent)}P.getProfile(We.profileId).then(Ve=>d(Ve)).catch(()=>e("/mandates?new=1")).finally(()=>M(!1)),We.groupId&&Promise.all([P.getTeamProfileConfig(We.groupId,We.profileId).catch(()=>null),P.getGroupById(We.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([Ve,ct,tt])=>{if(te(Ve),Ve){const Qe=new Map;for(const Oe of tt){const J=Oe.name&&Oe.email?`${Oe.name} (${Oe.email})`:Oe.name||Oe.email||Oe.id;Qe.set(Oe.id,J)}const De=(ct==null?void 0:ct.members)??[];for(const Oe of De){const J=Oe.userId??Oe.id;J&&(Oe.name&&Oe.email?Qe.set(J,`${Oe.name} (${Oe.email})`):Oe.name&&Qe.set(J,Oe.name))}const gt=(Ve.approvers??[]).map(Oe=>Qe.get(Oe)??Oe);L(gt);const st=De.find(Oe=>Oe.role==="admin");if(st){const Oe=st.userId??st.id;Oe&&U(Qe.get(Oe)??st.name)}}})},[e]);const we=v?Object.entries(v).filter(([ae])=>ae!=="profile"&&ae!=="path").map(([ae,We])=>`${ae} = ${We}`).join(", "):"",ve=(ae,We,Re)=>{y(ae),x(We),Re&&N(Re),m(3)},Q=b.trim()!==Uh.trim()&&b.trim()!=="",de=ae=>{Q&&!confirm("Replace your current intent with the AI draft?")||k(ae)},le=()=>{const ae=u==null?void 0:u.ttl,We={intent:b},Re=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...Re,bounds:v,context:j,contextLabels:S,gateContent:We,ttlConfig:ae})),e("/mandates/new/sign")},ne=async()=>{if(i){ce(!0),Se(null),Z(null),Y(null),F([]),fe(null);try{const ae=await P.aiIntentReview({profileId:i.profileId,newIntent:b,context:j??void 0});F(ae.grants??[]),ae.success?ae.review?Se(ae.review):Z(ae.note??"No other mandates on this profile to compare against."):Y(ae.error??"Check failed.")}catch(ae){Y(ae instanceof Error?ae.message:"Check failed.")}finally{ce(!1)}}},Be=ae=>{k(ae),(ee||Ae||G)&&(Se(null),Z(null),Y(null),F([]),fe(null))};return z||!i||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Qp,{currentStep:p,onStepClick:ae=>{ae>=2&&m(ae)}}),n.jsx(Ib,{profileId:i.profileId,bounds:we||void 0,groupName:i.groupName,domain:i.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(Xb,{profile:u,onConfirm:ve,onCancel:()=>e("/mandates?new=1"),initialBounds:v||void 0,initialContext:j||void 0,profileConfig:H,approverNames:X,adminName:q,workspace:{groupId:i.groupId,isPersonal:i.isPersonal}})}),p===3&&n.jsxs("div",{className:`intent-layout${R?"":" no-chat"}`,children:[R&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(so,{target:{kind:"intent",profileId:i.profileId,bounds:we||void 0},currentText:b,onApply:de})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:b,onChange:ae=>Be(ae.target.value)}),n.jsxs("div",{className:"char-counter",children:[b.length," / 2000"]})]}),R===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(ut,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),R&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:ne,disabled:K||!Q,children:K?"Checking…":"Check against my other grants"}),G&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:G})]}),Ae&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:Ae})]}),ee&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:sS(ee,I,fe,Ht(i.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>m(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:le,disabled:!Q,children:"Continue to Review"})]}),(((Me=H==null?void 0:H.approvers)==null?void 0:Me.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",X.length>0?X.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",X.length>0?X.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),R&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>E(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(tg,{open:C,onClose:()=>E(!1),ariaLabel:"Intent assistant",children:n.jsx(so,{target:{kind:"intent",profileId:i.profileId,bounds:we||void 0},currentText:b,onApply:ae=>{de(ae),E(!1)}})})]}),pe&&n.jsx("div",{className:"modal-backdrop",onClick:ae=>ae.target===ae.currentTarget&&fe(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:pe.length>1?`Existing mandates (${pe.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>fe(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:pe.map((ae,We)=>{var Re;return n.jsxs("div",{style:{marginBottom:We<pe.length-1?"1rem":0,paddingBottom:We<pe.length-1?"1rem":0,borderBottom:We<pe.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:ae.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((Re=ae.intent)==null?void 0:Re.trim())||"(no intent recorded)"}),Object.entries(ae.bounds).filter(([ze])=>ze!=="profile"&&ze!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(ae.bounds).filter(([ze])=>ze!=="profile"&&ze!=="path").map(([ze,Ve])=>`${ze}: ${Ve}`).join(" · ")})]})]},We)})})]})})]})]})}function iS(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
75
|
-
`).split(`
|
|
76
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
77
|
-
`).replace(/\n+$/,"")}async function hu(e){const a=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(i)).map(u=>u.toString(16).padStart(2,"0")).join("")}class oS extends Error{constructor(a,i,l){super(l);ia(this,"code");ia(this,"field");this.name="CanonicalValueError",this.code=a,this.field=i}}function lS(e){const r=new TextEncoder().encode(e);let a="";for(const i of r)i===61||i===37||i<32||i>126?a+="%"+i.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(i);return a}function ng(e,r,a){const i=[];for(const l of r){const u=e[l];if(u==null)continue;const d=String(u);if(d.includes(`
|
|
78
|
-
`)||d.includes("\r"))throw new oS(a,l,`Value for "${l}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);i.push(`${l}=${lS(d)}`)}return i.join(`
|
|
79
|
-
`)}async function zi(e,r){const a=r.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const i=ng(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await hu(i)}`}async function rg(e,r){const a=r.scopeSchema?ng(e,r.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await hu(a)}`}function Mc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":Mc(l)).join(",")+"]";const r=e,a=[];for(const i of Object.keys(r).sort()){const l=r[i];l!==void 0&&a.push(JSON.stringify(i)+":"+Mc(l))}return"{"+a.join(",")+"}"}async function sg(e){return`sha256:${await hu(Mc(e))}`}async function ao(e){const r=new TextEncoder().encode(iS(e)),a=await crypto.subtle.digest("SHA-256",r);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function ag(e,r){if(!e.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??r.boundsHash,contextHash:r.contextHash,context:r.context,...r.contextLabels&&Object.keys(r.contextLabels).length>0?{contextLabels:r.contextLabels}:{},gateContent:r.gateContent,...r.path?{path:r.path}:{}}}function cS(e){const r=e.commitment_modes;return r===void 0?["review","automatic"]:Array.isArray(r)?["review","automatic"].filter(a=>r.includes(a)):[]}function uS(e){return e==="per-action"?"review":"automatic"}function Wh(e){return e?cS(e).map(r=>r==="review"?"per-action":"immediate"):["per-action","immediate"]}function dS(e,r){return r.includes(e)?e:r[0]??null}function Hh(e){return e==null?new Set:new Set(String(e).split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}function fS(e,r){for(const a of e)if(r.has(a))return!0;return!1}function hS(e,r,a){for(const i of e){const l=Hh(r[i]),u=Hh(a[i]);if(!(l.size===0||u.size===0)&&!fS(l,u))return!1}return!0}function mS(e){return e.length>24?`${e.slice(0,10)}…`:e}function ig(e,r,a){const i=a==null?void 0:a[e];return String(r).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const d=i==null?void 0:i[u];return d?`${d} (${mS(u)})`:u}).join(", ")}function og(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const r=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${r}.`,fix:`Ask an admin of ${r} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${r} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const Fc=500;function pS(e){const r=e.trim();return r.length===0?{valid:!1,error:"Describe what should change."}:r.length>Fc?{valid:!1,error:`At most ${Fc} characters (currently ${r.length}).`}:{valid:!0,trimmed:r}}function lg(){return{outcome:"rejected"}}function Vh(){return{outcome:"replaced"}}function gS(e,r){if((e.pendingApprovers??[]).includes(r))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(r)?{route:"resolve",domain:r}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const yS={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function vS(e,r){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const i=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:yS[i],who:a.userId===r?"You":a.userId,at:a.at,note:l}}function xS(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function jS(){var Ee,$e;const e=gn(),{user:r,mode:a,domain:i}=kt(),[l,u]=h.useState(null),[d,p]=h.useState(null),[m,v]=h.useState(null),[y,j]=h.useState("per-action"),[x,S]=h.useState(1800),[N,b]=h.useState(86400),[k,C]=h.useState(""),[E,R]=h.useState("hours"),[A,z]=h.useState(""),[M,H]=h.useState(!0),[te,X]=h.useState(!1);h.useEffect(()=>{P.getIdentityDisclosure().then(he=>X(he.always)).catch(()=>{})},[]);const[L,q]=h.useState(!1),[U,K]=h.useState(""),[ce,ee]=h.useState(null),[Se,Ae]=h.useState([]),[Z,G]=h.useState(!1),[Y,I]=h.useState([]),[F,pe]=h.useState(0);h.useEffect(()=>{var Nt;const he=sessionStorage.getItem("agentAuth"),Fe=sessionStorage.getItem("agentGate");if(!he||!Fe){e("/mandates?new=1");return}const Ke=JSON.parse(he),Xe=JSON.parse(Fe),at={bounds:Xe.bounds??{},context:Xe.context??{},contextLabels:Xe.contextLabels??void 0,gateContent:Xe.gateContent};u(Ke),p(at),Xe.ttlConfig&&(S(Xe.ttlConfig.default??1800),b(Xe.ttlConfig.max??86400)),Xe.templateMode==="automatic"?j("immediate"):Xe.templateMode==="review"&&j("per-action");const yt=((Nt=Xe.ttlConfig)==null?void 0:Nt.max)??86400;if(typeof Xe.templateTtl=="number"&&Xe.templateTtl>0){const qe=Math.min(Xe.templateTtl,yt);S(qe),[3600,86400,604800,2592e3,31536e3].includes(qe)||(qe%86400===0?(C(String(qe/86400)),R("days")):(C(String(Math.max(1,Math.round(qe/3600)))),R("hours")))}P.getProfile(Ke.profileId).then(qe=>{var W;if(v(qe),!A){const ye=qe.name??((W=Ke.profileId.split("/").pop())==null?void 0:W.replace(/@.*$/,""))??"",Ne=[];if(at.context&&qe.scopeSchema)for(const dt of qe.scopeSchema.keyOrder){const Ge=at.context[dt];if(Ge!==void 0&&Ge!==""){const be=String(Ge).split(",").map(it=>it.trim()).filter(Boolean);Ne.push(be.join(", "))}}const Ze=Ne.length>0?`${ye}: ${Ne.join(" · ")}`:ye;z(Ze)}}).catch(()=>{}),Ke.isPersonal?G(!0):Promise.all([P.getTeamProfileConfig(Ke.groupId,Ke.profileId).catch(()=>null),P.getGroupById(Ke.groupId).catch(()=>null),P.listUsers().catch(()=>[])]).then(([qe,W,ye])=>{if(ee(qe),qe){const Ne=new Map;for(const Ge of ye){const be=Ge.name&&Ge.email?`${Ge.name} (${Ge.email})`:Ge.name||Ge.email||Ge.id;Ne.set(Ge.id,be)}const Ze=(W==null?void 0:W.members)??[];for(const Ge of Ze){const be=Ge.userId??Ge.id;be&&(Ge.name&&Ge.email?Ne.set(be,`${Ge.name} (${Ge.email})`):Ge.name&&Ne.set(be,Ge.name))}const dt=(qe.approvers??[]).map(Ge=>Ne.get(Ge)??Ge);Ae(dt)}}).finally(()=>{G(!0)})},[e]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const he=l.profileId,Fe=sessionStorage.getItem("agentEditReplaces");P.getEnrichedAuthorizations().then(Ke=>{const Xe=Ke.filter(at=>at.profileId===he&&at.authorizationId!==Fe).map(at=>({authorizationId:at.authorizationId,bounds:at.bounds,context:at.context??{},intent:at.intent}));I(Xe)}).catch(()=>I([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!m)return;const he=dS(y,Wh(m));he&&he!==y&&j(he)},[m,y]),h.useEffect(()=>{if(!d||!m||Y.length===0){pe(0);return}let he=!1;return(async()=>{const Fe=await zi(d.bounds,m),Ke=await Promise.all(Y.map(Xe=>zi(Xe.bounds,m).catch(()=>null)));he||pe(Ke.filter(Xe=>Xe===Fe).length)})().catch(()=>{he||pe(0)}),()=>{he=!0}},[d,m,Y]);const fe=async()=>{if(!(!l||!d||!m||!r)){if(!l.groupId){K("No active group; cannot create mandate.");return}q(!0),K("");try{const he=i||l.domain||"owner",Fe=await zi(d.bounds,m),Ke=await rg(d.context,m),[Xe,at]=await Promise.all([ao(d.gateContent.intent),ao(JSON.stringify({profile:l.profileId,domain:he,group:l.groupId}))]);let yt,Nt,qe,W;if(l.isTeam){const it=await P.getApproversPubkeys(l.groupId,l.profileId);if(it.length>0){const bt=await P.encryptIntent(d.gateContent.intent,it);yt=bt.intentCiphertext,Nt=bt.encryptedKeys,qe=bt.approversFrozen,W=bt.intentDisclosureHash}}const ye=`authz_${crypto.randomUUID()}`,Ne=sessionStorage.getItem("agentEditReplaces")||void 0,Ze=sessionStorage.getItem("agentReplacesProposal")||void 0,dt=await sg(m),Ge=await P.attest({authorization_id:ye,replaces:Ne,profile_id:l.profileId,profile_hash:dt,supported_versions:["0.7"],bounds:d.bounds,bounds_hash:Fe,scope_hash:Ke,domain:he,did:r.did,mandate_owners:[{did:r.did}],gate_content_hashes:{intent:Xe},execution_context_hash:at,group_id:l.groupId,ttl:x,commitment_mode:uS(y),title:A.trim(),intent_ciphertext:yt,encrypted_keys:Nt,approvers_frozen:qe,intent_disclosure_hash:W,disclose_identity:M});try{await P.pushGateContent(ag(Ge,{boundsHash:Fe,contextHash:Ke,context:d.context,contextLabels:d.contextLabels,gateContent:d.gateContent}))}catch(it){try{await P.revokeAttestation(ye,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${it instanceof Error?it.message:"Unknown error"})`)}if(Ne)try{await P.revokeAttestation(Ne,`Replaced by ${ye} (edit)`),P.resyncGates().catch(()=>{})}catch{}let be="";if(Ze)try{const it=await P.getProposal(Ze);if(it.status==="pending"){const bt=gS(it,(r==null?void 0:r.id)??"");bt?bt.route==="approver"?await P.rejectProposal(Ze,Vh()):await P.resolveProposal(Ze,"reject",bt.domain,Vh()):be="you are not one of the people who may decide it"}}catch(it){be=it instanceof Error?it.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),be){K(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${be}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(ye)}`)}catch(he){K(he instanceof Error?he.message:"Signing the mandate failed")}finally{q(!1)}}};if(!l||!d)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const we=Object.entries(d.bounds).filter(([he])=>he!=="profile"&&he!=="path"),ve=Object.entries(d.context),de=((ce==null?void 0:ce.caps)!=null?Object.keys(ce.caps):[]).length!==0,le=Se.length>0?Se.join(", "):((ce==null?void 0:ce.approvers)??[]).join(", "),ne=de?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${le}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",Be=de?`Over-cap actions will be reviewed by you and ${le}. Within-cap actions run per the mode you chose above.`:`Approvers ${le} can read your intent but won't gate any action — no caps configured on this profile.`,Me=!!((Ee=ce==null?void 0:ce.approvers)!=null&&Ee.length),ae=og({isPersonal:l.isPersonal,configLoaded:Z,grantors:ce?Vm(ce):void 0,userId:r==null?void 0:r.id,profileName:Ht(l.profileId),teamName:l.groupName}),We=!ae.can,Re=Wh(m),ze=Re.length===0,Ve=x>N,ct={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},tt={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Qe=(($e=m==null?void 0:m.scopeSchema)==null?void 0:$e.keyOrder)??[],De=Y.filter(he=>hS(Qe,d.context,he.context)),gt=De.length>0,st=Ht(l.profileId),Oe=he=>{const Fe=Object.values(he).map(Ke=>String(Ke).trim()).filter(Boolean);return Fe.length>0?Fe.join(", "):"all (unscoped)"},J=De.map(he=>Oe(he.context)).join("; "),ge=`This grant's scope overlaps an existing grant on ${st} (scoped to: ${J}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return n.jsxs(n.Fragment,{children:[n.jsx(Qp,{currentStep:4,onStepClick:he=>{he<=3&&e(`/mandates/new/intent?step=${he}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&m&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Ht(l.profileId)," ",m.version," — the current version of this profile."]})]}),U&&n.jsx("div",{className:"error-message",children:U}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Ht(l.profileId)}: daily operations`,value:A,onChange:he=>z(he.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," ",Oi]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[Re.includes("per-action")&&n.jsxs("button",{onClick:()=>j("per-action"),style:tt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:eo.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:eo.text})]}),Re.includes("immediate")&&n.jsxs("button",{onClick:()=>j("immediate"),style:ct,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:to.title}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:to.text})]})]}),Re.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:Re[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),ze&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(he=>he.seconds<=N).map(he=>n.jsx("button",{onClick:()=>{S(he.seconds),C("")},style:{padding:"0.5rem 0.85rem",border:x===he.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===he.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:he.label},he.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:k,onChange:he=>{C(he.target.value);const Fe=parseInt(he.target.value,10);if(Fe>0){const Ke=E==="days"?Fe*86400:Fe*3600;S(Math.min(Ke,N))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:E,onChange:he=>{R(he.target.value);const Fe=parseInt(k,10);if(Fe>0){const Ke=he.target.value==="days"?Fe*86400:Fe*3600;S(Math.min(Ke,N))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),Ve&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",N>=86400?`${Math.floor(N/86400)} days`:`${Math.floor(N/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:te||M,disabled:te,onChange:he=>H(he.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',te&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:d.gateContent.intent})]}),(!!we.length||!!ve.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[ve.map(([he,Fe])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:he}),n.jsx("dd",{children:ig(he,Fe,d.contextLabels)})]},he)),we.map(([he,Fe])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:he}),n.jsx("dd",{children:String(Fe)})]},he))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Ht(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:Z?ae.can?n.jsxs(n.Fragment,{children:[le,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ne})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:ae.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),ae.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:le}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[ae.reason," ",ae.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),F>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[F===1?`An active grant on ${st} already has exactly these limits.`:`${F} active grants on ${st} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,gt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:ge})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:fe,disabled:L||!A.trim()||We||ze,children:L?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Me?"block":"none"},children:Be})]})]})}const wS={card:"💳",mail:"✉️"};function cg(e){return wS[e]??"🔧"}function ug(e){var a;const r=[e.profile];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(l)&&r.push(l)}return r}function Gh(e,r){const a=new Map;for(const i of e)for(const l of ug(i.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Kn(l),name:Yn(l,r),entries:[]},a.set(l,u)),u.entries.push(i)}return[...a.values()].sort((i,l)=>i.name.localeCompare(l.name))}function bS(e,r){if(!r)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(d=>Hi(d.manifest)&&!Vi(d,r)),i=e.filter(d=>!Hi(d.manifest)||Vi(d,r)),l=i.filter(d=>d.state==="error"),u=i.filter(d=>d.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function SS(e){const r=e==null?void 0:e.overrides;return!r||typeof r!="object"?!1:Object.values(r).some(a=>{var i;return typeof((i=a==null?void 0:a.read)==null?void 0:i.ageField)=="string"})}const kS=[0,7,30,90,365,3650];function Pi(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function NS(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function hc({manifest:e,integration:r,state:a,onStatusChange:i,onSuccess:l}){var Oe;const[u,d]=h.useState({}),[p,m]=h.useState(!1),[v,y]=h.useState(!1),[j,x]=h.useState({}),[S,N]=h.useState({}),[b,k]=h.useState(void 0),[C,E]=h.useState(!1),[R,A]=h.useState(null),[z,M]=h.useState(!1),[H,te]=h.useState(!1),[X,L]=h.useState(!1),[q,U]=h.useState(!1),[K,ce]=h.useState({}),[ee,Se]=h.useState(null),[Ae,Z]=h.useState(!1),[G,Y]=h.useState(null),[I,F]=h.useState(!1);h.useEffect(()=>{let J=!1;return P.getCredential(e.id).then(ge=>{var Ee;if(!(J||!ge.configured)){if(m(!0),y(!0),ge.fields){const $e={};for(const he of e.credentials.fields)ge.fields[he.key]!=null&&($e[he.key]=ge.fields[he.key]);x($e)}if(N(ge.secrets??{}),k(ge.updatedAt),e.oauth){const $e=((Ee=ge.fieldNames)==null?void 0:Ee.includes(e.oauth.tokenStorage))??!1;E($e),$e&&P.getOAuthHealth(e.id).then(he=>{J||A(he)})}}}).catch(()=>{}),()=>{J=!0}},[e.id,e.oauth]);const pe=SS(e.toolGating),fe=r?r.readAgeDays??null:void 0,we=Ae&&ee?ee.value:fe,ve=async J=>{Se({value:J}),Z(!0),Y(null);try{await P.setReadPolicy(e.id,J),l(J===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Pi(J).toLowerCase()}`),i()}catch(ge){Y(ge instanceof Error?ge.message:"Could not save")}finally{Z(!1),Se(null)}},Q=!!e.oauth||e.credentials.fields.some(J=>!J.optional),de=e.oauth?C:p,le=!Q||de,ne=a==="starting"?"starting":le?r!=null&&r.running?"running":!p&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&p&&!C?"needs-oauth":"unconfigured",Be=async()=>{if(e.credentials.fields.some(ge=>{var Ee;return(Ee=u[ge.key])==null?void 0:Ee.trim()})){M(!0);try{await P.setCredential(e.id,u),m(!0),d({}),e.oauth?l(`${e.name} credentials saved!`):(l(`${e.name} credentials saved — starting integration...`),await ze())}catch{l(`Failed to save ${e.name} credentials`)}finally{M(!1)}}},Me=()=>{const J={};for(const ge of e.credentials.fields){const Ee=u[ge.key];ge.type==="password"?Ee!=null&&Ee.trim()&&(J[ge.key]=Ee):Ee!=null&&Ee!==(j[ge.key]??"")&&(J[ge.key]=Ee)}return J},ae=Object.keys(Me()).length>0,We=async()=>{const J=Me();if(Object.keys(J).length!==0){M(!0);try{await P.setCredential(e.id,J),d({}),m(!0),e.oauth?l(`${e.name} credentials saved — now click Connect.`):(U(!1),l(`${e.name} credentials updated — restarting...`),await ze())}catch{l(`Failed to update ${e.name} credentials`)}finally{M(!1)}}},Re=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const J=setInterval(async()=>{var ge;try{const Ee=await P.getCredential(e.id);Ee.configured&&e.oauth&&((ge=Ee.fieldNames)!=null&&ge.includes(e.oauth.tokenStorage))&&(E(!0),U(!1),A(null),clearInterval(J),l(`${e.name} connected — starting integration...`),P.getOAuthHealth(e.id).then(A).catch(()=>{}),await ze())}catch{}},2e3);setTimeout(()=>clearInterval(J),12e4)},ze=async()=>{L(!0);try{const J=await P.activateIntegration(e.id);J.warning?l(J.warning):l(`${e.name} integration started with ${J.tools.length} tools`),i()}catch(J){l(`Failed to start ${e.name}: ${J instanceof Error?J.message:"Unknown error"}`)}finally{L(!1)}},Ve=async()=>{try{await P.removeMcpIntegration(e.id),l(`${e.name} integration removed`),i()}catch{l(`Failed to remove ${e.name}`)}},ct=cg(e.icon),tt=NS(r),Qe=ne==="running"?{c:"int-chip-ok",t:"Running"}:ne==="starting"?{c:"int-chip-idle",t:"Starting"}:tt.chip,De=e.oauth&&C&&(R==null?void 0:R.status)==="failed",gt=Q?De?{c:"int-chip-bad",t:"Auth failed"}:de?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},st=J=>J.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[n.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:ct}),n.jsxs("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:[e.name,dh(e,j)&&n.jsxs("span",{style:{fontWeight:400,color:"var(--text-muted)"},children:[" · ",dh(e,j)]}),fh(e,j)&&n.jsx("span",{className:"card-mode-note","data-testid":"integration-mode-note",children:fh(e,j)})]}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[ne!=="unconfigured"&&ne!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Qe.c}`,children:[n.jsx("span",{className:"int-dot"}),Qe.t]}),n.jsxs("span",{className:`int-chip ${gt.c}`,children:[n.jsx("span",{className:"int-dot"}),gt.t]}),Uj(e,j)&&n.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[n.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&C&&n.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:R!=null&&R.account?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:R.account})]}):n.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),De&&!q&&n.jsxs("div",{style:{marginTop:"0.7rem",border:"2px solid var(--border-strong)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(R==null?void 0:R.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):R!=null&&R.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:R.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[n.jsxs("button",{className:"btn btn-primary btn-sm",onClick:Re,children:["Reconnect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{d({...j}),U(!0)},children:"Edit credentials"})]})]}),n.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[n.jsx("summary",{children:"Details"}),n.jsxs("div",{className:"int-meta",children:[n.jsx("span",{className:"int-k",children:"What"}),n.jsx("span",{children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:ug(e).join(", ")})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((Oe=e.oauth.scopes)==null?void 0:Oe.join(", "))||"—"})]}),r&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[r.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(ne!=="running"||De)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>te(!H),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[n.jsx("span",{style:{transition:"transform 0.2s",transform:H?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),H&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((J,ge)=>n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[n.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:ge+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:J.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[st(J.description),J.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:J.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},ge))})]}),ne==="starting"&&n.jsxs("div",{className:"service-status",style:{color:"var(--text-primary)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"transparent",border:"1px dashed var(--text-primary)"}}),"Starting…"]}),q&&n.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(J=>{var ge;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:J.label}),J.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:K[J.key]?"text":"password",name:`${e.id}-${J.key}-credential`,autoComplete:"new-password",placeholder:(ge=S[J.key])!=null&&ge.preview?`Unchanged — ends in ${S[J.key].preview}`:v?"Unchanged — paste a new value to replace":J.placeholder,value:u[J.key]||"",onChange:Ee=>d($e=>({...$e,[J.key]:Ee.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>ce(Ee=>({...Ee,[J.key]:!Ee[J.key]})),children:K[J.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${J.key}-credential`,autoComplete:"off",placeholder:J.placeholder,value:u[J.key]||"",onChange:Ee=>d($e=>({...$e,[J.key]:Ee.target.value}))})]},J.key)}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:We,disabled:z||!ae,children:z?"Saving…":"Save"}),!ae&&!z&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:Re,children:["Connect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{U(!1),d({})},children:"Cancel"})]})]}),!q&&ne==="running"&&r&&n.jsxs(n.Fragment,{children:[(Object.keys(j).length>0||Object.keys(S).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(J=>{const ge=J.type==="password",Ee=S[J.key];return!ge&&j[J.key]==null||ge&&Ee==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:J.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[ge?Ee.preview??"set":j[J.key],ge&&b&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(b).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},J.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(ut,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{d({...j}),U(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),n.jsx("span",{style:{flex:1}}),n.jsx("button",{className:"btn btn-sm btn-outline-strong",onClick:Ve,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),pe&&we!==void 0&&!I&&n.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),n.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:we===null?"window from your mandate":Pi(we).toLowerCase()}),Ae&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),G&&n.jsx("span",{className:"msg-error",style:{fontSize:"0.78rem"},children:G})]}),n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>F(!0),children:"Edit"})]})}),pe&&we!==void 0&&I&&n.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),n.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>F(!1),children:"Done"})]}),n.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[kS.map(J=>{const ge=we===J;return n.jsx("button",{className:`btn btn-sm ${ge?"btn-primary":"btn-secondary"}`,"aria-pressed":ge,disabled:Ae,onClick:()=>ve(J),children:Pi(J)},J)}),n.jsx("button",{className:`btn btn-sm ${we===null?"btn-primary":"btn-ghost"}`,"aria-pressed":we===null,disabled:Ae,onClick:()=>ve(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Pi(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:G?n.jsx("span",{className:"msg-error",children:G}):Ae?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):we===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):we===0?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):n.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",we," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(ut,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),ne==="unconfigured"&&(()=>{const J=e.credentials.fields.every($e=>$e.optional),ge=e.credentials.fields.some($e=>!$e.optional),Ee=e.credentials.fields.some($e=>{var he;return(he=u[$e.key])==null?void 0:he.trim()});return n.jsxs(n.Fragment,{children:[v&&n.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",n.jsx("button",{onClick:()=>{m(!0),e.oauth&&E(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map($e=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:$e.label}),$e.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:K[$e.key]?"text":"password",name:`${e.id}-${$e.key}-credential`,autoComplete:"new-password",placeholder:$e.placeholder,value:u[$e.key]||"",onChange:he=>d(Fe=>({...Fe,[$e.key]:he.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>ce(he=>({...he,[$e.key]:!he[$e.key]})),children:K[$e.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${$e.key}-credential`,autoComplete:"off",placeholder:$e.placeholder,value:u[$e.key]||"",onChange:he=>d(Fe=>({...Fe,[$e.key]:he.target.value}))})]},$e.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Ee&&n.jsx("button",{className:"btn btn-primary",onClick:Be,disabled:z||ge&&!e.credentials.fields.filter($e=>!$e.optional).every($e=>{var he;return(he=u[$e.key])==null?void 0:he.trim()}),children:z?"Saving...":"Save & Encrypt"}),J&&!Ee&&n.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:X,children:X?"Starting...":`Activate ${e.name}`})]})]})})(),ne==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsxs("button",{className:"btn btn-primary",onClick:Re,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>m(!1),children:"Change Credentials"})]})]}),ne==="ready"&&!r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:X,children:X?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>m(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{m(!1),E(!1)},children:"Change Credentials"})]})]}),ne==="ready"&&r&&!r.running&&(tt.showStart?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[n.jsx("span",{className:"service-status-dot"}),"Not running"]}),r.error&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.8rem",marginBottom:"0.75rem"},children:r.error}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:X,children:X?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:Ve,children:"Disable"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),n.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong",onClick:Ve,children:"Disable"})})]}))]})}function qh({group:e,children:r}){return n.jsxs("div",{className:"area-group","data-testid":"integration-area","data-area":e.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(Br,{icon:e.icon}),n.jsx("b",{children:e.name})]}),r]})}function CS({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:cg(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function ES(){const{loading:e,mcpServerUp:r,manifestsError:a,entries:i,refresh:l}=ru(),u=nu(),[d,p]=h.useState(""),m=Mn(),v=h.useCallback(j=>{p(j),setTimeout(()=>p(""),5e3)},[]),y=bS(i,u);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),d&&n.jsx("div",{className:"alert alert-success",children:d}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):r===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):y.grouped?n.jsxs(n.Fragment,{children:[y.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),Gh(y.testSystems,m).map(j=>n.jsx(qh,{group:j,children:j.entries.map(x=>n.jsx(hc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},j.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(j=>n.jsx(hc,{manifest:j.manifest,integration:j.integration,state:j.state,onStatusChange:l,onSuccess:v},j.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(j=>n.jsx(CS,{entry:j},j.id))]})]}),i.length===0&&n.jsx(Kh,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[Gh(i,m).map(j=>n.jsx(qh,{group:j,children:j.entries.map(x=>n.jsx(hc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},j.shortId)),i.length===0&&n.jsx(Kh,{manifestsError:a})]})]})}function Kh({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function TS(){var U,K,ce;const{activeTeam:e,activeMembership:r,refreshGroups:a,user:i}=kt(),l=gn(),[u,d]=h.useState(null),[p,m]=h.useState(!1),[v,y]=h.useState(""),[j,x]=h.useState(""),[S,N]=h.useState(!1),[b,k]=h.useState(""),[C,E]=h.useState("");h.useEffect(()=>{fetch("/health").then(ee=>ee.json()).then(ee=>{typeof ee.spUrl=="string"&&E(ee.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!e){d(null);return}P.getGroupById(e.id).then(ee=>{const Se=ee.group??ee,Ae=ee.members??[],Z=ee.isAdmin??!1,G=Ae.map(Y=>{const I=Y.userId||Y.id||"",F=Y.role||(Z&&I===Se.createdBy?"admin":"member");return{id:I,name:Y.name||I.slice(0,8)||"Member",email:Y.email||"",domains:Y.domains||[],role:F,isAdmin:F==="admin"||Z&&I===Se.createdBy}});d({id:Se.id,name:Se.name,members:G})}).catch(()=>d(null))},[e==null?void 0:e.id]);const R=(u==null?void 0:u.members.filter(ee=>ee.isAdmin))??[],A=(e==null?void 0:e.isAdmin)===!0&&R.length<=1&&R.some(ee=>ee.id===(i==null?void 0:i.id)),z=(e==null?void 0:e.name)??"",M=b.trim()===z&&!p,H=()=>{k(""),N(!0)},te=()=>{N(!1),k("")},X=async()=>{if(!(!e||!M)){m(!0),y("");try{await P.leaveTeam(e.id),await a(),x("You have left the team."),d(null),te()}catch(ee){y(ee instanceof Error?ee.message:"Failed to leave team")}finally{m(!1)}}},L=e&&C?`${C}/dashboard/groups/${e.id}`:void 0,q=C?`${C}/dashboard/groups`:void 0;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&n.jsx("div",{className:"error-message",children:v}),j&&n.jsx("div",{className:"alert alert-success",children:j}),e?n.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"card-title",children:e.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((U=u==null?void 0:u.members)==null?void 0:U.length)??0," ",(((K=u==null?void 0:u.members)==null?void 0:K.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(ce=u==null?void 0:u.members)==null?void 0:ce.map(ee=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:ee.name.split(" ").map(Se=>Se[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:ee.name}),n.jsx("div",{className:"member-email",children:ee.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:ee.role})]},ee.id)),n.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[L&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:L,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),n.jsx("span",{title:A?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:n.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:H,disabled:p||A,children:"Leave team"})})]})]}):n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[n.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>l("/onboarding"),children:"Join or create a team"}),q&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:q,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),S&&e&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:te,children:n.jsxs("div",{className:"card",onClick:ee=>ee.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[n.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",z,"?"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",n.jsx("strong",{children:"personal"})," mandates are not affected."]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",n.jsx("code",{children:z})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:b,onChange:ee=>k(ee.target.value),placeholder:z,disabled:p,autoFocus:!0})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:te,disabled:p,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:X,disabled:!M,children:p?"Leaving...":"Leave team"})]})]})})]})}function mu({areas:e,selected:r,onSelect:a,totalCount:i}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":r===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:i})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":r===l.shortId,onClick:()=>a(r===l.shortId?null:l.shortId),children:[n.jsx(Br,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const vr=e=>e.replace(/@.*$/,"").split("/").pop()??e,Yh=e=>e.split("@")[1]??"";function Jh(e){var a;const r=e.profile?[vr(e.profile)]:[];for(const i of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=i==null?void 0:i.profile;l&&!r.includes(vr(l))&&r.push(vr(l))}return r}function AS(e,r){const a=new Map;for(const i of e){const l=vr(i.id);if(!r.has(l))continue;const u=a.get(l);(!u||Yh(i.id).localeCompare(Yh(u.id),void 0,{numeric:!0})>0)&&a.set(l,i)}return a}function IS(e,r,a,i){var p;const l=new Set([...r.flatMap(m=>Jh(m)),...i.map(m=>vr(m.profile))]),u=AS(e,l),d=[];for(const m of r){const v=Jh(m);for(const[y,j]of v.entries()){const x=u.get(j);x&&d.push({key:y===0?`connector:${m.id}`:`connector:${m.id}:${j}`,name:v.length>1?`${m.name} — ${x.name??j}`:m.name,description:m.description||x.description,profile:x,kind:"connector",ready:((p=a.find(S=>S.id===m.id))==null?void 0:p.running)===!0,setupId:m.id,...m.intentHint&&y===0?{intentHint:m.intentHint}:{}})}}for(const m of i){const v=u.get(vr(m.profile));v&&d.push({key:`builtin:${m.id}`,name:m.name,description:m.description||v.description,profile:v,kind:"builtin",ready:m.available,unavailableReason:m.available?void 0:"Available only while simulation mode is on.",...m.intentHint?{intentHint:m.intentHint}:{}})}return d}function RS(e,r,a){if(r)return e.find(i=>vr(i.profile.id)===vr(r)&&i.ready&&a(i))}function dg({icon:e,className:r}){return n.jsx(Br,{icon:e,className:r})}function $S({onDismiss:e,preselectProfileId:r}){const a=gn(),{group:i,groupId:l,domain:u,user:d}=kt(),[p,m]=h.useState([]),[v,y]=h.useState([]),[j,x]=h.useState([]),[S,N]=h.useState([]),[b,k]=h.useState(!0),[C,E]=h.useState({});h.useEffect(()=>{Promise.all([P.listProfiles().catch(()=>[]),P.getIntegrationManifests().then(X=>X.manifests??[]).catch(()=>[]),P.getMcpHealth().catch(()=>null)]).then(async([X,L,q])=>{if(m(X),y(L),x((q==null?void 0:q.integrations)??[]),N((q==null?void 0:q.builtins)??[]),l){const U=await Promise.all(X.map(ce=>P.getTeamProfileConfig(l,ce.id).catch(()=>null))),K={};X.forEach((ce,ee)=>{const Se=U[ee];Se&&(K[ce.id]=Se)}),E(K)}}).finally(()=>k(!1))},[l]);const R=IS(p,v,j,S),A=X=>{const L=C[X.id];return og({isPersonal:!!(i!=null&&i.isPersonal),configLoaded:!b,grantors:L?Vm(L):void 0,userId:d==null?void 0:d.id,profileName:Ht(X.id),teamName:i==null?void 0:i.name})},z=X=>X in C,M=(X,L)=>{if(!l){console.error("No active group when creating authorization");return}const q=z(X);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:X,groupId:l,groupName:(i==null?void 0:i.name)??null,domain:u,isTeam:q,isPersonal:!!(i!=null&&i.isPersonal),...L?{intentHint:L}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},H=(X,L)=>{l&&M(X,L)},te=h.useRef(!1);return h.useEffect(()=>{if(b||!r||te.current)return;const X=RS(R,r,L=>A(L.profile).can);X&&(te.current=!0,H(X.profile.id,X.intentHint))},[b,r]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
|
|
80
|
-
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
81
|
-
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
82
|
-
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
83
|
-
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
84
|
-
`}),b?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):R.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(ut,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:R.map(X=>{const L=X.profile,q=z(L.id),U=A(L),K=!X.ready||!U.can,{icon:ce}=xr(L.id,{name:L.name});return n.jsxs("div",{className:"card",style:K?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(dg,{icon:ce,className:"profile-chip-icon"}),X.name]}),q?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):i!=null&&i.isPersonal?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:X.description}),U.can?X.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>H(L.id,X.intentHint),children:"Give a mandate"}):X.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:X.unavailableReason})]}):n.jsxs(ut,{to:`/integrations?setup=${X.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",X.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[U.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:U.fix})]})]})]},X.key)})})]})}function PS({domain:e,attested:r}){const a=r===!0?"domain-attested":r===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const fg=200;function _S(e,r,a=fg){return e.length<a?!0:e.some(i=>!Ur(i.timestamp,r))}function hg(e,r){return e.filter(a=>a.authorizationId===r).sort((a,i)=>i.timestamp-a.timestamp)}function LS(e){var m,v;const r={},{bounds:a,profile:i,authorizationId:l,nowMs:u}=e;if(!a)return r;const p=hg(e.receipts,l).filter(y=>Ur(y.timestamp,u)).reduce((y,j)=>{var x,S,N,b;return!y||j.timestamp>y.timestamp||j.timestamp===y.timestamp&&(((S=(x=j.cumulativeState)==null?void 0:x.daily)==null?void 0:S.count)??0)>(((b=(N=y.cumulativeState)==null?void 0:N.daily)==null?void 0:b.count)??0)?j:y},null);if(p){const y=pp(p,a,i,"daily"),j=(m=p.cumulativeState)==null?void 0:m.daily;return y&&j&&(r[y.key]=`${y.isAmount?j.amount:j.count} used today`),r}if(!e.coversToday)return r;for(const[y,j]of Object.entries(((v=i==null?void 0:i.boundsSchema)==null?void 0:v.fields)??{})){const x=j.boundType;y in a&&x&&(x.kind==="cumulative_sum"||x.kind==="cumulative_count")&&x.window==="daily"&&(r[y]="0 used today")}return r}const MS=15e3;let fs=null;function FS(){const e=Date.now();if(!fs||e-fs.at>MS){const r={at:e,p:P.getMyReceiptsPage({limit:fg}).then(a=>({receipts:a.receipts,coversToday:_S(a.receipts,Date.now())}))};r.p.catch(()=>{fs===r&&(fs=null)}),fs=r}return fs.p}function mg(){const[e,r]=h.useState({state:"loading"});return h.useEffect(()=>{let a=!0;return FS().then(i=>{a&&r({state:"ok",...i})},()=>{a&&r({state:"failed"})}),()=>{a=!1}},[]),e}function js({icon:e,title:r,text:a,children:i}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:r}),a&&n.jsx("div",{className:"empty-state-text",children:a}),i]})}function OS(e){const r=Math.floor(e/86400);if(r>=1)return`${r} day${r===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const i=Math.ceil(e/60);return`${i} minute${i===1?"":"s"}`}const zS=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function BS({item:e,onClose:r,onSuccess:a}){var R;const{user:i,activeDomain:l,groupId:u}=kt(),[d,p]=h.useState(null);h.useEffect(()=>{let A=!1;return P.getProfile(e.profile_id).then(z=>{var M;A||p(((M=z==null?void 0:z.ttl)==null?void 0:M.max)??null)}).catch(()=>{}),()=>{A=!0}},[e.profile_id]);const m=e.remaining_seconds??0,v=zS.filter(A=>A.seconds>m&&(d===null||A.seconds<=d)),y=((R=v[0])==null?void 0:R.seconds)??2592e3,[j,x]=h.useState(y);h.useEffect(()=>{var A;if(d!==null&&j>d){const z=(A=v[v.length-1])==null?void 0:A.seconds;z&&x(z)}},[d]);const[S,N]=h.useState(!1),[b,k]=h.useState(""),C=Object.entries(e.frame).filter(([A])=>A!=="profile"&&A!=="path"),E=async()=>{var A;if(i){N(!0),k("");try{const z=e.authorization_id,M=await P.getGateContent(z);if(!M)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const H=await P.getProfile(e.profile_id),te=e.frame,X=M.context??{},L=e.attested_domains[0]||l||"owner",q=await zi(te,H),U=await rg(X,H),[K,ce]=await Promise.all([ao(M.gateContent.intent),ao(JSON.stringify({profile:e.profile_id,path:e.path,domain:L}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const ee=(((A=e.deferred_commitment_domains)==null?void 0:A.length)??0)>0?"review":"automatic",Se=await sg(H),Ae=await P.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:Se,supported_versions:["0.7"],bounds:te,bounds_hash:q,scope_hash:U,domain:L,did:i.did,mandate_owners:[{did:i.did}],gate_content_hashes:{intent:K},execution_context_hash:ce,group_id:u,commitment_mode:ee,ttl:j});await P.pushGateContent(ag(Ae,{boundsHash:q,contextHash:U,context:X,path:e.path,gateContent:M.gateContent})),a()}catch(z){k(z instanceof Error?z.message:"Extension failed")}finally{N(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:A=>A.target===A.currentTarget&&r(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:r,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Ht(e.profile_id)," / ",e.path]}),C.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:C.map(([A,z])=>`${A}=${z}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),m>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",OS(m),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(A=>n.jsx("button",{className:`btn ${j===A.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(A.seconds),style:{minWidth:"3.5rem"},children:A.label},A.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),b&&n.jsx("div",{className:"error-message",children:b})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:r,disabled:S,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:E,disabled:S,children:S?"Extending...":"Extend"})]})]})})}function Qh(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Xh(e){return e.split("@")[1]??""}function DS(e,r){return Xh(e).localeCompare(Xh(r),void 0,{numeric:!0})>0}function pg(e,r){const a=Qh(e);let i;for(const l of r)Qh(l.id)===a&&(!i||DS(l.id,i.id))&&(i=l);return i}function gg(e,r){var i;if(!r)return{};const a={};for(const l of r.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(i=r.fields[l])==null?void 0:i.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function yg(e,r){return gg(e,r.boundsSchema)}function vg(e,r){return gg(e,r.scopeSchema)}function US(e,r,a){return[...e].sort((i,l)=>{if(a){if(i.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&i.authorization_id!==a)return 1}const u=Wi(i,r),d=Wi(l,r),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[d]?p[u]-p[d]:new Date(l.created_at).getTime()-new Date(i.created_at).getTime()})}function WS(e,r){const a=(r==null?void 0:r.keyedApprovers)??(r==null?void 0:r.approvers)??[];return e.length===0||a.length===0?!1:e.length!==a.length||e.some(i=>!a.includes(i))||a.some(i=>!e.includes(i))}function HS({item:e,newerProfile:r,area:a,revokedSet:i,expandedHash:l,gateCache:u,gateLoading:d,copiedHash:p,revokingHash:m,copyingHash:v,profileConfigCache:y,mode:j,group:x,ownerLabel:S,isAdmin:N,onExpand:b,onCopyHash:k,onCopy:C,onRevoke:E,onExtend:R,archivedSet:A,archivingHash:z,onArchive:M,highlightHash:H,needsReapprovalSet:te,manifests:X=[]}){var Oe;const L=tu(e,{revokedSet:i}),q=L==="active"&&((te==null?void 0:te.has(e.authorization_id))??!1),U=Jm(e,{revokedSet:i,archivedSet:A}),K=!S&&!!M&&Ym(L),ce=l===e.authorization_id,ee=u[e.authorization_id],Se=L==="active"||L==="pending"||L==="expired",Ae=Object.entries(e.frame).filter(([J])=>J!=="profile"&&J!=="path"),Z=Ns(e.profile_id),G=new Map(ip(e.frame,Z,"limits").map(J=>[J.key,J])),Y=J=>{var ge;return((ge=G.get(J))==null?void 0:ge.label)??J},I=(J,ge)=>{var Ee;return((Ee=G.get(J))==null?void 0:Ee.value)??String(ge)},F=y.get(e.profile_id)??null,pe=(((Oe=F==null?void 0:F.approvers)==null?void 0:Oe.length)??0)>0,fe=new Map;if(F!=null&&F.caps&&j==="team")for(const[J,ge]of Ae){const Ee=F.caps[J];typeof Ee=="number"&&Number(ge)>Ee&&fe.set(J,{authorized:Number(ge),cap:Ee})}const we=fe.size>0,ve=j==="team"&&WS(e.approvers_frozen??[],F),Q=Array.from(fe.entries()).map(([J,ge])=>`${J}: ${ge.authorized} (cap ${ge.cap})`).join(", "),de=Array.from(fe.entries()).map(([J,ge])=>`${J}: ${ge.authorized} → ${ge.cap}`).join(", "),le=we?pe?fe.size===1?`Above team cap: ${Q} — actions require approval`:`Above team cap (${fe.size}): ${Q} — actions require approval`:fe.size===1?`Reduced by hard cap: ${de}`:`Reduced by hard cap (${fe.size}): ${de}`:"",ne=we?pe?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,Be=xr(e.profile_id),Me=Be.name,ae=r?n.jsxs("p",{className:"ob-quiet","data-testid":"mandate-upgrade-hint",children:[n.jsxs("b",{children:[Me,"@",r.version," available"]}),r.whatsNew?n.jsxs(n.Fragment,{children:[" — ",r.whatsNew]}):null," ","This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]}):null,We=H!=null&&e.authorization_id===H,Re=e.deferred_commitment_domains.length>0?eo.title:to.title,Ve=Ae.slice(0,3).map(([J,ge])=>`${Y(J)} ${I(J,ge)}`),ct=Ae.length-Ve.length,tt=[Re,...Ve,...ct>0?[`+${ct} more`]:[]].join(" · "),Qe=e.created_at?`since ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:null,De=L==="expired"?Dj(e,L):null,gt=su(),st=h.useRef(null);return h.useLayoutEffect(()=>{var ge,Ee;if(!ce)return;const J=(ge=window.matchMedia)==null?void 0:ge.call(window,"(prefers-reduced-motion: reduce)").matches;(Ee=st.current)==null||Ee.scrollIntoView({block:"start",behavior:J?"auto":"smooth"})},[ce]),n.jsxs("div",{ref:st,className:`ob-card mandate-card${ce?" is-open":""}${We?" card-highlight":""}`,"data-testid":"mandate-card",children:[n.jsxs("button",{type:"button",className:"ob-head","aria-expanded":ce,onClick:()=>b(e),children:[n.jsx(Fr,{tag:"Mandate",profileId:e.profile_id,parts:[a,Qe,n.jsxs("span",{className:"ob-st",children:[L.charAt(0).toUpperCase()+L.slice(1),De?` ${new Date(De.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`:""]},"st"),q?n.jsx("span",{className:"ob-st",title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",children:"Needs re-approval"},"re"):null,Be.testSetup?"Test setup":null]}),n.jsx("span",{className:"ob-title",children:e.title||Me}),!ce&&n.jsx("span",{className:"ob-one",children:tt})]}),ae,S&&n.jsxs("p",{className:"ob-quiet",children:["Owner: ",n.jsx("b",{children:S})]}),(e.required_domains.length>1||e.missing_domains.length>0)&&n.jsx("div",{className:"ob-badges",children:e.required_domains.map(J=>n.jsx(PS,{domain:J,attested:e.attested_domains.includes(J)},J))}),we&&n.jsx("p",{className:"ob-quiet ob-bold",title:ne,"data-testid":"mandate-cap-note",children:le}),ve&&n.jsx("p",{className:"ob-quiet",children:n.jsx("button",{type:"button",className:"ob-link",onClick:()=>C(e),disabled:v===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:v===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})}),ce&&n.jsxs("div",{ref:gt,className:"ob-open","data-testid":"mandate-open",children:[n.jsxs("section",{className:"ob-tile","data-testid":"mandate-signed",children:[n.jsxs("div",{className:"ob-tile-h",children:[n.jsx(rp,{}),"You signed this"]}),n.jsxs("div",{className:"ob-part",children:[n.jsxs("div",{className:"ob-lbl",children:["Intent — your words",e.created_at?`, signed ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:""]}),d===e.authorization_id?n.jsx("p",{className:"ob-quiet",children:"Loading gate content..."}):ee?n.jsx("p",{className:"ob-intent","data-testid":"mandate-intent",children:ee.gateContent.intent}):n.jsx("p",{className:"ob-quiet",children:"Gate content not available."})]}),n.jsxs("dl",{className:"ob-kv ob-part",children:[n.jsx("dt",{children:"Commitment"}),n.jsx("dd",{children:Re}),(e.earliest_expiry||L==="revoked")&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Valid"}),n.jsx("dd",{children:L==="revoked"?"revoked":L==="expired"?`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} — expired`:`until ${new Date(e.earliest_expiry).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}, or until you revoke it`})]}),Ae.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Limits"}),n.jsx("dd",{children:n.jsx(VS,{item:e,boundsEntries:Ae,limitLines:G,limitLabel:Y,limitValue:I,aboveCapByKey:fe,hasApprovers:pe,profile:Z})})]}),(ee==null?void 0:ee.context)&&Object.keys(ee.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Scope"}),n.jsx("dd",{children:Object.entries(ee.context).map(([J,ge])=>n.jsx("div",{title:String(ge),children:ig(J,ge,ee.contextLabels)},J))})]}),n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:j==="team"&&x?`${x.name} (team)`:"Personal"})]})]}),!S&&n.jsx(GS,{item:e,manifests:X}),n.jsx(Jn,{title:"Technical details",summary:e.created_at?`created ${new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:void 0,testId:"mandate-technical",children:n.jsxs("dl",{className:"ob-kv",children:[e.created_at&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Created"}),n.jsx("dd",{children:new Date(e.created_at).toLocaleString()})]}),n.jsx("dt",{children:"Mandate id"}),n.jsxs("dd",{className:"ob-mono",children:[e.authorization_id," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>k(e.authorization_id),children:p===e.authorization_id?"copied":"copy"})]}),n.jsx("dt",{children:"Profile"}),n.jsx("dd",{className:"ob-mono",children:e.profile_id})]})}),n.jsxs("div",{className:"ob-btns",children:[!S&&(L==="active"||L==="pending")&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e,{asEdit:!0}),disabled:v===e.authorization_id,title:q?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:q?"Re-approve":"Edit"}),!S&&Se&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>R(e),children:"Extend"}),!S&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>C(e),disabled:v===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:v===e.authorization_id?"Copying…":"Copy"}),S&&N&&L!=="revoked"?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id,S,Me),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):!S&&(L==="active"||L==="pending")?n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>E(e.authorization_id),disabled:m===e.authorization_id,children:m===e.authorization_id?"Revoking…":"Revoke"}):null,K&&n.jsx("button",{type:"button",className:"ob-btn",onClick:()=>M(e.authorization_id,!U),disabled:z===e.authorization_id,title:U?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:z===e.authorization_id?U?"Unarchiving…":"Archiving…":U?"Unarchive":"Archive"})]})]})]},e.authorization_id)}function VS({item:e,boundsEntries:r,limitLines:a,limitLabel:i,limitValue:l,aboveCapByKey:u,hasApprovers:d,profile:p}){const m=mg(),v=m.state==="ok"?LS({receipts:m.receipts,coversToday:m.coversToday,authorizationId:e.authorization_id,bounds:e.frame,profile:p,nowMs:Date.now()}):{};return n.jsx("dl",{className:"ob-kv ob-sub","data-testid":"mandate-limits",children:r.map(([y,j])=>{var S;const x=u.get(y);return n.jsxs(h.Fragment,{children:[n.jsx("dt",{title:(S=a.get(y))==null?void 0:S.hint,children:i(y)}),n.jsx("dd",{children:x?d?n.jsxs("span",{title:`Team cap on ${y} is ${x.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${x.authorized}.`,children:[l(y,j)," ",n.jsxs("span",{className:"ob-quiet-inline",children:["↑ approval at ",x.cap]})]}):n.jsxs("span",{title:`Team cap on ${y} is ${x.cap} with no approvers configured (hard cap). Authorized for ${x.authorized}; effective ${x.cap}.`,children:[n.jsx("s",{children:l(y,j)})," → ",x.cap]}):l(y,j)}),n.jsx("dd",{className:"ob-use",children:v[y]??""})]},y)})})}function GS({item:e,manifests:r}){const a=mg(),i=a.state==="ok"?hg(a.receipts,e.authorization_id):[],l=i.filter(d=>Ur(d.timestamp,Date.now())).length,u=a.state==="loading"?"loading…":a.state==="failed"?"could not load":i.length===0?"none in the latest tickets":`${i.length} recent${l>0?` · ${l} today`:""}`;return n.jsxs(Jn,{title:"Tickets under this mandate",summary:u,testId:"mandate-tickets",children:[n.jsx("p",{className:"ob-lbl",children:"From the latest tickets signed on this account."}),a.state==="failed"&&n.jsx("p",{children:"Tickets could not be loaded. Try again shortly."}),a.state==="ok"&&i.length===0&&n.jsx("p",{children:"No action has run under this mandate in the latest tickets."}),i.slice(0,5).map(d=>n.jsxs("p",{className:"ob-ticket-row",children:[n.jsx(ut,{to:"/tickets",className:"ob-link-strong",children:vs(d,r)}),n.jsxs("span",{className:"ob-quiet-inline",children:[" · ",ma(d.timestamp,Date.now())]})]},d.id)),i.length>0&&n.jsx("p",{children:n.jsx(ut,{to:"/tickets",className:"ob-link-strong",children:"All tickets ›"})})]})}function qS(){const[e,r]=h.useState([]),[a,i]=h.useState(!0),[l,u]=h.useState([]),[d,p]=h.useState(!1),[m,v]=h.useState(new Map),[y,j]=h.useState("mine"),[x,S]=h.useState("active"),[N,b]=h.useState(null),[k,C]=h.useState(null),[E,R]=ks(),[A,z]=h.useState(()=>E.get("new")==="1"),[M]=h.useState(()=>E.get("profile")),[H,te]=h.useState(()=>E.get("highlight")),[X,L]=h.useState(null),[q,U]=h.useState({}),[K,ce]=h.useState(null),[ee,Se]=h.useState(null),[Ae,Z]=h.useState(null),[G,Y]=h.useState(new Set),[I,F]=h.useState(null),[pe,fe]=h.useState(new Set),[we,ve]=h.useState(null),[Q,de]=h.useState(null),[le,ne]=h.useState(new Set),Be=gn(),{group:Me,groupId:ae,domain:We,mode:Re,activeTeam:ze}=kt(),Ve=(ze==null?void 0:ze.isAdmin)===!0,[ct,tt]=h.useState(()=>new Map),[Qe,De]=h.useState([]);h.useEffect(()=>{P.getLabelManifests().then(De).catch(()=>{})},[]);const gt=h.useCallback(()=>{i(!0),P.getMyAttestations().then(r).catch(()=>{}).finally(()=>i(!1))},[]),st=h.useCallback(()=>{P.getArchivedMandates().then(re=>fe(new Set(re))).catch(()=>{})},[]);h.useEffect(()=>{st()},[st]);const Oe=h.useCallback(()=>{P.getEnrichedAuthorizations().then(re=>ne(new Set(re.filter(xe=>xe.needsReapproval).map(xe=>xe.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{Oe()},[Oe]);const J=async(re,xe)=>{ve(re);try{const B=await P.setMandateArchived(re,xe);fe(new Set(B)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(B){alert(B instanceof Error?B.message:"Failed to update archive")}finally{ve(null)}},ge=h.useCallback(()=>{ae&&(p(!0),P.listTeamAuthorizations(ae).then(u).catch(()=>{}).finally(()=>p(!1)))},[ae]);He("attestation-changed",()=>{gt(),Ve&&ae&&ge(),Oe()}),h.useEffect(()=>{if(!H)return;E.get("highlight")&&(E.delete("highlight"),R(E,{replace:!0}));const re=window.setTimeout(()=>te(null),3e3);return()=>window.clearTimeout(re)},[]),Wt(gt,3e5),h.useEffect(()=>{y==="team"&&Ve&&ae&&l.length===0&&!d&&ge()},[y,Ve,ae,l.length,d,ge]),h.useEffect(()=>{let re=!1;return P.listProfiles().then(xe=>{if(re)return;const B=rt=>rt.replace(/@.*$/,"").split("/").pop()??rt,oe=rt=>rt.split("@")[1]??"",Te=new Map;for(const rt of xe){const ot=B(rt.id),Fn=Te.get(ot);(!Fn||oe(rt.id).localeCompare(oe(Fn.id),void 0,{numeric:!0})>0)&&Te.set(ot,rt)}v(Te)}).catch(()=>{}),()=>{re=!0}},[]);const Ee=h.useCallback(re=>{const xe=ot=>ot.replace(/@.*$/,"").split("/").pop()??ot,B=ot=>ot.split("@")[1]??"",oe=m.get(xe(re));if(!oe)return;const Te=B(re),rt=B(oe.id);if(!(!Te||!rt))return rt.localeCompare(Te,void 0,{numeric:!0})>0?oe:void 0},[m]),$e=h.useCallback(re=>Yn(re,[...m.values()]),[m]);h.useEffect(()=>{if(Re!=="team"||!ae)return;const re=y==="mine"?e:l;if(re.length===0)return;const xe=[...new Set(re.map(B=>B.profile_id))].filter(B=>!ct.has(B));if(xe.length!==0){tt(B=>{const oe=new Map(B);for(const Te of xe)oe.set(Te,null);return oe});for(const B of xe)Promise.all([P.getTeamProfileConfig(ae,B),P.getApproversPubkeys(ae,B).catch(()=>null)]).then(([oe,Te])=>{const rt=oe&&Te?{...oe,keyedApprovers:Te.map(ot=>ot.userId)}:oe;tt(ot=>new Map(ot).set(B,rt))}).catch(()=>{})}},[e,l,y,ae,Re,ct]);const he=async re=>{if(X===re.authorization_id){L(null);return}L(re.authorization_id);const xe=re.authorization_id;if(!(xe in q)){ce(re.authorization_id);try{const B=await P.getGateContent(xe);U(oe=>({...oe,[xe]:B}))}catch{U(B=>({...B,[xe]:null}))}finally{ce(null)}}},Fe=re=>{navigator.clipboard.writeText(re).then(()=>{Z(re),setTimeout(()=>Z(null),2e3)})},Ke=async(re,xe)=>{var B;if(!ae){alert("No active group; cannot copy mandate.");return}de(re.authorization_id);try{const oe=re.authorization_id;let Te=q[oe]??null;oe in q||(Te=await P.getGateContent(oe),U(Tn=>({...Tn,[oe]:Te})));const rt=Object.fromEntries(Object.entries(re.frame).filter(([Tn])=>Tn!=="profile"&&Tn!=="path")),ot=(Te==null?void 0:Te.context)??{},Fn=((B=Te==null?void 0:Te.gateContent)==null?void 0:B.intent)??"",tn=re.deferred_commitment_domains.length>0?"review":"automatic",nn=re.attested_domains[0]||We||"owner",qt=Date.parse(re.created_at),wr=re.earliest_expiry?Date.parse(re.earliest_expiry):NaN,vo=Number.isFinite(qt)&&Number.isFinite(wr)&&wr>qt?Math.round((wr-qt)/1e3):void 0;let xa=re.profile_id,ja=rt,En=ot,Cs;const wa=await P.listProfiles(),Wr=pg(re.profile_id,wa);if(Wr&&Wr.id!==re.profile_id){const Tn=await P.getProfile(Wr.id);xa=Wr.id,ja=yg(rt,Tn),En=vg(ot,Tn),Cs=re.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:xa,groupId:ae,groupName:(Me==null?void 0:Me.name)??null,domain:nn,isPersonal:!!(Me!=null&&Me.isPersonal),upgradedFromProfileId:Cs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:ja,context:En,gateContent:{intent:Fn},templateMode:tn,templateTtl:vo})),xe!=null&&xe.asEdit?sessionStorage.setItem("agentEditReplaces",re.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Be("/mandates/new/intent")}catch(oe){alert(oe instanceof Error?oe.message:"Failed to copy mandate")}finally{de(null)}},Xe=async(re,xe,B)=>{const oe=xe&&B?`Revoke ${xe}'s ${B} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(oe)){F(re);try{await P.revokeAttestation(re),Y(Te=>new Set(Te).add(re)),P.resyncGates().catch(()=>{}),xe&&ae&&ge()}catch(Te){alert(Te instanceof Error?Te.message:"Failed to revoke mandate")}finally{F(null)}}},at=y==="mine"?e:l,yt=y==="mine"?a:d,Nt=y==="mine"?{revokedSet:G,archivedSet:pe}:{revokedSet:G},qe=re=>Wi(re,Nt),W={active:0,pending:0,expired:0,revoked:0,archived:0};for(const re of at)W[qe(re)]+=1;const ye=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Ne=(()=>{const re=new Map;for(const xe of at){if(qe(xe)!==x)continue;const B=Nn(xe.profile_id),oe=re.get(B);oe?oe.count+=1:re.set(B,{shortId:B,icon:Kn(xe.profile_id),name:$e(xe.profile_id),count:1})}return[...re.values()].sort((xe,B)=>xe.name.localeCompare(B.name))})(),Ze=Ne.reduce((re,xe)=>re+xe.count,0),dt=US(at.filter(re=>{if(qe(re)!==x||N!==null&&Nn(re.profile_id)!==N)return!1;if(k!==null){const xe=re.deferred_commitment_domains.length>0;if(k==="review"&&!xe||k==="auto"&&xe)return!1}return!0}),Nt,H),Ge=h.useMemo(()=>{const re=new Map;for(const xe of dt){const B=Nn(xe.profile_id);let oe=re.get(B);oe||(oe={shortId:B,icon:Kn(xe.profile_id),name:$e(xe.profile_id),items:[]},re.set(B,oe)),oe.items.push(xe)}return[...re.values()].sort((xe,B)=>B.items.length-xe.items.length||xe.name.localeCompare(B.name))},[dt,$e]),be=h.useCallback(re=>[...new Set(Qe.filter(xe=>{var B;return xe.profile===re||Object.values(((B=xe.toolGating)==null?void 0:B.overrides)??{}).some(oe=>(oe==null?void 0:oe.profile)===re)}).map(xe=>xe.name))],[Qe]),it={revokedSet:G,expandedHash:X,gateCache:q,gateLoading:K,copiedHash:Ae,revokingHash:I,copyingHash:Q,profileConfigCache:ct,mode:Re,activeDomain:We,group:Me,groupId:ae,onExpand:he,onCopyHash:Fe,onCopy:Ke,onRevoke:Xe,onExtend:Se,highlightHash:H,manifests:Qe},bt={...it,archivedSet:pe,archivingHash:we,onArchive:J,needsReapprovalSet:le};return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>z(!0),children:"+ New mandate"})]}),A&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{z(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),R(E,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:re=>re.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{z(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),R(E,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),n.jsx($S,{onDismiss:()=>z(!1),preselectProfileId:M})]})]})}),Ve&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{j("mine"),S("active"),b(null),C(null),L(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{j("team"),S("active"),b(null),C(null),L(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:ye.map(re=>n.jsxs("button",{className:`nav-tab${x===re?" active":""}`,onClick:()=>{S(re),b(null),C(null)},children:[re.charAt(0).toUpperCase()+re.slice(1)," (",W[re],")"]},re))}),Ze>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(mu,{areas:Ne,selected:N,onSelect:b,totalCount:Ze}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(re=>{const xe=k===re;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${re}`,"aria-selected":xe,onClick:()=>C(xe?null:re),children:re==="auto"?"Automatic":"Review"},re)})})]}),yt&&at.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):dt.length===0?n.jsx(js,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:Ge.map(re=>n.jsxs("section",{"data-testid":"mandate-area","data-area":re.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(Br,{icon:re.icon}),n.jsx("b",{children:re.name}),n.jsxs("span",{className:"meta",children:[re.items.length," mandate",re.items.length===1?"":"s",be(re.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",be(re.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:re.items.map(xe=>{const B=y==="team"?xe:null,oe=B!=null&&B.owner?B.owner.name??B.owner.email??B.owner.userId:void 0;return n.jsx(HS,{item:xe,newerProfile:Ee(xe.profile_id),area:re.name,ownerLabel:oe,isAdmin:Ve,...y==="mine"?bt:it},xe.authorization_id)})})]},re.shortId))}),ee&&n.jsx(BS,{item:ee,onClose:()=>Se(null),onSuccess:()=>{Se(null),gt()}})]})}function xg(e){const r=e.approved?e.proposalArgs:e.sentArgs;return yb(e.tool,r??null,e.manifests)??e.label}function KS(e){if(e.offDevice)return{level:"off-device"};const r=e.sentArgs??e.proposalArgs,a=r?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:r?YS(e.boundContent,r):null,argsCheck:a}:r?{level:"recorded",content:r,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function YS(e,r){const a={};for(const[i,l]of Object.entries(r))(typeof e=="string"?l===e:i in e)||(a[i]=l);return Object.keys(a).length>0?a:null}function jg(e,r,a){return ap(e,r).map(i=>{var l;return{...i,inTicket:QS(i.value,(l=r==null?void 0:r.executionMapping)==null?void 0:l[i.key],a)}})}function JS(e,r){if(String(e)===String(r))return!0;if(typeof e=="boolean"||typeof r=="boolean"||e===""||r===""||e===null||r===null)return!1;const a=Number(e),i=Number(r);return Number.isFinite(a)&&Number.isFinite(i)&&a===i}function QS(e,r,a){return!r||!a||e===void 0||e===null?!1:(typeof r=="string"?[{field:r}]:Array.isArray(r)?r:[r]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:JS(e,u)})}function mc(e){return e==null?"—":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):Vw(e)}function XS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Zh(e,r){return Object.entries(e).filter(([a,i])=>!XS(i)&&!(r&&a in r&&mc(r[a])===mc(i))).map(([a,i])=>({key:a,label:Ot(a),value:mc(i)}))}function ZS(e,r){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Zh(a,r)};const i=e.text.trim();if(i.startsWith("{"))try{const l=JSON.parse(i);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Zh(l,r)}}catch{}return{kind:"text",text:e.text}}const em=new Map;function ek(e){let r=em.get(e);return r||(r=P.getProposal(e).catch(()=>null),em.set(e,r)),r}let hs=null;function tk(e){if(!hs||e*1e3>hs.fetchedAtMs){const r={fetchedAtMs:Date.now(),map:P.getTicketHeadlines().catch(()=>(hs===r&&(hs=null),{}))};hs=r}return hs.map}function nk({proposal:e,tool:r,manifests:a,label:i}){const l=va(e);return n.jsx(n.Fragment,{children:xg({tool:r,manifests:a,label:i,approved:!0,proposalArgs:l.toolArgs})})}function rk({ticketId:e,timestamp:r,proposalId:a,tool:i,manifests:l,label:u}){const[d,p]=h.useState(null),[m,v]=h.useState(null);return h.useEffect(()=>{let y=!0;return p(null),v(null),a?ek(a).then(j=>{y&&p(j)}):tk(r).then(j=>{y&&v(j[e]??null)}),()=>{y=!1}},[a,e,r]),a?d?n.jsx(nk,{proposal:d,tool:i,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:xg({tool:i,manifests:l,label:u,approved:!1,sentArgs:m})})}function ps({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"preview-table-wrap",children:n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(r=>n.jsx("th",{children:r.label},r.key))})}),n.jsx("tbody",{children:e.rows.map((r,a)=>n.jsx("tr",{children:r.cells.map((i,l)=>n.jsx("td",{className:i.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:i.valueTitle,children:i.value},l))},a))})]})}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}const sk=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function ak(e,r){return typeof r!="string"?!1:/^data:image\//i.test(r)?!0:sk.test(e)?/^https?:\/\//.test(r):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(r)}function Lr(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function tm({row:e,which:r}){const a=Ns(e.profileRef),i=ip(e.value,a,r);return i.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:i.map(l=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function ik({row:e}){const r=Ns(e.profileRef),a=(r==null?void 0:r.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(r==null?void 0:r.name)??Ht(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function wg({row:e,altText:r}){if(e.kind==="list"||e.kind==="object"){const a=_p(e.value);if(a&&"table"in a)return n.jsx(ps,{table:a.table});if(a)return n.jsx(n.Fragment,{children:a.text})}switch(e.kind){case"profile":return n.jsx(ik,{row:e});case"profile-limits":return n.jsx(tm,{row:e,which:"limits"});case"profile-scope":return n.jsx(tm,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Lr(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,i)=>n.jsx("li",{children:Lr(a)},i))}):n.jsx(n.Fragment,{children:Lr(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Lr(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Lr(e.value)});default:return ak(e.key,e.value)?n.jsx("img",{src:e.value,alt:r??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Lr(e.value)})}}function Bi({args:e,display:r,heading:a="Details",requestRefArg:i}){const l=ap(e,r);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(d=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:d.hint,children:d.key===i?"Replying to":d.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:d.key===i?n.jsx("span",{"data-testid":"request-ref",title:Lr(d.value),children:"the message shown under Request"}):n.jsx(wg,{row:d,altText:u})})]},d.key))})]})}function ok(e){const r=h.useMemo(()=>typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof Blob>"u"?Ow(e):URL.createObjectURL(new Blob([Bw(e)],{type:e.contentType})),[e.contentBase64,e.contentType]);return h.useEffect(()=>()=>{r.startsWith("blob:")&&URL.revokeObjectURL(r)},[r]),r}function bg({doc:e,systemName:r,heading:a,sourceLine:i,trailingNote:l}){const u=ok(e),d=zw(e.pages),p=r?`Rendered by ${r}`:"Rendered",m=n.jsxs(n.Fragment,{children:[p," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),d&&n.jsx("div",{className:"preview-note",children:d}),i&&n.jsx("div",{className:"preview-note",children:i}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ip(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??m})]})]})]})}const lk="_attachmentsSealed";function ck(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.filename=="string"&&typeof r.contentType=="string"&&typeof r.sha256=="string"&&typeof r.bytes=="number"}function uk(e){if(e===null||typeof e!="object")return!1;const r=e;return typeof r.placeholder=="string"&&typeof r.connector=="string"&&typeof r.kind=="string"&&typeof r.id=="string"&&typeof r.value=="string"}function pu(e){const r={attachments:[],inserts:[]};if(!e)return r;const a=e[lk];if(a===null||typeof a!="object")return r;const i=a,l=Array.isArray(i.attachments)?i.attachments.filter(ck):[],u=Array.isArray(i.inserts)?i.inserts.filter(uk):[];return{attachments:l,inserts:u}}function dk(e){return!Number.isFinite(e)||e<0?"—":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function fk(e){return pu(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function Sg(e,r,a,i){var u,d,p;const l=(p=(d=(u=e==null?void 0:e.find(m=>m.id===r))==null?void 0:u.documents)==null?void 0:d[a])==null?void 0:p.label;if(l)return l.replace(/\{id\}/g,i)}function hk(e,r){return!e||!r||r==="loading"?null:r.status==="ok"?{key:"attachment-same-file",label:`same file as ${e}`,ok:!0,valueText:"",limitText:""}:r.status==="changed"?{key:"attachment-same-file",label:"attachment changed since it was sealed",ok:!1,valueText:"",limitText:""}:null}function mk({a:e,manifests:r,preview:a}){const i=jr(e.connector,r),l=Sg(r,e.connector,e.kind,e.id),u=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"src-tag-value src-tag-system-cell",children:["from ",i]}),l?n.jsxs(n.Fragment,{children:[" — ",l]}):null]});return a&&a!=="loading"&&a.status==="ok"?n.jsx(bg,{doc:{filename:a.filename,contentType:a.contentType,contentBase64:a.contentBase64,sha256:a.sha256},heading:"Attachment",sourceLine:u,trailingNote:null}):n.jsxs("div",{className:"document-preview-box","data-testid":"attachment-sealed",children:[n.jsx("h4",{children:"Attachment"}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),n.jsx("div",{className:"preview-note",children:dk(e.bytes)}),n.jsx("div",{className:"preview-note",children:u}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Ip(e.sha256)})]}),!a||a==="loading"?n.jsx("div",{className:"preview-note",children:"Loading preview…"}):a.status==="changed"?n.jsx("p",{className:"preview-note","data-testid":"attachment-changed",style:{color:"var(--check-failed)",fontWeight:700},children:"✕ changed since it was sealed"}):n.jsx("div",{className:"preview-note",children:"Preview not available."})]})]})}function pk({i:e,manifests:r}){const a=jr(e.connector,r);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function kg({attachments:e,inserts:r,manifests:a,fetchPreview:i,onChecks:l}){const[u,d]=h.useState({});return h.useEffect(()=>{if(!i)return;let p=!0;for(const m of e)d(v=>v[m.sha256]?v:{...v,[m.sha256]:"loading"}),i(m.sha256).then(v=>{p&&d(y=>({...y,[m.sha256]:v}))}).catch(()=>{p&&d(v=>({...v,[m.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{p=!1}},[e.map(p=>p.sha256).join(","),i]),h.useEffect(()=>{if(!l)return;const p=e.map(m=>hk(Sg(a,m.connector,m.kind,m.id),u[m.sha256])).filter(m=>m!==null);l(p)},[e,a,u,l]),e.length===0&&r.length===0?null:n.jsxs(n.Fragment,{children:[e.map(p=>n.jsx(mk,{a:p,manifests:a,preview:u[p.sha256]},`${p.connector}:${p.kind}:${p.id}`)),r.map(p=>n.jsx(pk,{i:p,manifests:a},`${p.placeholder}:${p.connector}:${p.kind}:${p.id}`))]})}let _i=null;function gk(){return _i||(_i=P.getToolDisplay().catch(()=>(_i=null,{}))),_i}function Ng({args:e,display:r,executionContext:a,sealed:i}){const l=jg(e,r,a);return l.length===0?null:n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:l.map(u=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:i?"is-sealed":void 0,children:[n.jsx(wg,{row:u}),u.inTicket&&n.jsx("span",{className:"ob-quiet-inline",title:"This value is also in the signed ticket",children:" · also in the ticket"})]})]},u.key))})}function nm({content:e,display:r,executionContext:a,sealed:i}){return typeof e=="string"?n.jsx("p",{className:`ob-text${i?" is-sealed":""}`,children:e}):n.jsx(Ng,{args:e,display:r,executionContext:a,sealed:i})}function rm({check:e}){return e==="match"?n.jsx("p",{className:"ob-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match what this gateway executed"})]}):n.jsx("p",{className:"ob-quiet",children:"Could not be checked against this gateway's execution record."})}function yk({view:e,display:r,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-quiet",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsxs("p",{className:"ob-quiet",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("section",{className:"ob-tile ob-sealed is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{className:"ob-tile-h",children:[n.jsx(rp,{}),"Sealed in the ticket"]}),n.jsx(nm,{content:e.bound,display:r,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"Does not match the fingerprint in the signed ticket — this local copy was changed"})]}),e.extras&&jg(e.extras,r,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ob-lbl ob-gap",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(Ng,{args:e.extras,display:r,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(rm,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ob-sent","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsx("h4",{className:"ob-sent-h",children:"What was sent"}),n.jsx("p",{className:"ob-lbl ob-after-h",children:"Recorded by this gateway — not sealed in the ticket"}),n.jsx(nm,{content:e.content,display:r,executionContext:a,sealed:!1}),n.jsx(rm,{check:e.check})]})}const sm=5;function vk({result:e,systemName:r,sent:a}){const i=ZS(e,a),[l,u]=h.useState(!1),d=e.ok?i.kind==="rows"?`what ${r} answered · ${i.rows.length} value${i.rows.length===1?"":"s"}`:`what ${r} answered`:"the action failed";return n.jsxs(Jn,{title:"Result",summary:d,testId:"ticket-result",attrs:{"data-ok":e.ok?"true":"false"},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway from ",r]}),!e.ok&&n.jsx("p",{className:"ob-check",children:n.jsx("b",{children:"The action failed."})}),i.kind==="rows"?n.jsx("dl",{className:"ob-kv ticket-sent-fields",children:(l?i.rows:i.rows.slice(0,sm)).map(p=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:p.label}),n.jsx("dd",{className:"is-system",children:p.value})]},p.key))}):n.jsx("p",{className:"ob-text is-system",children:i.text}),i.kind==="rows"&&i.rows.length>sm&&n.jsx("button",{type:"button",className:"ob-link",onClick:()=>u(p=>!p),children:l?"Show less":`Show all ${i.rows.length}`}),e.truncated&&n.jsx("p",{className:"ob-quiet",children:"Shortened to fit what this device keeps."})]})}function am(e){var a;const r=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const i of r)if(i&&typeof i=="object"&&!Array.isArray(i))return i;return null}function Cg({receipt:e,manifests:r}){var N;const[a,i]=h.useState(void 0),[l,u]=h.useState(null),[d,p]=h.useState(void 0),m=!!(e.contentHash&&e.contentBinding);h.useEffect(()=>{let b=!0;return gk().then(k=>{b&&p(k[e.action])}),()=>{b=!1}},[e.action]),h.useEffect(()=>{let b=!0;return i(void 0),u(null),(async()=>{let k;try{k=await P.getArchivedReceipt(e.id)}catch{b&&i(null);return}let C=null;const E=k==null?void 0:k.entry.boundContent;if(E!==void 0&&m)try{C=await Dp(e.contentBinding.kind,E)===e.contentHash}catch{C=!1}b&&(u(C),i(k))})(),()=>{b=!1}},[e.id,e.contentHash,e.contentBinding,m]);const v=h.useCallback(b=>P.getReceiptAttachmentPreview(e.id,b),[e.id]);if(a===void 0)return n.jsx("div",{className:"ob-sent ob-quiet","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const y=(N=a==null?void 0:a.entry.proposal)==null?void 0:N.toolArgs,j=KS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:y&&typeof y=="object"&&!Array.isArray(y)?y:void 0,hasHashToCheck:m,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=jr(Ln(e.action).integrationId,r),S=pu((a?am(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(yk,{view:j,display:d,executionContext:e.executionContext}),n.jsx(kg,{attachments:S.attachments,inserts:S.inserts,manifests:r,fetchPreview:v}),(a==null?void 0:a.result)&&n.jsx(vk,{result:a.result,systemName:x,sent:am(a)})]})}const im=500;function Di(e){return e.length>im?`${e.slice(0,im)}…`:e}function om(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function xk(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function io(e,r,a){var i;switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${r}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${r}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${Di(e.message)}`:"Preview not available."};case"refused":return{heading:`Refused by ${r}`,note:e.message?Di(e.message):`${r} refused to answer.`};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${Di(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e){const p=rb(a??{},e.reads,e.display,{readAt:e.readAt});return{heading:`What will be ${((i=e.display)==null?void 0:i.verb)??"created"} in ${r}`,note:bk(p)?`Values marked from the system were read by the gateway, not by the AI — read at ${xk(e.readAt)}.`:"",creation:p}}const l=Lp(e.body,{fields:e.fields}),u={heading:`From ${r}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:l},d=e.version;if(d&&(u.versionNote=`You approve ${d.field} ${d.approved}; if it changes, ${r} refuses it.`,d.stale)){const p=Yw(e.body,d.currentBody,{fields:e.fields,excludeKey:d.field});u.stale={heading:`A newer ${d.field} exists (${d.current})`,approvedLabel:`${om(d.field)} ${d.approved}`,currentLabel:`${om(d.field)} ${d.current}`,...p.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:p.approved,currentRendered:p.current}}}return u}}}function jk(e,r){if(e.state!=="failed")return null;const a=e.detail?Di(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${r} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${r}`,note:`${r} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function wk(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function bk(e){return e.sections.length>0?!0:e.rows.some(r=>r.kind==="identity"?!!r.identity.name:r.kind==="compare"?r.lines.some(a=>a.now!=="—"):r.kind==="table"?r.table.rows.some(a=>a.cells.some(i=>!i.sealed&&i.value!=="—"&&i.value!=="")):!1)}function lm({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function Sk({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(r=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:r.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:r.valueTitle,children:r.value})]},r.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((r,a)=>n.jsx("div",{style:r.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:r.kind==="add"?{fontWeight:600}:void 0,children:r.text||" "},a))}):e.table?n.jsx(ps,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((r,a)=>{var i;return n.jsx("div",{title:(i=e.lineTitles)==null?void 0:i[a],children:r},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function Oc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(r=>r.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(lm,{row:r}),n.jsx(ps,{table:r.table})]},r.key):n.jsxs(h.Fragment,{children:[n.jsx(lm,{row:r}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(Sk,{row:r})})]},r.key))})}function pc({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(Oc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(Oc,{rows:e.moreFields})]})]})}function kk({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.filter(r=>!r.table).map(r=>{var a,i;return n.jsxs("span",{children:[" · ",r.label," ",r.value??((a=r.lines)==null?void 0:a.join(", "))??((i=r.sublist)==null?void 0:i.map(l=>l.value).join(", "))]},r.key)})})]})}function Nk({view:e,systemName:r}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(a=>a.kind==="table"||a.kind==="compare"?null:n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:a.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:a.kind==="identity"?n.jsx(kk,{identity:a.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:a.valueTitle,children:a.value})})]},a.key))}),e.rows.map(a=>a.kind==="compare"&&n.jsxs("table",{className:"compare-table","data-testid":"compare-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),n.jsxs("th",{children:["Now (from ",r??"the system",")"]}),n.jsx("th",{children:"New"})]})}),n.jsx("tbody",{children:a.lines.map(i=>n.jsxs("tr",{children:[n.jsx("td",{className:"compare-label",children:i.label}),n.jsx("td",{className:"compare-now",children:i.now}),n.jsx("td",{className:"compare-new",children:i.next})]},i.key))})]},a.key)),e.rows.flatMap(a=>a.kind==="identity"?a.identity.context.filter(i=>i.table).map(i=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:i.label}),n.jsx(ps,{table:i.table})]},`${a.key}.${i.key}`)):[]),e.rows.filter(a=>a.kind==="table").map(a=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:a.label}),n.jsx(ps,{table:a.table})]},a.key)),e.sections.map((a,i)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(bg,{doc:a.document,systemName:r}):n.jsxs(n.Fragment,{children:[n.jsxs("h5",{children:[a.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),a.table&&n.jsx(ps,{table:a.table}),a.body&&n.jsx(Oc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},i))]})}function Eg({view:e}){return e.systemBoxes.length===0?null:n.jsx(n.Fragment,{children:e.systemBoxes.map(r=>n.jsxs("div",{className:"system-box","data-testid":"system-box",children:[n.jsx("div",{className:"system-box-heading",children:r.heading}),n.jsx("dl",{children:r.rows.map(a=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:a.label}),n.jsx("dd",{children:a.value})]},a.key))}),n.jsx("p",{className:"system-box-note",children:"Shown for this decision only. It is asked again when this is saved; that answer is stored."})]},r.key))})}function Ck(e,r){if(!(r!=null&&r.length)||e.status!=="ok"||!("body"in e)||!e.body.structured)return e;const a=Object.fromEntries(Object.entries(e.body.structured).filter(([i])=>!r.includes(i)));return{...e,body:{...e.body,structured:a},...e.fields?{fields:e.fields.filter(i=>!r.includes(i))}:{}}}function Tg({resp:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l=!0,omitKeys:u,hideNote:d=!1}){const p=Ck(e,u),m=io(p,r,a??void 0),v=p.status==="ok"?m.stale?"stale":"ok":p.status;return v==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:m.note}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:`preview-box preview-box-${v}`,"data-testid":"approval-preview","data-preview-status":v,children:[n.jsxs("h4",{children:[m.heading,m.creation&&(i?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),m.creation&&n.jsx(Nk,{view:m.creation,systemName:r}),m.rendered&&n.jsx(pc,{rendered:m.rendered}),m.note&&!d&&n.jsx("p",{className:"preview-note",children:m.note}),m.versionNote&&!m.stale&&n.jsx("p",{className:"preview-note",children:m.versionNote}),m.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:m.stale.heading}),m.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:m.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:m.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(pc,{rendered:m.stale.approvedRendered})}),n.jsx("dt",{children:m.stale.currentLabel}),n.jsx("dd",{children:n.jsx(pc,{rendered:m.stale.currentRendered})})]})]})]}),l&&m.creation&&n.jsx(Eg,{view:m.creation})]})}function Ek({proposalId:e,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d,onTone:p,onData:m}){const[v,y]=h.useState(null),[j,x]=h.useState(!1);return h.useEffect(()=>{let S=!0;return y(null),x(!1),P.getProposalPreview(e).then(N=>{S&&y(N)}).catch(()=>{S&&x(!0)}),()=>{S=!1}},[e]),h.useEffect(()=>{if(j){p==null||p("unavailable"),m==null||m({status:"unavailable",reason:"connector_error"});return}if(!v){m==null||m(null);return}const S=io(v,r,a??void 0);p==null||p(v.status==="ok"?S.stale?"stale":"ok":v.status),m==null||m(v)},[v,j,r,p,m]),j?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):v?n.jsx(Tg,{resp:v,systemName:r,toolArgs:a,sealed:i,systemBoxes:l,omitKeys:u,hideNote:d}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",r,"…"]})}const gc=6;function oo(e){if(!e)return;const r=Date.parse(e);return Number.isNaN(r)?e:new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Tk(e){if(!e)return{first:""};const r=e.split(`
|
|
85
|
-
`);return r.length<=gc?{first:e}:{first:r.slice(0,gc).join(`
|
|
86
|
-
`),more:r.slice(gc).join(`
|
|
87
|
-
`)}}const Ak="Linked by the AI",Ik="linked automatically — this action already carried a reference to it";function Ag(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:r,more:a}=Tk(e.body),i=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,oo(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:Ak,...e.implicit?{implicitNote:Ik}:{},metaLine:i.join(" · "),title:e.title,bodyFirst:r,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:oo(l.at)}))}}const ua="Read by the gateway — same customer, not matched to this request";function Rk(e){const r=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${r})`}function $k(e){var l;const r=!!e.aiWritten,a=r?"Activity":e.type??e.kind??"Entry";let i;if(r){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?oo(new Date(e.aiWritten.at).toISOString()):void 0;i=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else i=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:oo(e.at),title:e.title,body:e.body,attribution:i,aiWritten:r}}function Ig(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:ua,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:ua,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:ua,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const r=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>$k(l)),a=e.matches.map(Rk),i=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return r.length===0?{state:"empty",label:ua,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:i}:{state:"ok",label:ua,note:"",matchNotes:a,items:r,unreachableNote:i}}function Rg({req:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:e.implicitNote}),e.metaLine&&n.jsx("p",{className:"au10-req-meta",children:e.metaLine}),e.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:e.title})}),e.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:e.bodyFirst}),e.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:e.bodyMore})]}),e.attribution&&n.jsx("p",{className:"au10-req-attrib",children:e.attribution}),e.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",e.chain.length,")"]}),e.chain.map((r,a)=>n.jsxs("div",{className:"au10-chain-item",children:[(r.author||r.at)&&n.jsxs("p",{className:"au10-req-meta",children:[r.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:r.author})]}):null,r.author&&r.at?" · ":"",r.at]}),r.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:r.title})}),r.body&&n.jsx("p",{className:"au10-req-quote",children:r.body}),r.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",r.author,", not checked"]})]},a))]})]})}function $g({hist:e}){return e.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:e.note}):n.jsxs(n.Fragment,{children:[e.matchNotes.map((r,a)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:r},a)),n.jsx("ul",{className:"au10-hist-list",children:e.items.map((r,a)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[r.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),r.headLabel]}),n.jsx("span",{children:r.at})]}),r.title&&n.jsx("div",{className:"au10-hist-title",children:r.title}),r.body&&n.jsx("div",{className:"au10-hist-body",children:r.body}),n.jsx("p",{className:"au10-hist-attrib",children:r.attribution})]},a))}),e.unreachableNote&&n.jsx("p",{className:"preview-note",children:e.unreachableNote})]})}function Pg({resp:e}){const r=Ag(e.request),a=Ig(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("h4",{children:["Request",r.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:r.tag})]}),n.jsx(Rg,{req:r})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),n.jsx($g,{hist:a})]})]})}const cm=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function Pk(e){if(e.state!=="ok")return e.note;const r=e.items.length,a=e.items[0];return`${r} ${r===1?"entry":"entries"}${a!=null&&a.at?` · latest ${a.at}`:""}`}function _k(e){return e.state!=="ok"?e.note??"":e.title??e.metaLine??""}function Lk({resp:e}){const r=Ag(e.request),a=Ig(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("details",{className:"av3-fold",style:{order:12},"data-testid":"au10-request","data-request-status":r.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Request"}),n.jsx("span",{className:"one",children:_k(r)}),cm]}),n.jsxs("div",{className:"av3-fold-body",children:[r.tag&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-ai",style:{marginLeft:0},children:r.tag})}),n.jsx(Rg,{req:r})]})]}),n.jsxs("details",{className:"av3-fold",style:{order:13},"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"History"}),n.jsx("span",{className:"one",children:Pk(a)}),cm]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{className:"au10-req-meta",children:n.jsx("span",{className:"src-tag src-tag-system",style:{marginLeft:0},children:a.label})}),n.jsx($g,{hist:a})]})]})]})}function Mk({proposalId:e,onData:r,layout:a="boxes"}){const[i,l]=h.useState(null),[u,d]=h.useState(!1);return h.useEffect(()=>{let p=!0;return l(null),d(!1),P.getProposalRequestContext(e).then(m=>{p&&l(m)}).catch(()=>{p&&d(!0)}),()=>{p=!1}},[e]),h.useEffect(()=>{r==null||r(u?null:i)},[i,u,r]),u||!i?null:a==="folds"?n.jsx(Lk,{resp:i}):n.jsx(Pg,{resp:i})}function Fk(e,r,a){const i=Object.entries(e??{});if(i.length===0)return{entry:void 0,otherCount:0};const u=i.find(([,p])=>p.by===r)??(a?i.find(([p])=>p===`domain:${a}`):void 0),d=u?i.length-1:i.length;return{entry:u==null?void 0:u[1],otherCount:d}}function Ok(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function zk(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function Bk(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function _g({proposalId:e,tool:r,manifests:a}){const{user:i,domain:l}=kt(),[u,d]=h.useState(null),[p,m]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let z=!0;return d(null),m(null),y(!1),Promise.all([P.getShownSnapshot(e),P.getProposal(e)]).then(([M,H])=>{z&&(d(M),m(H))}).catch(()=>{z&&y(!0)}),()=>{z=!1}},[e]),v||!u||!p)return null;const j=u.status==="off_device",{entry:x,otherCount:S}=Fk(p.shownHashes,(i==null?void 0:i.id)??"",l),N=Ok({offDevice:j,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),b=zk(S);if(j)return n.jsx(Jn,{title:"What you saw",summary:"only on the approving gateway",testId:"au10-shown",attrs:{"data-shown-status":"off-device"},children:n.jsx("p",{className:"ob-quiet",children:"Only on the approving gateway — this device has no local copy."})});const{snapshot:k}=u,{integrationId:C}=Ln(r),E=jr(C,a),R=Bk(k.readAt),A=N==="verified"?`read ${R} · verified`:N==="mismatch"?`read ${R} · does not match what was approved`:`read ${R}`;return n.jsxs(Jn,{title:"What you saw",summary:A,testId:"au10-shown",attrs:{"data-shown-status":N},children:[n.jsxs("p",{className:"ob-lbl",children:["Read by the gateway at ",R,", kept on this device — not read again now."]}),n.jsx(Tg,{resp:k.preview,systemName:E,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(Pg,{resp:k.requestContext}),N==="verified"&&n.jsx("p",{className:"ob-check",children:"✓ Matches the fingerprint recorded with your approval."}),N==="mismatch"&&n.jsxs("p",{className:"ob-check ob-check-x",children:["✕ ",n.jsx("b",{children:"This copy differs from the fingerprint recorded with your approval."})]}),N==="unchecked"&&n.jsx("p",{className:"ob-quiet",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),b&&n.jsx("p",{className:"ob-quiet","data-testid":"au10-shown-others",children:b})]})}function Dk({receipt:e,manifests:r,localAuth:a,localUnavailable:i,signature:l,grantTitle:u,ownerLabel:d,spUrl:p,formatDate:m,onOpenComplete:v,isNew:y=!1,defaultOpen:j=!1}){const x=Ns(e.profileId),S=C0(e,x),N=E0(a==null?void 0:a.context,x),b=T0(e,(a==null?void 0:a.bounds)??e.limits,x),k=a==null?void 0:a.intent,C=xr(e.profileId).testSetup||ho(e.action),[E,R]=h.useState(!1),[A,z]=h.useState(j),M=Date.now(),H=Mn(),te=Dr(e.profileId,H),X=po(e.action,r),L=su(),q=u||I0(e.profileId),U=ma(e.timestamp,M),K=iu(e.id);return n.jsxs("div",{className:`ob-card ticket-obj-card${y?" is-new":""}${A?" is-open":""}`,"data-new":y?"true":"false","data-testid":"ticket-card",children:[n.jsxs("button",{type:"button",className:"ob-head ticket-obj-head","aria-expanded":A,onClick:()=>z(ce=>!ce),children:[n.jsx(Fr,{tag:"Ticket",profileId:e.profileId,className:"obj-line",parts:[te,`via ${X}`,U,n.jsx("span",{className:"ob-st",children:qi(e)?"Approved":"Automatic"},"st"),C?"Test setup":null,y?n.jsx("span",{className:"ob-st","aria-label":"new since your last visit",children:"New"},"new"):null]}),n.jsxs("span",{className:"ob-title receipt-what",children:[te," · ",n.jsx("span",{"data-testid":"ticket-headline",children:n.jsx(rk,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:r,label:vs(e,r)})})]}),l==="valid"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="valid-legacy"&&n.jsxs("span",{className:"ob-check",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:[n.jsx("span",{"aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:["Signature verified on this device · issued before protocol 0.7 · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l==="invalid"&&n.jsxs("span",{className:"ob-check ob-check-x",title:"The stored ticket does not match what was signed.",children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("b",{children:["Signature check failed · ticket ",n.jsx("span",{className:"ob-mono",children:K})]})]}),l!=="valid"&&l!=="valid-legacy"&&l!=="invalid"&&n.jsxs("span",{className:"ob-one",children:["Ticket ",n.jsx("span",{className:"ob-mono",children:K})]}),S&&n.jsx("span",{className:"ob-one receipt-scope",children:S})]}),A&&n.jsxs("div",{ref:L,className:"ob-open",children:[n.jsx(Cg,{receipt:e,manifests:r}),e.proposalId&&n.jsx(_g,{proposalId:e.proposalId,tool:e.action,manifests:r}),n.jsxs(Jn,{title:"Mandate",summary:[q,b].filter(Boolean).join(" · "),testId:"ticket-mandate",children:[n.jsxs("p",{className:"ob-lbl",children:[k||N?"Name, allowed values and intent: from this device.":"Name: from this device.",b?" Use: sealed in the ticket.":""]}),n.jsxs("dl",{className:"ob-kv receipt-rows",children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:q}),d&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Owner"}),n.jsx("dd",{children:d})]}),N&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Allowed"}),n.jsx("dd",{children:N})]}),b&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Used"}),n.jsx("dd",{className:"receipt-num",children:b})]}),n.jsx("dt",{children:"Intent"}),n.jsx("dd",{className:"ob-plain",children:k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${E?"":" intent-clamped"}`,children:k})," ",n.jsx("button",{type:"button",className:"ob-link",onClick:()=>R(!E),children:E?"Show less":"Show full intent"})]}):n.jsx("span",{className:"receipt-absent",children:i?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]})]}),n.jsxs(Jn,{title:"Technical details",summary:`ticket ${K} · ${m(e.timestamp)}`,testId:"ticket-technical",children:[n.jsx("p",{className:"ob-lbl",children:"Read from the signed ticket."}),n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Ticket"}),n.jsx("dd",{className:"ob-mono",children:e.id}),n.jsx("dt",{children:"Issued"}),n.jsx("dd",{className:"receipt-when",children:m(e.timestamp)}),n.jsx("dt",{children:"Action"}),n.jsx("dd",{className:"ob-mono",children:e.action})]}),n.jsxs("details",{className:"ob-raw receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"ob-mono receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([ce,ee])=>`${ce}=${ee}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]}),n.jsxs("div",{className:"ob-btns receipt-foot",children:[n.jsx("button",{type:"button",className:"ob-btn receipt-evidence-link",onClick:v,children:"Complete ticket"}),p&&n.jsxs("a",{className:"ob-btn receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",title:"Redacted, shareable",children:["Public link ↗",n.jsx("span",{className:"ob-btn-q",children:" · redacted"})]})]})]})]})}function Uk({receipt:e,onClose:r}){const[a,i]=h.useState(null),[l,u]=h.useState(null),[d,p]=h.useState(null),[m,v]=h.useState(!0),[y,j]=h.useState(!1);h.useEffect(()=>{let k=!1;return v(!0),P.getArchivedReceipt(e.id).then(C=>{k||(i(C),u(C?"local":"authority-server"),p((C==null?void 0:C.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||v(!1)}),()=>{k=!0}},[e.id]);const x=a?a.entry:{receipt:e},S=JSON.stringify(x,null,2);function N(){const k=URL.createObjectURL(new Blob([S],{type:"application/json"})),C=document.createElement("a");C.href=k,C.download=`suveren-ticket-${e.id.slice(0,8)}.json`,C.click(),URL.revokeObjectURL(k)}async function b(){try{await navigator.clipboard.writeText(S),j(!0),setTimeout(()=>j(!1),2e3)}catch{j(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:k=>k.target===k.currentTarget&&r(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:r,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[d==="valid"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),d==="valid-legacy"&&n.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued. Issued before protocol 0.7 — checked with that version's format."}),d==="invalid"&&n.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:m?"Loading…":l==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),n.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:N,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:b,children:y?"Copied":"Copy"})]})]})})}function Wk(e){return new Date(e*1e3).toLocaleString()}function Hk(e,r){if(r==="all")return!0;const a=r==="1d"?1:r==="7d"?7:30,i=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=i}function Vk(e,r,a){const i=r.trim().toLowerCase();return i?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(i)):!0}function um(e,r){const a=new Map(e.map(i=>[i.id,i]));for(const i of r)a.set(i.id,i);return[...a.values()].sort((i,l)=>l.timestamp-i.timestamp)}function Gk(){const{activeTeam:e,groupId:r}=kt(),a=(e==null?void 0:e.isAdmin)===!0,[i,l]=h.useState("mine"),[u,d]=ks(),p=$0(u.get("filter")),m=W=>{const ye=new URLSearchParams(u);W==="all"?ye.delete("filter"):ye.set("filter",W),d(ye,{replace:!0})},v=ep(u.get("area")),y=W=>{const ye=new URLSearchParams(u);W===null?ye.delete("area"):ye.set("area",W),d(ye,{replace:!0})},j=Mn(),[x,S]=h.useState(null),N=h.useRef(!1),[b,k]=h.useState([]),[C,E]=h.useState([]),[R,A]=h.useState(""),[z,M]=h.useState(!0),[H,te]=h.useState({}),[X,L]=h.useState(new Set),[q,U]=h.useState(""),[K,ce]=h.useState(new Set),[ee,Se]=h.useState("all"),[Ae,Z]=h.useState(!1),[G,Y]=h.useState(!1),[I,F]=h.useState(null),[pe,fe]=h.useState({}),[we,ve]=h.useState(!1),[Q,de]=h.useState({}),[le,ne]=h.useState({}),[Be,Me]=h.useState(null),[ae,We]=h.useState(null),[Re,ze]=h.useState(!1),[Ve,ct]=h.useState(!1),tt=h.useRef(""),Qe=h.useCallback(W=>i==="team"&&a&&r?P.listTeamReceiptsPage(r,{before:W,limit:200}):P.getMyReceiptsPage({before:W,limit:200}),[i,a,r]),De=h.useCallback(()=>{const W=i==="team"?`team:${r}`:"mine",ye=tt.current!==W;tt.current=W,M(!0),ct(!1),Qe().then(Ne=>{k(Ze=>ye?Ne.receipts:um(Ze,Ne.receipts)),We(Ze=>ye?Ne.nextBefore:Ze??Ne.nextBefore)}).catch(()=>{ye&&k([]),ct(!0)}).finally(()=>M(!1))},[Qe,i,r]),gt=h.useCallback(()=>{!ae||Re||(ze(!0),ct(!1),Qe(ae).then(W=>{k(ye=>um(ye,W.receipts)),We(W.nextBefore)}).catch(()=>ct(!0)).finally(()=>ze(!1)))},[ae,Re,Qe]);Wt(De,12e4);const st=h.useCallback(()=>{De(),x!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markTicketsSeen(Date.now()).catch(()=>{}))},[De,x]);He("ticket-recorded",st),h.useEffect(()=>{z||N.current||(N.current=!0,P.getLastSeenTicketsAt().then(W=>(S(W),P.markTicketsSeen(Date.now()))).catch(()=>S(Number.POSITIVE_INFINITY)))},[z]),h.useEffect(()=>{P.getLabelManifests().then(E).catch(()=>{}),fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&A(W.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{P.getLocalAuthorizations().then(({authorizations:W,signatures:ye})=>{fe(W),de(ye),ve(!1)}).catch(()=>{fe({}),de({}),ve(!0)}),P.getMyAttestations().then(W=>{const ye={};for(const Ne of W)Ne.authorization_id&&Ne.title&&(ye[Ne.authorization_id]=Ne.title);ne(ye)}).catch(()=>{})},[]),h.useEffect(()=>{i!=="team"||Object.keys(H).length>0||P.listUsers().then(W=>{const ye={};for(const Ne of W)ye[Ne.id]={name:Ne.name,email:Ne.email};te(ye)}).catch(()=>{})},[i,H]);const Oe=h.useMemo(()=>{const W=new Set;for(const ye of b)W.add(ye.action);return[...W].sort()},[b]),J=h.useMemo(()=>{if(i!=="team")return[];const W=new Set;for(const ye of b)ye.userId&&W.add(ye.userId);return[...W].map(ye=>{var Ne;return{id:ye,label:(Ne=H[ye])!=null&&Ne.name?`${H[ye].name} (${H[ye].email})`:ye}}).sort((ye,Ne)=>ye.label.localeCompare(Ne.label))},[i,b,H]),ge=h.useMemo(()=>b.filter(W=>!(!Vk(W,q,[Yn(W.profileId,j),vs(W,C),jr(Ln(W.action).integrationId,C),W.authorizationId?le[W.authorizationId]:null])||K.size>0&&!K.has(W.action)||X.size>0&&W.userId&&!X.has(W.userId)||!Hk(W,ee))),[b,q,j,C,le,K,X,ee]),Ee=h.useMemo(()=>{const W={automatic:0,approved:0,all:0};for(const ye of ge)W.all+=1,W[Ki(ye,"approved")?"approved":"automatic"]+=1;return W},[ge]),$e=h.useMemo(()=>ge.filter(W=>Ki(W,p)),[ge,p]),he=h.useMemo(()=>{const W=new Map;for(const ye of $e){const Ne=Nn(ye.profileId),Ze=W.get(Ne);Ze?Ze.count+=1:W.set(Ne,{shortId:Ne,icon:Kn(ye.profileId),name:Yn(ye.profileId,j),count:1})}return[...W.values()].sort((ye,Ne)=>ye.name.localeCompare(Ne.name))},[$e,j]),Fe=h.useMemo(()=>$e.filter(W=>tp(W.profileId,v)),[$e,v]),Ke=h.useMemo(()=>x===null?0:Fe.filter(W=>Yi(W,x)).length,[Fe,x]),Xe=K.size>0||X.size>0||ee!=="all";function at(W){ce(ye=>{const Ne=new Set(ye);return Ne.has(W)?Ne.delete(W):Ne.add(W),Ne})}function yt(W){L(ye=>{const Ne=new Set(ye);return Ne.has(W)?Ne.delete(W):Ne.add(W),Ne})}function Nt(){ce(new Set),L(new Set),Se("all"),U("")}async function qe(){Y(!0),F(null);try{const{bundle:W,filename:ye}=await P.fetchEvidenceBundle(),Ne=URL.createObjectURL(new Blob([JSON.stringify(W,null,2)],{type:"application/json"})),Ze=document.createElement("a");Ze.href=Ne,Ze.download=ye,Ze.click(),URL.revokeObjectURL(Ne);const dt=W.sources??{};dt.authorityServer?dt.local||F(`Downloaded Authority Server history only — ${dt.localError??"local archive unavailable."}`):F(`Downloaded local evidence only — ${dt.asError??"Authority Server export unavailable."}`)}catch(W){F(`Export failed: ${W instanceof Error?W.message:String(W)}`)}finally{Y(!1)}}return n.jsxs("div",{className:"ob-page",children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ke>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ke," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:qe,disabled:G,children:G?"Preparing…":"Download evidence"})]}),I&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:I}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(W=>n.jsx("button",{onClick:()=>l(W),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:i===W?"2px solid var(--accent)":"2px solid transparent",color:i===W?"var(--text-primary)":"var(--text-tertiary)",fontWeight:i===W?600:500},children:W==="mine"?"Mine":"Team"},W))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:R0.map(W=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${W}`,"aria-selected":p===W,onClick:()=>m(W),children:[W==="automatic"?"Automatic":W==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Ee[W]})]},W))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:q,onChange:W=>U(W.target.value)}),q&&n.jsx("button",{className:"search-clear",onClick:()=>U(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${Ae?" active":""}`,onClick:()=>Z(!Ae),children:["Filters",Xe?` (${K.size+(ee!=="all"?1:0)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(mu,{areas:he,selected:v,onSelect:y,totalCount:$e.length}),Ae&&n.jsxs("div",{className:"filter-panel",children:[Oe.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Oe.map(W=>n.jsx("button",{className:`filter-chip${K.has(W)?" selected":""}`,onClick:()=>at(W),children:W},W))})]}),i==="team"&&J.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:J.map(W=>n.jsx("button",{className:`filter-chip${X.has(W.id)?" selected":""}`,onClick:()=>yt(W.id),children:W.label},W.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([W,ye])=>n.jsx("button",{className:`filter-chip${ee===W?" selected":""}`,onClick:()=>Se(W),children:ye},W))})]})]}),Xe&&n.jsxs("div",{className:"active-filters",children:[[...K].map(W=>n.jsxs("span",{className:"active-chip",onClick:()=>at(W),children:[W," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)),[...X].map(W=>{const ye=H[W],Ne=ye?ye.name:W;return n.jsxs("span",{className:"active-chip",onClick:()=>yt(W),children:[Ne," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)}),ee!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>Se("all"),children:[ee==="1d"?"Today":ee==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:Nt,children:"Clear all"})]}),Ve&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),z&&b.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Fe.length===0?n.jsx(js,{icon:"⌕",title:b.length===0?"No tickets in the last 30 days":"No matching tickets",text:b.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:Fe.length===b.length?`${b.length} ticket${b.length!==1?"s":""}`:`${Fe.length} of ${b.length} tickets`}),n.jsx("div",{className:"ob-list",children:Fe.map(W=>{const ye=W.userId?H[W.userId]:void 0;return n.jsx("div",{className:"ob-list-item",children:n.jsx(Dk,{receipt:W,manifests:C,localAuth:W.authorizationId?pe[W.authorizationId]:void 0,localUnavailable:we,signature:Q[W.id],grantTitle:W.authorizationId?le[W.authorizationId]:null,ownerLabel:i==="team"&&W.userId?ye?`${ye.name} (${ye.email})`:W.userId:null,spUrl:R,formatDate:Wk,onOpenComplete:()=>Me(W),isNew:x!==null&&Yi(W,x),defaultOpen:Fe.length===1})},W.id)})})]}),Be&&n.jsx(Uk,{receipt:Be,onClose:()=>Me(null)}),ae&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:gt,disabled:Re,children:Re?"Loading…":"Load older"})})]})}function qk(){const[e,r]=h.useState(null),[a,i]=h.useState({}),[l,u]=h.useState(!1),d=Mn(),[p,m]=ks(),v=ep(p.get("area")),y=h.useCallback(M=>{const H=new URLSearchParams(p);M===null?H.delete("area"):H.set("area",M),m(H,{replace:!0})},[p,m]),[j,x]=h.useState({}),S=h.useCallback(()=>{P.getMyAttestations().then(M=>{const H={};for(const te of M)te.title&&(H[te.authorization_id]=te.title);x(H)}).catch(()=>{})},[]);h.useEffect(()=>{S()},[S]),Wt(S,3e5);const[N,b]=h.useState(null),k=h.useRef(!1),C=h.useCallback(()=>{P.getDenials({limit:200}).then(({records:M})=>{r(M),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{C()},[C]),Wt(C,6e4),h.useEffect(()=>{if(!e)return;const M=[...new Set(e.map(H=>H.profile).filter(H=>!!H))].filter(H=>!(H in a));M.length!==0&&Promise.all(M.map(H=>go(H))).then(H=>{i(te=>{const X={...te};return M.forEach((L,q)=>{X[L]=H[q]}),X})})},[e,a]),h.useEffect(()=>{!e||k.current||(k.current=!0,P.getLastSeenBlockedAt().then(M=>(b(M),P.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const E=h.useCallback(()=>{C(),S(),N!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||P.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[C,S,N]);He("denial-recorded",E);const R=h.useMemo(()=>{const M=new Map;for(const H of e??[]){const te=H.profile??H.integrationId,X=Nn(te),L=M.get(X);L?L.count+=1:M.set(X,{shortId:X,icon:Kn(te),name:Yn(te,d),count:1})}return[...M.values()].sort((H,te)=>H.name.localeCompare(te.name))},[e,d]);if(l)return n.jsx(js,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const A=x0(e,Date.now()),z=e.filter(M=>tp(M.profile??M.integrationId,v));return n.jsxs("div",{className:"blocked-page ob-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[A," today · nothing ran"]})]}),e.length===0?n.jsx(js,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(mu,{areas:R,selected:v,onSelect:y,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:z.map((M,H)=>{const te=lp(M,M.profile?a[M.profile]??void 0:void 0,j),X=N!==null&&M.ts>N,L=M.profile??M.integrationId;return n.jsx(Kk,{record:M,view:te,area:Yn(L,d),unseen:X,mandateTitle:op(M,j)},`${M.ts}-${H}`)})})]})]})}function Kk({record:e,view:r,area:a,unseen:i,mandateTitle:l}){const u=su();return n.jsx("div",{className:"ob-card blocked-item blocked-card","data-seen":i?"false":"true","data-testid":"blocked-card",children:n.jsxs("div",{ref:u,children:[n.jsx(Fr,{tag:"Blocked",profileId:e.profile??void 0,className:"obj-line",parts:[a,e.integrationId?`via ${ys(e.integrationId)}`:null,cp(e.ts,Date.now()),i?n.jsx("span",{className:"ob-st new-pill","data-testid":"blocked-new",children:"New"}):null]}),n.jsx("h3",{className:"ob-title",children:up(e)}),n.jsxs("p",{className:"ob-check ob-check-x","data-kind":ya(e),children:[n.jsx("span",{"aria-hidden":"true",children:"✕"}),n.jsxs("span",{children:[n.jsx("b",{children:dp(e)})," ",r.sentence]})]}),n.jsx("p",{className:"ob-quiet",children:S0(e)}),n.jsx(Jn,{title:"What you can do",summary:"change the mandate or ignore it",testId:"blocked-advice",children:n.jsx("p",{children:r.whatYouCanDo})}),n.jsx(Jn,{title:"Technical details",summary:e.code??void 0,testId:"blocked-technical",children:n.jsxs("dl",{className:"ob-kv",children:[n.jsx("dt",{children:"Action"}),n.jsxs("dd",{className:"ob-mono",children:[ys(e.integrationId)," · ",e.tool]}),n.jsx("dt",{children:"Mandate"}),n.jsxs("dd",{children:[l??(e.mandateId?"":"none covers it"),e.mandateId&&n.jsxs("span",{className:"ob-mono",children:[" ",e.mandateId.slice(0,14),"…"]})]}),e.code&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Code"}),n.jsx("dd",{className:"ob-mono",children:e.code})]})]})}),n.jsx("div",{className:"ob-btns",children:n.jsx(ut,{className:"ob-btn",to:e.mandateId?`/mandates?highlight=${encodeURIComponent(e.mandateId)}`:"/mandates",children:"Open mandate"})})]})})}const Yk={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Jk(){const[e,r]=h.useState(null),[a,i]=h.useState(!1),[l,u]=h.useState(null),d=h.useCallback(async()=>{try{r(await P.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{d()},[d]);const p=h.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){i(!0),u(null);try{await P.setAutostart(!e.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{r(await P.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}i(!1)}}},[e,a,d]);if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const m=Yk[e.platform]??"a login service";return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",m," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}function Qk(){const[e,r]=h.useState(null),[a,i]=h.useState(!1),[l,u]=h.useState(null),d=h.useCallback(async()=>{try{const m=await P.getGatewaySettings();r(m.desktopNotifications),u(null)}catch(m){u(m instanceof Error?m.message:"Could not read notification setting")}},[]);h.useEffect(()=>{d()},[d]);const p=h.useCallback(async()=>{if(!(e===null||a)){i(!0),u(null);try{const m=await P.setGatewaySettings({desktopNotifications:!e});r(m.desktopNotifications)}catch(m){u(m instanceof Error?m.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]);return e===null?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e?"Turn off":"Turn on"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const dm={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Xk(){const[e,r]=h.useState(null),[a,i]=h.useState(!1),[l,u]=h.useState(null),d=h.useCallback(async()=>{try{r(await P.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);h.useEffect(()=>{d()},[d]);const p=h.useCallback(async()=>{if(!(!e||a)){i(!0),u(null);try{r(await P.setIdentityDisclosure(!e.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await d()}finally{i(!1)}}},[e,a,d]),m=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[m,n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]});const v=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${dm.as_vouched} ${e.verifier}`:dm[e.method??""]??e.method}`:null;return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[m,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Zk={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function eN(){const{version:e,latestVersion:r,updateAvailable:a,installMethod:i}=Zc();return e?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",n.jsx("strong",{children:e}),a&&r?n.jsxs(n.Fragment,{children:[" — ",n.jsx("strong",{children:r})," is available"]}):null]}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Zk[i]??"Update checking is unavailable",i==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function zc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function fm(e){return e===!0}function tN(){const[e,r]=h.useState(null),[a,i]=h.useState(null);h.useEffect(()=>{let d=!1;return P.getAsPairing().then(p=>{d||r(p)}).catch(p=>{d||i(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{d=!0}},[]);const l=fm(e==null?void 0:e.asUrlLockedByPolicy),u=fm(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),l&&n.jsx(zc,{})]}),!e&&!a&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.5rem 0 0",fontSize:"0.9rem"},children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"URL:"})," ",n.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"Key fingerprint:"})," ",n.jsx("code",{children:e.fingerprint}),n.jsx("br",{}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"TLS certificate pin:"})," ",u&&n.jsx(zc,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?n.jsx("code",{children:e.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),l?n.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):n.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",n.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function nN(){const{simulation:e,locked:r}=Ap();return r?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(zc,{})]}),n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const rN={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}},da=["AI Assistant","Authority Server","This computer","Security","Version"],fa={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function sN(){const[e,r]=h.useState(""),[a,i]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[d,p]=h.useState("https://openrouter.ai/api/v1"),[m,v]=h.useState("google/gemma-4-31b-it"),[y,j]=h.useState(""),[x,S]=h.useState(!1),[N,b]=h.useState(!1),[k,C]=h.useState(!1),[E,R]=h.useState(null),[A,z]=h.useState([]),[M,H]=h.useState(!1),[te,X]=h.useState(null),[L,q]=h.useState(""),U=h.useCallback(G=>{r(G),setTimeout(()=>r(""),3e3)},[]),K=h.useCallback(async(G,Y,I)=>{H(!0),X(null);try{const F=await P.aiModels({provider:G,endpoint:Y,...I?{apiKey:I}:{}});F.ok&&F.models.length>0?(z(F.models),X(`${F.models.length} models available`)):(z([]),X(F.message||"No models returned — using defaults"))}catch(F){z([]),X(F instanceof Error?F.message:"Failed to load models")}finally{H(!1)}},[]),ce=h.useCallback(async()=>{try{const G=await P.getCredential("ai-config");if(S(G.configured),G.configured&&G.fields){const Y=G.fields.provider||"openai-compatible",I=G.fields.endpoint||"";G.fields.provider&&u(Y),G.fields.endpoint&&p(I),G.fields.model&&v(G.fields.model),I.includes("openai.com")?i("openai"):I.includes("groq.com")?i("groq"):I.includes("together.xyz")?i("together"):I.includes("openrouter.ai")?i("openrouter"):i("ollama"),I&&K(Y,I)}}catch{}},[K]);h.useEffect(()=>{ce()},[ce]);const ee=G=>{i(G),z([]),X(null),q("");const Y=rN[G];Y&&(u(Y.provider),p(Y.endpoint),v(""),K(Y.provider,Y.endpoint,y||void 0))},Se=()=>K(l,d,y||void 0),Ae=async()=>{b(!0);try{await P.setCredential("ai-config",{provider:l,endpoint:d,model:m,...y?{apiKey:y}:{}}),S(!0),U("AI configuration saved!")}catch{U("Failed to save AI config")}finally{b(!1)}},Z=async()=>{C(!0),R(null);try{const G=await P.aiTest({provider:l,endpoint:d,model:m,...y?{apiKey:y}:{}});R(G.ok?`OK: ${G.message}`:`Failed: ${G.message}`)}catch(G){R(`Error: ${G instanceof Error?G.message:"Unknown"}`)}finally{C(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:fa,children:da[0]}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",children:"Configuration"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),x&&n.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[n.jsx("span",{className:"status-banner-icon",children:"✓"}),n.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:"Provider Preset"}),n.jsxs("select",{className:"form-input",value:a,onChange:G=>ee(G.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("label",{className:"form-label",children:["API Key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:G=>j(G.target.value),onBlur:()=>{y.trim()&&K(l,d,y.trim())},placeholder:x?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:Se,disabled:M,title:"Re-fetch the model list from the provider",children:M?"Loading…":"↻ Refresh"})]}),A.length===0?n.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:M?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const G=A,Y=G.includes(m),I=G.length>12,F=L.trim().toLowerCase();let pe=F?G.filter(fe=>fe.toLowerCase().includes(F)):G;return Y&&!pe.includes(m)&&(pe=[m,...pe]),n.jsxs(n.Fragment,{children:[I&&n.jsx("input",{className:"form-input",value:L,onChange:fe=>q(fe.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:Y?m:"__unset__",onChange:fe=>v(fe.target.value==="__unset__"?"":fe.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),pe.map(fe=>n.jsx("option",{value:fe,children:fe},fe)),F&&pe.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",L,"”"]})]})]})})(),te&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:te})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Ae,disabled:N||!m.trim(),title:m.trim()?void 0:"Select a model first",children:N?"Saving...":"Save & Encrypt"}),x&&n.jsx("button",{className:"btn btn-ghost",onClick:Z,disabled:k,children:k?"Testing...":"Test Connection"})]}),E&&n.jsx("div",{className:`alert ${E.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:E})]}),n.jsx(aN,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:fa,children:da[1]}),n.jsx(tN,{}),n.jsx(Xk,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:fa,children:da[2]}),n.jsx(Jk,{}),n.jsx(Qk,{}),n.jsx(nN,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:fa,children:da[3]}),n.jsx("div",{className:"card",style:{padding:"1.5rem"},children:n.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),n.jsxs("section",{children:[n.jsx("h2",{style:fa,children:da[4]}),n.jsx(eN,{})]})]})}function aN(){const[e,r]=h.useState(null),[a,i]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[d,p]=h.useState(null),[m,v]=h.useState(null),[y,j]=h.useState(!1),x=h.useCallback(async()=>{if(!y)try{const b=await P.getAIPrompts();r(b),i({intent:b.intent.current,context:b.context.current}),j(!0)}catch(b){p(b instanceof Error?b.message:"Failed to load prompts")}},[y]),S=async b=>{if(e){u(b),p(null);try{const k=a[b],C=k.trim()===e[b].default.trim()?"":k;await P.setAIPrompt(b,C);const E=await P.getAIPrompts();r(E),i({intent:E.intent.current,context:E.context.current}),v(b),setTimeout(()=>v(null),2e3)}catch(k){p(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},N=async b=>{if(confirm(`Revert ${b} prompt to the built-in default?`)){u(b),p(null);try{await P.setAIPrompt(b,"");const k=await P.getAIPrompts();r(k),i({intent:k.intent.current,context:k.context.current})}catch(k){p(k instanceof Error?k.message:"Revert failed")}finally{u(null)}}};return n.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:b=>{b.currentTarget.open&&x()},children:[n.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),d&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:d}),!y&&!d&&n.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(hm,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:b=>i(k=>({...k,intent:b})),onSave:()=>S("intent"),onRevert:()=>N("intent"),saving:l==="intent",justSaved:m==="intent"}),n.jsx(hm,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:a.context,onChange:b=>i(k=>({...k,context:b})),onSave:()=>S("context"),onRevert:()=>N("context"),saving:l==="context",justSaved:m==="context"})]})]})}function hm({kind:e,label:r,description:a,state:i,draft:l,onChange:u,onSave:d,onRevert:p,saving:m,justSaved:v}){const y=l!==i.current;return n.jsxs("section",{style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:r}),n.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),i.overridden&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea",value:l,onChange:j=>u(j.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${r} system prompt`}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:d,disabled:m||!y,children:m?"Saving…":"Save"}),i.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:m,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!m&&!v&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),n.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:i.default})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function iN(e){return e.proposalId?"review":"automatic"}function mm(e,r,a={}){const i=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const d of e)i==="pending"&&d.status!=="pending"||a.profile&&d.profileId!==a.profile||u.push({kind:"proposal",id:d.id,sortTimestamp:d.createdAt,commitmentMode:"review",profileId:d.profileId,proposal:d});if(i==="all")for(const d of r){const p=iN(d);!l&&p==="automatic"||a.profile&&d.profileId!==a.profile||u.push({kind:"receipt",id:d.id,sortTimestamp:d.timestamp,commitmentMode:p,profileId:d.profileId,receipt:d})}return u.sort((d,p)=>p.sortTimestamp-d.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}function pm(e){const r=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,[a,i]=h.useState(r);return h.useEffect(()=>{if(typeof window.matchMedia!="function")return;const l=window.matchMedia(e),u=()=>i(l.matches);return u(),l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[e]),a}const oN=["https://","http://"];function Lg(e,r){return e!=null&&e.length?e.flatMap(a=>{const i=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const d=r[u];return typeof d=="string"||typeof d=="number"?String(d):"\0"});return i.includes("\0")||/\{|\}/.test(i)?[]:oN.some(l=>i.toLowerCase().startsWith(l))?[{label:a.label,href:i,description:a.description}]:[]}):[]}function lN(e,r){const a=e-Math.floor(r/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const i=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let d;return i>0?d=`expires in ${i}d ${l}h`:l>0?d=`expires in ${l}h ${u}m`:d=`expires in ${Math.max(1,u)}m`,{label:d,urgent:a<2*3600,expired:!1}}function cN({profileId:e,declared:r}){const{icon:a}=xr(e,r),i=Qj(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(dg,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:i})]}),n.jsx("div",{className:"id-sep"})]})}function uN({proposalId:e,systemName:r}){const[a,i]=h.useState(null);if(h.useEffect(()=>{let u=!0;return i(null),P.getProposalOutcome(e).then(d=>{u&&i(d)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=jk(a,r);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}const dN=15e3;let Li=null;function fN(){const e=Date.now();return(!Li||e-Li.at>dN)&&(Li={at:e,p:P.getMyReceiptsPage({limit:200}).then(r=>r.receipts).catch(()=>[])}),Li.p}function hN(e,r,a){var l,u,d,p;let i=null;for(const m of e)m.authorizationId!==r||!Ur(m.timestamp,a)||(!i||m.timestamp>i.timestamp||m.timestamp===i.timestamp&&(((u=(l=m.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(d=i.cumulativeState)==null?void 0:d.daily)==null?void 0:p.count)??0))&&(i=m);return i}function mN(e,r,a){const i=[];for(const[l,u]of[["daily","today"],["monthly","this month"]]){const d=au(e,r,a,l);d&&i.push({label:u,text:"limit"in d?`${d.used} of ${d.limit}`:`${d.count} ${d.count===1?"call":"calls"}`})}return i}function pN(e,r,a){const[i,l]=h.useState(void 0);if(h.useEffect(()=>{let d=!0;return l(void 0),fN().then(p=>{d&&l(hN(p,e,Date.now()))}),()=>{d=!1}},[e]),i===void 0)return{state:"loading"};if(i===null)return{state:"none"};const u=mN(i,r,a);return u.length?{state:"ok",lines:u}:{state:"none"}}function gN({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let yc=null;function yN(){return yc||(yc=P.getEnrichedAuthorizations().then(e=>new Map(e.map(r=>[r.authorizationId,r.bounds]))).catch(()=>new Map)),yc}function vN(e){const[r,a]=h.useState(void 0);return h.useEffect(()=>{let i=!0;if(e)return yN().then(l=>{i&&a(l.get(e))}),()=>{i=!1}},[e]),r}function xN(e,r){const[a,i]=h.useState(null),[l,u]=h.useState(!1),[d,p]=h.useState(null);return h.useEffect(()=>{let m=!0;return i(null),p(null),u(!0),(async()=>{var v;try{try{const x=await P.getGateContent(e);if((v=x==null?void 0:x.gateContent)!=null&&v.intent){m&&i(x.gateContent.intent);return}}catch{}const y=await P.getAttestationIntent(e);if(!y){m&&p("Intent not available or you are not an authorized approver.");return}const j=await P.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:r});m&&i(j)}catch(y){m&&p(y instanceof Error?y.message:"Failed to decrypt intent")}finally{m&&u(!1)}})(),()=>{m=!1}},[e,r]),{intent:a,loading:l,error:d}}function jN(e,r){const a=e.map(l=>({key:`limit:${l.key}`,status:l.ok?"pass":"fail",label:l.label,...l.valueText||l.limitText?{text:`${l.valueText} — your limit ${l.limitText}`.trim()}:{}})),i=(r??[]).map(l=>{const u=l.detail??l.reason;return{key:`check:${l.key}${l.index!==void 0?`:${l.index}`:""}`,status:l.status,label:l.label,...u?{text:u}:{}}});return[...a,...i]}function wN(e){switch(e.status){case"pass":return e.text?`${e.label} — ${e.text}`:e.label;case"fail":return e.text?`${e.label}: ${e.text}`:e.label;case"not_checked":return`${e.label}: not checked${e.text?` — ${e.text}`:""}`;case"notice":return e.text?`${e.label}: ${e.text}`:e.label}}const bN=n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),SN=n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})});function vc({l:e}){if(e.status==="notice")return n.jsxs("div",{className:"check-line check-notice","data-check-status":"notice",children:[bN,n.jsx("span",{children:e.text?n.jsxs(n.Fragment,{children:[n.jsxs("strong",{children:[e.label,":"]})," ",e.text]}):n.jsx("strong",{children:e.label})})]});const r=e.status==="pass"?"✓":e.status==="fail"?"✕":"–";return n.jsxs("div",{className:`check-line check-${e.status.replace("_","-")}`,"data-check-status":e.status,children:[n.jsx("span",{className:"check-mark","aria-hidden":"true",children:r}),n.jsx("span",{children:wN(e)})]})}function gm({lines:e,placement:r}){if(r==="top"){const u=e.filter(d=>d.status==="fail");return u.length===0?null:n.jsx("div",{className:"card-checks card-checks-top","data-testid":"card-checks-top",style:{order:2},children:u.map(d=>n.jsx(vc,{l:d},d.key))})}const a={not_checked:0,notice:1},i=e.filter(u=>u.status==="not_checked"||u.status==="notice").map((u,d)=>({l:u,i:d})).sort((u,d)=>a[u.l.status]-a[d.l.status]||u.i-d.i).map(({l:u})=>u),l=e.filter(u=>u.status==="pass");return i.length===0&&l.length===0?null:n.jsxs("div",{className:"card-checks card-checks-body","data-testid":"card-checks-body",children:[i.length>0&&n.jsx("div",{className:"av3-attention",style:{order:4},children:i.map(u=>n.jsx(vc,{l:u},u.key))}),l.length>0&&n.jsxs("details",{className:"av3-fold",style:{order:11},"data-testid":"checks-passed",children:[n.jsxs("summary",{children:[n.jsxs("span",{className:"h",children:["✓ ",l.length," ",l.length===1?"check":"checks"," passed"]}),n.jsx("span",{className:"one",children:l.map(u=>u.label).join(" · ")}),SN]}),n.jsx("div",{className:"av3-fold-body",children:l.map(u=>n.jsx(vc,{l:u},u.key))})]})]})}function ym(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[a,i]of Object.entries(e))(typeof i=="string"||typeof i=="number")&&(r[a]=i);return r}function kN(e){const r=ym(e.limits),a=ym(e.scope),i=typeof e.intent=="string"?e.intent:"",l={bounds:r,context:a,gateContent:{intent:i}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function Bc(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Bc(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function NN({proposal:e,currentUserId:r,proposalLinks:a,toolDisplay:i,manifests:l,onContentState:u,onShownSnapshot:d,nameOf:p,mandateTitle:m,topExtras:v}){var qe,W,ye,Ne,Ze,dt,Ge;const[y,j]=h.useState(!1),[x,S]=h.useState(!1),[N,b]=h.useState(null),k=gn(),{group:C,groupId:E,domain:R}=kt(),A=Object.entries(e.executionContext),z=Ns(e.profileId),M=vN(e.authorizationId),H=u0(e.tool),{integrationId:te}=Ln(e.tool),X=jr(te,l),{intent:L,loading:q,error:U}=xN(e.authorizationId,r),K=va(e),ce=K.toolArgs!==null,[ee,Se]=h.useState([]),Ae=[...A0(e.executionContext,M,z),...fk(K.toolArgs),...ee],Z=h.useMemo(()=>pu(K.toolArgs),[K.toolArgs]),G=h.useCallback(be=>P.getProposalAttachmentPreview(e.id,be),[e.id]);h.useEffect(()=>{u==null||u({loading:K.loading,readable:ce})},[K.loading,ce]);const Y=db(e),I=K.toolArgs?Lg(a,K.toolArgs):[],F=async()=>{if(!E){b("No active workspace; cannot open the mandate screen.");return}S(!0),b(null);try{if(!K.toolArgs){b("This content is not readable on this device yet.");return}const be=K.toolArgs,it=typeof be.profile=="string"?be.profile:"",bt=await P.listProfiles(),re=pg(it,bt);if(!re){b(`Unknown profile "${it}".`);return}const xe=await P.getProfile(re.id),B=kN(be),oe=yg(B.bounds,xe),Te=vg(B.context,xe);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:re.id,groupId:E,groupName:(C==null?void 0:C.name)??null,domain:R,isPersonal:!!(C!=null&&C.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...B,bounds:oe,context:Te})),sessionStorage.setItem("agentReplacesProposal",e.id),k("/mandates/new/intent")}catch(be){b(be instanceof Error?be.message:"Could not open the mandate screen.")}finally{S(!1)}},[pe,fe]=h.useState(null),we=wk(pe),[ve,Q]=h.useState(null),de=jN(Ae,ve==null?void 0:ve.checks);h.useEffect(()=>{ob(e.id,ve)},[e.id,ve]);const[le,ne]=h.useState(null);h.useEffect(()=>{if(!ve||!le){d==null||d(null);return}const be=ve.status==="ok"?ve.readAt:Date.now();d==null||d({readAt:be,preview:ve,requestContext:le,...K.toolArgs?{toolArgs:K.toolArgs}:{},sealed:K.sealed})},[ve,le,K.toolArgs,K.sealed,d]);const{toolName:Be}=Ln(e.tool),Me=(Ze=(Ne=(ye=(W=(qe=l==null?void 0:l.find(be=>be.id===te))==null?void 0:qe.toolGating)==null?void 0:W.overrides)==null?void 0:ye[Be])==null?void 0:Ne.sourceFromArg)==null?void 0:Ze.arg;K.toolArgs&&K.toolArgs;const ae=K.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(Bi,{args:K.toolArgs,display:i,heading:"",requestRefArg:Me}),A.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:A.map(([be,it],bt)=>{const{label:re,hint:xe}=gh(be,z);return n.jsxs("span",{children:[bt>0&&" · ",n.jsxs("span",{title:xe,children:[re,"=",Bc(it)]})]},be)})})]}):null,We=Mn(),Re=e.tool===Kp,ze=Re?K.toolArgs:null,Ve=Re?no(ze,e.profileId):e.profileId,ct=Dr(Ve,We),tt=Re?xr(no(ze,e.profileId)).testSetup:xr(e.profileId).testSetup||ho(e.tool),Qe=yp(e.expiresAt,Date.now()),De=jb(ve&&ve.status==="ok"&&"body"in ve?ve.body.structured:void 0),gt=typeof(ze==null?void 0:ze.intent)=="string"&&ze.intent.trim()?ze.intent:Re?De.intent??null:null,st=Re?xb((ze==null?void 0:ze.mode)??De.mode):null,Oe=Re&&K.toolArgs?Object.fromEntries(Object.entries(K.toolArgs).filter(([be])=>be!=="intent"&&be!=="mode")):K.toolArgs,J=Oe?n.jsx(Bi,{args:Oe,display:i,heading:"",requestRefArg:Me}):null,ge=m||(z==null?void 0:z.name)||Ht(e.profileId),Ee=pN(e.authorizationId,M,z),$e=Ee.state==="ok"?Ee.lines.map(be=>`${be.text} ${be.label}`).join(" · "):Ee.state==="none"?"none yet today":"",he=ve?io(ve,X,K.toolArgs??void 0).creation:void 0,Fe=ve?io(ve,X,K.toolArgs??void 0).note:void 0,Ke=e.tool.toLowerCase(),Xe=["delete","refund","cancel","revoke"].some(be=>Ke.includes(be)),at=typeof((dt=K.toolArgs)==null?void 0:dt._imagePreview)=="string"?K.toolArgs._imagePreview:null,yt=Re?"You sign this":"Runs exactly as shown",Nt=Re?wb(De):`${H} · ${Nn(e.profileId)}${e.profileId.includes("@")?`@${e.profileId.split("@")[1]}`:""}`;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"av3-type",style:{order:0},"data-testid":"approval-type",children:[Re?n.jsx("span",{className:"av3-mtag",children:"Mandate"}):n.jsx("b",{children:"Action"}),n.jsxs("span",{className:"av3-area",children:[n.jsx(Br,{icon:Kn(Ve)}),ct]}),n.jsx("span",{children:gp(e.createdAt*1e3,Date.now())}),tt&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx("h2",{className:"av3-title",style:{order:1},"data-testid":"approval-summary",children:Re?n.jsxs(n.Fragment,{children:[ct," · ",Yp(ct,ze).name??"new mandate"]}):qp(e.tool,K.toolArgs,l,void 0,Bp(ve??void 0,K.toolArgs))}),Qe&&n.jsx("p",{className:"av3-quiet av3-due",style:{order:1},"data-testid":"approval-deadline",children:Qe}),n.jsx(gm,{lines:de,placement:"top"}),v&&n.jsx("div",{className:"av3-extras",style:{order:3},children:v}),n.jsx(gm,{lines:de,placement:"body"}),Xe&&n.jsx("div",{className:"av3-attention",style:{order:4},"data-testid":"irreversible-note",children:n.jsxs("div",{className:"check-line check-notice",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),n.jsx("path",{d:"M8 7.5v3.5M8 5h0"})]}),n.jsx("span",{children:n.jsx("strong",{children:"Irreversible action"})})]})}),K.sealed&&K.undecryptable&&n.jsxs("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-undecryptable",children:[n.jsx("strong",{children:"Encrypted for another device."}),n.jsx("p",{children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),K.sealed&&K.loading&&n.jsx("div",{className:"av3-note",style:{order:5},"data-testid":"proposal-decrypting",children:"Decrypting…"}),n.jsxs("section",{className:"av3-sealed",style:{order:6},"data-testid":"sealed-values","aria-labelledby":`sealed-h-${e.id}`,children:[n.jsxs("h3",{id:`sealed-h-${e.id}`,className:"av3-sealed-h",children:[n.jsxs("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:[n.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1.5"}),n.jsx("path",{d:"M5.5 7V5a2.5 2.5 0 0 1 5 0v2"})]}),yt]}),Re&>&&n.jsxs("div",{className:"av3-intent","data-testid":"mandate-intent-ai",children:[n.jsx("div",{className:"av3-intent-l",children:"Intent — written by the AI, becomes your words when you sign"}),n.jsx("p",{children:gt})]}),ce&&Re&&n.jsxs("div",{className:"av3-edit",children:[n.jsx("button",{type:"button",className:"av3-link","data-testid":"edit-before-signing",onClick:F,disabled:x,children:x?"Opening…":"Edit before signing"}),N&&n.jsx("p",{className:"msg-error",children:N})]}),st&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-mode",children:[n.jsx("dt",{children:st.label}),n.jsx("dd",{children:st.title})]}),at&&n.jsx("img",{src:at,alt:typeof((Ge=K.toolArgs)==null?void 0:Ge.altText)=="string"?K.toolArgs.altText:"local image preview",className:"av3-image"}),we&&ce&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",children:[n.jsxs("h4",{children:["What will be sent ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),J]}),ce&&K.toolArgs&&ph(K.toolArgs,i)!==void 0&&n.jsx(gN,{text:ph(K.toolArgs,i)}),ce&&n.jsx(kg,{attachments:Z.attachments,inserts:Z.inserts,manifests:l,fetchPreview:G,onChecks:Se}),ce&&n.jsx(Ek,{proposalId:e.id,systemName:X,toolArgs:K.toolArgs,sealed:K.sealed,systemBoxes:!1,omitKeys:Re?vb:void 0,hideNote:!0,onTone:fe,onData:Q}),Re&&(De.workspace||De.title)&&n.jsxs("dl",{className:"av3-mandate-rows","data-testid":"mandate-applies-to",children:[De.workspace&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Applies to"}),n.jsx("dd",{children:De.workspace})]}),De.title&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Title"}),n.jsx("dd",{children:De.title})]})]})]}),he&&he.systemBoxes.length>0&&n.jsx("div",{style:{order:7},children:n.jsx(Eg,{view:he})}),Y.length>0&&n.jsxs("p",{className:"av3-quiet",style:{order:7},"data-testid":"proposal-cannot-read",children:["Cannot read this proposal yet: ",Y.map(be=>(p==null?void 0:p(be))??be).join(", ")," — shared automatically once they sign in on a device."]}),Re?n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"proposed-through",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Proposed through"}),n.jsxs("span",{className:"one",children:["Delegation",De.checks[0]?` · ${De.checks[0]}`:""]}),n.jsx(xc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsxs("p",{children:["Proposed by the AI through your ",n.jsx("strong",{children:"Delegation"})," mandate."]}),De.checks.length>0&&n.jsx("ul",{className:"av3-plain","data-testid":"mandate-checks",children:De.checks.map(be=>n.jsx("li",{children:be},be))}),n.jsx(vm,{intent:L,loading:q,error:U,expanded:y,onToggle:()=>j(!y)})]})]}):n.jsxs("details",{className:"av3-fold",style:{order:10},"data-testid":"covered-by",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Covered by"}),n.jsxs("span",{className:"one",children:[ge,$e?` · ${$e}`:""]}),n.jsx(xc,{})]}),n.jsxs("div",{className:"av3-fold-body",children:[n.jsx("p",{children:n.jsxs(ut,{to:"/mandates",className:"av3-link-strong",children:[ge," ›"]})}),Ee.state==="ok"&&n.jsx("dl",{className:"av3-usage",children:Ee.lines.map(be=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:be.label}),n.jsx("dd",{children:be.text})]},be.label))}),Ee.state==="none"&&n.jsx("p",{className:"av3-quiet",children:"No ticket under this mandate yet today."}),n.jsx(vm,{intent:L,loading:q,error:U,expanded:y,onToggle:()=>j(!y)})]})]}),ce&&n.jsx(Mk,{proposalId:e.id,layout:"folds",onData:ne}),ce&&I.length>0&&n.jsx("div",{className:"av3-links",style:{order:9},children:I.map(be=>n.jsxs("a",{href:be.href,target:"_blank",rel:"noopener noreferrer",className:"av3-link-btn",title:be.description??be.href,children:[be.label," ↗"]},be.label))}),ce&&n.jsxs("details",{className:"av3-fold",style:{order:15},"data-testid":"technical-details",children:[n.jsxs("summary",{children:[n.jsx("span",{className:"h",children:"Technical details"}),n.jsx("span",{className:"one",children:Nt}),n.jsx(xc,{})]}),n.jsxs("div",{className:"av3-fold-body proposal-args-fold",children:[Re&&(De.proposal||De.profileVersion)&&n.jsxs("dl",{className:"av3-usage",children:[De.proposal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Proposal"}),n.jsx("dd",{children:De.proposal})]}),De.profileVersion&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Version"}),n.jsx("dd",{children:De.profileVersion})]})]}),Re?null:we?A.length>0&&n.jsx("div",{className:"av3-bound",children:A.map(([be,it],bt)=>{const{label:re,hint:xe}=gh(be,z);return n.jsxs("span",{children:[bt>0&&" · ",n.jsxs("span",{title:xe,children:[re,"=",Bc(it)]})]},be)})}):ae,Fe&&n.jsx("p",{className:"av3-quiet","data-testid":"preview-source-note",children:Fe}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),K.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]})]})]})}function xc(){return n.jsx("svg",{className:"i chev",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})}function vm({intent:e,loading:r,error:a,expanded:i,onToggle:l}){return n.jsxs("div",{className:"av3-mintent",children:[n.jsx("div",{className:"av3-quiet",children:"Intent"}),a?n.jsx("p",{className:"msg-error",children:a}):e!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${i?"":" intent-clamped"}`,children:e}),n.jsx("button",{type:"button",className:"av3-link",onClick:l,children:i?"Show less":"Show full intent"})]}):r?n.jsx("p",{className:"av3-quiet",children:"Loading intent…"}):n.jsx("p",{className:"av3-quiet",children:"No intent available for this mandate."})]})}const CN="setup__create_mandate";function Mg({proposal:e,currentUserId:r,manifests:a,toolDisplay:i,proposalLinks:l,mandateTitle:u,nameOf:d,topExtras:p,canApprove:m=!0,alreadyDecided:v=!1,decide:y,onDecided:j,nextLabelText:x,onBusyChange:S,className:N}){const b=e.tool===CN,[k,C]=h.useState({t:"idle"}),[E,R]=h.useState(""),[A,z]=h.useState(""),[M,H]=h.useState(!1),[te,X]=h.useState(!0),L=h.useRef(null),q=async()=>{const G=L.current;if(G)try{const{shownHash:Y}=await P.saveShownSnapshot(e.id,G);return Y}catch{return}},U=async(G,Y)=>{if(!(k.t==="working"||k.t==="done")){if(G==="approve"&&Cp()){z(Ep);return}z(""),C({t:"working",kind:G});try{const I=await q(),F=await y({kind:G,note:Y,shownHash:I});C({t:"done",kind:G,result:F}),j==null||j(G,F)}catch(I){z(I instanceof Error?I.message:"Failed"),C(G==="change"?{t:"change"}:{t:"idle"})}}},K=()=>{const G=pS(E);if(!G.valid){z(G.error);return}U("change",G.trimmed)},ce=h.useRef(null);h.useEffect(()=>{const G=ce.current;if(!G)return;const Y=I=>{var pe;const F=I.target;!F.open||!((pe=F.classList)!=null&&pe.contains("av3-fold"))||G.querySelectorAll("details.av3-fold[open]").forEach(fe=>{fe!==F&&(fe.open=!1)})};return G.addEventListener("toggle",Y,!0),()=>G.removeEventListener("toggle",Y,!0)},[]);const ee=k.t==="working"||k.t==="done";h.useEffect(()=>(S==null||S(ee),()=>{ee&&(S==null||S(!1))}),[ee]);const Se=!v&&!ee&&fb({loading:M,readable:te}),Ae=b?"Sign mandate":"Approve",Z=`human-only-${e.id}`;return n.jsxs("div",{className:`card av3-card${ee?" av3-busy":""}${N?` ${N}`:""}`,"data-testid":"approval-card","data-proposal-id":e.id,"data-phase":k.t,children:[n.jsx("div",{className:"av3-scroll",children:n.jsxs("article",{ref:ce,className:"av3-body","aria-hidden":ee||void 0,children:[x&&n.jsx("div",{className:"av3-next",role:"status",style:{order:-1},children:x}),n.jsx(NN,{proposal:e,currentUserId:r,proposalLinks:l,toolDisplay:i,manifests:a,nameOf:d,mandateTitle:u,topExtras:p,onContentState:({loading:G,readable:Y})=>{H(G),X(Y)},onShownSnapshot:G=>{L.current=G}})]})}),n.jsx("span",{id:Z,className:"sr-only",children:"Only you approve. Never let an AI or a browser it controls open this page or approve for you."}),Se&&k.t!=="change"&&n.jsxs("footer",{className:"av3-foot",children:[A&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:A}),n.jsxs("div",{className:`av3-btns${m?"":" av3-btns-two"}`,children:[m&&n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-approve","aria-describedby":Z,onClick:()=>void U("approve"),children:Ae}),n.jsxs("button",{type:"button",className:"av3-btn","data-testid":"btn-change-needed",onClick:()=>{z(""),C({t:"change"})},children:[n.jsx("span",{className:"long",children:"Ask for changes"}),n.jsx("span",{className:"short",children:"Changes"})]}),n.jsx("button",{type:"button",className:"av3-btn","data-testid":"btn-reject",onClick:()=>void U("reject"),children:"Reject"})]})]}),!v&&!ee&&k.t==="change"&&n.jsxs("footer",{className:"av3-foot av3-chg",children:[n.jsx("label",{className:"av3-chg-l",htmlFor:`chg-${e.id}`,children:"What should the AI change?"}),n.jsx("textarea",{id:`chg-${e.id}`,"data-testid":"change-note",value:E,maxLength:Fc,rows:3,onChange:G=>R(G.target.value),autoFocus:!0}),A&&n.jsx("p",{className:"msg-error av3-error",role:"alert",children:A}),n.jsxs("div",{className:"av3-btns av3-btns-two",children:[n.jsx("button",{type:"button",className:"av3-btn av3-btn-primary","data-testid":"btn-send-back",onClick:K,children:"Send to the AI"}),n.jsx("button",{type:"button",className:"av3-btn",onClick:()=>{C({t:"idle"}),z("")},children:"Back"})]})]}),k.t==="working"&&n.jsxs("div",{className:"av3-stamp av3-stamp-wait",role:"status","data-testid":"decision-working",children:[n.jsx("span",{className:"av3-spin","aria-hidden":"true"}),O0(k.kind,b),"…"]}),k.t==="done"&&n.jsxs("div",{className:"av3-stamp",role:"status","data-testid":"decision-stamp",children:[n.jsx("svg",{className:"av3-check",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"m5 12.5 4.5 4.5L19 7.5"})}),n.jsx("div",{className:"av3-stamp-w",children:z0(k.kind,b)}),n.jsx("div",{className:"av3-stamp-t",children:B0(k.kind,k.result)})]})]})}async function EN(e,{kind:r,note:a,shownHash:i},l){const u=Cj(e,l.activeDomain),d=await cu(e);if(r==="approve"){const m=await P.resolveProposal(e.id,"commit",u,{contentHash:d,shownHash:i});return{ticketId:vp(m.receipt)}}if(r==="reject")return await P.resolveProposal(e.id,"reject",u,{...lg(),contentHash:d,shownHash:i}),{};const{noteEncrypted:p}=await P.encryptProposalNote(a??"",Wp(e,l.userId));return await P.resolveProposal(e.id,"reject",u,{outcome:"change_needed",noteEncrypted:p,contentHash:d,shownHash:i}),{}}function TN(e){const r=e instanceof Error?e.message:"Approval failed";return r.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":r.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":r}async function AN(e,{kind:r,note:a,shownHash:i},l){try{const u=await cu(e);if(r==="approve"){const p=await P.approveProposal(e.id,u,i);try{const j=await P.getAttestationIntent(e.authorizationId);if(j){const x=await P.decryptIntent({intentCiphertext:j.intentCiphertext,encryptedKey:j.encryptedKey,approverId:l.userId});await P.storeApprovedIntent(e.authorizationId,x)}}catch{}const{requiredApprovals:m,approvedCount:v}=p,y=m!==void 0&&v!==void 0?m-v:void 0;return{ticketId:vp(p.receipt),...y!==void 0&&y>0?{detail:`${y} more approval${y===1?"":"s"} still needed`}:{}}}if(r==="reject")return await P.rejectProposal(e.id,lg(),u,i),{};const{noteEncrypted:d}=await P.encryptProposalNote(a??"",Wp(e,l.userId));return await P.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:d},u,i),{}}catch(u){throw new Error(TN(u))}}const IN={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},RN={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},xm={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function jc(e){const r=Date.now()-e*1e3,a=r/36e5;return a<48?a<1?`${Math.max(1,Math.round(r/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $N(e){return e.split("__").pop()??e}function PN(e){const r=e.toLowerCase();return r.includes("delete")||r.includes("refund")||r.includes("cancel")||r.includes("revoke")}function Fg(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(r=>Fg(r)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Og({proposal:e,manifests:r,toolDisplay:a,proposalLinks:i,currentUserId:l,mandateTitle:u,onDecided:d,nextLabelText:p,onBusyChange:m}){const{domain:v}=kt();return n.jsx(Mg,{proposal:e,currentUserId:l,manifests:r,toolDisplay:a,proposalLinks:i,mandateTitle:u,nextLabelText:p,onBusyChange:m,decide:y=>EN(e,y,{activeDomain:v,userId:l}),onDecided:(y,j)=>d==null?void 0:d(e.id,y,j)})}function _N(e){const{item:r}=e;return r.kind==="proposal"&&r.proposal.status==="pending"?n.jsx(Og,{proposal:r.proposal,manifests:e.manifests,toolDisplay:e.toolDisplay,proposalLinks:e.proposalLinks,currentUserId:e.currentUserId??"",mandateTitle:e.mandateTitle,onDecided:e.onDecided}):n.jsx(LN,{...e})}function LN({item:e,proposalLinks:r,toolDisplay:a,manifests:i,currentUserId:l}){const u=e.kind==="proposal",d=u?e.proposal.status:"executed",p=u?e.proposal.tool:e.receipt.action,m=$N(p),v=PN(p),{integrationId:y}=Ln(p),j=jr(y,i),x=u&&d==="rejected"?vS(e.proposal,l??""):null,S=u&&d==="refused"?xS(e.proposal):null,N=hb(u?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),b=va(u?e.proposal:{toolArgs:void 0,content:void 0}),k=u?b.toolArgs:null,C=u?e.proposal.executionContext:e.receipt.executionContext,E=u?null:e.receipt.cumulativeState,R=u&&b.toolArgs?Lg(r,b.toolArgs):[],A=Object.entries(C??{}),z=xr(e.profileId).testSetup||ho(p);return n.jsxs("div",{className:"card id-card",children:[n.jsx(cN,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:m}),z&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"automatic"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[u&&d==="pending"&&(()=>{const M=lN(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:M.urgent?600:400,whiteSpace:"nowrap"},children:M.label})})(),n.jsx("span",{"data-testid":x||S?"outcome-kind":void 0,className:`status-badge ${x?xm[x.kind]:S?xm.REFUSED:RN[d]}`,children:x?x.kind:S?S.kind:IN[d]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:jc(e.sortTimestamp)})]})]}),u&&e.proposal.status==="executed"&&n.jsx(uN,{proposalId:e.proposal.id,systemName:j}),x&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",x.who,", ",jc(x.at)]}),(N??x.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[x.kind==="CHANGE NEEDED"?"Change: ":"Note: ",N??x.note]})]}),S&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",jc(S.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",S.message]})]}),v&&n.jsx("div",{className:"note-attention",style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-attention",children:"Irreversible action"})}),u&&typeof(k==null?void 0:k._imagePreview)=="string"&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),n.jsx("img",{src:k._imagePreview,alt:typeof(k==null?void 0:k.altText)=="string"?k.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),n.jsxs(n.Fragment,{children:[R.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:R.map(M=>n.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:M.description??M.href,children:[M.label," ↗"]},M.label))}),u?n.jsxs(n.Fragment,{children:[k&&n.jsx(Bi,{args:k,display:a}),A.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:A.map(([M,H])=>`${M}=${Fg(H)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Cg,{receipt:e.receipt,manifests:i}),e.receipt.proposalId&&n.jsx(_g,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:i})]})]}),E&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",E.daily.count," action",E.daily.count===1?"":"s",E.daily.amount>0?`, ${E.daily.amount}`:""," · ","this month: ",E.monthly.count,E.monthly.amount>0?`, ${E.monthly.amount}`:""]}),n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[u?"Proposal":"Ticket",": ",e.id]})]})]})}function MN(e,r=[]){const a=new Map;for(const i of e){const l=i.name&&i.email?`${i.name} (${i.email})`:i.name||i.email||i.id;a.set(i.id,l)}for(const i of r){const l=i.userId??i.id;l&&(i.name&&i.email?a.set(l,`${i.name} (${i.email})`):i.name&&a.set(l,i.name))}return a}function FN(e,r){return e.map(a=>r.get(a)??a)}function zg(e){var S;const{groupId:r}=kt(),a=Ns(e.profileId),[i,l]=h.useState(null),[u,d]=h.useState(new Map),[p,m]=h.useState(!0);h.useEffect(()=>{let N=!0;if(!r){m(!1);return}return m(!0),Promise.all([P.getTeamProfileConfig(r,e.profileId).catch(()=>null),P.getGroupById(r).catch(()=>null),P.listUsers().catch(()=>[])]).then(([b,k,C])=>{N&&(l(b),d(MN(C,(k==null?void 0:k.members)??[])))}).finally(()=>{N&&m(!1)}),()=>{N=!1}},[r,e.profileId]);const v=Tj(i??{}),y=FN(e.pendingApprovers??[],u),j=N=>u.get(N)??N,x=i&&((S=a==null?void 0:a.boundsSchema)!=null&&S.fields)?Pb(e.executionContext,i,a.boundsSchema.fields):null;return{loading:p,profileConfig:i,requiredApprovals:v,approverNames:y,nameOf:j,aboveCapReason:x}}function Bg(e,r){return!!e.createdBy&&!!r&&e.createdBy===r}function Dg(e){return(e.pendingApprovers??[]).filter(r=>r!==e.createdBy)}function ON({proposal:e,currentUserId:r,onDecided:a,proposalLinks:i,toolDisplay:l,manifests:u,mandateTitle:d,nextLabelText:p,onBusyChange:m}){const v=Dg(e),y=e.approvedBy??{},j=Object.keys(y).length,x=r in y,S=zg(e),N=Bg(e,r),b=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"approver-progress av3-quiet",children:["Needs ",S.requiredApprovals," approval",S.requiredApprovals===1?"":"s"," from:"," ",v.map((k,C)=>n.jsxs("span",{className:`who${k in y?" done":""}`,style:{marginLeft:C===0?"0.25rem":"0.5rem",fontWeight:k in y?600:void 0},children:[k in y?"✓ ":"",S.nameOf(k),k===r?" (you)":"",C<v.length-1?",":""]},k)),S.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",j," of ",S.requiredApprovals,")"]})]}),S.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",children:[n.jsx("b",{children:"Above the team limit:"})," ",n.jsxs("span",{children:[S.aboveCapReason.fieldLabel,S.aboveCapReason.value!==void 0?` ${S.aboveCapReason.value}`:""," (limit ",String(S.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${S.nameOf(e.createdBy)}.`:""]})]}),N&&n.jsx("p",{className:"blocked-note av3-bold","data-testid":"cant-approve-own-action",children:"You can't approve your own action."}),x&&n.jsxs("p",{className:"av3-quiet",children:["You approved this action.",S.requiredApprovals>1&&j<S.requiredApprovals?` Waiting on ${S.requiredApprovals-j} more approval(s).`:""]})]});return n.jsx(Mg,{proposal:e,currentUserId:r,manifests:u,toolDisplay:l,proposalLinks:i,mandateTitle:d,nameOf:S.nameOf,nextLabelText:p,onBusyChange:m,topExtras:b,canApprove:!N,alreadyDecided:x,decide:k=>AN(e,k,{userId:r}),onDecided:(k,C)=>a==null?void 0:a(e.id,k,C)})}function zN(){const{domain:e,user:r}=kt(),a=(r==null?void 0:r.id)??"",[i,l]=h.useState("me"),[u,d]=h.useState([]),[p,m]=h.useState([]),[v,y]=h.useState({}),[j,x]=h.useState(!0),S=h.useCallback(async()=>{try{const B=await P.getProposalsForApprover();d(B)}catch{}finally{x(!1)}},[]);He("proposal-added",S),He("proposal-approved",S),He("proposal-rejected",S),He("proposal-resolved",S),Wt(S,3e4);const[N,b]=h.useState([]),[k,C]=h.useState(!0),E=h.useCallback(async()=>{try{const B=await P.getMyProposals(e);b(B)}catch{}finally{C(!1)}},[e]);He("proposal-added",E),He("proposal-approved",E),He("proposal-rejected",E),He("proposal-resolved",E),He("execution-failed",E),Wt(E,3e4,e);const R=h.useMemo(()=>N.filter(B=>{var oe;return B.status==="pending"&&(((oe=B.pendingApprovers)==null?void 0:oe.length)??0)===0}),[N]),A=h.useMemo(()=>mm(R,[],{status:"pending"}),[R]),[z,M]=h.useState([]),H=h.useCallback(async()=>{if(a)try{const oe=(await P.getMyProposals(e)).filter(Te=>Te.status==="pending"&&Te.pendingApprovers&&Te.pendingApprovers.includes(a)&&Te.approvedBy&&a in Te.approvedBy);M(oe)}catch{}},[a,e]);He("proposal-approved",H),He("proposal-rejected",H),Wt(H,3e4,`${a}:${e}`);const[te,X]=h.useState([]),L=h.useCallback(async()=>{try{const B=await P.getProposalsCreatedByMe();if(B!==null){X(B);return}X(await P.getMyPendingProposals())}catch{}},[]);He("proposal-added",L),He("proposal-approved",L),He("proposal-rejected",L),Wt(L,3e4),h.useEffect(()=>{P.getLabelManifests().then(m).catch(()=>{}),P.getToolDisplay().then(y).catch(()=>{})},[]);const q=B=>{var oe;return(oe=p.find(Te=>Te.id===B.split("__")[0]))==null?void 0:oe.proposalLinks};h.useEffect(()=>{S(),E(),H(),L()},[]);const[U,K]=h.useState([]),[ce,ee]=h.useState([]),[Se,Ae]=h.useState(!0),[Z,G]=h.useState("pending"),[Y,I]=h.useState(null),[F,pe]=h.useState(!1),fe=h.useCallback(async()=>{try{const{proposals:B,receipts:oe}=await P.getThread({domain:e,status:Z,sinceDays:7});K(B),ee(oe)}catch{}finally{Ae(!1)}},[e,Z]);Wt(fe,3e4,`${e}:${Z}`);const we=h.useMemo(()=>{const B=new Set;for(const oe of U)B.add(oe.profileId);for(const oe of ce)B.add(oe.profileId);return Array.from(B).sort()},[U,ce]),ve=h.useMemo(()=>mm(U,ce,{status:Z,profile:Y??void 0,includeAutonomous:F}),[U,ce,Z,Y,F]),Q=h.useMemo(()=>{const B=new Set,oe=[];for(const Te of[...z,...te])B.has(Te.id)||(B.add(Te.id),oe.push(Te));return oe.sort((Te,rt)=>rt.createdAt-Te.createdAt)},[z,te]),[de,le]=h.useState({});h.useEffect(()=>{P.getMyAttestations().then(B=>{const oe={};for(const Te of B)Te.authorization_id&&Te.title&&(oe[Te.authorization_id]=Te.title);le(oe)}).catch(()=>{})},[]);const[ne,Be]=h.useState(new Set),Me=h.useMemo(()=>{const B=[];for(const oe of A)oe.kind==="proposal"&&B.push({id:oe.proposal.id,proposal:oe.proposal,route:"queue"});for(const oe of u)B.some(Te=>Te.id===oe.id)||B.push({id:oe.id,proposal:oe,route:"approver"});return B.filter(oe=>!ne.has(oe.id)).sort((oe,Te)=>oe.proposal.createdAt-Te.proposal.createdAt)},[A,u,ne]),ae=h.useMemo(()=>Me.map(B=>B.id),[Me]),We=h.useRef(ae);We.current=ae;const Re=Me.length,ze=pm("(min-width: 1400px)"),Ve=pm("(prefers-reduced-motion: reduce)"),[ct]=ks(),[tt,Qe]=h.useState(()=>ct.get("open")),[De,gt]=h.useState(!1),[st,Oe]=h.useState(!1),[J,ge]=h.useState(null),[Ee,$e]=h.useState(null),he=h.useRef([]);h.useEffect(()=>()=>{he.current.forEach(B=>window.clearTimeout(B))},[]);const Fe=(B,oe)=>{he.current.push(window.setTimeout(B,oe))},Ke=j||k,Xe=h.useRef(null);h.useEffect(()=>{if(!(J||Ke)){if(ae.length===1&&tt===null&&Xe.current!==ae[0]){Xe.current=ae[0],Qe(ae[0]);return}tt&&!ae.includes(tt)&&Qe(null)}},[ae,tt,J,Ke]);const at=!Ke&&!J&&ae.length===1&&tt===null&&Xe.current!==ae[0],yt=(J==null?void 0:J.entry)??(tt?Me.find(B=>B.id===tt)??null:null),Nt=yt&&!J?ae.indexOf(yt.id):-1,qe=h.useCallback(B=>{$e(null),Qe(B)},[]),W=h.useCallback((B,oe,Te)=>{const rt=We.current,ot=Me.find(tn=>tn.id===B);if(!ot)return;Be(tn=>new Set(tn).add(B)),ge({entry:ot,before:rt}),S(),E(),H(),L(),fe(),wh();const Fn=()=>{const tn=rt.filter(qt=>qt!==B),nn=D0(rt,B);ge(null),gt(!1),Qe(nn),$e(nn?{id:nn,label:W0(tn,nn)}:null),nn&&Fe(()=>$e(qt=>qt&&qt.id===nn?null:qt),2200)};Fe(()=>{if(Ve){Fn();return}gt(!0),Fe(Fn,320)},1100)},[Me,Ve,S,E,H,L,fe]),ye=h.useCallback(()=>{S(),E(),H(),fe(),wh()},[S,E,H,fe]);h.useEffect(()=>{if(i!=="me"||!tt||J||st)return;const B=oe=>{if(oe.metaKey||oe.ctrlKey||oe.altKey)return;const Te=oe.target;if(Te&&(Te.tagName==="TEXTAREA"||Te.tagName==="INPUT"||Te.tagName==="SELECT"||Te.isContentEditable))return;const rt=V0(oe.key);if(!rt)return;const ot=We.current.indexOf(tt);rt==="prev"&&ot>0?(oe.preventDefault(),qe(We.current[ot-1])):rt==="next"&&ot>=0&&ot<We.current.length-1?(oe.preventDefault(),qe(We.current[ot+1])):rt==="list"&&(oe.preventDefault(),qe(null))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[i,tt,J,st,qe]);const Ne=B=>q(B.proposal.tool),Ze=B=>B.authorizationId?de[B.authorizationId]:void 0,dt=B=>{const oe=Ee&&Ee.id===B.id?Ee.label:null;return B.route==="queue"?n.jsx(Og,{proposal:B.proposal,manifests:p,toolDisplay:v[B.proposal.tool],proposalLinks:Ne(B),currentUserId:a,mandateTitle:Ze(B.proposal),onDecided:W,nextLabelText:oe,onBusyChange:Oe},B.id):n.jsx(ON,{proposal:B.proposal,currentUserId:a,manifests:p,toolDisplay:v[B.proposal.tool],proposalLinks:Ne(B),mandateTitle:Ze(B.proposal),onDecided:W,nextLabelText:oe,onBusyChange:Oe},B.id)},Ge=n.jsxs("label",{className:"av3-show",children:[n.jsx("span",{children:"Show"}),n.jsxs("span",{className:"av3-select",children:[n.jsx("select",{"data-testid":"queue-view",value:i,onChange:B=>{const oe=B.target.value;l(oe),oe==="all"&&fe()},"aria-label":"Show",children:H0.map(B=>n.jsx("option",{value:B.id,children:B.label},B.id))}),n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m4 6 4 4 4-4"})})]})]}),be=n.jsxs("header",{className:"av3-ph",children:[n.jsx("h1",{className:"av3-ph-title",children:"Approvals"}),n.jsx("span",{className:"av3-sp"}),Ge]}),it=n.jsxs("header",{className:"av3-ph",children:[!ze&&n.jsxs("button",{type:"button",className:"av3-back","data-testid":"back-to-list",disabled:st,onClick:()=>qe(null),children:[n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})}),"Approvals ",n.jsx("span",{className:"n",children:Re})]}),n.jsx("span",{className:"av3-sp"}),J||st?n.jsx("span",{className:"av3-pos",children:Re>0?`${Re} left`:"none left"}):Nt>=0&&ae.length>1?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"av3-pos","data-testid":"card-position",children:[Nt+1," of ",ae.length]}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Previous approval",disabled:Nt<=0,onClick:()=>qe(ae[Nt-1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M10 3 5 8l5 5"})})}),n.jsx("button",{type:"button",className:"av3-ib","aria-label":"Next approval",disabled:Nt>=ae.length-1,onClick:()=>qe(ae[Nt+1]),children:n.jsx("svg",{className:"i",viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"m6 3 5 5-5 5"})})})]}):null]}),bt=n.jsxs("div",{className:"av3-rows",children:[Me.length>0&&n.jsxs("div",{className:"av3-lh",children:[n.jsxs("span",{children:[Me.length," waiting for you"]}),n.jsx("span",{children:"oldest first"})]}),Me.map(B=>n.jsx(Jp,{proposal:B.proposal,manifests:p,titles:de,selected:tt===B.id,onOpen:()=>qe(B.id),who:B.route==="approver"?"Team approval — other people are involved":void 0},B.id))]}),re=n.jsx("p",{className:"av3-empty","data-testid":"queue-empty",children:"Nothing waiting for you."}),xe=yt&&n.jsx("div",{className:`av3-stage is-open${J&&De?" av3-out":""}${Ee&&Ee.id===yt.id?" av3-in":""}`,"data-testid":ze?"approval-open":"approval-row","data-proposal-id":yt.id,children:dt(yt)},yt.id);return n.jsxs("div",{className:`av3-page${ze?" av3-wide":""}`,"data-view":i,children:[i==="me"&&((Ke||at)&&!J?n.jsxs(n.Fragment,{children:[be,n.jsx("p",{className:"av3-empty",children:"Loading…"})]}):ze?n.jsxs("div",{className:"av3-split",children:[n.jsxs("section",{className:"av3-pane av3-pane-list","aria-label":"Approvals",children:[be,n.jsx("div",{className:"av3-pane-scroll",children:Re===0?re:bt})]}),n.jsx("section",{className:"av3-pane av3-pane-card",children:yt?n.jsxs(n.Fragment,{children:[it,n.jsx("div",{className:"av3-cbox",children:xe})]}):Re>0&&n.jsx("p",{className:"av3-empty",children:"Pick an approval from the list."})})]}):yt?n.jsxs("section",{className:"av3-pane","aria-label":"Approval",children:[it,n.jsx("div",{className:"av3-cbox",children:xe})]}):n.jsxs("section",{className:"av3-pane","aria-label":"Approvals",children:[be,n.jsx("div",{className:"av3-pane-scroll",children:Re===0?re:bt})]})),i==="others"&&n.jsxs("section",{className:"av3-pane","aria-label":"Waiting on others",children:[be,n.jsx("div",{className:"av3-pane-scroll",children:Q.length===0?n.jsx("p",{className:"av3-empty",children:"Nothing is waiting on others."}):n.jsx("div",{className:"av3-stack",children:Q.map(B=>n.jsx(DN,{proposal:B,currentUserId:a,onCancel:async()=>{try{await P.rejectProposal(B.id,{reason:"cancelled by creator"}),H(),E()}catch(oe){alert(oe instanceof Error?oe.message:"Cancel failed")}},onWithdraw:async()=>{const oe=await cu(B);await P.withdrawProposal(B.id,void 0,oe),L(),H()}},B.id))})})]}),i==="all"&&n.jsxs("section",{className:"av3-pane","aria-label":"All approvals",children:[be,n.jsxs("div",{className:"av3-pane-scroll",children:[n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${Z==="pending"?"selected":""}`,onClick:()=>G("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${Z==="all"?"selected":""}`,onClick:()=>G("all"),children:"All"}),we.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),we.map(B=>n.jsx("button",{className:`filter-chip ${Y===B?"selected":""}`,onClick:()=>I(Y===B?null:B),children:Ht(B)},B)),Z==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${F?"selected":""}`,onClick:()=>pe(!F),title:"Include actions that ran without a human review (automatic mode)",children:[F?"✓ ":"","Automatic actions"]})]})]}),Se&&ve.length===0?n.jsx("p",{className:"av3-empty",children:"Loading…"}):ve.length===0?n.jsx("p",{className:"av3-empty",children:Z==="pending"?"Nothing waiting for you.":"Nothing here yet."}):n.jsx("div",{className:"av3-stack av3-inline",children:ve.map(B=>n.jsx(_N,{proposalLinks:B.kind==="proposal"?q(B.proposal.tool):void 0,toolDisplay:B.kind==="proposal"?v[B.proposal.tool]:void 0,manifests:p,currentUserId:a,item:B,mandateTitle:B.kind==="proposal"?Ze(B.proposal):void 0,onDecided:ye},B.id))})]})]})]})}function BN(e){const r=Date.now()-e*1e3,a=Math.floor(r/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const i=Math.floor(r/36e5);return i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function DN({proposal:e,currentUserId:r,onCancel:a,onWithdraw:i}){const[l,u]=h.useState(!1),[d,p]=h.useState(!1),[m,v]=h.useState(""),y=zg(e),j=Bg(e,r),x=Dg(e),S=e.approvedBy??{},N=Object.keys(S).length,b=x.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},C=async()=>{p(!0),v("");try{await i()}catch(R){v(R instanceof Error?R.message:"Withdraw failed")}finally{p(!1)}},E=xr(e.profileId).testSetup||ho(e.tool);return n.jsx("div",{className:"card av3-other",children:n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:BN(e.createdAt)})]}),b&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",y.requiredApprovals," approval",y.requiredApprovals===1?"":"s"," from:"," ",x.map((R,A)=>n.jsxs("span",{className:`who${R in S?" done":""}`,style:{marginLeft:A===0?"0.25rem":"0.5rem",fontWeight:R in S?600:void 0},children:[R in S?"✓ ":"",y.nameOf(R),R===r?" (you)":"",A<x.length-1?",":""]},R)),y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",N," of ",y.requiredApprovals,")"]})]}),y.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[y.aboveCapReason.fieldLabel,y.aboveCapReason.value!==void 0?` ${y.aboveCapReason.value}`:""," (limit ",String(y.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${y.nameOf(e.createdBy)}.`:""]})]}),b&&j&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),b&&j?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:C,disabled:d,children:d?"Withdrawing...":"Withdraw"}),m&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:m})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:k,disabled:l,children:l?"Cancelling...":"Cancel"})})]})})}const UN=`# Agent Brief
|
|
88
|
-
|
|
89
|
-
You act on my behalf through Suveren — the gateway that gates every
|
|
90
|
-
privileged tool call you make. Suveren implements the bounded-authority
|
|
91
|
-
model from the open Human Agency Protocol (HAP): each mandate
|
|
92
|
-
describes an area of authority, a set of numeric limits, and a scope.
|
|
93
|
-
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
94
|
-
|
|
95
|
-
## Before you act in a domain
|
|
96
|
-
|
|
97
|
-
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
98
|
-
intent, scope, and usage for that area. The session brief shows only
|
|
99
|
-
a one-line summary per mandate — the Intent paragraph lives behind
|
|
100
|
-
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
101
|
-
publish on weekends", "only reply in English").
|
|
102
|
-
2. If the action would exceed a bound or fall outside the scope, stop
|
|
103
|
-
and explain what would be blocked instead of trying.
|
|
104
|
-
3. If you're not sure whether an action is covered, ask me first.
|
|
105
|
-
|
|
106
|
-
## How to handle reviews
|
|
107
|
-
|
|
108
|
-
Mandates in review mode require my approval before the action
|
|
109
|
-
executes. When you propose an action:
|
|
110
|
-
- Include everything I need to judge it (title, recipients, amounts,
|
|
111
|
-
dates, attendees) in the tool arguments.
|
|
112
|
-
- Don't batch unrelated proposals — one proposal per decision.
|
|
113
|
-
|
|
114
|
-
## Standing orders
|
|
115
|
-
|
|
116
|
-
(Add your own here. Examples:)
|
|
117
|
-
|
|
118
|
-
- Every morning, summarize today's calendar and flag conflicts.
|
|
119
|
-
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
120
|
-
next.
|
|
121
|
-
- Never email anyone outside the company without asking first.
|
|
122
|
-
- When drafting posts, prefer plain language over marketing copy.
|
|
123
|
-
`;function WN(){const[e,r]=h.useState(""),[a,i]=h.useState(""),[l,u]=h.useState(!0),[d,p]=h.useState(!1),[m,v]=h.useState(null),[y,j]=h.useState(!1),x=e!==a,S=new Blob([e]).size,N=16*1024;h.useEffect(()=>{if(!x)return;const E=A=>{A.preventDefault(),A.returnValue=""},R=A=>{var H,te;if(A.defaultPrevented||A.button!==0||A.metaKey||A.ctrlKey||A.shiftKey||A.altKey)return;const z=(te=(H=A.target)==null?void 0:H.closest)==null?void 0:te.call(H,"a");if(!z||!z.href)return;let M;try{M=new URL(z.href)}catch{return}M.origin===window.location.origin&&M.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(A.preventDefault(),A.stopPropagation()))};return window.addEventListener("beforeunload",E),document.addEventListener("click",R,!0),()=>{window.removeEventListener("beforeunload",E),document.removeEventListener("click",R,!0)}},[x]),h.useEffect(()=>{let E=!1;return P.getAgentContext().then(R=>{E||(r(R),i(R))}).catch(R=>{E||v({kind:"error",text:R instanceof Error?R.message:"Failed to load context"})}).finally(()=>{E||u(!1)}),()=>{E=!0}},[]);const b=async()=>{p(!0),v(null);try{await P.saveAgentContext(e),i(e),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(E){v({kind:"error",text:E instanceof Error?E.message:"Save failed"})}finally{p(!1)}},k=()=>{r(a),v(null)},C=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||r(UN)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!l&&n.jsx("button",{className:"btn btn-primary btn-sm",onClick:C,disabled:d,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),m&&n.jsx("div",{className:m.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:m.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(so,{target:{kind:"context"},currentText:e,onApply:E=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||r(E)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[n.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),n.jsxs("span",{className:S>N?"msg-error":void 0,style:{fontSize:"0.75rem",color:S>N?void 0:"var(--text-muted)"},children:[S.toLocaleString()," / ",N.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:e,onChange:E=>r(E.target.value),placeholder:l?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:l,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),n.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:k,disabled:d||!x,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:b,disabled:d||!x||S>N||l,children:d?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(tg,{open:y,onClose:()=>j(!1),ariaLabel:"Brief assistant",children:n.jsx(so,{target:{kind:"context"},currentText:e,onApply:E=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(r(E),j(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function HN(e){const r=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return r&&r[1].replace(/<[^>]+>/g,"").trim()||"Report"}function VN(e){const r=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!r)return null;const a=r.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const i=a.profile.split("@")[0].split("/").pop();return i?i.charAt(0).toUpperCase()+i.slice(1):null}function GN(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qN(e,r){const a=r.emailExportError?"cases unknown":`${r.coveredCases.length}/${r.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${r.ticketsReferenced.length}/${r.ticketsInPeriod.length} tickets covered`}function KN(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function YN(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function jm(e,r="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:r}}function JN(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function QN(e,r){const a=r[e];return a==null||a===""||JN(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function XN(e){const r=[];return e.missingCases.length>0&&r.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&r.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),r.length>0?`Not in the report: ${r.join(" · ")}`:null}function ZN(e,r){var a;if(r)return r;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const i=(a=e.data)==null?void 0:a.goal;return(i==null?void 0:i.ticketId)??null}return null}const e1="allow-popups allow-popups-to-escape-sandbox",t1="AI analysis — not verified",n1="Green = verified by the gateway — raw signed fields only",r1="Grey dashed = the AI's own analysis, not verified",s1="= translation by the AI, not verified",a1="Übersetzung anzeigen / show translation";function wm(e){var a;const r=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return r<=0?null:`${r} ${r===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function i1(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim()===""}function o1(e,r){return r&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function l1(e,r,a){const i=new URLSearchParams(e);return i.set("element",r),a?i.set("ticket",a):i.delete("ticket"),i}const c1={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function u1(e){return e.filter(r=>r.status==="unverifiable").map(r=>({elementId:r.id,text:`${c1[r.kind]??"Element"}: ${r.reason??"could not be checked"}`}))}function d1(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const r=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,i=[...r.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return i.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),i.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function f1(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const gu={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},h1={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function m1(e,r){return Array.isArray(r.fields)?r.fields.map(i=>({label:i.key,value:i.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(i=>r[i]!==void 0&&r[i]!==null).map(i=>({label:i,value:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])}))}function p1(e,r){const a=h1[e].filter(i=>r[i]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...gu,marginTop:"0.5rem"},children:a.map(i=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:i}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof r[i]=="object"?JSON.stringify(r[i]):String(r[i])})]},i))})]})}function wc(e,r){return r?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),r.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",r.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:gu,children:m1(e,r.data??{}).map(({label:a,value:i})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:i})]},a))}),p1(e,r.data??{})]})]}):null}function g1({report:e,elementId:r,ticketParam:a,onClose:i,onSelectTicket:l}){var j;const u=e.elements.find(x=>x.id===r),d=ZN(u,a),p=d?e.ticketDetails[d]:void 0,m=d1(u),v=(j=e.proof.verifiedValues.find(x=>x.elementId===r))==null?void 0:j.summary,y=h.useRef(null);return h.useEffect(()=>{const x=y.current;if(!x||typeof x.getBoundingClientRect!="function")return;const S=x.getBoundingClientRect().top;(S<0||S>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[r,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),m.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:m.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===d?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===d,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!d&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:gu,children:Object.keys(u.data??{}).map(x=>{const S=QN(x,u.data??{});return S===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:S})]},x)})})),p&&n.jsxs(n.Fragment,{children:[wc("Ticket",p.ticket),wc("Mandate",p.mandate),wc("Approval",p.approval)]}),d&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",d,"."]})]})}async function y1(e){const{html:r,filename:a}=await e.exportReport();e.download(r,a),await e.refresh()}function bm({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function v1({report:e,open:r,selectedId:a,onOpenElement:i,detail:l}){const{proof:u,coverage:d}=e,p=u1(e.elements),m=XN(d),v=KN(d),y=YN(d),j=jm(u.signaturesValid),x=jm(u.recordsChecked);return n.jsxs("div",{className:`reports-side${r?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:j.kind==="ok"?"msg-ok":void 0,children:j.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),children:[n.jsx("span",{children:S.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(bm,{detail:v.detail})]}):n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Cases"}),n.jsx("b",{children:v.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets in test period"}),n.jsxs("b",{children:[d.ticketsReferenced.length," of ",d.ticketsInPeriod.length]})]}),y&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:y.detail?"reports-error":"reports-note",role:y.detail?"alert":void 0,children:y.text}),n.jsx(bm,{detail:y.detail})]}),m&&n.jsx("p",{className:"reports-missing",children:m})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(S=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===S.elementId?" reports-row-selected":""}`,onClick:()=>i(S.elementId),title:"Show details",children:[n.jsx("span",{children:S.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},S.elementId))]})]})}function x1(){const[e,r]=h.useState(null),[a,i]=h.useState(!0),[l,u]=h.useState(null),[d,p]=h.useState(!1),[m,v]=h.useState(!1),[y,j]=h.useState(null),[x,S]=h.useState(!1),[N,b]=h.useState(!1),[k,C]=ks(),E=h.useCallback(()=>P.getReport().then(({report:U})=>r(U)).catch(U=>u(U instanceof Error?U.message:String(U))),[]),R=h.useCallback(()=>{i(!0),u(null),E().finally(()=>i(!1))},[E]);h.useEffect(()=>{R()},[R]),h.useEffect(()=>{e&&P.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const A=h.useCallback(()=>{p(!0),P.recheckReport().then(({report:U})=>r(U)).catch(U=>u(U instanceof Error?U.message:String(U))).finally(()=>p(!1))},[]),z=h.useCallback(async()=>{v(!0),j(null);try{await y1({exportReport:()=>P.exportReportWithProof(),download:(U,K)=>{const ce=URL.createObjectURL(new Blob([U],{type:"text/html"})),ee=document.createElement("a");ee.href=ce,ee.download=K,ee.click(),URL.revokeObjectURL(ce)},refresh:E})}catch(U){j(U instanceof Error?U.message:String(U))}finally{v(!1)}},[E]),M=k.get("element"),H=k.get("ticket"),te=h.useCallback((U,K)=>{C(l1(k,U,K))},[k,C]),X=h.useCallback(()=>{const U=new URLSearchParams(k);U.delete("element"),U.delete("ticket"),C(U,{replace:!0})},[k,C]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(js,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const L=HN(e.renderedHtml),q=VN(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:L}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Gi(e.coverage).title,children:[n.jsx("b",{children:Gi(e.coverage).text})," · written ",hp(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[q?`written by the AI under mandate ${q} · `:"","checked ",GN(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:A,disabled:d,children:d?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:z,disabled:m,children:m?"Exporting…":"Export with proof"})]})]}),y&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:qN(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>S(U=>!U),children:x?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),n1]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),r1," (“",t1,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",s1]})]}),wm(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:wm(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:N,onChange:U=>b(U.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:a1})]}),n.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),i1(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:e1,srcDoc:f1(o1(e,N)),className:"reports-iframe"})]}),n.jsx(v1,{report:e,open:x||!!M,selectedId:M,onOpenElement:U=>te(U),detail:M?n.jsx(g1,{report:e,elementId:M,ticketParam:H,onClose:X,onSelectTicket:U=>te(M,U)}):void 0})]})]})})}function ms({to:e}){const{search:r,hash:a}=en();return n.jsx(Gn,{to:`${e}${r}${a}`,replace:!0})}function j1({children:e}){const{user:r,mode:a,domain:i}=kt();return r?a==="team"&&!i?n.jsx(Gn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(Gn,{to:"/login",replace:!0})}function w1(){const{user:e,handleSessionLocked:r,refreshGroups:a}=kt();return He("session-locked",i=>{const l=i==null?void 0:i.message;r(l)}),He("team-membership-changed",()=>{a()}),n.jsxs(Wx,{children:[n.jsx(ht,{path:"/login",element:e?n.jsx(Gn,{to:"/",replace:!0}):n.jsx(ww,{})}),n.jsx(ht,{path:"/onboarding",element:e?n.jsx(Ew,{}):n.jsx(Gn,{to:"/login",replace:!0})}),n.jsxs(ht,{element:n.jsx(j1,{children:n.jsx(xw,{})}),children:[n.jsx(ht,{path:"/",element:n.jsx(Tb,{})}),n.jsx(ht,{path:"/mandates",element:n.jsx(qS,{})}),n.jsx(ht,{path:"/mandates/new/intent",element:n.jsx(aS,{})}),n.jsx(ht,{path:"/mandates/new/sign",element:n.jsx(jS,{})}),n.jsx(ht,{path:"/integrations",element:n.jsx(ES,{})}),n.jsx(ht,{path:"/team",element:n.jsx(TS,{})}),n.jsx(ht,{path:"/tickets",element:n.jsx(Gk,{})}),n.jsx(ht,{path:"/blocked",element:n.jsx(qk,{})}),n.jsx(ht,{path:"/approvals",element:n.jsx(zN,{})}),n.jsx(ht,{path:"/reports",element:n.jsx(x1,{})}),n.jsx(ht,{path:"/agent/new",element:n.jsx(Gn,{to:"/mandates?new=1",replace:!0})}),n.jsx(ht,{path:"/agent/gate",element:n.jsx(ms,{to:"/mandates/new/intent"})}),n.jsx(ht,{path:"/agent/review",element:n.jsx(ms,{to:"/mandates/new/sign"})}),n.jsx(ht,{path:"/authorizations",element:n.jsx(ms,{to:"/mandates"})}),n.jsx(ht,{path:"/groups",element:n.jsx(ms,{to:"/team"})}),n.jsx(ht,{path:"/audit",element:n.jsx(ms,{to:"/tickets"})}),n.jsx(ht,{path:"/proposals",element:n.jsx(ms,{to:"/approvals"})}),n.jsx(ht,{path:"/agent-brief",element:n.jsx(WN,{})}),n.jsx(ht,{path:"/settings",element:n.jsx(sN,{})}),n.jsx(ht,{path:"/settings/services",element:n.jsx(Gn,{to:"/settings",replace:!0})}),n.jsx(ht,{path:"/deploy",element:n.jsx(Gn,{to:"/integrations",replace:!0})})]}),n.jsx(ht,{path:"*",element:n.jsx(Gn,{to:"/",replace:!0})})]})}function b1(){return n.jsx(mj,{children:n.jsx(Rj,{children:n.jsx(_j,{children:n.jsx(w1,{})})})})}Bv.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(b1,{})}));
|