@symbo.ls/brender 3.14.664 → 3.14.666

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.666
4
+
5
+ ### Patch Changes
6
+
7
+ - Cross-tenant isolation for server renders, and the wider CLI production gate.
8
+
9
+ - fetch: a server render context (`isolateFetchCache`, set by brender) has its own query store — cache, requests in flight, invalidations and mounted queries — so two renders of different projects in one process never share rows, in sequence or at the same time; a server render binds no browser-only refetch (no focus / online listeners, no `refetchInterval` timer), so no request of one page lands in another page's seed and the process exits when the work is done.
10
+ - brender: renders that start together share one framework bundle; every render owns its `location`, Web Storage and `history`.
11
+ - cli: destructive platform writes (project delete, transfer, members, invites, library changes, version writes) print the target and need a typed "production" or `--yes` for production; `project create` is not gated.
12
+
13
+ - Updated dependencies
14
+ - smbls@3.14.839
15
+ - @symbo.ls/fetch@3.14.666
16
+
17
+ ## 3.14.665
18
+
19
+ ### Patch Changes
20
+
21
+ - xma.info report round (FW-XMA-EXCEPTIONS-UPSTREAM-1), its /simplify pass and the follow-ups.
22
+
23
+ - element: optional features (view events, `always` handler chains, plain-row diff, hydration, yielding mount) are feature slots — `create.js` installs all of them, `src/lean.js` none (the smbls embed); one chunked mount driver and one meter per task; the chunked first render costs about a third of what it did (a resumed row goes after the previous row, one `__ref` shape, the budget is read once); `whenConnected`; `onWindowLoad` after load reaches an element built off-document; a null/false row item under `childExtends` builds nothing; building an n-row list no longer scans the parent's keys per row.
24
+ - smbls: the embed is back under its 72 KiB cap and the iife is 2.6 % smaller (terser renames locals after esbuild in the two classic-script builds; maps chained); kits stay lazy in `smbls/core`, fetch is one chunk; live sync loads only when `wantsLiveSync`; a URL-loaded dependency registers in parcel builds.
25
+ - router: the newest navigation wins over one waiting on an async guard; no lazy chunk rides along a resumed route.
26
+ - default-config: accessible Dropdown writes its attributes straight to the nodes, one tab stop per list, an `active` write re-runs only the rows that change, a key-opened menu focuses its item during the reveal; Dialog and Icon clean-ups.
27
+ - styling (scratch, css, css-in-props): one compound-value resolver; CSS colour functions (`oklch()`, `color()`, `color-mix()`, `light-dark()`, `lab()`, `lch()`, `hwb()`) pass through compound values; border props read the scheme only in literal mode.
28
+ - fetch / brender: every server render starts from an empty query cache (seeds carry every request a page makes); the local adapter stays lazy; shared route loop for `smbls build` and `smbls brender`, `smbls brender --strict`.
29
+ - cli: every command that writes to the platform prints its target and needs a typed "production" or `--yes` for production; `smbls deploy --save` saves the provider, `-y/--yes` is consent; `deploy --dry-run` no longer pushes.
30
+ - frank-audit: FA205 reports only factory calls that run at module load.
31
+
32
+ - Updated dependencies
33
+ - @symbo.ls/css@3.14.779
34
+ - @symbo.ls/default-config@3.14.787
35
+ - @symbo.ls/element@3.14.805
36
+ - @symbo.ls/scratch@3.14.789
37
+ - smbls@3.14.838
38
+ - @symbo.ls/utils@3.14.787
39
+ - @symbo.ls/fetch@3.14.665
40
+
3
41
  ## 3.14.664
4
42
 
5
43
  ### Patch Changes
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @symbo.ls/brender
2
2
 
3
- Server-side renderer and client-side hydrator for DOMQL/Symbols apps. Converts DOMQL element trees into static HTML on the server, then reconnects that HTML to live DOMQL elements in the browser — without re-rendering from scratch.
3
+ Server-side renderer for DOMQL/Symbols apps. Converts DOMQL element trees into static HTML on the server (or at build time). In the browser the app's runtime (`smbls`) either **adopts** that HTML — every element takes the server's node for its place, so nothing is drawn twice — or **replaces** it with a fresh client render. Which one is the page's choice (`adoptDom`, below): `smbls build` makes every page for adoption unless `symbols.json` says `brender: { hydrate: false }`.
4
4
 
5
5
  ## How it works
6
6
 
7
- Brender has two phases: **render** (server) and **liquidate** (browser).
7
+ Brender has two phases: **render** (server) and **boot** (browser).
8
8
 
9
9
  ### Render (DOMQL -> HTML)
10
10
 
@@ -31,15 +31,16 @@ DOMQL Source Virtual DOM Output
31
31
  }
32
32
  ```
33
33
 
34
- ### Liquidate (HTML -> DOMQL)
34
+ ### Boot (HTML -> DOMQL), in `smbls`
35
35
 
36
- In the browser, when the app JS loads:
36
+ In the browser, when the app JS loads (`smbls` `src/prerender.js`):
37
37
 
38
- 1. The pre-rendered HTML is already in the DOM — the user sees the page instantly
39
- 2. DOMQL re-creates the element tree from the same source definitions, but skips DOM creation (the nodes already exist)
40
- 3. `hydrate()` walks the DOMQL tree and the real DOM simultaneously, matching `data-br` keys
41
- 4. For each match: `element.node = domNode` and `domNode.ref = element`
42
- 5. DOMQL now owns every node — reactive updates, event handlers, and state changes work as if the page was client-rendered
38
+ 1. The pre-rendered HTML is already in the DOM — the visitor sees the page at once
39
+ 2. The runtime sees the page's mark (`<meta name="brender">`, below) and reads the element-path registry
40
+ 3. With a registry (an adoption page): the app's normal `create()` runs, but each element takes the server's node at its path — its attributes and text are written again by the client, its element children are adopted the same way. A node of another tag is not adopted (that element gets a fresh one)
41
+ 4. The adoption stays open until the first view has settled: the first route rendered (also behind a guard that waits), and no `@symbo.ls/fetch` request in flight — so a list that renders with its first data adopts the server's rows. Meanwhile the server nodes still waiting for their element stay on screen, where they were. It closes at the latest after 3 s (`hydrate: { timeout }` in the project's config), or at the visitor's first click or key press; then whatever no element adopted goes, with the server's `<style>` tags
42
+ 5. Without a registry (a replace page, or `hydrate: false` in the project's config): the server's markup and styles go and the app renders fresh
43
+ 6. Either way the recorded data answers (`data-fetch-seed`, below) are adopted by the requests that ask for them, so the client does not ask again for what the server had, and `el.context.prerendered` is `true` — a gate that hides the app until its data is in can let the server's first view count as ready
43
44
 
44
45
  ```
45
46
  Browser DOM (static) DOMQL Tree (no nodes) After hydrate()
@@ -64,7 +65,7 @@ Browser DOM (static) DOMQL Tree (no nodes) After hydrate()
64
65
  | `env.js` | `createEnv()` — linkedom virtual DOM with browser API stubs (requestAnimationFrame, history, location, etc.) |
65
66
  | `keys.js` | `resetKeys()`, `assignKeys()` — stamps data-br on DOM nodes; `mapKeysToElements()` — builds registry |
66
67
  | `metadata.js` | Re-exports from [`@symbo.ls/helmet`](../helmet/) — `extractMetadata()`, `generateHeadHtml()`, `resolveMetadata()`, `applyMetadata()` |
67
- | `prefetch.js` | `prefetchPageData()` — SSR data prefetching via DB adapter; `injectPrefetchedState()` — injects fetched data into page definitions |
68
+ | `prefetch.js` | `fetchSSRTranslations()` — a project's table/RPC labels before a render; `prefetchPageData()` / `injectPrefetchedState()` — deprecated: a page's `fetch` data outside a render (render() does not use them) |
68
69
  | `load.js` | `loadProject()` — imports a symbols/ directory; `loadAndRenderAll()` — renders every route |
69
70
  | `sitemap.js` | `generateSitemap()` — generates sitemap.xml from routes |
70
71
  | `index.js` | Re-exports everything |
@@ -128,17 +129,56 @@ import { renderPage, loadProject } from '@symbo.ls/brender'
128
129
  const data = await loadProject('/path/to/project')
129
130
  const result = await renderPage(data, '/about', {
130
131
  lang: 'ka',
131
- prefetch: true // enable SSR data prefetching
132
+ prefetch: true // fetch table/RPC labels first, wait for the page's requests
132
133
  })
133
134
 
134
- // result.html -> complete <!DOCTYPE html> page
135
- // result.route -> '/about'
136
- // result.brKeyCount -> number of data-br keys
135
+ // result.html -> complete <!DOCTYPE html> page
136
+ // result.route -> '/about'
137
+ // result.brKeyCount -> number of data-br keys
138
+ // result.diagnostics -> { failedRequests, rawLabelKeys } (see below)
137
139
  ```
138
140
 
139
- ### `prefetchPageData(data, route, options?)`
141
+ Options:
140
142
 
141
- Fetches data for a page's declarative `fetch` definitions during SSR, using the project's DB adapter. (No built-in SSR adapter currently resolves — the Supabase SSR path was removed; client-side fetch owns data loading.)
143
+ | Option | Default | What it does |
144
+ |--------|---------|--------------|
145
+ | `pathname` | the route | The address the page is rendered at. The router matches it, and `location` (canonical, og:url) reads it. A route with parameters needs one (`renderPage(data, '/:lang/about', { pathname: '/en/about' })`); the not-found page `/*` is rendered at `/404` by `smbls build`. |
146
+ | `shell` | — | A built app document (e.g. `dist/index.html`) to render INTO. |
147
+ | `preloadScripts` | `true` | With `shell`: a high-priority `modulepreload` (`preload as=script` for a classic script) in `<head>` for each script the shell boots from, so the pre-rendered images do not take its bandwidth. `async` and `nomodule` scripts are left alone. |
148
+ | `eagerImages` | `2` | Images past the first `eagerImages` in the markup get `loading="lazy"`, unless they name their own `loading`. `false` turns it off. |
149
+ | `lang` | the page's | `<html lang>`. With `shell` and a project with languages, the page's language (the root state's `lang`). |
150
+ | `prefetch` | `true` | Fetch table/RPC labels before the render and wait for the page's requests (up to 2 s). `false` fetches no labels first and waits only a 50 ms quiet period. Either way the page's data comes from its `fetch` declarations during the render. |
151
+ | `depth` | `0` | Directory depth of the output file: rebases the shell's relative script/link URLs |
152
+ | `adoptDom` | `false` | Ship the element-path registry, so the client adopts the markup instead of replacing it (`smbls build` passes it unless `brender: { hydrate: false }`) |
153
+ | `isr` | — | `{ clientScript }`: a standalone document that boots this client bundle |
154
+ | `hydrate` | `true` | With `isr`: boot the client over the markup (`false`: the legacy swap script) |
155
+ | `nonce` | — | Content-Security-Policy nonce for the inline scripts the `isr` document still has (the label seed, the legacy swap script) — a page rendered into a shell has none |
156
+ | `themeColor` | | See render.js. |
157
+
158
+ **Data and labels.** A page's declarative `fetch` runs during the render, through the fetch plugin, with the real element: its `transform(data, el, state)`, and `children` re-run on the answer. The render waits for the requests it starts. Labels: a table/RPC `polyglot.fetch` (`{ rpc }`) is fetched before the render, for every language; a FUNCTION `polyglot.fetch` is the project's own loader and runs inside the render, called by the polyglot plugin with the root element. Labels resolve in the page's language — the root state's `lang` (a router guard that reads `/en/…` sets it), else `polyglot.defaultLang`.
159
+
160
+ **Diagnostics.** `result.diagnostics` names what a page was made without: `failedRequests` (`{ url, reason }`, origin and path only — a query can carry a key) and `rawLabelKeys` (label keys the page shows raw). `null` when another render overlapped this one in the same process. `smbls build` prints them; `smbls build --strict` fails on them.
161
+
162
+ **Every render is the same render.** Each render processes the design system on a config of its own, the way the page's single boot does (`context.isolateDesignSystem`), with its own `localStorage`/`sessionStorage`, so the tenth page of a build has the theme variables, language and labels of the first. Each render also has a `@symbo.ls/fetch` query cache of its own (`context.isolateFetchCache`): a page makes every request its markup depends on itself, so its fetch seed carries every answer it shows, even when an earlier page of the build read the same key; and renders in one process — one after another or at once, of one project or of several — never share rows, requests in flight or invalidations. Its queries bind no window focus, reconnect or `refetchInterval` refetch: once its markup is taken, a render's queries leave no listener, no timer and no request behind. A process builds the framework bundle once, also when its first renders start together.
163
+
164
+ ### The page the browser gets (the client's contract)
165
+
166
+ No inline script — a strict Content-Security-Policy (`script-src 'self'`, no `'unsafe-inline'`) blocks inline scripts, never `<meta>` tags or JSON data blocks:
167
+
168
+ | Part | Where | Meaning |
169
+ |------|-------|---------|
170
+ | `<meta name="brender" content="hydrate\|replace">` | `<head>` | The page is pre-rendered; `hydrate` when it carries the registry |
171
+ | `data-br="br-N"` | each server element node | The node's key |
172
+ | `<script type="application/json" data-brender="registry">{…}</script>` | after the markup | Element path → `data-br` key (`__root` for the app's root); adoption pages only |
173
+ | `<script type="application/json" data-fetch-seed>[…]</script>` | after the markup | The anonymous GET answers the render got (`@symbo.ls/fetch`), adopted by the client request that sends exactly the same request |
174
+
175
+ The runtime also reads what pages from brender up to 3.14.664 carry — the inline `window.__BRENDER__` flag, `window.__BR_REGISTRY__`, `window.__BRENDER_HYDRATE__` — and, when a policy blocked that flag, takes a `data-br` element directly in the mount node for the mark. An smbls runtime older than this format does not know the `<meta>`: keep `smbls` and `@symbo.ls/brender` at the same release.
176
+
177
+ What is recorded for the seed: a GET whose only headers are `Accept` / `Accept-Language` — so an anonymous read of a keyed backend counts when `fetch.reads` moves its key into the query string (`reads: { query: { apikey: 'apikey' }, rpc: 'get' }`, read-only RPCs as GETs) — with an ok JSON or text answer, at most 256 KB each and 1 MB per page. Never a POST, a call with `Authorization` or another header, or anything from a render that overlapped another.
178
+
179
+ ### `prefetchPageData(data, route, options?)` (deprecated)
180
+
181
+ Fetches data for a page's declarative `fetch` definitions OUTSIDE a render, using the project's DB adapter. `render()` does not use it, and neither does the `prefetch` option: the fetch plugin loads a page's data during the render. A `transform` here receives no element. Deprecated with `injectPrefetchedState`; both stay exported for now.
142
182
 
143
183
  ```js
144
184
  import { prefetchPageData } from '@symbo.ls/brender'
@@ -161,9 +201,13 @@ const hydrated = hydrate(elementTree, { root: document.body })
161
201
  // and every domNode.ref points back to the DOMQL element
162
202
  ```
163
203
 
164
- ### `loadProject(path)`
204
+ ### `loadProject(path, options?)`
165
205
 
166
- Imports a standard `symbols/` directory structure:
206
+ `options.dir` — the symbols directory (symbols.json `dir`, default `symbols`). `options.context` — a module, relative to `path`, whose default export is the context the build's entry boots with (`{ state, components, pages, functions, designSystem, …, ...config }`, as `symbols/context.js`); everything but `app.js` then comes from it, so a public entry with fewer pages (no admin) is pre-rendered with exactly those pages.
207
+
208
+ `new URL('…', import.meta.url)` in a project file resolves against THAT file (a `file:` URL of the source asset); `smbls build` maps it to the built asset.
209
+
210
+ Without `context`, imports a standard `symbols/` directory structure:
167
211
 
168
212
  ```
169
213
  project/
@@ -223,26 +267,65 @@ smbls brender --out-dir build
223
267
  # Disable ISR client bundle
224
268
  smbls brender --no-isr
225
269
 
226
- # Disable SSR data prefetching
270
+ # Fetch no labels first and do not wait for each page's requests
227
271
  smbls brender --no-prefetch
228
272
 
273
+ # Fail when a page renders with failed requests or raw label keys
274
+ smbls brender --strict
275
+
229
276
  # Watch mode — re-renders on file changes
230
277
  smbls brender --watch
231
278
  ```
232
279
 
233
280
  Output directory defaults to `dist-brender` (or `brenderDistDir` from `symbols.json`) to avoid conflicting with the SPA's `dist/` folder.
234
281
 
235
- Param routes (e.g. `/blog/:id`) are automatically skipped — they need runtime data.
282
+ Param routes (e.g. `/blog/:id`) are skipped unless `brender.paths` lists addresses for them.
283
+
284
+ `smbls brender` and `smbls build` share one route loop: the same `brender` settings from `symbols.json` (`context`, `paths`, `exclude`, `strict`, `eagerImages`), `file:` URLs resolved into the output (a `file:` URL that names no project file fails its route), and the same diagnostics. `smbls brender` writes standalone pages in a directory layout (`/about` → `about/index.html`), each with the CSS of every page it rendered.
285
+
286
+ ### `smbls build`
287
+
288
+ With brender on (the default), `smbls build` pre-renders every static route INTO the bundler's `dist/index.html`:
289
+
290
+ - `/about` → `about.html`, `/` → `index.html`, `/*` → `404.html` rendered at `/404`. Two routes that end in one file (`/404` and `/*`) are written once — the first in page order — and the other is reported.
291
+ - The bundler's own document is kept as **`200.html`** — serve it for client-side routes (an SPA rewrite, a Worker's catch-all), never `index.html`, which is now the home page. A `200.html` already in the output (`public/`) is not replaced.
292
+ - Every `file:` URL in a page (a `new URL('…', import.meta.url)` asset) is mapped to the file the bundler emitted from the same source (found by content), or copied into the output under a content hash. A `file:` URL that names no project file fails the build.
293
+ - A page made with failed data or label requests, or with raw label keys, is reported; `smbls build --strict` (or `brender.strict`) fails the build on it.
236
294
 
237
295
  ### symbols.json
238
296
 
239
297
  ```json
240
298
  {
241
- "brender": true,
299
+ "brender": { "hydrate": true },
242
300
  "brenderDistDir": "dist-brender"
243
301
  }
244
302
  ```
245
303
 
304
+ `brender`: `true` (default for `smbls build`), `false` (no pre-render), or an object, which turns it on — `hydrate: false` makes `smbls build` ship replace pages (no registry; the client renders fresh).
305
+
306
+ `brender` can be an object (still on):
307
+
308
+ ```json
309
+ {
310
+ "brender": {
311
+ "context": "symbols/siteContext.js",
312
+ "exclude": ["/admin*"],
313
+ "paths": { "/:lang": ["/en"], "/:lang/about": ["/en/about"] },
314
+ "strict": true,
315
+ "eagerImages": 2
316
+ }
317
+ }
318
+ ```
319
+
320
+ | Key | |
321
+ |---|---|
322
+ | `context` | The module the build's entry boots with (see `loadProject`). |
323
+ | `exclude` | Page keys not pre-rendered; a trailing `*` matches every key that starts with what precedes it. A page can also say `prerender: false`. |
324
+ | `paths` | Route with parameters → the addresses to render it at (`/en/about` → `en/about.html`). Each must fit its route. |
325
+ | `strict` | As `--strict`. |
326
+ | `eagerImages` | As renderPage's. |
327
+ | `hydrate` | `true` (default): every page ships its element-path registry and the client adopts it; `false`: replace pages (no registry; the client renders fresh). |
328
+
246
329
  ## Examples
247
330
 
248
331
  The `examples/` directory contains runnable experiments. Copy a project's source into `examples/` first (gitignored), then run:
@@ -339,7 +422,7 @@ The `data-br` attribute is the bridge between server and client. The contract:
339
422
  3. **Element nodes only**: Only `nodeType === 1` (elements) get keys, not text nodes or comments
340
423
  4. **Bidirectional**: After hydration, `element.node` and `node.ref` point to each other
341
424
 
342
- This means the server and client don't need to exchange the registry — as long as both run the same DOMQL source, the keys will match. The registry JSON is exported for debugging and inspection only.
425
+ The client finds an element's node through the registry the page carries (element path → key): an element whose node never reached the DOM (an `if` that was false, a text node) has no key, so keys alone do not line up with elements.
343
426
 
344
427
  ## Architecture notes
345
428
 
@@ -351,7 +434,7 @@ This means the server and client don't need to exchange the registry — as long
351
434
  - `createEnv()` sets `globalThis.window/document/Node/HTMLElement` because `@domql/utils` `isDOMNode` uses `instanceof` checks against global constructors
352
435
  - CSS is extracted from the atomic CSS engine's generated rules
353
436
  - `onRender` callbacks that do network requests or call `s.update()` will error during SSR — this is expected and harmless since the HTML is already produced before those callbacks fire
354
- - Data prefetching (`prefetch.js`) walks page definitions to find `fetch` declarations, then executes them against the DB adapter before rendering. Fetched data is injected into page state so components render with real content
437
+ - Data comes from the fetch plugin during the render (with the real element); the render waits for its requests. `prefetch.js` keeps the deprecated `prefetchPageData` for callers that want a page's data outside a render
355
438
 
356
439
  ## Theme support
357
440
 
package/dist/esm/env.js CHANGED
@@ -1 +1 @@
1
- import{parseHTML as c}from"linkedom";const a=new WeakSet;class h{static[Symbol.hasInstance](e){return a.has(e)}}const u=n=>{let e=Object.getPrototypeOf(n.createElement("select")),l;for(;e&&!(l=Object.getOwnPropertyDescriptor(e,"value"));)e=Object.getPrototypeOf(e);!e||!l||!l.get||l.set||Object.defineProperty(e,"value",{configurable:!0,enumerable:l.enumerable,get:l.get,set(r){const o=r==null?"":String(r);let t=!1;for(const s of this.querySelectorAll("option")){const i=s.hasAttribute("value")?s.getAttribute("value"):s.textContent;!t&&i===o?(s.setAttribute("selected",""),t=!0):s.removeAttribute("selected")}}})},b=(n="<!DOCTYPE html><html><head></head><body></body></html>")=>{const{window:e,document:l}=c(n);e.requestAnimationFrame||(e.requestAnimationFrame=o=>{const t=setTimeout(o,0);return t?.unref&&t.unref(),t}),e.cancelAnimationFrame||(e.cancelAnimationFrame=o=>clearTimeout(o)),e.history||(e.history={pushState:()=>{},replaceState:()=>{},state:null}),e.location||(e.location={pathname:"/",search:"",hash:"",origin:"http://localhost",protocol:"http:",host:"localhost",hostname:"localhost",port:"",href:"http://localhost/"}),e.URL||(e.URL=URL),e.scrollTo||(e.scrollTo=()=>{});const r=()=>{const o={};return{getItem:t=>o[t]??null,setItem:(t,s)=>{o[t]=String(s)},removeItem:t=>{delete o[t]},clear:()=>{for(const t in o)delete o[t]},get length(){return Object.keys(o).length},key:t=>Object.keys(o)[t]??null}};return e.localStorage||(e.localStorage=r()),e.sessionStorage||(e.sessionStorage=r()),globalThis.localStorage||(globalThis.localStorage=e.localStorage),globalThis.sessionStorage||(globalThis.sessionStorage=e.sessionStorage),u(l),e.MutationObserver||(e.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=e,globalThis.document=l,globalThis.Node=e.Node||globalThis.Node,globalThis.Element=e.Element||globalThis.Element,globalThis.HTMLElement=e.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=e.MutationObserver,a.add(e),e.constructor&&e.constructor!==Object?globalThis.Window=e.constructor:(typeof globalThis.Window!="function"||globalThis.Window===Object)&&(globalThis.Window=h),{window:e,document:l}};export{b as createEnv};
1
+ import{parseHTML as h}from"linkedom";const a=new WeakSet;class u{static[Symbol.hasInstance](t){return a.has(t)}}const b=o=>{let t=Object.getPrototypeOf(o.createElement("select")),e;for(;t&&!(e=Object.getOwnPropertyDescriptor(t,"value"));)t=Object.getPrototypeOf(t);!t||!e||!e.get||e.set||Object.defineProperty(t,"value",{configurable:!0,enumerable:e.enumerable,get:e.get,set(l){const r=l==null?"":String(l);let s=!1;for(const n of this.querySelectorAll("option")){const c=n.hasAttribute("value")?n.getAttribute("value"):n.textContent;!s&&c===r?(n.setAttribute("selected",""),s=!0):n.removeAttribute("selected")}}})},i=()=>{const o={};return{getItem:t=>o[t]??null,setItem:(t,e)=>{o[t]=String(e)},removeItem:t=>{delete o[t]},clear:()=>{for(const t in o)delete o[t]},get length(){return Object.keys(o).length},key:t=>Object.keys(o)[t]??null}},m=(o="<!DOCTYPE html><html><head></head><body></body></html>")=>{const t={location:{pathname:"/",search:"",hash:"",origin:"http://localhost",protocol:"http:",host:"localhost",hostname:"localhost",port:"",href:"http://localhost/"},localStorage:i(),sessionStorage:i(),history:{pushState:()=>{},replaceState:()=>{},state:null}},{window:e,document:l}=h(o,t);return e.requestAnimationFrame||(e.requestAnimationFrame=r=>{const s=setTimeout(r,0);return s?.unref&&s.unref(),s}),e.cancelAnimationFrame||(e.cancelAnimationFrame=r=>clearTimeout(r)),e.URL||(e.URL=URL),e.scrollTo||(e.scrollTo=()=>{}),globalThis.localStorage=t.localStorage,globalThis.sessionStorage=t.sessionStorage,globalThis.history||(globalThis.history=t.history),b(l),e.MutationObserver||(e.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=e,globalThis.document=l,globalThis.Node=e.Node||globalThis.Node,globalThis.Element=e.Element||globalThis.Element,globalThis.HTMLElement=e.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=e.MutationObserver,a.add(e),e.constructor&&e.constructor!==Object?globalThis.Window=e.constructor:(typeof globalThis.Window!="function"||globalThis.Window===Object)&&(globalThis.Window=u),{window:e,document:l}};export{m as createEnv};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as m,loadAndRenderAll as a}from"./load.js";import{render as p,renderElement as n,renderRoute as d,renderPage as i,resetGlobalCSSCache as l,getAccumulatedEmotionCSS as c,replaceEmotionCSS as f,adoptionScripts as s}from"./render.js";import{extractMetadata as S,generateHeadHtml as g}from"./metadata.js";import{collectBrNodes as h,hydrate as E}from"./hydrate.js";import{generateSitemap as u}from"./sitemap.js";import{prefetchPageData as y,injectPrefetchedState as C}from"./prefetch.js";import{composeIntoShell as P}from"./shell.js";var D={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:m,loadAndRenderAll:a,render:p,renderElement:n,renderRoute:d,renderPage:i,resetGlobalCSSCache:l,getAccumulatedEmotionCSS:c,replaceEmotionCSS:f,extractMetadata:S,generateHeadHtml:g,collectBrNodes:h,hydrate:E,generateSitemap:u,prefetchPageData:y,injectPrefetchedState:C,composeIntoShell:P,adoptionScripts:s};export{s as adoptionScripts,t as assignKeys,h as collectBrNodes,P as composeIntoShell,e as createEnv,D as default,S as extractMetadata,g as generateHeadHtml,u as generateSitemap,c as getAccumulatedEmotionCSS,E as hydrate,C as injectPrefetchedState,a as loadAndRenderAll,m as loadProject,o as mapKeysToElements,y as prefetchPageData,p as render,n as renderElement,i as renderPage,d as renderRoute,f as replaceEmotionCSS,l as resetGlobalCSSCache,r as resetKeys};
1
+ import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as m,loadAndRenderAll as a}from"./load.js";import{render as p,renderElement as n,renderRoute as d,renderPage as i,resetGlobalCSSCache as l,getAccumulatedEmotionCSS as c,replaceEmotionCSS as f,adoptionScripts as s,prerenderParts as S}from"./render.js";import{extractMetadata as g,generateHeadHtml as h}from"./metadata.js";import{collectBrNodes as E,hydrate as P}from"./hydrate.js";import{generateSitemap as u}from"./sitemap.js";import{prefetchPageData as y,injectPrefetchedState as C}from"./prefetch.js";import{composeIntoShell as x}from"./shell.js";var G={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:m,loadAndRenderAll:a,render:p,renderElement:n,renderRoute:d,renderPage:i,resetGlobalCSSCache:l,getAccumulatedEmotionCSS:c,replaceEmotionCSS:f,extractMetadata:g,generateHeadHtml:h,collectBrNodes:E,hydrate:P,generateSitemap:u,prefetchPageData:y,injectPrefetchedState:C,composeIntoShell:x,adoptionScripts:s,prerenderParts:S};export{s as adoptionScripts,t as assignKeys,E as collectBrNodes,x as composeIntoShell,e as createEnv,G as default,g as extractMetadata,h as generateHeadHtml,u as generateSitemap,c as getAccumulatedEmotionCSS,P as hydrate,C as injectPrefetchedState,a as loadAndRenderAll,m as loadProject,o as mapKeysToElements,y as prefetchPageData,S as prerenderParts,p as render,n as renderElement,i as renderPage,d as renderRoute,f as replaceEmotionCSS,l as resetGlobalCSSCache,r as resetKeys};
package/dist/esm/load.js CHANGED
@@ -1 +1,2 @@
1
- import{resolve as x,join as s}from"path";import{existsSync as M,unlinkSync as S}from"fs";import{tmpdir as L}from"os";import{randomBytes as k}from"crypto";const t=async r=>{if(!M(r))return null;let e;try{e=await import("esbuild")}catch{try{return await import(r)}catch{return null}}const o=s(L(),`brender_${k(8).toString("hex")}.mjs`);try{return await e.build({entryPoints:[r],bundle:!0,format:"esm",platform:"node",outfile:o,write:!0,logLevel:"silent",external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty"]}),await import(`file://${o}`)}catch{try{return await import(r)}catch{return null}}finally{try{S(o)}catch{}}},v=async r=>{const e=x(r,"symbols"),[o,n,l,a,d,c,u,p,m,f,h,y,g]=await Promise.all([t(s(e,"app.js")),t(s(e,"state.js")),t(s(e,"config.js")),t(s(e,"dependencies.js")),t(s(e,"components","index.js")),t(s(e,"snippets","index.js")),t(s(e,"pages","index.js")),t(s(e,"functions","index.js")),t(s(e,"methods","index.js")),t(s(e,"designSystem","index.js")),t(s(e,"files","index.js")),t(s(e,"assets","index.js")).catch(()=>null),t(s(e,"sharedLibraries.js")).catch(()=>null)]),i={app:{...o?.default||{}},state:{...n?.default||{}},dependencies:{...a?.default||{}},components:{...d||{}},snippets:{...c||{}},pages:{...u?.default||{}},functions:{...p||{}},methods:{...m||{}},designSystem:{...f?.default||{}},files:{...h?.default||{}},assets:{...y?.default||{}},config:{...l?.default||{}},sharedLibraries:g?.default||[]};if(i.sharedLibraries.length){const{resolveSharedLibraries:b,mergeSharedLibraries:j}=await import("@symbo.ls/utils");i.sharedLibraries.some(w=>typeof w=="string")&&(i.sharedLibraries=await b(i.sharedLibraries)),j(i,i.sharedLibraries)}return i},D=async(r,e)=>{const o=await v(r),n=o.pages||{},l=Object.keys(n),a={};for(const d of l)a[d]=await e(o,{route:d});return a};export{D as loadAndRenderAll,v as loadProject};
1
+ import{resolve as l,join as o,extname as _,sep as c}from"path";import{existsSync as S,readFileSync as E,unlinkSync as $}from"fs";import{tmpdir as A}from"os";import{randomBytes as T}from"crypto";import{pathToFileURL as O}from"url";const R=/\bimport\.meta\.url\b/g,k=/\bimport\.meta\.url\b/,v={".js":"js",".mjs":"js",".cjs":"js",".jsx":"jsx",".ts":"ts",".mts":"ts",".tsx":"tsx"},U={name:"brender-source-import-meta-url",setup(t){t.onLoad({filter:/\.[cm]?[jt]sx?$/},s=>{if(s.path.includes(`${c}node_modules${c}`))return;const e=E(s.path,"utf8");return k.test(e)?{contents:`const __brenderImportMetaUrl = ${JSON.stringify(O(s.path).href)};
2
+ `+e.replace(R,"__brenderImportMetaUrl"),loader:v[_(s.path)]||"js"}:void 0})}},n=async(t,{strict:s=!1}={})=>{if(!S(t)){if(s)throw new Error(`${t} does not exist`);return null}let e;try{e=await import("esbuild")}catch{try{return await import(t)}catch{return null}}const a=o(A(),`brender_${T(8).toString("hex")}.mjs`);try{return await e.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:a,write:!0,logLevel:"silent",plugins:[U],external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty"]}),await import(`file://${a}`)}catch(r){try{return await import(t)}catch{if(s)throw r;return null}}finally{try{$(a)}catch{}}},I=["state","dependencies","components","snippets","pages","functions","methods","designSystem","files","assets"],C=async(t,s)=>{const e=l(t,s);let a;try{a=await n(e,{strict:!0})}catch(i){throw new Error(`brender: cannot load the context module ${s} (${i.message})`)}const r=a&&(a.default||a);if(!r||typeof r!="object")throw new Error(`brender: the context module ${s} has no default export object`);const d={...r};for(const i of I)r[i]&&typeof r[i]=="object"&&(d[i]={...r[i]});return d.sharedLibraries=Array.isArray(r.sharedLibraries)?r.sharedLibraries:[],d},u=async t=>{if(t.sharedLibraries.length){const{resolveSharedLibraries:s,mergeSharedLibraries:e}=await import("@symbo.ls/utils");t.sharedLibraries.some(r=>typeof r=="string")&&(t.sharedLibraries=await s(t.sharedLibraries)),e(t,t.sharedLibraries)}return t},F=async(t,s={})=>{const e=l(t,s.dir||"symbols");if(s.context){const[M,L]=await Promise.all([n(o(e,"app.js")),C(t,s.context)]);return u({app:{...M?.default||{}},...L})}const[a,r,d,i,p,m,f,h,b,y,j,x,g]=await Promise.all([n(o(e,"app.js")),n(o(e,"state.js")),n(o(e,"config.js")),n(o(e,"dependencies.js")),n(o(e,"components","index.js")),n(o(e,"snippets","index.js")),n(o(e,"pages","index.js")),n(o(e,"functions","index.js")),n(o(e,"methods","index.js")),n(o(e,"designSystem","index.js")),n(o(e,"files","index.js")),n(o(e,"assets","index.js")).catch(()=>null),n(o(e,"sharedLibraries.js")).catch(()=>null)]),w={app:{...a?.default||{}},state:{...r?.default||{}},dependencies:{...i?.default||{}},components:{...p||{}},snippets:{...m||{}},pages:{...f?.default||{}},functions:{...h||{}},methods:{...b||{}},designSystem:{...y?.default||{}},files:{...j?.default||{}},assets:{...x?.default||{}},config:{...d?.default||{}},sharedLibraries:g?.default||[]};return u(w)},z=async(t,s)=>{const e=await F(t),a=e.pages||{},r=Object.keys(a),d={};for(const i of r)d[i]=await s(e,{route:i});return d};export{z as loadAndRenderAll,F as loadProject,U as sourceUrlPlugin};
@@ -1 +1 @@
1
- const o=t=>typeof t=="function",b=t=>Array.isArray(t),g=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),j=(t,r)=>{if(t){if(o(t))try{return t({state:r||{},call:()=>{},__ref:{}},r||{})}catch{return}return t}},k=(t,r)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const e=o(t)?null:{...t};return!e||(e.method||(e.method="select"),o(e.params)&&(e.params=j(e.params,r)),e.method==="insert"||e.method==="update"||e.method==="upsert"||e.method==="delete")||e.on&&e.on!=="create"?null:e},S=(t,r="")=>{if(!t||typeof t!="object")return[];if(o(t))return[];const e=[],s=t.state||{};if(t.fetch){const n=b(t.fetch)?t.fetch:[t.fetch];for(const c of n){const a=k(c,s);a&&e.push({config:a,stateKey:a.as,path:r,elementState:s})}}for(const n in t)n==="fetch"||n==="state"||n==="props"||n==="attr"||n==="on"||n==="define"||n==="childExtends"||n==="childProps"||n==="childrenAs"||n.charAt(0)>="A"&&n.charAt(0)<="Z"&&g(t[n])&&e.push(...S(t[n],r?`${r}.${n}`:n));return e},M=["rest","local"],w=new WeakMap,A=async t=>{if(!t)return null;if(g(t)&&(o(t.select)||o(t.rpc)))return t;const r=typeof t=="string"?{adapter:t}:t;if(!g(r)||typeof r.adapter!="string")return null;if(w.has(r))return w.get(r);const e=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(o(s.hasAdapter)?s.hasAdapter(r.adapter):M.includes(r.adapter)))return null;try{return await s.resolveDb(r)}catch(c){return console.warn(`[brender] SSR adapter "${r.adapter}" unavailable: ${c.message}`),null}})();return w.set(r,e),e},P=async(t,r)=>{try{const{method:e,from:s,params:n,transform:c,limit:a,offset:l,order:u,single:h,headers:d,baseUrl:i}=r;let f;if(e==="rpc"){if(!o(t.rpc))return null;f=await t.rpc({from:s,params:n,headers:d,baseUrl:i})}else{if(!o(t.select))return null;f=await t.select({from:s,select:r.select,params:n,limit:a,offset:l,order:u,single:h,headers:d,baseUrl:i})}let p=f?.data??null;if(f?.error)return null;if(p&&c&&o(c))try{p=c(p)}catch{}return p}catch{return null}},x=async(t,r="/",e={})=>{const n=(t.pages||{})[r];if(!n)return new Map;const c=t.config||t.settings||{},a=c.fetch||t.fetch||c.db||t.db;if(!a)return new Map;const l=await A(a);if(!l)return new Map;const u=S(n);if(!u.length)return new Map;const h=new Map,d=await Promise.allSettled(u.map(async({config:i,stateKey:f,path:p})=>{const y=await P(l,i);if(y!==null){const m=h.get(p)||{};f?m[f]=y:g(y)&&Object.assign(m,y),h.set(p,m)}}));return h},E=async t=>{const r=t.config||{},e=r.polyglot||t.polyglot;if(!e?.fetch)return null;const s=r.fetch||t.fetch||r.db||t.db;if(!s)return null;const n=await A(s);if(!n)return null;const c=e.fetch,a=c.rpc||c.from||"get_translations_if_changed",l=e.languages||[e.defaultLang||"en"],u={},h=await Promise.allSettled(l.map(async d=>{try{if(!o(n.rpc))return;const i=await n.rpc({from:a,params:{p_lang:d,p_cached_version:0}});if(i.error||!i.data)return;const f=i.data;f.translations&&(u[d]=f.translations)}catch(i){console.warn("[brender] SSR translation fetch failed:",i.message)}}));return Object.keys(u).length?u:null},_=(t,r)=>{if(!(!t||typeof t!="object")){for(const e in t)if(!(e==="state"||e==="fetch"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs")&&e.charAt(0)>="A"&&e.charAt(0)<="Z"&&g(t[e])){const s=t[e],n=s.state&&typeof s.state=="object"?{...r,...s.state}:r;if(o(s.children))try{const c={state:n,call:l=>{if(l==="getActiveLang"||l==="getLang")return n?.lang||"ka";if(l==="polyglot")return arguments[1]||""},__ref:{}},a=s.children(c,n);b(a)&&a.length>0&&(s.children=a)}catch{}_(s,n)}}},D=(t,r)=>{if(!(!r||!r.size))for(const[e,s]of r){let n=t;if(e){const c=e.split(".");for(const a of c){if(!n||typeof n!="object")break;n=n[a]}}n&&typeof n=="object"&&((!n.state||typeof n.state!="object")&&(n.state={}),Object.assign(n.state,s),_(n,n.state))}};export{A as createSSRAdapter,E as fetchSSRTranslations,D as injectPrefetchedState,x as prefetchPageData};
1
+ const a=t=>typeof t=="function",S=t=>Array.isArray(t),g=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),_=(t,r)=>{if(t){if(a(t))try{return t({state:r||{},call:()=>{},__ref:{}},r||{})}catch{return}return t}},j=(t,r)=>{if(!t)return null;if(typeof t=="string")return{from:t,method:"select"};const n=a(t)?null:{...t};return!n||(n.method||(n.method="select"),a(n.params)&&(n.params=_(n.params,r)),n.method==="insert"||n.method==="update"||n.method==="upsert"||n.method==="delete")||n.on&&n.on!=="create"?null:n},b=(t,r="")=>{if(!t||typeof t!="object")return[];if(a(t))return[];const n=[],s=t.state||{};if(t.fetch){const e=S(t.fetch)?t.fetch:[t.fetch];for(const c of e){const o=j(c,s);o&&n.push({config:o,stateKey:o.as,path:r,elementState:s})}}for(const e in t)e==="fetch"||e==="state"||e==="props"||e==="attr"||e==="on"||e==="define"||e==="childExtends"||e==="childProps"||e==="childrenAs"||e.charAt(0)>="A"&&e.charAt(0)<="Z"&&g(t[e])&&n.push(...b(t[e],r?`${r}.${e}`:e));return n},M=["rest","local"],w=new WeakMap,A=async t=>{if(!t)return null;if(g(t)&&(a(t.select)||a(t.rpc)))return t;const r=typeof t=="string"?{adapter:t}:t;if(!g(r)||typeof r.adapter!="string")return null;if(w.has(r))return w.get(r);const n=(async()=>{let s;try{s=await import("@symbo.ls/fetch")}catch{return null}if(!(a(s.hasAdapter)?s.hasAdapter(r.adapter):M.includes(r.adapter)))return null;try{return await s.resolveDb(r)}catch(c){return console.warn(`[brender] SSR adapter "${r.adapter}" unavailable: ${c.message}`),null}})();return w.set(r,n),n},k=async(t,r)=>{try{const{method:n,from:s,params:e,transform:c,limit:o,offset:p,order:f,single:h,headers:d,baseUrl:l}=r;let i;if(n==="rpc"){if(!a(t.rpc))return null;i=await t.rpc({from:s,params:e,headers:d,baseUrl:l})}else{if(!a(t.select))return null;i=await t.select({from:s,select:r.select,params:e,limit:o,offset:p,order:f,single:h,headers:d,baseUrl:l})}let u=i?.data??null;if(i?.error)return null;if(u&&c&&a(c))try{u=c(u)}catch{}return u}catch{return null}},P=async(t,r="/",n={})=>{const e=(t.pages||{})[r];if(!e)return new Map;const c=t.config||t.settings||{},o=c.fetch||t.fetch||c.db||t.db;if(!o)return new Map;const p=await A(o);if(!p)return new Map;const f=b(e);if(!f.length)return new Map;const h=new Map,d=await Promise.allSettled(f.map(async({config:l,stateKey:i,path:u})=>{const y=await k(p,l);if(y!==null){const m=h.get(u)||{};i?m[i]=y:g(y)&&Object.assign(m,y),h.set(u,m)}}));return h},x=async t=>{const r=t.config||{},n=r.polyglot||t.polyglot;if(!n?.fetch||typeof n.fetch=="function")return null;const s=r.fetch||t.fetch||r.db||t.db;if(!s)return null;const e=await A(s);if(!e)return null;const c=n.fetch,o=c.rpc||c.from||"get_translations_if_changed",p=n.languages||[n.defaultLang||"en"],f={},h=await Promise.allSettled(p.map(async d=>{try{if(!a(e.rpc))return;const l=await e.rpc({from:o,params:{p_lang:d,p_cached_version:0}});if(l.error||!l.data)return;const i=l.data;i.translations&&(f[d]=i.translations)}catch(l){console.warn("[brender] SSR translation fetch failed:",l.message)}}));return Object.keys(f).length?f:null},D=(t,r)=>{if(!(!r||!r.size))for(const[n,s]of r){let e=t;if(n){const c=n.split(".");for(const o of c){if(!e||typeof e!="object")break;e=e[o]}}e&&typeof e=="object"&&((!e.state||typeof e.state!="object")&&(e.state={}),Object.assign(e.state,s))}};export{A as createSSRAdapter,x as fetchSSRTranslations,D as injectPrefetchedState,P as prefetchPageData};
@@ -1,22 +1,21 @@
1
- import{resolve as u,join as ke,dirname as v}from"path";import{existsSync as d,unlinkSync as we,readFileSync as V,realpathSync as xe}from"fs";import{resolvePackageEntry as _e}from"./packageEntry.js";import{tmpdir as je}from"os";import{randomBytes as ve}from"crypto";import{createRequire as oe}from"module";import{createEnv as ie}from"./env.js";import{resetKeys as ae,assignKeys as ce,mapKeysToElements as fe}from"./keys.js";import{extractMetadata as ne,generateHeadHtml as Te}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as Ee}from"./shell.js";import{prefetchPageData as Le,injectPrefetchedState as Ce,fetchSSRTranslations as qe}from"./prefetch.js";import{createEarlySeedScript as $e}from"@symbo.ls/fetch";import{headerEntries as Pe}from"@symbo.ls/fetch/rest";import{jsonForScript as De}from"@symbo.ls/utils";let Q=null;const Ae=async()=>{if(Q)return Q;try{return Q=(await import("@symbo.ls/funcql")).funcqlPlugin,Q}catch{return null}};import"linkedom";import{reset as Me}from"@symbo.ls/css";const se=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const l of o){if(n==null||typeof n!="object")return;n=n[l]}return n},Oe=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,l=t||n?.defaultLang||"en";if(n?.translations){const c=n.translations[l];if(c){const r=se(c,e);if(r!==void 0)return r}}const a=this?.state?.root||o?.state?.root;if(a?.translations){const c=a.translations[l];if(c){const r=se(c,e);if(r!==void 0)return r}}const p=n?.defaultLang||"en";if(p!==l&&n?.translations){const c=n.translations[p];if(c){const r=se(c,e);if(r!==void 0)return r}}return e},pe=function(){const e=this?.context;return this?.state?.root?.lang||e?.polyglot?.defaultLang||"en"},L=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(const l of e)n.push(typeof l=="object"&&l!==null?L(l,t):l);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const l=e[n];o[n]=typeof l=="object"&&l!==null?L(l,t):l}return o};let M=null;try{import.meta.url&&(M=oe(import.meta.url))}catch{}const Ie=()=>{if(!import.meta.url||!M)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:r=>r};const e=xe(new URL(".",import.meta.url).pathname),t=u(e,"../..");if(d(u(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const r=M.resolve("smbls/package.json");n=v(r)}catch{let r=e;for(;r!==v(r);){const s=u(r,"node_modules","smbls");if(d(u(s,"package.json"))){n=s;break}r=v(r)}}let l=M;if(n)try{l=oe(u(n,"package.json"))}catch{}let a,p=process.cwd();for(;p!==v(p);){if(d(u(p,"package.json"))){a=p;break}p=v(p)}let c=l;if(a)try{c=oe(u(a,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:a,_smblsRequire:l,_projectRequire:c}},K=(e,t)=>{const o=e.isMonorepo?[M]:[e._smblsRequire,e._projectRequire,M].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},_t=(e,t,...o)=>{if(e.isMonorepo)return u(e.monorepoRoot,"packages",t,...o);const n=K(e,`${t}/package.json`);return n?u(v(n),...o):null},jt=(e,t,...o)=>{if(e.isMonorepo)return u(e.monorepoRoot,"plugins",t,...o);const n=K(e,`@symbo.ls/${t}/package.json`);return n?u(v(n),...o):null},re=(e,t,...o)=>{if(e.isMonorepo){for(const l of["packages","plugins"]){const a=u(e.monorepoRoot,l,t,...o);if(d(a))return a}return null}const n=K(e,`@symbo.ls/${t}/package.json`);return n?u(v(n),...o):null},ue=(e,t,...o)=>{if(e.isMonorepo)return u(e.monorepoRoot,"packages","domql","packages",t,...o);const n=K(e,`@symbo.ls/${t}/package.json`);return n?u(v(n),...o):null};let X=null;const me="smbls/ssr",Fe=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Ne=async()=>{if(X)return X;const e=Ie();let t;if(M&&e.isMonorepo)t=u(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let c;try{return X=await Fe(),X}catch(s){c=s}if(!M)throw new Error(`brender: ${me} is not available in this bundled runtime (${c.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const r=e.smblsRoot&&u(e.smblsRoot,"src","createDomql.js");if(r&&d(r))t=r;else throw new Error(`brender: cannot load ${me} (${c.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),n=ke(je(),`br_createDomql_${ve(6).toString("hex")}.mjs`),l=_e,a={name:"workspace-resolve",setup(c){c.onResolve({filter:/^smbls/},r=>{const s=r.path.replace(/^smbls\/?/,""),f=e.isMonorepo?u(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!f)return;if(!s){const h=l(f);return h?{path:h}:void 0}const i=u(f,s);if(d(i))return{path:i};if(d(i+".js"))return{path:i+".js"};const m=u(i,"index.js");if(d(m))return{path:m}}),c.onResolve({filter:/^domql$/},r=>{if(e.isMonorepo){const s=u(e.monorepoRoot,"packages","domql","src","index.js");if(d(s))return{path:s};const f=u(e.monorepoRoot,"packages","domql","index.js");if(d(f))return{path:f}}else try{const s=_require.resolve("domql/package.json"),f=l(v(s));if(f)return{path:f}}catch{}}),c.onResolve({filter:/^@symbo\.ls\//},r=>{const s=r.path.replace("@symbo.ls/","");if(s==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const i of["packages","plugins"]){const m=u(e.monorepoRoot,i,s,"src","index.js");if(d(m))return{path:m};const h=u(e.monorepoRoot,i,s,"index.js");if(d(h))return{path:h}}const f=u(e.monorepoRoot,"packages","default-config","blank","index.js");if(s==="default-config"&&d(f))return{path:f}}else{const f=re(e,s,"src","index.js");if(f&&d(f))return{path:f};const i=re(e,s,"index.js");if(i&&d(i))return{path:i};if(s==="default-config"){const m=re(e,"default-config","blank","index.js");if(m&&d(m))return{path:m}}}}),c.onResolve({filter:/^@domql\//},r=>{const s=r.path.replace("@symbo.ls/","");if(e.isMonorepo){const f=u(e.monorepoRoot,"packages","domql","packages",s,"src","index.js");if(d(f))return{path:f};const i=u(e.monorepoRoot,"packages","domql","packages",s,"index.js");if(d(i))return{path:i}}else{const f=ue(e,s,"src","index.js");if(f&&d(f))return{path:f};const i=ue(e,s,"index.js");if(i&&d(i))return{path:i}}}),c.onResolve({filter:/^css-in-props/},r=>{let s;if(e.isMonorepo)s=u(e.monorepoRoot,"packages","css-in-props");else{const m=K(e,"css-in-props/package.json");m&&(s=v(m))}if(!s)return;const f=r.path.replace(/^css-in-props\/?/,"");if(f){const m=u(s,f),h=u(m,"index.js");if(d(h))return{path:h};if(d(m+".js"))return{path:m+".js"};if(d(m))return{path:m}}const i=l(s);if(i)return{path:i}}),c.onResolve({filter:/^@emotion\//},r=>{let s;if(e.isMonorepo)s=u(e.monorepoRoot,"node_modules",r.path);else{const f=K(e,`${r.path}/package.json`);if(!f)return;s=v(f)}if(d(s)){const f=u(s,"package.json");if(d(f))try{const i=JSON.parse(V(f,"utf8")),m=i.module||i.main||"dist/emotion-css.esm.js";return{path:u(s,m)}}catch{}return{path:s}}}),c.onResolve({filter:/\.json$/},r=>{if(r.resolveDir){const s=u(r.resolveDir,r.path);if(d(s))return{path:s}}}),c.onLoad({filter:/smbls\/.*options\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("options.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),c.onLoad({filter:/smbls\/.*init\.js$/},async r=>{if(!r.path.includes("smbls/")||!r.path.endsWith("init.js"))return;let s=V(r.path,"utf8");return s=s.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:s,loader:"js"}}),c.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),c.onLoad({filter:/smbls\/src\/router\.js$/},async r=>{let s=V(r.path,"utf8");return s=s.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:s,loader:"js"}}),c.onLoad({filter:/fetchOnCreate\.js$/},async r=>{if(!r.path.includes("smbls/"))return;let s=V(r.path,"utf8");return s=s.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:s,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[a],nodePaths:e.isMonorepo?[u(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[u(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[u(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[u(e.smblsRoot,"..","..","node_modules")]:[]].filter(c=>d(c)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const p=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{we(n)}catch{}return X=p,p},Be={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},He=(e,t)=>{const o={},n=l=>{const a=l&&l.__ref;if(a){if(a.__brKey){const p=t(l);o[p===""?"__root":p]=a.__brKey}if(a.__children)for(const p of a.__children)n(l[p])}};return n(e),o},Je=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let G=0;const ge=Symbol.for("brender.fetchTracked"),de=()=>G,Ke=256*1024,Ge=1024*1024,We=new Set(["accept-language","accept"]);let le=0,D=null;const Ue=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",l=n?t.url:String(t),a=String(o&&o.method||n&&t.method||"GET").toUpperCase(),p={},c=r=>{if(!r)return;const s=!Array.isArray(r)&&typeof r.entries!="function";for(const[f,i]of Pe(r))s&&i==null||(p[String(f).toLowerCase()]=String(i))};return n&&c(t.headers),o&&c(o.headers),{url:l,method:a,headers:p}},Ye=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const l=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(l))return;let a;try{a=o.clone()}catch{return}n(a.text().then(p=>{e.tainted||p.length>Ke||e.bytes+p.length>Ge||(e.bytes+=p.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:l,body:p}))},()=>{}))},ze=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[ge])return;const t=function(...o){G++;let n=!1;const l=()=>{n||(n=!0,G--)},a=s=>{G++,s.then(()=>{G--},()=>{G--})},p=D&&!D.tainted?D:null;let c=null;if(p)try{c=Ue(o),(c.method!=="GET"||!/^https?:/i.test(c.url)||Object.keys(c.headers).some(s=>!We.has(s)))&&(c=null)}catch{c=null}let r;try{r=e.apply(this,o)}catch(s){throw l(),s}return r&&typeof r.then=="function"?r.then(s=>{c&&Ye(p,c,s,a),l()},l):l(),r};t[ge]=!0,globalThis.fetch=t},Ve=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=De(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
- `+$e(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},he=async(e,t={})=>{const{route:o="/",pathname:n,state:l,context:a,prefetch:p=!1}=t,c=n||o,r=globalThis.location,s=globalThis.window;(!globalThis.location||globalThis.location.pathname!==c)&&(globalThis.location={pathname:c,href:c,search:"",hash:"",origin:""}),globalThis.window||(globalThis.window={location:globalThis.location});let f;if(p)try{const g=e.pages||{};f={...g};const y=await Le(e,o);if(y.size){const P=JSON.parse(JSON.stringify(g[o],(_,A)=>{if(typeof A!="function")return A})),J=(_,A)=>{if(!(!_||!A))for(const E in _)typeof _[E]=="function"?A[E]=_[E]:typeof _[E]=="object"&&_[E]!==null&&!Array.isArray(_[E])&&typeof A[E]=="object"&&A[E]!==null&&J(_[E],A[E])};J(g[o],P),Ce(P,y),f[o]=P}}catch(g){console.error("[brender] Prefetch error:",g),f=e.pages}let i;if(p)try{i=await qe(e)}catch(g){console.warn("[brender] SSR translation fetch failed:",g.message)}r!==void 0?globalThis.location=r:delete globalThis.location,s!==void 0?globalThis.window=s:delete globalThis.window;const{window:m,document:h}=ie(),w=h.body;m.location.pathname=c;const T=globalThis.document,S=globalThis.location;globalThis.document=h,globalThis.location=m.location;const{createDomqlElement:R}=await Ne(),Z=L(e.app||{}),k={...e.config||{}};e.polyglot&&!k.polyglot&&(k.polyglot=e.polyglot),e.fetch&&!k.fetch&&(k.fetch=e.fetch),e.router&&!k.router&&(k.router=e.router);for(const g of Xe)e[g]!=null&&k[g]==null&&(k[g]=e[g]);const x=k.polyglot?{...k.polyglot}:void 0;i&&x&&(x.translations={...x.translations||{},...i});const j=L(e.state||{});(i||x)&&(j.root||(j.root={}),x&&(j.root.lang=j.root.lang||x.defaultLang||"en"),i&&(j.root.translations={...j.root.translations||{},...i})),Me();const F={};for(const g in e){if(Je.has(g))continue;const y=e[g];F[g]=y&&typeof y=="object"?L(y):y}const C={...F,state:j,...l?{state:{...j,...l}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(f||e.pages||{}),functions:{...e.functions||{},polyglot:Oe,getActiveLang:pe,getLang:pe},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...k,...x?{polyglot:x}:{},document:h,window:m,parent:{node:w},initOptions:{},domqlOptions:{sourcemap:!1},sync:!1,inspect:!1,notifications:!1,...a||{}},N=await Ae();N&&(C.plugins=C.plugins||[],C.plugins.some(g=>g.name==="funcql")||C.plugins.push(N)),ae(),ze(),le++,le===1?D={entries:[],bytes:0,tainted:!1}:D&&(D.tainted=!0);const W=D;let b;try{b=await R(Z,C);const g=Date.now(),y=p?2e3:50,P=J=>new Promise(_=>setTimeout(_,J));for(await P(Math.min(50,y));p&&de()>0&&Date.now()-g<y;)await P(10),de()===0&&await P(Math.max(0,Math.min(50,y-(Date.now()-g))))}finally{le--,D===W&&(D=null)}const B=W&&!W.tainted?W.entries.slice():[];ce(w);const q=fe(b),{elementPath:U}=await import("@symbo.ls/element"),O=He(b,U),Y=ne(e,o,b,b?.state),$=[],I=h.head||h.querySelector("head");if(I)for(const g of I.querySelectorAll("style")){if(g.sheet&&g.sheet.cssRules)for(const y of g.sheet.cssRules)y.cssText&&$.push(y);if(!$.length){const y=g.textContent||"";y&&$.push({cssText:y})}}const H=$.map(g=>g.cssText),{globalCSS:z,classRules:Re}=tt($);let te=ye(w.innerHTML);if(i){const g=x?.defaultLang||"en",y=i[g]||Object.values(i)[0]||{};te=te.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(P,J)=>{const _=J.trim();return y[_]??P})}return T!==void 0?globalThis.document=T:delete globalThis.document,S!==void 0?globalThis.location=S:delete globalThis.location,{html:te,metadata:Y,registry:q,brRegistry:O,element:b,emotionCSS:H,globalCSS:z,classRules:Re,fetchSeed:B,document:h,window:m,ssrTranslations:i,prefetchedPages:f}},vt=async(e,t={})=>{const{context:o={}}=t,{window:n,document:l}=ie(),a=l.body,{create:p}=await import("@symbo.ls/element"),c=await import("@symbo.ls/utils"),r={...Be,...o.components||{}},s={...c,...o.utils||{},...o.functions||{}};ae();let f;try{f=p(e,{node:a},"root",{context:{document:l,window:n,...o,components:r,utils:s}})}catch{}ce(a);const i=f?fe(f):{};return{html:ye(a.innerHTML),registry:i,element:f}},ye=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,l)=>{if(n.includes("&lt;")){const a=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+a+l}return t}),Xe=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],Ze=/\.[A-Za-z_\\-]/,Qe=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!Ze.test(t)},et=/^\s*(:root|\[data-theme|\[data-skin)/,be=e=>{const t=e&&e.cssText;if(typeof t!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(t))return"keyframes";if(t.startsWith("@font-face"))return null;if(typeof e.selectorText=="string")return Qe(e.selectorText)?et.test(e.selectorText)?"root":"reset":null;const o=e.cssRules&&Array.from(e.cssRules);if(o&&o.length&&/^@(media|supports|container)\b/.test(t)){const n=new Set(o.map(be));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},tt=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const l=be(n);l?t[l].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
1
+ import{resolve as m,join as Ce,dirname as x}from"path";import{existsSync as b,unlinkSync as De,readFileSync as W,realpathSync as Ie}from"fs";import{resolvePackageEntry as Oe}from"./packageEntry.js";import{tmpdir as Me}from"os";import{randomBytes as Pe}from"crypto";import{createRequire as oe}from"module";import{pathToFileURL as Fe}from"url";import{createEnv as ue}from"./env.js";import{resetKeys as de,assignKeys as me,mapKeysToElements as ge}from"./keys.js";import{extractMetadata as se,generateHeadHtml as Be}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as Ke}from"./shell.js";import{fetchSSRTranslations as Ne}from"./prefetch.js";import{createEarlySeedScript as Ge}from"@symbo.ls/fetch";import{headerEntries as He}from"@symbo.ls/fetch/rest";import{brenderRegistryBlock as Je,escapeRegExp as We,jsonForScript as Ue,polyglotFallbackLang as U}from"@symbo.ls/utils";let X=null;const ze=async()=>{if(X)return X;try{return X=(await import("@symbo.ls/funcql")).funcqlPlugin,X}catch{return null}};import"linkedom";import{createEarlySeedBlock as Ye}from"@symbo.ls/fetch";import{reset as Ve}from"@symbo.ls/css";const Z=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let s=e;for(const r of o){if(s==null||typeof s!="object")return;s=s[r]}return s},ne=(e,t)=>U(e?.lang,t),he=(e,t,o,s)=>{if(o?.translations){const n=o.translations[t];if(n){const l=Z(n,e);if(l!==void 0)return l}}if(s?.translations){const n=s.translations[t];if(n){const l=Z(n,e);if(l!==void 0)return l}}const r=U(void 0,o);if(r!==t&&o?.translations){const n=o.translations[r];if(n){const l=Z(n,e);if(l!==void 0)return l}}},Xe=function(e,t){if(!e)return"";const o=this?.context,s=o?.polyglot,r=this?.state?.root||o?.state?.root,n=he(e,t||ne(r,s),s,r);if(n!==void 0)return n;const l=ie(ce);return s&&l&&l.labelKeys.add(e),e},ye=function(){return ne(this?.state?.root,this?.context?.polyglot)},_=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const s=[];t.set(e,s);for(const r of e)s.push(typeof r=="object"&&r!==null?_(r,t):r);return s}const o={};t.set(e,o);for(const s of Object.keys(e)){const r=e[s];o[s]=typeof r=="object"&&r!==null?_(r,t):r}return o};let $=null;try{import.meta.url&&($=oe(import.meta.url))}catch{}const Ze=()=>{if(!import.meta.url||!$)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:a=>a};const e=Ie(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(b(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let s;try{const a=$.resolve("smbls/package.json");s=x(a)}catch{let a=e;for(;a!==x(a);){const y=m(a,"node_modules","smbls");if(b(m(y,"package.json"))){s=y;break}a=x(a)}}let r=$;if(s)try{r=oe(m(s,"package.json"))}catch{}let n,l=process.cwd();for(;l!==x(l);){if(b(m(l,"package.json"))){n=l;break}l=x(l)}let u=r;if(n)try{u=oe(m(n,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:s,brenderDir:e,projectRoot:n,_smblsRequire:r,_projectRequire:u}},P=(e,t)=>{const o=e.isMonorepo?[$]:[e._smblsRequire,e._projectRequire,$].filter(Boolean);for(const s of o)try{return s.resolve(t)}catch{}return null},Qt=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const s=P(e,`${t}/package.json`);return s?m(x(s),...o):null},eo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null},re=(e,t,...o)=>{if(e.isMonorepo){for(const r of["packages","plugins"]){const n=m(e.monorepoRoot,r,t,...o);if(b(n))return n}return null}const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null},be=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const s=P(e,`@symbo.ls/${t}/package.json`);return s?m(x(s),...o):null};let Q=null;const Se="smbls/ssr",Qe=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},et=()=>(Q||(Q=tt().catch(e=>{throw Q=null,e})),Q),tt=async()=>{const e=Ze();let t;if($&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await Qe()}catch(c){f=c}if(!$)throw new Error(`brender: ${Se} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const i=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(i&&b(i))t=i;else throw new Error(`brender: cannot load ${Se} (${f.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),s=Ce(Me(),`br_createDomql_${Pe(6).toString("hex")}.mjs`),r=Oe,n=e.isMonorepo?await import(Fe(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,l=n?new Set(n.workspacePackageRoots().map(f=>n.workspacePackageAt(f).name)):null,u=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,a={name:"workspace-resolve",setup(f){n&&(f.onResolve({filter:/^[^./]/},i=>{if(u.test(i.path))return;const c=i.path.split("/"),d=i.path.startsWith("@")?c.slice(0,2).join("/"):c[0];if(!l.has(d))return;const p=n.resolveWorkspaceSource(i.path,i.importer||t);return p?{path:p}:{errors:[{text:`"${i.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},i=>n.isWorkspaceDist(i.path)?{errors:[{text:`${i.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},i=>{const c=i.path.replace(/^smbls\/?/,""),d=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!d)return;if(!c){const g=r(d);return g?{path:g}:void 0}const p=m(d,c);if(b(p))return{path:p};if(b(p+".js"))return{path:p+".js"};const h=m(p,"index.js");if(b(h))return{path:h}}),f.onResolve({filter:/^domql$/},i=>{if(e.isMonorepo){const c=m(e.monorepoRoot,"packages","domql","src","index.js");if(b(c))return{path:c};const d=m(e.monorepoRoot,"packages","domql","index.js");if(b(d))return{path:d}}else try{const c=_require.resolve("domql/package.json"),d=r(x(c));if(d)return{path:d}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},i=>{const c=i.path.replace("@symbo.ls/","");if(c==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const p of["packages","plugins"]){const h=m(e.monorepoRoot,p,c,"src","index.js");if(b(h))return{path:h};const g=m(e.monorepoRoot,p,c,"index.js");if(b(g))return{path:g}}const d=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(c==="default-config"&&b(d))return{path:d}}else{const d=re(e,c,"src","index.js");if(d&&b(d))return{path:d};const p=re(e,c,"index.js");if(p&&b(p))return{path:p};if(c==="default-config"){const h=re(e,"default-config","blank","index.js");if(h&&b(h))return{path:h}}}}),f.onResolve({filter:/^@domql\//},i=>{const c=i.path.replace("@symbo.ls/","");if(e.isMonorepo){const d=m(e.monorepoRoot,"packages","domql","packages",c,"src","index.js");if(b(d))return{path:d};const p=m(e.monorepoRoot,"packages","domql","packages",c,"index.js");if(b(p))return{path:p}}else{const d=be(e,c,"src","index.js");if(d&&b(d))return{path:d};const p=be(e,c,"index.js");if(p&&b(p))return{path:p}}}),f.onResolve({filter:/^css-in-props/},i=>{let c;if(e.isMonorepo)c=m(e.monorepoRoot,"packages","css-in-props");else{const h=P(e,"css-in-props/package.json");h&&(c=x(h))}if(!c)return;const d=i.path.replace(/^css-in-props\/?/,"");if(d){const h=m(c,d),g=m(h,"index.js");if(b(g))return{path:g};if(b(h+".js"))return{path:h+".js"};if(b(h))return{path:h}}const p=r(c);if(p)return{path:p}}),f.onResolve({filter:/^@emotion\//},i=>{let c;if(e.isMonorepo)c=m(e.monorepoRoot,"node_modules",i.path);else{const d=P(e,`${i.path}/package.json`);if(!d)return;c=x(d)}if(b(c)){const d=m(c,"package.json");if(b(d))try{const p=JSON.parse(W(d,"utf8")),h=p.module||p.main||"dist/emotion-css.esm.js";return{path:m(c,h)}}catch{}return{path:c}}}),f.onResolve({filter:/\.json$/},i=>{if(i.resolveDir){const c=m(i.resolveDir,i.path);if(b(c))return{path:c}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("options.js"))return;let c=W(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async i=>{if(!i.path.includes("smbls/")||!i.path.endsWith("init.js"))return;let c=W(i.path,"utf8");return c=c.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:c,loader:"js"}}),f.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async i=>{let c=W(i.path,"utf8");return c=c.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:c,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async i=>{if(!i.path.includes("smbls/"))return;let c=W(i.path,"utf8");return c=c.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:c,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:s,write:!0,logLevel:"warning",plugins:[a],nodePaths:e.isMonorepo?[m(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[m(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[m(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[m(e.smblsRoot,"..","..","node_modules")]:[]].filter(f=>b(f)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const y=await import(`file://${s}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",s);else try{De(s)}catch{}return y},ot={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},st=(e,t)=>{const o={};return ke(e,(s,r)=>{if(!r.__brKey)return;const n=t(s);o[n===""?"__root":n]=r.__brKey}),o},ke=(e,t)=>{const o=s=>{const r=s&&s.__ref;if(r&&(t(s,r),r.__children))for(const n of r.__children)o(s[n])};o(e)},nt=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let F=0;const Re=Symbol.for("brender.fetchTracked"),we=()=>F,rt=256*1024,ct=1024*1024,it=new Set(["accept-language","accept"]),xe={renders:0,record:null},lt=50,ce={renders:0,record:null},je=(e,t)=>{e.renders++,e.renders===1?e.record=t():e.record&&(e.record.tainted=!0);const o=e.record;return{record:o,close:()=>{e.renders--,e.record===o&&(e.record=null)}}},ie=e=>e.record&&!e.record.tainted?e.record:null,at=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},le=(e,t,o)=>{!e||e.tainted||e.failures.length>=lt||e.failures.push({url:at(t),reason:o})},ve=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),ft=e=>{const[t,o]=e,s=t&&typeof t=="object"&&typeof t.url=="string",r=ve(t),n=String(o&&o.method||s&&t.method||"GET").toUpperCase(),l={},u=a=>{if(!a)return;const y=!Array.isArray(a)&&typeof a.entries!="function";for(const[f,i]of He(a))y&&i==null||(l[String(f).toLowerCase()]=String(i))};return s&&u(t.headers),o&&u(o.headers),{url:r,method:n,headers:l}},pt=(e,t,o,s)=>{if(!o||!o.ok||typeof o.clone!="function")return;const r=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(r))return;let n;try{n=o.clone()}catch{return}s(n.text().then(l=>{e.tainted||l.length>rt||e.bytes+l.length>ct||(e.bytes+=l.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:r,body:l}))},()=>{}))},ut=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Re])return;const t=function(...o){F++;let s=!1;const r=()=>{s||(s=!0,F--)},n=i=>{F++,i.then(()=>{F--},()=>{F--})},l=ie(xe),u=ie(ce);let a=null;if(l)try{a=ft(o),(a.method!=="GET"||!/^https?:/i.test(a.url)||Object.keys(a.headers).some(i=>!it.has(i)))&&(a=null)}catch{a=null}const y=()=>ve(o[0]);let f;try{f=e.apply(this,o)}catch(i){throw le(u,y(),i&&i.message||"failed"),r(),i}return f&&typeof f.then=="function"?f.then(i=>{a&&pt(l,a,i,n),u&&i&&i.ok===!1&&le(u,y(),"HTTP "+i.status),r()},i=>{le(u,y(),i&&i.message||"network error"),r()}):r(),f};t[Re]=!0,globalThis.fetch=t},to=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const s=Ue(e);return o?`<script>window.__BR_REGISTRY__=${s};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+Ge(t):""):`<script>window.__BR_REGISTRY__=${s}<\/script>`},_e=async(e,t={})=>{const{route:o="/",pathname:s,state:r,context:n,prefetch:l=!1}=t,u=s||o;ut();const a=je(ce,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await dt(e,{route:o,locationPath:u,stateOverrides:r,contextOverrides:n,prefetch:l},a.record)}finally{a.close()}},dt=async(e,{route:t,locationPath:o,stateOverrides:s,contextOverrides:r,prefetch:n},l)=>{let u;if(n)try{u=await Ne(e)}catch(c){console.warn("[brender] SSR translation fetch failed:",c.message)}const{window:a,document:y}=ue(),f=y.body;a.location.pathname=o;const i=[ee("document",y),ee("location",a.location),ee("localStorage",a.localStorage),ee("sessionStorage",a.sessionStorage)];try{const{createDomqlElement:c}=await et(),d=_(e.app||{}),p={...e.config||{}};e.polyglot&&!p.polyglot&&(p.polyglot=e.polyglot),e.fetch&&!p.fetch&&(p.fetch=e.fetch),e.router&&!p.router&&(p.router=e.router);for(const S of bt)e[S]!=null&&p[S]==null&&(p[S]=e[S]);const h=p.polyglot?{...p.polyglot}:void 0;u&&h&&(h.translations={...h.translations||{},...u});const g=_(e.state||{});(u||h)&&(g.root||(g.root={}),h&&(g.root.lang=U(g.root.lang,h)),u&&(g.root.translations={...g.root.translations||{},...u})),Ve();const q={};for(const S in e){if(nt.has(S))continue;const R=e[S];q[S]=R&&typeof R=="object"?_(R):R}const T={...q,state:g,...s?{state:{...g,...s}}:{},dependencies:_(e.dependencies||{}),components:_(e.components||{}),snippets:_(e.snippets||{}),pages:_(e.pages||{}),functions:{...e.functions||{},polyglot:Xe,getActiveLang:ye,getLang:ye},methods:e.methods||{},designSystem:_(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...p,...h?{polyglot:h}:{},document:y,window:a,parent:{node:f},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,...r||{}},B=await ze();B&&(T.plugins=T.plugins||[],T.plugins.some(S=>S.name==="funcql")||T.plugins.push(B)),de();const I=je(xe,()=>({entries:[],bytes:0,tainted:!1})),O=I.record;let j;try{j=await c(d,T);const S=Date.now(),R=n?2e3:50,L=M=>new Promise(J=>setTimeout(J,M));for(await L(Math.min(50,R));n&&we()>0&&Date.now()-S<R;)await L(10),we()===0&&await L(Math.max(0,Math.min(50,R-(Date.now()-S))))}finally{I.close()}const z=O&&!O.tainted?O.entries.slice():[];me(f);const Y=ge(j),{elementPath:A}=await import("@symbo.ls/element"),K=st(j,A),N=se(e,t,j,j?.state),v=[],C=y.head||y.querySelector("head");if(C)for(const S of C.querySelectorAll("style")){if(S.sheet&&S.sheet.cssRules)for(const R of S.sheet.cssRules)R.cssText&&v.push(R);if(!v.length){const R=S.textContent||"";R&&v.push({cssText:R})}}const D=v.map(S=>S.cssText),{globalCSS:V,classRules:pe}=wt(v);let k=Le(f.innerHTML);const w=j?.state?.root,E=ne(w,h),G=mt(u,w);G&&(k=Te(k,Ee(G,E,h)));const H=l&&!l.tainted?{failedRequests:l.failures.slice(),rawLabelKeys:yt(l.labelKeys,k,E,h,w)}:null;return{html:k,metadata:N,registry:Y,brRegistry:K,element:j,emotionCSS:D,globalCSS:V,classRules:pe,fetchSeed:z,document:y,window:a,ssrTranslations:G||void 0,activeLang:E,diagnostics:H}}finally{for(const c of i)c()}},ee=(e,t)=>{const o=Object.getOwnPropertyDescriptor(globalThis,e);return o&&!o.configurable?!o.writable&&!o.set?()=>{}:(globalThis[e]=t,()=>{}):(Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0,enumerable:!0}),()=>{o?Object.defineProperty(globalThis,e,o):delete globalThis[e]})},ae=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,fe=e=>e&&typeof e.parse=="function"?e.parse():e,mt=(e,t)=>{const o=fe(t?.translations),s={};for(const r of[e,o])if(!(!r||typeof r!="object"))for(const n in r){const l=fe(r[n]);l&&typeof l=="object"&&(s[n]={...s[n]||{},...l})}return Object.keys(s).length?s:null},Ee=(e,t,o)=>e[t]||e[U(void 0,o)]||Object.values(e)[0]||{},Te=(e,t)=>e.replace(ae,(o,s)=>Z(t,s.trim())??o),gt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,ht=(e,t)=>new RegExp(`(?:^|[^\\w.-])${We(t)}(?![\\w-]|\\.\\w)`).test(e),yt=(e,t,o,s,r)=>{const n=new Set,l=t.replace(gt,"");for(const u of e)/\s/.test(u)||he(u,o,s,r)===void 0&&ht(l,u)&&n.add(u);for(const u of l.matchAll(ae))n.add(u[1].trim());return[...n]},oo=async(e,t={})=>{const{context:o={}}=t,{window:s,document:r}=ue(),n=r.body,{create:l}=await import("@symbo.ls/element"),u=await import("@symbo.ls/utils"),a={...ot,...o.components||{}},y={...u,...o.utils||{},...o.functions||{}};de();let f;try{f=l(e,{node:n},"root",{context:{document:r,window:s,...o,components:a,utils:y}})}catch{}me(n);const i=f?ge(f):{};return{html:Le(n.innerHTML),registry:i,element:f}},Le=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,s,r)=>{if(s.includes("&lt;")){const n=s.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+n+r}return t}),bt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],St=/\.[A-Za-z_\\-]/,kt=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!St.test(t)},Rt=/^\s*(:root|\[data-theme|\[data-skin)/,$e=e=>{const t=e&&e.cssText;if(typeof t!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(t))return"keyframes";if(t.startsWith("@font-face"))return null;if(typeof e.selectorText=="string")return kt(e.selectorText)?Rt.test(e.selectorText)?"root":"reset":null;const o=e.cssRules&&Array.from(e.cssRules);if(o&&o.length&&/^@(media|supports|container)\b/.test(t)){const s=new Set(o.map($e));return s.has(null)||s.size!==1?s.has(null)?null:"reset":[...s][0]}return null},wt=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const s of e||[]){const r=$e(s);r?t[r].push(s.cssText):s&&s.cssText&&o.push(s.cssText)}return{globalCSS:{rootRule:t.root.join(`
3
3
  `),resetRules:t.reset.join(`
4
4
  `),keyframeRules:t.keyframes.join(`
5
- `),fontFaceCSS:""},classRules:o}};let ee=new Set;const Tt=()=>{ee=new Set},Et=()=>Array.from(ee).join(`
6
- `),Lt=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
5
+ `),fontFaceCSS:""},classRules:o}};let te=new Set;const so=()=>{te=new Set},no=()=>Array.from(te).join(`
6
+ `),ro=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
8
- </style>`:""),Ct=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:l=!0}=t,a=await he(e,{route:o,pathname:n,prefetch:l});if(!a)return null;const p=e.designSystem||{},c=a.globalCSS;let r=null,s=null;try{const f=a.element,i=f?.context?.polyglot||e.polyglot||e.config?.polyglot;if(s=f?.state?.root?.lang||i?.defaultLang||"en",a.prefetchedPages&&a.prefetchedPages[o]){const m=a.prefetchedPages[o],h=(w,T={})=>{if(!w||typeof w!="object")return T;if(w.state&&typeof w.state=="object")for(const[S,R]of Object.entries(w.state))R!=null&&typeof R!="function"&&(T[S]=R);for(const[S,R]of Object.entries(w))S==="state"||S==="props"||S==="attr"||S==="on"||S==="define"||S==="__ref"||S.startsWith("__")||R&&typeof R=="object"&&!Array.isArray(R)&&h(R,T);return T};r=h(m)}}catch{}return{html:a.html,css:a.classRules.join(`
9
- `),classRules:a.classRules.slice(),globalCSS:c,resetCss:c.resetRules,fontLinks:Se(p),metadata:a.metadata||ne(e,o),brKeyCount:a.registry?Object.keys(a.registry).length:0,brRegistry:a.brRegistry||{},fetchSeed:a.fetchSeed||[],ssrTranslations:a.ssrTranslations,prefetchedState:r,activeLang:s}},qt=async(e,t="/",o={})=>{const{lang:n,themeColor:l,isr:a,hydrate:p=!0,prefetch:c=!0,shell:r,adoptDom:s=!1}=o,f=n||e.state?.lang||e.app?.metadata?.lang||"en",i=await he(e,{route:t,prefetch:c});if(!i)return null;const m={...i.metadata};if(l&&(m["theme-color"]=l),typeof r=="string"&&!e.name){const b="\0brender-undeclared-title\0";if(ne({...e,name:b},t,i.element,i.element?.state).title===b)for(const q of["title","og:title","twitter:title"])m[q]===i.metadata.title&&delete m[q]}const h=Te(m);for(const b of i.classRules)b&&ee.add(b);const w=Array.from(ee).join(`
10
- `),T=i.globalCSS,S=`<style data-brender>
11
- ${T.rootRule||""}
12
- ${T.resetRules||""}
13
- ${T.keyframeRules||""}
14
- </style>`,R=w?`<style data-emotion="smbls">
15
- ${w}
16
- </style>`:"",Z=Se(e.designSystem||{}),k=Object.keys(i.registry).length,x=Ve({brRegistry:i.brRegistry,fetchSeed:i.fetchSeed,hydrateFlag:s});let j="";if(a&&a.clientScript){const b=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,B=b>0?"../".repeat(b):"./";if(p){let q="";if(i.ssrTranslations){const O=e.polyglot||e.config?.polyglot,Y=O?.storagePrefix||"",$=O?.storageLangKey||"",I=[];for(const H in i.ssrTranslations){const z=i.ssrTranslations[H];z&&typeof z=="object"&&I.push(`localStorage.setItem(${JSON.stringify(Y+H)},${JSON.stringify(JSON.stringify(z))})`)}if($){const H=O?.defaultLang||"en";I.push(`if(!localStorage.getItem(${JSON.stringify($)}))localStorage.setItem(${JSON.stringify($)},${JSON.stringify(H)})`)}I.length&&(q=`<script>try{${I.join(";")}}catch(e){}<\/script>
17
- `)}const U=x?x+`
18
- `:"";j=`${q}${U}<script>window.__BRENDER__=true<\/script>
19
- <script type="module" src="${B}${a.clientScript}"><\/script>`}else j=`<script type="module">
8
+ </style>`:""),co=async(e,t={})=>{const{route:o="/",pathname:s,prefetch:r=!0}=t,n=await _e(e,{route:o,pathname:s,prefetch:r});if(!n)return null;const l=e.designSystem||{},u=n.globalCSS;let a=null;try{const f=xt(n.element);Object.keys(f).length&&(a=f)}catch{}const y=n.activeLang;return{html:n.html,css:n.classRules.join(`
9
+ `),classRules:n.classRules.slice(),globalCSS:u,resetCss:u.resetRules,fontLinks:Ae(l),metadata:n.metadata||se(e,o),brKeyCount:n.registry?Object.keys(n.registry).length:0,brRegistry:n.brRegistry||{},fetchSeed:n.fetchSeed||[],ssrTranslations:n.ssrTranslations,prefetchedState:a,activeLang:y,diagnostics:n.diagnostics}},xt=e=>{const t={};return ke(e,o=>{const s=o.fetch;if(!(!s||typeof s!="object"||!o.state))for(const r of Array.isArray(s)?s:[s]){const n=r&&typeof r=="object"&&typeof r.as=="string"?r.as:null;if(!n)continue;const l=n.startsWith("~/"),u=l?n.slice(2):n,a=l?o.state.root:o.state,y=fe(a&&a[u]);u&&y!=null&&typeof y!="function"&&(t[u]=y)}}),t},io=async(e,t="/",o={})=>{const{lang:s,themeColor:r,isr:n,hydrate:l=!0,prefetch:u=!0,shell:a,adoptDom:y=!1,pathname:f,eagerImages:i=qe,preloadScripts:c=!0,nonce:d}=o,p=Tt(d),h=s||e.state?.lang||e.app?.metadata?.lang||"en",g=await _e(e,{route:t,pathname:f,prefetch:u});if(!g)return null;const q={...g.metadata};if(r&&(q["theme-color"]=r),typeof a=="string"&&!e.name){const k="\0brender-undeclared-title\0";if(se({...e,name:k},t,g.element,g.element?.state).title===k)for(const E of["title","og:title","twitter:title"])q[E]===g.metadata.title&&delete q[E]}const T=Be(q);for(const k of g.classRules)k&&te.add(k);const B=Array.from(te).join(`
10
+ `),I=g.globalCSS,O=`<style data-brender>
11
+ ${I.rootRule||""}
12
+ ${I.resetRules||""}
13
+ ${I.keyframeRules||""}
14
+ </style>`,j=B?`<style data-emotion="smbls">
15
+ ${B}
16
+ </style>`:"",z=Ae(e.designSystem||{}),Y=Object.keys(g.registry).length,A=Et({brRegistry:g.brRegistry,fetchSeed:g.fetchSeed,adoptDom:y});let K="";if(n&&n.clientScript){const k=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,w=k>0?"../".repeat(k):"./";if(l){let E="";if(g.ssrTranslations){const H=e.polyglot||e.config?.polyglot,S=H?.storagePrefix||"",R=H?.storageLangKey||"",L=[];for(const M in g.ssrTranslations){const J=g.ssrTranslations[M];J&&typeof J=="object"&&L.push(`localStorage.setItem(${JSON.stringify(S+M)},${JSON.stringify(JSON.stringify(J))})`)}if(R){const M=U(void 0,H);L.push(`if(!localStorage.getItem(${JSON.stringify(R)}))localStorage.setItem(${JSON.stringify(R)},${JSON.stringify(M)})`)}L.length&&(E=`<script${p}>try{${L.join(";")}}catch(e){}<\/script>
17
+ `)}const G=A.blocks?A.blocks+`
18
+ `:"";K=`${E}${G}<script type="module" src="${w}${n.clientScript}"${p}><\/script>`}else K=`<script type="module"${p}>
20
19
  {
21
20
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
22
21
  const observer = new MutationObserver((mutations) => {
@@ -33,19 +32,22 @@ ${w}
33
32
  observer.observe(document.body, { childList: true })
34
33
  }
35
34
  <\/script>
36
- <script type="module" src="${B}${a.clientScript}"><\/script>`}const F={...e.config||{}};e.polyglot&&!F.polyglot&&(F.polyglot=e.polyglot);const C=F.polyglot;let N=h;if(C){const b=C.defaultLang||"en",q={...C.translations||{},...i.ssrTranslations||{}}[b]||{};N=h.replace(/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,(U,O)=>{const Y=O.trim();return q[Y]??U})}return typeof r=="string"?{html:Ee(r,{headTags:N,headEnd:[Z,S,R].filter(Boolean).join(`
37
- `),body:i.html,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:s?x:""}),route:t,brKeyCount:k,shell:!0}:{html:`<!DOCTYPE html>
38
- <html lang="${f}">
35
+ <script type="module" src="${w}${n.clientScript}"${p}><\/script>`}const N={...e.config||{}};e.polyglot&&!N.polyglot&&(N.polyglot=e.polyglot);const v=N.polyglot;let C=T;if(v){const k={...v.translations||{}};for(const w in g.ssrTranslations||{})k[w]={...k[w]||{},...g.ssrTranslations[w]};C=Te(T,Ee(k,g.activeLang,v))}const D=g.diagnostics;if(D)for(const k of C.matchAll(ae)){const w=k[1].trim();D.rawLabelKeys.includes(w)||D.rawLabelKeys.push(w)}const V=_t(g.html,i);return typeof a=="string"?{html:Ke(a,{headTags:`${C}
36
+ ${A.meta}`,headEnd:[z,O,j].filter(Boolean).join(`
37
+ `),body:V,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:A.blocks,lang:s||(v?g.activeLang:void 0),preloadScripts:c}),route:t,brKeyCount:Y,shell:!0,diagnostics:D}:{html:`<!DOCTYPE html>
38
+ <html lang="${h}">
39
39
  <head>
40
- ${N}
41
- ${Z}
40
+ ${C}${n&&n.clientScript&&l?`
41
+ ${A.meta}`:""}
42
+ ${z}
42
43
 
43
- ${S}
44
- ${R}
44
+ ${O}
45
+ ${j}
45
46
  </head>
46
47
  <body>
47
- ${i.html}
48
- ${j}
48
+ ${V}
49
+ ${K}
49
50
  </body>
50
- </html>`,route:t,brKeyCount:k}},Se=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const l of Object.values(t)){if(typeof l!="string")continue;const a=l.match(/'([^']+)'/);a&&o.add(a[1])}return o.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...o].map(l=>`family=${l.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
51
- `):""};export{me as SMBLS_SSR_SPECIFIER,Ve as adoptionScripts,Et as getAccumulatedEmotionCSS,he as render,vt as renderElement,qt as renderPage,Ct as renderRoute,Lt as replaceEmotionCSS,Tt as resetGlobalCSSCache,tt as splitCapturedCSS};
51
+ </html>`,route:t,brKeyCount:Y,diagnostics:D}},qe=2,jt=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,vt=/\sloading\s*=/i,_t=(e,t=qe)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let s=0;return e.replace(jt,r=>s++<o||vt.test(r)?r:r.replace(/^<img\b/i,'<img loading="lazy"'))},Ae=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const r of Object.values(t)){if(typeof r!="string")continue;const n=r.match(/'([^']+)'/);n&&o.add(n[1])}return o.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...o].map(r=>`family=${r.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
52
+ `):""},Et=({brRegistry:e,fetchSeed:t,adoptDom:o=!1}={})=>{const s=o&&e&&Object.keys(e).length?Je(e):"",r=Ye(t);return{meta:`<meta name="brender" content="${s?"hydrate":"replace"}">`,blocks:[s,r].filter(Boolean).join(`
53
+ `)}},Tt=e=>{if(e==null||e==="")return"";const t=String(e);if(!/^[A-Za-z0-9+/=_-]+$/.test(t))throw new Error("brender: a nonce is base64 or base64url text");return` nonce="${t}"`};export{qe as EAGER_IMAGES_DEFAULT,Se as SMBLS_SSR_SPECIFIER,to as adoptionScripts,no as getAccumulatedEmotionCSS,_t as markLazyImages,Et as prerenderParts,_e as render,oo as renderElement,io as renderPage,co as renderRoute,ro as replaceEmotionCSS,so as resetGlobalCSSCache,wt as splitCapturedCSS};