@lpdjs/firestore-repo-service 3.0.15 → 3.0.17

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.
Files changed (37) hide show
  1. package/dist/{create-servers-p1-jJNTG.d.ts → create-servers-BQ7pxnG0.d.ts} +2 -2
  2. package/dist/{create-servers-B5Z5v2SP.d.cts → create-servers-DKg5Yg2d.d.cts} +2 -2
  3. package/dist/effects-B8aIXMZ2.d.ts +158 -0
  4. package/dist/effects-CqJSneNZ.d.cts +158 -0
  5. package/dist/index.cjs +92 -92
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +4 -4
  8. package/dist/index.d.ts +4 -4
  9. package/dist/index.js +92 -92
  10. package/dist/index.js.map +1 -1
  11. package/dist/llms-full.txt +110 -2
  12. package/dist/llms.txt +1 -1
  13. package/dist/servers/admin/index.cjs +4 -4
  14. package/dist/servers/admin/index.cjs.map +1 -1
  15. package/dist/servers/admin/index.d.cts +2 -2
  16. package/dist/servers/admin/index.d.ts +2 -2
  17. package/dist/servers/admin/index.js +4 -4
  18. package/dist/servers/admin/index.js.map +1 -1
  19. package/dist/servers/crud/index.cjs +2 -2
  20. package/dist/servers/crud/index.cjs.map +1 -1
  21. package/dist/servers/crud/index.d.cts +4 -5
  22. package/dist/servers/crud/index.d.ts +4 -5
  23. package/dist/servers/crud/index.js +2 -2
  24. package/dist/servers/crud/index.js.map +1 -1
  25. package/dist/servers/index.cjs +101 -101
  26. package/dist/servers/index.cjs.map +1 -1
  27. package/dist/servers/index.d.cts +4 -5
  28. package/dist/servers/index.d.ts +4 -5
  29. package/dist/servers/index.js +101 -101
  30. package/dist/servers/index.js.map +1 -1
  31. package/dist/{types-BGh5_2fl.d.cts → types-DgzPoPvx.d.cts} +360 -47
  32. package/dist/{types-Cc6lelk1.d.ts → types-wMBgnYjH.d.ts} +360 -47
  33. package/package.json +1 -1
  34. package/dist/openapi-B9utXiEH.d.cts +0 -70
  35. package/dist/openapi-Bsqq2zgh.d.ts +0 -70
  36. package/dist/rules-18wH7Uak.d.ts +0 -30
  37. package/dist/rules-oSXoV4Js.d.cts +0 -30
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.15) — full documentation
1
+ # @lpdjs/firestore-repo-service (v3.0.17) — full documentation
2
2
 
3
3
  > ⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.
4
4
 
@@ -1316,6 +1316,7 @@ Send complex filter conditions including `where` (AND), `orWhere` (simple OR), a
1316
1316
  | `middlewares` | `MiddlewareHandler[]` | Custom Hono middleware array |
1317
1317
  | `repos` | `Record<string, CrudRepoConfig>` | Per-repository configuration mapping |
1318
1318
  | `indexesError` | `(err: { repoName, error, indexUrl, c }) => void` | Callback triggered when a Firestore missing-index error occurs |
1319
+ | `onHookError` | `(ctx: CrudHookErrorContext) => void \| Promise<void>` | Callback invoked when a post-write hook (or `changesNeeded` follow-up update) throws |
1319
1320
  | `openapi` | `OpenAPISpecOptions` | OpenAPI 3.1 documentation settings |
1320
1321
  | `verbose` | `boolean` | Include detailed error messages in HTTP 500 responses |
1321
1322
 
@@ -1330,7 +1331,8 @@ Send complex filter conditions including `where` (AND), `orWhere` (simple OR), a
1330
1331
  | `orderableFields` | `string[]` | List of allowed fields for ordering |
1331
1332
  | `allowedIncludes` | `string[]` | List of relation keys allowed in `includes` |
1332
1333
  | `allowDelete` | `boolean` | Whether `DELETE /:id` is enabled |
1333
- | `rules` | `CrudRule[]` | Before rules & diff engine for mutation validation |
1334
+ | `rules` | `CrudRules<TRepo>` | Per-operation authorization, before-rules & `preWrite` mutations |
1335
+ | `hooks` | `CrudHooks<TRepo>` | Post-write lifecycle hooks (`afterCreate`, `afterUpdate`, `afterDelete`, `afterBatch`) |
1334
1336
  | `pageSize` | `number` | Default page size for list requests |
1335
1337
 
1336
1338
  ---
@@ -1372,6 +1374,112 @@ If a rule returns `false` or a string error message, the mutation is rejected wi
1372
1374
 
1373
1375
  ---
1374
1376
 
1377
+ ## Lifecycle Hooks, Mutations & Effects (`hooks`)
1378
+
1379
+ While `rules` govern authorization and before-validation checks, `hooks` manage both **pre-write mutations** and **post-write reactive side effects** with full model type inference from each repository:
1380
+
1381
+ - **`beforeCreate`** (`POST /:repoName` & batch `create`): runs after validation and `rules.create`. Mutate `ctx.body` in place to normalize or inject server-derived fields.
1382
+ - **`beforeUpdate`** (`PUT/PATCH /:repoName/:id` & batch `update`): runs after validation and `rules.update`. Mutate `ctx.body` in place; `diff` is **recomputed afterward** so mutated fields are captured by `afterUpdate` / `afterBatch`.
1383
+ - **`afterCreate`** (`POST /:repoName`): receives `{ user, doc, id, pathArgs, params, c }`. May optionally return a non-empty `Partial<T>` to patch the newly created document via `repo.update(...pathArgs, changes)` and return the patched document in the HTTP 201 response.
1384
+ - **`afterUpdate`** (`PUT/PATCH /:repoName/:id`): receives `{ user, before, after, body, diff, id, pathArgs, params, c }`. The `diff` is **recomputed after `rules.update` and `beforeUpdate`**, so fields added or modified during pre-write are present in `diff.changes` and `diff.after`. May optionally return a non-empty `Partial<T>` to apply follow-up changes to the current document and return the final document in the HTTP 200 response.
1385
+ - **`afterDelete`** (`DELETE /:repoName/:id`): receives `{ user, doc, id, pathArgs, params, c }` where `doc` is the snapshot captured prior to deletion.
1386
+ - **`afterBatch`** (`POST /:repoName/batch`): called **once after `batch.commit()`** with `{ user, created, updated, deleted, params, c }` (each `updated` item carries its `diff` recomputed after pre-write mutations). If `afterBatch` is omitted, the server automatically falls back to invoking `afterCreate` / `afterUpdate` / `afterDelete` sequentially on each committed item.
1387
+ - **`onAfterError`**: per-repo error callback `(err, phase) => void` invoked when any `after*` hook fails (in addition to server-wide `onHookError`).
1388
+
1389
+ ### Built-in helpers (`mutations` & `effects`)
1390
+
1391
+ Aligned with `createRules` / `applyRules` / `createBeforeRules`, the package exports declarative builders ready to plug into `hooks`:
1392
+
1393
+ - **Pre-write mutations**: `createMutations`, `applyMutations`, `createBeforeCreateMutations`, `createBeforeUpdateMutations` (indexed by model field key plus `"*"` wildcard, with optional `operations: ["create"] | ["update"]` filter).
1394
+ - **Post-write effects**: `createEffects`, `applyEffects`, `createAfterUpdateEffects` (indexed by model field key plus `"*"` wildcard, with isolated per-rule error capture via `onRuleError` and automatic `changesNeeded` aggregation).
1395
+
1396
+ ```typescript
1397
+ import {
1398
+ createAfterUpdateEffects,
1399
+ createBeforeCreateMutations,
1400
+ createBeforeUpdateMutations,
1401
+ createEffects,
1402
+ createMutations,
1403
+ withActor,
1404
+ } from "@lpdjs/firestore-repo-service";
1405
+
1406
+ const eventMutations = createMutations<PreventionEvent>({
1407
+ proId: [
1408
+ {
1409
+ description: "Auto-accept when a pro is assigned",
1410
+ operations: ["update"],
1411
+ mutation: ({ body, diff }) => {
1412
+ if (diff.changes.proId) {
1413
+ body.status = "accepted";
1414
+ body.publicationStatus = "toRepublish";
1415
+ }
1416
+ },
1417
+ },
1418
+ ],
1419
+ "*": [
1420
+ ({ body }) => {
1421
+ if (typeof body.title === "string") body.title = body.title.trim();
1422
+ },
1423
+ ],
1424
+ });
1425
+
1426
+ const eventEffects = createEffects<PreventionEvent, { after: PreventionEvent }>({
1427
+ status: [
1428
+ {
1429
+ description: "Notify when accepted",
1430
+ rule: ({ diff }) => diff.changes.status === "accepted",
1431
+ handler: async ({ after }) => {
1432
+ await notifyAssignment(after);
1433
+ return { notifiedAt: new Date() }; // optional follow-up patch
1434
+ },
1435
+ },
1436
+ ],
1437
+ });
1438
+
1439
+ export const api = servers.crud({
1440
+ basePath: "/api",
1441
+ onHookError: ({ hook, repoName, id, error }) => {
1442
+ logger.error(`[CRUD ${hook}] failed on ${repoName}/${id ?? "batch"}`, error);
1443
+ },
1444
+ repos: {
1445
+ preventionEvents: {
1446
+ path: "prevention/prev_rules/prev_workshops/{workshopId}/prev_events",
1447
+ hooks: {
1448
+ beforeCreate: createBeforeCreateMutations(eventMutations),
1449
+ beforeUpdate: createBeforeUpdateMutations(eventMutations),
1450
+ afterUpdate: createAfterUpdateEffects(
1451
+ eventEffects,
1452
+ (ctx) => ({ after: ctx.after }),
1453
+ {
1454
+ onRuleError: (r) =>
1455
+ logger.error(`[afterUpdate] Effect failed: ${r.description}`, r.error),
1456
+ },
1457
+ ),
1458
+ afterBatch: async ({ updated }) => {
1459
+ // Runs ONCE after batch.commit() — ideal for deduplicating recalculations
1460
+ const workshopIds = new Set(updated.map((u) => u.pathArgs[0]));
1461
+ await withActor({ userId: "system" }, async () => {
1462
+ for (const wid of workshopIds) {
1463
+ await recalculateWorkshop(wid);
1464
+ }
1465
+ });
1466
+ },
1467
+ onAfterError: (err, phase) => {
1468
+ logger.error(`[preventionEvents:${phase}]`, err);
1469
+ },
1470
+ },
1471
+ },
1472
+ },
1473
+ });
1474
+ ```
1475
+
1476
+ **Execution guarantees:**
1477
+ - Every hook is **`await`ed before sending the HTTP response** (safe on Cloud Functions v2, where CPU is throttled once the response finishes).
1478
+ - Post-write hook errors (and errors from follow-up `changesNeeded` patches) are **caught and routed to `hooks.onAfterError` / `onHookError`** (falling back to the Hono `logger` or `console.error`) so a committed write never returns a misleading HTTP 500.
1479
+ - The `actorResolver` `AsyncLocalStorage` scope remains active during hook execution: cascading repository writes automatically inherit the HTTP actor's `_historyMeta`, or can override it with `withActor({ userId: "system" }, ...)`.
1480
+
1481
+ ---
1482
+
1375
1483
  ## Missing Index Detection (`indexesError` & HTTP 424)
1376
1484
 
1377
1485
  When a complex filter or compound query requires a composite index that has not yet been built in Firestore, the CRUD server automatically catches the Firestore `FAILED_PRECONDITION` error:
package/dist/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # @lpdjs/firestore-repo-service (v3.0.15)
1
+ # @lpdjs/firestore-repo-service (v3.0.17)
2
2
 
3
3
  > ⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.
4
4
 
@@ -1,4 +1,4 @@
1
- 'use strict';var jsxRuntime=require('hono/jsx/jsx-runtime'),zod=require('zod'),crypto=require('crypto'),server=require('hono/jsx/dom/server');var Yt=Object.defineProperty;var Ie=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var en=(e,t)=>{for(var n in t)Yt(e,n,{get:t[n],enumerable:true});};function L(e){let t=e,n=t._zod?.def?.type;if(n)return an[n]??`Zod${n.charAt(0).toUpperCase()}${n.slice(1)}`;let r=t._def?.typeName;return r||""}function X(e){let t=e;if(t._zod?.def?.innerType)return t._zod.def.innerType;if(t._def?.innerType)return t._def.innerType}function ke(e){let t=e,n=t._zod?.def?.in;if(n)return n;if(t._def?.schema)return t._def.schema}function gt(e){let t=e;if(t._zod?.def?.element)return t._zod.def.element;if(t._def?.type)return t._def.type}function bt(e){let t=e;if(t._zod?.def?.defaultValue!==void 0)return t._zod.def.defaultValue;let n=t._def?.defaultValue;return typeof n=="function"?n():n}function Y(e){let t=e;return t.shape&&typeof t.shape=="object"?t.shape:t._zod?.def?.shape&&typeof t._zod.def.shape=="object"?t._zod.def.shape:t._def?.shape?typeof t._def.shape=="function"?t._def.shape():t._def.shape:{}}function Se(e){let t=e;return Array.isArray(t.options)?t.options:t._zod?.def?.entries?Object.values(t._zod.def.entries):Array.isArray(t._def?.values)?t._def.values:[]}function Ae(e){let t=e;return t._zod?.def?.entries?t._zod.def.entries:t.enum&&typeof t.enum=="object"?t.enum:t._def?.values&&typeof t._def.values=="object"?t._def.values:{}}function Re(e){let t=e;return Array.isArray(t._zod?.def?.values)?t._zod.def.values[0]:t._def?.value}function $e(e){let t=e;return Array.isArray(t.options)?t.options:Array.isArray(t._zod?.def?.options)?t._zod.def.options:Array.isArray(t._def?.options)?t._def.options:[]}function vt(e){let t=e,n=[],r=t._zod?.def?.checks;if(Array.isArray(r)){for(let o of r)o.format&&n.push(o.format);if(n.length>0)return n}let a=t._def?.checks;if(Array.isArray(a))for(let o of a)o.kind&&n.push(o.kind);return n}var an,Ne=Ie(()=>{"use strict";an={string:"ZodString",number:"ZodNumber",bigint:"ZodBigInt",boolean:"ZodBoolean",date:"ZodDate",enum:"ZodEnum",nativeEnum:"ZodNativeEnum",literal:"ZodLiteral",object:"ZodObject",array:"ZodArray",optional:"ZodOptional",nullable:"ZodNullable",default:"ZodDefault",coerce:"ZodCoerce",union:"ZodUnion",undefined:"ZodUndefined",unknown:"ZodUnknown",any:"ZodAny",record:"ZodRecord"};});function Ct({val:e}){return jsxRuntime.jsx("span",{class:"text-sm text-base-content/80 font-mono tabular-nums whitespace-nowrap",children:e.toLocaleString()})}function yn({message:e}){return jsxRuntime.jsx("span",{class:"tooltip tooltip-warning tooltip-right inline-flex align-middle ml-1 text-warning","data-tip":e,role:"img","aria-label":e,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:"size-3.5",children:jsxRuntime.jsx("path",{d:"M12 2 1 22h22L12 2zm0 6 7.5 13h-15L12 8zm-1 4v4h2v-4h-2zm0 5v2h2v-2h-2z"})})})}function be({val:e,mismatch:t}){let n=Xe(e);return t?jsxRuntime.jsxs("span",{class:"inline-flex items-start gap-0.5",children:[n,jsxRuntime.jsx(yn,{message:t})]}):n}function Xe(e){if(e==null)return jsxRuntime.jsx("span",{class:"opacity-30 italic text-xs",children:"\u2014"});if(typeof e=="boolean")return e?jsxRuntime.jsx("span",{class:"badge badge-success badge-sm",children:"true"}):jsxRuntime.jsx("span",{class:"badge badge-error badge-sm",children:"false"});if(e instanceof Date)return jsxRuntime.jsx(Ct,{val:e});if(typeof e=="object"&&e!==null&&typeof e.toDate=="function")return jsxRuntime.jsx(Ct,{val:e.toDate()});if(typeof e=="number")return jsxRuntime.jsx("span",{class:"text-sm font-mono tabular-nums",children:String(e)});if(Array.isArray(e))return e.length===0?jsxRuntime.jsx("span",{class:"text-xs text-base-content/30",children:"[]"}):jsxRuntime.jsxs("ul",{class:"list-none p-0 m-0 space-y-0.5 text-xs",children:[e.slice(0,8).map((n,r)=>jsxRuntime.jsx("li",{class:"break-all",children:Xe(n)},r)),e.length>8&&jsxRuntime.jsxs("li",{class:"text-base-content/40 italic",children:["+",e.length-8," more\u2026"]})]});if(typeof e=="object"&&e!==null){let n=Object.entries(e);return n.length===0?jsxRuntime.jsx("span",{class:"text-xs text-base-content/30",children:"{}"}):jsxRuntime.jsxs("dl",{class:"grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5 text-xs m-0",children:[n.slice(0,8).map(([r,a])=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("dt",{class:"text-base-content/50 font-semibold whitespace-nowrap",children:r}),jsxRuntime.jsx("dd",{class:"break-all",children:Xe(a)})]})),n.length>8&&jsxRuntime.jsxs("dt",{class:"col-span-2 text-base-content/40 italic",children:["+",n.length-8," more\u2026"]})]})}let t=String(e);return jsxRuntime.jsx("span",{class:"text-sm break-all",children:t})}var Fe=Ie(()=>{"use strict";});function Ce(e){if(!e)return "unknown";let t=Ye(e);switch(L(t)){case "ZodString":return "string";case "ZodNumber":return "number";case "ZodBigInt":return "bigint";case "ZodBoolean":return "boolean";case "ZodDate":return "date";case "ZodArray":return "array";case "ZodObject":case "ZodRecord":return "object";case "ZodEnum":case "ZodNativeEnum":return "enum";case "ZodLiteral":return "literal";default:return "unknown"}}function Ye(e){let t=L(e);if(t==="ZodOptional"||t==="ZodNullable"||t==="ZodDefault"){let n=X(e);return n?Ye(n):e}return e}function Ee(e,t){if(!e)return;let n=t.split("."),r=e;for(let a of n){if(!r)return;let o=Ye(r);if(L(o)!=="ZodObject")return;r=Y(o)[a];}return r}function xn(e){return e==null?"null":e instanceof Date?"date":Array.isArray(e)?"array":typeof e=="string"?"string":typeof e=="boolean"?"boolean":typeof e=="bigint"?"bigint":typeof e=="number"?"number":typeof e=="object"?typeof e.toDate=="function"?"date":"object":"unknown"}function Te(e,t){if(e==="unknown")return null;let n=xn(t);return n==="null"?null:e==="enum"||e==="literal"?n==="string"||n==="number"?null:`Expected ${e} (string/number), got ${n}`:e===n||e==="number"&&n==="bigint"||e==="bigint"&&n==="number"?null:`Expected ${e}, got ${n}`}var et=Ie(()=>{"use strict";Ne();});var Ot={};en(Ot,{PanelMany:()=>kn,PanelOne:()=>wn,RightPanel:()=>tt});function wn({doc:e,repoName:t,basePath:n,schema:r,columns:a}){if(!e)return jsxRuntime.jsx("div",{class:"text-center py-12 text-base-content/50",children:"Document not found."});let o=String(e.docId??e.id??""),s=`${n}/${t}/${encodeURIComponent(o)}/edit`,c=Tt(r,a);return jsxRuntime.jsxs("div",{class:"space-y-4",children:[jsxRuntime.jsxs("div",{class:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{class:"text-xs text-base-content/60",children:[jsxRuntime.jsx("span",{class:"font-mono",children:t}),jsxRuntime.jsx("span",{class:"opacity-50",children:" \xB7 "}),jsxRuntime.jsx("span",{class:"font-mono break-all",children:o})]}),jsxRuntime.jsx("a",{href:s,class:"btn btn-sm btn-primary",children:"Edit \u2192"})]}),jsxRuntime.jsx("dl",{class:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-2 border border-base-300 rounded-box p-4 bg-base-100",children:a.map(l=>{let p=e[l],f=c[l],h=f?Te(f,p):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("dt",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide pt-0.5",children:l}),jsxRuntime.jsx("dd",{class:"min-w-0",children:jsxRuntime.jsx(be,{val:p,mismatch:h})})]})})})]})}function kn({docs:e,repoName:t,basePath:n,fk:r,fv:a,columns:o,schema:s,pagination:c}){let l=`${n}/${t}?fv_${r}=${encodeURIComponent(a)}`,p=Tt(s,o);return jsxRuntime.jsxs("div",{class:"space-y-4",children:[jsxRuntime.jsxs("div",{class:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{class:"text-xs text-base-content/60",children:[jsxRuntime.jsx("span",{class:"font-mono",children:t}),jsxRuntime.jsx("span",{class:"opacity-50",children:" where "}),jsxRuntime.jsx("span",{class:"font-mono",children:r}),jsxRuntime.jsx("span",{class:"opacity-50",children:" = "}),jsxRuntime.jsx("span",{class:"font-mono break-all",children:a}),jsxRuntime.jsx("span",{class:"opacity-50",children:" \xB7 "}),jsxRuntime.jsxs("span",{children:[e.length," doc",e.length!==1?"s":""]})]}),jsxRuntime.jsx("a",{href:l,class:"btn btn-sm btn-outline",children:"Full view \u2192"})]}),jsxRuntime.jsx("div",{class:"overflow-x-auto rounded-box border border-base-300 bg-base-100",children:jsxRuntime.jsxs("table",{class:"table table-xs w-full",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{class:"bg-base-200/50",children:[o.map((f,h)=>jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:f},h)),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:e.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colspan:o.length+1,class:"text-center py-10 text-base-content/40",children:"No related documents"})}):e.map((f,h)=>{let g=String(f.docId??f.id??""),S=`${n}/${t}/${encodeURIComponent(g)}/edit`;return jsxRuntime.jsxs("tr",{class:"hover",children:[o.map((y,F)=>{let Z=f[y],B=p[y],U=B?Te(B,Z):null;return jsxRuntime.jsx("td",{class:"align-top py-1.5",children:jsxRuntime.jsx(be,{val:Z,mismatch:U})},F)}),jsxRuntime.jsx("td",{class:"text-right py-1.5",children:jsxRuntime.jsx("a",{href:S,class:"btn btn-xs btn-ghost",children:"Edit"})})]},h)})})]})}),(c.hasPrev||c.hasNext)&&jsxRuntime.jsxs("div",{class:"flex justify-center items-center gap-2",children:[c.hasPrev?jsxRuntime.jsx("button",{type:"button",class:"btn btn-xs btn-outline","data-frs-panel-page":"prev","data-cursor":c.prevCursor,children:"\u2190 Previous"}):jsxRuntime.jsx("button",{class:"btn btn-xs btn-outline",disabled:true,children:"\u2190 Previous"}),c.hasNext?jsxRuntime.jsx("button",{type:"button",class:"btn btn-xs btn-outline","data-frs-panel-page":"next","data-cursor":c.nextCursor,children:"Next \u2192"}):jsxRuntime.jsx("button",{class:"btn btn-xs btn-outline",disabled:true,children:"Next \u2192"})]})]})}function Tt(e,t){if(!e)return {};let n={};for(let r of t)n[r]=Ce(Ee(e,r));return n}var tt,nt=Ie(()=>{"use strict";Fe();et();tt=({basePath:e=""})=>jsxRuntime.jsxs("div",{class:"fixed inset-0 z-[100] hidden pointer-events-none","data-frs-panel-root":!0,"data-frs-base-path":e,"aria-hidden":"true",children:[jsxRuntime.jsx("div",{class:"absolute inset-0 bg-black/30 opacity-0 transition-opacity duration-200 pointer-events-auto","data-frs-panel-backdrop":!0}),jsxRuntime.jsxs("aside",{class:"absolute top-0 right-0 h-full w-full md:w-1/2 bg-base-100 shadow-2xl border-l border-base-300 translate-x-full transition-transform duration-200 pointer-events-auto flex flex-col","data-frs-panel":!0,role:"dialog","aria-label":"Relation preview",children:[jsxRuntime.jsxs("header",{class:"flex items-center justify-between px-5 py-3 border-b border-base-300 bg-base-200/40 shrink-0",children:[jsxRuntime.jsx("h2",{class:"font-semibold text-base truncate","data-frs-panel-title":!0,children:"Relation"}),jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-ghost btn-circle","data-frs-panel-close":!0,"aria-label":"Close panel",children:"\u2715"})]}),jsxRuntime.jsx("div",{class:"flex-1 overflow-auto p-5 text-sm","data-frs-panel-body":!0,children:jsxRuntime.jsx("div",{class:"flex items-center justify-center py-12 text-base-content/40",children:jsxRuntime.jsx("span",{class:"loading loading-spinner loading-md"})})})]})]});});function He(e,t,n){let r=t==="/"?"":t.replace(/\/$/,"");if(process.env.FUNCTIONS_EMULATOR==="true"){let s=process.env.GCLOUD_PROJECT??process.env.GOOGLE_CLOUD_PROJECT??"demo-project",c=n??process.env.FUNCTION_REGION??"us-central1",l=(process.env.FUNCTION_TARGET??"").replace(/\./g,"-");return `/${s}/${c}/${l}${r}`}let a=process.env.K_SERVICE,o=e?.hostname??e?.headers?.host??"";return a&&typeof o=="string"&&o.includes("cloudfunctions.net")?`/${a.toLowerCase()}${r}`:r}function pt(e){if(typeof e=="string")return e;if(Array.isArray(e)){let t=e[0];return typeof t=="string"?t:void 0}}function qe(e){return !!e&&typeof e=="object"&&e.__authExtension===true}var Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function ft(){let e="";for(;e.length<20;){let t=crypto.randomBytes(20);for(let n=0;n<t.length&&e.length<20;n++){let r=t[n];r>=Ve.length*4||(e+=Ve.charAt(r%Ve.length));}}return e}function mt(e){return e.match(/^\{([^}]+)\}$/)?.[1]?.trim()||null}function ht(e,t="docId",n=false){if(typeof e!="string"||!e.trim())return {rawPath:e??"",collectionId:"",collectionPath:"",parentKeys:[],documentPathTemplate:null,hasTemplate:false};let r=e.split("/").map(h=>h.trim()).filter(Boolean);if(r.length===0)return {rawPath:e,collectionId:e,collectionPath:e,parentKeys:[],documentPathTemplate:null,hasTemplate:false};if(r.length===1){let h=r[0];return {rawPath:e,collectionId:h,collectionPath:h,parentKeys:[],documentPathTemplate:n?null:`${h}/{${t}}`,hasTemplate:e.includes("{")&&e.includes("}")}}let a=r.length%2===0,o=a?r.slice(0,-1):r,s=o[o.length-1],c=o.join("/"),p=o.slice(0,-1).map(mt).filter(h=>h!==null),f=a?r.join("/"):`${c}/{${t}}`;return {rawPath:e,collectionId:s,collectionPath:c,parentKeys:p,documentPathTemplate:f,hasTemplate:true}}function yt(e,t={}){if(!e||typeof e!="object")return;let{pathKey:n,documentKey:r="docId",parentKeys:a,documentPathTemplate:o,isGroup:s}=t,c=n&&typeof e[n]=="string"&&e[n]?e[n]:void 0;if(c&&o){let l=c.split("/").filter(Boolean),p=o.split("/").filter(Boolean);if(l.length===p.length){let f=[];for(let h=0;h<p.length;h++)mt(p[h])!==null&&f.push(l[h]);if(f.length>0)return f}}if(a&&a.length>0){let l=a.length+1;if(c){let f=c.split("/").filter(Boolean),h=[];for(let g=1;g<f.length;g+=2)h.push(f[g]);if(h.length>=l)return h.slice(h.length-l)}let p=r?e[r]:void 0;if(typeof p=="string"&&p.trim()!==""){let f=[],h=true;for(let g of a){let S=e[g];if(typeof S=="string"&&S.trim()!=="")f.push(S);else {h=false;break}}if(h)return [...f,p]}}if(c){let l=c.split("/").filter(Boolean),p=[];for(let f=1;f<l.length;f+=2)p.push(l[f]);if(p.length>0)return !s&&(!a||a.length===0)?[p[p.length-1]]:p}}Ne();Ne();function on(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/^\s/,"").replace(/^./,t=>t.toUpperCase())}function xt(e){let t=e,n=true,r=false,a;for(;;){let o=L(t);if(o==="ZodOptional")n=false,t=X(t);else if(o==="ZodNullable")n=false,r=true,t=X(t);else if(o==="ZodDefault")n=false,a=bt(t),t=X(t);else if(o==="ZodEffects"||o==="ZodPipe"||o==="ZodTransform"){let s=ke(t);if(!s)break;t=s;}else break}return {inner:t,required:n,nullable:r,defaultValue:a}}function ee(e,t=""){if(L(e)==="ZodObject"){let r=Y(e);return Object.entries(r).map(([a,o])=>wt(t?`${t}.${a}`:a,a,o))}return [wt(t||"value",t||"value",e)]}function wt(e,t,n){let{inner:r,required:a,nullable:o,defaultValue:s}=xt(n),c=L(r),l=on(t.split(".").pop()??t);switch(c){case "ZodString":{let p=vt(r),f=p.includes("email"),h=p.includes("url");return {name:e,label:l,type:"text",required:a,nullable:o,defaultValue:s,hint:f?"email":h?"url":void 0}}case "ZodNumber":case "ZodBigInt":return {name:e,label:l,type:"number",required:a,nullable:o,defaultValue:s};case "ZodBoolean":return {name:e,label:l,type:"checkbox",required:a,nullable:o,defaultValue:s};case "ZodDate":case "ZodCoerce":return {name:e,label:l,type:"datetime-local",required:a,nullable:o,defaultValue:s};case "ZodEnum":{let p=Se(r);return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:p}}case "ZodNativeEnum":{let p=Ae(r),f=Object.values(p).filter(h=>typeof h=="string");return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:f}}case "ZodLiteral":{let p=String(Re(r)??"");return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:[p]}}case "ZodUnion":{let p=$e(r);if(p.length>0&&p.every(S=>L(S)==="ZodLiteral")){let S=p.map(y=>String(Re(y)??""));return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:S}}if(p.some(S=>L(S)==="ZodDate"))return {name:e,label:l,type:"datetime-local",required:a,nullable:o,defaultValue:s};let g=p.find(S=>{if(L(S)==="ZodObject"){let y=Y(S);return "_latitude"in y&&"_longitude"in y||"latitude"in y&&"longitude"in y}return false});return g?{name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,nested:ee(g,e),hint:"GeoPoint"}:{name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON"}}case "ZodObject":{let p=ee(r,e);return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,nested:p,hint:"JSON object"}}case "ZodArray":{let p=gt(r);if(!p)return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON array"};let{inner:f}=xt(p),h=L(f),g,S,y;switch(h){case "ZodString":g="text";break;case "ZodNumber":case "ZodBigInt":g="number";break;case "ZodBoolean":g="checkbox";break;case "ZodDate":g="datetime-local";break;case "ZodEnum":g="select",S=Se(f);break;case "ZodNativeEnum":g="select",S=Object.values(Ae(f)).filter(F=>typeof F=="string");break;case "ZodObject":g="object",y=ee(f);break;default:return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON array"}}return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,arrayElementType:g,arrayElementOptions:S,arrayElementFields:y}}default:return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON"}}}function Ze(e,t=0){let n=t>0?`ml-${t*4}`:"",r=`field_${e.name.replace(/\./g,"__")}`,a=e.name,o=e.required?" required":"",s=e.defaultValue==="__null__",c=!s&&e.defaultValue!=null?String(e.defaultValue):"",l=e.nullable&&e.type!=="checkbox"?`<span class="flex items-center gap-1 shrink-0">
1
+ 'use strict';var jsxRuntime=require('hono/jsx/jsx-runtime'),zod=require('zod'),crypto=require('crypto'),server=require('hono/jsx/dom/server');var Yt=Object.defineProperty;var Ie=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var en=(e,t)=>{for(var n in t)Yt(e,n,{get:t[n],enumerable:true});};function L(e){let t=e,n=t._zod?.def?.type;if(n)return an[n]??`Zod${n.charAt(0).toUpperCase()}${n.slice(1)}`;let r=t._def?.typeName;return r||""}function X(e){let t=e;if(t._zod?.def?.innerType)return t._zod.def.innerType;if(t._def?.innerType)return t._def.innerType}function ke(e){let t=e,n=t._zod?.def?.in;if(n)return n;if(t._def?.schema)return t._def.schema}function gt(e){let t=e;if(t._zod?.def?.element)return t._zod.def.element;if(t._def?.type)return t._def.type}function bt(e){let t=e;if(t._zod?.def?.defaultValue!==void 0)return t._zod.def.defaultValue;let n=t._def?.defaultValue;return typeof n=="function"?n():n}function Y(e){let t=e;return t.shape&&typeof t.shape=="object"?t.shape:t._zod?.def?.shape&&typeof t._zod.def.shape=="object"?t._zod.def.shape:t._def?.shape?typeof t._def.shape=="function"?t._def.shape():t._def.shape:{}}function Se(e){let t=e;return Array.isArray(t.options)?t.options:t._zod?.def?.entries?Object.values(t._zod.def.entries):Array.isArray(t._def?.values)?t._def.values:[]}function Ae(e){let t=e;return t._zod?.def?.entries?t._zod.def.entries:t.enum&&typeof t.enum=="object"?t.enum:t._def?.values&&typeof t._def.values=="object"?t._def.values:{}}function Re(e){let t=e;return Array.isArray(t._zod?.def?.values)?t._zod.def.values[0]:t._def?.value}function $e(e){let t=e;return Array.isArray(t.options)?t.options:Array.isArray(t._zod?.def?.options)?t._zod.def.options:Array.isArray(t._def?.options)?t._def.options:[]}function vt(e){let t=e,n=[],r=t._zod?.def?.checks;if(Array.isArray(r)){for(let o of r)o.format&&n.push(o.format);if(n.length>0)return n}let a=t._def?.checks;if(Array.isArray(a))for(let o of a)o.kind&&n.push(o.kind);return n}var an,Ne=Ie(()=>{"use strict";an={string:"ZodString",number:"ZodNumber",bigint:"ZodBigInt",boolean:"ZodBoolean",date:"ZodDate",enum:"ZodEnum",nativeEnum:"ZodNativeEnum",literal:"ZodLiteral",object:"ZodObject",array:"ZodArray",optional:"ZodOptional",nullable:"ZodNullable",default:"ZodDefault",coerce:"ZodCoerce",union:"ZodUnion",undefined:"ZodUndefined",unknown:"ZodUnknown",any:"ZodAny",record:"ZodRecord"};});function Ct({val:e}){return jsxRuntime.jsx("span",{class:"text-sm text-base-content/80 font-mono tabular-nums whitespace-nowrap",children:e.toLocaleString()})}function hn({message:e}){return jsxRuntime.jsx("span",{class:"tooltip tooltip-warning tooltip-right inline-flex align-middle ml-1 text-warning","data-tip":e,role:"img","aria-label":e,children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",class:"size-3.5",children:jsxRuntime.jsx("path",{d:"M12 2 1 22h22L12 2zm0 6 7.5 13h-15L12 8zm-1 4v4h2v-4h-2zm0 5v2h2v-2h-2z"})})})}function be({val:e,mismatch:t}){let n=Xe(e);return t?jsxRuntime.jsxs("span",{class:"inline-flex items-start gap-0.5",children:[n,jsxRuntime.jsx(hn,{message:t})]}):n}function Xe(e){if(e==null)return jsxRuntime.jsx("span",{class:"opacity-30 italic text-xs",children:"\u2014"});if(typeof e=="boolean")return e?jsxRuntime.jsx("span",{class:"badge badge-success badge-sm",children:"true"}):jsxRuntime.jsx("span",{class:"badge badge-error badge-sm",children:"false"});if(e instanceof Date)return jsxRuntime.jsx(Ct,{val:e});if(typeof e=="object"&&e!==null&&typeof e.toDate=="function")return jsxRuntime.jsx(Ct,{val:e.toDate()});if(typeof e=="number")return jsxRuntime.jsx("span",{class:"text-sm font-mono tabular-nums",children:String(e)});if(Array.isArray(e))return e.length===0?jsxRuntime.jsx("span",{class:"text-xs text-base-content/30",children:"[]"}):jsxRuntime.jsxs("ul",{class:"list-none p-0 m-0 space-y-0.5 text-xs",children:[e.slice(0,8).map((n,r)=>jsxRuntime.jsx("li",{class:"break-all",children:Xe(n)},r)),e.length>8&&jsxRuntime.jsxs("li",{class:"text-base-content/40 italic",children:["+",e.length-8," more\u2026"]})]});if(typeof e=="object"&&e!==null){let n=Object.entries(e);return n.length===0?jsxRuntime.jsx("span",{class:"text-xs text-base-content/30",children:"{}"}):jsxRuntime.jsxs("dl",{class:"grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5 text-xs m-0",children:[n.slice(0,8).map(([r,a])=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("dt",{class:"text-base-content/50 font-semibold whitespace-nowrap",children:r}),jsxRuntime.jsx("dd",{class:"break-all",children:Xe(a)})]})),n.length>8&&jsxRuntime.jsxs("dt",{class:"col-span-2 text-base-content/40 italic",children:["+",n.length-8," more\u2026"]})]})}let t=String(e);return jsxRuntime.jsx("span",{class:"text-sm break-all",children:t})}var Fe=Ie(()=>{"use strict";});function Ce(e){if(!e)return "unknown";let t=Ye(e);switch(L(t)){case "ZodString":return "string";case "ZodNumber":return "number";case "ZodBigInt":return "bigint";case "ZodBoolean":return "boolean";case "ZodDate":return "date";case "ZodArray":return "array";case "ZodObject":case "ZodRecord":return "object";case "ZodEnum":case "ZodNativeEnum":return "enum";case "ZodLiteral":return "literal";default:return "unknown"}}function Ye(e){let t=L(e);if(t==="ZodOptional"||t==="ZodNullable"||t==="ZodDefault"){let n=X(e);return n?Ye(n):e}return e}function Ee(e,t){if(!e)return;let n=t.split("."),r=e;for(let a of n){if(!r)return;let o=Ye(r);if(L(o)!=="ZodObject")return;r=Y(o)[a];}return r}function xn(e){return e==null?"null":e instanceof Date?"date":Array.isArray(e)?"array":typeof e=="string"?"string":typeof e=="boolean"?"boolean":typeof e=="bigint"?"bigint":typeof e=="number"?"number":typeof e=="object"?typeof e.toDate=="function"?"date":"object":"unknown"}function Te(e,t){if(e==="unknown")return null;let n=xn(t);return n==="null"?null:e==="enum"||e==="literal"?n==="string"||n==="number"?null:`Expected ${e} (string/number), got ${n}`:e===n||e==="number"&&n==="bigint"||e==="bigint"&&n==="number"?null:`Expected ${e}, got ${n}`}var et=Ie(()=>{"use strict";Ne();});var Ot={};en(Ot,{PanelMany:()=>kn,PanelOne:()=>wn,RightPanel:()=>tt});function wn({doc:e,repoName:t,basePath:n,schema:r,columns:a}){if(!e)return jsxRuntime.jsx("div",{class:"text-center py-12 text-base-content/50",children:"Document not found."});let o=String(e.docId??e.id??""),s=`${n}/${t}/${encodeURIComponent(o)}/edit`,c=Tt(r,a);return jsxRuntime.jsxs("div",{class:"space-y-4",children:[jsxRuntime.jsxs("div",{class:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{class:"text-xs text-base-content/60",children:[jsxRuntime.jsx("span",{class:"font-mono",children:t}),jsxRuntime.jsx("span",{class:"opacity-50",children:" \xB7 "}),jsxRuntime.jsx("span",{class:"font-mono break-all",children:o})]}),jsxRuntime.jsx("a",{href:s,class:"btn btn-sm btn-primary",children:"Edit \u2192"})]}),jsxRuntime.jsx("dl",{class:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-2 border border-base-300 rounded-box p-4 bg-base-100",children:a.map(l=>{let p=e[l],f=c[l],y=f?Te(f,p):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("dt",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide pt-0.5",children:l}),jsxRuntime.jsx("dd",{class:"min-w-0",children:jsxRuntime.jsx(be,{val:p,mismatch:y})})]})})})]})}function kn({docs:e,repoName:t,basePath:n,fk:r,fv:a,columns:o,schema:s,pagination:c}){let l=`${n}/${t}?fv_${r}=${encodeURIComponent(a)}`,p=Tt(s,o);return jsxRuntime.jsxs("div",{class:"space-y-4",children:[jsxRuntime.jsxs("div",{class:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{class:"text-xs text-base-content/60",children:[jsxRuntime.jsx("span",{class:"font-mono",children:t}),jsxRuntime.jsx("span",{class:"opacity-50",children:" where "}),jsxRuntime.jsx("span",{class:"font-mono",children:r}),jsxRuntime.jsx("span",{class:"opacity-50",children:" = "}),jsxRuntime.jsx("span",{class:"font-mono break-all",children:a}),jsxRuntime.jsx("span",{class:"opacity-50",children:" \xB7 "}),jsxRuntime.jsxs("span",{children:[e.length," doc",e.length!==1?"s":""]})]}),jsxRuntime.jsx("a",{href:l,class:"btn btn-sm btn-outline",children:"Full view \u2192"})]}),jsxRuntime.jsx("div",{class:"overflow-x-auto rounded-box border border-base-300 bg-base-100",children:jsxRuntime.jsxs("table",{class:"table table-xs w-full",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{class:"bg-base-200/50",children:[o.map((f,y)=>jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:f},y)),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:e.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colspan:o.length+1,class:"text-center py-10 text-base-content/40",children:"No related documents"})}):e.map((f,y)=>{let g=String(f.docId??f.id??""),S=`${n}/${t}/${encodeURIComponent(g)}/edit`;return jsxRuntime.jsxs("tr",{class:"hover",children:[o.map((h,F)=>{let Z=f[h],B=p[h],U=B?Te(B,Z):null;return jsxRuntime.jsx("td",{class:"align-top py-1.5",children:jsxRuntime.jsx(be,{val:Z,mismatch:U})},F)}),jsxRuntime.jsx("td",{class:"text-right py-1.5",children:jsxRuntime.jsx("a",{href:S,class:"btn btn-xs btn-ghost",children:"Edit"})})]},y)})})]})}),(c.hasPrev||c.hasNext)&&jsxRuntime.jsxs("div",{class:"flex justify-center items-center gap-2",children:[c.hasPrev?jsxRuntime.jsx("button",{type:"button",class:"btn btn-xs btn-outline","data-frs-panel-page":"prev","data-cursor":c.prevCursor,children:"\u2190 Previous"}):jsxRuntime.jsx("button",{class:"btn btn-xs btn-outline",disabled:true,children:"\u2190 Previous"}),c.hasNext?jsxRuntime.jsx("button",{type:"button",class:"btn btn-xs btn-outline","data-frs-panel-page":"next","data-cursor":c.nextCursor,children:"Next \u2192"}):jsxRuntime.jsx("button",{class:"btn btn-xs btn-outline",disabled:true,children:"Next \u2192"})]})]})}function Tt(e,t){if(!e)return {};let n={};for(let r of t)n[r]=Ce(Ee(e,r));return n}var tt,nt=Ie(()=>{"use strict";Fe();et();tt=({basePath:e=""})=>jsxRuntime.jsxs("div",{class:"fixed inset-0 z-[100] hidden pointer-events-none","data-frs-panel-root":!0,"data-frs-base-path":e,"aria-hidden":"true",children:[jsxRuntime.jsx("div",{class:"absolute inset-0 bg-black/30 opacity-0 transition-opacity duration-200 pointer-events-auto","data-frs-panel-backdrop":!0}),jsxRuntime.jsxs("aside",{class:"absolute top-0 right-0 h-full w-full md:w-1/2 bg-base-100 shadow-2xl border-l border-base-300 translate-x-full transition-transform duration-200 pointer-events-auto flex flex-col","data-frs-panel":!0,role:"dialog","aria-label":"Relation preview",children:[jsxRuntime.jsxs("header",{class:"flex items-center justify-between px-5 py-3 border-b border-base-300 bg-base-200/40 shrink-0",children:[jsxRuntime.jsx("h2",{class:"font-semibold text-base truncate","data-frs-panel-title":!0,children:"Relation"}),jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-ghost btn-circle","data-frs-panel-close":!0,"aria-label":"Close panel",children:"\u2715"})]}),jsxRuntime.jsx("div",{class:"flex-1 overflow-auto p-5 text-sm","data-frs-panel-body":!0,children:jsxRuntime.jsx("div",{class:"flex items-center justify-center py-12 text-base-content/40",children:jsxRuntime.jsx("span",{class:"loading loading-spinner loading-md"})})})]})]});});function He(e,t,n){let r=t==="/"?"":t.replace(/\/$/,"");if(process.env.FUNCTIONS_EMULATOR==="true"){let s=process.env.GCLOUD_PROJECT??process.env.GOOGLE_CLOUD_PROJECT??"demo-project",c=n??process.env.FUNCTION_REGION??"us-central1",l=(process.env.FUNCTION_TARGET??"").replace(/\./g,"-");return `/${s}/${c}/${l}${r}`}let a=process.env.K_SERVICE,o=e?.hostname??e?.headers?.host??"";return a&&typeof o=="string"&&o.includes("cloudfunctions.net")?`/${a.toLowerCase()}${r}`:r}function pt(e){if(typeof e=="string")return e;if(Array.isArray(e)){let t=e[0];return typeof t=="string"?t:void 0}}function qe(e){return !!e&&typeof e=="object"&&e.__authExtension===true}var Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function ft(){let e="";for(;e.length<20;){let t=crypto.randomBytes(20);for(let n=0;n<t.length&&e.length<20;n++){let r=t[n];r>=Ve.length*4||(e+=Ve.charAt(r%Ve.length));}}return e}function mt(e){return e.match(/^\{([^}]+)\}$/)?.[1]?.trim()||null}function yt(e,t="docId",n=false){if(typeof e!="string"||!e.trim())return {rawPath:e??"",collectionId:"",collectionPath:"",parentKeys:[],documentPathTemplate:null,hasTemplate:false};let r=e.split("/").map(y=>y.trim()).filter(Boolean);if(r.length===0)return {rawPath:e,collectionId:e,collectionPath:e,parentKeys:[],documentPathTemplate:null,hasTemplate:false};if(r.length===1){let y=r[0];return {rawPath:e,collectionId:y,collectionPath:y,parentKeys:[],documentPathTemplate:n?null:`${y}/{${t}}`,hasTemplate:e.includes("{")&&e.includes("}")}}let a=r.length%2===0,o=a?r.slice(0,-1):r,s=o[o.length-1],c=o.join("/"),p=o.slice(0,-1).map(mt).filter(y=>y!==null),f=a?r.join("/"):`${c}/{${t}}`;return {rawPath:e,collectionId:s,collectionPath:c,parentKeys:p,documentPathTemplate:f,hasTemplate:true}}function ht(e,t={}){if(!e||typeof e!="object")return;let{pathKey:n,documentKey:r="docId",parentKeys:a,documentPathTemplate:o,isGroup:s}=t,c=n&&typeof e[n]=="string"&&e[n]?e[n]:void 0;if(c&&o){let l=c.split("/").filter(Boolean),p=o.split("/").filter(Boolean);if(l.length===p.length){let f=[];for(let y=0;y<p.length;y++)mt(p[y])!==null&&f.push(l[y]);if(f.length>0)return f}}if(a&&a.length>0){let l=a.length+1;if(c){let f=c.split("/").filter(Boolean),y=[];for(let g=1;g<f.length;g+=2)y.push(f[g]);if(y.length>=l)return y.slice(y.length-l)}let p=r?e[r]:void 0;if(typeof p=="string"&&p.trim()!==""){let f=[],y=true;for(let g of a){let S=e[g];if(typeof S=="string"&&S.trim()!=="")f.push(S);else {y=false;break}}if(y)return [...f,p]}}if(c){let l=c.split("/").filter(Boolean),p=[];for(let f=1;f<l.length;f+=2)p.push(l[f]);if(p.length>0)return !s&&(!a||a.length===0)?[p[p.length-1]]:p}}Ne();Ne();function on(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/^\s/,"").replace(/^./,t=>t.toUpperCase())}function xt(e){let t=e,n=true,r=false,a;for(;;){let o=L(t);if(o==="ZodOptional")n=false,t=X(t);else if(o==="ZodNullable")n=false,r=true,t=X(t);else if(o==="ZodDefault")n=false,a=bt(t),t=X(t);else if(o==="ZodEffects"||o==="ZodPipe"||o==="ZodTransform"){let s=ke(t);if(!s)break;t=s;}else break}return {inner:t,required:n,nullable:r,defaultValue:a}}function ee(e,t=""){if(L(e)==="ZodObject"){let r=Y(e);return Object.entries(r).map(([a,o])=>wt(t?`${t}.${a}`:a,a,o))}return [wt(t||"value",t||"value",e)]}function wt(e,t,n){let{inner:r,required:a,nullable:o,defaultValue:s}=xt(n),c=L(r),l=on(t.split(".").pop()??t);switch(c){case "ZodString":{let p=vt(r),f=p.includes("email"),y=p.includes("url");return {name:e,label:l,type:"text",required:a,nullable:o,defaultValue:s,hint:f?"email":y?"url":void 0}}case "ZodNumber":case "ZodBigInt":return {name:e,label:l,type:"number",required:a,nullable:o,defaultValue:s};case "ZodBoolean":return {name:e,label:l,type:"checkbox",required:a,nullable:o,defaultValue:s};case "ZodDate":case "ZodCoerce":return {name:e,label:l,type:"datetime-local",required:a,nullable:o,defaultValue:s};case "ZodEnum":{let p=Se(r);return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:p}}case "ZodNativeEnum":{let p=Ae(r),f=Object.values(p).filter(y=>typeof y=="string");return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:f}}case "ZodLiteral":{let p=String(Re(r)??"");return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:[p]}}case "ZodUnion":{let p=$e(r);if(p.length>0&&p.every(S=>L(S)==="ZodLiteral")){let S=p.map(h=>String(Re(h)??""));return {name:e,label:l,type:"select",required:a,nullable:o,defaultValue:s,options:S}}if(p.some(S=>L(S)==="ZodDate"))return {name:e,label:l,type:"datetime-local",required:a,nullable:o,defaultValue:s};let g=p.find(S=>{if(L(S)==="ZodObject"){let h=Y(S);return "_latitude"in h&&"_longitude"in h||"latitude"in h&&"longitude"in h}return false});return g?{name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,nested:ee(g,e),hint:"GeoPoint"}:{name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON"}}case "ZodObject":{let p=ee(r,e);return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,nested:p,hint:"JSON object"}}case "ZodArray":{let p=gt(r);if(!p)return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON array"};let{inner:f}=xt(p),y=L(f),g,S,h;switch(y){case "ZodString":g="text";break;case "ZodNumber":case "ZodBigInt":g="number";break;case "ZodBoolean":g="checkbox";break;case "ZodDate":g="datetime-local";break;case "ZodEnum":g="select",S=Se(f);break;case "ZodNativeEnum":g="select",S=Object.values(Ae(f)).filter(F=>typeof F=="string");break;case "ZodObject":g="object",h=ee(f);break;default:return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON array"}}return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,arrayElementType:g,arrayElementOptions:S,arrayElementFields:h}}default:return {name:e,label:l,type:"textarea",required:a,nullable:o,defaultValue:s,hint:"JSON"}}}function Ze(e,t=0){let n=t>0?`ml-${t*4}`:"",r=`field_${e.name.replace(/\./g,"__")}`,a=e.name,o=e.required?" required":"",s=e.defaultValue==="__null__",c=!s&&e.defaultValue!=null?String(e.defaultValue):"",l=e.nullable&&e.type!=="checkbox"?`<span class="flex items-center gap-1 shrink-0">
2
2
  <input type="hidden" id="${r}__isnull" name="${a}__isnull" value="${s?"1":""}">
3
3
  <label class="flex items-center gap-1 cursor-pointer select-none text-xs text-base-content/40 hover:text-base-content/70 border border-base-300 rounded px-2 py-1">
4
4
  <input type="checkbox" class="checkbox checkbox-xs" ${s?"checked":""}
@@ -35,7 +35,7 @@
35
35
  ${e.required&&!e.nullable?"":'<option value="">\u2014 optional \u2014</option>'}
36
36
  ${(e.options??[]).map(f=>`<option value="${$(f)}"${c===f?" selected":""}>${$(f)}</option>`).join(`
37
37
  `)}
38
- </select>`;break;case "textarea":if(e.arrayElementType)return sn(e,t);if(e.nested&&e.nested.length>0){let f=e.nested.map(h=>Ze(h,t+1)).join(`
38
+ </select>`;break;case "textarea":if(e.arrayElementType)return sn(e,t);if(e.nested&&e.nested.length>0){let f=e.nested.map(y=>Ze(y,t+1)).join(`
39
39
  `);return `
40
40
  <fieldset class="fieldset border border-base-300 rounded-box p-3 mb-3 ${n}">
41
41
  <legend class="fieldset-legend text-xs font-semibold text-base-content/60 px-1">
@@ -133,7 +133,7 @@
133
133
  <button type="submit" class="btn btn-primary btn-sm">${$(r)}</button>
134
134
  <button type="button" class="btn btn-ghost btn-sm" onclick="history.back()">Cancel</button>
135
135
  </div>
136
- </form>`}var ln=new Set(["<","<=",">",">=","!="]),cn=new Set(["array-contains","array-contains-any"]);function Ke(e){return e==="desc"?"DESCENDING":"ASCENDING"}function dn(e){return ht(e).collectionId||e}function un(e,t,n,r,a){let o=[],s=new Set;for(let l of r)if(l.op==="=="||l.op==="in"||l.op==="not-in"){if(s.has(l.field))continue;s.add(l.field),o.push({fieldPath:l.field,order:"ASCENDING"});}for(let l of r)if(cn.has(l.op)){if(s.has(l.field))continue;s.add(l.field),o.push({fieldPath:l.field,arrayConfig:"CONTAINS"});}for(let l of r)if(ln.has(l.op)){if(s.has(l.field))continue;s.add(l.field);let p=a?.field===l.field?Ke(a.dir):"ASCENDING";o.push({fieldPath:l.field,order:p});}if(a&&!s.has(a.field)&&o.push({fieldPath:a.field,order:Ke(a.dir)}),o.length===1&&n)return mn(e,t,o[0]);let c=a&&o.some(l=>l.fieldPath===a.field)?Ke(a.dir):"ASCENDING";return o.push({fieldPath:"__name__",order:c}),pn(e,t,n,o)}function pn(e,t,n,r,a="(default)"){let o=`projects/${e}/databases/${a}/collectionGroups/${t}/indexes/_`,s=[...We(1,o),...De(2,n?2:1)];for(let p of r)s.push(...At(3,Rt(p)));let c=a==="(default)"?"-default-":a,l=encodeURIComponent($t(s));return `https://console.firebase.google.com/project/${e}/firestore/databases/${c}/indexes?create_composite=${l}`}function fn(e){return e.match(/https:\/\/console\.firebase\.google\.com[^\s)"]*/)?.[0]}function Je(e){let t=[],n=e>>>0;for(;n>=128;)t.push(n&127|128),n>>>=7;return t.push(n&127),t}function Ge(e,t){return e<<3|t}function We(e,t){let n=Array.from(new TextEncoder().encode(t));return [Ge(e,2),...Je(n.length),...n]}function De(e,t){return [Ge(e,0),...Je(t)]}function At(e,t){return [Ge(e,2),...Je(t.length),...t]}function Rt(e){let t=[...We(1,e.fieldPath)];return e.arrayConfig==="CONTAINS"?t.push(...De(3,1)):t.push(...De(2,e.order==="DESCENDING"?2:1)),t}function $t(e){let t=String.fromCharCode(...e),n;if(typeof Buffer<"u")n=Buffer.from(e).toString("base64");else if(typeof btoa<"u")n=btoa(t);else throw new Error("No base64 encoder available");return n.replace(/=+$/,"")}function mn(e,t,n,r="(default)"){let a=`projects/${e}/databases/${r}/collectionGroups/${t}/fields/${n.fieldPath}`,o=[...We(1,a),...De(2,2),...At(3,Rt(n))],s=r==="(default)"?"-default-":r,c=encodeURIComponent($t(o));return `https://console.firebase.google.com/project/${e}/firestore/databases/${s}/indexes/automatic?create_exemption=${c}`}function hn(e){let t=e,n=[t?.firestore?.projectId,t?.firestore?.app?.options?.projectId,t?.firestore?._settings?.projectId,t?.firestore?.databaseId?.projectId,t?._firestore?.projectId];for(let a of n)if(typeof a=="string"&&a.length>0)return a;return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.FIREBASE_PROJECT_ID||void 0}function ue(e){let t=e;return t?t.code===9?true:typeof t.message=="string"?t.message.includes("requires an index"):false:false}function Qe(e,t){let n=e??{},r=ue(e),a;if(r&&(a=n.message?fn(n.message):void 0,!a)){let o=hn(t.ref);if(o){let s=dn(t.path);a=un(o,s,t.isGroup,t.filters,t.sort);}}return {type:r?"index":"error",message:r?"This query requires a composite index that does not exist yet.":n.message??"Query failed",indexUrl:a}}Fe();var Et=`// \u2500\u2500 Shared helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
136
+ </form>`}var ln=new Set(["<","<=",">",">=","!="]),cn=new Set(["array-contains","array-contains-any"]);function Ke(e){return e==="desc"?"DESCENDING":"ASCENDING"}function dn(e){return yt(e).collectionId||e}function un(e,t,n,r,a){let o=[],s=new Set;for(let l of r)if(l.op==="=="||l.op==="in"||l.op==="not-in"){if(s.has(l.field))continue;s.add(l.field),o.push({fieldPath:l.field,order:"ASCENDING"});}for(let l of r)if(cn.has(l.op)){if(s.has(l.field))continue;s.add(l.field),o.push({fieldPath:l.field,arrayConfig:"CONTAINS"});}for(let l of r)if(ln.has(l.op)){if(s.has(l.field))continue;s.add(l.field);let p=a?.field===l.field?Ke(a.dir):"ASCENDING";o.push({fieldPath:l.field,order:p});}if(a&&!s.has(a.field)&&o.push({fieldPath:a.field,order:Ke(a.dir)}),o.length===1&&n)return mn(e,t,o[0]);let c=a&&o.some(l=>l.fieldPath===a.field)?Ke(a.dir):"ASCENDING";return o.push({fieldPath:"__name__",order:c}),pn(e,t,n,o)}function pn(e,t,n,r,a="(default)"){let o=`projects/${e}/databases/${a}/collectionGroups/${t}/indexes/_`,s=[...We(1,o),...De(2,n?2:1)];for(let p of r)s.push(...At(3,Rt(p)));let c=a==="(default)"?"-default-":a,l=encodeURIComponent($t(s));return `https://console.firebase.google.com/project/${e}/firestore/databases/${c}/indexes?create_composite=${l}`}function fn(e){return e.match(/https:\/\/console\.firebase\.google\.com[^\s)"]*/)?.[0]}function Je(e){let t=[],n=e>>>0;for(;n>=128;)t.push(n&127|128),n>>>=7;return t.push(n&127),t}function Ge(e,t){return e<<3|t}function We(e,t){let n=Array.from(new TextEncoder().encode(t));return [Ge(e,2),...Je(n.length),...n]}function De(e,t){return [Ge(e,0),...Je(t)]}function At(e,t){return [Ge(e,2),...Je(t.length),...t]}function Rt(e){let t=[...We(1,e.fieldPath)];return e.arrayConfig==="CONTAINS"?t.push(...De(3,1)):t.push(...De(2,e.order==="DESCENDING"?2:1)),t}function $t(e){let t=String.fromCharCode(...e),n;if(typeof Buffer<"u")n=Buffer.from(e).toString("base64");else if(typeof btoa<"u")n=btoa(t);else throw new Error("No base64 encoder available");return n.replace(/=+$/,"")}function mn(e,t,n,r="(default)"){let a=`projects/${e}/databases/${r}/collectionGroups/${t}/fields/${n.fieldPath}`,o=[...We(1,a),...De(2,2),...At(3,Rt(n))],s=r==="(default)"?"-default-":r,c=encodeURIComponent($t(o));return `https://console.firebase.google.com/project/${e}/firestore/databases/${s}/indexes/automatic?create_exemption=${c}`}function yn(e){let t=e,n=[t?.firestore?.projectId,t?.firestore?.app?.options?.projectId,t?.firestore?._settings?.projectId,t?.firestore?.databaseId?.projectId,t?._firestore?.projectId];for(let a of n)if(typeof a=="string"&&a.length>0)return a;return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.FIREBASE_PROJECT_ID||void 0}function ue(e){let t=e;return t?t.code===9?true:typeof t.message=="string"?t.message.includes("requires an index"):false:false}function Qe(e,t){let n=e??{},r=ue(e),a;if(r&&(a=n.message?fn(n.message):void 0,!a)){let o=yn(t.ref);if(o){let s=dn(t.path);a=un(o,s,t.isGroup,t.filters,t.sort);}}return {type:r?"index":"error",message:r?"This query requires a composite index that does not exist yet.":n.message??"Query failed",indexUrl:a}}Fe();var Et=`// \u2500\u2500 Shared helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
137
137
  function frsGetBasePath() {
138
138
  var root = document.querySelector("[data-frs-panel-root]");
139
139
  var bp = root && root.getAttribute("data-frs-base-path");
@@ -1055,6 +1055,6 @@ function initColumnReorder(table) {
1055
1055
  });
1056
1056
  });
1057
1057
  }
1058
- `;function ze(){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:Et}})}nt();function se(e){return "<!DOCTYPE html>"+server.renderToString(e)}var Rn=["corporate","silk","dark"],$n=()=>jsxRuntime.jsxs("div",{class:"dropdown dropdown-end","data-frs-theme-switcher":true,children:[jsxRuntime.jsxs("button",{type:"button",tabIndex:0,class:"btn btn-sm btn-ghost text-neutral-content gap-1.5","aria-label":"Switch theme",children:[jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",class:"size-4",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"}),jsxRuntime.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),jsxRuntime.jsx("span",{class:"text-xs hidden sm:inline","data-frs-theme-current":true,children:"Theme"})]}),jsxRuntime.jsx("ul",{tabIndex:0,class:"dropdown-content menu menu-sm bg-base-100 text-base-content rounded-box z-50 mt-2 w-40 p-1 shadow-lg border border-base-300",children:Rn.map(e=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button","data-frs-theme":e,class:"capitalize justify-between",children:[jsxRuntime.jsx("span",{children:e}),jsxRuntime.jsx("span",{class:"hidden text-primary","data-frs-theme-check":e,children:"\u2713"})]})},e))})]}),ie=({opts:e,children:t})=>{let{title:n,breadcrumb:r,flash:a,basePath:o="/"}=e;return jsxRuntime.jsxs("html",{lang:"en","data-theme":"corporate",children:[jsxRuntime.jsxs("head",{children:[jsxRuntime.jsx("meta",{charset:"UTF-8"}),jsxRuntime.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),jsxRuntime.jsxs("title",{children:[n," \u2014 FRS Admin"]}),jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:"(function(){try{var t=localStorage.getItem('frs-admin-theme');if(t){document.documentElement.setAttribute('data-theme',t);}}catch(_){}})();"}}),jsxRuntime.jsx("link",{href:"https://cdn.jsdelivr.net/npm/daisyui@5/themes.css",rel:"stylesheet",type:"text/css"}),jsxRuntime.jsx("link",{href:"https://cdn.jsdelivr.net/npm/daisyui@5/daisyui.css",rel:"stylesheet",type:"text/css"}),jsxRuntime.jsx("script",{src:"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"})]}),jsxRuntime.jsxs("body",{class:"bg-base-200/50 min-h-screen flex flex-col",children:[jsxRuntime.jsxs("div",{class:"navbar bg-neutral text-neutral-content shadow-sm sticky top-0 z-50 px-6",children:[jsxRuntime.jsx("div",{class:"flex-1",children:jsxRuntime.jsx("a",{href:o,class:"font-bold text-lg tracking-tight hover:opacity-80 transition-opacity",children:"FRS Admin"})}),jsxRuntime.jsx("div",{class:"flex-none",children:jsxRuntime.jsx($n,{})})]}),jsxRuntime.jsxs("main",{class:"px-6 py-8 w-full flex-1",children:[r&&r.length>0&&jsxRuntime.jsx("div",{class:"text-sm breadcrumbs mb-4",children:jsxRuntime.jsx("ul",{children:r.map((s,c)=>s.href?jsxRuntime.jsx("li",{children:jsxRuntime.jsx("a",{href:s.href,children:s.label})},c):jsxRuntime.jsx("li",{class:"text-base-content/60",children:s.label},c))})}),jsxRuntime.jsx("h1",{class:"text-2xl font-bold mb-6",children:n}),a&&jsxRuntime.jsxs("div",{role:"alert",class:`alert ${a.type==="success"?"alert-success":a.type==="warning"?"alert-warning":"alert-error"} mb-6`,children:[jsxRuntime.jsx("span",{class:"flex-1",children:a.message}),a.action&&jsxRuntime.jsx("a",{href:a.action.href,...a.action.external?{target:"_blank",rel:"noopener noreferrer"}:{},class:"btn btn-sm btn-outline",children:a.action.label})]}),t]}),jsxRuntime.jsx(tt,{basePath:o}),jsxRuntime.jsx(ze,{})]})]})};function rt(e,t){return se(jsxRuntime.jsx(ie,{opts:t,children:jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:e}})}))}function at(e,t){return se(jsxRuntime.jsx(ie,{opts:{title:"Repositories",basePath:t},children:e.length===0?jsxRuntime.jsxs("div",{class:"text-center py-20 text-base-content/50",children:[jsxRuntime.jsx("p",{class:"text-lg font-medium mb-1",children:"No repositories configured"}),jsxRuntime.jsx("p",{class:"text-sm",children:"Add a repository to your FRS config to get started."})]}):jsxRuntime.jsx("div",{class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:e.map(n=>jsxRuntime.jsx("a",{href:`${t}/${n.name}`,class:"card bg-base-100 border border-base-300 hover:shadow-md no-underline transition-shadow",children:jsxRuntime.jsxs("div",{class:"card-body p-5",children:[jsxRuntime.jsx("h2",{class:"card-title text-sm font-semibold",children:n.name}),jsxRuntime.jsx("p",{class:"text-xs text-base-content/50 font-mono",children:n.path})]})},n.name))})}))}var Pt=[{value:"==",label:"="},{value:"!=",label:"\u2260"},{value:"in",label:"in"},{value:"not-in",label:"not in"}],Cn=[{value:"==",label:"="},{value:"!=",label:"\u2260"},{value:"<",label:"<"},{value:"<=",label:"\u2264"},{value:">",label:">"},{value:">=",label:"\u2265"},{value:"in",label:"in"},{value:"not-in",label:"not in"}],En=[{value:"array-contains",label:"contains"},{value:"array-contains-any",label:"contains any"}];function Tn(e){switch(e){case "ZodNumber":case "ZodBigInt":case "ZodDate":return Cn;case "ZodBoolean":return Pt;case "ZodArray":return En;default:return Pt}}var le="__null__";function On(e){return `(function(cb){var i=document.getElementById('${e}');if(!i)return;if(cb.checked){i.dataset._prev=i.value;if(i.tagName==='SELECT'){var o=i.querySelector('option[value="${le}"]');if(!o){o=document.createElement('option');o.value='${le}';o.textContent='\u2205 null';o.dataset._auto='1';i.appendChild(o);}o.selected=true;}else{if(i.type==='number'||i.type==='datetime-local'){i.dataset._type=i.type;i.type='text';}i.value='${le}';i.readOnly=true;}i.style.opacity='0.55';}else{i.style.opacity='';if(i.tagName==='SELECT'){var o2=i.querySelector('option[value="${le}"][data-_auto="1"]');if(o2)o2.remove();var prev=i.dataset._prev||'';for(var k=0;k<i.options.length;k++)i.options[k].selected=(i.options[k].value===prev);}else{if(i.dataset._type){i.type=i.dataset._type;delete i.dataset._type;}i.readOnly=false;i.value=(i.dataset._prev&&i.dataset._prev!=='${le}')?i.dataset._prev:'';}}})(this)`}function _n(e,t){return `(function(){var h=document.getElementById('${e}');var boxes=document.querySelectorAll('input[data-enum-group="${t}"]');h.value=Array.from(boxes).filter(function(b){return b.checked;}).map(function(b){return b.value;}).join(',');})()`}function Oe({inputId:e,active:t}){return jsxRuntime.jsxs("label",{class:"flex items-center gap-1 cursor-pointer select-none text-xs text-base-content/60 hover:text-base-content border border-base-300 rounded-md px-1.5 py-1 shrink-0 leading-none h-8",title:"Filter where field IS NULL",children:[jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs",checked:t,onchange:On(e)}),jsxRuntime.jsx("span",{children:"\u2205"})]})}function Pn({col:e,active:t}){let n=t?.value??"",r=n===le,a=`fv_input_${e.name.replace(/\./g,"__")}`,o=t?.op,s=o==="in"||o==="not-in";if(e.enumValues&&e.enumValues.length>0){if(s){let c=new Set(n.split(",").map(p=>p.trim()).filter(Boolean)),l=`eg_${e.name.replace(/\./g,"__")}`;return jsxRuntime.jsxs("div",{class:"flex flex-wrap items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{type:"hidden",id:a,name:`fv_${e.name}`,value:n}),e.enumValues.map(p=>jsxRuntime.jsxs("label",{class:"flex items-center gap-1 text-xs border border-base-300 rounded px-2 cursor-pointer hover:bg-base-200",children:[jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs",value:p,checked:c.has(p),"data-enum-group":l,onchange:_n(a,l)}),jsxRuntime.jsx("span",{children:p})]},p))]})}return jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsxs("select",{id:a,name:`fv_${e.name}`,class:"select select-sm select-bordered w-full",style:r?"opacity:0.55":void 0,children:[jsxRuntime.jsx("option",{value:"",selected:n===""&&!r,children:"\u2014"}),e.enumValues.map(c=>jsxRuntime.jsx("option",{value:c,selected:n===c,children:c},c)),e.nullable&&jsxRuntime.jsx("option",{value:le,"data-_auto":"1",selected:r,children:"\u2205 null"})]}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]})}if(e.zodType==="ZodBoolean")return jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsxs("select",{id:a,name:`fv_${e.name}`,class:"select select-sm select-bordered w-full",style:r?"opacity:0.55":void 0,children:[jsxRuntime.jsx("option",{value:"",selected:n===""&&!r,children:"\u2014"}),jsxRuntime.jsx("option",{value:"true",selected:n==="true",children:"true"}),jsxRuntime.jsx("option",{value:"false",selected:n==="false",children:"false"}),e.nullable&&jsxRuntime.jsx("option",{value:le,"data-_auto":"1",selected:r,children:"\u2205 null"})]}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]});if(e.zodType==="ZodArray"){let c=t?.op==="array-contains-any";return jsxRuntime.jsx("input",{id:a,type:"text",name:`fv_${e.name}`,value:n,placeholder:c?"val1, val2, \u2026":"value",class:"input input-sm input-bordered w-full"})}return e.zodType==="ZodNumber"||e.zodType==="ZodBigInt"?jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:r?"text":"number",name:`fv_${e.name}`,value:n,placeholder:"value",class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0,"data-_type":r?"number":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]}):e.zodType==="ZodDate"?jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:r?"text":"datetime-local",name:`fv_${e.name}`,value:n,class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0,"data-_type":r?"datetime-local":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]}):jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:"text",name:`fv_${e.name}`,value:n,placeholder:"value",class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]})}function ot({action:e,columnMeta:t,activeFilters:n,isGroup:r}){let a=Object.fromEntries(n.map(l=>[l.field,l])),o=n.length>0,s=n.length>=2||r&&o,c=t.filter(l=>l.zodType!=="ZodObject"&&l.zodType!=="ZodRecord");return jsxRuntime.jsxs("details",{class:"collapse collapse-arrow bg-base-100 border border-base-300 rounded-box mb-6 shadow-sm",open:o?true:void 0,children:[jsxRuntime.jsxs("summary",{class:"collapse-title text-sm font-medium py-2 min-h-0",children:["Filters",o&&jsxRuntime.jsxs("span",{class:"badge badge-primary badge-sm ml-2",children:[n.length," active"]})]}),jsxRuntime.jsx("div",{class:"collapse-content pb-4 pt-2",children:jsxRuntime.jsxs("form",{method:"get",action:e,children:[jsxRuntime.jsx("div",{class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:c.map(l=>{let p=Tn(l.zodType),f=a[l.name],h=f?.op??p[0].value;return jsxRuntime.jsxs("div",{class:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("label",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:l.name}),jsxRuntime.jsxs("div",{class:"flex gap-1.5",children:[p.length>1?jsxRuntime.jsx("select",{name:`fo_${l.name}`,class:"select select-sm select-bordered w-20 shrink-0",children:p.map(g=>jsxRuntime.jsx("option",{value:g.value,selected:g.value===h,children:g.label},g.value))}):jsxRuntime.jsx("input",{type:"hidden",name:`fo_${l.name}`,value:p[0].value}),jsxRuntime.jsx(Pn,{col:l,active:f})]})]},l.name)})}),jsxRuntime.jsxs("div",{class:"flex flex-wrap gap-2 mt-4 pt-3 border-t border-base-200 items-center",children:[jsxRuntime.jsx("button",{type:"submit",class:"btn btn-sm btn-primary",children:"Apply"}),o&&jsxRuntime.jsx("a",{href:e,class:"btn btn-sm btn-ghost",children:"Clear"}),s&&jsxRuntime.jsxs("span",{class:"text-xs text-warning ml-auto flex items-center gap-1",children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),r?"Collection group queries require a composite index":"Multiple filters may require a composite index"]})]})]})})]})}function st(e,t,n,r,a,o){let s=n==="create"?`Create ${e}`:`Edit ${e} / ${r??""}`,c=n==="create"?[{label:"Repositories",href:a},{label:e,href:`${a}/${e}`},{label:"New document"}]:[{label:"Repositories",href:a},{label:e,href:`${a}/${e}`},{label:`Edit ${r??""}`}];return se(jsxRuntime.jsx(ie,{opts:{title:s,breadcrumb:c,basePath:a,flash:o},children:jsxRuntime.jsx("div",{class:"card bg-base-100 border border-base-300",children:jsxRuntime.jsx("div",{class:"card-body p-6",children:jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:t}})})})}))}Fe();et();function it(e,t,n){let r=new URLSearchParams;for(let a of e)r.set(`fv_${a.field}`,a.value),r.set(`fo_${a.field}`,a.op);return t&&(r.set("ob",t.field),r.set("od",t.dir)),n&&r.set("ps",String(n)),r}function It(e,t,n,r,a){let o=it(e,r,a);return o.set("cursor",t),o.set("dir",n),`?${o.toString()}`}function In(e,t,n,r){let a=it(n,void 0,r);return t?.field===e?t.dir==="asc"&&(a.set("ob",e),a.set("od","desc")):(a.set("ob",e),a.set("od","asc")),`?${a.toString()}`}function Nn(e,t,n){return `?${it(t,n,e).toString()}`}function lt(e,t,n,r,a,o,s=[],c=[],l=false,p=[],f,h,g,S,y,F,Z,B=false){let U=`${r}/${e}`,v=`${U}/create`,m={};if(Z)for(let b of n)m[b]=Ce(Ee(Z,b));let x=(F??[]).filter(b=>true),i=x.length>0,d=l,u=d||i,E=x.map(b=>{let N=Ee(Z,b),A=Ce(N),R=s.find(C=>C.name===b);return {name:b,type:A,enumValues:R?.enumValues??null,nullable:R?.nullable??false}}),P=[];return Z&&(P=ee(Z).filter(N=>x.includes(N.name))),se(jsxRuntime.jsxs(ie,{opts:{title:e,breadcrumb:[{label:"Repositories",href:r},{label:e}],basePath:r,flash:o},children:[s.length>0&&jsxRuntime.jsx(ot,{action:U,columnMeta:s,activeFilters:c,isGroup:S}),g&&jsxRuntime.jsxs("div",{role:"alert",class:`alert ${g.type==="index"?"alert-warning":"alert-error"} mb-6 shadow-sm`,children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24",children:g.type==="index"?jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"}):jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),jsxRuntime.jsxs("div",{class:"flex-1",children:[jsxRuntime.jsx("h3",{class:"font-bold",children:g.type==="index"?"Composite index required":"Query failed"}),jsxRuntime.jsx("div",{class:"text-sm",children:g.message})]}),g.indexUrl&&jsxRuntime.jsx("a",{href:g.indexUrl,target:"_blank",rel:"noopener noreferrer",class:"btn btn-sm btn-outline",children:"Create Index \u2192"})]}),jsxRuntime.jsxs("div",{class:"flex flex-wrap justify-between items-center mb-4 gap-3","data-frs-toolbar":true,children:[jsxRuntime.jsxs("div",{class:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{class:"text-sm text-base-content/60",children:[t.length,typeof y=="number"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" ","of"," ",jsxRuntime.jsx("span",{class:"font-semibold text-base-content/80",children:y})]})," ","document",(typeof y=="number"?y:t.length)!==1&&"s"]}),jsxRuntime.jsxs("div",{class:"flex items-center gap-1.5 text-sm text-base-content/60",children:[jsxRuntime.jsx("span",{children:"Rows"}),jsxRuntime.jsx("div",{class:"join",children:[10,25,50,100].map(b=>jsxRuntime.jsx("a",{href:Nn(b,c,f),class:`join-item btn btn-xs ${h===b?"btn-active btn-primary":"btn-outline"}`,children:b},b))})]})]}),jsxRuntime.jsxs("div",{class:"flex gap-2",children:[jsxRuntime.jsx("form",{method:"post",action:`${U}/_bulk/backfill`,onsubmit:"return confirm('Backfill entire repository? This will scan all documents and fill missing system keys.')",children:jsxRuntime.jsx("button",{type:"submit",class:"btn btn-outline btn-sm",children:"Backfill"})}),jsxRuntime.jsx("a",{href:v,class:"btn btn-primary btn-sm",children:"+ New"})]})]}),u&&jsxRuntime.jsxs("div",{class:"hidden mb-3 alert alert-info py-2 px-3","data-frs-bulk-bar":true,"data-frs-repo":e,"data-frs-total":typeof y=="number"?String(y):"","data-frs-page-size":String(h??t.length),"data-frs-allow-delete":d?"1":"0","data-frs-allow-update":i?"1":"0","data-frs-fields":JSON.stringify(E),"data-frs-filters":JSON.stringify(c),children:[jsxRuntime.jsxs("div",{class:"flex-1 text-sm",children:[jsxRuntime.jsx("span",{"data-frs-bulk-summary":true,children:"0 selected"}),typeof y=="number"&&y>t.length&&jsxRuntime.jsxs("button",{type:"button",class:"ml-3 link text-sm hidden","data-frs-bulk-select-all":true,children:["Select all ",y," matching documents"]}),jsxRuntime.jsxs("span",{class:"hidden ml-3 italic","data-frs-bulk-all-active":true,children:["All ",y??"?"," matching documents are selected."," ",jsxRuntime.jsx("button",{type:"button",class:"link","data-frs-bulk-clear":true,children:"Clear selection"})]})]}),jsxRuntime.jsxs("div",{class:"flex gap-2",children:[i&&jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-outline","data-frs-bulk-action":"update",children:"Update field\u2026"}),d&&jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-error btn-outline","data-frs-bulk-action":"delete",children:"Delete"})]})]}),jsxRuntime.jsx("div",{class:"overflow-x-auto rounded-box border border-base-300 bg-base-100","data-frs-table-wrap":true,children:jsxRuntime.jsxs("table",{class:"table table-sm w-full","data-frs-table":true,"data-frs-repo":e,"data-frs-colcount":n.length,children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{class:"bg-base-200/50",children:[u&&jsxRuntime.jsx("th",{class:"w-8",children:jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs checkbox-primary","data-frs-select-page":true,"aria-label":"Select all on this page"})}),[...n].map((b,N)=>{let A=f?.field===b,R=A?f.dir==="asc"?" \u25B2":" \u25BC":"";return jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:jsxRuntime.jsxs("a",{href:In(b,f,c,h),class:`hover:text-base-content inline-flex items-center gap-0.5${A?" text-primary font-bold":""}`,children:[b,R]})},N)}),p.map((b,N)=>jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:b.column},`rel-${N}`)),jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:t.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colspan:n.length+p.length+1+(u?1:0),class:"text-center py-16 text-base-content/40",children:"No documents found"})}):t.map((b,N)=>{let A=String(b.docId??b.id??""),R=`${r}/${e}/${encodeURIComponent(A)}/edit`,C=`${r}/${e}/${encodeURIComponent(A)}/delete`;return jsxRuntime.jsxs("tr",{class:"hover","data-frs-row-id":A,children:[u&&jsxRuntime.jsx("td",{class:"align-middle py-2",children:jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs checkbox-primary","data-frs-select-row":true,value:A,"aria-label":`Select ${A}`})}),n.map((O,M)=>{let q=b[O],I=m[O],w=I?Te(I,q):null;return jsxRuntime.jsx("td",{class:"align-top py-2",children:jsxRuntime.jsx(be,{val:q,mismatch:w})},M)}),p.map((O,M)=>{let q=b[O.key];if(q==null||q==="")return jsxRuntime.jsx("td",{class:"py-2"},`rel-${M}`);let I=O.type==="one"?`${r}/${O.targetRepo}/${encodeURIComponent(String(q))}/edit`:`${r}/${O.targetRepo}?fv_${O.targetKey}=${encodeURIComponent(String(q))}`;return jsxRuntime.jsx("td",{class:"align-middle py-2",children:jsxRuntime.jsx("a",{href:I,class:"btn btn-xs btn-ghost btn-outline","data-frs-relation":true,"data-frs-rel-type":O.type,"data-frs-rel-repo":O.targetRepo,"data-frs-rel-fk":O.targetKey,"data-frs-rel-val":String(q),"data-frs-rel-label":O.column,children:O.column})},`rel-${M}`)}),jsxRuntime.jsx("td",{class:"align-middle text-right whitespace-nowrap py-2",children:jsxRuntime.jsxs("div",{class:"flex gap-1 justify-end",children:[jsxRuntime.jsx("a",{href:R,class:"btn btn-xs btn-outline",children:"Edit"}),B&&jsxRuntime.jsx("a",{href:`${r}/${e}/${encodeURIComponent(A)}/history`,class:"btn btn-xs btn-outline",title:"View change history",children:"History"}),l&&jsxRuntime.jsx("form",{method:"post",action:C,onsubmit:"return confirm('Delete this document?')",children:jsxRuntime.jsx("button",{type:"submit",class:"btn btn-xs btn-error btn-outline",children:"Delete"})})]})})]},N)})})]})}),(a.hasPrev||a.hasNext)&&jsxRuntime.jsxs("div",{class:"flex flex-col items-center mt-6 gap-2",children:[jsxRuntime.jsxs("div",{class:"flex justify-center items-center gap-2",children:[a.hasPrev?jsxRuntime.jsx("a",{href:It(c,a.prevCursor,"prev",f,h),class:"btn btn-sm btn-outline",children:"\u2190 Previous"}):jsxRuntime.jsx("button",{class:"btn btn-sm btn-outline",disabled:true,children:"\u2190 Previous"}),a.hasNext?jsxRuntime.jsx("a",{href:It(c,a.nextCursor,"next",f,h),class:"btn btn-sm btn-outline",children:"Next \u2192"}):jsxRuntime.jsx("button",{class:"btn btn-sm btn-outline",disabled:true,children:"Next \u2192"})]}),typeof y=="number"&&jsxRuntime.jsxs("div",{class:"text-xs text-base-content/50",children:[y," total document",y!==1?"s":"",c.length>0?" matching filters":""]})]}),u&&i&&jsxRuntime.jsxs("dialog",{id:"frs-bulk-update-modal",class:"modal",children:[jsxRuntime.jsxs("div",{class:"modal-box",children:[jsxRuntime.jsx("h3",{class:"font-bold text-lg mb-3",children:"Bulk update field"}),jsxRuntime.jsx("p",{class:"text-sm text-base-content/60 mb-4","data-frs-bulk-update-summary":true,children:"Update one field on the selected documents."}),jsxRuntime.jsxs("form",{method:"dialog","data-frs-bulk-update-form":true,"data-frs-form":true,children:[jsxRuntime.jsxs("label",{class:"form-control w-full mb-3",children:[jsxRuntime.jsx("div",{class:"label",children:jsxRuntime.jsx("span",{class:"label-text text-xs uppercase tracking-wide",children:"Field"})}),jsxRuntime.jsxs("select",{class:"select select-bordered select-sm w-full",name:"field",required:true,"data-frs-bulk-field-select":true,children:[jsxRuntime.jsx("option",{value:"",children:"\u2014 Select a field \u2014"}),x.map(b=>jsxRuntime.jsx("option",{value:b,children:b},b))]})]}),jsxRuntime.jsx("div",{class:"mb-4","data-frs-bulk-value-container":true}),jsxRuntime.jsxs("div",{class:"modal-action",children:[jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-ghost","data-frs-bulk-update-cancel":true,children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",class:"btn btn-sm btn-primary","data-frs-bulk-update-submit":true,children:"Apply"})]})]})]}),jsxRuntime.jsx("form",{method:"dialog",class:"modal-backdrop",children:jsxRuntime.jsx("button",{children:"close"})})]}),jsxRuntime.jsx("div",{class:"hidden","data-frs-bulk-templates":true,children:P.map(b=>jsxRuntime.jsx("div",{"data-frs-bulk-template-for":b.name,dangerouslySetInnerHTML:{__html:Ze(b)}},b.name))})]}))}function Le(e,t){return rt(e,t)}function Nt(e,t){return at(e,t)}function Zt(e,t,n,r,a,o,s,c,l,p,f,h,g,S,y,F,Z,B){return lt(e,t,n,r,a,o,s,c,l,p,f,h,g,S,y,F,Z,B)}function fe(e,t,n,r,a,o){return st(e,t,n,r,a,o)}async function Dt(e,t){if(t)try{let n=e.repo.ref,r=n?.firestore;if(t.startsWith("{"))try{let a=JSON.parse(t);if(a.docPath&&r&&typeof r.doc=="function"){let o=await r.doc(a.docPath).get();if(o.exists)return o}a.docId&&(t=a.docId);}catch{}if(t.includes("/")&&r&&typeof r.doc=="function"){let a=await r.doc(t).get();if(a.exists)return a}if(typeof n.doc=="function"){let a=await n.doc(t).get();if(a.exists)return a}}catch{}}function Be(e,t){return yt(e,{pathKey:t.pathKey,documentKey:t.documentKey??"docId",parentKeys:t.parentKeys,documentPathTemplate:t.documentPathTemplate,isGroup:t.isGroup})}async function ve(e,t){let n=e.documentKey??"docId",r=`by${n.charAt(0).toUpperCase()}${n.slice(1)}`;if(typeof e.repo.get[r]=="function")try{let o=await e.repo.get[r](t);if(o)return o}catch{}return (await e.repo.query.by({where:[[n,"==",t]],limit:1}))[0]??null}function ct(e,t,n){let r=e.documentKey??"docId",a=Qe(n,{ref:e.repo.ref,path:e.path,isGroup:!!e.isGroup,filters:[{field:r,op:"==",value:t}]});return a.type==="index"?{type:"warning",message:"Loading this document requires a composite index that does not exist yet.",...a.indexUrl?{action:{href:a.indexUrl,label:"Create Index \u2192",external:true}}:{}}:{type:"error",message:a.message}}function T(e,t,n=200){e.status(n).set("Content-Type","text/html; charset=utf-8").send(t);}function Me(e,t){e.status(302).set("Location",t).send("");}function Ue(e,t){let n=t.shape,r={};for(let[a,o]of Object.entries(n)){let s=ut(o),c=L(s),l=c==="ZodObject",p=s,f=false;if(c==="ZodUnion"){let S=$e(s);S.some(F=>L(F)==="ZodDate")&&(f=true);let y=S.find(F=>{if(L(F)==="ZodObject"){let Z=Y(F);return "latitude"in Z&&"longitude"in Z}return false});y&&(l=true,p=y);}if(e[a+"__isnull"]==="1"){r[a]=null;continue}if(l){let S={},y=false;for(let[B,U]of Object.entries(e))B.startsWith(`${a}.`)&&(S[B.slice(a.length+1)]=U,y=true);if(y){r[a]=Ue(S,p);continue}let F=e[a],Z=Array.isArray(F)?F[F.length-1]:F;if(Z)try{r[a]=JSON.parse(Z);}catch{r[a]=Z;}continue}let h=e[a],g=Array.isArray(h)?h[h.length-1]:h;if(g===void 0||g===""){c==="ZodBoolean"&&(r[a]=false);continue}if(f){r[a]=new Date(g);continue}switch(c){case "ZodBoolean":g==="__null__"?r[a]=null:r[a]=g==="true"||g==="on"||g==="1";break;case "ZodNumber":case "ZodBigInt":r[a]=Number(g);break;case "ZodDate":r[a]=new Date(g);break;case "ZodArray":try{r[a]=JSON.parse(g);}catch{r[a]=g;}break;default:if(g.startsWith("{")||g.startsWith("["))try{r[a]=JSON.parse(g);break}catch{}r[a]=g;}}return r}function Ft(e){let t=null;if(e instanceof Date)t=e;else if(typeof e=="object"&&e!==null&&typeof e.toDate=="function")t=e.toDate();else if(typeof e=="object"&&e!==null&&"_seconds"in e&&"_nanoseconds"in e)t=new Date(e._seconds*1e3+Math.floor(e._nanoseconds/1e6));else if(typeof e=="string"||typeof e=="number"){let r=new Date(e);isNaN(r.getTime())||(t=r);}if(!t||isNaN(t.getTime()))return null;let n=r=>String(r).padStart(2,"0");return `${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function jt(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable"||n==="ZodDefault")t=X(t);else if(n==="ZodEffects"||n==="ZodPipe"||n==="ZodTransform"){let r=ke(t);if(!r)return n;t=r;}else return n}}function ut(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable"||n==="ZodDefault")t=X(t);else if(n==="ZodEffects"||n==="ZodPipe"||n==="ZodTransform"){let r=ke(t);if(!r)return t;t=r;}else return t}}function Lt(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable")return true;if(n==="ZodDefault"){t=X(t);continue}return false}}function Bt(e){let t=ut(e),n=L(t);if(n==="ZodEnum"){let r=Se(t);return r.length>0?r:void 0}if(n==="ZodNativeEnum"){let r=Ae(t),a=Object.values(r).filter(o=>typeof o=="string");return a.length>0?a:void 0}if(n==="ZodLiteral"){let r=Re(t);return typeof r=="string"?[r]:void 0}}function Mt(e,t,n=""){let r={};for(let a of Object.keys(t.shape)){let o=n?`${n}.${a}`:a,s=e[a];if(s===null){r[o]="__null__";continue}if(s===void 0)continue;let c=ut(t.shape[a]),l=L(c),p=l==="ZodObject",f=c,h=false;if(l==="ZodUnion"){let g=$e(c);g.some(y=>L(y)==="ZodDate")&&(h=true);let S=g.find(y=>{if(L(y)==="ZodObject"){let F=Y(y);return "latitude"in F&&"longitude"in F}return false});S&&(p=true,f=S);}if(p&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&!("_seconds"in s)&&typeof s.toDate!="function"){let g=Mt(s,f,o);Object.assign(r,g);}else if(l==="ZodDate"||h){let g=Ft(s);g!==null&&(r[o]=g);}else if(typeof s=="object"&&s!==null&&!Array.isArray(s)&&("_seconds"in s||typeof s.toDate=="function")){let g=Ft(s);r[o]=g??JSON.stringify(s,null,2);}else typeof s=="object"?r[o]=JSON.stringify(s,null,2):r[o]=String(s);}return r}function dt(e,t){return e.map(n=>({...n,defaultValue:t[n.name]??n.defaultValue,nested:n.nested?dt(n.nested,t):void 0}))}function Fn(e,t){let n=new Set(["==","!=","<","<=",">",">=","in","not-in","array-contains","array-contains-any"]),r=[];for(let[a,o]of Object.entries(e)){if(!a.startsWith("fv_"))continue;let s=a.slice(3);if(!t.has(s))continue;let c=(o??"").trim();if(!c)continue;let l=e[`fo_${s}`]??"==",p=n.has(l)?l:"==";r.push({field:s,op:p,value:c});}return r}function zt(e){let t="__null__",n=r=>r===t?null:r==="true"?true:r==="false"?false:r!==""&&!isNaN(Number(r))?Number(r):r;return e.map(r=>{if(r.op==="array-contains-any"||r.op==="in"||r.op==="not-in"){let a=r.value.split(",").map(o=>o.trim()).filter(o=>o!==""&&o!==t).map(o=>n(o));return [r.field,r.op,a]}return [r.field,r.op,n(r.value)]})}function Ut(e,t,n=""){let r=[];for(let a of e){let o=n?`${n}.${a}`:a,s=t.shape[a];if(!s){r.push({name:o,zodType:"ZodString"});continue}let c=jt(s);if(c==="ZodObject"){let l=s;for(;;){let f=L(l);if(f==="ZodOptional"||f==="ZodNullable"||f==="ZodDefault")l=X(l);else break}let p=Y(l);r.push(...Ut(Object.keys(p),l,o));}else r.push({name:o,zodType:c,nullable:Lt(s),enumValues:Bt(s)});}return r}function zn(e,t){let n=t.split("."),r=e;for(let a of n){for(;;){let s=L(r);if(s==="ZodOptional"||s==="ZodNullable"||s==="ZodDefault")r=X(r);else break}let o=Y(r);if(!(a in o))return null;r=o[a];}return r}function me(e,t){if(!t||t.length===0)return e;let n=[],r=new Map;for(let o of t){let s=o.indexOf(".");if(s===-1)n.push(o);else {let c=o.slice(0,s),l=o.slice(s+1);r.has(c)||r.set(c,[]),r.get(c).push(l);}}let a={};for(let o of n)o in e.shape&&(a[o]=e.shape[o]);for(let[o,s]of r){if(!(o in e.shape))continue;let c=e.shape[o];for(;;){let l=L(c);if(l==="ZodOptional"||l==="ZodNullable"||l==="ZodDefault")c=X(c);else break}if(L(c)!=="ZodObject"){a[o]=e.shape[o];continue}a[o]=me(c,s);}return zod.z.object(a)}function ne(e,t,n){return He(e,t,n)}function Ht(e,t,n){let r=(v,m)=>{let x=ne(v,t,n),i=Object.values(e).map(d=>({name:d.name,path:d.path}));T(m,Nt(i,x));},a=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=i.pageSize??25,u=v.query??{},E=u.cursor,P=u.dir==="prev"?"prev":"next",b=u.ob??"",N=u.od==="desc"?"desc":"asc",A=b?{field:b,dir:N}:void 0,R=parseInt(u.ps??""),C=Number.isFinite(R)&&R>0?Math.min(R,200):d,O=i.listColumns??Object.keys(i.schema.shape),M=i.documentKey??"docId",q=[M,...O.filter(Q=>Q!==M)];A&&(new Set([M,...O]).has(A.field)||(A=void 0));let I=i.filterableFields?(()=>{let Q=[];for(let ae of i.filterableFields)(ae.includes(".")||O.includes(ae))&&Q.push(ae);return Q})():O,w=(()=>{let Q=[];for(let ae of I)if(ae.includes(".")){let ye=zn(i.schema,ae);Q.push({name:ae,zodType:ye?jt(ye):"ZodString",nullable:ye?Lt(ye):false,enumValues:ye?Bt(ye):void 0});}else Q.push(...Ut([ae],i.schema));return Q})(),K=new Set(w.map(Q=>Q.name)),ce=Fn(u,K),re=zt(ce),xe;E&&(xe=await Dt(i,E));let[H,he]=await Promise.all([i.repo.query.paginate({pageSize:C,cursor:xe,direction:P,...re.length>0?{where:re}:{},...A?{orderBy:[{field:A.field,direction:A.dir}]}:{}}).catch(Q=>({queryError:Qe(Q,{ref:i.repo.ref,path:i.path,isGroup:!!i.isGroup,filters:ce,sort:A})})),i.repo.aggregate.count(re.length>0?{where:re}:{}).catch(()=>{})]),oe="queryError"in H,Jt=oe?[]:H.data,Gt=oe?"":H.nextCursor?.ref?.path??H.nextCursor?.id??"",Wt=oe?"":H.prevCursor?.ref?.path??H.prevCursor?.id??"",Qt=oe?H.queryError:void 0,Xt=ne(v,t,n),we,Pe=u.flash;Pe==="created"?we={type:"success",message:"Document created successfully."}:Pe==="updated"?we={type:"success",message:"Document updated successfully."}:Pe==="deleted"?we={type:"success",message:"Document deleted successfully."}:Pe==="backfilled"&&(we={type:"success",message:"Repository backfilled successfully."}),T(m,Zt(i.name,Jt,q,Xt,{hasPrev:oe?false:H.hasPrevPage,hasNext:oe?false:H.hasNextPage,prevCursor:Wt,nextCursor:Gt},we,w,ce,i.allowDelete??false,i.relationalMeta,A,C,Qt,i.isGroup,he,i.mutableFields,i.schema,i.historyEnabled));},o=(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=me(i.schema,i.createFields),E=ee(u),P=`${d}/${i.name}/create`,b=de(E,P,"POST","Create document");T(m,fe(i.name,b,"create",null,d));},s=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=v.body??{},E=Ue(u,i.schema),P=me(i.schema,i.createFields),b=P.safeParse(E);if(!b.success){let N=ee(P),A=`${d}/${i.name}/create`,R=de(N,A,"POST","Create document"),C=b.error.issues.map(O=>`${O.path.join(".")}: ${O.message}`).join(", ");T(m,fe(i.name,R,"create",null,d,{type:"error",message:`Validation error: ${C}`}),422);return}try{if(i.isGroup&&i.parentKeys&&i.parentKeys.length>0){let N={...b.data},A=i.parentKeys.filter(R=>N[R]===void 0||N[R]===null||typeof N[R]=="string"&&N[R].trim()==="");if(A.length>0)throw new Error(`Missing parent key(s) for subcollection create: ${A.join(", ")}`);if(typeof i.repo.create=="function")await i.repo.create(N);else {let R=i.parentKeys.map(M=>String(N[M])),C=i.documentKey??"docId",O=N[C]||ft();await i.repo.set(...R,O,N);}}else await i.repo.create(b.data);Me(m,`${d}/${i.name}?flash=created`);}catch(N){let A=me(i.schema,i.createFields),R=ee(A),C=`${d}/${i.name}/create`,O=de(R,C,"POST","Create document");T(m,fe(i.name,O,"create",null,d,{type:"error",message:`Save error: ${N.message}`}),500);}},c=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}let u=ne(v,t,n),E=null;try{E=await ve(d,i);}catch(C){let O=ct(d,i,C),M=ue(C)?424:500;T(m,Le("",{title:`Edit ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`Edit ${i}`}],flash:O}),M);return}if(!E){T(m,"Document not found",404);return}let P=Mt(E,d.schema),b=me(d.schema,d.mutableFields),N=dt(ee(b),P),A=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,R=de(N,A,"POST","Save changes");T(m,fe(d.name,R,"edit",i,u));},l=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}let u=ne(v,t,n),E=v.body??{},P=Ue(E,d.schema),b=me(d.schema,d.mutableFields),A=b.partial().safeParse(P);if(!A.success){let R=Object.fromEntries(Object.entries(E).map(([I,w])=>[I,Array.isArray(w)?w.join(","):w??""])),C=dt(ee(b),R),O=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,M=de(C,O,"POST","Save changes"),q=A.error.issues.map(I=>`${I.path.join(".")}: ${I.message}`).join(", ");T(m,fe(d.name,M,"edit",i,u,{type:"error",message:`Validation error: ${q}`}),422);return}try{let R=await ve(d,i),C=(R&&Be(R,d))??[i];await d.repo.update(...C,A.data),Me(m,`${u}/${d.name}?flash=updated`);}catch(R){let C=me(d.schema,d.mutableFields),O=ee(C),M=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,q=de(O,M,"POST","Save changes"),I=ue(R)?ct(d,i,R):{type:"error",message:`Save error: ${R.message}`},w=ue(R)?424:500;T(m,fe(d.name,q,"edit",i,u,I),w);}},p=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}if(!d.allowDelete){T(m,"Delete is not allowed for this repository",403);return}let u=ne(v,t,n);try{let E=await ve(d,i),P=(E&&Be(E,d))??[i];await d.repo.delete(...P),Me(m,`${u}/${d.name}?flash=deleted`);}catch(E){let P=ue(E)?ct(d,i,E):{type:"error",message:`Delete error: ${E.message}`},b=ue(E)?424:500;T(m,Le("",{title:`Delete ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`Delete ${i}`}],flash:P}),b);}},f=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=v.query,E=u?.type==="many"?"many":"one",P=Math.max(1,Math.min(100,Number(u?.ps??25)||25)),b=i.listColumns??Object.keys(Y(i.schema)),{PanelOne:N,PanelMany:A}=await Promise.resolve().then(()=>(nt(),Ot)),{renderToString:R}=await import('hono/jsx/dom/server');if(E==="one"){let w=String(u?.id??"");if(!w){T(m,"<div class='p-6 text-error'>Missing id parameter.</div>",400);return}try{let K=await ve(i,w),ce=R(N({doc:K,repoName:i.name,basePath:d,schema:i.schema,columns:b}));T(m,ce);}catch(K){T(m,`<div class='p-6 text-error text-sm'>Error: ${K.message}</div>`,500);}return}let C=String(u?.fk??""),O=String(u?.fv??"");if(!C||!O){T(m,"<div class='p-6 text-error'>Missing fk/fv parameters.</div>",400);return}let M=u?.cursor??"",q=u?.dir==="prev"?"prev":"next",I;M&&(I=await Dt(i,M));try{let w=await i.repo.query.paginate({pageSize:P,cursor:I,direction:q,where:[[C,"==",jn(O)]]}),K=R(A({docs:w.data,repoName:i.name,basePath:d,fk:C,fv:O,columns:b,schema:i.schema,pagination:{hasPrev:w.hasPrevPage,hasNext:w.hasNextPage,prevCursor:w.prevCursor?.ref?.path??w.prevCursor?.id??"",nextCursor:w.nextCursor?.ref?.path??w.nextCursor?.id??"",pageSize:P}}));T(m,K);}catch(w){T(m,`<div class='p-6 text-error text-sm'>Error: ${w.message}</div>`,500);}},h=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n);try{await i.repo.system.backfillKeys(),Me(m,`${d}/${i.name}?flash=backfilled`);}catch(u){T(m,`<div class="p-6 text-error">Backfill failed: ${u.message}</div>`,500);}},g=async(v,m)=>{let x=[];for(let i of m){let d;if(v.isGroup||v.parentKeys?.length){let u=await ve(v,i);d=u?Be(u,v):void 0;}d||(d=[i]);try{let u=v.repo.documentRef(...d);u&&x.push(u);}catch{}}return x},S=async(v,m)=>{let x=zt(m),i=v.documentKey??"docId",d=[],u;for(;;){let E=await v.repo.query.paginate({pageSize:500,cursor:u,direction:"next",...x.length>0?{where:x}:{}});for(let P of E.data){let b=String(P[i]??P.id??"");b&&d.push(b);}if(!E.hasNextPage||!E.nextCursor)break;u=E.nextCursor;}return d},y=async(v,m)=>{let x=v.params.repoName;if(!x){W(m,{error:"Bad request"},400);return}let i=e[x];if(!i){W(m,{error:"Repository not found"},404);return}if(!i.allowDelete){W(m,{error:"Delete is not allowed for this repository"},403);return}let d=v.body??{};try{let u=await Z(i,d);if(u.length===0){W(m,{deleted:0});return}let E=await g(i,u);for(let P=0;P<E.length;P+=500)await i.repo.bulk.delete(E.slice(P,P+500));W(m,{deleted:E.length});}catch(u){W(m,{error:u.message},500);}},F=async(v,m)=>{let x=v.params.repoName;if(!x){W(m,{error:"Bad request"},400);return}let i=e[x];if(!i){W(m,{error:"Repository not found"},404);return}let d=v.body??{},u=String(d.field??"");if(!u){W(m,{error:"Missing 'field'"},400);return}if(!i.mutableFields||!i.mutableFields.includes(u)){W(m,{error:`Field '${u}' is not bulk-updatable`},403);return}let E=i.schema.shape?.[u],P;if(E){let b=typeof i.schema=="object"&&i.schema&&"constructor"in i.schema&&i.schema.constructor.name.includes("Zod")?i.schema.pick({[u]:true}):void 0;if(!b){W(m,{error:"Invalid schema structure"},500);return}P=Ue(d.formPayload??{},b)[u];let A=E.safeParse(P);if(!A.success){W(m,{error:`Invalid value for '${u}': ${A.error.message}`},400);return}P=A.data;}try{let b=await Z(i,d);if(b.length===0){W(m,{updated:0});return}let A=(await g(i,b)).map(R=>({docRef:R,data:{[u]:P}}));for(let R=0;R<A.length;R+=500)await i.repo.bulk.update(A.slice(R,R+500));W(m,{updated:A.length});}catch(b){W(m,{error:b.message},500);}};async function Z(v,m){if(m.selectAll){let x=B(m.filters,v);return await S(v,x)}return Array.isArray(m.ids)?m.ids.filter(x=>typeof x=="string"&&!!x):[]}function B(v,m){if(!Array.isArray(v))return [];let x=new Set((m.filterableFields??Object.keys(Y(m.schema))).map(u=>String(u))),i=new Set(["==","!=","<","<=",">",">=","in","not-in","array-contains","array-contains-any"]),d=[];for(let u of v)u&&typeof u=="object"&&typeof u.field=="string"&&x.has(u.field)&&typeof u.value=="string"&&i.has(String(u.op))&&d.push({field:u.field,op:u.op,value:u.value});return d}return {handleDashboard:r,handleList:a,handleCreateForm:o,handleCreateSubmit:s,handleEditForm:c,handleEditSubmit:l,handleDelete:p,handlePanel:f,handleBulkDelete:y,handleBulkUpdate:F,handleBulkBackfill:h,handleHistory:async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}if(!d.historyEnabled||!d.repo.history){T(m,"History not enabled for this repository",404);return}let u=ne(v,t,n),E=d.historySubcollection??"history",P=[i];try{let w=await ve(d,i),K=w?Be(w,d):void 0;K&&K.length>0&&(P=K);}catch{}let b=parseInt(String(v.query?.limit??"")),N=Number.isFinite(b)&&b>0?Math.min(b,500):100,A=[],R;try{A=await d.repo.history.list(...P,{limit:N});}catch(w){R=w.message;}let C=w=>String(w??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),O=w=>{if(w===void 0)return '<span class="opacity-40">undefined</span>';if(w===null)return '<span class="opacity-40">null</span>';if(typeof w=="object")try{return `<code class="text-xs">${C(JSON.stringify(w))}</code>`}catch{return C(String(w))}return C(String(w))},M=w=>w?typeof w.toDate=="function"?w.toDate().toISOString():w instanceof Date?w.toISOString():C(String(w)):"",q=w=>`<span class="badge badge-sm ${w==="create"?"badge-success":w==="delete"?"badge-error":w==="custom"?"badge-secondary":"badge-info"}">${C(w)}</span>`,I="";if(I+='<div class="flex items-center justify-between mb-4">',I+=`<a href="${u}/${d.name}/${encodeURIComponent(i)}/edit" class="btn btn-sm btn-outline">\u2190 Back to edit</a>`,I+=`<a href="${u}/${d.name}" class="btn btn-sm btn-outline">\u2190 Back to list</a>`,I+="</div>",I+=`<p class="text-sm text-base-content/60 mb-4">Subcollection: <code>${C(E)}</code> \xB7 Showing up to ${N} entries.</p>`,R)I+=`<div class="alert alert-error mb-4">${C(R)}</div>`;else if(A.length===0)I+='<div class="alert">No history entries found.</div>';else {I+='<div class="overflow-x-auto"><table class="table table-zebra table-sm">',I+="<thead><tr><th>When</th><th>Op</th><th>User</th><th>Reason / Comment</th><th>Changes</th></tr></thead><tbody>";for(let w of A){let K=w.meta??{},ce=[K.reason,K.comment].filter(H=>H!=null&&H!=="").map(H=>C(String(H))).join(" \u2014 "),re="",xe=Object.keys(w.changes??{});if(w.custom){let H=`<strong>${C(w.custom.title)}</strong>`,he=w.custom.key?` <code class="text-xs opacity-60">${C(w.custom.key)}</code>`:"",oe=w.custom.description?`<div class="text-xs opacity-80 mt-0.5">${C(w.custom.description)}</div>`:"";re=`<div>${H}${he}${oe}</div>`;}else xe.length===0?re='<span class="opacity-40">\u2014</span>':re='<ul class="space-y-1">'+xe.map(H=>{let he=w.changes[H];return `<li><strong>${C(H)}</strong>: ${O(he.oldValue)} \u2192 ${O(he.newValue)}</li>`}).join("")+"</ul>";I+="<tr>",I+=`<td class="whitespace-nowrap text-xs font-mono">${C(M(w.historySetAt))}</td>`,I+=`<td>${q(w.operation??"update")}</td>`,I+=`<td class="text-xs">${C(K.userEmail??K.userId??"")}</td>`,I+=`<td class="text-xs">${ce}</td>`,I+=`<td>${re}</td>`,I+="</tr>";}I+="</tbody></table></div>";}T(m,Le(I,{title:`History \u2014 ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`History ${i}`}]}));}}}function W(e,t,n=200){e.status(n).set("Content-Type","application/json; charset=utf-8").send(JSON.stringify(t));}function jn(e){return e==="true"?true:e==="false"?false:e!==""&&!isNaN(Number(e))?Number(e):e}function Ln(e){let t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,r=>r===":"?r:`\\${r}`).replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,a)=>(t.push(a),"([^/]+)"));return {pattern:new RegExp(`^${n}$`),paramNames:t}}function Bn(e){let t=e.path??e.url??"/",n=t.indexOf("?");return n===-1?t:t.slice(0,n)}var _e=class{constructor(){this.routes=[];this.middlewares=[];this.notFoundHandler=(t,n)=>{n.status(404).send("Not Found");};this.errorHandler=(t,n,r)=>{console.error("[MiniRouter]",t),r.status(500).send("Internal Server Error");};}use(t){return this.middlewares.push(t),this}get(t,n){return this.addRoute("GET",t,n)}post(t,n){return this.addRoute("POST",t,n)}put(t,n){return this.addRoute("PUT",t,n)}patch(t,n){return this.addRoute("PATCH",t,n)}delete(t,n){return this.addRoute("DELETE",t,n)}onNotFound(t){return this.notFoundHandler=t,this}onError(t){return this.errorHandler=t,this}addRoute(t,n,r){let{pattern:a,paramNames:o}=Ln(n);return this.routes.push({method:t.toUpperCase(),pattern:a,paramNames:o,handler:r}),this}async handle(t,n){let r=(t.method??"GET").toUpperCase(),a=Bn(t),o=null,s={};for(let p of this.routes){if(p.method!==r)continue;let f=a.match(p.pattern);if(f){o=p,s={},p.paramNames.forEach((h,g)=>{s[h]=decodeURIComponent(f[g+1]??"");});break}}let c=Object.assign(t,{params:s}),l=o?o.handler:this.notFoundHandler;try{await this.runMiddlewareChain(c,n,l);}catch(p){this.errorHandler(p,t,n);}}async runMiddlewareChain(t,n,r){let a=0,o=async()=>{if(a<this.middlewares.length){let s=this.middlewares[a++];await s(t,n,o);}else await r(t,n);};await o();}};var qt="https://cdn.jsdelivr.net",Vt="https://www.gstatic.com",Mn=["default-src 'self'",`script-src 'self' 'unsafe-inline' 'unsafe-eval' ${qt} ${Vt}`,`style-src 'self' 'unsafe-inline' ${qt}`,`connect-src 'self' ${Vt} https://*.googleapis.com https://*.firebaseio.com https://identitytoolkit.googleapis.com`,"img-src 'self' data:","font-src 'self' data:","frame-ancestors 'none'","base-uri 'self'","form-action 'self'"].join("; ");function Kt(e={}){let t=e.csp===void 0?Mn:e.csp,n=e.frameOptions===void 0?"DENY":e.frameOptions,r=e.referrerPolicy===void 0?"no-referrer":e.referrerPolicy,a=e.cacheControl===void 0?"private, no-store":e.cacheControl;return async(o,s,c)=>{typeof s?.setHeader=="function"&&(s.setHeader("X-Content-Type-Options","nosniff"),n&&s.setHeader("X-Frame-Options",n),r&&s.setHeader("Referrer-Policy",r),a&&s.setHeader("Cache-Control",a),t&&s.setHeader("Content-Security-Policy",t)),await c();}}async function Un(e){return typeof e.rawBody=="string"?e.rawBody:Buffer.isBuffer(e.rawBody)?e.rawBody.toString("utf8"):""}function Hn(e){let t={};if(!e)return t;for(let n of e.split("&")){let r=n.indexOf("=");if(r===-1)continue;let a=decodeURIComponent(n.slice(0,r).replace(/\+/g," ")),o=decodeURIComponent(n.slice(r+1).replace(/\+/g," ")),s=t[a];s===void 0?t[a]=o:Array.isArray(s)?s.push(o):t[a]=[s,o];}return t}function ga(e){let{basePath:t="/",repos:n,parseBody:r=true,securityHeaders:a,auth:o,middleware:s=[],httpsOptions:c}=e,l=t==="/"?"":t.replace(/\/$/,""),p={};for(let[S,y]of Object.entries(n)){if(!y.repo)throw new Error(`[createAdminServer] Repository "${S}" has no 'repo' defined. Did you forget to pass it or is there a circular import?`);let F=y.schema??y.repo.schema??null;if(!F)throw new Error(`[createAdminServer] Repository "${S}" has no Zod schema. Either use createRepositoryConfig(schema)(config) or pass schema: explicitly.`);let Z,B,U;if(y.fieldsConfig){let x=y.fieldsConfig;Z=[],B=[],U=[];for(let[i,d]of Object.entries(x))for(let u of d)u==="filterable"?Z.push(i):u==="mutable"?B.push(i):u==="create"&&U.push(i);Z.length===0&&(Z=void 0),B.length===0&&(B=void 0),U.length===0&&(U=void 0);}let v=(()=>{let x=y.repo._parentKeys;return x&&x.length>0?x:void 0})();if(v&&U)for(let x of v)U.includes(x)||U.push(x);let m={name:S,path:y.path,repo:y.repo,schema:F,documentKey:y.documentKey??"docId",pathKey:y.repo._pathKey??void 0,isGroup:!!y.repo._isGroup,parentKeys:v,documentPathTemplate:y.repo._documentPathTemplate??void 0,createdKey:y.repo._createdKey??void 0,listColumns:y.listColumns,pageSize:y.pageSize,filterableFields:Z,mutableFields:B,createFields:U,allowDelete:y.allowDelete??false,historyEnabled:!!y.repo._historyConfig?.enabled,historySubcollection:(y.repo._historyConfig?.enabled&&y.repo._historySubcollection)??void 0,relationalMeta:(()=>{if(!y.relationalFields||y.relationalFields.length===0)return;let x=y.repo.relationalKeys??{},i=[];for(let d of y.relationalFields){let u=x[d.key];u&&i.push({key:u.sourceKey?String(u.sourceKey):d.key,column:d.column,targetRepo:String(u.repo),targetKey:String(u.key),type:u.type});}return i.length>0?i:void 0})()};p[S]=m;}let f=Ht(p,l,pt(c?.region)),h=new _e;if(a!==false&&h.use(Kt(a===void 0?{}:a)),r&&h.use(async(S,y,F)=>{let Z=S,B=String(Z.headers?.["content-type"]??"");if(B.includes("application/x-www-form-urlencoded")){let U=await Un(Z);S.body=Hn(U);}else if(B.includes("application/json")&&typeof Z.body=="string")try{S.body=JSON.parse(Z.body);}catch{}await F();}),o)if(qe(o)){for(let S of o.routes){let y=`${l}${S.path}`;S.method==="GET"?h.get(y,S.handler):h.post(y,S.handler);}h.use(o.middleware);}else if(typeof o=="function")h.use(o);else {let S=o.realm??"Admin",y="Basic "+Buffer.from(`${o.username}:${o.password}`).toString("base64");h.use((F,Z,B)=>{if((F.headers?.authorization??"")!==y){Z.status(401).set("WWW-Authenticate",`Basic realm="${S}"`).set("Content-Type","text/plain").send("Unauthorized");return}B();});}for(let S of s)h.use(S);h.get(`${l}/`,f.handleDashboard),h.get(`${l}`,f.handleDashboard),h.get(`${l}/:repoName/_panel`,f.handlePanel),h.post(`${l}/:repoName/_bulk/delete`,f.handleBulkDelete),h.post(`${l}/:repoName/_bulk/update`,f.handleBulkUpdate),h.post(`${l}/:repoName/_bulk/backfill`,f.handleBulkBackfill),h.get(`${l}/:repoName`,f.handleList),h.get(`${l}/:repoName/create`,f.handleCreateForm),h.post(`${l}/:repoName/create`,f.handleCreateSubmit),h.get(`${l}/:repoName/:id/edit`,f.handleEditForm),h.post(`${l}/:repoName/:id/edit`,f.handleEditSubmit),h.get(`${l}/:repoName/:id/history`,f.handleHistory),h.post(`${l}/:repoName/:id/delete`,f.handleDelete);let g=async(S,y)=>{await h.handle(S,y);};return c&&(g.httpsOptions=c),g}
1058
+ `;function ze(){return jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:Et}})}nt();function se(e){return "<!DOCTYPE html>"+server.renderToString(e)}var Rn=["corporate","silk","dark"],$n=()=>jsxRuntime.jsxs("div",{class:"dropdown dropdown-end","data-frs-theme-switcher":true,children:[jsxRuntime.jsxs("button",{type:"button",tabIndex:0,class:"btn btn-sm btn-ghost text-neutral-content gap-1.5","aria-label":"Switch theme",children:[jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",class:"size-4",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"}),jsxRuntime.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),jsxRuntime.jsx("span",{class:"text-xs hidden sm:inline","data-frs-theme-current":true,children:"Theme"})]}),jsxRuntime.jsx("ul",{tabIndex:0,class:"dropdown-content menu menu-sm bg-base-100 text-base-content rounded-box z-50 mt-2 w-40 p-1 shadow-lg border border-base-300",children:Rn.map(e=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button","data-frs-theme":e,class:"capitalize justify-between",children:[jsxRuntime.jsx("span",{children:e}),jsxRuntime.jsx("span",{class:"hidden text-primary","data-frs-theme-check":e,children:"\u2713"})]})},e))})]}),ie=({opts:e,children:t})=>{let{title:n,breadcrumb:r,flash:a,basePath:o="/"}=e;return jsxRuntime.jsxs("html",{lang:"en","data-theme":"corporate",children:[jsxRuntime.jsxs("head",{children:[jsxRuntime.jsx("meta",{charset:"UTF-8"}),jsxRuntime.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),jsxRuntime.jsxs("title",{children:[n," \u2014 FRS Admin"]}),jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:"(function(){try{var t=localStorage.getItem('frs-admin-theme');if(t){document.documentElement.setAttribute('data-theme',t);}}catch(_){}})();"}}),jsxRuntime.jsx("link",{href:"https://cdn.jsdelivr.net/npm/daisyui@5/themes.css",rel:"stylesheet",type:"text/css"}),jsxRuntime.jsx("link",{href:"https://cdn.jsdelivr.net/npm/daisyui@5/daisyui.css",rel:"stylesheet",type:"text/css"}),jsxRuntime.jsx("script",{src:"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"})]}),jsxRuntime.jsxs("body",{class:"bg-base-200/50 min-h-screen flex flex-col",children:[jsxRuntime.jsxs("div",{class:"navbar bg-neutral text-neutral-content shadow-sm sticky top-0 z-50 px-6",children:[jsxRuntime.jsx("div",{class:"flex-1",children:jsxRuntime.jsx("a",{href:o,class:"font-bold text-lg tracking-tight hover:opacity-80 transition-opacity",children:"FRS Admin"})}),jsxRuntime.jsx("div",{class:"flex-none",children:jsxRuntime.jsx($n,{})})]}),jsxRuntime.jsxs("main",{class:"px-6 py-8 w-full flex-1",children:[r&&r.length>0&&jsxRuntime.jsx("div",{class:"text-sm breadcrumbs mb-4",children:jsxRuntime.jsx("ul",{children:r.map((s,c)=>s.href?jsxRuntime.jsx("li",{children:jsxRuntime.jsx("a",{href:s.href,children:s.label})},c):jsxRuntime.jsx("li",{class:"text-base-content/60",children:s.label},c))})}),jsxRuntime.jsx("h1",{class:"text-2xl font-bold mb-6",children:n}),a&&jsxRuntime.jsxs("div",{role:"alert",class:`alert ${a.type==="success"?"alert-success":a.type==="warning"?"alert-warning":"alert-error"} mb-6`,children:[jsxRuntime.jsx("span",{class:"flex-1",children:a.message}),a.action&&jsxRuntime.jsx("a",{href:a.action.href,...a.action.external?{target:"_blank",rel:"noopener noreferrer"}:{},class:"btn btn-sm btn-outline",children:a.action.label})]}),t]}),jsxRuntime.jsx(tt,{basePath:o}),jsxRuntime.jsx(ze,{})]})]})};function rt(e,t){return se(jsxRuntime.jsx(ie,{opts:t,children:jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:e}})}))}function at(e,t){return se(jsxRuntime.jsx(ie,{opts:{title:"Repositories",basePath:t},children:e.length===0?jsxRuntime.jsxs("div",{class:"text-center py-20 text-base-content/50",children:[jsxRuntime.jsx("p",{class:"text-lg font-medium mb-1",children:"No repositories configured"}),jsxRuntime.jsx("p",{class:"text-sm",children:"Add a repository to your FRS config to get started."})]}):jsxRuntime.jsx("div",{class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:e.map(n=>jsxRuntime.jsx("a",{href:`${t}/${n.name}`,class:"card bg-base-100 border border-base-300 hover:shadow-md no-underline transition-shadow",children:jsxRuntime.jsxs("div",{class:"card-body p-5",children:[jsxRuntime.jsx("h2",{class:"card-title text-sm font-semibold",children:n.name}),jsxRuntime.jsx("p",{class:"text-xs text-base-content/50 font-mono",children:n.path})]})},n.name))})}))}var Pt=[{value:"==",label:"="},{value:"!=",label:"\u2260"},{value:"in",label:"in"},{value:"not-in",label:"not in"}],Cn=[{value:"==",label:"="},{value:"!=",label:"\u2260"},{value:"<",label:"<"},{value:"<=",label:"\u2264"},{value:">",label:">"},{value:">=",label:"\u2265"},{value:"in",label:"in"},{value:"not-in",label:"not in"}],En=[{value:"array-contains",label:"contains"},{value:"array-contains-any",label:"contains any"}];function Tn(e){switch(e){case "ZodNumber":case "ZodBigInt":case "ZodDate":return Cn;case "ZodBoolean":return Pt;case "ZodArray":return En;default:return Pt}}var le="__null__";function On(e){return `(function(cb){var i=document.getElementById('${e}');if(!i)return;if(cb.checked){i.dataset._prev=i.value;if(i.tagName==='SELECT'){var o=i.querySelector('option[value="${le}"]');if(!o){o=document.createElement('option');o.value='${le}';o.textContent='\u2205 null';o.dataset._auto='1';i.appendChild(o);}o.selected=true;}else{if(i.type==='number'||i.type==='datetime-local'){i.dataset._type=i.type;i.type='text';}i.value='${le}';i.readOnly=true;}i.style.opacity='0.55';}else{i.style.opacity='';if(i.tagName==='SELECT'){var o2=i.querySelector('option[value="${le}"][data-_auto="1"]');if(o2)o2.remove();var prev=i.dataset._prev||'';for(var k=0;k<i.options.length;k++)i.options[k].selected=(i.options[k].value===prev);}else{if(i.dataset._type){i.type=i.dataset._type;delete i.dataset._type;}i.readOnly=false;i.value=(i.dataset._prev&&i.dataset._prev!=='${le}')?i.dataset._prev:'';}}})(this)`}function _n(e,t){return `(function(){var h=document.getElementById('${e}');var boxes=document.querySelectorAll('input[data-enum-group="${t}"]');h.value=Array.from(boxes).filter(function(b){return b.checked;}).map(function(b){return b.value;}).join(',');})()`}function Oe({inputId:e,active:t}){return jsxRuntime.jsxs("label",{class:"flex items-center gap-1 cursor-pointer select-none text-xs text-base-content/60 hover:text-base-content border border-base-300 rounded-md px-1.5 py-1 shrink-0 leading-none h-8",title:"Filter where field IS NULL",children:[jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs",checked:t,onchange:On(e)}),jsxRuntime.jsx("span",{children:"\u2205"})]})}function Pn({col:e,active:t}){let n=t?.value??"",r=n===le,a=`fv_input_${e.name.replace(/\./g,"__")}`,o=t?.op,s=o==="in"||o==="not-in";if(e.enumValues&&e.enumValues.length>0){if(s){let c=new Set(n.split(",").map(p=>p.trim()).filter(Boolean)),l=`eg_${e.name.replace(/\./g,"__")}`;return jsxRuntime.jsxs("div",{class:"flex flex-wrap items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{type:"hidden",id:a,name:`fv_${e.name}`,value:n}),e.enumValues.map(p=>jsxRuntime.jsxs("label",{class:"flex items-center gap-1 text-xs border border-base-300 rounded px-2 cursor-pointer hover:bg-base-200",children:[jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs",value:p,checked:c.has(p),"data-enum-group":l,onchange:_n(a,l)}),jsxRuntime.jsx("span",{children:p})]},p))]})}return jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsxs("select",{id:a,name:`fv_${e.name}`,class:"select select-sm select-bordered w-full",style:r?"opacity:0.55":void 0,children:[jsxRuntime.jsx("option",{value:"",selected:n===""&&!r,children:"\u2014"}),e.enumValues.map(c=>jsxRuntime.jsx("option",{value:c,selected:n===c,children:c},c)),e.nullable&&jsxRuntime.jsx("option",{value:le,"data-_auto":"1",selected:r,children:"\u2205 null"})]}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]})}if(e.zodType==="ZodBoolean")return jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsxs("select",{id:a,name:`fv_${e.name}`,class:"select select-sm select-bordered w-full",style:r?"opacity:0.55":void 0,children:[jsxRuntime.jsx("option",{value:"",selected:n===""&&!r,children:"\u2014"}),jsxRuntime.jsx("option",{value:"true",selected:n==="true",children:"true"}),jsxRuntime.jsx("option",{value:"false",selected:n==="false",children:"false"}),e.nullable&&jsxRuntime.jsx("option",{value:le,"data-_auto":"1",selected:r,children:"\u2205 null"})]}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]});if(e.zodType==="ZodArray"){let c=t?.op==="array-contains-any";return jsxRuntime.jsx("input",{id:a,type:"text",name:`fv_${e.name}`,value:n,placeholder:c?"val1, val2, \u2026":"value",class:"input input-sm input-bordered w-full"})}return e.zodType==="ZodNumber"||e.zodType==="ZodBigInt"?jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:r?"text":"number",name:`fv_${e.name}`,value:n,placeholder:"value",class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0,"data-_type":r?"number":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]}):e.zodType==="ZodDate"?jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:r?"text":"datetime-local",name:`fv_${e.name}`,value:n,class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0,"data-_type":r?"datetime-local":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]}):jsxRuntime.jsxs("div",{class:"flex items-center gap-1 w-full",children:[jsxRuntime.jsx("input",{id:a,type:"text",name:`fv_${e.name}`,value:n,placeholder:"value",class:"input input-sm input-bordered w-full",readOnly:r||void 0,style:r?"opacity:0.55":void 0}),e.nullable&&jsxRuntime.jsx(Oe,{inputId:a,active:r})]})}function ot({action:e,columnMeta:t,activeFilters:n,isGroup:r}){let a=Object.fromEntries(n.map(l=>[l.field,l])),o=n.length>0,s=n.length>=2||r&&o,c=t.filter(l=>l.zodType!=="ZodObject"&&l.zodType!=="ZodRecord");return jsxRuntime.jsxs("details",{class:"collapse collapse-arrow bg-base-100 border border-base-300 rounded-box mb-6 shadow-sm",open:o?true:void 0,children:[jsxRuntime.jsxs("summary",{class:"collapse-title text-sm font-medium py-2 min-h-0",children:["Filters",o&&jsxRuntime.jsxs("span",{class:"badge badge-primary badge-sm ml-2",children:[n.length," active"]})]}),jsxRuntime.jsx("div",{class:"collapse-content pb-4 pt-2",children:jsxRuntime.jsxs("form",{method:"get",action:e,children:[jsxRuntime.jsx("div",{class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:c.map(l=>{let p=Tn(l.zodType),f=a[l.name],y=f?.op??p[0].value;return jsxRuntime.jsxs("div",{class:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("label",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:l.name}),jsxRuntime.jsxs("div",{class:"flex gap-1.5",children:[p.length>1?jsxRuntime.jsx("select",{name:`fo_${l.name}`,class:"select select-sm select-bordered w-20 shrink-0",children:p.map(g=>jsxRuntime.jsx("option",{value:g.value,selected:g.value===y,children:g.label},g.value))}):jsxRuntime.jsx("input",{type:"hidden",name:`fo_${l.name}`,value:p[0].value}),jsxRuntime.jsx(Pn,{col:l,active:f})]})]},l.name)})}),jsxRuntime.jsxs("div",{class:"flex flex-wrap gap-2 mt-4 pt-3 border-t border-base-200 items-center",children:[jsxRuntime.jsx("button",{type:"submit",class:"btn btn-sm btn-primary",children:"Apply"}),o&&jsxRuntime.jsx("a",{href:e,class:"btn btn-sm btn-ghost",children:"Clear"}),s&&jsxRuntime.jsxs("span",{class:"text-xs text-warning ml-auto flex items-center gap-1",children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),r?"Collection group queries require a composite index":"Multiple filters may require a composite index"]})]})]})})]})}function st(e,t,n,r,a,o){let s=n==="create"?`Create ${e}`:`Edit ${e} / ${r??""}`,c=n==="create"?[{label:"Repositories",href:a},{label:e,href:`${a}/${e}`},{label:"New document"}]:[{label:"Repositories",href:a},{label:e,href:`${a}/${e}`},{label:`Edit ${r??""}`}];return se(jsxRuntime.jsx(ie,{opts:{title:s,breadcrumb:c,basePath:a,flash:o},children:jsxRuntime.jsx("div",{class:"card bg-base-100 border border-base-300",children:jsxRuntime.jsx("div",{class:"card-body p-6",children:jsxRuntime.jsx("div",{dangerouslySetInnerHTML:{__html:t}})})})}))}Fe();et();function it(e,t,n){let r=new URLSearchParams;for(let a of e)r.set(`fv_${a.field}`,a.value),r.set(`fo_${a.field}`,a.op);return t&&(r.set("ob",t.field),r.set("od",t.dir)),n&&r.set("ps",String(n)),r}function It(e,t,n,r,a){let o=it(e,r,a);return o.set("cursor",t),o.set("dir",n),`?${o.toString()}`}function In(e,t,n,r){let a=it(n,void 0,r);return t?.field===e?t.dir==="asc"&&(a.set("ob",e),a.set("od","desc")):(a.set("ob",e),a.set("od","asc")),`?${a.toString()}`}function Nn(e,t,n){return `?${it(t,n,e).toString()}`}function lt(e,t,n,r,a,o,s=[],c=[],l=false,p=[],f,y,g,S,h,F,Z,B=false){let U=`${r}/${e}`,v=`${U}/create`,m={};if(Z)for(let b of n)m[b]=Ce(Ee(Z,b));let x=(F??[]).filter(b=>true),i=x.length>0,d=l,u=d||i,E=x.map(b=>{let N=Ee(Z,b),A=Ce(N),R=s.find(C=>C.name===b);return {name:b,type:A,enumValues:R?.enumValues??null,nullable:R?.nullable??false}}),P=[];return Z&&(P=ee(Z).filter(N=>x.includes(N.name))),se(jsxRuntime.jsxs(ie,{opts:{title:e,breadcrumb:[{label:"Repositories",href:r},{label:e}],basePath:r,flash:o},children:[s.length>0&&jsxRuntime.jsx(ot,{action:U,columnMeta:s,activeFilters:c,isGroup:S}),g&&jsxRuntime.jsxs("div",{role:"alert",class:`alert ${g.type==="index"?"alert-warning":"alert-error"} mb-6 shadow-sm`,children:[jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24",children:g.type==="index"?jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"}):jsxRuntime.jsx("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),jsxRuntime.jsxs("div",{class:"flex-1",children:[jsxRuntime.jsx("h3",{class:"font-bold",children:g.type==="index"?"Composite index required":"Query failed"}),jsxRuntime.jsx("div",{class:"text-sm",children:g.message})]}),g.indexUrl&&jsxRuntime.jsx("a",{href:g.indexUrl,target:"_blank",rel:"noopener noreferrer",class:"btn btn-sm btn-outline",children:"Create Index \u2192"})]}),jsxRuntime.jsxs("div",{class:"flex flex-wrap justify-between items-center mb-4 gap-3","data-frs-toolbar":true,children:[jsxRuntime.jsxs("div",{class:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{class:"text-sm text-base-content/60",children:[t.length,typeof h=="number"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" ","of"," ",jsxRuntime.jsx("span",{class:"font-semibold text-base-content/80",children:h})]})," ","document",(typeof h=="number"?h:t.length)!==1&&"s"]}),jsxRuntime.jsxs("div",{class:"flex items-center gap-1.5 text-sm text-base-content/60",children:[jsxRuntime.jsx("span",{children:"Rows"}),jsxRuntime.jsx("div",{class:"join",children:[10,25,50,100].map(b=>jsxRuntime.jsx("a",{href:Nn(b,c,f),class:`join-item btn btn-xs ${y===b?"btn-active btn-primary":"btn-outline"}`,children:b},b))})]})]}),jsxRuntime.jsxs("div",{class:"flex gap-2",children:[jsxRuntime.jsx("form",{method:"post",action:`${U}/_bulk/backfill`,onsubmit:"return confirm('Backfill entire repository? This will scan all documents and fill missing system keys.')",children:jsxRuntime.jsx("button",{type:"submit",class:"btn btn-outline btn-sm",children:"Backfill"})}),jsxRuntime.jsx("a",{href:v,class:"btn btn-primary btn-sm",children:"+ New"})]})]}),u&&jsxRuntime.jsxs("div",{class:"hidden mb-3 alert alert-info py-2 px-3","data-frs-bulk-bar":true,"data-frs-repo":e,"data-frs-total":typeof h=="number"?String(h):"","data-frs-page-size":String(y??t.length),"data-frs-allow-delete":d?"1":"0","data-frs-allow-update":i?"1":"0","data-frs-fields":JSON.stringify(E),"data-frs-filters":JSON.stringify(c),children:[jsxRuntime.jsxs("div",{class:"flex-1 text-sm",children:[jsxRuntime.jsx("span",{"data-frs-bulk-summary":true,children:"0 selected"}),typeof h=="number"&&h>t.length&&jsxRuntime.jsxs("button",{type:"button",class:"ml-3 link text-sm hidden","data-frs-bulk-select-all":true,children:["Select all ",h," matching documents"]}),jsxRuntime.jsxs("span",{class:"hidden ml-3 italic","data-frs-bulk-all-active":true,children:["All ",h??"?"," matching documents are selected."," ",jsxRuntime.jsx("button",{type:"button",class:"link","data-frs-bulk-clear":true,children:"Clear selection"})]})]}),jsxRuntime.jsxs("div",{class:"flex gap-2",children:[i&&jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-outline","data-frs-bulk-action":"update",children:"Update field\u2026"}),d&&jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-error btn-outline","data-frs-bulk-action":"delete",children:"Delete"})]})]}),jsxRuntime.jsx("div",{class:"overflow-x-auto rounded-box border border-base-300 bg-base-100","data-frs-table-wrap":true,children:jsxRuntime.jsxs("table",{class:"table table-sm w-full","data-frs-table":true,"data-frs-repo":e,"data-frs-colcount":n.length,children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{class:"bg-base-200/50",children:[u&&jsxRuntime.jsx("th",{class:"w-8",children:jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs checkbox-primary","data-frs-select-page":true,"aria-label":"Select all on this page"})}),[...n].map((b,N)=>{let A=f?.field===b,R=A?f.dir==="asc"?" \u25B2":" \u25BC":"";return jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:jsxRuntime.jsxs("a",{href:In(b,f,c,y),class:`hover:text-base-content inline-flex items-center gap-0.5${A?" text-primary font-bold":""}`,children:[b,R]})},N)}),p.map((b,N)=>jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide",children:b.column},`rel-${N}`)),jsxRuntime.jsx("th",{class:"text-xs font-semibold text-base-content/60 uppercase tracking-wide text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:t.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colspan:n.length+p.length+1+(u?1:0),class:"text-center py-16 text-base-content/40",children:"No documents found"})}):t.map((b,N)=>{let A=String(b.docId??b.id??""),R=`${r}/${e}/${encodeURIComponent(A)}/edit`,C=`${r}/${e}/${encodeURIComponent(A)}/delete`;return jsxRuntime.jsxs("tr",{class:"hover","data-frs-row-id":A,children:[u&&jsxRuntime.jsx("td",{class:"align-middle py-2",children:jsxRuntime.jsx("input",{type:"checkbox",class:"checkbox checkbox-xs checkbox-primary","data-frs-select-row":true,value:A,"aria-label":`Select ${A}`})}),n.map((O,M)=>{let q=b[O],I=m[O],w=I?Te(I,q):null;return jsxRuntime.jsx("td",{class:"align-top py-2",children:jsxRuntime.jsx(be,{val:q,mismatch:w})},M)}),p.map((O,M)=>{let q=b[O.key];if(q==null||q==="")return jsxRuntime.jsx("td",{class:"py-2"},`rel-${M}`);let I=O.type==="one"?`${r}/${O.targetRepo}/${encodeURIComponent(String(q))}/edit`:`${r}/${O.targetRepo}?fv_${O.targetKey}=${encodeURIComponent(String(q))}`;return jsxRuntime.jsx("td",{class:"align-middle py-2",children:jsxRuntime.jsx("a",{href:I,class:"btn btn-xs btn-ghost btn-outline","data-frs-relation":true,"data-frs-rel-type":O.type,"data-frs-rel-repo":O.targetRepo,"data-frs-rel-fk":O.targetKey,"data-frs-rel-val":String(q),"data-frs-rel-label":O.column,children:O.column})},`rel-${M}`)}),jsxRuntime.jsx("td",{class:"align-middle text-right whitespace-nowrap py-2",children:jsxRuntime.jsxs("div",{class:"flex gap-1 justify-end",children:[jsxRuntime.jsx("a",{href:R,class:"btn btn-xs btn-outline",children:"Edit"}),B&&jsxRuntime.jsx("a",{href:`${r}/${e}/${encodeURIComponent(A)}/history`,class:"btn btn-xs btn-outline",title:"View change history",children:"History"}),l&&jsxRuntime.jsx("form",{method:"post",action:C,onsubmit:"return confirm('Delete this document?')",children:jsxRuntime.jsx("button",{type:"submit",class:"btn btn-xs btn-error btn-outline",children:"Delete"})})]})})]},N)})})]})}),(a.hasPrev||a.hasNext)&&jsxRuntime.jsxs("div",{class:"flex flex-col items-center mt-6 gap-2",children:[jsxRuntime.jsxs("div",{class:"flex justify-center items-center gap-2",children:[a.hasPrev?jsxRuntime.jsx("a",{href:It(c,a.prevCursor,"prev",f,y),class:"btn btn-sm btn-outline",children:"\u2190 Previous"}):jsxRuntime.jsx("button",{class:"btn btn-sm btn-outline",disabled:true,children:"\u2190 Previous"}),a.hasNext?jsxRuntime.jsx("a",{href:It(c,a.nextCursor,"next",f,y),class:"btn btn-sm btn-outline",children:"Next \u2192"}):jsxRuntime.jsx("button",{class:"btn btn-sm btn-outline",disabled:true,children:"Next \u2192"})]}),typeof h=="number"&&jsxRuntime.jsxs("div",{class:"text-xs text-base-content/50",children:[h," total document",h!==1?"s":"",c.length>0?" matching filters":""]})]}),u&&i&&jsxRuntime.jsxs("dialog",{id:"frs-bulk-update-modal",class:"modal",children:[jsxRuntime.jsxs("div",{class:"modal-box",children:[jsxRuntime.jsx("h3",{class:"font-bold text-lg mb-3",children:"Bulk update field"}),jsxRuntime.jsx("p",{class:"text-sm text-base-content/60 mb-4","data-frs-bulk-update-summary":true,children:"Update one field on the selected documents."}),jsxRuntime.jsxs("form",{method:"dialog","data-frs-bulk-update-form":true,"data-frs-form":true,children:[jsxRuntime.jsxs("label",{class:"form-control w-full mb-3",children:[jsxRuntime.jsx("div",{class:"label",children:jsxRuntime.jsx("span",{class:"label-text text-xs uppercase tracking-wide",children:"Field"})}),jsxRuntime.jsxs("select",{class:"select select-bordered select-sm w-full",name:"field",required:true,"data-frs-bulk-field-select":true,children:[jsxRuntime.jsx("option",{value:"",children:"\u2014 Select a field \u2014"}),x.map(b=>jsxRuntime.jsx("option",{value:b,children:b},b))]})]}),jsxRuntime.jsx("div",{class:"mb-4","data-frs-bulk-value-container":true}),jsxRuntime.jsxs("div",{class:"modal-action",children:[jsxRuntime.jsx("button",{type:"button",class:"btn btn-sm btn-ghost","data-frs-bulk-update-cancel":true,children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",class:"btn btn-sm btn-primary","data-frs-bulk-update-submit":true,children:"Apply"})]})]})]}),jsxRuntime.jsx("form",{method:"dialog",class:"modal-backdrop",children:jsxRuntime.jsx("button",{children:"close"})})]}),jsxRuntime.jsx("div",{class:"hidden","data-frs-bulk-templates":true,children:P.map(b=>jsxRuntime.jsx("div",{"data-frs-bulk-template-for":b.name,dangerouslySetInnerHTML:{__html:Ze(b)}},b.name))})]}))}function Le(e,t){return rt(e,t)}function Nt(e,t){return at(e,t)}function Zt(e,t,n,r,a,o,s,c,l,p,f,y,g,S,h,F,Z,B){return lt(e,t,n,r,a,o,s,c,l,p,f,y,g,S,h,F,Z,B)}function fe(e,t,n,r,a,o){return st(e,t,n,r,a,o)}async function Dt(e,t){if(t)try{let n=e.repo.ref,r=n?.firestore;if(t.startsWith("{"))try{let a=JSON.parse(t);if(a.docPath&&r&&typeof r.doc=="function"){let o=await r.doc(a.docPath).get();if(o.exists)return o}a.docId&&(t=a.docId);}catch{}if(t.includes("/")&&r&&typeof r.doc=="function"){let a=await r.doc(t).get();if(a.exists)return a}if(typeof n.doc=="function"){let a=await n.doc(t).get();if(a.exists)return a}}catch{}}function Be(e,t){return ht(e,{pathKey:t.pathKey,documentKey:t.documentKey??"docId",parentKeys:t.parentKeys,documentPathTemplate:t.documentPathTemplate,isGroup:t.isGroup})}async function ve(e,t){let n=e.documentKey??"docId",r=`by${n.charAt(0).toUpperCase()}${n.slice(1)}`;if(typeof e.repo.get[r]=="function")try{let o=await e.repo.get[r](t);if(o)return o}catch{}return (await e.repo.query.by({where:[[n,"==",t]],limit:1}))[0]??null}function ct(e,t,n){let r=e.documentKey??"docId",a=Qe(n,{ref:e.repo.ref,path:e.path,isGroup:!!e.isGroup,filters:[{field:r,op:"==",value:t}]});return a.type==="index"?{type:"warning",message:"Loading this document requires a composite index that does not exist yet.",...a.indexUrl?{action:{href:a.indexUrl,label:"Create Index \u2192",external:true}}:{}}:{type:"error",message:a.message}}function T(e,t,n=200){e.status(n).set("Content-Type","text/html; charset=utf-8").send(t);}function Me(e,t){e.status(302).set("Location",t).send("");}function Ue(e,t){let n=t.shape,r={};for(let[a,o]of Object.entries(n)){let s=ut(o),c=L(s),l=c==="ZodObject",p=s,f=false;if(c==="ZodUnion"){let S=$e(s);S.some(F=>L(F)==="ZodDate")&&(f=true);let h=S.find(F=>{if(L(F)==="ZodObject"){let Z=Y(F);return "latitude"in Z&&"longitude"in Z}return false});h&&(l=true,p=h);}if(e[a+"__isnull"]==="1"){r[a]=null;continue}if(l){let S={},h=false;for(let[B,U]of Object.entries(e))B.startsWith(`${a}.`)&&(S[B.slice(a.length+1)]=U,h=true);if(h){r[a]=Ue(S,p);continue}let F=e[a],Z=Array.isArray(F)?F[F.length-1]:F;if(Z)try{r[a]=JSON.parse(Z);}catch{r[a]=Z;}continue}let y=e[a],g=Array.isArray(y)?y[y.length-1]:y;if(g===void 0||g===""){c==="ZodBoolean"&&(r[a]=false);continue}if(f){r[a]=new Date(g);continue}switch(c){case "ZodBoolean":g==="__null__"?r[a]=null:r[a]=g==="true"||g==="on"||g==="1";break;case "ZodNumber":case "ZodBigInt":r[a]=Number(g);break;case "ZodDate":r[a]=new Date(g);break;case "ZodArray":try{r[a]=JSON.parse(g);}catch{r[a]=g;}break;default:if(g.startsWith("{")||g.startsWith("["))try{r[a]=JSON.parse(g);break}catch{}r[a]=g;}}return r}function Ft(e){let t=null;if(e instanceof Date)t=e;else if(typeof e=="object"&&e!==null&&typeof e.toDate=="function")t=e.toDate();else if(typeof e=="object"&&e!==null&&"_seconds"in e&&"_nanoseconds"in e)t=new Date(e._seconds*1e3+Math.floor(e._nanoseconds/1e6));else if(typeof e=="string"||typeof e=="number"){let r=new Date(e);isNaN(r.getTime())||(t=r);}if(!t||isNaN(t.getTime()))return null;let n=r=>String(r).padStart(2,"0");return `${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function jt(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable"||n==="ZodDefault")t=X(t);else if(n==="ZodEffects"||n==="ZodPipe"||n==="ZodTransform"){let r=ke(t);if(!r)return n;t=r;}else return n}}function ut(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable"||n==="ZodDefault")t=X(t);else if(n==="ZodEffects"||n==="ZodPipe"||n==="ZodTransform"){let r=ke(t);if(!r)return t;t=r;}else return t}}function Lt(e){let t=e;for(;;){let n=L(t);if(n==="ZodOptional"||n==="ZodNullable")return true;if(n==="ZodDefault"){t=X(t);continue}return false}}function Bt(e){let t=ut(e),n=L(t);if(n==="ZodEnum"){let r=Se(t);return r.length>0?r:void 0}if(n==="ZodNativeEnum"){let r=Ae(t),a=Object.values(r).filter(o=>typeof o=="string");return a.length>0?a:void 0}if(n==="ZodLiteral"){let r=Re(t);return typeof r=="string"?[r]:void 0}}function Mt(e,t,n=""){let r={};for(let a of Object.keys(t.shape)){let o=n?`${n}.${a}`:a,s=e[a];if(s===null){r[o]="__null__";continue}if(s===void 0)continue;let c=ut(t.shape[a]),l=L(c),p=l==="ZodObject",f=c,y=false;if(l==="ZodUnion"){let g=$e(c);g.some(h=>L(h)==="ZodDate")&&(y=true);let S=g.find(h=>{if(L(h)==="ZodObject"){let F=Y(h);return "latitude"in F&&"longitude"in F}return false});S&&(p=true,f=S);}if(p&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&!("_seconds"in s)&&typeof s.toDate!="function"){let g=Mt(s,f,o);Object.assign(r,g);}else if(l==="ZodDate"||y){let g=Ft(s);g!==null&&(r[o]=g);}else if(typeof s=="object"&&s!==null&&!Array.isArray(s)&&("_seconds"in s||typeof s.toDate=="function")){let g=Ft(s);r[o]=g??JSON.stringify(s,null,2);}else typeof s=="object"?r[o]=JSON.stringify(s,null,2):r[o]=String(s);}return r}function dt(e,t){return e.map(n=>({...n,defaultValue:t[n.name]??n.defaultValue,nested:n.nested?dt(n.nested,t):void 0}))}function Fn(e,t){let n=new Set(["==","!=","<","<=",">",">=","in","not-in","array-contains","array-contains-any"]),r=[];for(let[a,o]of Object.entries(e)){if(!a.startsWith("fv_"))continue;let s=a.slice(3);if(!t.has(s))continue;let c=(o??"").trim();if(!c)continue;let l=e[`fo_${s}`]??"==",p=n.has(l)?l:"==";r.push({field:s,op:p,value:c});}return r}function zt(e){let t="__null__",n=r=>r===t?null:r==="true"?true:r==="false"?false:r!==""&&!isNaN(Number(r))?Number(r):r;return e.map(r=>{if(r.op==="array-contains-any"||r.op==="in"||r.op==="not-in"){let a=r.value.split(",").map(o=>o.trim()).filter(o=>o!==""&&o!==t).map(o=>n(o));return [r.field,r.op,a]}return [r.field,r.op,n(r.value)]})}function Ut(e,t,n=""){let r=[];for(let a of e){let o=n?`${n}.${a}`:a,s=t.shape[a];if(!s){r.push({name:o,zodType:"ZodString"});continue}let c=jt(s);if(c==="ZodObject"){let l=s;for(;;){let f=L(l);if(f==="ZodOptional"||f==="ZodNullable"||f==="ZodDefault")l=X(l);else break}let p=Y(l);r.push(...Ut(Object.keys(p),l,o));}else r.push({name:o,zodType:c,nullable:Lt(s),enumValues:Bt(s)});}return r}function zn(e,t){let n=t.split("."),r=e;for(let a of n){for(;;){let s=L(r);if(s==="ZodOptional"||s==="ZodNullable"||s==="ZodDefault")r=X(r);else break}let o=Y(r);if(!(a in o))return null;r=o[a];}return r}function me(e,t){if(!t||t.length===0)return e;let n=[],r=new Map;for(let o of t){let s=o.indexOf(".");if(s===-1)n.push(o);else {let c=o.slice(0,s),l=o.slice(s+1);r.has(c)||r.set(c,[]),r.get(c).push(l);}}let a={};for(let o of n)o in e.shape&&(a[o]=e.shape[o]);for(let[o,s]of r){if(!(o in e.shape))continue;let c=e.shape[o];for(;;){let l=L(c);if(l==="ZodOptional"||l==="ZodNullable"||l==="ZodDefault")c=X(c);else break}if(L(c)!=="ZodObject"){a[o]=e.shape[o];continue}a[o]=me(c,s);}return zod.z.object(a)}function ne(e,t,n){return He(e,t,n)}function Ht(e,t,n){let r=(v,m)=>{let x=ne(v,t,n),i=Object.values(e).map(d=>({name:d.name,path:d.path}));T(m,Nt(i,x));},a=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=i.pageSize??25,u=v.query??{},E=u.cursor,P=u.dir==="prev"?"prev":"next",b=u.ob??"",N=u.od==="desc"?"desc":"asc",A=b?{field:b,dir:N}:void 0,R=parseInt(u.ps??""),C=Number.isFinite(R)&&R>0?Math.min(R,200):d,O=i.listColumns??Object.keys(i.schema.shape),M=i.documentKey??"docId",q=[M,...O.filter(Q=>Q!==M)];A&&(new Set([M,...O]).has(A.field)||(A=void 0));let I=i.filterableFields?(()=>{let Q=[];for(let ae of i.filterableFields)(ae.includes(".")||O.includes(ae))&&Q.push(ae);return Q})():O,w=(()=>{let Q=[];for(let ae of I)if(ae.includes(".")){let he=zn(i.schema,ae);Q.push({name:ae,zodType:he?jt(he):"ZodString",nullable:he?Lt(he):false,enumValues:he?Bt(he):void 0});}else Q.push(...Ut([ae],i.schema));return Q})(),K=new Set(w.map(Q=>Q.name)),ce=Fn(u,K),re=zt(ce),xe;E&&(xe=await Dt(i,E));let[H,ye]=await Promise.all([i.repo.query.paginate({pageSize:C,cursor:xe,direction:P,...re.length>0?{where:re}:{},...A?{orderBy:[{field:A.field,direction:A.dir}]}:{}}).catch(Q=>({queryError:Qe(Q,{ref:i.repo.ref,path:i.path,isGroup:!!i.isGroup,filters:ce,sort:A})})),i.repo.aggregate.count(re.length>0?{where:re}:{}).catch(()=>{})]),oe="queryError"in H,Jt=oe?[]:H.data,Gt=oe?"":H.nextCursor?.ref?.path??H.nextCursor?.id??"",Wt=oe?"":H.prevCursor?.ref?.path??H.prevCursor?.id??"",Qt=oe?H.queryError:void 0,Xt=ne(v,t,n),we,Pe=u.flash;Pe==="created"?we={type:"success",message:"Document created successfully."}:Pe==="updated"?we={type:"success",message:"Document updated successfully."}:Pe==="deleted"?we={type:"success",message:"Document deleted successfully."}:Pe==="backfilled"&&(we={type:"success",message:"Repository backfilled successfully."}),T(m,Zt(i.name,Jt,q,Xt,{hasPrev:oe?false:H.hasPrevPage,hasNext:oe?false:H.hasNextPage,prevCursor:Wt,nextCursor:Gt},we,w,ce,i.allowDelete??false,i.relationalMeta,A,C,Qt,i.isGroup,ye,i.mutableFields,i.schema,i.historyEnabled));},o=(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=me(i.schema,i.createFields),E=ee(u),P=`${d}/${i.name}/create`,b=de(E,P,"POST","Create document");T(m,fe(i.name,b,"create",null,d));},s=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=v.body??{},E=Ue(u,i.schema),P=me(i.schema,i.createFields),b=P.safeParse(E);if(!b.success){let N=ee(P),A=`${d}/${i.name}/create`,R=de(N,A,"POST","Create document"),C=b.error.issues.map(O=>`${O.path.join(".")}: ${O.message}`).join(", ");T(m,fe(i.name,R,"create",null,d,{type:"error",message:`Validation error: ${C}`}),422);return}try{if(i.isGroup&&i.parentKeys&&i.parentKeys.length>0){let N={...b.data},A=i.parentKeys.filter(R=>N[R]===void 0||N[R]===null||typeof N[R]=="string"&&N[R].trim()==="");if(A.length>0)throw new Error(`Missing parent key(s) for subcollection create: ${A.join(", ")}`);if(typeof i.repo.create=="function")await i.repo.create(N);else {let R=i.parentKeys.map(M=>String(N[M])),C=i.documentKey??"docId",O=N[C]||ft();await i.repo.set(...R,O,N);}}else await i.repo.create(b.data);Me(m,`${d}/${i.name}?flash=created`);}catch(N){let A=me(i.schema,i.createFields),R=ee(A),C=`${d}/${i.name}/create`,O=de(R,C,"POST","Create document");T(m,fe(i.name,O,"create",null,d,{type:"error",message:`Save error: ${N.message}`}),500);}},c=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}let u=ne(v,t,n),E=null;try{E=await ve(d,i);}catch(C){let O=ct(d,i,C),M=ue(C)?424:500;T(m,Le("",{title:`Edit ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`Edit ${i}`}],flash:O}),M);return}if(!E){T(m,"Document not found",404);return}let P=Mt(E,d.schema),b=me(d.schema,d.mutableFields),N=dt(ee(b),P),A=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,R=de(N,A,"POST","Save changes");T(m,fe(d.name,R,"edit",i,u));},l=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}let u=ne(v,t,n),E=v.body??{},P=Ue(E,d.schema),b=me(d.schema,d.mutableFields),A=b.partial().safeParse(P);if(!A.success){let R=Object.fromEntries(Object.entries(E).map(([I,w])=>[I,Array.isArray(w)?w.join(","):w??""])),C=dt(ee(b),R),O=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,M=de(C,O,"POST","Save changes"),q=A.error.issues.map(I=>`${I.path.join(".")}: ${I.message}`).join(", ");T(m,fe(d.name,M,"edit",i,u,{type:"error",message:`Validation error: ${q}`}),422);return}try{let R=await ve(d,i),C=(R&&Be(R,d))??[i];await d.repo.update(...C,A.data),Me(m,`${u}/${d.name}?flash=updated`);}catch(R){let C=me(d.schema,d.mutableFields),O=ee(C),M=`${u}/${d.name}/${encodeURIComponent(i)}/edit`,q=de(O,M,"POST","Save changes"),I=ue(R)?ct(d,i,R):{type:"error",message:`Save error: ${R.message}`},w=ue(R)?424:500;T(m,fe(d.name,q,"edit",i,u,I),w);}},p=async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}if(!d.allowDelete){T(m,"Delete is not allowed for this repository",403);return}let u=ne(v,t,n);try{let E=await ve(d,i),P=(E&&Be(E,d))??[i];await d.repo.delete(...P),Me(m,`${u}/${d.name}?flash=deleted`);}catch(E){let P=ue(E)?ct(d,i,E):{type:"error",message:`Delete error: ${E.message}`},b=ue(E)?424:500;T(m,Le("",{title:`Delete ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`Delete ${i}`}],flash:P}),b);}},f=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n),u=v.query,E=u?.type==="many"?"many":"one",P=Math.max(1,Math.min(100,Number(u?.ps??25)||25)),b=i.listColumns??Object.keys(Y(i.schema)),{PanelOne:N,PanelMany:A}=await Promise.resolve().then(()=>(nt(),Ot)),{renderToString:R}=await import('hono/jsx/dom/server');if(E==="one"){let w=String(u?.id??"");if(!w){T(m,"<div class='p-6 text-error'>Missing id parameter.</div>",400);return}try{let K=await ve(i,w),ce=R(N({doc:K,repoName:i.name,basePath:d,schema:i.schema,columns:b}));T(m,ce);}catch(K){T(m,`<div class='p-6 text-error text-sm'>Error: ${K.message}</div>`,500);}return}let C=String(u?.fk??""),O=String(u?.fv??"");if(!C||!O){T(m,"<div class='p-6 text-error'>Missing fk/fv parameters.</div>",400);return}let M=u?.cursor??"",q=u?.dir==="prev"?"prev":"next",I;M&&(I=await Dt(i,M));try{let w=await i.repo.query.paginate({pageSize:P,cursor:I,direction:q,where:[[C,"==",jn(O)]]}),K=R(A({docs:w.data,repoName:i.name,basePath:d,fk:C,fv:O,columns:b,schema:i.schema,pagination:{hasPrev:w.hasPrevPage,hasNext:w.hasNextPage,prevCursor:w.prevCursor?.ref?.path??w.prevCursor?.id??"",nextCursor:w.nextCursor?.ref?.path??w.nextCursor?.id??"",pageSize:P}}));T(m,K);}catch(w){T(m,`<div class='p-6 text-error text-sm'>Error: ${w.message}</div>`,500);}},y=async(v,m)=>{let x=v.params.repoName;if(!x){T(m,"Bad request",400);return}let i=e[x];if(!i){T(m,"Repository not found",404);return}let d=ne(v,t,n);try{await i.repo.system.backfillKeys(),Me(m,`${d}/${i.name}?flash=backfilled`);}catch(u){T(m,`<div class="p-6 text-error">Backfill failed: ${u.message}</div>`,500);}},g=async(v,m)=>{let x=[];for(let i of m){let d;if(v.isGroup||v.parentKeys?.length){let u=await ve(v,i);d=u?Be(u,v):void 0;}d||(d=[i]);try{let u=v.repo.documentRef(...d);u&&x.push(u);}catch{}}return x},S=async(v,m)=>{let x=zt(m),i=v.documentKey??"docId",d=[],u;for(;;){let E=await v.repo.query.paginate({pageSize:500,cursor:u,direction:"next",...x.length>0?{where:x}:{}});for(let P of E.data){let b=String(P[i]??P.id??"");b&&d.push(b);}if(!E.hasNextPage||!E.nextCursor)break;u=E.nextCursor;}return d},h=async(v,m)=>{let x=v.params.repoName;if(!x){W(m,{error:"Bad request"},400);return}let i=e[x];if(!i){W(m,{error:"Repository not found"},404);return}if(!i.allowDelete){W(m,{error:"Delete is not allowed for this repository"},403);return}let d=v.body??{};try{let u=await Z(i,d);if(u.length===0){W(m,{deleted:0});return}let E=await g(i,u);for(let P=0;P<E.length;P+=500)await i.repo.bulk.delete(E.slice(P,P+500));W(m,{deleted:E.length});}catch(u){W(m,{error:u.message},500);}},F=async(v,m)=>{let x=v.params.repoName;if(!x){W(m,{error:"Bad request"},400);return}let i=e[x];if(!i){W(m,{error:"Repository not found"},404);return}let d=v.body??{},u=String(d.field??"");if(!u){W(m,{error:"Missing 'field'"},400);return}if(!i.mutableFields||!i.mutableFields.includes(u)){W(m,{error:`Field '${u}' is not bulk-updatable`},403);return}let E=i.schema.shape?.[u],P;if(E){let b=typeof i.schema=="object"&&i.schema&&"constructor"in i.schema&&i.schema.constructor.name.includes("Zod")?i.schema.pick({[u]:true}):void 0;if(!b){W(m,{error:"Invalid schema structure"},500);return}P=Ue(d.formPayload??{},b)[u];let A=E.safeParse(P);if(!A.success){W(m,{error:`Invalid value for '${u}': ${A.error.message}`},400);return}P=A.data;}try{let b=await Z(i,d);if(b.length===0){W(m,{updated:0});return}let A=(await g(i,b)).map(R=>({docRef:R,data:{[u]:P}}));for(let R=0;R<A.length;R+=500)await i.repo.bulk.update(A.slice(R,R+500));W(m,{updated:A.length});}catch(b){W(m,{error:b.message},500);}};async function Z(v,m){if(m.selectAll){let x=B(m.filters,v);return await S(v,x)}return Array.isArray(m.ids)?m.ids.filter(x=>typeof x=="string"&&!!x):[]}function B(v,m){if(!Array.isArray(v))return [];let x=new Set((m.filterableFields??Object.keys(Y(m.schema))).map(u=>String(u))),i=new Set(["==","!=","<","<=",">",">=","in","not-in","array-contains","array-contains-any"]),d=[];for(let u of v)u&&typeof u=="object"&&typeof u.field=="string"&&x.has(u.field)&&typeof u.value=="string"&&i.has(String(u.op))&&d.push({field:u.field,op:u.op,value:u.value});return d}return {handleDashboard:r,handleList:a,handleCreateForm:o,handleCreateSubmit:s,handleEditForm:c,handleEditSubmit:l,handleDelete:p,handlePanel:f,handleBulkDelete:h,handleBulkUpdate:F,handleBulkBackfill:y,handleHistory:async(v,m)=>{let x=v.params.repoName,i=v.params.id;if(!x||!i){T(m,"Bad request",400);return}let d=e[x];if(!d){T(m,"Repository not found",404);return}if(!d.historyEnabled||!d.repo.history){T(m,"History not enabled for this repository",404);return}let u=ne(v,t,n),E=d.historySubcollection??"history",P=[i];try{let w=await ve(d,i),K=w?Be(w,d):void 0;K&&K.length>0&&(P=K);}catch{}let b=parseInt(String(v.query?.limit??"")),N=Number.isFinite(b)&&b>0?Math.min(b,500):100,A=[],R;try{A=await d.repo.history.list(...P,{limit:N});}catch(w){R=w.message;}let C=w=>String(w??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),O=w=>{if(w===void 0)return '<span class="opacity-40">undefined</span>';if(w===null)return '<span class="opacity-40">null</span>';if(typeof w=="object")try{return `<code class="text-xs">${C(JSON.stringify(w))}</code>`}catch{return C(String(w))}return C(String(w))},M=w=>w?typeof w.toDate=="function"?w.toDate().toISOString():w instanceof Date?w.toISOString():C(String(w)):"",q=w=>`<span class="badge badge-sm ${w==="create"?"badge-success":w==="delete"?"badge-error":w==="custom"?"badge-secondary":"badge-info"}">${C(w)}</span>`,I="";if(I+='<div class="flex items-center justify-between mb-4">',I+=`<a href="${u}/${d.name}/${encodeURIComponent(i)}/edit" class="btn btn-sm btn-outline">\u2190 Back to edit</a>`,I+=`<a href="${u}/${d.name}" class="btn btn-sm btn-outline">\u2190 Back to list</a>`,I+="</div>",I+=`<p class="text-sm text-base-content/60 mb-4">Subcollection: <code>${C(E)}</code> \xB7 Showing up to ${N} entries.</p>`,R)I+=`<div class="alert alert-error mb-4">${C(R)}</div>`;else if(A.length===0)I+='<div class="alert">No history entries found.</div>';else {I+='<div class="overflow-x-auto"><table class="table table-zebra table-sm">',I+="<thead><tr><th>When</th><th>Op</th><th>User</th><th>Reason / Comment</th><th>Changes</th></tr></thead><tbody>";for(let w of A){let K=w.meta??{},ce=[K.reason,K.comment].filter(H=>H!=null&&H!=="").map(H=>C(String(H))).join(" \u2014 "),re="",xe=Object.keys(w.changes??{});if(w.custom){let H=`<strong>${C(w.custom.title)}</strong>`,ye=w.custom.key?` <code class="text-xs opacity-60">${C(w.custom.key)}</code>`:"",oe=w.custom.description?`<div class="text-xs opacity-80 mt-0.5">${C(w.custom.description)}</div>`:"";re=`<div>${H}${ye}${oe}</div>`;}else xe.length===0?re='<span class="opacity-40">\u2014</span>':re='<ul class="space-y-1">'+xe.map(H=>{let ye=w.changes[H];return `<li><strong>${C(H)}</strong>: ${O(ye.oldValue)} \u2192 ${O(ye.newValue)}</li>`}).join("")+"</ul>";I+="<tr>",I+=`<td class="whitespace-nowrap text-xs font-mono">${C(M(w.historySetAt))}</td>`,I+=`<td>${q(w.operation??"update")}</td>`,I+=`<td class="text-xs">${C(K.userEmail??K.userId??"")}</td>`,I+=`<td class="text-xs">${ce}</td>`,I+=`<td>${re}</td>`,I+="</tr>";}I+="</tbody></table></div>";}T(m,Le(I,{title:`History \u2014 ${d.name} / ${i}`,basePath:u,breadcrumb:[{label:"Repositories",href:u},{label:d.name,href:`${u}/${d.name}`},{label:`History ${i}`}]}));}}}function W(e,t,n=200){e.status(n).set("Content-Type","application/json; charset=utf-8").send(JSON.stringify(t));}function jn(e){return e==="true"?true:e==="false"?false:e!==""&&!isNaN(Number(e))?Number(e):e}function Ln(e){let t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,r=>r===":"?r:`\\${r}`).replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,a)=>(t.push(a),"([^/]+)"));return {pattern:new RegExp(`^${n}$`),paramNames:t}}function Bn(e){let t=e.path??e.url??"/",n=t.indexOf("?");return n===-1?t:t.slice(0,n)}var _e=class{constructor(){this.routes=[];this.middlewares=[];this.notFoundHandler=(t,n)=>{n.status(404).send("Not Found");};this.errorHandler=(t,n,r)=>{console.error("[MiniRouter]",t),r.status(500).send("Internal Server Error");};}use(t){return this.middlewares.push(t),this}get(t,n){return this.addRoute("GET",t,n)}post(t,n){return this.addRoute("POST",t,n)}put(t,n){return this.addRoute("PUT",t,n)}patch(t,n){return this.addRoute("PATCH",t,n)}delete(t,n){return this.addRoute("DELETE",t,n)}onNotFound(t){return this.notFoundHandler=t,this}onError(t){return this.errorHandler=t,this}addRoute(t,n,r){let{pattern:a,paramNames:o}=Ln(n);return this.routes.push({method:t.toUpperCase(),pattern:a,paramNames:o,handler:r}),this}async handle(t,n){let r=(t.method??"GET").toUpperCase(),a=Bn(t),o=null,s={};for(let p of this.routes){if(p.method!==r)continue;let f=a.match(p.pattern);if(f){o=p,s={},p.paramNames.forEach((y,g)=>{s[y]=decodeURIComponent(f[g+1]??"");});break}}let c=Object.assign(t,{params:s}),l=o?o.handler:this.notFoundHandler;try{await this.runMiddlewareChain(c,n,l);}catch(p){this.errorHandler(p,t,n);}}async runMiddlewareChain(t,n,r){let a=0,o=async()=>{if(a<this.middlewares.length){let s=this.middlewares[a++];await s(t,n,o);}else await r(t,n);};await o();}};var qt="https://cdn.jsdelivr.net",Vt="https://www.gstatic.com",Mn=["default-src 'self'",`script-src 'self' 'unsafe-inline' 'unsafe-eval' ${qt} ${Vt}`,`style-src 'self' 'unsafe-inline' ${qt}`,`connect-src 'self' ${Vt} https://*.googleapis.com https://*.firebaseio.com https://identitytoolkit.googleapis.com`,"img-src 'self' data:","font-src 'self' data:","frame-ancestors 'none'","base-uri 'self'","form-action 'self'"].join("; ");function Kt(e={}){let t=e.csp===void 0?Mn:e.csp,n=e.frameOptions===void 0?"DENY":e.frameOptions,r=e.referrerPolicy===void 0?"no-referrer":e.referrerPolicy,a=e.cacheControl===void 0?"private, no-store":e.cacheControl;return async(o,s,c)=>{typeof s?.setHeader=="function"&&(s.setHeader("X-Content-Type-Options","nosniff"),n&&s.setHeader("X-Frame-Options",n),r&&s.setHeader("Referrer-Policy",r),a&&s.setHeader("Cache-Control",a),t&&s.setHeader("Content-Security-Policy",t)),await c();}}async function Un(e){return typeof e.rawBody=="string"?e.rawBody:Buffer.isBuffer(e.rawBody)?e.rawBody.toString("utf8"):""}function Hn(e){let t={};if(!e)return t;for(let n of e.split("&")){let r=n.indexOf("=");if(r===-1)continue;let a=decodeURIComponent(n.slice(0,r).replace(/\+/g," ")),o=decodeURIComponent(n.slice(r+1).replace(/\+/g," ")),s=t[a];s===void 0?t[a]=o:Array.isArray(s)?s.push(o):t[a]=[s,o];}return t}function ga(e){let{basePath:t="/",repos:n,parseBody:r=true,securityHeaders:a,auth:o,middleware:s=[],httpsOptions:c}=e,l=t==="/"?"":t.replace(/\/$/,""),p={};for(let[S,h]of Object.entries(n)){if(!h.repo)throw new Error(`[createAdminServer] Repository "${S}" has no 'repo' defined. Did you forget to pass it or is there a circular import?`);let F=h.schema??h.repo.schema??null;if(!F)throw new Error(`[createAdminServer] Repository "${S}" has no Zod schema. Either use createRepositoryConfig(schema)(config) or pass schema: explicitly.`);let Z,B,U;if(h.fieldsConfig){let x=h.fieldsConfig;Z=[],B=[],U=[];for(let[i,d]of Object.entries(x))for(let u of d)u==="filterable"?Z.push(i):u==="mutable"?B.push(i):u==="create"&&U.push(i);Z.length===0&&(Z=void 0),B.length===0&&(B=void 0),U.length===0&&(U=void 0);}let v=(()=>{let x=h.repo._parentKeys;return x&&x.length>0?x:void 0})();if(v&&U)for(let x of v)U.includes(x)||U.push(x);let m={name:S,path:h.path,repo:h.repo,schema:F,documentKey:h.documentKey??"docId",pathKey:h.repo._pathKey??void 0,isGroup:!!h.repo._isGroup,parentKeys:v,documentPathTemplate:h.repo._documentPathTemplate??void 0,createdKey:h.repo._createdKey??void 0,listColumns:h.listColumns,pageSize:h.pageSize,filterableFields:Z,mutableFields:B,createFields:U,allowDelete:h.allowDelete??false,historyEnabled:!!h.repo._historyConfig?.enabled,historySubcollection:(h.repo._historyConfig?.enabled&&h.repo._historySubcollection)??void 0,relationalMeta:(()=>{if(!h.relationalFields||h.relationalFields.length===0)return;let x=h.repo.relationalKeys??{},i=[];for(let d of h.relationalFields){let u=x[d.key];u&&i.push({key:u.sourceKey?String(u.sourceKey):d.key,column:d.column,targetRepo:String(u.repo),targetKey:String(u.key),type:u.type});}return i.length>0?i:void 0})()};p[S]=m;}let f=Ht(p,l,pt(c?.region)),y=new _e;if(a!==false&&y.use(Kt(a===void 0?{}:a)),r&&y.use(async(S,h,F)=>{let Z=S,B=String(Z.headers?.["content-type"]??"");if(B.includes("application/x-www-form-urlencoded")){let U=await Un(Z);S.body=Hn(U);}else if(B.includes("application/json")&&typeof Z.body=="string")try{S.body=JSON.parse(Z.body);}catch{}await F();}),o)if(qe(o)){for(let S of o.routes){let h=`${l}${S.path}`;S.method==="GET"?y.get(h,S.handler):y.post(h,S.handler);}y.use(o.middleware);}else if(typeof o=="function")y.use(o);else {let S=o.realm??"Admin",h="Basic "+Buffer.from(`${o.username}:${o.password}`).toString("base64");y.use((F,Z,B)=>{if((F.headers?.authorization??"")!==h){Z.status(401).set("WWW-Authenticate",`Basic realm="${S}"`).set("Content-Type","text/plain").send("Unauthorized");return}B();});}for(let S of s)y.use(S);y.get(`${l}/`,f.handleDashboard),y.get(`${l}`,f.handleDashboard),y.get(`${l}/:repoName/_panel`,f.handlePanel),y.post(`${l}/:repoName/_bulk/delete`,f.handleBulkDelete),y.post(`${l}/:repoName/_bulk/update`,f.handleBulkUpdate),y.post(`${l}/:repoName/_bulk/backfill`,f.handleBulkBackfill),y.get(`${l}/:repoName`,f.handleList),y.get(`${l}/:repoName/create`,f.handleCreateForm),y.post(`${l}/:repoName/create`,f.handleCreateSubmit),y.get(`${l}/:repoName/:id/edit`,f.handleEditForm),y.post(`${l}/:repoName/:id/edit`,f.handleEditSubmit),y.get(`${l}/:repoName/:id/history`,f.handleHistory),y.post(`${l}/:repoName/:id/delete`,f.handleDelete);let g=async(S,h)=>{await y.handle(S,h);};return c&&(g.httpsOptions=c),g}
1059
1059
  exports.MiniRouter=_e;exports.createAdminServer=ga;//# sourceMappingURL=index.cjs.map
1060
1060
  //# sourceMappingURL=index.cjs.map