@protobase/ui 0.111.1 → 0.111.2

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 (119) hide show
  1. package/dist/account/messages.d.ts +2 -2
  2. package/dist/app/change-confirm/messages.d.ts +2 -2
  3. package/dist/app/confirm-sign-in-messages.d.ts +2 -2
  4. package/dist/app/create/messages.d.ts +2 -2
  5. package/dist/app/delete/messages.d.ts +2 -2
  6. package/dist/app/displays/messages.d.ts +2 -2
  7. package/dist/app/embedded-list/messages.d.ts +2 -2
  8. package/dist/app/export/messages.d.ts +2 -2
  9. package/dist/app/field-types/workflow/messages.d.ts +2 -2
  10. package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
  11. package/dist/app/focus/messages.d.ts +2 -2
  12. package/dist/app/gallery/gallery-layout.d.ts +2 -2
  13. package/dist/app/gallery/messages.d.ts +2 -2
  14. package/dist/app/history/messages.d.ts +2 -2
  15. package/dist/app/import/messages.d.ts +2 -2
  16. package/dist/app/list-messages.d.ts +2 -2
  17. package/dist/app/messages.d.ts +2 -2
  18. package/dist/app/meta-gate-messages.d.ts +2 -2
  19. package/dist/app/new-version/messages.d.ts +2 -2
  20. package/dist/app/pages/messages.d.ts +2 -2
  21. package/dist/app/record-chart/messages.d.ts +2 -2
  22. package/dist/app/record-messages.d.ts +2 -2
  23. package/dist/app/record-mode/shown-layout.d.ts +1 -1
  24. package/dist/app/record-row/messages.d.ts +2 -2
  25. package/dist/app/runtime/messages.d.ts +2 -2
  26. package/dist/app/saved/messages.d.ts +2 -2
  27. package/dist/app/saved/use-favorite.d.ts +1 -1
  28. package/dist/app/search/messages.d.ts +2 -2
  29. package/dist/app/searches/messages.d.ts +2 -2
  30. package/dist/app/searches/use-save-search.d.ts +1 -1
  31. package/dist/app-shell/messages.d.ts +2 -2
  32. package/dist/assistant-dock/messages.d.ts +2 -2
  33. package/dist/auth/messages.d.ts +2 -2
  34. package/dist/calls/messages.d.ts +2 -2
  35. package/dist/chat/messages.d.ts +2 -2
  36. package/dist/compact-table/messages.d.ts +2 -2
  37. package/dist/filter-panel/messages.d.ts +2 -2
  38. package/dist/inline-child-table/messages.d.ts +2 -2
  39. package/dist/invitations/messages.d.ts +2 -2
  40. package/dist/locale/en.js +8 -1
  41. package/dist/locale/en.json.d.ts +7 -0
  42. package/dist/locale/messages.d.ts +14 -0
  43. package/dist/locale/nl.js +8 -1
  44. package/dist/mocks/orders.d.ts +1 -1
  45. package/dist/organizations/messages.d.ts +2 -2
  46. package/dist/package.js +1 -1
  47. package/dist/primitives/messages.d.ts +2 -2
  48. package/dist/shell/assets/{api-provider-BopdAXpc.js → api-provider-CcDtTh0D.js} +2 -2
  49. package/dist/shell/assets/{app-CFp4G8NK.js → app-Du-Fd1QD.js} +8 -8
  50. package/dist/shell/assets/{badge-B4ikYIDJ.js → badge-ChHXC28D.js} +2 -2
  51. package/dist/shell/assets/{checkbox-B23HcgB6.js → checkbox-COOOlJPG.js} +2 -2
  52. package/dist/shell/assets/{display-value-DoqvOXh1.js → display-value-fDiKbfJO.js} +2 -2
  53. package/dist/shell/assets/export-worker-BGjZsI8V.js +15 -0
  54. package/dist/shell/assets/{field-badge-Dhke0lFK.js → field-badge-3QmjR1r3.js} +2 -2
  55. package/dist/shell/assets/{graph-view-DI1ULzNt.js → graph-view-CEo3E2az.js} +2 -2
  56. package/dist/shell/assets/{html-viewer-C_AC-COH.js → html-viewer-kitQumwS.js} +2 -2
  57. package/dist/shell/assets/{in-place-form-BE0jeXxK.js → in-place-form-DkBB2sDN.js} +2 -2
  58. package/dist/shell/assets/{index-or0lVadT.js → index-C5uOKZWj.js} +2 -2
  59. package/dist/shell/assets/{intl-cache-ULd6cKG6.js → intl-cache-bXVNV0Yq.js} +2 -2
  60. package/dist/shell/assets/{maplibre-DrBxXIsy.js → maplibre-q_iehi3V.js} +2 -2
  61. package/dist/shell/assets/{markdown-content-COBuNH9x.js → markdown-content-DgtMKGmV.js} +2 -2
  62. package/dist/shell/assets/messages-ClKBpZlk.js +2 -0
  63. package/dist/shell/assets/parse-worker-D7uEODYK.js +35 -0
  64. package/dist/shell/assets/{record-map-DfwRSYzd.js → record-map-X0gQ1idf.js} +2 -2
  65. package/dist/shell/assets/{records-map-qZnBB7DR.js → records-map-Gb_4xMSf.js} +2 -2
  66. package/dist/shell/assets/{run-trace-view-Fk1tXCaT.js → run-trace-view-BadnYB2f.js} +2 -2
  67. package/dist/shell/assets/{search-picker-DJ78Pz1K.js → search-picker-Cup7zlxY.js} +2 -2
  68. package/dist/shell/assets/{shared-protobase-ui-DSiFrCL5.js → shared-protobase-ui-BeXOZjFz.js} +2 -2
  69. package/dist/shell/assets/{step-catalog-C1OlIQJx.js → step-catalog-C1IXvKkP.js} +2 -2
  70. package/dist/shell/assets/{step-panel-DztOKEAB.js → step-panel-B46ysdoF.js} +2 -2
  71. package/dist/shell/assets/{use-app-address-EhuvnsNl.js → use-app-address-D50fN1nP.js} +2 -2
  72. package/dist/shell/assets/{use-meta-7JZ_HBay.js → use-meta-BqEqOLNe.js} +2 -2
  73. package/dist/shell/assets/{use-sibling-page-Cd-rFEbN.js → use-sibling-page-CyN4ATqh.js} +2 -2
  74. package/dist/shell/assets/{value-badge-D3nfF_kP.js → value-badge-BKLV4otJ.js} +2 -2
  75. package/dist/shell/assets/{workflow-canvas-DsvH-l5e.js → workflow-canvas-cBkbjmNk.js} +2 -2
  76. package/dist/shell/assets/{workflow-graph-editor-sZa5WHEO.js → workflow-graph-editor-BflCDM8U.js} +2 -2
  77. package/dist/shell/assets/{workflow-workbench-Bq7-Q1-w.js → workflow-workbench-B4S3OnRL.js} +2 -2
  78. package/dist/shell/index.html +12 -12
  79. package/dist/shell/protobase.shell.json +2 -2
  80. package/dist/shell/protobase.sw.js +2 -2
  81. package/dist/shell-source-maps/assets/{api-provider-BopdAXpc.js.map → api-provider-CcDtTh0D.js.map} +1 -1
  82. package/dist/shell-source-maps/assets/{app-CFp4G8NK.js.map → app-Du-Fd1QD.js.map} +1 -1
  83. package/dist/shell-source-maps/assets/{badge-B4ikYIDJ.js.map → badge-ChHXC28D.js.map} +1 -1
  84. package/dist/shell-source-maps/assets/{checkbox-B23HcgB6.js.map → checkbox-COOOlJPG.js.map} +1 -1
  85. package/dist/shell-source-maps/assets/{display-value-DoqvOXh1.js.map → display-value-fDiKbfJO.js.map} +1 -1
  86. package/dist/shell-source-maps/assets/export-worker-BGjZsI8V.js.map +1 -0
  87. package/dist/shell-source-maps/assets/{field-badge-Dhke0lFK.js.map → field-badge-3QmjR1r3.js.map} +1 -1
  88. package/dist/shell-source-maps/assets/{graph-view-DI1ULzNt.js.map → graph-view-CEo3E2az.js.map} +1 -1
  89. package/dist/shell-source-maps/assets/{html-viewer-C_AC-COH.js.map → html-viewer-kitQumwS.js.map} +1 -1
  90. package/dist/shell-source-maps/assets/{in-place-form-BE0jeXxK.js.map → in-place-form-DkBB2sDN.js.map} +1 -1
  91. package/dist/shell-source-maps/assets/{index-or0lVadT.js.map → index-C5uOKZWj.js.map} +1 -1
  92. package/dist/shell-source-maps/assets/{intl-cache-ULd6cKG6.js.map → intl-cache-bXVNV0Yq.js.map} +1 -1
  93. package/dist/shell-source-maps/assets/{maplibre-DrBxXIsy.js.map → maplibre-q_iehi3V.js.map} +1 -1
  94. package/dist/shell-source-maps/assets/{markdown-content-COBuNH9x.js.map → markdown-content-DgtMKGmV.js.map} +1 -1
  95. package/dist/shell-source-maps/assets/messages-ClKBpZlk.js.map +1 -0
  96. package/dist/shell-source-maps/assets/parse-worker-D7uEODYK.js.map +1 -0
  97. package/dist/shell-source-maps/assets/{record-map-DfwRSYzd.js.map → record-map-X0gQ1idf.js.map} +1 -1
  98. package/dist/shell-source-maps/assets/{records-map-qZnBB7DR.js.map → records-map-Gb_4xMSf.js.map} +1 -1
  99. package/dist/shell-source-maps/assets/{run-trace-view-Fk1tXCaT.js.map → run-trace-view-BadnYB2f.js.map} +1 -1
  100. package/dist/shell-source-maps/assets/{search-picker-DJ78Pz1K.js.map → search-picker-Cup7zlxY.js.map} +1 -1
  101. package/dist/shell-source-maps/assets/{shared-protobase-ui-DSiFrCL5.js.map → shared-protobase-ui-BeXOZjFz.js.map} +1 -1
  102. package/dist/shell-source-maps/assets/{step-catalog-C1OlIQJx.js.map → step-catalog-C1IXvKkP.js.map} +1 -1
  103. package/dist/shell-source-maps/assets/{step-panel-DztOKEAB.js.map → step-panel-B46ysdoF.js.map} +1 -1
  104. package/dist/shell-source-maps/assets/{use-app-address-EhuvnsNl.js.map → use-app-address-D50fN1nP.js.map} +1 -1
  105. package/dist/shell-source-maps/assets/{use-meta-7JZ_HBay.js.map → use-meta-BqEqOLNe.js.map} +1 -1
  106. package/dist/shell-source-maps/assets/{use-sibling-page-Cd-rFEbN.js.map → use-sibling-page-CyN4ATqh.js.map} +1 -1
  107. package/dist/shell-source-maps/assets/{value-badge-D3nfF_kP.js.map → value-badge-BKLV4otJ.js.map} +1 -1
  108. package/dist/shell-source-maps/assets/{workflow-canvas-DsvH-l5e.js.map → workflow-canvas-cBkbjmNk.js.map} +1 -1
  109. package/dist/shell-source-maps/assets/{workflow-graph-editor-sZa5WHEO.js.map → workflow-graph-editor-BflCDM8U.js.map} +1 -1
  110. package/dist/shell-source-maps/assets/{workflow-workbench-Bq7-Q1-w.js.map → workflow-workbench-B4S3OnRL.js.map} +1 -1
  111. package/dist/status/messages.d.ts +2 -2
  112. package/dist/users/messages.d.ts +2 -2
  113. package/package.json +5 -5
  114. package/dist/shell/assets/export-worker-DcpuaeRz.js +0 -15
  115. package/dist/shell/assets/messages-Y1hA4dds.js +0 -2
  116. package/dist/shell/assets/parse-worker-B5yLKylw.js +0 -35
  117. package/dist/shell-source-maps/assets/export-worker-DcpuaeRz.js.map +0 -1
  118. package/dist/shell-source-maps/assets/messages-Y1hA4dds.js.map +0 -1
  119. package/dist/shell-source-maps/assets/parse-worker-B5yLKylw.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"field-badge-Dhke0lFK.js","names":["n","a","t","__toESM","displayValue","ValueBadge","import_jsx_runtime","require_jsx_runtime","FieldBadge","declared","model","field","value","record","hints","view"],"sources":["../../../src/app/field-badge.tsx"],"sourcesContent":["import type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { displayValue } from '../live/display-value'\nimport { ValueBadge } from './value-badge'\n\n/**\n * A record's value of `field` as a badge, in the words and colour its view gives the value, with the field's label for\n * screen readers; nothing for a field the model does not have or an empty value.\n */\nexport const FieldBadge = ({ model, view, field, record }: { model: ResourceModel; view: ViewModel | undefined; field: string; record: Record<string, unknown> }) => {\n const declared = model.fields[field]\n const value = record[field]\n if (!declared || value === null || value === undefined) return null\n const hints = view?.fields[field]\n return (\n <ValueBadge value={value} hints={hints}>\n <span className=\"sr-only\">{hints?.label ?? field}: </span>\n {displayValue(declared, value, hints)}\n </ValueBadge>\n )\n}\n"],"mappings":"0pBAQaQ,GAAc,CAAE,QAAO,OAAM,QAAO,YAAoH,CACnK,IAAMC,EAAWC,EAAM,OAAOC,GACxBC,EAAQC,EAAOF,GACrB,GAAI,CAACF,GAAYG,GAAU,KAA6B,OAAO,KAC/D,IAAME,EAAQC,GAAM,OAAOJ,GAC3B,OACE,EAAAL,EAAA,KAAA,CAACD,EAAD,CAAmB,QAAc,QAAjC,SAAA,EACE,EAAAC,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,UAAhB,SAAA,CAA2BQ,GAAO,OAASH,EAAM,IAAQ,CACxD,CAAA,EAAAP,EAAaK,EAAUG,EAAOE,CAAK,CAC1B,GAEhB","debugId":"e191ed25-14a3-4d3b-9ccb-ded42ec94501"}
1
+ {"version":3,"file":"field-badge-3QmjR1r3.js","names":["n","a","t","__toESM","displayValue","ValueBadge","import_jsx_runtime","require_jsx_runtime","FieldBadge","declared","model","field","value","record","hints","view"],"sources":["../../../src/app/field-badge.tsx"],"sourcesContent":["import type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { displayValue } from '../live/display-value'\nimport { ValueBadge } from './value-badge'\n\n/**\n * A record's value of `field` as a badge, in the words and colour its view gives the value, with the field's label for\n * screen readers; nothing for a field the model does not have or an empty value.\n */\nexport const FieldBadge = ({ model, view, field, record }: { model: ResourceModel; view: ViewModel | undefined; field: string; record: Record<string, unknown> }) => {\n const declared = model.fields[field]\n const value = record[field]\n if (!declared || value === null || value === undefined) return null\n const hints = view?.fields[field]\n return (\n <ValueBadge value={value} hints={hints}>\n <span className=\"sr-only\">{hints?.label ?? field}: </span>\n {displayValue(declared, value, hints)}\n </ValueBadge>\n )\n}\n"],"mappings":"0pBAQaQ,GAAc,CAAE,QAAO,OAAM,QAAO,YAAoH,CACnK,IAAMC,EAAWC,EAAM,OAAOC,GACxBC,EAAQC,EAAOF,GACrB,GAAI,CAACF,GAAYG,GAAU,KAA6B,OAAO,KAC/D,IAAME,EAAQC,GAAM,OAAOJ,GAC3B,OACE,EAAAL,EAAA,KAAA,CAACD,EAAD,CAAmB,QAAc,QAAjC,SAAA,EACE,EAAAC,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,UAAhB,SAAA,CAA2BQ,GAAO,OAASH,EAAM,IAAQ,CACxD,CAAA,EAAAP,EAAaK,EAAUG,EAAOE,CAAK,CAC1B,GAEhB","debugId":"374268d1-d6bd-4148-95c9-9dc00db299cc"}
@@ -1 +1 @@
1
- {"version":3,"file":"graph-view-DI1ULzNt.js","names":["_Fragment","useMemo","useState","useState","useMemo","ReactFlow","n","a","t","__toESM","require_react","require_jsx_runtime","ToneEdge","parseCondition","scopeValue","evaluateCondition","RecordScope","RouteLink","valueColor","valueTone","scopeOf","FieldBadge","ReactFlowProvider","useReactFlow","MarkerType","Position","Controls","index","Handle","useElk","slotPattern","sampleSlots","slots","text","last","match","source","quoted","edgeConditions","edgeCondition","when","import_react","toneStrokes","dashes","edgeConditionsOf","props","name","holds","parsed","scope","row","path","edgeLook","status","colors","view","value","edge","stroke","dash","conditions","labelValue","labels","label","nodeSize","padding","elkPadding","placedGap","groupId","id","nodeId","algorithmOptions","input","unplaced","shape","node","graphElk","nodes","options","box","groups","members","group","loose","laid","edges","boundsOf","boxes","x","y","placeGraph","placed","position","engine","visit","child","parent","at","laidOut","above","below","shift","whole","moved","import_jsx_runtime","handle","Handles","sides","frame","chosen","RecordNode","data","fields","content","to","model","GroupNode","useGraphLayout","elk","signature","placedOnly","setLaidOut","failure","setFailure","current","result","error","nodeTypes","minHeight","maxHeight","fitViewOptions","themed","number","flowNodes","read","drawn","layout","select","flowEdges","look","straight","FitOnLayout","flow","Flow","measured","setMeasured","sizes","positions","layoutName","direction","ready","measure","heights","changes","change","next","before","size","GraphView"],"sources":["../../../../layout/src/filter-slots.ts","../../../../layout/src/graph-edges.ts","../../../src/app/pages/blocks/graph/graph-edges.ts","../../../src/app/pages/blocks/graph/graph-layout.ts","../../../src/app/pages/blocks/graph/graph-nodes.tsx","../../../src/app/pages/blocks/graph/use-graph-layout.ts","../../../src/app/pages/blocks/graph/graph-view.tsx"],"sourcesContent":["import { parseFilter, type Expr } from 'aip-parsers/filter'\n\n// A filter or condition with `{{path}}` slots only parses once each slot stands in for a value: a quoted one for a\n// word, any other for a number. Each slot's place in that text then finds it in the syntax tree.\n\n/** One `{{path}}` of a filter, where its stand-in starts, and whether it sits in quotes as a whole value. */\nexport type FilterSlot = { path: string; start: number; quoted: boolean }\n\nconst slotPattern = /([\"'])\\{\\{\\s*([^{}]*?)\\s*\\}\\}\\1|\\{\\{\\s*([^{}]*?)\\s*\\}\\}/g\n\n/** `source` with every slot replaced by a stand-in value, and the slots in order. */\nexport const sampleSlots = (source: string): { text: string; slots: FilterSlot[] } => {\n const slots: FilterSlot[] = []\n let text = ''\n let last = 0\n for (const match of source.matchAll(slotPattern)) {\n text += source.slice(last, match.index)\n const quoted = match[1] !== undefined\n slots.push({ path: (quoted ? match[2] : match[3])!, start: text.length, quoted })\n text += quoted ? `${match[1]}x${match[1]}` : '0'\n last = match.index + match[0].length\n }\n return { text: text + source.slice(last), slots }\n}\n\ntype Node = { kind: string; span?: { start: number }; [key: string]: unknown }\n\n// The conjuncts of the top level: `a AND b c` is three.\nconst conjuncts = (expr: Expr): Expr[] => (expr.kind === 'and' || expr.kind === 'sequence' ? expr.args.flatMap(conjuncts) : [expr])\n\nconst isLiteralAt = (node: Node, start: number) => (node.kind === 'string' || node.kind === 'number') && node.span?.start === start\n\n/**\n * The slots that are one side of a top-level AND equality with a field on the other, `field = {{path}}`, the one shape\n * a read can split per row without waiting for the rows it depends on; `undefined` when the filter does not parse.\n */\nexport const equalitySlots = (source: string): { slots: FilterSlot[]; split: Set<FilterSlot> } | undefined => {\n const { text, slots } = sampleSlots(source)\n const parsed = parseFilter(text)\n if (!parsed.ok) return\n const split = new Set<FilterSlot>()\n for (const conjunct of parsed.ast ? conjuncts(parsed.ast) : []) {\n if (conjunct.kind !== 'compare' || conjunct.op !== '=') continue\n const [left, right] = [conjunct.left as Node, conjunct.right as Node]\n for (const slot of slots) {\n if ((left.kind === 'member' && isLiteralAt(right, slot.start)) || (right.kind === 'member' && isLiteralAt(left, slot.start))) split.add(slot)\n }\n }\n return { slots, split }\n}\n","import { parseCondition } from './condition'\nimport { sampleSlots } from './filter-slots'\nimport type { LayoutNode } from './node'\n\n/** The conditions on a graph's edge, each evaluated per edge as the graph draws. */\nexport const edgeConditions = ['animated', 'dashed', 'dotted'] as const\n\nconst text = (value: unknown) => (typeof value === 'string' ? value : undefined)\n\n/** A condition on an edge: its `{{path}}`s are the scope's around the graph, filled before it draws; its fields the edge's. */\nexport const edgeCondition = (when: string) => parseCondition(sampleSlots(when).text)\n\n/** The fields of an edge a graph's conditions compare, which its read asks for. */\nexport const edgeConditionFields = (node: LayoutNode): string[] =>\n edgeConditions.flatMap((name) => {\n const when = text(node.props[name])\n const parsed = when === undefined ? undefined : edgeCondition(when)\n return parsed?.ok ? parsed.paths.map((path) => path.split('.')[0]!) : []\n })\n","import { edgeCondition, edgeConditions, evaluateCondition, scopeValue, type GraphProps, type ShapeEdge } from '@protobase/layout'\nimport type { BadgeTone, ViewModel } from '@protobase/schema'\nimport { valueColor, valueTone } from '../../../../live/value-color'\n\n/** How an edge draws: its line's colour, whether it moves, its dashes, and the text on its middle. */\nexport type EdgeLook = { stroke: string; animated: boolean; dash?: string; label?: string }\n\n// A line in the colour its value's badge has, the app's border colour without one\nconst toneStrokes: Record<BadgeTone, string> = {\n neutral: 'var(--color-border-strong)',\n blue: 'var(--color-primary)',\n green: 'var(--color-success)',\n amber: 'var(--color-warning)',\n red: 'var(--color-danger)',\n violet: 'var(--color-violet)',\n}\n\nconst dashes = { dashed: '6 4', dotted: '1.5 4' }\n\ntype Parsed = Partial<Record<(typeof edgeConditions)[number], ReturnType<typeof edgeCondition>>>\n\n/** The graph's conditions on an edge, parsed once: a condition that does not parse never holds. */\nexport const edgeConditionsOf = (props: Pick<GraphProps, (typeof edgeConditions)[number]>): Parsed =>\n Object.fromEntries(edgeConditions.flatMap((name) => (typeof props[name] === 'string' ? [[name, edgeCondition(props[name])]] : [])))\n\nconst holds = (parsed: ReturnType<typeof edgeCondition> | undefined, row: Record<string, unknown>) => {\n if (!parsed?.ok) return false\n const scope = { stack: [{ record: row }] }\n return evaluateCondition(parsed, Object.fromEntries(parsed.paths.map((path) => [path, scopeValue(scope, path)])))\n}\n\n/** How `edge` draws by the graph's `edgeStatus`, `edgeLabel` and conditions, its colours and value labels the edges view's. */\nexport const edgeLook = (edge: ShapeEdge, props: Pick<GraphProps, 'edgeLabel' | 'edgeStatus'>, conditions: Parsed, view: ViewModel | undefined): EdgeLook => {\n const status = props.edgeStatus\n const colors = status === undefined ? undefined : view?.fields[status]?.valueColors\n const value = status === undefined ? undefined : edge.row[status]\n const stroke = status === undefined || value == null ? toneStrokes.neutral : (valueColor(colors, value) ?? toneStrokes[valueTone(colors, value)])\n const dash = holds(conditions.dotted, edge.row) ? dashes.dotted : holds(conditions.dashed, edge.row) ? dashes.dashed : undefined\n const labelValue = props.edgeLabel === undefined ? undefined : edge.row[props.edgeLabel]\n const labels = props.edgeLabel === undefined ? undefined : view?.fields[props.edgeLabel]?.valueLabels\n const label = labelValue == null || labelValue === '' ? undefined : (labels?.[String(labelValue)] ?? String(labelValue))\n return { stroke, animated: holds(conditions.animated, edge.row), ...(dash && { dash }), ...(label !== undefined && { label }) }\n}\n","import type { ElkNode } from 'elkjs/lib/elk-api'\nimport type { GraphLayoutName, GraphShape } from '@protobase/layout'\n\n/** A node's size: room for its label on one or two lines and its status badge, the width a node's own contents get. */\nexport const nodeSize = { width: 200, height: 64 }\n\n/** The width of a node that draws contents of its own, whose height they decide. */\nexport const contentWidth = 224\n\n/** A box at its top-left corner, in the graph's own coordinates. */\nexport type Box = { x: number; y: number; width: number; height: number }\n\nexport type Size = { width: number; height: number }\n\n/** Where each group and node of a graph sits, each group a region around its nodes, and the size of the whole. */\nexport type GraphLayout = { groups: Map<string, Box>; nodes: Map<string, Box>; width: number; height: number }\n\n/** How a graph is laid out: its algorithm, which way a layered one runs, each node's size, and the nodes placed by their records. */\nexport type LayoutInput = { layout: GraphLayoutName; direction: 'down' | 'right'; sizes: ReadonlyMap<string, Size>; positions: ReadonlyMap<string, { x: number; y: number }> }\n\n// Room in a region around its nodes, more on top for its value\nconst padding = { top: 32, side: 16, bottom: 16 }\nconst elkPadding = `[top=${padding.top},left=${padding.side},bottom=${padding.bottom},right=${padding.side}]`\n\n// The space between the nodes the engine lays out and the ones placed above them\nconst placedGap = 48\n\nconst groupId = (id: string) => `group:${id}`\nconst nodeId = (id: string) => `node:${id}`\n\nconst algorithmOptions = (input: LayoutInput): Record<string, string> =>\n input.layout === 'force'\n ? // Its seed is fixed, so the same records always make the same picture\n { 'elk.algorithm': 'force', 'elk.randomSeed': '1', 'elk.spacing.nodeNode': '40' }\n : { 'elk.algorithm': 'layered', 'elk.direction': input.direction === 'right' ? 'RIGHT' : 'DOWN', 'elk.layered.spacing.nodeNodeBetweenLayers': '56', 'elk.spacing.nodeNode': '32' }\n\n/** The nodes the engine places: those without a position of their own. */\nconst unplaced = (shape: GraphShape, input: LayoutInput) => shape.nodes.filter((node) => !input.positions.has(node.id))\n\n/**\n * The graph ELK lays out: each node without a position as a box of its size, inside a box of its group, and each edge\n * between two of them. A layered graph lays its groups out with the rest (hierarchy INCLUDE_CHILDREN); a force one\n * lays each group out inside its box, then the boxes as nodes. `undefined` when every node has a position.\n */\nexport const graphElk = (shape: GraphShape, input: LayoutInput): ElkNode | undefined => {\n const nodes = unplaced(shape, input)\n if (nodes.length === 0) return undefined\n const options = algorithmOptions(input)\n const box = (id: string): ElkNode => ({ id: nodeId(id), ...(input.sizes.get(id) ?? nodeSize) })\n const groups = shape.groups.flatMap((group): ElkNode[] => {\n const members = nodes.filter((node) => node.group === group.id)\n return members.length === 0 ? [] : [{ id: groupId(group.id), layoutOptions: { ...options, 'elk.padding': elkPadding }, children: members.map((node) => box(node.id)) }]\n })\n const loose = nodes.filter((node) => node.group === undefined).map((node) => box(node.id))\n const laid = new Set(nodes.map((node) => node.id))\n const edges = shape.edges.filter((edge) => laid.has(edge.source) && laid.has(edge.target) && edge.source !== edge.target).map((edge) => ({ id: `edge:${edge.id}`, sources: [nodeId(edge.source)], targets: [nodeId(edge.target)] }))\n return { id: 'root', layoutOptions: { ...options, ...(input.layout === 'layered' && { 'elk.hierarchyHandling': 'INCLUDE_CHILDREN' }) }, children: [...groups, ...loose], edges }\n}\n\nconst boundsOf = (boxes: Box[]): Box | undefined => {\n if (boxes.length === 0) return undefined\n const x = Math.min(...boxes.map((box) => box.x))\n const y = Math.min(...boxes.map((box) => box.y))\n return { x, y, width: Math.max(...boxes.map((box) => box.x + box.width)) - x, height: Math.max(...boxes.map((box) => box.y + box.height)) - y }\n}\n\n/**\n * Where everything sits: each placed node at its position, the nodes the engine laid out (`laidOut`, from `graphElk`)\n * under them, each group a region around its nodes, the whole moved so it starts at 0, 0.\n */\nexport const placeGraph = (shape: GraphShape, input: LayoutInput, laidOut?: ElkNode): GraphLayout => {\n const placed = new Map<string, Box>()\n for (const node of shape.nodes) {\n const position = input.positions.get(node.id)\n if (position) placed.set(node.id, { ...position, ...(input.sizes.get(node.id) ?? nodeSize) })\n }\n // ELK gives each child its place inside its parent\n const engine = new Map<string, Box>()\n const visit = (parent: ElkNode, x: number, y: number) => {\n for (const child of parent.children ?? []) {\n const at = { x: x + (child.x ?? 0), y: y + (child.y ?? 0) }\n if (child.id.startsWith('node:')) engine.set(child.id.slice('node:'.length), { ...at, width: child.width ?? nodeSize.width, height: child.height ?? nodeSize.height })\n else visit(child, at.x, at.y)\n }\n }\n if (laidOut) visit(laidOut, 0, 0)\n const above = boundsOf([...placed.values()])\n const below = boundsOf([...engine.values()])\n const shift = above && below ? { x: above.x - below.x, y: above.y + above.height + placedGap - below.y } : { x: 0, y: 0 }\n for (const [id, box] of engine) placed.set(id, { ...box, x: box.x + shift.x, y: box.y + shift.y })\n const groups = new Map<string, Box>()\n for (const group of shape.groups) {\n const members = boundsOf(shape.nodes.filter((node) => node.group === group.id && placed.has(node.id)).map((node) => placed.get(node.id)!))\n if (members) groups.set(group.id, { x: members.x - padding.side, y: members.y - padding.top, width: members.width + 2 * padding.side, height: members.height + padding.top + padding.bottom })\n }\n const whole = boundsOf([...placed.values(), ...groups.values()]) ?? { x: 0, y: 0, width: 0, height: 0 }\n const moved = (box: Box): Box => ({ ...box, x: box.x - whole.x, y: box.y - whole.y })\n return {\n nodes: new Map([...placed].map(([id, box]) => [id, moved(box)])),\n groups: new Map([...groups].map(([id, box]) => [id, moved(box)])),\n width: whole.width,\n height: whole.height,\n }\n}\n","import type { GraphFields } from '@protobase/layout'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { Handle, Position, type Node, type NodeProps } from '@xyflow/react'\nimport type { ReactNode } from 'react'\nimport { RouteLink, type RouteTarget } from '../../../../primitives/route-link'\nimport { FieldBadge } from '../../../field-badge'\nimport { ToneEdge } from '../../../related-cards/tone-edge'\nimport { RecordScope } from '../../record-scope'\nimport { scopeOf } from '../../use-layout-data'\n\ntype Drawn = { model: ResourceModel; view: ViewModel | undefined; fields: GraphFields }\n\n/** Which sides a node's edges meet it on: the top and bottom for a graph that runs down, else the left and right. */\nexport type Sides = 'vertical' | 'horizontal'\n\n/**\n * A node as it draws: its record, what the graph draws in each node, the link that chooses it when the graph has\n * `select`, whether it is chosen, and which sides its edges meet.\n */\nexport type RecordNodeData = Drawn & { row: Record<string, unknown>; content?: ReactNode; to?: RouteTarget; chosen: boolean; sides: Sides }\n\n/** A group as it draws: the record of one of its nodes, whose `group` value it shows. */\nexport type GroupNodeData = Drawn & { row: Record<string, unknown> }\n\n// The handles take no part in the drawing, since the graph cannot be edited\nconst handle = 'pointer-events-none !min-h-0 !min-w-0 !border-0 !bg-transparent'\n\nconst Handles = ({ sides }: { sides: Sides }) => (\n <>\n <Handle type=\"target\" position={sides === 'vertical' ? Position.Top : Position.Left} isConnectable={false} className={handle} />\n <Handle type=\"source\" position={sides === 'vertical' ? Position.Bottom : Position.Right} isConnectable={false} className={handle} />\n </>\n)\n\nconst frame = (chosen: boolean) => `relative rounded-lg border bg-surface text-body ${chosen ? 'border-primary ring-2 ring-primary/40' : 'border-border'}`\n\n/**\n * A node: with contents of the graph's own, those, drawn inside its record, the whole node a link that chooses it; else\n * its label, linking to the page with it chosen, over its status badge. Its status colours its left edge.\n */\nexport const RecordNode = ({ data }: NodeProps<Node<RecordNodeData, 'record'>>) => {\n const { model, view, fields, row, content, to, chosen, sides } = data\n const label = String(row[fields.label] ?? '')\n const edge = fields.status && <ToneEdge view={view} field={fields.status} record={row} />\n if (content !== undefined) {\n return (\n <div data-chosen={chosen || undefined} className={`${frame(chosen)} flex w-full flex-col gap-1 px-3 py-2`}>\n <Handles sides={sides} />\n {edge}\n {/* A link over the whole node chooses it, under the contents, whose own links stay theirs; React Flow turns\n pointer events off on a node that cannot be dragged or selected, so each takes them back */}\n {to && <RouteLink to={to} aria-label={label} aria-current={chosen || undefined} className=\"pointer-events-auto absolute inset-0 rounded-lg hover:bg-muted/40\" />}\n <div className=\"relative min-w-0 [overflow-wrap:anywhere] [&_a]:pointer-events-auto\">\n <RecordScope value={scopeOf(model, row)}>{content}</RecordScope>\n </div>\n </div>\n )\n }\n return (\n <div data-chosen={chosen || undefined} className={`${frame(chosen)} flex size-full flex-col justify-center gap-1 px-3 py-2`}>\n <Handles sides={sides} />\n {edge}\n {to ? (\n <RouteLink to={to} aria-current={chosen || undefined} className=\"pointer-events-auto line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline\">\n {label}\n </RouteLink>\n ) : (\n <span className=\"line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere]\">{label}</span>\n )}\n {fields.status && (\n <div className=\"flex\">\n <FieldBadge model={model} view={view} field={fields.status} record={row} />\n </div>\n )}\n </div>\n )\n}\n\n/** A group: a region around its nodes, its `group` value at its top. */\nexport const GroupNode = ({ data }: NodeProps<Node<GroupNodeData, 'group-box'>>) => (\n <div className=\"size-full rounded-xl border border-dashed border-border-strong bg-muted/40\">\n {data.fields.group && (\n <div className=\"flex px-2 pt-1 text-xs\">\n <FieldBadge model={data.model} view={data.view} field={data.fields.group} record={data.row} />\n </div>\n )}\n </div>\n)\n","import { useEffect, useMemo, useState } from 'react'\nimport type { GraphShape } from '@protobase/layout'\nimport { useElk } from '../../../../lib/elk/use-elk'\nimport { graphElk, placeGraph, type GraphLayout, type LayoutInput } from './graph-layout'\n\n/**\n * Where the graph's groups and nodes sit, laid out again when its nodes, edges, sizes or positions change; undefined\n * until the first layout is done. A layout that a newer one overtook is dropped. Without a node to lay out, the engine\n * is never asked. A layout that fails throws, for the block's fallback or the page's error boundary to draw.\n */\nexport const useGraphLayout = (shape: GraphShape, input: LayoutInput): GraphLayout | undefined => {\n const elk = graphElk(shape, input)\n const engine = useElk()\n // One text for what the layout is made from, so a new shape of the same records lays nothing out again\n const signature = JSON.stringify([elk, shape.nodes.map((node) => node.id), shape.groups.map((group) => group.id), [...input.positions], [...input.sizes]])\n const placedOnly = useMemo(() => (elk ? undefined : placeGraph(shape, input)), [signature])\n const [laidOut, setLaidOut] = useState<{ signature: string; layout: GraphLayout }>()\n const [failure, setFailure] = useState<Error>()\n useEffect(() => {\n if (!engine || !elk) return\n let current = true\n engine.layout(elk).then(\n (result) => {\n if (current) setLaidOut({ signature, layout: placeGraph(shape, input, result) })\n },\n (error: unknown) => {\n if (current) setFailure(error instanceof Error ? error : new Error(String(error)))\n },\n )\n return () => {\n current = false\n }\n }, [engine, signature])\n // A layout that failed, such as a worker that cannot load, draws the graph's fallback or its error, not a blank box\n if (failure) throw failure\n if (placedOnly) return placedOnly\n // The last layout stands while the next one is made, so a live update does not blank the graph\n return laidOut?.layout\n}\n","import { Controls, MarkerType, ReactFlow, ReactFlowProvider, useReactFlow, type Edge, type Node, type NodeChange } from '@xyflow/react'\nimport type { GraphFields, GraphProps, GraphShape } from '@protobase/layout'\nimport { useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react'\nimport type { ComponentRead, ComponentSelect } from '../../component-reads'\nimport { edgeConditionsOf, edgeLook } from './graph-edges'\nimport { contentWidth, nodeSize, type GraphLayout, type Size } from './graph-layout'\nimport { GroupNode, RecordNode, type GroupNodeData, type RecordNodeData, type Sides } from './graph-nodes'\nimport { useGraphLayout } from './use-graph-layout'\nimport '@xyflow/react/dist/style.css'\n\nconst nodeTypes = { record: RecordNode, 'group-box': GroupNode }\n\n// The box's height follows the graph's shape at the box's width, within bounds, so the page scrolls past it\nconst minHeight = 256\nconst maxHeight = 'min(40rem, 70vh)'\n\n// A graph wider than the box, as on a phone, stays readable and pans; the fit button shows all of it\nconst fitViewOptions = { minZoom: 0.6, maxZoom: 1 }\n\n// The library's lines and controls in the app's tokens, over the page's own background: the variables it reads over\n// its own defaults\nconst themed = {\n '--xy-edge-stroke': 'var(--color-border-strong)',\n '--xy-edge-stroke-width': '1.5',\n '--xy-background-color': 'transparent',\n '--xy-edge-label-background-color': 'var(--color-surface)',\n '--xy-edge-label-color': 'var(--color-muted-foreground)',\n '--xy-controls-button-background-color': 'var(--color-surface)',\n '--xy-controls-button-background-color-hover': 'var(--color-muted)',\n '--xy-controls-button-color': 'var(--color-foreground)',\n '--xy-controls-button-color-hover': 'var(--color-foreground)',\n '--xy-controls-button-border-color': 'var(--color-border)',\n '--xy-attribution-background-color': 'transparent',\n} as CSSProperties\n\nexport type GraphViewProps = {\n shape: GraphShape\n nodes: Pick<ComponentRead, 'model' | 'view'>\n edges: Pick<ComponentRead, 'model' | 'view'>\n fields: GraphFields\n props: Pick<GraphProps, 'layout' | 'direction' | 'x' | 'y' | 'edgeLabel' | 'edgeStatus' | 'animated' | 'dashed' | 'dotted'>\n select?: ComponentSelect\n /** What each node draws, inside its record, the graph's `node`; its label and status without it. */\n content?: ReactNode\n}\n\nconst number = (value: unknown) => (typeof value === 'number' && Number.isFinite(value) ? value : typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)) ? Number(value) : undefined)\n\n// The nodes React Flow draws: each group's region under the nodes, each node at its box, one with contents of its own\n// as wide as they are given and as tall as they draw, which it measures\nconst flowNodes = ({ shape, nodes: read, fields, select, content }: GraphViewProps, layout: GraphLayout | undefined, sides: Sides): Node[] => {\n const drawn = { model: read.model, view: read.view, fields }\n const groups = shape.groups.flatMap((group): Node<GroupNodeData>[] => {\n const box = layout?.groups.get(group.id)\n const row = shape.nodes.find((node) => node.group === group.id)!.row\n return box ? [{ id: `group:${group.id}`, type: 'group-box', position: { x: box.x, y: box.y }, width: box.width, height: box.height, zIndex: -1, data: { ...drawn, row }, draggable: false, selectable: false, focusable: false }] : []\n })\n const nodes = shape.nodes.map((node): Node<RecordNodeData> => {\n const box = layout?.nodes.get(node.id)\n const chosen = select?.chosen === node.id\n return {\n id: `node:${node.id}`,\n type: 'record',\n position: box ? { x: box.x, y: box.y } : { x: 0, y: 0 },\n ...(content === undefined ? { width: nodeSize.width, height: nodeSize.height } : { style: { width: contentWidth } }),\n data: { ...drawn, row: node.row, chosen, sides, ...(content !== undefined && { content }), ...(select && { to: select.linkTo(node.id) }) },\n draggable: false,\n selectable: false,\n }\n })\n return [...groups, ...nodes]\n}\n\nconst flowEdges = ({ shape, edges: read, props }: GraphViewProps, straight: boolean): Edge[] => {\n const conditions = edgeConditionsOf(props)\n return shape.edges.map((edge) => {\n const look = edgeLook(edge, props, conditions, read.view)\n return {\n id: `edge:${edge.id}`,\n source: `node:${edge.source}`,\n target: `node:${edge.target}`,\n ...(straight && { type: 'straight' }),\n markerEnd: { type: MarkerType.ArrowClosed, color: look.stroke },\n style: { stroke: look.stroke, ...(look.dash && { strokeDasharray: look.dash }) },\n animated: look.animated,\n ...(look.label !== undefined && { label: look.label, labelBgPadding: [4, 2] as [number, number], labelBgBorderRadius: 4 }),\n focusable: false,\n selectable: false,\n }\n })\n}\n\n// Fits the graph to its box each time it is laid out anew, as its first fit does, a frame later, once the nodes stand\n// where the layout put them\nconst FitOnLayout = ({ layout }: { layout: GraphLayout | undefined }) => {\n const flow = useReactFlow()\n useEffect(() => {\n if (!layout) return\n const frame = requestAnimationFrame(() => void flow.fitView(fitViewOptions))\n return () => cancelAnimationFrame(frame)\n }, [flow, layout])\n return null\n}\n\nconst Flow = (props: GraphViewProps) => {\n const { shape, content } = props\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(new Map())\n const sizes = useMemo(() => new Map(shape.nodes.map((node) => [node.id, content === undefined ? nodeSize : { width: contentWidth, height: measured.get(node.id)?.height ?? nodeSize.height }])), [shape, content, measured])\n const positions = useMemo(() => {\n const { x, y } = props.props\n if (x === undefined || y === undefined) return new Map<string, { x: number; y: number }>()\n return new Map(shape.nodes.flatMap((node) => {\n const at = { x: number(node.row[x]), y: number(node.row[y]) }\n return at.x === undefined || at.y === undefined ? [] : [[node.id, at as { x: number; y: number }]]\n }))\n }, [shape, props.props.x, props.props.y])\n const layoutName = props.props.layout ?? 'layered'\n const direction = props.props.direction ?? 'down'\n const layout = useGraphLayout(shape, { layout: layoutName, direction, sizes, positions })\n // A node with contents of its own is laid out at the height it draws at, so until each has drawn once the graph is\n // see-through: React Flow shows each node itself, so hiding the box would not hide them\n const ready = layout !== undefined && (content === undefined || shape.nodes.every((node) => measured.has(node.id)))\n const sides: Sides = layoutName === 'layered' && direction === 'right' ? 'horizontal' : 'vertical'\n const nodes = flowNodes(props, layout, sides)\n const edges = useMemo(() => flowEdges(props, layoutName === 'force'), [shape, props.edges.view, props.props, layoutName])\n const measure = (changes: NodeChange[]) => {\n const heights = changes.flatMap((change) => (change.type === 'dimensions' && change.dimensions && change.id.startsWith('node:') ? [[change.id.slice('node:'.length), change.dimensions] as const] : []))\n if (heights.length === 0) return\n setMeasured((before) => {\n const next = new Map(before)\n for (const [id, size] of heights) next.set(id, { width: Math.round(size.width), height: Math.round(size.height) })\n const same = next.size === before.size && [...next].every(([id, size]) => before.get(id)?.height === size.height)\n return same ? before : next\n })\n }\n return (\n <div className=\"w-full\" style={{ ...themed, aspectRatio: layout ? `${Math.max(layout.width, 1)} / ${Math.max(layout.height, 1)}` : undefined, minHeight, maxHeight, ...(!ready && { opacity: 0 }) }}>\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={content === undefined ? undefined : measure}\n fitView\n fitViewOptions={fitViewOptions}\n minZoom={0.1}\n nodesDraggable={false}\n nodesConnectable={false}\n elementsSelectable={false}\n edgesFocusable={false}\n zoomOnScroll={false}\n zoomOnDoubleClick={false}\n preventScrolling={false}\n zoomOnPinch\n panOnDrag\n >\n <FitOnLayout layout={ready ? layout : undefined} />\n <Controls showInteractive={false} />\n </ReactFlow>\n </div>\n )\n}\n\n/**\n * The graph in a box as wide as the page and as tall as its shape asks, within bounds, fitted to it unless that would\n * shrink it past reading: pinch or the zoom buttons zoom it, dragging pans it, and the wheel scrolls the page past it.\n * Read-only: nothing moves, connects or is deleted.\n */\nexport const GraphView = (props: GraphViewProps) => (\n <ReactFlowProvider>\n <Flow {...props} />\n </ReactFlowProvider>\n)\n"],"mappings":"g6BAQA,IAAM8B,EAAc,2DAGPC,EAAe,GAA0D,CACpF,IAAMC,EAAsB,CA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CAET,EAOaoI,GAAa,IACxB,EAAAtD,EAAA,IAAA,CAAClF,EAAD,CAAA,UACE,EAAAkF,EAAA,IAAA,CAACuC,GAAD,CAAM,GAAIlG,CAAQ,CAAA,CACD,CAAA","debugId":"c8d542f3-36d2-4ede-83de-7707a7bf1d51"}
1
+ {"version":3,"file":"graph-view-CEo3E2az.js","names":["_Fragment","useMemo","useState","useState","useMemo","ReactFlow","n","a","t","__toESM","require_react","require_jsx_runtime","ToneEdge","parseCondition","scopeValue","evaluateCondition","RecordScope","RouteLink","valueColor","valueTone","scopeOf","FieldBadge","ReactFlowProvider","useReactFlow","MarkerType","Position","Controls","index","Handle","useElk","slotPattern","sampleSlots","slots","text","last","match","source","quoted","edgeConditions","edgeCondition","when","import_react","toneStrokes","dashes","edgeConditionsOf","props","name","holds","parsed","scope","row","path","edgeLook","status","colors","view","value","edge","stroke","dash","conditions","labelValue","labels","label","nodeSize","padding","elkPadding","placedGap","groupId","id","nodeId","algorithmOptions","input","unplaced","shape","node","graphElk","nodes","options","box","groups","members","group","loose","laid","edges","boundsOf","boxes","x","y","placeGraph","placed","position","engine","visit","child","parent","at","laidOut","above","below","shift","whole","moved","import_jsx_runtime","handle","Handles","sides","frame","chosen","RecordNode","data","fields","content","to","model","GroupNode","useGraphLayout","elk","signature","placedOnly","setLaidOut","failure","setFailure","current","result","error","nodeTypes","minHeight","maxHeight","fitViewOptions","themed","number","flowNodes","read","drawn","layout","select","flowEdges","look","straight","FitOnLayout","flow","Flow","measured","setMeasured","sizes","positions","layoutName","direction","ready","measure","heights","changes","change","next","before","size","GraphView"],"sources":["../../../../layout/src/filter-slots.ts","../../../../layout/src/graph-edges.ts","../../../src/app/pages/blocks/graph/graph-edges.ts","../../../src/app/pages/blocks/graph/graph-layout.ts","../../../src/app/pages/blocks/graph/graph-nodes.tsx","../../../src/app/pages/blocks/graph/use-graph-layout.ts","../../../src/app/pages/blocks/graph/graph-view.tsx"],"sourcesContent":["import { parseFilter, type Expr } from 'aip-parsers/filter'\n\n// A filter or condition with `{{path}}` slots only parses once each slot stands in for a value: a quoted one for a\n// word, any other for a number. Each slot's place in that text then finds it in the syntax tree.\n\n/** One `{{path}}` of a filter, where its stand-in starts, and whether it sits in quotes as a whole value. */\nexport type FilterSlot = { path: string; start: number; quoted: boolean }\n\nconst slotPattern = /([\"'])\\{\\{\\s*([^{}]*?)\\s*\\}\\}\\1|\\{\\{\\s*([^{}]*?)\\s*\\}\\}/g\n\n/** `source` with every slot replaced by a stand-in value, and the slots in order. */\nexport const sampleSlots = (source: string): { text: string; slots: FilterSlot[] } => {\n const slots: FilterSlot[] = []\n let text = ''\n let last = 0\n for (const match of source.matchAll(slotPattern)) {\n text += source.slice(last, match.index)\n const quoted = match[1] !== undefined\n slots.push({ path: (quoted ? match[2] : match[3])!, start: text.length, quoted })\n text += quoted ? `${match[1]}x${match[1]}` : '0'\n last = match.index + match[0].length\n }\n return { text: text + source.slice(last), slots }\n}\n\ntype Node = { kind: string; span?: { start: number }; [key: string]: unknown }\n\n// The conjuncts of the top level: `a AND b c` is three.\nconst conjuncts = (expr: Expr): Expr[] => (expr.kind === 'and' || expr.kind === 'sequence' ? expr.args.flatMap(conjuncts) : [expr])\n\nconst isLiteralAt = (node: Node, start: number) => (node.kind === 'string' || node.kind === 'number') && node.span?.start === start\n\n/**\n * The slots that are one side of a top-level AND equality with a field on the other, `field = {{path}}`, the one shape\n * a read can split per row without waiting for the rows it depends on; `undefined` when the filter does not parse.\n */\nexport const equalitySlots = (source: string): { slots: FilterSlot[]; split: Set<FilterSlot> } | undefined => {\n const { text, slots } = sampleSlots(source)\n const parsed = parseFilter(text)\n if (!parsed.ok) return\n const split = new Set<FilterSlot>()\n for (const conjunct of parsed.ast ? conjuncts(parsed.ast) : []) {\n if (conjunct.kind !== 'compare' || conjunct.op !== '=') continue\n const [left, right] = [conjunct.left as Node, conjunct.right as Node]\n for (const slot of slots) {\n if ((left.kind === 'member' && isLiteralAt(right, slot.start)) || (right.kind === 'member' && isLiteralAt(left, slot.start))) split.add(slot)\n }\n }\n return { slots, split }\n}\n","import { parseCondition } from './condition'\nimport { sampleSlots } from './filter-slots'\nimport type { LayoutNode } from './node'\n\n/** The conditions on a graph's edge, each evaluated per edge as the graph draws. */\nexport const edgeConditions = ['animated', 'dashed', 'dotted'] as const\n\nconst text = (value: unknown) => (typeof value === 'string' ? value : undefined)\n\n/** A condition on an edge: its `{{path}}`s are the scope's around the graph, filled before it draws; its fields the edge's. */\nexport const edgeCondition = (when: string) => parseCondition(sampleSlots(when).text)\n\n/** The fields of an edge a graph's conditions compare, which its read asks for. */\nexport const edgeConditionFields = (node: LayoutNode): string[] =>\n edgeConditions.flatMap((name) => {\n const when = text(node.props[name])\n const parsed = when === undefined ? undefined : edgeCondition(when)\n return parsed?.ok ? parsed.paths.map((path) => path.split('.')[0]!) : []\n })\n","import { edgeCondition, edgeConditions, evaluateCondition, scopeValue, type GraphProps, type ShapeEdge } from '@protobase/layout'\nimport type { BadgeTone, ViewModel } from '@protobase/schema'\nimport { valueColor, valueTone } from '../../../../live/value-color'\n\n/** How an edge draws: its line's colour, whether it moves, its dashes, and the text on its middle. */\nexport type EdgeLook = { stroke: string; animated: boolean; dash?: string; label?: string }\n\n// A line in the colour its value's badge has, the app's border colour without one\nconst toneStrokes: Record<BadgeTone, string> = {\n neutral: 'var(--color-border-strong)',\n blue: 'var(--color-primary)',\n green: 'var(--color-success)',\n amber: 'var(--color-warning)',\n red: 'var(--color-danger)',\n violet: 'var(--color-violet)',\n}\n\nconst dashes = { dashed: '6 4', dotted: '1.5 4' }\n\ntype Parsed = Partial<Record<(typeof edgeConditions)[number], ReturnType<typeof edgeCondition>>>\n\n/** The graph's conditions on an edge, parsed once: a condition that does not parse never holds. */\nexport const edgeConditionsOf = (props: Pick<GraphProps, (typeof edgeConditions)[number]>): Parsed =>\n Object.fromEntries(edgeConditions.flatMap((name) => (typeof props[name] === 'string' ? [[name, edgeCondition(props[name])]] : [])))\n\nconst holds = (parsed: ReturnType<typeof edgeCondition> | undefined, row: Record<string, unknown>) => {\n if (!parsed?.ok) return false\n const scope = { stack: [{ record: row }] }\n return evaluateCondition(parsed, Object.fromEntries(parsed.paths.map((path) => [path, scopeValue(scope, path)])))\n}\n\n/** How `edge` draws by the graph's `edgeStatus`, `edgeLabel` and conditions, its colours and value labels the edges view's. */\nexport const edgeLook = (edge: ShapeEdge, props: Pick<GraphProps, 'edgeLabel' | 'edgeStatus'>, conditions: Parsed, view: ViewModel | undefined): EdgeLook => {\n const status = props.edgeStatus\n const colors = status === undefined ? undefined : view?.fields[status]?.valueColors\n const value = status === undefined ? undefined : edge.row[status]\n const stroke = status === undefined || value == null ? toneStrokes.neutral : (valueColor(colors, value) ?? toneStrokes[valueTone(colors, value)])\n const dash = holds(conditions.dotted, edge.row) ? dashes.dotted : holds(conditions.dashed, edge.row) ? dashes.dashed : undefined\n const labelValue = props.edgeLabel === undefined ? undefined : edge.row[props.edgeLabel]\n const labels = props.edgeLabel === undefined ? undefined : view?.fields[props.edgeLabel]?.valueLabels\n const label = labelValue == null || labelValue === '' ? undefined : (labels?.[String(labelValue)] ?? String(labelValue))\n return { stroke, animated: holds(conditions.animated, edge.row), ...(dash && { dash }), ...(label !== undefined && { label }) }\n}\n","import type { ElkNode } from 'elkjs/lib/elk-api'\nimport type { GraphLayoutName, GraphShape } from '@protobase/layout'\n\n/** A node's size: room for its label on one or two lines and its status badge, the width a node's own contents get. */\nexport const nodeSize = { width: 200, height: 64 }\n\n/** The width of a node that draws contents of its own, whose height they decide. */\nexport const contentWidth = 224\n\n/** A box at its top-left corner, in the graph's own coordinates. */\nexport type Box = { x: number; y: number; width: number; height: number }\n\nexport type Size = { width: number; height: number }\n\n/** Where each group and node of a graph sits, each group a region around its nodes, and the size of the whole. */\nexport type GraphLayout = { groups: Map<string, Box>; nodes: Map<string, Box>; width: number; height: number }\n\n/** How a graph is laid out: its algorithm, which way a layered one runs, each node's size, and the nodes placed by their records. */\nexport type LayoutInput = { layout: GraphLayoutName; direction: 'down' | 'right'; sizes: ReadonlyMap<string, Size>; positions: ReadonlyMap<string, { x: number; y: number }> }\n\n// Room in a region around its nodes, more on top for its value\nconst padding = { top: 32, side: 16, bottom: 16 }\nconst elkPadding = `[top=${padding.top},left=${padding.side},bottom=${padding.bottom},right=${padding.side}]`\n\n// The space between the nodes the engine lays out and the ones placed above them\nconst placedGap = 48\n\nconst groupId = (id: string) => `group:${id}`\nconst nodeId = (id: string) => `node:${id}`\n\nconst algorithmOptions = (input: LayoutInput): Record<string, string> =>\n input.layout === 'force'\n ? // Its seed is fixed, so the same records always make the same picture\n { 'elk.algorithm': 'force', 'elk.randomSeed': '1', 'elk.spacing.nodeNode': '40' }\n : { 'elk.algorithm': 'layered', 'elk.direction': input.direction === 'right' ? 'RIGHT' : 'DOWN', 'elk.layered.spacing.nodeNodeBetweenLayers': '56', 'elk.spacing.nodeNode': '32' }\n\n/** The nodes the engine places: those without a position of their own. */\nconst unplaced = (shape: GraphShape, input: LayoutInput) => shape.nodes.filter((node) => !input.positions.has(node.id))\n\n/**\n * The graph ELK lays out: each node without a position as a box of its size, inside a box of its group, and each edge\n * between two of them. A layered graph lays its groups out with the rest (hierarchy INCLUDE_CHILDREN); a force one\n * lays each group out inside its box, then the boxes as nodes. `undefined` when every node has a position.\n */\nexport const graphElk = (shape: GraphShape, input: LayoutInput): ElkNode | undefined => {\n const nodes = unplaced(shape, input)\n if (nodes.length === 0) return undefined\n const options = algorithmOptions(input)\n const box = (id: string): ElkNode => ({ id: nodeId(id), ...(input.sizes.get(id) ?? nodeSize) })\n const groups = shape.groups.flatMap((group): ElkNode[] => {\n const members = nodes.filter((node) => node.group === group.id)\n return members.length === 0 ? [] : [{ id: groupId(group.id), layoutOptions: { ...options, 'elk.padding': elkPadding }, children: members.map((node) => box(node.id)) }]\n })\n const loose = nodes.filter((node) => node.group === undefined).map((node) => box(node.id))\n const laid = new Set(nodes.map((node) => node.id))\n const edges = shape.edges.filter((edge) => laid.has(edge.source) && laid.has(edge.target) && edge.source !== edge.target).map((edge) => ({ id: `edge:${edge.id}`, sources: [nodeId(edge.source)], targets: [nodeId(edge.target)] }))\n return { id: 'root', layoutOptions: { ...options, ...(input.layout === 'layered' && { 'elk.hierarchyHandling': 'INCLUDE_CHILDREN' }) }, children: [...groups, ...loose], edges }\n}\n\nconst boundsOf = (boxes: Box[]): Box | undefined => {\n if (boxes.length === 0) return undefined\n const x = Math.min(...boxes.map((box) => box.x))\n const y = Math.min(...boxes.map((box) => box.y))\n return { x, y, width: Math.max(...boxes.map((box) => box.x + box.width)) - x, height: Math.max(...boxes.map((box) => box.y + box.height)) - y }\n}\n\n/**\n * Where everything sits: each placed node at its position, the nodes the engine laid out (`laidOut`, from `graphElk`)\n * under them, each group a region around its nodes, the whole moved so it starts at 0, 0.\n */\nexport const placeGraph = (shape: GraphShape, input: LayoutInput, laidOut?: ElkNode): GraphLayout => {\n const placed = new Map<string, Box>()\n for (const node of shape.nodes) {\n const position = input.positions.get(node.id)\n if (position) placed.set(node.id, { ...position, ...(input.sizes.get(node.id) ?? nodeSize) })\n }\n // ELK gives each child its place inside its parent\n const engine = new Map<string, Box>()\n const visit = (parent: ElkNode, x: number, y: number) => {\n for (const child of parent.children ?? []) {\n const at = { x: x + (child.x ?? 0), y: y + (child.y ?? 0) }\n if (child.id.startsWith('node:')) engine.set(child.id.slice('node:'.length), { ...at, width: child.width ?? nodeSize.width, height: child.height ?? nodeSize.height })\n else visit(child, at.x, at.y)\n }\n }\n if (laidOut) visit(laidOut, 0, 0)\n const above = boundsOf([...placed.values()])\n const below = boundsOf([...engine.values()])\n const shift = above && below ? { x: above.x - below.x, y: above.y + above.height + placedGap - below.y } : { x: 0, y: 0 }\n for (const [id, box] of engine) placed.set(id, { ...box, x: box.x + shift.x, y: box.y + shift.y })\n const groups = new Map<string, Box>()\n for (const group of shape.groups) {\n const members = boundsOf(shape.nodes.filter((node) => node.group === group.id && placed.has(node.id)).map((node) => placed.get(node.id)!))\n if (members) groups.set(group.id, { x: members.x - padding.side, y: members.y - padding.top, width: members.width + 2 * padding.side, height: members.height + padding.top + padding.bottom })\n }\n const whole = boundsOf([...placed.values(), ...groups.values()]) ?? { x: 0, y: 0, width: 0, height: 0 }\n const moved = (box: Box): Box => ({ ...box, x: box.x - whole.x, y: box.y - whole.y })\n return {\n nodes: new Map([...placed].map(([id, box]) => [id, moved(box)])),\n groups: new Map([...groups].map(([id, box]) => [id, moved(box)])),\n width: whole.width,\n height: whole.height,\n }\n}\n","import type { GraphFields } from '@protobase/layout'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { Handle, Position, type Node, type NodeProps } from '@xyflow/react'\nimport type { ReactNode } from 'react'\nimport { RouteLink, type RouteTarget } from '../../../../primitives/route-link'\nimport { FieldBadge } from '../../../field-badge'\nimport { ToneEdge } from '../../../related-cards/tone-edge'\nimport { RecordScope } from '../../record-scope'\nimport { scopeOf } from '../../use-layout-data'\n\ntype Drawn = { model: ResourceModel; view: ViewModel | undefined; fields: GraphFields }\n\n/** Which sides a node's edges meet it on: the top and bottom for a graph that runs down, else the left and right. */\nexport type Sides = 'vertical' | 'horizontal'\n\n/**\n * A node as it draws: its record, what the graph draws in each node, the link that chooses it when the graph has\n * `select`, whether it is chosen, and which sides its edges meet.\n */\nexport type RecordNodeData = Drawn & { row: Record<string, unknown>; content?: ReactNode; to?: RouteTarget; chosen: boolean; sides: Sides }\n\n/** A group as it draws: the record of one of its nodes, whose `group` value it shows. */\nexport type GroupNodeData = Drawn & { row: Record<string, unknown> }\n\n// The handles take no part in the drawing, since the graph cannot be edited\nconst handle = 'pointer-events-none !min-h-0 !min-w-0 !border-0 !bg-transparent'\n\nconst Handles = ({ sides }: { sides: Sides }) => (\n <>\n <Handle type=\"target\" position={sides === 'vertical' ? Position.Top : Position.Left} isConnectable={false} className={handle} />\n <Handle type=\"source\" position={sides === 'vertical' ? Position.Bottom : Position.Right} isConnectable={false} className={handle} />\n </>\n)\n\nconst frame = (chosen: boolean) => `relative rounded-lg border bg-surface text-body ${chosen ? 'border-primary ring-2 ring-primary/40' : 'border-border'}`\n\n/**\n * A node: with contents of the graph's own, those, drawn inside its record, the whole node a link that chooses it; else\n * its label, linking to the page with it chosen, over its status badge. Its status colours its left edge.\n */\nexport const RecordNode = ({ data }: NodeProps<Node<RecordNodeData, 'record'>>) => {\n const { model, view, fields, row, content, to, chosen, sides } = data\n const label = String(row[fields.label] ?? '')\n const edge = fields.status && <ToneEdge view={view} field={fields.status} record={row} />\n if (content !== undefined) {\n return (\n <div data-chosen={chosen || undefined} className={`${frame(chosen)} flex w-full flex-col gap-1 px-3 py-2`}>\n <Handles sides={sides} />\n {edge}\n {/* A link over the whole node chooses it, under the contents, whose own links stay theirs; React Flow turns\n pointer events off on a node that cannot be dragged or selected, so each takes them back */}\n {to && <RouteLink to={to} aria-label={label} aria-current={chosen || undefined} className=\"pointer-events-auto absolute inset-0 rounded-lg hover:bg-muted/40\" />}\n <div className=\"relative min-w-0 [overflow-wrap:anywhere] [&_a]:pointer-events-auto\">\n <RecordScope value={scopeOf(model, row)}>{content}</RecordScope>\n </div>\n </div>\n )\n }\n return (\n <div data-chosen={chosen || undefined} className={`${frame(chosen)} flex size-full flex-col justify-center gap-1 px-3 py-2`}>\n <Handles sides={sides} />\n {edge}\n {to ? (\n <RouteLink to={to} aria-current={chosen || undefined} className=\"pointer-events-auto line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere] text-primary-text hover:underline\">\n {label}\n </RouteLink>\n ) : (\n <span className=\"line-clamp-2 min-w-0 font-medium [overflow-wrap:anywhere]\">{label}</span>\n )}\n {fields.status && (\n <div className=\"flex\">\n <FieldBadge model={model} view={view} field={fields.status} record={row} />\n </div>\n )}\n </div>\n )\n}\n\n/** A group: a region around its nodes, its `group` value at its top. */\nexport const GroupNode = ({ data }: NodeProps<Node<GroupNodeData, 'group-box'>>) => (\n <div className=\"size-full rounded-xl border border-dashed border-border-strong bg-muted/40\">\n {data.fields.group && (\n <div className=\"flex px-2 pt-1 text-xs\">\n <FieldBadge model={data.model} view={data.view} field={data.fields.group} record={data.row} />\n </div>\n )}\n </div>\n)\n","import { useEffect, useMemo, useState } from 'react'\nimport type { GraphShape } from '@protobase/layout'\nimport { useElk } from '../../../../lib/elk/use-elk'\nimport { graphElk, placeGraph, type GraphLayout, type LayoutInput } from './graph-layout'\n\n/**\n * Where the graph's groups and nodes sit, laid out again when its nodes, edges, sizes or positions change; undefined\n * until the first layout is done. A layout that a newer one overtook is dropped. Without a node to lay out, the engine\n * is never asked. A layout that fails throws, for the block's fallback or the page's error boundary to draw.\n */\nexport const useGraphLayout = (shape: GraphShape, input: LayoutInput): GraphLayout | undefined => {\n const elk = graphElk(shape, input)\n const engine = useElk()\n // One text for what the layout is made from, so a new shape of the same records lays nothing out again\n const signature = JSON.stringify([elk, shape.nodes.map((node) => node.id), shape.groups.map((group) => group.id), [...input.positions], [...input.sizes]])\n const placedOnly = useMemo(() => (elk ? undefined : placeGraph(shape, input)), [signature])\n const [laidOut, setLaidOut] = useState<{ signature: string; layout: GraphLayout }>()\n const [failure, setFailure] = useState<Error>()\n useEffect(() => {\n if (!engine || !elk) return\n let current = true\n engine.layout(elk).then(\n (result) => {\n if (current) setLaidOut({ signature, layout: placeGraph(shape, input, result) })\n },\n (error: unknown) => {\n if (current) setFailure(error instanceof Error ? error : new Error(String(error)))\n },\n )\n return () => {\n current = false\n }\n }, [engine, signature])\n // A layout that failed, such as a worker that cannot load, draws the graph's fallback or its error, not a blank box\n if (failure) throw failure\n if (placedOnly) return placedOnly\n // The last layout stands while the next one is made, so a live update does not blank the graph\n return laidOut?.layout\n}\n","import { Controls, MarkerType, ReactFlow, ReactFlowProvider, useReactFlow, type Edge, type Node, type NodeChange } from '@xyflow/react'\nimport type { GraphFields, GraphProps, GraphShape } from '@protobase/layout'\nimport { useEffect, useMemo, useState, type CSSProperties, type ReactNode } from 'react'\nimport type { ComponentRead, ComponentSelect } from '../../component-reads'\nimport { edgeConditionsOf, edgeLook } from './graph-edges'\nimport { contentWidth, nodeSize, type GraphLayout, type Size } from './graph-layout'\nimport { GroupNode, RecordNode, type GroupNodeData, type RecordNodeData, type Sides } from './graph-nodes'\nimport { useGraphLayout } from './use-graph-layout'\nimport '@xyflow/react/dist/style.css'\n\nconst nodeTypes = { record: RecordNode, 'group-box': GroupNode }\n\n// The box's height follows the graph's shape at the box's width, within bounds, so the page scrolls past it\nconst minHeight = 256\nconst maxHeight = 'min(40rem, 70vh)'\n\n// A graph wider than the box, as on a phone, stays readable and pans; the fit button shows all of it\nconst fitViewOptions = { minZoom: 0.6, maxZoom: 1 }\n\n// The library's lines and controls in the app's tokens, over the page's own background: the variables it reads over\n// its own defaults\nconst themed = {\n '--xy-edge-stroke': 'var(--color-border-strong)',\n '--xy-edge-stroke-width': '1.5',\n '--xy-background-color': 'transparent',\n '--xy-edge-label-background-color': 'var(--color-surface)',\n '--xy-edge-label-color': 'var(--color-muted-foreground)',\n '--xy-controls-button-background-color': 'var(--color-surface)',\n '--xy-controls-button-background-color-hover': 'var(--color-muted)',\n '--xy-controls-button-color': 'var(--color-foreground)',\n '--xy-controls-button-color-hover': 'var(--color-foreground)',\n '--xy-controls-button-border-color': 'var(--color-border)',\n '--xy-attribution-background-color': 'transparent',\n} as CSSProperties\n\nexport type GraphViewProps = {\n shape: GraphShape\n nodes: Pick<ComponentRead, 'model' | 'view'>\n edges: Pick<ComponentRead, 'model' | 'view'>\n fields: GraphFields\n props: Pick<GraphProps, 'layout' | 'direction' | 'x' | 'y' | 'edgeLabel' | 'edgeStatus' | 'animated' | 'dashed' | 'dotted'>\n select?: ComponentSelect\n /** What each node draws, inside its record, the graph's `node`; its label and status without it. */\n content?: ReactNode\n}\n\nconst number = (value: unknown) => (typeof value === 'number' && Number.isFinite(value) ? value : typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)) ? Number(value) : undefined)\n\n// The nodes React Flow draws: each group's region under the nodes, each node at its box, one with contents of its own\n// as wide as they are given and as tall as they draw, which it measures\nconst flowNodes = ({ shape, nodes: read, fields, select, content }: GraphViewProps, layout: GraphLayout | undefined, sides: Sides): Node[] => {\n const drawn = { model: read.model, view: read.view, fields }\n const groups = shape.groups.flatMap((group): Node<GroupNodeData>[] => {\n const box = layout?.groups.get(group.id)\n const row = shape.nodes.find((node) => node.group === group.id)!.row\n return box ? [{ id: `group:${group.id}`, type: 'group-box', position: { x: box.x, y: box.y }, width: box.width, height: box.height, zIndex: -1, data: { ...drawn, row }, draggable: false, selectable: false, focusable: false }] : []\n })\n const nodes = shape.nodes.map((node): Node<RecordNodeData> => {\n const box = layout?.nodes.get(node.id)\n const chosen = select?.chosen === node.id\n return {\n id: `node:${node.id}`,\n type: 'record',\n position: box ? { x: box.x, y: box.y } : { x: 0, y: 0 },\n ...(content === undefined ? { width: nodeSize.width, height: nodeSize.height } : { style: { width: contentWidth } }),\n data: { ...drawn, row: node.row, chosen, sides, ...(content !== undefined && { content }), ...(select && { to: select.linkTo(node.id) }) },\n draggable: false,\n selectable: false,\n }\n })\n return [...groups, ...nodes]\n}\n\nconst flowEdges = ({ shape, edges: read, props }: GraphViewProps, straight: boolean): Edge[] => {\n const conditions = edgeConditionsOf(props)\n return shape.edges.map((edge) => {\n const look = edgeLook(edge, props, conditions, read.view)\n return {\n id: `edge:${edge.id}`,\n source: `node:${edge.source}`,\n target: `node:${edge.target}`,\n ...(straight && { type: 'straight' }),\n markerEnd: { type: MarkerType.ArrowClosed, color: look.stroke },\n style: { stroke: look.stroke, ...(look.dash && { strokeDasharray: look.dash }) },\n animated: look.animated,\n ...(look.label !== undefined && { label: look.label, labelBgPadding: [4, 2] as [number, number], labelBgBorderRadius: 4 }),\n focusable: false,\n selectable: false,\n }\n })\n}\n\n// Fits the graph to its box each time it is laid out anew, as its first fit does, a frame later, once the nodes stand\n// where the layout put them\nconst FitOnLayout = ({ layout }: { layout: GraphLayout | undefined }) => {\n const flow = useReactFlow()\n useEffect(() => {\n if (!layout) return\n const frame = requestAnimationFrame(() => void flow.fitView(fitViewOptions))\n return () => cancelAnimationFrame(frame)\n }, [flow, layout])\n return null\n}\n\nconst Flow = (props: GraphViewProps) => {\n const { shape, content } = props\n const [measured, setMeasured] = useState<ReadonlyMap<string, Size>>(new Map())\n const sizes = useMemo(() => new Map(shape.nodes.map((node) => [node.id, content === undefined ? nodeSize : { width: contentWidth, height: measured.get(node.id)?.height ?? nodeSize.height }])), [shape, content, measured])\n const positions = useMemo(() => {\n const { x, y } = props.props\n if (x === undefined || y === undefined) return new Map<string, { x: number; y: number }>()\n return new Map(shape.nodes.flatMap((node) => {\n const at = { x: number(node.row[x]), y: number(node.row[y]) }\n return at.x === undefined || at.y === undefined ? [] : [[node.id, at as { x: number; y: number }]]\n }))\n }, [shape, props.props.x, props.props.y])\n const layoutName = props.props.layout ?? 'layered'\n const direction = props.props.direction ?? 'down'\n const layout = useGraphLayout(shape, { layout: layoutName, direction, sizes, positions })\n // A node with contents of its own is laid out at the height it draws at, so until each has drawn once the graph is\n // see-through: React Flow shows each node itself, so hiding the box would not hide them\n const ready = layout !== undefined && (content === undefined || shape.nodes.every((node) => measured.has(node.id)))\n const sides: Sides = layoutName === 'layered' && direction === 'right' ? 'horizontal' : 'vertical'\n const nodes = flowNodes(props, layout, sides)\n const edges = useMemo(() => flowEdges(props, layoutName === 'force'), [shape, props.edges.view, props.props, layoutName])\n const measure = (changes: NodeChange[]) => {\n const heights = changes.flatMap((change) => (change.type === 'dimensions' && change.dimensions && change.id.startsWith('node:') ? [[change.id.slice('node:'.length), change.dimensions] as const] : []))\n if (heights.length === 0) return\n setMeasured((before) => {\n const next = new Map(before)\n for (const [id, size] of heights) next.set(id, { width: Math.round(size.width), height: Math.round(size.height) })\n const same = next.size === before.size && [...next].every(([id, size]) => before.get(id)?.height === size.height)\n return same ? before : next\n })\n }\n return (\n <div className=\"w-full\" style={{ ...themed, aspectRatio: layout ? `${Math.max(layout.width, 1)} / ${Math.max(layout.height, 1)}` : undefined, minHeight, maxHeight, ...(!ready && { opacity: 0 }) }}>\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={content === undefined ? undefined : measure}\n fitView\n fitViewOptions={fitViewOptions}\n minZoom={0.1}\n nodesDraggable={false}\n nodesConnectable={false}\n elementsSelectable={false}\n edgesFocusable={false}\n zoomOnScroll={false}\n zoomOnDoubleClick={false}\n preventScrolling={false}\n zoomOnPinch\n panOnDrag\n >\n <FitOnLayout layout={ready ? layout : undefined} />\n <Controls showInteractive={false} />\n </ReactFlow>\n </div>\n )\n}\n\n/**\n * The graph in a box as wide as the page and as tall as its shape asks, within bounds, fitted to it unless that would\n * shrink it past reading: pinch or the zoom buttons zoom it, dragging pans it, and the wheel scrolls the page past it.\n * Read-only: nothing moves, connects or is deleted.\n */\nexport const GraphView = (props: GraphViewProps) => (\n <ReactFlowProvider>\n <Flow {...props} />\n </ReactFlowProvider>\n)\n"],"mappings":"g6BAQA,IAAM8B,EAAc,2DAGPC,EAAe,GAA0D,CACpF,IAAMC,EAAsB,CAAC,EACzBC,EAAO,GACPC,EAAO,EACX,IAAK,IAAMC,KAASC,EAAO,SAASN,CAAW,EAAG,CAChD,GAAQM,EAAO,MAAMF,EAAMC,EAAM,KAAK,EACtC,IAAME,EAASF,EAAM,KAAO,IAAA,GAC5BH,EAAM,KAAK,CAAE,KAAOK,EAASF,EAAM,GAAKA,EAAM,GAAM,MAAOF,EAAK,OAAQ,QAAO,CAAC,EAChF,GAAQI,EAAS,GAAGF,EAAM,GAAG,GAAGA,EAAM,KAAO,IAC7C,EAAOA,EAAM,MAAQA,EAAM,EAAE,CAAC,MAChC,CACA,MAAO,CAAE,KAAMF,EAAOG,EAAO,MAAMF,CAAI,EAAG,OAAM,CAClD,EClBaI,EAAiB,CAAC,WAAY,SAAU,QAAQ,EAKhDC,EAAiB,GAAiB1B,EAAekB,EAAYS,CAAI,CAAC,CAAC,IAAI,aCF9EE,EAAyC,CAC7C,QAAS,6BACT,KAAM,uBACN,MAAO,uBACP,MAAO,uBACP,I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GAAG2B,EAAQ,YAAaK,EAAS,GAAG,KAAK,IAAIA,EAAO,MAAO,CAAC,EAAE,KAAK,KAAK,IAAIA,EAAO,OAAQ,CAAC,IAAM,IAAA,GAAW,YAAW,YAAW,GAAI,CAACc,GAAS,CAAE,QAAS,CAAE,CAAG,EAChM,UAAA,EAAA9C,EAAA,KAAA,CAACnG,EAAD,CACS,QACA,QACI,YACX,cAAe4G,IAAY,IAAA,GAAY,IAAA,GAAYsC,EACnD,QAAA,GACgB,iBAChB,QAAS,GACT,eAAgB,GAChB,iBAAkB,GAClB,mBAAoB,GACpB,eAAgB,GAChB,aAAc,GACd,kBAAmB,GACnB,iBAAkB,GAClB,YAAA,GACA,UAAA,GAhBF,SAAA,EAkBE,EAAA/C,EAAA,IAAA,CAACqC,GAAD,CAAa,OAAQS,EAAQd,EAAS,IAAA,EAAY,CAAA,GAClD,EAAAhC,EAAA,IAAA,CAAC9E,EAAD,CAAU,gBAAiB,EAAQ,CAAA,CAC1B,GACR,CAAA,CAET,EAOaoI,GAAa,IACxB,EAAAtD,EAAA,IAAA,CAAClF,EAAD,CAAA,UACE,EAAAkF,EAAA,IAAA,CAACuC,GAAD,CAAM,GAAIlG,CAAQ,CAAA,CACD,CAAA","debugId":"84a37136-6b34-485f-808e-6d2afe8bdb4a"}
@@ -1 +1 @@
1
- {"version":3,"file":"html-viewer-C_AC-COH.js","names":["useCallback","n","a","t","__toESM","require_react","require_jsx_runtime","useAppAddress","PageSkeleton","useViewedResource","HtmlFrame","useFileText","useSiblingPage","import_react","openTab","url","useFrameLinks","resource","fileAddress","file","link","href","to","newTab","go","import_jsx_runtime","HtmlViewer","read","page","siblings","address","follow"],"sources":["../../../src/app/file-viewers/use-frame-links.ts","../../../src/app/file-viewers/html-viewer.tsx"],"sourcesContent":["import { useCallback } from 'react'\nimport { useAppAddress } from '../use-app-address'\nimport type { SiblingFile } from './file-viewer'\nimport type { FrameLink } from './sibling-page'\nimport { useViewedResource } from './viewed-resource'\n\nconst openTab = (url: string) => window.open(url, '_blank', 'noopener,noreferrer')\n\n/**\n * The links of a sibling page in a file viewer. A sibling opens on its record's address with `?file=<field>`, which its\n * link shows, in this tab or a new one: in its viewer, or beside its download when it has none. An outside address\n * opens in a new tab that cannot reach back to the app.\n */\nexport const useFrameLinks = () => {\n const resource = useViewedResource()\n const { go, href } = useAppAddress()\n\n const fileAddress = useCallback((file: SiblingFile) => ({ kind: 'record', resource, key: file.key, file: file.field }) as const, [resource])\n\n const address = useCallback(\n (link: FrameLink<SiblingFile>) => (link.kind === 'external' ? link.url : new URL(href(fileAddress(link.file)), window.location.href).href),\n [fileAddress, href],\n )\n\n const follow = useCallback(\n (link: FrameLink<SiblingFile>, { newTab }: { newTab: boolean }) => {\n if (link.kind === 'external') {\n openTab(link.url)\n return\n }\n const to = fileAddress(link.file)\n if (newTab) {\n openTab(href(to))\n return\n }\n go(to)\n },\n [fileAddress, go, href],\n )\n\n return { address, follow }\n}\n","import { PageSkeleton } from './page-skeleton'\nimport type { FileViewerProps } from './file-viewer'\nimport { HtmlFrame } from './html-frame'\nimport { useFileText } from './use-file-text'\nimport { useFrameLinks } from './use-frame-links'\nimport { useSiblingPage } from './use-sibling-page'\n\n/**\n * Protobase's viewer for HTML files: the page in an `HtmlFrame` that runs none of its scripts, with its images, videos\n * and links resolved to its siblings. A file it cannot read throws, so the viewer page offers the download instead.\n */\nexport const HtmlViewer = ({ file, siblings }: FileViewerProps) => {\n const read = useFileText(file)\n const { address, follow } = useFrameLinks()\n const page = useSiblingPage(read.data, siblings, address)\n if (read.error) throw read.error\n if (!page) return <PageSkeleton name={file.name} />\n return <HtmlFrame html={page.html} title={file.name} links={page.links} onLink={follow} />\n}\n"],"mappings":"0uBAMMc,EAAW,GAAgB,OAAO,KAAKC,EAAK,SAAU,qBAAqB,EAOpEC,MAAsB,CACjC,IAAMC,EAAWR,EAAkB,EAC7B,CAAE,KAAI,QAASF,EAAc,EAE7BW,GAAA,EAAclB,EAAAA,YAAAA,CAAa,IAAuB,CAAE,KAAM,SAAU,WAAU,IAAKmB,EAAK,IAAK,KAAMA,EAAK,KAAM,GAAa,CAACF,CAAQ,CAAC,EAuB3I,MAAO,CAAE,SAAA,EArBOjB,EAAAA,YAAAA,CACb,GAAkCoB,EAAK,OAAS,WAAaA,EAAK,IAAM,IAAI,IAAIC,EAAKH,EAAYE,EAAK,IAAI,CAAC,EAAG,OAAO,SAAS,IAAI,CAAC,CAAC,KACrI,CAACF,EAAaG,CAAI,CAmBX,EAAS,QAAA,EAhBHrB,EAAAA,YAAAA,EACZ,EAA8B,CAAE,YAAkC,CACjE,GAAIoB,EAAK,OAAS,WAAY,CAC5BN,EAAQM,EAAK,GAAG,EAChB,MACF,CACA,IAAME,EAAKJ,EAAYE,EAAK,IAAI,EAChC,GAAIG,EAAQ,CACVT,EAAQO,EAAKC,CAAE,CAAC,EAChB,MACF,CACAE,EAAGF,CAAE,CACP,EACA,CAACJ,EAAaM,EAAIH,CAAI,CAGN,CAAO,CAC3B,aC9BaK,GAAc,CAAE,OAAM,cAAgC,CACjE,IAAMC,EAAOhB,EAAYQ,CAAI,EACvB,CAAE,UAAS,UAAWH,EAAc,EACpCY,EAAOhB,EAAee,EAAK,KAAME,EAAUC,CAAO,EACxD,GAAIH,EAAK,MAAO,MAAMA,EAAK,MAE3B,OADKC,GACE,EAAAH,EAAA,IAAA,CAACf,EAAD,CAAW,KAAMkB,EAAK,KAAM,MAAOT,EAAK,KAAM,MAAOS,EAAK,MAAO,OAAQG,CAAS,CAAA,GADvE,EAAAN,EAAA,IAAA,CAACjB,EAAD,CAAc,KAAMW,EAAK,IAAO,CAAA,CAEpD","debugId":"bf002f82-3873-4cce-9e4e-89c4c04d0447"}
1
+ {"version":3,"file":"html-viewer-kitQumwS.js","names":["useCallback","n","a","t","__toESM","require_react","require_jsx_runtime","useAppAddress","PageSkeleton","useViewedResource","HtmlFrame","useFileText","useSiblingPage","import_react","openTab","url","useFrameLinks","resource","fileAddress","file","link","href","to","newTab","go","import_jsx_runtime","HtmlViewer","read","page","siblings","address","follow"],"sources":["../../../src/app/file-viewers/use-frame-links.ts","../../../src/app/file-viewers/html-viewer.tsx"],"sourcesContent":["import { useCallback } from 'react'\nimport { useAppAddress } from '../use-app-address'\nimport type { SiblingFile } from './file-viewer'\nimport type { FrameLink } from './sibling-page'\nimport { useViewedResource } from './viewed-resource'\n\nconst openTab = (url: string) => window.open(url, '_blank', 'noopener,noreferrer')\n\n/**\n * The links of a sibling page in a file viewer. A sibling opens on its record's address with `?file=<field>`, which its\n * link shows, in this tab or a new one: in its viewer, or beside its download when it has none. An outside address\n * opens in a new tab that cannot reach back to the app.\n */\nexport const useFrameLinks = () => {\n const resource = useViewedResource()\n const { go, href } = useAppAddress()\n\n const fileAddress = useCallback((file: SiblingFile) => ({ kind: 'record', resource, key: file.key, file: file.field }) as const, [resource])\n\n const address = useCallback(\n (link: FrameLink<SiblingFile>) => (link.kind === 'external' ? link.url : new URL(href(fileAddress(link.file)), window.location.href).href),\n [fileAddress, href],\n )\n\n const follow = useCallback(\n (link: FrameLink<SiblingFile>, { newTab }: { newTab: boolean }) => {\n if (link.kind === 'external') {\n openTab(link.url)\n return\n }\n const to = fileAddress(link.file)\n if (newTab) {\n openTab(href(to))\n return\n }\n go(to)\n },\n [fileAddress, go, href],\n )\n\n return { address, follow }\n}\n","import { PageSkeleton } from './page-skeleton'\nimport type { FileViewerProps } from './file-viewer'\nimport { HtmlFrame } from './html-frame'\nimport { useFileText } from './use-file-text'\nimport { useFrameLinks } from './use-frame-links'\nimport { useSiblingPage } from './use-sibling-page'\n\n/**\n * Protobase's viewer for HTML files: the page in an `HtmlFrame` that runs none of its scripts, with its images, videos\n * and links resolved to its siblings. A file it cannot read throws, so the viewer page offers the download instead.\n */\nexport const HtmlViewer = ({ file, siblings }: FileViewerProps) => {\n const read = useFileText(file)\n const { address, follow } = useFrameLinks()\n const page = useSiblingPage(read.data, siblings, address)\n if (read.error) throw read.error\n if (!page) return <PageSkeleton name={file.name} />\n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CAAA,CAEpD","debugId":"248ad42e-9b04-41f5-be0e-cc39491b11b7"}
@@ -1 +1 @@
1
- {"version":3,"file":"in-place-form-BE0jeXxK.js","names":["n","a","t","__toESM","Button","ErrorBanner","Field","text","import_jsx_runtime","require_jsx_runtime","InPlaceForm","shown","form","section","fields","field","event","onSubmit","children","submit"],"sources":["../../../src/app/create/in-place-form.tsx"],"sourcesContent":["import type { FormEvent, ReactNode } from 'react'\nimport { Field } from '../../record-view/field'\nimport { Button } from '../../primitives/button'\nimport { ErrorBanner } from '../error-banner'\nimport type { CreateForm } from './use-create-form'\nimport { text } from './messages'\n\nexport type InPlaceFormProps = {\n form: CreateForm\n /** The fields to show, by name, of the form's; the others keep what the form was given. */\n fields: readonly string[]\n /** The submit button's label. */\n submit: string\n /** The submit button cannot be pressed. */\n disabled?: boolean\n /** Sends the form; `form.submit()` when omitted. */\n onSubmit?: () => void\n /** What the form says above its fields, or inputs of the caller's own. */\n children?: ReactNode\n}\n\n/**\n * A create form that stays where it is, for a focus page's panel or a dialog: the named fields of `useCreateForm`, its\n * failure and its submit button, so an action is done beside what it acts on, with no page of its own. `onCreated`\n * says what comes next.\n */\nexport const InPlaceForm = ({ form, fields, submit, disabled, onSubmit, children }: InPlaceFormProps) => {\n const shown = form.sections.flatMap((section) => section.fields).filter((field) => fields.includes(field.name))\n const send = (event: FormEvent) => {\n event.preventDefault()\n if (onSubmit) onSubmit()\n else void form.submit()\n }\n return (\n <form ref={form.ref} className=\"flex flex-col gap-4\" onSubmit={send}>\n {form.message && <ErrorBanner title={text('notCreated')} error={new Error(form.message)} />}\n {children}\n {shown.map((field) => (\n <Field key={field.name} name={field.name} label={field.label} required={field.required} help={field.help} error={field.error} wide={field.wide}>\n {field.editor}\n </Field>\n ))}\n <Button variant=\"primary\" type=\"submit\" className=\"max-md:min-h-11\" loading={form.saving} disabled={disabled}>\n {submit}\n </Button>\n </form>\n )\n}\n"],"mappings":"kqBA0BaU,GAAe,CAAE,OAAM,SAAQ,SAAQ,WAAU,WAAU,cAAiC,CACvG,IAAMC,EAAQC,EAAK,SAAS,QAAS,GAAYC,EAAQ,MAAM,CAAC,CAAC,OAAQ,GAAUC,EAAO,SAASC,EAAM,IAAI,CAAC,EAM9G,OACE,EAAAP,EAAA,KAAA,CAAC,OAAD,CAAM,IAAKI,EAAK,IAAK,UAAU,sBAAsB,SANzC,GAAqB,CACjCI,EAAM,eAAe,EACjBC,EAAUA,EAAS,EAClBL,EAAU,OAAO,CACxB,EAEE,SAAA,CACGA,EAAK,UAAW,EAAAJ,EAAA,IAAA,CAACH,EAAD,CAAa,MAAOE,EAAK,YAAY,EAAG,MAAW,MAAMK,EAAK,OAAO,CAAI,CAAA,EACzFM,EACAP,EAAM,IAAK,IACV,EAAAH,EAAA,IAAA,CAACF,EAAD,CAAwB,KAAMS,EAAM,KAAM,MAAOA,EAAM,MAAO,SAAUA,EAAM,SAAU,KAAMA,EAAM,KAAM,MAAOA,EAAM,MAAO,KAAMA,EAAM,KACvI,SAAAA,EAAM,MACF,EAFKA,EAAM,IAEX,CACR,GACD,EAAAP,EAAA,IAAA,CAACJ,EAAD,CAAQ,QAAQ,UAAU,KAAK,SAAS,UAAU,kBAAkB,QAASQ,EAAK,OAAkB,WACjG,SAAAO,CACK,CAAA,CACJ,GAEV","debugId":"44d23797-c4ae-477c-9572-f9c033efe366"}
1
+ {"version":3,"file":"in-place-form-DkBB2sDN.js","names":["n","a","t","__toESM","Button","ErrorBanner","Field","text","import_jsx_runtime","require_jsx_runtime","InPlaceForm","shown","form","section","fields","field","event","onSubmit","children","submit"],"sources":["../../../src/app/create/in-place-form.tsx"],"sourcesContent":["import type { FormEvent, ReactNode } from 'react'\nimport { Field } from '../../record-view/field'\nimport { Button } from '../../primitives/button'\nimport { ErrorBanner } from '../error-banner'\nimport type { CreateForm } from './use-create-form'\nimport { text } from './messages'\n\nexport type InPlaceFormProps = {\n form: CreateForm\n /** The fields to show, by name, of the form's; the others keep what the form was given. */\n fields: readonly string[]\n /** The submit button's label. */\n submit: string\n /** The submit button cannot be pressed. */\n disabled?: boolean\n /** Sends the form; `form.submit()` when omitted. */\n onSubmit?: () => void\n /** What the form says above its fields, or inputs of the caller's own. */\n children?: ReactNode\n}\n\n/**\n * A create form that stays where it is, for a focus page's panel or a dialog: the named fields of `useCreateForm`, its\n * failure and its submit button, so an action is done beside what it acts on, with no page of its own. `onCreated`\n * says what comes next.\n */\nexport const InPlaceForm = ({ form, fields, submit, disabled, onSubmit, children }: InPlaceFormProps) => {\n const shown = form.sections.flatMap((section) => section.fields).filter((field) => fields.includes(field.name))\n const send = (event: FormEvent) => {\n event.preventDefault()\n if (onSubmit) onSubmit()\n else void form.submit()\n }\n return (\n <form ref={form.ref} className=\"flex flex-col gap-4\" onSubmit={send}>\n {form.message && <ErrorBanner title={text('notCreated')} error={new Error(form.message)} />}\n {children}\n {shown.map((field) => (\n <Field key={field.name} name={field.name} label={field.label} required={field.required} help={field.help} error={field.error} wide={field.wide}>\n {field.editor}\n </Field>\n ))}\n <Button variant=\"primary\" type=\"submit\" className=\"max-md:min-h-11\" loading={form.saving} disabled={disabled}>\n {submit}\n </Button>\n </form>\n )\n}\n"],"mappings":"kqBA0BaU,GAAe,CAAE,OAAM,SAAQ,SAAQ,WAAU,WAAU,cAAiC,CACvG,IAAMC,EAAQC,EAAK,SAAS,QAAS,GAAYC,EAAQ,MAAM,CAAC,CAAC,OAAQ,GAAUC,EAAO,SAASC,EAAM,IAAI,CAAC,EAM9G,OACE,EAAAP,EAAA,KAAA,CAAC,OAAD,CAAM,IAAKI,EAAK,IAAK,UAAU,sBAAsB,SANzC,GAAqB,CACjCI,EAAM,eAAe,EACjBC,EAAUA,EAAS,EAClBL,EAAU,OAAO,CACxB,EAEE,SAAA,CACGA,EAAK,UAAW,EAAAJ,EAAA,IAAA,CAACH,EAAD,CAAa,MAAOE,EAAK,YAAY,EAAG,MAAW,MAAMK,EAAK,OAAO,CAAI,CAAA,EACzFM,EACAP,EAAM,IAAK,IACV,EAAAH,EAAA,IAAA,CAACF,EAAD,CAAwB,KAAMS,EAAM,KAAM,MAAOA,EAAM,MAAO,SAAUA,EAAM,SAAU,KAAMA,EAAM,KAAM,MAAOA,EAAM,MAAO,KAAMA,EAAM,KACvI,SAAAA,EAAM,MACF,EAFKA,EAAM,IAEX,CACR,GACD,EAAAP,EAAA,IAAA,CAACJ,EAAD,CAAQ,QAAQ,UAAU,KAAK,SAAS,UAAU,kBAAkB,QAASQ,EAAK,OAAkB,WACjG,SAAAO,CACK,CAAA,CACJ,GAEV","debugId":"03901076-b033-43d3-9203-0f43d771906f"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-or0lVadT.js","names":["createRoot","StrictMode","projectUi","n","a","t","__toESM","__exportAll","require_react","require_client","require_jsx_runtime","guarded","protobaseVersion","restorePage","uiFromModule","loadStartCache","nativeBridgeOf","App","browserLocale","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","listenForPresses","doc","noop","apiOriginMeta","databaseName","storeName","indexedDbStartCacheStore","opened","open","request","factory","reject","resolve","run","db","transaction","mode","act","store","key","value","keys","openStartCache","error","showKeyboardAccessoryBar","bridge","applyNativeTextSize","platform","nativeViewport","content","part","applyNativeViewport","meta","apiOriginOf","contents","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","storage"],"sources":["../../../src/lib/press-feedback.ts","../../../../schema/src/api-origin-meta.ts","../../../src/data/start-cache/start-cache-store.ts","../../../src/data/start-cache/open-start-cache.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-text-size.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * Lets the pressed look in `press.css` show on iOS, whose WebKit applies `:active` on touch only while a touch listener\n * is on the page. The listener does nothing and is passive, so scrolling never waits for it.\n */\nexport const listenForPresses = (doc: Document) => doc.addEventListener('touchstart', noop, { passive: true })\n\nconst noop = () => {}\n","/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","/** Where the start cache keeps its records: a few values by key, structured-cloned as IndexedDB stores them. */\nexport type StartCacheStore = {\n read: (key: string) => Promise<unknown>\n write: (key: string, value: unknown) => Promise<void>\n remove: (keys: readonly string[]) => Promise<void>\n}\n\nconst databaseName = 'protobase-start-cache'\nconst storeName = 'records'\n\n/**\n * The start cache in this origin's IndexedDB: in the iOS and Android app the web view's storage inside the app's\n * sandbox, which a fresh install's purge removes. One connection serves the page. Each call is a transaction of its own,\n * and IndexedDB runs them in the order they were made, so a removal after a write always wins.\n */\nexport const indexedDbStartCacheStore = (factory: IDBFactory = indexedDB): StartCacheStore => {\n let opened: Promise<IDBDatabase> | undefined\n const open = () =>\n (opened ??= new Promise<IDBDatabase>((resolve, reject) => {\n const request = factory.open(databaseName, 1)\n request.onupgradeneeded = () => request.result.createObjectStore(storeName)\n request.onerror = () => reject(request.error)\n request.onsuccess = () => resolve(request.result)\n }))\n const run = async <T>(mode: IDBTransactionMode, act: (store: IDBObjectStore) => IDBRequest<T> | undefined) => {\n const db = await open()\n return new Promise<T | undefined>((resolve, reject) => {\n const transaction = db.transaction(storeName, mode)\n const request = act(transaction.objectStore(storeName))\n // A failed request aborts its transaction, which then holds the error; the error event comes before it has it\n transaction.oncomplete = () => resolve(request?.result)\n transaction.onabort = () => reject(transaction.error ?? new DOMException('The start cache transaction was aborted', 'AbortError'))\n })\n }\n return {\n read: (key) => run('readonly', (store) => store.get(key)),\n write: async (key, value) => void (await run('readwrite', (store) => store.put(value, key))),\n remove: async (keys) =>\n void (await run('readwrite', (store) => {\n for (const key of keys) store.delete(key)\n return undefined\n })),\n }\n}\n","import { protobaseVersion } from '../../plugins/plugin-api'\nimport { loadStartCache } from './start-cache'\nimport { indexedDbStartCacheStore } from './start-cache-store'\n\n/**\n * The page's start cache in IndexedDB, for this shell's Protobase version. A browser that keeps no IndexedDB, or refuses\n * to open it, such as some private windows, starts without one.\n */\nexport const openStartCache = async () => {\n if (typeof indexedDB === 'undefined') return\n try {\n return await loadStartCache(indexedDbStartCacheStore(), protobaseVersion)\n } catch (error) {\n if (error instanceof DOMException) return\n throw error\n }\n}\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * Marks the iOS app's document, whose root text size then follows the phone's text size (Dynamic Type) through\n * `styles.css`. Android's WebView follows it by its text zoom, which the shell sets, and a browser by its own setting.\n */\nexport const applyNativeTextSize = (root: Pick<HTMLElement, 'dataset'>, platform: string) => {\n if (platform !== 'ios') return\n root.dataset.pbTextSize = 'system'\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { guarded } from '../lib/guarded'\nimport { listenForPresses } from '../lib/press-feedback'\nimport { browserLocale } from '../locale/active-locale'\nimport { openStartCache } from '../data/start-cache/open-start-cache'\nimport { App } from './app'\nimport { restorePage } from './live-update/kept-page'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeTextSize } from './native-text-size'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nlistenForPresses(document)\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n applyNativeTextSize(document.documentElement, nativeBridge.getPlatform())\n void showKeyboardAccessoryBar(nativeBridge)\n // Back on the page the app showed before a live update reloaded it\n const storage = guarded(() => window.sessionStorage, undefined)\n if (storage) restorePage(storage, window.history)\n}\n\n// The first render already has what the app showed last time, read from the start cache\nvoid openStartCache().then((startCache) =>\n createRoot(root).render(\n <StrictMode>\n <App baseUrl={`${pageApiOrigin() ?? ''}/api/v1`} ui={uiFromModule(projectUi)} locale={browserLocale()} nativeBridge={nativeBridge} startCache={startCache} />\n </StrictMode>,\n ),\n)\n"],"mappings":"s7CAIa+B,EAAoB,GAAkBC,EAAI,iBAAiB,aAAcC,EAAM,CAAE,QAAS,EAAK,CAAC,EAEvGA,MAAa,CAAC,ECDPC,EAAgB,uBCEvBC,EAAe,wBACfC,EAAY,UAOLC,GAA4B,EAAsB,YAA+B,CAC5F,IAAIC,EACEC,MACH,IAAW,IAAI,SAAsB,EAAS,IAAW,CACxD,IAAMC,EAAUC,EAAQ,KAAKN,EAAc,CAAC,EAC5C,EAAQ,oBAAwBK,EAAQ,OAAO,kBAAkBJ,CAAS,EAC1E,EAAQ,YAAgBM,EAAOF,EAAQ,KAAK,EAC5C,EAAQ,cAAkBG,EAAQH,EAAQ,MAAM,CAClD,CAAC,EACGI,EAAM,MAAU,EAA0B,IAA8D,CAC5G,IAAMC,EAAK,MAAMN,EAAK,EACtB,OAAO,IAAI,SAAwB,EAAS,IAAW,CACrD,IAAMO,EAAcD,EAAG,YAAYT,EAAWW,CAAI,EAC5CP,EAAUQ,EAAIF,EAAY,YAAYV,CAAS,CAAC,EAEtD,EAAY,eAAmBO,EAAQH,GAAS,MAAM,EACtD,EAAY,YAAgBE,EAAOI,EAAY,OAAS,IAAI,aAAa,0CAA2C,YAAY,CAAC,CACnI,CAAC,CACH,EACA,MAAO,CACL,KAAO,GAAQF,EAAI,WAAa,GAAUK,EAAM,IAAIC,CAAG,CAAC,EACxD,MAAO,MAAO,EAAK,IAAU,KAAM,MAAMN,EAAI,YAAc,GAAUK,EAAM,IAAIE,EAAOD,CAAG,CAAC,EAC1F,OAAQ,KAAO,IACb,KAAM,MAAMN,EAAI,YAAc,GAAU,CACtC,IAAK,IAAMM,KA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AS,iBAAkC,cAAc9B,EAAc,GAAG,CAAC,CAAC,CAAC,IAAK,GAAS6B,EAAK,OAAO,CAAC,aCFpHM,EAAO,SAAS,eAAe,MAAM,EAC3C,GAAI,CAACA,EAAM,MAAU,MAAM,4CAA4C,EAEvEtC,EAAiB,QAAQ,EAEzB,IAAMuC,EAAetD,EAAe,MAAsC,EAC1E,GAAIsD,EAAc,CAChBR,EAAoB,QAAQ,EAC5BL,EAAoB,SAAS,gBAAiBa,EAAa,YAAY,CAAC,EACxEf,EAA8Be,CAAY,EAE1C,IAAMC,EAAU5D,MAAc,OAAO,eAAgB,IAAA,EAAS,EAC1D4D,GAAS1D,EAAY0D,EAAS,OAAO,OAAO,CAClD,CAGKlB,EAAe,CAAC,CAAC,KAAM,IAAA,EAC1BrD,EAAAA,WAAAA,CAAWqE,CAAI,CAAC,CAAC,QACf,EAAAD,EAAA,IAAA,CAACnE,EAAAA,WAAD,CAAA,UACE,EAAAmE,EAAA,IAAA,CAACnD,EAAD,CAAK,QAAS,GAAGkD,EAAc,GAAK,GAAG,SAAU,GAAIrD,EAAaZ,CAAS,EAAG,OAAQgB,EAAc,EAAiB,eAA0B,YAAa,CAAA,CAClJ,CAAA,CACd,CACF","debugId":"28af4955-69d4-4f4f-b813-fbb568301954"}
1
+ {"version":3,"file":"index-C5uOKZWj.js","names":["createRoot","StrictMode","projectUi","n","a","t","__toESM","__exportAll","require_react","require_client","require_jsx_runtime","guarded","protobaseVersion","restorePage","uiFromModule","loadStartCache","nativeBridgeOf","App","browserLocale","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","listenForPresses","doc","noop","apiOriginMeta","databaseName","storeName","indexedDbStartCacheStore","opened","open","request","factory","reject","resolve","run","db","transaction","mode","act","store","key","value","keys","openStartCache","error","showKeyboardAccessoryBar","bridge","applyNativeTextSize","platform","nativeViewport","content","part","applyNativeViewport","meta","apiOriginOf","contents","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","storage"],"sources":["../../../src/lib/press-feedback.ts","../../../../schema/src/api-origin-meta.ts","../../../src/data/start-cache/start-cache-store.ts","../../../src/data/start-cache/open-start-cache.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-text-size.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * Lets the pressed look in `press.css` show on iOS, whose WebKit applies `:active` on touch only while a touch listener\n * is on the page. The listener does nothing and is passive, so scrolling never waits for it.\n */\nexport const listenForPresses = (doc: Document) => doc.addEventListener('touchstart', noop, { passive: true })\n\nconst noop = () => {}\n","/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","/** Where the start cache keeps its records: a few values by key, structured-cloned as IndexedDB stores them. */\nexport type StartCacheStore = {\n read: (key: string) => Promise<unknown>\n write: (key: string, value: unknown) => Promise<void>\n remove: (keys: readonly string[]) => Promise<void>\n}\n\nconst databaseName = 'protobase-start-cache'\nconst storeName = 'records'\n\n/**\n * The start cache in this origin's IndexedDB: in the iOS and Android app the web view's storage inside the app's\n * sandbox, which a fresh install's purge removes. One connection serves the page. Each call is a transaction of its own,\n * and IndexedDB runs them in the order they were made, so a removal after a write always wins.\n */\nexport const indexedDbStartCacheStore = (factory: IDBFactory = indexedDB): StartCacheStore => {\n let opened: Promise<IDBDatabase> | undefined\n const open = () =>\n (opened ??= new Promise<IDBDatabase>((resolve, reject) => {\n const request = factory.open(databaseName, 1)\n request.onupgradeneeded = () => request.result.createObjectStore(storeName)\n request.onerror = () => reject(request.error)\n request.onsuccess = () => resolve(request.result)\n }))\n const run = async <T>(mode: IDBTransactionMode, act: (store: IDBObjectStore) => IDBRequest<T> | undefined) => {\n const db = await open()\n return new Promise<T | undefined>((resolve, reject) => {\n const transaction = db.transaction(storeName, mode)\n const request = act(transaction.objectStore(storeName))\n // A failed request aborts its transaction, which then holds the error; the error event comes before it has it\n transaction.oncomplete = () => resolve(request?.result)\n transaction.onabort = () => reject(transaction.error ?? new DOMException('The start cache transaction was aborted', 'AbortError'))\n })\n }\n return {\n read: (key) => run('readonly', (store) => store.get(key)),\n write: async (key, value) => void (await run('readwrite', (store) => store.put(value, key))),\n remove: async (keys) =>\n void (await run('readwrite', (store) => {\n for (const key of keys) store.delete(key)\n return undefined\n })),\n }\n}\n","import { protobaseVersion } from '../../plugins/plugin-api'\nimport { loadStartCache } from './start-cache'\nimport { indexedDbStartCacheStore } from './start-cache-store'\n\n/**\n * The page's start cache in IndexedDB, for this shell's Protobase version. A browser that keeps no IndexedDB, or refuses\n * to open it, such as some private windows, starts without one.\n */\nexport const openStartCache = async () => {\n if (typeof indexedDB === 'undefined') return\n try {\n return await loadStartCache(indexedDbStartCacheStore(), protobaseVersion)\n } catch (error) {\n if (error instanceof DOMException) return\n throw error\n }\n}\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * Marks the iOS app's document, whose root text size then follows the phone's text size (Dynamic Type) through\n * `styles.css`. Android's WebView follows it by its text zoom, which the shell sets, and a browser by its own setting.\n */\nexport const applyNativeTextSize = (root: Pick<HTMLElement, 'dataset'>, platform: string) => {\n if (platform !== 'ios') return\n root.dataset.pbTextSize = 'system'\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { guarded } from '../lib/guarded'\nimport { listenForPresses } from '../lib/press-feedback'\nimport { browserLocale } from '../locale/active-locale'\nimport { openStartCache } from '../data/start-cache/open-start-cache'\nimport { App } from './app'\nimport { restorePage } from './live-update/kept-page'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeTextSize } from './native-text-size'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nlistenForPresses(document)\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n applyNativeTextSize(document.documentElement, nativeBridge.getPlatform())\n void showKeyboardAccessoryBar(nativeBridge)\n // Back on the page the app showed before a live update reloaded it\n const storage = guarded(() => window.sessionStorage, undefined)\n if (storage) restorePage(storage, window.history)\n}\n\n// The first render already has what the app showed last time, read from the start cache\nvoid openStartCache().then((startCache) =>\n createRoot(root).render(\n <StrictMode>\n <App baseUrl={`${pageApiOrigin() ?? ''}/api/v1`} ui={uiFromModule(projectUi)} locale={browserLocale()} nativeBridge={nativeBridge} startCache={startCache} />\n </StrictMode>,\n ),\n)\n"],"mappings":"s7CAIa+B,EAAoB,GAAkBC,EAAI,iBAAiB,aAAcC,EAAM,CAAE,QAAS,EAAK,CAAC,EAEvGA,MAAa,CAAC,ECDPC,EAAgB,uBCEvBC,EAAe,wBACfC,EAAY,UAOLC,GAA4B,EAAsB,YAA+B,CAC5F,IAAIC,EACEC,MACH,IAAW,IAAI,SAAsB,EAAS,IAAW,CACxD,IAAMC,EAAUC,EAAQ,KAAKN,EAAc,CAAC,EAC5C,EAAQ,oBAAwBK,EAAQ,OAAO,kBAAkBJ,CAAS,EAC1E,EAAQ,YAAgBM,EAAOF,EAAQ,KAAK,EAC5C,EAAQ,cAAkBG,EAAQH,EAAQ,MAAM,CAClD,CAAC,EACGI,EAAM,MAAU,EAA0B,IAA8D,CAC5G,IAAMC,EAAK,MAAMN,EAAK,EACtB,OAAO,IAAI,SAAwB,EAAS,IAAW,CACrD,IAAMO,EAAcD,EAAG,YAAYT,EAAWW,CAAI,EAC5CP,EAA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version":3,"file":"intl-cache-ULd6cKG6.js","names":["n","a","t","formatTag","cache","cachedFormat","tag","id","key","make"],"sources":["../../../src/format/intl-cache.ts"],"sourcesContent":["import { formatTag } from '../locale/active-locale'\n\nconst cache = new Map<string, unknown>()\n\n/** One `Intl` formatter per language tag and `key`, made with `make` for the active locale's tag the first time. */\nexport const cachedFormat = <T>(key: string, make: (tag: string) => T): T => {\n const tag = formatTag()\n const id = `${tag}|${key}`\n if (!cache.has(id)) cache.set(id, make(tag))\n return cache.get(id) as T\n}\n"],"mappings":"kgBAEA,IAAMI,EAAQ,IAAI,IAGLC,GAAmB,EAAa,IAAgC,CAC3E,IAAMC,EAAMH,EAAU,EAChBI,EAAK,GAAGD,EAAI,GAAGE,IAErB,OADKJ,EAAM,IAAIG,CAAE,GAAGH,EAAM,IAAIG,EAAIE,EAAKH,CAAG,CAAC,EACpCF,EAAM,IAAIG,CAAE,CACrB","debugId":"142dde9c-286e-440e-bfea-27c7eefb06e5"}
1
+ {"version":3,"file":"intl-cache-bXVNV0Yq.js","names":["n","a","t","formatTag","cache","cachedFormat","tag","id","key","make"],"sources":["../../../src/format/intl-cache.ts"],"sourcesContent":["import { formatTag } from '../locale/active-locale'\n\nconst cache = new Map<string, unknown>()\n\n/** One `Intl` formatter per language tag and `key`, made with `make` for the active locale's tag the first time. */\nexport const cachedFormat = <T>(key: string, make: (tag: string) => T): T => {\n const tag = formatTag()\n const id = `${tag}|${key}`\n if (!cache.has(id)) cache.set(id, make(tag))\n return cache.get(id) as T\n}\n"],"mappings":"kgBAEA,IAAMI,EAAQ,IAAI,IAGLC,GAAmB,EAAa,IAAgC,CAC3E,IAAMC,EAAMH,EAAU,EAChBI,EAAK,GAAGD,EAAI,GAAGE,IAErB,OADKJ,EAAM,IAAIG,CAAE,GAAGH,EAAM,IAAIG,EAAIE,EAAKH,CAAG,CAAC,EACpCF,EAAM,IAAIG,CAAE,CACrB","debugId":"1b5d5355-d18a-4187-9c27-548eb91cb1de"}
@@ -1 +1 @@
1
- {"version":3,"file":"maplibre-DrBxXIsy.js","names":["useState","_Fragment","maplibre.setWorkerUrl","workerUrl","maplibre.addProtocol","Protocol","maplibre","n","a","t","__toESM","require_react","require_jsx_runtime","guarded","Segmented","messages","createLucideIcon","maplibre_gl_exports","An","UF","maplibre_gl_worker_default","Source","useMap","Layer","B","__iconData","MapPin","import_react","mapLayerStorageKey","chosenMapLayer","layers","layer","id","readMapLayer","storage","writeMapLayer","text","import_jsx_runtime","styleValue","MapLayerSwitch","chosenId","setChosenId","map","chosen","choose","value","beforeId","below","mapLib"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/map-pin.mjs","../../../src/app/map/map-layer-choice.ts","../../../src/app/map/messages.ts","../../../src/app/map/map-layer-switch.tsx","../../../src/app/map/maplibre.ts"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"map-pin\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\",\n key: \"1r0f0z\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"10\", r: \"3\", key: \"ilqhr7\" }]\n ]\n};\n__iconData.node;\nconst MapPin = createLucideIcon(__iconData);\n\nexport { __iconData, MapPin as default };\n//# sourceMappingURL=map-pin.mjs.map\n","import type { MapLayerModel } from '@protobase/client'\nimport { guarded } from '../../lib/guarded'\n\nexport const mapLayerStorageKey = 'protobase:map-layer'\n\n/** The layer the browser last chose, if the app still offers it: else the style's own map, which is the default. */\nexport const chosenMapLayer = (layers: MapLayerModel[], id: string | null | undefined) => layers.find((layer) => layer.id === id)\n\n/** The id of the layer chosen in this browser, if any; unavailable storage reads as the default map. */\nexport const readMapLayer = (storage: Pick<Storage, 'getItem'>) => guarded(() => storage.getItem(mapLayerStorageKey), null)\n\n/** Remembers a layer by its id, and the default map by forgetting the choice, so the default costs no storage. */\nexport const writeMapLayer = (storage: Pick<Storage, 'setItem' | 'removeItem'>, id: string | undefined) =>\n guarded(() => (id === undefined ? storage.removeItem(mapLayerStorageKey) : storage.setItem(mapLayerStorageKey, id)), undefined)\n","import { messages } from '../../locale/messages'\n\nexport const text = messages('app/map')\n","import { useState } from 'react'\nimport { Layer, Source, useMap } from 'react-map-gl/maplibre'\nimport type { MapLayerModel } from '@protobase/client'\nimport { Segmented } from '../../primitives/segmented'\nimport { chosenMapLayer, readMapLayer, writeMapLayer } from './map-layer-choice'\nimport { text } from './messages'\n\n// The default map's value in the switch: no layer id can be empty.\nconst styleValue = ''\n\n/**\n * Inside a map, a switch in its top left corner between the style's map and each of `layers`, and the chosen layer's\n * tiles drawn over the style's, under `below` when the map has that layer, such as the areas around records. The\n * layer's credit joins the map's attribution while it shows. Outside its bounds the style's map shows through. The\n * choice is remembered in this browser, for every map. Nothing without layers.\n */\nexport const MapLayerSwitch = ({ layers, below }: { layers: MapLayerModel[] | undefined; below?: string }) => {\n const [chosenId, setChosenId] = useState(() => readMapLayer(localStorage))\n const { current: map } = useMap()\n if (!layers || layers.length === 0) return null\n const chosen = chosenMapLayer(layers, chosenId)\n const choose = (value: string) => {\n const id = value === styleValue ? undefined : value\n writeMapLayer(localStorage, id)\n setChosenId(id ?? null)\n }\n const beforeId = below && map?.getLayer(below) ? below : undefined\n return (\n <>\n {chosen && (\n <Source key={chosen.id} id={`map-layer-${chosen.id}`} type=\"raster\" tiles={[chosen.tiles]} tileSize={256} attribution={chosen.attribution} maxzoom={chosen.maxzoom ?? 22} {...(chosen.bounds && { bounds: chosen.bounds })}>\n <Layer id={`map-layer-${chosen.id}`} type=\"raster\" {...(beforeId && { beforeId })} />\n </Source>\n )}\n <div className=\"absolute left-2.5 top-2.5 z-10 rounded-md shadow\">\n <Segmented label={text('mapLayer')} value={chosen?.id ?? styleValue} onChange={choose} options={[{ value: styleValue, label: text('map') }, ...layers.map((layer) => ({ value: layer.id, label: layer.label }))]} />\n </div>\n </>\n )\n}\n","import * as maplibre from 'maplibre-gl'\nimport workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'\nimport 'maplibre-gl/dist/maplibre-gl.css'\nimport { Protocol } from 'pmtiles'\n\n// This module loads the first time a map is drawn, and once: MapLibre runs its worker from the bundled file, as its\n// docs say for Vite, and reads `pmtiles://` sources in a style by range requests to the one archive. A map takes\n// MapLibre from here, so a build that drops modules imported only for their effects keeps this one.\nmaplibre.setWorkerUrl(workerUrl)\nmaplibre.addProtocol('pmtiles', new Protocol().tile)\n\n/** MapLibre, set up to run its worker and read PMTiles archives: what a map draws with. */\nexport const mapLib = maplibre\n"],"ignoreList":[0],"mappings":"23BASA,IAAMyB,EAAa,CACjB,KAAM,UACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,uGACH,IAAK,QACP,CACF,EACA,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CAC1D,CACF,EACAA,EAAW,KACX,IAAMC,EAASV,EAAiBS,CAAU,aCrB7BG,EAAqB,sBAGrBC,GAAkB,EAAyB,IAAkCC,EAAO,KAAM,GAAUC,EAAM,KAAOC,CAAE,EAGnHC,EAAgB,GAAsCpB,MAAcqB,EAAQ,QAAQN,CAAkB,EAAG,IAAI,EAG7GO,GAAiB,EAAkD,IAC9EtB,MAAemB,IAAO,IAAA,GAAYE,EAAQ,WAAWN,CAAkB,EAAIM,EAAQ,QAAQN,EAAoBI,CAAE,EAAI,IAAA,EAAS,ECXnHI,EAAOrB,EAAS,SAAS,aCMhCuB,EAAa,GAQNC,GAAkB,CAAE,SAAQ,WAAqE,CAC5G,GAAM,CAACC,EAAUC,IAAA,EAAezC,EAAAA,SAAAA,KAAeiC,EAAa,YAAY,CAA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ac93-242788c2cb41"}
1
+ {"version":3,"file":"maplibre-q_iehi3V.js","names":["useState","_Fragment","maplibre.setWorkerUrl","workerUrl","maplibre.addProtocol","Protocol","maplibre","n","a","t","__toESM","require_react","require_jsx_runtime","guarded","Segmented","messages","createLucideIcon","maplibre_gl_exports","An","UF","maplibre_gl_worker_default","Source","useMap","Layer","B","__iconData","MapPin","import_react","mapLayerStorageKey","chosenMapLayer","layers","layer","id","readMapLayer","storage","writeMapLayer","text","import_jsx_runtime","styleValue","MapLayerSwitch","chosenId","setChosenId","map","chosen","choose","value","beforeId","below","mapLib"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/map-pin.mjs","../../../src/app/map/map-layer-choice.ts","../../../src/app/map/messages.ts","../../../src/app/map/map-layer-switch.tsx","../../../src/app/map/maplibre.ts"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"map-pin\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\",\n key: \"1r0f0z\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"10\", r: \"3\", key: \"ilqhr7\" }]\n ]\n};\n__iconData.node;\nconst MapPin = createLucideIcon(__iconData);\n\nexport { __iconData, MapPin as default };\n//# sourceMappingURL=map-pin.mjs.map\n","import type { MapLayerModel } from '@protobase/client'\nimport { guarded } from '../../lib/guarded'\n\nexport const mapLayerStorageKey = 'protobase:map-layer'\n\n/** The layer the browser last chose, if the app still offers it: else the style's own map, which is the default. */\nexport const chosenMapLayer = (layers: MapLayerModel[], id: string | null | undefined) => layers.find((layer) => layer.id === id)\n\n/** The id of the layer chosen in this browser, if any; unavailable storage reads as the default map. */\nexport const readMapLayer = (storage: Pick<Storage, 'getItem'>) => guarded(() => storage.getItem(mapLayerStorageKey), null)\n\n/** Remembers a layer by its id, and the default map by forgetting the choice, so the default costs no storage. */\nexport const writeMapLayer = (storage: Pick<Storage, 'setItem' | 'removeItem'>, id: string | undefined) =>\n guarded(() => (id === undefined ? storage.removeItem(mapLayerStorageKey) : storage.setItem(mapLayerStorageKey, id)), undefined)\n","import { messages } from '../../locale/messages'\n\nexport const text = messages('app/map')\n","import { useState } from 'react'\nimport { Layer, Source, useMap } from 'react-map-gl/maplibre'\nimport type { MapLayerModel } from '@protobase/client'\nimport { Segmented } from '../../primitives/segmented'\nimport { chosenMapLayer, readMapLayer, writeMapLayer } from './map-layer-choice'\nimport { text } from './messages'\n\n// The default map's value in the switch: no layer id can be empty.\nconst styleValue = ''\n\n/**\n * Inside a map, a switch in its top left corner between the style's map and each of `layers`, and the chosen layer's\n * tiles drawn over the style's, under `below` when the map has that layer, such as the areas around records. The\n * layer's credit joins the map's attribution while it shows. Outside its bounds the style's map shows through. The\n * choice is remembered in this browser, for every map. Nothing without layers.\n */\nexport const MapLayerSwitch = ({ layers, below }: { layers: MapLayerModel[] | undefined; below?: string }) => {\n const [chosenId, setChosenId] = useState(() => readMapLayer(localStorage))\n const { current: map } = useMap()\n if (!layers || layers.length === 0) return null\n const chosen = chosenMapLayer(layers, chosenId)\n const choose = (value: string) => {\n const id = value === styleValue ? undefined : value\n writeMapLayer(localStorage, id)\n setChosenId(id ?? null)\n }\n const beforeId = below && map?.getLayer(below) ? below : undefined\n return (\n <>\n {chosen && (\n <Source key={chosen.id} id={`map-layer-${chosen.id}`} type=\"raster\" tiles={[chosen.tiles]} tileSize={256} attribution={chosen.attribution} maxzoom={chosen.maxzoom ?? 22} {...(chosen.bounds && { bounds: chosen.bounds })}>\n <Layer id={`map-layer-${chosen.id}`} type=\"raster\" {...(beforeId && { beforeId })} />\n </Source>\n )}\n <div className=\"absolute left-2.5 top-2.5 z-10 rounded-md shadow\">\n <Segmented label={text('mapLayer')} value={chosen?.id ?? styleValue} onChange={choose} options={[{ value: styleValue, label: text('map') }, ...layers.map((layer) => ({ value: layer.id, label: layer.label }))]} />\n </div>\n </>\n )\n}\n","import * as maplibre from 'maplibre-gl'\nimport workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'\nimport 'maplibre-gl/dist/maplibre-gl.css'\nimport { Protocol } from 'pmtiles'\n\n// This module loads the first time a map is drawn, and once: MapLibre runs its worker from the bundled file, as its\n// docs say for Vite, and reads `pmtiles://` sources in a style by range requests to the one archive. A map takes\n// MapLibre from here, so a build that drops modules imported only for their effects keeps this one.\nmaplibre.setWorkerUrl(workerUrl)\nmaplibre.addProtocol('pmtiles', new Protocol().tile)\n\n/** MapLibre, set up to run its worker and read PMTiles archives: what a map draws with. */\nexport const mapLib = maplibre\n"],"ignoreList":[0],"mappings":"23BASA,IAAMyB,EAAa,CACjB,KAAM,UACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,uGACH,IAAK,QACP,CACF,EACA,CAAC,SAAU,CAAE,GAAI,KAAM,GAAI,KAAM,EAAG,IAAK,IAAK,QAAS,CAAC,CAC1D,CACF,EACAA,EAAW,KACX,IAAMC,EAASV,EAAiBS,CAAU,aCrB7BG,EAAqB,sBAGrBC,GAAkB,EAAyB,IAAkCC,EAAO,KAAM,GAAUC,EAAM,KAAOC,CAAE,EAGnHC,EAAgB,GAAsCpB,MAAcqB,EAAQ,QAAQN,CAAkB,EAAG,IAAI,EAG7GO,GAAiB,EAAkD,IAC9EtB,MAAemB,IAAO,IAAA,GAAYE,EAAQ,WAAWN,CAAkB,EAAIM,EAAQ,QAAQN,EAAoBI,CAAE,EAAI,IAAA,EAAS,ECXnHI,EAAOrB,EAAS,SAAS,aCMhCuB,EAAa,GAQNC,GAAkB,CAAE,SAAQ,WAAqE,CAC5G,GAAM,CAACC,EAAUC,IAAA,EAAezC,EAAAA,SAAAA,KAAeiC,EAAa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-8b75-4bac-ad29-2e2250a35cfc"}
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-content-COBuNH9x.js","names":["Marked","useMemo","DOMPurify","n","a","t","__toESM","require_react","require_jsx_runtime","useHeadingLevel","cn","purify_default","U","import_react","nestedHeadingLevel","under","depth","escapes","escapeHtml","text","char","scheme","linkSchemes","imageSchemes","ignoredByBrowsers","safeAddress","named","href","schemes","error","titled","title","parser","block","tokens","address","inLink","parsers","markdownHtml","markdown","source","token","headingsUnder","import_jsx_runtime","page","MarkdownContent","insideLink","html","className"],"sources":["../../../src/markdown/nested-heading-level.ts","../../../src/markdown/markdown-html.ts","../../../src/markdown/markdown-content.tsx"],"sourcesContent":["/**\n * The level a markdown heading of `depth` takes under a heading of level `under`: one below it at the least, so `#` and\n * `##` both become the level under it and `###` the one after, and never past h6. With nothing above it, `depth` stays.\n */\nexport const nestedHeadingLevel = (depth: number, under: number) => {\n if (under === 0) return depth\n return Math.min(6, Math.max(under + 1, depth + under - 1))\n}\n","import { Marked, type Tokens } from 'marked'\nimport { nestedHeadingLevel } from './nested-heading-level'\n\nexport type MarkdownHtmlOptions = {\n /** The HTML goes inside a link, such as a card: its links become their text and its images their alt text. */\n inLink?: boolean\n /** The level of the heading the HTML sits under, whose level its own headings go below; 0, the default, keeps them. */\n headingsUnder?: number\n}\n\nconst escapes: Record<string, string> = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' }\nconst escapeHtml = (text: string) => text.replace(/[&<>\"']/g, (char) => escapes[char]!)\n\nconst scheme = /^([a-z][a-z0-9+.-]*):/i\nconst linkSchemes = new Set(['http', 'https', 'mailto', 'tel'])\nconst imageSchemes = new Set(['http', 'https'])\n\n// The browser drops these from an address, so `java\\tscript:` is still a script\nconst ignoredByBrowsers = /[\\u0000-\\u0020\\u007f]/g\n\n// An address percent-encoded as marked does, or null when it leaves the allowed schemes, such as `javascript:`.\nconst safeAddress = (href: string, schemes: ReadonlySet<string>) => {\n const named = scheme.exec(href.replace(ignoredByBrowsers, ''))?.[1]?.toLowerCase()\n if (named !== undefined && !schemes.has(named)) return null\n try {\n return encodeURI(href).replace(/%25/g, '%')\n } catch (error) {\n if (error instanceof URIError) return null\n throw error\n }\n}\n\nconst titled = (title: string | null | undefined) => (title ? ` title=\"${escapeHtml(title)}\"` : '')\n\nconst parser = ({ inLink = false }: MarkdownHtmlOptions) =>\n new Marked({\n gfm: true,\n // A line break in the text is one on the page, as in a comment on GitHub\n breaks: true,\n renderer: {\n // Raw HTML shows as the text it is, never as markup\n html: ({ text, block }: Tokens.HTML | Tokens.Tag) => (block ? `<p>${escapeHtml(text)}</p>` : escapeHtml(text)),\n link({ href, title, tokens }: Tokens.Link) {\n const text = this.parser.parseInline(tokens)\n const address = inLink ? null : safeAddress(href, linkSchemes)\n if (address === null) return text\n return `<a href=\"${escapeHtml(address)}\"${titled(title)} target=\"_blank\" rel=\"noopener noreferrer nofollow\">${text}</a>`\n },\n image({ href, title, text }: Tokens.Image) {\n const address = inLink ? null : safeAddress(href, imageSchemes)\n if (address === null) return escapeHtml(text)\n return `<img src=\"${escapeHtml(address)}\" alt=\"${escapeHtml(text)}\"${titled(title)} loading=\"lazy\">`\n },\n },\n })\n\nconst parsers = { inLink: parser({ inLink: true }), page: parser({}) }\n\n/**\n * Markdown as HTML (GitHub's flavour, line breaks kept): raw HTML escaped, links and images only to http(s), mailto and\n * tel addresses or relative ones, links opening in a new tab and headings below `headingsUnder`. The page sanitises the\n * result again before showing it.\n */\nexport const markdownHtml = (source: string, { inLink = false, headingsUnder = 0 }: MarkdownHtmlOptions = {}) => {\n const markdown = inLink ? parsers.inLink : parsers.page\n const tokens = markdown.lexer(source)\n markdown.walkTokens(tokens, (token) => {\n if (token.type === 'heading') token.depth = nestedHeadingLevel(token.depth, headingsUnder)\n })\n return markdown.parser(tokens)\n}\n","import { useMemo } from 'react'\nimport DOMPurify from 'dompurify'\nimport { cn } from '../lib/cn'\nimport { useHeadingLevel } from '../lib/heading-level'\nimport { markdownHtml } from './markdown-html'\n\n// The parts markdown makes, in the theme's colours; code and tables wrap rather than scroll inside\nconst page = cn(\n 'break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n '[&_p]:my-2 [&_ul]:my-2 [&_ol]:my-2 [&_pre]:my-2 [&_blockquote]:my-2 [&_table]:my-2 [&_hr]:my-3',\n '[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h2]:mt-4 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold',\n '[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:font-semibold [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:font-semibold [&_h5]:font-semibold [&_h6]:font-semibold',\n '[&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li:has(>input)]:list-none [&_li>input]:mr-1.5 [&_li>input]:-ml-5 [&_li>input]:align-middle',\n '[&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 hover:[&_a]:text-primary-hover',\n '[&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]',\n '[&_pre]:whitespace-pre-wrap [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0',\n '[&_blockquote]:border-l-2 [&_blockquote]:border-border-strong [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground',\n '[&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold',\n '[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1 [&_td]:[overflow-wrap:anywhere]',\n '[&_hr]:border-border [&_img]:inline [&_img]:max-w-full [&_img]:rounded [&_del]:text-muted-foreground',\n)\n\n// Inside a link, such as a card, it reads as running text: no gaps between blocks and headings no larger\nconst inLink = cn('[&_*]:my-0 [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold [&_ul]:list-inside [&_ol]:list-inside [&_pre]:whitespace-pre-wrap [&_code]:font-mono [&_code]:text-[0.9em]')\n\nexport type MarkdownContentProps = {\n source: string\n /** It is shown inside a link, such as a card: its own links and images show as their text. */\n inLink?: boolean\n className?: string\n}\n\n/**\n * Markdown rendered, sanitised before it reaches the page: raw HTML shows as text, links open in a new tab and headings\n * sit below the heading the markdown is under, such as a record page section's.\n */\nexport const MarkdownContent = ({ source, inLink: insideLink = false, className }: MarkdownContentProps) => {\n const headingsUnder = useHeadingLevel()\n const html = useMemo(() => DOMPurify.sanitize(markdownHtml(source, { inLink: insideLink, headingsUnder }), { ADD_ATTR: ['target'] }), [source, insideLink, headingsUnder])\n return <div className={cn(insideLink ? inLink : page, className)} dangerouslySetInnerHTML={{ __html: html }} />\n}\n"],"mappings":"ivBAIac,GAAsB,EAAe,IAC5CC,IAAU,EAAUC,EACjB,KAAK,IAAI,EAAG,KAAK,IAAID,EAAQ,EAAGC,EAAQD,EAAQ,CAAC,CAAC,ECIrDE,EAAkC,CAAE,IAAK,QAAS,IAAK,OAAQ,IAAK,OAAQ,IAAK,SAAU,IAAK,OAAQ,EACxGC,EAAc,GAAiBC,EAAK,QAAQ,WAAa,GAASF,EAAQG,EAAM,EAEhFC,EAAS,yBACTC,EAAc,IAAI,IAAI,CAAC,OAAQ,QAAS,SAAU,KAAK,CAAC,EACxDC,EAAe,IAAI,IAAI,CAAC,OAAQ,OAAO,CAAC,EAGxCC,EAAoB,yBAGpBC,GAAe,EAAc,IAAiC,CAClE,IAAMC,EAAQL,EAAO,KAAKM,EAAK,QAAQH,EAAmB,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,EACjF,GAAIE,IAAU,IAAA,IAAa,CAACE,EAAQ,IAAIF,CAAK,EAAG,OAAO,KACvD,GAAI,CACF,OAAO,UAAUC,CAAI,CAAC,CAAC,QAAQ,OAAQ,GAAG,CAC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,kGACA,4GACA,2HACA,yHACA,gKACA,6FACA,sGACF,EAGM0B,EAAS1B,EAAG,sLAAsL,EAa3LmC,GAAmB,CAAE,SAAQ,OAAQC,EAAa,GAAO,eAAsC,CAC1G,IAAMJ,EAAgBjC,EAAgB,EAChCsC,GAAA,EAAO9C,EAAAA,QAAAA,KAAcC,EAAU,SAASoC,EAAaE,EAAQ,CAAE,OAAQM,EAAY,eAAc,CAAC,EAAG,CAAE,SAAU,CAAC,QAAQ,CAAE,CAAC,EAAG,CAACN,EAAQM,EAAYJ,CAAa,CAAC,EACzK,OAAO,EAAAC,EAAA,IAAA,CAAC,MAAD,CAAK,UAAWjC,EAAGoC,EAAaV,EAASQ,EAAMI,CAAS,EAAG,wBAAyB,CAAE,OAAQD,CAAK,CAAI,CAAA,CAChH","debugId":"8e06e347-f711-4c72-9c75-e08e69e2da27"}
1
+ {"version":3,"file":"markdown-content-DgtMKGmV.js","names":["Marked","useMemo","DOMPurify","n","a","t","__toESM","require_react","require_jsx_runtime","useHeadingLevel","cn","purify_default","U","import_react","nestedHeadingLevel","under","depth","escapes","escapeHtml","text","char","scheme","linkSchemes","imageSchemes","ignoredByBrowsers","safeAddress","named","href","schemes","error","titled","title","parser","block","tokens","address","inLink","parsers","markdownHtml","markdown","source","token","headingsUnder","import_jsx_runtime","page","MarkdownContent","insideLink","html","className"],"sources":["../../../src/markdown/nested-heading-level.ts","../../../src/markdown/markdown-html.ts","../../../src/markdown/markdown-content.tsx"],"sourcesContent":["/**\n * The level a markdown heading of `depth` takes under a heading of level `under`: one below it at the least, so `#` and\n * `##` both become the level under it and `###` the one after, and never past h6. With nothing above it, `depth` stays.\n */\nexport const nestedHeadingLevel = (depth: number, under: number) => {\n if (under === 0) return depth\n return Math.min(6, Math.max(under + 1, depth + under - 1))\n}\n","import { Marked, type Tokens } from 'marked'\nimport { nestedHeadingLevel } from './nested-heading-level'\n\nexport type MarkdownHtmlOptions = {\n /** The HTML goes inside a link, such as a card: its links become their text and its images their alt text. */\n inLink?: boolean\n /** The level of the heading the HTML sits under, whose level its own headings go below; 0, the default, keeps them. */\n headingsUnder?: number\n}\n\nconst escapes: Record<string, string> = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;', \"'\": '&#39;' }\nconst escapeHtml = (text: string) => text.replace(/[&<>\"']/g, (char) => escapes[char]!)\n\nconst scheme = /^([a-z][a-z0-9+.-]*):/i\nconst linkSchemes = new Set(['http', 'https', 'mailto', 'tel'])\nconst imageSchemes = new Set(['http', 'https'])\n\n// The browser drops these from an address, so `java\\tscript:` is still a script\nconst ignoredByBrowsers = /[\\u0000-\\u0020\\u007f]/g\n\n// An address percent-encoded as marked does, or null when it leaves the allowed schemes, such as `javascript:`.\nconst safeAddress = (href: string, schemes: ReadonlySet<string>) => {\n const named = scheme.exec(href.replace(ignoredByBrowsers, ''))?.[1]?.toLowerCase()\n if (named !== undefined && !schemes.has(named)) return null\n try {\n return encodeURI(href).replace(/%25/g, '%')\n } catch (error) {\n if (error instanceof URIError) return null\n throw error\n }\n}\n\nconst titled = (title: string | null | undefined) => (title ? ` title=\"${escapeHtml(title)}\"` : '')\n\nconst parser = ({ inLink = false }: MarkdownHtmlOptions) =>\n new Marked({\n gfm: true,\n // A line break in the text is one on the page, as in a comment on GitHub\n breaks: true,\n renderer: {\n // Raw HTML shows as the text it is, never as markup\n html: ({ text, block }: Tokens.HTML | Tokens.Tag) => (block ? `<p>${escapeHtml(text)}</p>` : escapeHtml(text)),\n link({ href, title, tokens }: Tokens.Link) {\n const text = this.parser.parseInline(tokens)\n const address = inLink ? null : safeAddress(href, linkSchemes)\n if (address === null) return text\n return `<a href=\"${escapeHtml(address)}\"${titled(title)} target=\"_blank\" rel=\"noopener noreferrer nofollow\">${text}</a>`\n },\n image({ href, title, text }: Tokens.Image) {\n const address = inLink ? null : safeAddress(href, imageSchemes)\n if (address === null) return escapeHtml(text)\n return `<img src=\"${escapeHtml(address)}\" alt=\"${escapeHtml(text)}\"${titled(title)} loading=\"lazy\">`\n },\n },\n })\n\nconst parsers = { inLink: parser({ inLink: true }), page: parser({}) }\n\n/**\n * Markdown as HTML (GitHub's flavour, line breaks kept): raw HTML escaped, links and images only to http(s), mailto and\n * tel addresses or relative ones, links opening in a new tab and headings below `headingsUnder`. The page sanitises the\n * result again before showing it.\n */\nexport const markdownHtml = (source: string, { inLink = false, headingsUnder = 0 }: MarkdownHtmlOptions = {}) => {\n const markdown = inLink ? parsers.inLink : parsers.page\n const tokens = markdown.lexer(source)\n markdown.walkTokens(tokens, (token) => {\n if (token.type === 'heading') token.depth = nestedHeadingLevel(token.depth, headingsUnder)\n })\n return markdown.parser(tokens)\n}\n","import { useMemo } from 'react'\nimport DOMPurify from 'dompurify'\nimport { cn } from '../lib/cn'\nimport { useHeadingLevel } from '../lib/heading-level'\nimport { markdownHtml } from './markdown-html'\n\n// The parts markdown makes, in the theme's colours; code and tables wrap rather than scroll inside\nconst page = cn(\n 'break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',\n '[&_p]:my-2 [&_ul]:my-2 [&_ol]:my-2 [&_pre]:my-2 [&_blockquote]:my-2 [&_table]:my-2 [&_hr]:my-3',\n '[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h2]:mt-4 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold',\n '[&_h3]:mt-3 [&_h3]:mb-1 [&_h3]:font-semibold [&_h4]:mt-3 [&_h4]:mb-1 [&_h4]:font-semibold [&_h5]:font-semibold [&_h6]:font-semibold',\n '[&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li:has(>input)]:list-none [&_li>input]:mr-1.5 [&_li>input]:-ml-5 [&_li>input]:align-middle',\n '[&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 hover:[&_a]:text-primary-hover',\n '[&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]',\n '[&_pre]:whitespace-pre-wrap [&_pre]:rounded-md [&_pre]:bg-muted [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0',\n '[&_blockquote]:border-l-2 [&_blockquote]:border-border-strong [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground',\n '[&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-border [&_th]:bg-surface [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold',\n '[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1 [&_td]:[overflow-wrap:anywhere]',\n '[&_hr]:border-border [&_img]:inline [&_img]:max-w-full [&_img]:rounded [&_del]:text-muted-foreground',\n)\n\n// Inside a link, such as a card, it reads as running text: no gaps between blocks and headings no larger\nconst inLink = cn('[&_*]:my-0 [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold [&_ul]:list-inside [&_ol]:list-inside [&_pre]:whitespace-pre-wrap [&_code]:font-mono [&_code]:text-[0.9em]')\n\nexport type MarkdownContentProps = {\n source: string\n /** It is shown inside a link, such as a card: its own links and images show as their text. */\n inLink?: boolean\n className?: string\n}\n\n/**\n * Markdown rendered, sanitised before it reaches the page: raw HTML shows as text, links open in a new tab and headings\n * sit below the heading the markdown is under, such as a record page section's.\n */\nexport const MarkdownContent = ({ source, inLink: insideLink = false, className }: MarkdownContentProps) => {\n const headingsUnder = useHeadingLevel()\n const html = useMemo(() => DOMPurify.sanitize(markdownHtml(source, { inLink: insideLink, headingsUnder }), { ADD_ATTR: ['target'] }), [source, insideLink, headingsUnder])\n return <div className={cn(insideLink ? inLink : page, className)} dangerouslySetInnerHTML={{ __html: html }} />\n}\n"],"mappings":"ivBAIac,GAAsB,EAAe,IAC5CC,IAAU,EAAUC,EACjB,KAAK,IAAI,EAAG,KAAK,IAAID,EAAQ,EAAGC,EAAQD,EAAQ,CAAC,CAAC,ECIrDE,EAAkC,CAAE,IAAK,QAAS,IAAK,OAAQ,IAAK,OAAQ,IA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