@symbo.ls/brender 3.14.673 → 3.14.674

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,20 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.674
4
+
5
+ ### Patch Changes
6
+
7
+ - A payload key can no longer write to a prototype, a shared library reaches a consumer as copies, and a server render takes back its own library entries (merge programme 2026-10-25, lane F1).
8
+
9
+ - Security: `deepDestringifyFunctions` and `destringifyGlobalScope` (`@symbo.ls/utils`, and so the `smbls` bundle) and the renderer's own reviver (`@symbo.ls/mermaid` `deepDestringifyFunctions`, `stripFunctionStrings`) skip the keys `__proto__`, `constructor` and `prototype`. Before, a served page payload with a `__proto__` key wrote its object into `Object.prototype` (every object of the process then carried its keys, the next server render in the same process too), and a revived global scope inherited from an object the payload chose. The library merge (`deepDefaults` and its copies) skips the same keys.
10
+ - A library's `polyglot.translations` fill a consumer that has translations of its own, language by language and key by key: the app's key wins, an app with `polyglot.fetch` keeps its own maps, and a flat dotted library key never shadows a nested app value. `@symbo.ls/sync` puts the library keys back after a livesync snapshot or op.
11
+ - The merge hands a consumer copies of a library's design system and bags, never the library's objects, so one consumer's boot can no longer write into a library payload that other consumers share. A cycle in a library value is kept, not followed. Every `smbls` boot starts from its own default containers.
12
+ - `@symbo.ls/brender`: a render takes back only the `__SMBLS_PKGS__` entries its own libraries added; the process keeps one package registry and its framework entries.
13
+
14
+ - Updated dependencies
15
+ - @symbo.ls/utils@3.14.851
16
+ - smbls@3.14.856
17
+
3
18
  ## 3.14.673
4
19
 
5
20
  ### Patch Changes
@@ -1,25 +1,25 @@
1
- import{resolve as m,join as Je,dirname as _}from"path";import{existsSync as h,unlinkSync as Ye,readFileSync as X,realpathSync as ze}from"fs";import{resolvePackageEntry as Ve}from"./packageEntry.js";import{tmpdir as Xe}from"os";import{randomBytes as Qe}from"crypto";import{createRequire as fe}from"module";import{pathToFileURL as Ze}from"url";import{createEnv as Re}from"./env.js";import{resetKeys as ke,assignKeys as we,mapKeysToElements as xe}from"./keys.js";import{extractMetadata as pe,generateHeadHtml as et}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as tt}from"./shell.js";import{trimSpriteToPage as ot,classRulesForPage as nt,markupClasses as st,trimVariablesToPage as rt}from"./pageWeight.js";import{fetchSSRTranslations as ct}from"./prefetch.js";import{createEarlySeedScript as at}from"@symbo.ls/fetch";import{headerEntries as it}from"@symbo.ls/fetch/rest";import{brenderStampMeta as lt,escapeRegExp as ft,jsonForScript as pt,polyglotFallbackLang as oe,polyglotLangStorageKey as ut,polyglotAddressLang as mt,polyglotStartupScript as dt}from"@symbo.ls/utils";import{brenderRegistryBlock as gt,brenderRegistryTreeBlock as ht}from"@symbo.ls/utils/server";let ne=null;const yt=async()=>{if(ne)return ne;try{return ne=(await import("@symbo.ls/funcql")).funcqlPlugin,ne}catch{return null}};import"linkedom";import{createEarlySeedBlock as bt}from"@symbo.ls/fetch";import{reset as St}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 s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},re=(e,t)=>oe(e?.lang,t),je=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=se(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=se(r,e);if(a!==void 0)return a}}const s=oe(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=se(r,e);if(a!==void 0)return a}}},Rt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=je(e,t||re(s,n),n,s);if(r!==void 0)return r;const a=ge(de);return n&&a&&a.labelKeys.add(e),e},Te=function(){return re(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 n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?$(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?$(s,t):s}return o};let O=null;try{import.meta.url&&(O=fe(import.meta.url))}catch{}const kt=()=>{if(!import.meta.url||!O)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:l=>l};const e=ze(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(h(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const l=O.resolve("smbls/package.json");n=_(l)}catch{let l=e;for(;l!==_(l);){const g=m(l,"node_modules","smbls");if(h(m(g,"package.json"))){n=g;break}l=_(l)}}let s=O;if(n)try{s=fe(m(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==_(a);){if(h(m(a,"package.json"))){r=a;break}a=_(a)}let p=s;if(r)try{p=fe(m(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:p}},U=(e,t)=>{const o=e.isMonorepo?[O]:[e._smblsRequire,e._projectRequire,O].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},Oo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const n=U(e,`${t}/package.json`);return n?m(_(n),...o):null},Po=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const n=U(e,`@symbo.ls/${t}/package.json`);return n?m(_(n),...o):null},ue=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=m(e.monorepoRoot,s,t,...o);if(h(r))return r}return null}const n=U(e,`@symbo.ls/${t}/package.json`);return n?m(_(n),...o):null},Ee=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const n=U(e,`@symbo.ls/${t}/package.json`);return n?m(_(n),...o):null};let ce=null;const _e="smbls/ssr",wt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},ve=()=>(ce||(ce=xt().catch(e=>{throw ce=null,e})),ce),xt=async()=>{const e=kt();let t;if(O&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await wt()}catch(i){f=i}if(!O)throw new Error(`brender: ${_e} 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 c=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(c&&h(c))t=c;else throw new Error(`brender: cannot load ${_e} (${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"),n=Je(Xe(),`br_createDomql_${Qe(6).toString("hex")}.mjs`),s=Ve,r=e.isMonorepo?await import(Ze(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,p=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,l={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(p.test(c.path))return;const i=c.path.split("/"),u=c.path.startsWith("@")?i.slice(0,2).join("/"):i[0];if(!a.has(u))return;const d=r.resolveWorkspaceSource(c.path,c.importer||t);return d?{path:d}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const i=c.path.replace(/^smbls\/?/,""),u=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!i){const E=s(u);return E?{path:E}:void 0}const d=m(u,i);if(h(d))return{path:d};if(h(d+".js"))return{path:d+".js"};const b=m(d,"index.js");if(h(b))return{path:b}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const i=m(e.monorepoRoot,"packages","domql","src","index.js");if(h(i))return{path:i};const u=m(e.monorepoRoot,"packages","domql","index.js");if(h(u))return{path:u}}else try{const i=_require.resolve("domql/package.json"),u=s(_(i));if(u)return{path:u}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const i=c.path.replace("@symbo.ls/","");if(i==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const d of["packages","plugins"]){const b=m(e.monorepoRoot,d,i,"src","index.js");if(h(b))return{path:b};const E=m(e.monorepoRoot,d,i,"index.js");if(h(E))return{path:E}}const u=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(i==="default-config"&&h(u))return{path:u}}else{const u=ue(e,i,"src","index.js");if(u&&h(u))return{path:u};const d=ue(e,i,"index.js");if(d&&h(d))return{path:d};if(i==="default-config"){const b=ue(e,"default-config","blank","index.js");if(b&&h(b))return{path:b}}}}),f.onResolve({filter:/^@domql\//},c=>{const i=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=m(e.monorepoRoot,"packages","domql","packages",i,"src","index.js");if(h(u))return{path:u};const d=m(e.monorepoRoot,"packages","domql","packages",i,"index.js");if(h(d))return{path:d}}else{const u=Ee(e,i,"src","index.js");if(u&&h(u))return{path:u};const d=Ee(e,i,"index.js");if(d&&h(d))return{path:d}}}),f.onResolve({filter:/^css-in-props/},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"packages","css-in-props");else{const b=U(e,"css-in-props/package.json");b&&(i=_(b))}if(!i)return;const u=c.path.replace(/^css-in-props\/?/,"");if(u){const b=m(i,u),E=m(b,"index.js");if(h(E))return{path:E};if(h(b+".js"))return{path:b+".js"};if(h(b))return{path:b}}const d=s(i);if(d)return{path:d}}),f.onResolve({filter:/^@emotion\//},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"node_modules",c.path);else{const u=U(e,`${c.path}/package.json`);if(!u)return;i=_(u)}if(h(i)){const u=m(i,"package.json");if(h(u))try{const d=JSON.parse(X(u,"utf8")),b=d.module||d.main||"dist/emotion-css.esm.js";return{path:m(i,b)}}catch{}return{path:i}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const i=m(c.resolveDir,c.path);if(h(i))return{path:i}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let i=X(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let i=X(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,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 c=>{let i=X(c.path,"utf8");return i=i.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:i,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let i=X(c.path,"utf8");return i=i.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:i,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[l],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=>h(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 g=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{Ye(n)}catch{}return g},jt={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"}},Tt=(e,t)=>{const o={};return Le(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},Le=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},Et=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let W=0;const $e=Symbol.for("brender.fetchTracked"),me=()=>W,_t=256*1024,vt=1024*1024,Lt=new Set(["accept-language","accept"]),De={renders:0,record:null},$t=50,de={renders:0,record:null},Ae=(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)}}},ge=e=>e.record&&!e.record.tainted?e.record:null,Dt=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},he=(e,t,o)=>{!e||e.tainted||e.failures.length>=$t||e.failures.push({url:Dt(t),reason:o})},Ce=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),At=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Ce(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},p=l=>{if(!l)return;const g=!Array.isArray(l)&&typeof l.entries!="function";for(const[f,c]of it(l))g&&c==null||(a[String(f).toLowerCase()]=String(c))};return n&&p(t.headers),o&&p(o.headers),{url:s,method:r,headers:a}},Ct=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(a=>{e.tainted||a.length>_t||e.bytes+a.length>vt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},qt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[$e])return;const t=function(...o){W++;let n=!1;const s=()=>{n||(n=!0,W--)},r=c=>{W++,c.then(()=>{W--},()=>{W--})},a=ge(De),p=ge(de);let l=null;if(a)try{l=At(o),(l.method!=="GET"||!/^https?:/i.test(l.url)||Object.keys(l.headers).some(c=>!Lt.has(c)))&&(l=null)}catch{l=null}const g=()=>Ce(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw he(p,g(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{l&&Ct(a,l,c,r),p&&c&&c.ok===!1&&he(p,g(),"HTTP "+c.status),s()},c=>{he(p,g(),c&&c.message||"network error"),s()}):s(),f};t[$e]=!0,globalThis.fetch=t},Fo=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=pt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
- `+at(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Mt=3e4,It=2147483647;let qe=Promise.resolve();const Me=()=>{},Ot=e=>{const t=qe.then(e);return qe=t.then(Me,Me),t},Pt=e=>{if(e===void 0)return Mt;if(e===0||e===!1||e===1/0)return 0;if(typeof e!="number"||!(e>0))throw new TypeError(`brender: options.timeout is a number of milliseconds, or 0 / false for no limit \u2014 not ${JSON.stringify(e)}`);return Math.min(e,It)},Ft=(e,t)=>{const o=e.route||"/",n=e.pathname||o,s=n===o?o:`${n} (route ${o})`,r=new Error(`brender: the render of ${s} did not finish within ${t} ms and was abandoned, so the renders after it can run (options.timeout)`);return r.code="BRENDER_RENDER_TIMEOUT",r.route=o,r.pathname=n,r.timeout=t,r},Bt=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},Kt=e=>{let t=!1;return()=>{t||(t=!0,e())}},Ie=(e,t={})=>{let o;try{o=Pt(t.timeout)}catch(n){return Promise.reject(n)}return Ot(()=>Gt(e,t,o))},Gt=async(e,t,o)=>{await ve();const n={closed:!1,undo:[]},s=Nt(e,t,n);if(!o)return s;let r;const a=new Promise((p,l)=>{r=setTimeout(()=>{Bt(n),l(Ft(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},Nt=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:p=!1}=t,l=s||n;qt();const g=Ae(de,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await Ht(e,{route:n,locationPath:l,stateOverrides:r,contextOverrides:a,prefetch:p},g.record,o)}finally{g.close()}},Ht=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r},a,p)=>{const l=()=>{if(p.closed)throw new Error("brender: this render was abandoned at its timeout")};let g;if(r){try{g=await ct(e)}catch(d){p.closed||console.warn("[brender] SSR translation fetch failed:",d.message)}l()}const{window:f,document:c}=Re(),i=c.body;f.location.pathname=o;const u=[ae("document",c),ae("location",f.location),ae("localStorage",f.localStorage),ae("sessionStorage",f.sessionStorage)].map(Kt);p.undo.push(...u);try{const{createDomqlElement:d,PRERENDER_REGISTRY_FORMATS:b}=await ve();l();const E=$(e.app||{}),x={...e.config||{}};e.polyglot&&!x.polyglot&&(x.polyglot=e.polyglot),e.fetch&&!x.fetch&&(x.fetch=e.fetch),e.router&&!x.router&&(x.router=e.router);for(const y of Vt)e[y]!=null&&x[y]==null&&(x[y]=e[y]);const w=x.polyglot?{...x.polyglot}:void 0,Q=mt(o,w);Q&&f.localStorage.setItem(ut(w),Q),g&&w&&(w.translations={...w.translations||{},...g});const v=$(e.state||{});(g||w)&&(v.root||(v.root={}),w&&(v.root.lang=oe(v.root.lang,w)),g&&(v.root.translations={...v.root.translations||{},...g})),St();const P={};for(const y in e){if(Et.has(y))continue;const k=e[y];P[y]=k&&typeof k=="object"?$(k):k}const D={...P,state:v,...n?{state:{...v,...n}}:{},dependencies:$(e.dependencies||{}),components:$(e.components||{}),snippets:$(e.snippets||{}),pages:$(e.pages||{}),functions:{...e.functions||{},polyglot:Rt,getActiveLang:Te,getLang:Te},methods:e.methods||{},designSystem:$(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...x,...w?{polyglot:w}:{},document:c,window:f,parent:{node:i},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...s||{}},N=await yt();l(),N&&(D.plugins=D.plugins||[],D.plugins.some(y=>y.name==="funcql")||D.plugins.push(N)),ke();const S=Ae(De,()=>({entries:[],bytes:0,tainted:!1})),A=S.record;let j;try{j=await d(E,D),l();const y=Date.now(),k=r?2e3:50,R=T=>new Promise(G=>setTimeout(G,T));for(await R(Math.min(50,k));r&&!p.closed&&me()>0&&Date.now()-y<k;)await R(10),me()===0&&await R(Math.max(0,Math.min(50,k-(Date.now()-y))));if(l(),r&&await Ut(j,w)){l();const T=Date.now();for(await R(Math.min(50,k));!p.closed&&me()>0&&Date.now()-T<k;)await R(10);l()}}finally{S.close()}const C=A&&!A.tainted&&!(x.fetch&&x.fetch.seed===!1)?A.entries.slice():[];we(i);const J=xe(j),{elementPath:Y}=await import("@symbo.ls/element");l();const Z=Tt(j,Y),z=j?.context?.routerOptions?.contentElementKey||"content",F=j&&j[z],q=F&&typeof F=="object"&&F.__ref?F:void 0,Se=pe(e,t,j,j?.state,q),M=[],V=c.head||c.querySelector("head");if(V)for(const y of V.querySelectorAll("style")){if(y.sheet&&y.sheet.cssRules)for(const k of y.sheet.cssRules)k.cssText&&M.push(k);if(!M.length){const k=y.textContent||"";k&&M.push({cssText:k})}}const ee=M.map(y=>y.cssText),{globalCSS:te,classRules:le}=oo(M);let L=Fe(i.innerHTML);const B=j?.state?.root,K=re(B,w),I=Wt(g,B);I&&(L=Pe(L,Oe(I,K,w)));const H=a&&!a.tainted?{failedRequests:a.failures.slice(),rawLabelKeys:zt(a.labelKeys,L,K,w,B)}:null;return{html:L,metadata:Se,registry:J,brRegistry:Z,element:j,emotionCSS:ee,globalCSS:te,classRules:le,fetchSeed:C,document:c,window:f,ssrTranslations:I||void 0,activeLang:K,diagnostics:H,preparedDesignSystem:D.preparedDesignSystem||null,registryFormats:Array.isArray(b)?b.slice():["paths"]}}finally{for(const d of u)d()}},ae=(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]})},Ut=async(e,t)=>{if(!t||!t.fetch||!e||typeof e.call!="function")return!1;const o=e.state&&e.state.root;if(!o)return!1;const n=re(o,t),s=o.translations&&o.translations[n];if(s&&typeof s=="object"&&Object.keys(s).length||t.translations&&t.translations[n])return!1;try{await e.call("loadTranslations",n,{inFlight:!0})}catch{}return!0},ye=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,be=e=>e&&typeof e.parse=="function"?e.parse():e,Wt=(e,t)=>{const o=be(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=be(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Oe=(e,t,o)=>e[t]||e[oe(void 0,o)]||Object.values(e)[0]||{},Pe=(e,t)=>e.replace(ye,(o,n)=>se(t,n.trim())??o),Jt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,Yt=(e,t)=>new RegExp(`(?:^|[^\\w.-])${ft(t)}(?![\\w-]|\\.\\w)`).test(e),zt=(e,t,o,n,s)=>{const r=new Set,a=t.replace(Jt,"");for(const p of e)/\s/.test(p)||je(p,o,n,s)===void 0&&Yt(a,p)&&r.add(p);for(const p of a.matchAll(ye))r.add(p[1].trim());return[...r]},Bo=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=Re(),r=s.body,{create:a}=await import("@symbo.ls/element"),p=await import("@symbo.ls/utils"),l={...jt,...o.components||{}},g={...p,...o.utils||{},...o.functions||{}};ke();let f;try{f=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:l,utils:g}})}catch{}we(r);const c=f?xe(f):{};return{html:Fe(r.innerHTML),registry:c,element:f}},Fe=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,s)=>{if(n.includes("&lt;")){const r=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+r+s}return t}),Vt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],Xt=new Set(["auto","system"]),Be=e=>{if(!e||typeof e!="object")return null;const t=e.config&&typeof e.config=="object"?e.config:{};if((t.themeRoot!=null?t.themeRoot:e.themeRoot)!=null)return null;const n=t.globalTheme!=null?t.globalTheme:e.globalTheme;if(typeof n!="string")return null;const s=n.trim();return!s||Xt.has(s)?null:s},Qt=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),Zt=/\.[A-Za-z_\\-]/,eo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!Zt.test(t)},to=/^\s*(:root|\[data-theme|\[data-skin)/,Ke=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 eo(e.selectorText)?to.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(Ke));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Ge=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),oo=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ke(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
1
+ import{resolve as m,join as Je,dirname as E}from"path";import{existsSync as b,unlinkSync as Ye,readFileSync as z,realpathSync as ze}from"fs";import{resolvePackageEntry as Ve}from"./packageEntry.js";import{tmpdir as Xe}from"os";import{randomBytes as Qe}from"crypto";import{createRequire as pe}from"module";import{pathToFileURL as Ze}from"url";import{createEnv as ke}from"./env.js";import{resetKeys as we,assignKeys as _e,mapKeysToElements as je}from"./keys.js";import{extractMetadata as ue,generateHeadHtml as et}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as tt}from"./shell.js";import{trimSpriteToPage as ot,classRulesForPage as nt,markupClasses as st,trimVariablesToPage as rt}from"./pageWeight.js";import{fetchSSRTranslations as ct}from"./prefetch.js";import{createEarlySeedScript as at}from"@symbo.ls/fetch";import{headerEntries as it}from"@symbo.ls/fetch/rest";import{brenderStampMeta as lt,escapeRegExp as ft,jsonForScript as pt,libraryPackageSpecs as ut,polyglotFallbackLang as te,polyglotLangStorageKey as mt,polyglotAddressLang as dt,polyglotStartupScript as gt}from"@symbo.ls/utils";import{brenderRegistryBlock as ht,brenderRegistryTreeBlock as yt}from"@symbo.ls/utils/server";let oe=null;const bt=async()=>{if(oe)return oe;try{return oe=(await import("@symbo.ls/funcql")).funcqlPlugin,oe}catch{return null}};import"linkedom";import{createEarlySeedBlock as St}from"@symbo.ls/fetch";import{reset as Rt}from"@symbo.ls/css";const ne=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},se=(e,t)=>te(e?.lang,t),xe=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const a=ne(r,e);if(a!==void 0)return a}}if(n?.translations){const r=n.translations[t];if(r){const a=ne(r,e);if(a!==void 0)return a}}const s=te(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const a=ne(r,e);if(a!==void 0)return a}}},kt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=xe(e,t||se(s,n),n,s);if(r!==void 0)return r;const a=he(ge);return n&&a&&a.labelKeys.add(e),e},Te=function(){return se(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 n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?$(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?$(s,t):s}return o};let O=null;try{import.meta.url&&(O=pe(import.meta.url))}catch{}const wt=()=>{if(!import.meta.url||!O)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:l=>l};const e=ze(new URL(".",import.meta.url).pathname),t=m(e,"../..");if(b(m(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const l=O.resolve("smbls/package.json");n=E(l)}catch{let l=e;for(;l!==E(l);){const h=m(l,"node_modules","smbls");if(b(m(h,"package.json"))){n=h;break}l=E(l)}}let s=O;if(n)try{s=pe(m(n,"package.json"))}catch{}let r,a=process.cwd();for(;a!==E(a);){if(b(m(a,"package.json"))){r=a;break}a=E(a)}let p=s;if(r)try{p=pe(m(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:p}},G=(e,t)=>{const o=e.isMonorepo?[O]:[e._smblsRequire,e._projectRequire,O].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},Fo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages",t,...o);const n=G(e,`${t}/package.json`);return n?m(E(n),...o):null},Bo=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"plugins",t,...o);const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},me=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=m(e.monorepoRoot,s,t,...o);if(b(r))return r}return null}const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null},Ee=(e,t,...o)=>{if(e.isMonorepo)return m(e.monorepoRoot,"packages","domql","packages",t,...o);const n=G(e,`@symbo.ls/${t}/package.json`);return n?m(E(n),...o):null};let re=null;const ve="smbls/ssr",_t=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Le=()=>(re||(re=jt().catch(e=>{throw re=null,e})),re),jt=async()=>{const e=wt();let t;if(O&&e.isMonorepo)t=m(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await _t()}catch(i){f=i}if(!O)throw new Error(`brender: ${ve} 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 c=e.smblsRoot&&m(e.smblsRoot,"src","createDomql.js");if(c&&b(c))t=c;else throw new Error(`brender: cannot load ${ve} (${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"),n=Je(Xe(),`br_createDomql_${Qe(6).toString("hex")}.mjs`),s=Ve,r=e.isMonorepo?await import(Ze(m(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,a=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,p=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,l={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(p.test(c.path))return;const i=c.path.split("/"),u=c.path.startsWith("@")?i.slice(0,2).join("/"):i[0];if(!a.has(u))return;const g=r.resolveWorkspaceSource(c.path,c.importer||t);return g?{path:g}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const i=c.path.replace(/^smbls\/?/,""),u=e.isMonorepo?m(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!u)return;if(!i){const x=s(u);return x?{path:x}:void 0}const g=m(u,i);if(b(g))return{path:g};if(b(g+".js"))return{path:g+".js"};const y=m(g,"index.js");if(b(y))return{path:y}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const i=m(e.monorepoRoot,"packages","domql","src","index.js");if(b(i))return{path:i};const u=m(e.monorepoRoot,"packages","domql","index.js");if(b(u))return{path:u}}else try{const i=_require.resolve("domql/package.json"),u=s(E(i));if(u)return{path:u}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const i=c.path.replace("@symbo.ls/","");if(i==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const g of["packages","plugins"]){const y=m(e.monorepoRoot,g,i,"src","index.js");if(b(y))return{path:y};const x=m(e.monorepoRoot,g,i,"index.js");if(b(x))return{path:x}}const u=m(e.monorepoRoot,"packages","default-config","blank","index.js");if(i==="default-config"&&b(u))return{path:u}}else{const u=me(e,i,"src","index.js");if(u&&b(u))return{path:u};const g=me(e,i,"index.js");if(g&&b(g))return{path:g};if(i==="default-config"){const y=me(e,"default-config","blank","index.js");if(y&&b(y))return{path:y}}}}),f.onResolve({filter:/^@domql\//},c=>{const i=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const u=m(e.monorepoRoot,"packages","domql","packages",i,"src","index.js");if(b(u))return{path:u};const g=m(e.monorepoRoot,"packages","domql","packages",i,"index.js");if(b(g))return{path:g}}else{const u=Ee(e,i,"src","index.js");if(u&&b(u))return{path:u};const g=Ee(e,i,"index.js");if(g&&b(g))return{path:g}}}),f.onResolve({filter:/^css-in-props/},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"packages","css-in-props");else{const y=G(e,"css-in-props/package.json");y&&(i=E(y))}if(!i)return;const u=c.path.replace(/^css-in-props\/?/,"");if(u){const y=m(i,u),x=m(y,"index.js");if(b(x))return{path:x};if(b(y+".js"))return{path:y+".js"};if(b(y))return{path:y}}const g=s(i);if(g)return{path:g}}),f.onResolve({filter:/^@emotion\//},c=>{let i;if(e.isMonorepo)i=m(e.monorepoRoot,"node_modules",c.path);else{const u=G(e,`${c.path}/package.json`);if(!u)return;i=E(u)}if(b(i)){const u=m(i,"package.json");if(b(u))try{const g=JSON.parse(z(u,"utf8")),y=g.module||g.main||"dist/emotion-css.esm.js";return{path:m(i,y)}}catch{}return{path:i}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const i=m(c.resolveDir,c.path);if(b(i))return{path:i}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let i=z(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let i=z(c.path,"utf8");return i=i.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:i,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 c=>{let i=z(c.path,"utf8");return i=i.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:i,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let i=z(c.path,"utf8");return i=i.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:i,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[l],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 h=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{Ye(n)}catch{}return h},xt={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"}},Tt=(e,t)=>{const o={};return $e(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},$e=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},Et=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let N=0;const De=Symbol.for("brender.fetchTracked"),de=()=>N,vt=256*1024,Lt=1024*1024,$t=new Set(["accept-language","accept"]),Ae={renders:0,record:null},Dt=50,ge={renders:0,record:null},Ce=(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)}}},he=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]}},ye=(e,t,o)=>{!e||e.tainted||e.failures.length>=Dt||e.failures.push({url:At(t),reason:o})},qe=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Ct=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=qe(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),a={},p=l=>{if(!l)return;const h=!Array.isArray(l)&&typeof l.entries!="function";for(const[f,c]of it(l))h&&c==null||(a[String(f).toLowerCase()]=String(c))};return n&&p(t.headers),o&&p(o.headers),{url:s,method:r,headers:a}},qt=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(a=>{e.tainted||a.length>vt||e.bytes+a.length>Lt||(e.bytes+=a.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:a}))},()=>{}))},Mt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[De])return;const t=function(...o){N++;let n=!1;const s=()=>{n||(n=!0,N--)},r=c=>{N++,c.then(()=>{N--},()=>{N--})},a=he(Ae),p=he(ge);let l=null;if(a)try{l=Ct(o),(l.method!=="GET"||!/^https?:/i.test(l.url)||Object.keys(l.headers).some(c=>!$t.has(c)))&&(l=null)}catch{l=null}const h=()=>qe(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw ye(p,h(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{l&&qt(a,l,c,r),p&&c&&c.ok===!1&&ye(p,h(),"HTTP "+c.status),s()},c=>{ye(p,h(),c&&c.message||"network error"),s()}):s(),f};t[De]=!0,globalThis.fetch=t},Ko=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=pt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+at(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Ot=e=>{const t=globalThis.__SMBLS_PKGS__,o=new Set(t&&typeof t=="object"?Object.getOwnPropertyNames(t):[]);return()=>{const n=globalThis.__SMBLS_PKGS__;if(!n||typeof n!="object")return;let s;try{s=ut(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},Pt=3e4,It=2147483647;let Me=Promise.resolve();const Oe=()=>{},Ft=e=>{const t=Me.then(e);return Me=t.then(Oe,Oe),t},Bt=e=>{if(e===void 0)return Pt;if(e===0||e===!1||e===1/0)return 0;if(typeof e!="number"||!(e>0))throw new TypeError(`brender: options.timeout is a number of milliseconds, or 0 / false for no limit \u2014 not ${JSON.stringify(e)}`);return Math.min(e,It)},Kt=(e,t)=>{const o=e.route||"/",n=e.pathname||o,s=n===o?o:`${n} (route ${o})`,r=new Error(`brender: the render of ${s} did not finish within ${t} ms and was abandoned, so the renders after it can run (options.timeout)`);return r.code="BRENDER_RENDER_TIMEOUT",r.route=o,r.pathname=n,r.timeout=t,r},Gt=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},Nt=e=>{let t=!1;return()=>{t||(t=!0,e())}},Pe=(e,t={})=>{let o;try{o=Bt(t.timeout)}catch(n){return Promise.reject(n)}return Ft(()=>Ht(e,t,o))},Ht=async(e,t,o)=>{await Le();const n={closed:!1,undo:[]},s=Ut(e,t,n);if(!o)return s;let r;const a=new Promise((p,l)=>{r=setTimeout(()=>{Gt(n),l(Kt(t,o))},o)});try{return await Promise.race([s,a])}finally{clearTimeout(r)}},Ut=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:a,prefetch:p=!1}=t,l=s||n;Mt();const h=Ce(ge,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await Wt(e,{route:n,locationPath:l,stateOverrides:r,contextOverrides:a,prefetch:p},h.record,o)}finally{h.close()}},Wt=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r},a,p)=>{const l=()=>{if(p.closed)throw new Error("brender: this render was abandoned at its timeout")};let h;if(r){try{h=await ct(e)}catch(y){p.closed||console.warn("[brender] SSR translation fetch failed:",y.message)}l()}const{window:f,document:c}=ke(),i=c.body;f.location.pathname=o;let u=null;const g=[ce("document",c),ce("location",f.location),ce("localStorage",f.localStorage),ce("sessionStorage",f.sessionStorage),Ot(()=>u&&u.sharedLibraries)].map(Nt);p.undo.push(...g);try{const{createDomqlElement:y,PRERENDER_REGISTRY_FORMATS:x}=await Le();l();const ie=$(e.app||{}),j={...e.config||{}};e.polyglot&&!j.polyglot&&(j.polyglot=e.polyglot),e.fetch&&!j.fetch&&(j.fetch=e.fetch),e.router&&!j.router&&(j.router=e.router);for(const R of Qt)e[R]!=null&&j[R]==null&&(j[R]=e[R]);const w=j.polyglot?{...j.polyglot}:void 0,H=dt(o,w);H&&f.localStorage.setItem(mt(w),H),h&&w&&(w.translations={...w.translations||{},...h});const T=$(e.state||{});(h||w)&&(T.root||(T.root={}),w&&(T.root.lang=te(T.root.lang,w)),h&&(T.root.translations={...T.root.translations||{},...h})),Rt();const V={};for(const R in e){if(Et.has(R))continue;const d=e[R];V[R]=d&&typeof d=="object"?$(d):d}const v={...V,state:T,...n?{state:{...T,...n}}:{},dependencies:$(e.dependencies||{}),components:$(e.components||{}),snippets:$(e.snippets||{}),pages:$(e.pages||{}),functions:{...e.functions||{},polyglot:kt,getActiveLang:Te,getLang:Te},methods:e.methods||{},designSystem:$(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],...j,...w?{polyglot:w}:{},document:c,window:f,parent:{node:i},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...s||{}};u=v;const S=await bt();l(),S&&(v.plugins=v.plugins||[],v.plugins.some(R=>R.name==="funcql")||v.plugins.push(S)),we();const P=Ce(Ae,()=>({entries:[],bytes:0,tainted:!1})),K=P.record;let k;try{k=await y(ie,v),l();const R=Date.now(),d=r?2e3:50,_=D=>new Promise(fe=>setTimeout(fe,D));for(await _(Math.min(50,d));r&&!p.closed&&de()>0&&Date.now()-R<d;)await _(10),de()===0&&await _(Math.max(0,Math.min(50,d-(Date.now()-R))));if(l(),r&&await Jt(k,w)){l();const D=Date.now();for(await _(Math.min(50,d));!p.closed&&de()>0&&Date.now()-D<d;)await _(10);l()}}finally{P.close()}const U=K&&!K.tainted&&!(j.fetch&&j.fetch.seed===!1)?K.entries.slice():[];_e(i);const W=je(k),{elementPath:X}=await import("@symbo.ls/element");l();const J=Tt(k,X),Q=k?.context?.routerOptions?.contentElementKey||"content",L=k&&k[Q],Re=L&&typeof L=="object"&&L.__ref?L:void 0,Z=ue(e,t,k,k?.state,Re),A=[],Y=c.head||c.querySelector("head");if(Y)for(const R of Y.querySelectorAll("style")){if(R.sheet&&R.sheet.cssRules)for(const d of R.sheet.cssRules)d.cssText&&A.push(d);if(!A.length){const d=R.textContent||"";d&&A.push({cssText:d})}}const ee=A.map(R=>R.cssText),{globalCSS:le,classRules:I}=so(A);let C=Be(i.innerHTML);const F=k?.state?.root,q=se(F,w),M=Yt(h,F);M&&(C=Fe(C,Ie(M,q,w)));const B=a&&!a.tainted?{failedRequests:a.failures.slice(),rawLabelKeys:Xt(a.labelKeys,C,q,w,F)}:null;return{html:C,metadata:Z,registry:W,brRegistry:J,element:k,emotionCSS:ee,globalCSS:le,classRules:I,fetchSeed:U,document:c,window:f,ssrTranslations:M||void 0,activeLang:q,diagnostics:B,preparedDesignSystem:v.preparedDesignSystem||null,registryFormats:Array.isArray(x)?x.slice():["paths"]}}finally{for(const y of g)y()}},ce=(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]})},Jt=async(e,t)=>{if(!t||!t.fetch||!e||typeof e.call!="function")return!1;const o=e.state&&e.state.root;if(!o)return!1;const n=se(o,t),s=o.translations&&o.translations[n];if(s&&typeof s=="object"&&Object.keys(s).length||t.translations&&t.translations[n])return!1;try{await e.call("loadTranslations",n,{inFlight:!0})}catch{}return!0},be=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,Se=e=>e&&typeof e.parse=="function"?e.parse():e,Yt=(e,t)=>{const o=Se(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const a=Se(s[r]);a&&typeof a=="object"&&(n[r]={...n[r]||{},...a})}return Object.keys(n).length?n:null},Ie=(e,t,o)=>e[t]||e[te(void 0,o)]||Object.values(e)[0]||{},Fe=(e,t)=>e.replace(be,(o,n)=>ne(t,n.trim())??o),zt=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,Vt=(e,t)=>new RegExp(`(?:^|[^\\w.-])${ft(t)}(?![\\w-]|\\.\\w)`).test(e),Xt=(e,t,o,n,s)=>{const r=new Set,a=t.replace(zt,"");for(const p of e)/\s/.test(p)||xe(p,o,n,s)===void 0&&Vt(a,p)&&r.add(p);for(const p of a.matchAll(be))r.add(p[1].trim());return[...r]},Go=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=ke(),r=s.body,{create:a}=await import("@symbo.ls/element"),p=await import("@symbo.ls/utils"),l={...xt,...o.components||{}},h={...p,...o.utils||{},...o.functions||{}};we();let f;try{f=a(e,{node:r},"root",{context:{document:s,window:n,...o,components:l,utils:h}})}catch{}_e(r);const c=f?je(f):{};return{html:Be(r.innerHTML),registry:c,element:f}},Be=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,s)=>{if(n.includes("&lt;")){const r=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+r+s}return t}),Qt=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],Zt=new Set(["auto","system"]),Ke=e=>{if(!e||typeof e!="object")return null;const t=e.config&&typeof e.config=="object"?e.config:{};if((t.themeRoot!=null?t.themeRoot:e.themeRoot)!=null)return null;const n=t.globalTheme!=null?t.globalTheme:e.globalTheme;if(typeof n!="string")return null;const s=n.trim();return!s||Zt.has(s)?null:s},eo=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),to=/\.[A-Za-z_\\-]/,oo=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!to.test(t)},no=/^\s*(:root|\[data-theme|\[data-skin)/,Ge=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 oo(e.selectorText)?no.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(Ge));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Ne=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),so=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ge(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
3
3
  `),resetRules:t.reset.join(`
4
4
  `),keyframeRules:t.keyframes.join(`
5
- `),fontFaceCSS:""},classRules:o}};let ie=new Set;const Ko=()=>{ie=new Set},Go=()=>Array.from(ie).join(`
6
- `),No=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
5
+ `),fontFaceCSS:""},classRules:o}};let ae=new Set;const No=()=>{ae=new Set},Ho=()=>Array.from(ae).join(`
6
+ `),Uo=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
8
- </style>`:""),Ho=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,a=await Ie(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!a)return null;const p=e.designSystem||{},l=a.globalCSS;let g=null;try{const c=no(a.element);Object.keys(c).length&&(g=c)}catch{}const f=a.activeLang;return{html:a.html,css:a.classRules.join(`
9
- `),classRules:a.classRules.slice(),globalCSS:l,resetCss:l.resetRules,fontLinks:He(p),metadata:a.metadata||pe(e,o),brKeyCount:a.registry?Object.keys(a.registry).length:0,brRegistry:a.brRegistry||{},fetchSeed:a.fetchSeed||[],ssrTranslations:a.ssrTranslations,prefetchedState:g,activeLang:f,theme:Be(e),diagnostics:a.diagnostics,preparedDesignSystem:a.preparedDesignSystem||null}},no=e=>{const t={};return Le(e,o=>{const n=o.fetch;if(!(!n||typeof n!="object"||!o.state))for(const s of Array.isArray(n)?n:[n]){const r=s&&typeof s=="object"&&typeof s.as=="string"?s.as:null;if(!r)continue;const a=r.startsWith("~/"),p=a?r.slice(2):r,l=a?o.state.root:o.state,g=be(l&&l[p]);p&&g!=null&&typeof g!="function"&&(t[p]=g)}}),t},Uo=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:a=!0,prefetch:p=!0,shell:l,adoptDom:g=!1,pathname:f,eagerImages:c=Ne,preloadScripts:i=!0,nonce:u,timeout:d,stamp:b,time:E,spriteIcons:x="all",cssClasses:w="all",cssVariables:Q="all",registryFormat:v="paths"}=o,P=lo(u),D=n||e.state?.lang||e.app?.metadata?.lang||"en",N=Be(e),S=await Ie(e,{route:t,pathname:f,prefetch:p,timeout:d});if(!S)return null;const A={...S.metadata};if(s&&(A["theme-color"]=s),typeof l=="string"&&!e.name){const R="\0brender-undeclared-title\0";if(pe({...e,name:R},t,S.element,S.element?.state).title===R)for(const G of["title","og:title","twitter:title"])A[G]===S.metadata.title&&delete A[G]}const j=et(A);for(const R of S.classRules)R&&ie.add(R);let C=co(S.html,c);x==="page"&&(C=ot(C,typeof l=="string"?l:"").html);const J=Array.from(ie),Y=J.filter(Ge),Z=Y.length?J.filter(R=>!Ge(R)):J,z=w==="page"?nt(Z,st(C,typeof l=="string"?l:"")).join(`
10
- `):Z.join(`
11
- `),F=Y.length?`<style data-smbls-faces>
12
- ${Y.join(`
8
+ </style>`:""),Wo=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,a=await Pe(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!a)return null;const p=e.designSystem||{},l=a.globalCSS;let h=null;try{const c=ro(a.element);Object.keys(c).length&&(h=c)}catch{}const f=a.activeLang;return{html:a.html,css:a.classRules.join(`
9
+ `),classRules:a.classRules.slice(),globalCSS:l,resetCss:l.resetRules,fontLinks:Ue(p),metadata:a.metadata||ue(e,o),brKeyCount:a.registry?Object.keys(a.registry).length:0,brRegistry:a.brRegistry||{},fetchSeed:a.fetchSeed||[],ssrTranslations:a.ssrTranslations,prefetchedState:h,activeLang:f,theme:Ke(e),diagnostics:a.diagnostics,preparedDesignSystem:a.preparedDesignSystem||null}},ro=e=>{const t={};return $e(e,o=>{const n=o.fetch;if(!(!n||typeof n!="object"||!o.state))for(const s of Array.isArray(n)?n:[n]){const r=s&&typeof s=="object"&&typeof s.as=="string"?s.as:null;if(!r)continue;const a=r.startsWith("~/"),p=a?r.slice(2):r,l=a?o.state.root:o.state,h=Se(l&&l[p]);p&&h!=null&&typeof h!="function"&&(t[p]=h)}}),t},Jo=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:a=!0,prefetch:p=!0,shell:l,adoptDom:h=!1,pathname:f,eagerImages:c=He,preloadScripts:i=!0,nonce:u,timeout:g,stamp:y,time:x,spriteIcons:ie="all",cssClasses:j="all",cssVariables:w="all",registryFormat:H="paths"}=o,T=po(u),V=n||e.state?.lang||e.app?.metadata?.lang||"en",v=Ke(e),S=await Pe(e,{route:t,pathname:f,prefetch:p,timeout:g});if(!S)return null;const P={...S.metadata};if(s&&(P["theme-color"]=s),typeof l=="string"&&!e.name){const d="\0brender-undeclared-title\0";if(ue({...e,name:d},t,S.element,S.element?.state).title===d)for(const D of["title","og:title","twitter:title"])P[D]===S.metadata.title&&delete P[D]}const K=et(P);for(const d of S.classRules)d&&ae.add(d);let k=io(S.html,c);ie==="page"&&(k=ot(k,typeof l=="string"?l:"").html);const U=Array.from(ae),W=U.filter(Ne),X=W.length?U.filter(d=>!Ne(d)):U,J=j==="page"?nt(X,st(k,typeof l=="string"?l:"")).join(`
10
+ `):X.join(`
11
+ `),Q=W.length?`<style data-smbls-faces>
12
+ ${W.join(`
13
13
  `)}
14
- </style>`:"",q=S.globalCSS,M=`<style data-brender>
15
- ${(Q==="page"?rt(q.rootRule||"",q.resetRules,q.keyframeRules,z,C,typeof l=="string"?l:"").css:q.rootRule)||""}
16
- ${q.resetRules||""}
17
- ${q.keyframeRules||""}
18
- </style>`,V=z?`<style data-emotion="smbls">
19
- ${z}
20
- </style>`:"",ee=He(e.designSystem||{}),te=Object.keys(S.registry).length,le=v==="tree"||v==="auto"&&(S.registryFormats||[]).includes("tree"),L=ao({brRegistry:S.brRegistry,fetchSeed:S.fetchSeed,adoptDom:g,stamp:b,time:E,registryFormat:le?"tree":"paths"});let B="";if(r&&r.clientScript){const R=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,T=R>0?"../".repeat(R):"./";if(a){const G=dt({polyglot:e.polyglot||e.config?.polyglot,translations:S.ssrTranslations,lang:S.activeLang,pathname:f||t,attrs:P}),Ue=G?G+`
21
- `:"",We=L.blocks?L.blocks+`
22
- `:"";B=`${Ue}${We}<script type="module" src="${T}${r.clientScript}"${P}><\/script>`}else B=`<script type="module"${P}>
14
+ </style>`:"",L=S.globalCSS,Z=`<style data-brender>
15
+ ${(w==="page"?rt(L.rootRule||"",L.resetRules,L.keyframeRules,J,k,typeof l=="string"?l:"").css:L.rootRule)||""}
16
+ ${L.resetRules||""}
17
+ ${L.keyframeRules||""}
18
+ </style>`,A=J?`<style data-emotion="smbls">
19
+ ${J}
20
+ </style>`:"",Y=Ue(e.designSystem||{}),ee=Object.keys(S.registry).length,le=H==="tree"||H==="auto"&&(S.registryFormats||[]).includes("tree"),I=lo({brRegistry:S.brRegistry,fetchSeed:S.fetchSeed,adoptDom:h,stamp:y,time:x,registryFormat:le?"tree":"paths"});let C="";if(r&&r.clientScript){const d=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,_=d>0?"../".repeat(d):"./";if(a){const D=gt({polyglot:e.polyglot||e.config?.polyglot,translations:S.ssrTranslations,lang:S.activeLang,pathname:f||t,attrs:T}),fe=D?D+`
21
+ `:"",We=I.blocks?I.blocks+`
22
+ `:"";C=`${fe}${We}<script type="module" src="${_}${r.clientScript}"${T}><\/script>`}else C=`<script type="module"${T}>
23
23
  {
24
24
  const brEls = document.querySelectorAll('body > :not(script):not(style)')
25
25
  const observer = new MutationObserver((mutations) => {
@@ -36,23 +36,23 @@ ${z}
36
36
  observer.observe(document.body, { childList: true })
37
37
  }
38
38
  <\/script>
39
- <script type="module" src="${T}${r.clientScript}"${P}><\/script>`}const K={...e.config||{}};e.polyglot&&!K.polyglot&&(K.polyglot=e.polyglot);const I=K.polyglot;let H=j;if(I){const R={...I.translations||{}};for(const T in S.ssrTranslations||{})R[T]={...R[T]||{},...S.ssrTranslations[T]};H=Pe(j,Oe(R,S.activeLang,I))}const y=S.diagnostics;if(y)for(const R of H.matchAll(ye)){const T=R[1].trim();y.rawLabelKeys.includes(T)||y.rawLabelKeys.push(T)}return typeof l=="string"?{html:tt(l,{headTags:`${H}
40
- ${L.meta}`,headEnd:[ee,F,M,V].filter(Boolean).join(`
41
- `),body:C,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:L.blocks,lang:n||(I?S.activeLang:void 0),theme:N,preloadScripts:i}),route:t,brKeyCount:te,shell:!0,diagnostics:y,preparedDesignSystem:S.preparedDesignSystem||null}:{html:`<!DOCTYPE html>
42
- <html lang="${D}"${N?` data-theme="${Qt(N)}"`:""}>
39
+ <script type="module" src="${_}${r.clientScript}"${T}><\/script>`}const F={...e.config||{}};e.polyglot&&!F.polyglot&&(F.polyglot=e.polyglot);const q=F.polyglot;let M=K;if(q){const d={...q.translations||{}};for(const _ in S.ssrTranslations||{})d[_]={...d[_]||{},...S.ssrTranslations[_]};M=Fe(K,Ie(d,S.activeLang,q))}const B=S.diagnostics;if(B)for(const d of M.matchAll(be)){const _=d[1].trim();B.rawLabelKeys.includes(_)||B.rawLabelKeys.push(_)}return typeof l=="string"?{html:tt(l,{headTags:`${M}
40
+ ${I.meta}`,headEnd:[Y,Q,Z,A].filter(Boolean).join(`
41
+ `),body:k,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:I.blocks,lang:n||(q?S.activeLang:void 0),theme:v,preloadScripts:i}),route:t,brKeyCount:ee,shell:!0,diagnostics:B,preparedDesignSystem:S.preparedDesignSystem||null}:{html:`<!DOCTYPE html>
42
+ <html lang="${V}"${v?` data-theme="${eo(v)}"`:""}>
43
43
  <head>
44
- ${H}${r&&r.clientScript&&a?`
45
- ${L.meta}`:""}
46
- ${ee}
47
- ${F}
48
- ${M}
49
- ${V}
44
+ ${M}${r&&r.clientScript&&a?`
45
+ ${I.meta}`:""}
46
+ ${Y}
47
+ ${Q}
48
+ ${Z}
49
+ ${A}
50
50
  </head>
51
51
  <body>
52
+ ${k}
52
53
  ${C}
53
- ${B}
54
54
  </body>
55
- </html>`,route:t,brKeyCount:te,diagnostics:y,preparedDesignSystem:S.preparedDesignSystem||null}},Ne=2,so=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,ro=/\sloading\s*=/i,co=(e,t=Ne)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(so,s=>n++<o||ro.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},He=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const s of Object.values(t)){if(typeof s!="string")continue;const r=s.match(/'([^']+)'/);r&&o.add(r[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(s=>`family=${s.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
56
- `):""},ao=({brRegistry:e,fetchSeed:t,adoptDom:o=!1,stamp:n,time:s,registryFormat:r="paths"}={})=>{const p=o&&e&&Object.keys(e).length?r==="tree"&&ht(e)||gt(e):"",l=bt(t);return{meta:`<meta name="brender" content="${p?"hydrate":"replace"}">
57
- `+lt(io(n,s)),blocks:[p,l].filter(Boolean).join(`
58
- `)}},io=(e,t)=>{const o=typeof t=="number"&&isFinite(t)?Math.round(t):Date.now();return{stamp:e!=null&&e!==""?String(e):new Date(o).toISOString(),time:o}},lo=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{Ne as EAGER_IMAGES_DEFAULT,_e as SMBLS_SSR_SPECIFIER,Fo as adoptionScripts,io as buildStamp,Be as fixedThemeOf,Go as getAccumulatedEmotionCSS,co as markLazyImages,ao as prerenderParts,Ie as render,Bo as renderElement,Uo as renderPage,Ho as renderRoute,No as replaceEmotionCSS,Ko as resetGlobalCSSCache,oo as splitCapturedCSS};
55
+ </html>`,route:t,brKeyCount:ee,diagnostics:B,preparedDesignSystem:S.preparedDesignSystem||null}},He=2,co=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,ao=/\sloading\s*=/i,io=(e,t=He)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(co,s=>n++<o||ao.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},Ue=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const s of Object.values(t)){if(typeof s!="string")continue;const r=s.match(/'([^']+)'/);r&&o.add(r[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(s=>`family=${s.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
56
+ `):""},lo=({brRegistry:e,fetchSeed:t,adoptDom:o=!1,stamp:n,time:s,registryFormat:r="paths"}={})=>{const p=o&&e&&Object.keys(e).length?r==="tree"&&yt(e)||ht(e):"",l=St(t);return{meta:`<meta name="brender" content="${p?"hydrate":"replace"}">
57
+ `+lt(fo(n,s)),blocks:[p,l].filter(Boolean).join(`
58
+ `)}},fo=(e,t)=>{const o=typeof t=="number"&&isFinite(t)?Math.round(t):Date.now();return{stamp:e!=null&&e!==""?String(e):new Date(o).toISOString(),time:o}},po=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{He as EAGER_IMAGES_DEFAULT,ve as SMBLS_SSR_SPECIFIER,Ko as adoptionScripts,fo as buildStamp,Ke as fixedThemeOf,Ho as getAccumulatedEmotionCSS,io as markLazyImages,lo as prerenderParts,Pe as render,Go as renderElement,Jo as renderPage,Wo as renderRoute,Uo as replaceEmotionCSS,No as resetGlobalCSSCache,so as splitCapturedCSS};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/brender",
3
- "version": "3.14.673",
3
+ "version": "3.14.674",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -52,12 +52,12 @@
52
52
  "@symbo.ls/fetch": "^3.14.669",
53
53
  "@symbo.ls/helmet": "^3.14.671",
54
54
  "@symbo.ls/scratch": "^3.14.795",
55
- "@symbo.ls/utils": "^3.14.849",
55
+ "@symbo.ls/utils": "^3.14.851",
56
56
  "esbuild": "^0.28.1",
57
57
  "linkedom": "^0.16.8"
58
58
  },
59
59
  "peerDependencies": {
60
- "smbls": "^3.14.851"
60
+ "smbls": "^3.14.856"
61
61
  },
62
62
  "optionalDependencies": {
63
63
  "@symbo.ls/funcql": "^3.14.0"
package/render.js CHANGED
@@ -14,7 +14,7 @@ import { trimSpriteToPage, classRulesForPage, markupClasses, trimVariablesToPage
14
14
  import { fetchSSRTranslations } from './prefetch.js'
15
15
  import { createEarlySeedScript } from '@symbo.ls/fetch'
16
16
  import { headerEntries } from '@symbo.ls/fetch/rest'
17
- import { brenderStampMeta, escapeRegExp, jsonForScript, polyglotFallbackLang, polyglotLangStorageKey, polyglotAddressLang, polyglotStartupScript } from '@symbo.ls/utils'
17
+ import { brenderStampMeta, escapeRegExp, jsonForScript, libraryPackageSpecs, polyglotFallbackLang, polyglotLangStorageKey, polyglotAddressLang, polyglotStartupScript } from '@symbo.ls/utils'
18
18
  import { brenderRegistryBlock, brenderRegistryTreeBlock } from '@symbo.ls/utils/server'
19
19
 
20
20
  // funcql plugin — enables evaluation of funcql schemas as property values
@@ -925,12 +925,65 @@ export const adoptionScripts = ({ brRegistry, fetchSeed, hydrateFlag = true } =
925
925
  (fetchSeed && fetchSeed.length ? '\n' + createEarlySeedScript(fetchSeed) : '')
926
926
  }
927
927
 
928
+ // ── Each render's own shared libraries ──────────────────────────────────────
929
+ // A boot registers every linked shared library on `globalThis.__SMBLS_PKGS__`
930
+ // (smbls registerSharedLibraryPackages: the raw library objects under their
931
+ // BARE package names — `@symbo-ls/<key>`, the owner dropped — first-wins),
932
+ // and frank's facade for a literal dynamic import of a declared library
933
+ // (`await import('@symbo-ls/kit/functions/index.js')`) answers from that
934
+ // registry only. One process renders many projects — the platform's
935
+ // published-site worker builds every published project — so the FIRST
936
+ // project's library answered every later project's facade: another owner's
937
+ // library under the same key, or another pinned version of it (merge
938
+ // programme 2026-10-25, lane F1 follow-up N1). So a render takes back, when
939
+ // it ends, the entries ITS libraries added: each package name
940
+ // `libraryPackageSpecs` gives for the render's `sharedLibraries` — the names
941
+ // the boot registered them under — that the registry did not hold when the
942
+ // render's turn started. It is one of the put-backs of "One render at a
943
+ // time": a render that throws, or is abandoned at its limit, takes them back
944
+ // too. Everything else a render registers stays the process's — the
945
+ // framework packages (from smbls source the first render loads the kits,
946
+ // and their `smbls` entry registers every framework package then), the
947
+ // host's packages, the dependencies a boot loaded — and so does an entry the
948
+ // registry held before the render under one of its libraries' names (the
949
+ // boot's first-wins kept it, so it was never the render's). The registry
950
+ // object itself stays the process's: a render's own view of it, swapped like
951
+ // `document`, lost every framework package its first render registered, and
952
+ // code that keeps the object (the lazy entries of smbls registerLazyPackages
953
+ // settle on the store they were defined on) would have kept that view. An
954
+ // abandoned render's boot that registers a library only after it was
955
+ // abandoned (a library it resolves at runtime) leaves that entry in the
956
+ // registry — the limit "One render at a time" names for every bare global.
957
+ // The registry keys stay the bare package names: they are what every
958
+ // published bundle's facade reads (frank scopeRewriter.js).
959
+ const takeBackLibraryEntries = (librariesOf) => {
960
+ const found = globalThis.__SMBLS_PKGS__
961
+ const held = new Set(found && typeof found === 'object' ? Object.getOwnPropertyNames(found) : [])
962
+ return () => {
963
+ const store = globalThis.__SMBLS_PKGS__
964
+ if (!store || typeof store !== 'object') return
965
+ let specs
966
+ try {
967
+ specs = libraryPackageSpecs(librariesOf())
968
+ } catch (e) {
969
+ // the boot named the libraries with this function to register them:
970
+ // a list it cannot name registered nothing
971
+ return
972
+ }
973
+ // own entries only, never read: a lazy entry is an accessor
974
+ for (const [spec] of specs) {
975
+ if (!held.has(spec) && Object.prototype.hasOwnProperty.call(store, spec)) Reflect.deleteProperty(store, spec)
976
+ }
977
+ }
978
+ }
979
+
928
980
  // ── One render at a time ────────────────────────────────────────────────────
929
981
  // A render puts its environment on the process's BARE globals — `document`,
930
982
  // `location`, `localStorage`, `sessionStorage` (swapGlobal below) and
931
983
  // `window` (createEnv) — because the framework reads them bare, and it shares
932
984
  // process-wide records with the code it runs (the fetch seed and diagnostics
933
- // above, the data-br key counter, the CSS engine's reset). Every render owns
985
+ // above, the data-br key counter, the CSS engine's reset, the package
986
+ // registry: see "Each render's own shared libraries"). Every render owns
934
987
  // its location, Web Storage, history (createEnv) and query store
935
988
  // (`isolateFetchCache`), yet renders that overlapped in one process still
936
989
  // swapped those bare globals over each other: of five overlapping renders,
@@ -1131,11 +1184,16 @@ const renderWithDiagnostics = async (data, { route, locationPath, stateOverrides
1131
1184
  // lazy accessor) is never read or lost. Each goes back once: at the end of
1132
1185
  // the render, or at its timeout (`turn.undo`) — then never again, when the
1133
1186
  // abandoned render unwinds over a later render's globals.
1187
+ // The context this render boots with, once it is built: the boot reads its
1188
+ // `sharedLibraries` and registers them (see "Each render's own shared
1189
+ // libraries").
1190
+ let renderContext = null
1134
1191
  const restoreGlobals = [
1135
1192
  swapGlobal('document', document),
1136
1193
  swapGlobal('location', window.location),
1137
1194
  swapGlobal('localStorage', window.localStorage),
1138
- swapGlobal('sessionStorage', window.sessionStorage)
1195
+ swapGlobal('sessionStorage', window.sessionStorage),
1196
+ takeBackLibraryEntries(() => renderContext && renderContext.sharedLibraries)
1139
1197
  ].map(once)
1140
1198
  turn.undo.push(...restoreGlobals)
1141
1199
  try {
@@ -1273,6 +1331,7 @@ const renderWithDiagnostics = async (data, { route, locationPath, stateOverrides
1273
1331
  // Caller overrides
1274
1332
  ...(contextOverrides || {})
1275
1333
  }
1334
+ renderContext = ctx
1276
1335
 
1277
1336
  // Add funcql plugin if available (enables funcql schema evaluation in exec())
1278
1337
  const funcql = await getFuncqlPlugin()
package/shell.js CHANGED
@@ -138,6 +138,17 @@ const rebaseAssets = (html, depth) => {
138
138
  // CORS/integrity attributes, so the browser reuses the response. An `async`
139
139
  // script (a helper the app does not wait for) or a `nomodule` one is left
140
140
  // alone, as is anything that is not JavaScript (importmap, JSON data).
141
+ //
142
+ // Lighthouse 13.5.0 (trace_engine 0.0.65) counts this script's DOWNLOAD in
143
+ // its simulated FCP whenever the download ends before the observed first
144
+ // paint: Lantern only links classic `EvaluateScript` events to a URL, never a
145
+ // module's `v8.evaluateModule`, so it cannot prove a module ran after the
146
+ // paint. The simulated FCP then flips between two values from run to run
147
+ // (XMA, smbls 3.14.854: 1.1 s / 1.8 s) while the real paint does not move.
148
+ // trace_engine 0.0.67 (crbug.com/568836981, lighthouse 13.5.0-dev.20261023)
149
+ // links module evaluation and the flip is gone. Do not lower this priority to
150
+ // please the old Lantern — only `fetchpriority="low"` gets the script out of
151
+ // its "render-blocking" set, and that hands the bandwidth back to the images.
141
152
  const SCRIPT_TYPES = new Set(['', 'module', 'text/javascript', 'application/javascript'])
142
153
 
143
154
  const hasAttr = (tag, name) => new RegExp(`\\s${name}(?:\\s*=|\\s|>|/)`, 'i').test(tag)