@symbo.ls/utils 3.14.785 → 3.14.787

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,39 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.787
4
+
5
+ ### Patch Changes
6
+
7
+ - xma.info report round (FW-XMA-EXCEPTIONS-UPSTREAM-1), its /simplify pass and the follow-ups.
8
+
9
+ - 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.
10
+ - 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.
11
+ - router: the newest navigation wins over one waiting on an async guard; no lazy chunk rides along a resumed route.
12
+ - 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.
13
+ - 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.
14
+ - 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`.
15
+ - 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.
16
+ - frank-audit: FA205 reports only factory calls that run at module load.
17
+
18
+ - Updated dependencies
19
+ - @symbo.ls/fetch@3.14.665
20
+
21
+ ## 3.14.786
22
+
23
+ ### Patch Changes
24
+
25
+ - Performance pass on the 3.14.827–3.14.832 batch, and opt-in View Transitions.
26
+
27
+ - Element create is faster than 3.14.826 again (kekela-like 4,068-element tree: create CPU min 1,265–1,355 ms vs 1,361–1,532 ms on 3.14.826). Per-definition caching of the extends merge layers (46,330 → 13,600 entries), no per-element source-text reads, one attribute writer.
28
+ - `css()` 3x faster (21 → 7 µs per call), byte-identical CSS output.
29
+ - Helmet renders a head layer only when its values change (20 `root.update({})` → 0 head renders, was 40). One runtime head writer: `applyElementMetadata`.
30
+ - brender/mermaid: registry script is escaped on the ISR and non-adopt paths; head/SSR output byte-identical otherwise.
31
+ - View Transitions for page switches (opt-in), `viewTransitionName` / `viewTransitionClass` flat props, `designSystem.viewTransition` animations.
32
+ - utils exports shared helpers used by helmet, frank, fetch and polyglot (escapeHtml, jsonForScript, alternateLinkKey, faviconLinkKey, bareLibraryKey, librarySpecsFor, polyglotLangStorageKey, ...).
33
+
34
+ - Updated dependencies
35
+ - @symbo.ls/fetch@3.14.664
36
+
3
37
  ## 3.14.785
4
38
 
5
39
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./key.js"),module.exports);o(r,require("./env.js"),module.exports);o(r,require("./types.js"),module.exports);o(r,require("./object.js"),module.exports);o(r,require("./function.js"),module.exports);o(r,require("./array.js"),module.exports);o(r,require("./node.js"),module.exports);o(r,require("./if.js"),module.exports);o(r,require("./log.js"),module.exports);o(r,require("./string.js"),module.exports);o(r,require("./globals.js"),module.exports);o(r,require("./cookie.js"),module.exports);o(r,require("./tags.js"),module.exports);o(r,require("./component.js"),module.exports);o(r,require("./props.js"),module.exports);o(r,require("./extends.js"),module.exports);o(r,require("./element.js"),module.exports);o(r,require("./state.js"),module.exports);o(r,require("./keys.js"),module.exports);o(r,require("./scope.js"),module.exports);o(r,require("./methods.js"),module.exports);o(r,require("./cache.js"),module.exports);o(r,require("./update.js"),module.exports);o(r,require("./triggerEvent.js"),module.exports);o(r,require("./projectKeys.js"),module.exports);o(r,require("./legacyScopePreamble.js"),module.exports);o(r,require("./browser.js"),module.exports);o(r,require("./cdn.js"),module.exports);o(r,require("./date.js"),module.exports);o(r,require("./detectHeight.js"),module.exports);o(r,require("./fibonacci.js"),module.exports);o(r,require("./files.js"),module.exports);o(r,require("./load.js"),module.exports);o(r,require("./metadata.js"),module.exports);o(r,require("./scaling.js"),module.exports);o(r,require("./sharedLibraries.js"),module.exports);o(r,require("./string-extra.js"),module.exports);o(r,require("./style.js"),module.exports);o(r,require("./assets.js"),module.exports);
1
+ "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./key.js"),module.exports);o(r,require("./env.js"),module.exports);o(r,require("./types.js"),module.exports);o(r,require("./object.js"),module.exports);o(r,require("./function.js"),module.exports);o(r,require("./array.js"),module.exports);o(r,require("./node.js"),module.exports);o(r,require("./if.js"),module.exports);o(r,require("./log.js"),module.exports);o(r,require("./string.js"),module.exports);o(r,require("./globals.js"),module.exports);o(r,require("./cookie.js"),module.exports);o(r,require("./tags.js"),module.exports);o(r,require("./component.js"),module.exports);o(r,require("./props.js"),module.exports);o(r,require("./extends.js"),module.exports);o(r,require("./element.js"),module.exports);o(r,require("./state.js"),module.exports);o(r,require("./keys.js"),module.exports);o(r,require("./scope.js"),module.exports);o(r,require("./methods.js"),module.exports);o(r,require("./cache.js"),module.exports);o(r,require("./update.js"),module.exports);o(r,require("./triggerEvent.js"),module.exports);o(r,require("./projectKeys.js"),module.exports);o(r,require("./legacyScopePreamble.js"),module.exports);o(r,require("./polyglotLang.js"),module.exports);o(r,require("./browser.js"),module.exports);o(r,require("./cdn.js"),module.exports);o(r,require("./date.js"),module.exports);o(r,require("./detectHeight.js"),module.exports);o(r,require("./fibonacci.js"),module.exports);o(r,require("./files.js"),module.exports);o(r,require("./load.js"),module.exports);o(r,require("./metadata.js"),module.exports);o(r,require("./scaling.js"),module.exports);o(r,require("./sharedLibraries.js"),module.exports);o(r,require("./string-extra.js"),module.exports);o(r,require("./style.js"),module.exports);o(r,require("./assets.js"),module.exports);
package/dist/cjs/keys.js CHANGED
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!i.call(e,o)&&o!==n&&a(e,o,{get:()=>t[o],enumerable:!(s=c(t,o))||s.enumerable});return e};var x=e=>h(a({},"__esModule",{value:!0}),e);var y={};E(y,{DOMQL_EVENTS:()=>g,DOMQ_PROPERTIES:()=>S,ELEMENT_METHOD_OVERRIDE_POINTS:()=>l,METHODS:()=>r,METHODS_EXL:()=>f,PARSED_DOMQ_PROPERTIES:()=>R,PROPS_METHODS:()=>d,STATE_METHODS:()=>p,STATE_PROPERTIES:()=>u,isBuiltinElementMethod:()=>m,isProtectedElementMethod:()=>P});module.exports=x(y);const S=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),R=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),u=["ref","parent","__element","__depends","__ref","__children","root"],p=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),d=new Set(["update","__element"]),r=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),m=e=>r.has(e),l=new Set(["log","warn","error","verbose"]),P=e=>r.has(e)&&!l.has(e),f=new Set(["node","context","extends","__element","__ref",...r,...p,...d]),g=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);
1
+ "use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!i.call(e,o)&&o!==n&&a(e,o,{get:()=>t[o],enumerable:!(s=c(t,o))||s.enumerable});return e};var x=e=>h(a({},"__esModule",{value:!0}),e);var y={};E(y,{DOMQL_EVENTS:()=>g,DOMQ_PROPERTIES:()=>S,ELEMENT_METHOD_OVERRIDE_POINTS:()=>l,METHODS:()=>r,METHODS_EXL:()=>f,PARSED_DOMQ_PROPERTIES:()=>R,PROPS_METHODS:()=>d,STATE_METHODS:()=>p,STATE_PROPERTIES:()=>u,isBuiltinElementMethod:()=>m,isProtectedElementMethod:()=>P});module.exports=x(y);const S=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),R=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),u=["ref","parent","__element","__depends","__ref","__children","root"],p=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),d=new Set(["update","__element"]),r=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","whenConnected","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),m=e=>r.has(e),l=new Set(["log","warn","error","verbose"]),P=e=>r.has(e)&&!l.has(e),f=new Set(["node","context","extends","__element","__ref",...r,...p,...d]),g=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var o in e)g(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of O(e))!b.call(t,n)&&n!==o&&g(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var h=t=>u(g({},"__esModule",{value:!0}),t);var w={};R(w,{repairLegacyArrowScopePreamble:()=>d});module.exports=h(w);const $=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],p=(t,e)=>t.split("$R").join(e),P=$.map(t=>[p(t,"this"),t]),i="const __scope = ",j=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,a=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,x=/^[A-Za-z_$][\w$]*$/,c=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),S=t=>t.length>=2&&c(t[0],"el")?t[0]:t.length>=2&&c(t[1],"el")?t[1]:t.length>=1&&c(t[0],"el")||c(t[0],"element")||c(t[0],"node")?t[0]:t.find(e=>c(e,"element"))||null,d=t=>{if(typeof t!="string"||t.indexOf(i)===-1||t.indexOf("this")===-1)return t;const e=a.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(i,o))return t;o+=i.length;const s=j.exec(t.slice(o,o+400));s&&(o+=s[0].length);const n=P.find(([r])=>t.startsWith(r,o));if(!n)return t;const l=o+n[0].length;if(t[l]!==(s?")":";"))return t;const f=(e[1]!==void 0?e[1]:e[2]).split(",").map(r=>r.split("=")[0].trim()).filter(Boolean);if(f.some(r=>!x.test(r)))return t;const _=S(f);return _?t.slice(0,o)+p(n[1],_)+t.slice(l):t};
1
+ "use strict";var g=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var o in e)g(t,o,{get:e[o],enumerable:!0})},$=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of u(e))!R.call(t,n)&&n!==o&&g(t,n,{get:()=>e[n],enumerable:!(s=b(e,n))||s.enumerable});return t};var P=t=>$(g({},"__esModule",{value:!0}),t);var w={};h(w,{repairLegacyArrowScopePreamble:()=>E,scopeElementParam:()=>O,scopeReceiverExpression:()=>j});module.exports=P(w);const i=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],f=(t,e)=>t.split("$R").join(e),x=i.map(t=>[f(t,"this"),t]),j=t=>f(i[i.length-1],t),l="const __scope = ",d=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,S=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,a=/^[A-Za-z_$][\w$]*$/,c=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),O=(t,e)=>{if(t.length>=2&&c(t[0],"el"))return t[0];if(t.length>=2&&c(t[1],"el"))return t[1];if(t.length>=1&&c(t[0],"el")||c(t[0],"element")||c(t[0],"node"))return t[0];if(typeof e=="function"){const o=e();if(o&&t.includes(o))return o}return t.find(o=>c(o,"element"))||null},E=t=>{if(typeof t!="string"||t.indexOf(l)===-1||t.indexOf("this")===-1)return t;const e=S.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(l,o))return t;o+=l.length;const s=d.exec(t.slice(o,o+400));s&&(o+=s[0].length);const n=x.find(([r])=>t.startsWith(r,o));if(!n)return t;const _=o+n[0].length;if(t[_]!==(s?")":";"))return t;const p=(e[1]!==void 0?e[1]:e[2]).split(",").map(r=>r.split("=")[0].trim()).filter(Boolean);if(p.some(r=>!a.test(r)))return t;const y=O(p);return y?t.slice(0,o)+f(n[1],y)+t.slice(_):t};
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var U=(e,n)=>{for(var t in n)A(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of F(n))!K.call(e,i)&&i!==t&&A(e,i,{get:()=>n[i],enumerable:!(s=T(n,i))||s.enumerable});return e};var P=e=>D(A({},"__esModule",{value:!0}),e);var z={};U(z,{fileEntryUrl:()=>W,generateHeadArrayTags:()=>E,generateMetaTags:()=>N,getPageMetadata:()=>B,hashContent:()=>j,resolveFileReferences:()=>x});module.exports=P(z);var b=require("./types.js"),M=require("./function.js");const p=e=>{if(e==null)return"";const n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.toString().replace(/[&<>"']/g,t=>n[t])},R=e=>Object.entries(e||{}).filter(([n,t])=>t!==void 0).map(([n,t])=>`${n}="${p(t)}"`).join(" "),j=e=>{let n=5381;const t=String(e);for(let s=0;s<t.length;s++)n=(n*33^t.charCodeAt(s))>>>0;return n.toString(36)},_=new Set(["jsonLd","styles","scripts"]),E=e=>{const n=[];if(Array.isArray(e.jsonLd))for(const t of e.jsonLd){if(t==null)continue;const s=typeof t=="string"?t:JSON.stringify(t),i=String(s).replace(/<\/script/gi,"<\\/script");n.push(`<script type="application/ld+json" data-smbls-jsonld="${j(s)}">${i}<\/script>`)}if(Array.isArray(e.styles))for(const t of e.styles){if(t==null||!String(t).trim())continue;const s=String(t).replace(/<\/style/gi,"<\\/style");n.push(`<style data-smbls-style="${j(s)}">${s}</style>`)}if(Array.isArray(e.scripts))for(const t of e.scripts){if(!t)continue;const s=typeof t=="string",i=s?t:t.src;if(!i&&!t.body)continue;const o=[];i&&o.push(`src="${p(i)}"`),s||(t.type&&o.push(`type="${p(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${p(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${p(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${p(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(i||j(t.body||""))}"`;if(!s&&t.body){const d=String(t.body).replace(/<\/script/gi,"<\\/script");n.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else n.push(`<script ${o.join(" ")}${l}><\/script>`)}return n},q=(e,n,t)=>e==="favicons"?Array.isArray(n)?typeof t=="string"?` data-smbls-favicon="${p(t)}"`:(0,b.isObject)(t)?` data-smbls-favicon="${j(JSON.stringify(t))}"`:"":"":(e==="icon"||e==="favicon")&&typeof n=="string"?` data-smbls-single-icon="${p(n)}"`:"",C=e=>(0,b.isObject)(e)?` data-smbls-alternate="${p(`${e.hreflang||""}|${e.href||""}`)}"`:"",N=(e,n)=>{n||(e={...e,robots:"noindex"});const t=Object.entries(e).reduce((s,[i,o])=>{if(!o&&o!==0&&o!==!1||_.has(i))return s;if(i==="title")return s.push(`<title>${p(o)}</title>`),s;if(i==="canonical")return s.push(`<link rel="canonical" href="${p(o)}">`),s;if(i==="manifest")return s.push(`<link rel="manifest" href="${p(o)}">`),s;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=q(i,o,c);if(typeof c=="string")s.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const r=R(c);/rel=/.test(r)?s.push(`<link ${r}${u}>`):s.push(`<link rel="icon" ${r}${u}>`)}}),s;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([r,g])=>g!==void 0).map(([r,g])=>`${r}="${p(g)}"`).join(" ");s.push(`<link rel="alternate" ${u}${C(c)}>`)}}),s;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")s.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(r=>{if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")s.push(`<meta ${u}="${p(f)}" content="${p(r)}">`);else if(typeof r=="object"){const g=Object.entries(r).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");s.push(`<meta ${g}>`)}});else if(typeof c=="object"){const r=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");s.push(`<meta ${r}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return l(f,o,"http-equiv"),s}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return l(f,o,"itemprop"),s}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),s}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),s}return l(i,o),s},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...E(e)),t.join(`
2
- `)},H=e=>typeof e=="string"&&e.length>0&&!e.startsWith("/")&&!e.startsWith("http"),S=e=>typeof e=="string"&&e.length>0,W=e=>{if(!e||typeof e!="object")return null;if(S(e.src))return e.src;const n=e.content;return!n||typeof n!="object"?null:S(n.src)?n.src:S(n.storageUrl)?n.storageUrl:null};function x(e,n){if(!n||typeof n!="object")return e;const t=i=>!H(i)||!Object.prototype.hasOwnProperty.call(n,i)?i:W(n[i])||i,s={...e};for(const[i,o]of Object.entries(s))typeof o=="string"?s[i]=t(o):Array.isArray(o)&&(s[i]=o.map(l=>typeof l=="string"?t(l):l));return s}function w(e,n){if(!e||!n)return;const t=n.split(".");let s=e;for(const i of t){if(s==null||typeof s!="object")return;s=s[i]}return s}function J(e,n){const t=w(e,n);if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&!(0,M.isStringFunction)(t))return t}function Y(e,n,t){const i=(n.config||n.settings||{}).polyglot||n.polyglot,o=t?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[t?.state,n.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const r of h){const g=J(r,u);if(g!==void 0)return g}},c={...e};for(const[u,r]of Object.entries(c))typeof r!="string"||!r.includes("{{")||(c[u]=r.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??w(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??w(d,a)??g}));return c}function L(e){if(!(0,b.isObject)(e))return{};const n={...e};for(const[t,s]of Object.entries(n))if(typeof s=="function"){const i=s.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){n[t]=`{{ ${l[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){n[t]=`{{ ${d[1]} }}`;continue}delete n[t]}else if(typeof s=="string"){const i=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){n[t]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){n[t]=`{{ ${o[1]} | polyglot }}`;continue}if(s.includes("=>")&&s.includes("s.")){const l=s.match(/s\.(\w+(?:\.\w+)+)/);if(l){n[t]=`{{ ${l[1]} }}`;continue}}(0,M.isStringFunction)(s)&&delete n[t]}return n}function B(e,n,t,{isProduction:s=!1,channel:i="production"}={}){const o=e.pages?.[n],l=(0,b.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=L(d),f=new Set(Object.keys(h)),c=e.app?.metadata||{},u=L(c);let r={};if(e.integrations?.seo?r={...e.integrations.seo,...u,...h}:Object.keys(u).length?r={...u,...h}:r={...h},!r.title){const a=e.name||e.key;a?s?r.title=a:i==="development"?r.title=`${a} / dev:symbo.ls`:i==="staging"?r.title=`${a} / staging:symbo.ls`:r.title=`${a} / symbo.ls`:r.title="Symbols demo"}r=Y(r,e,t),r.title&&(f.has("title")||!r["og:title"])&&(f.has("og:title")||(r["og:title"]=r.title)),r.description&&(f.has("description")||!r["og:description"])&&(f.has("og:description")||(r["og:description"]=r.description)),r.title&&!r["twitter:title"]&&(r["twitter:title"]=r.title),r.description&&!r["twitter:description"]&&(r["twitter:description"]=r.description);const g=f.has("og:url")?r["og:url"]:f.has("url")?r.url:void 0,y=t?.actualPathname||n;if(g)r["og:url"]=g;else if(r["og:url"]||r.url){const a=(r["og:url"]||r.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;r["og:url"]=a+m}}r=x(r,e.files);const $=e.name||e.app?.metadata?.title||e.app?.name||"";for(const[a,m]of Object.entries(r))if(typeof m=="string"&&m.includes("{{")){const O=m.replace(/\{\{[^}]*\}\}/g,"").trim();O?r[a]=O:a==="title"?r[a]=$:delete r[a]}return r}
1
+ "use strict";var S=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var _=(t,r)=>{for(var e in r)S(t,e,{get:r[e],enumerable:!0})},q=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of D(r))!F.call(t,s)&&s!==e&&S(t,s,{get:()=>r[s],enumerable:!(n=W(r,s))||n.enumerable});return t};var C=t=>q(S({},"__esModule",{value:!0}),t);var k={};_(k,{BRENDER_REGISTRY_BLOCK:()=>P,alternateLinkKey:()=>R,brenderRegistryBlock:()=>B,escapeHtml:()=>p,faviconLinkKey:()=>K,fileEntryUrl:()=>N,generateHeadArrayTags:()=>E,generateMetaTags:()=>I,getPageMetadata:()=>Z,hashContent:()=>j,jsonForScript:()=>x,readJsonDataBlock:()=>U,resolveFileReferences:()=>T});module.exports=C(k);var m=require("./types.js"),L=require("./function.js");const p=t=>{if(t==null)return"";const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>r[e])},x=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),U=(t,r,{remove:e=!1,warn:n}={})=>{if(!t||typeof t.querySelector!="function")return null;let s=null;try{s=t.querySelector(r)}catch{return null}if(!s)return null;e&&s.parentNode&&s.parentNode.removeChild(s);let o;try{o=JSON.parse(s.textContent||"")}catch(l){n&&n(l)}return{value:o,block:s}},P='script[type="application/json"][data-brender="registry"]',B=t=>'<script type="application/json" data-brender="registry">'+x(t)+"<\/script>",J=t=>Object.entries(t||{}).filter(([r,e])=>e!==void 0).map(([r,e])=>`${r}="${p(e)}"`).join(" "),j=t=>{let r=5381;const e=String(t);for(let n=0;n<e.length;n++)r=(r*33^e.charCodeAt(n))>>>0;return r.toString(36)},H=new Set(["jsonLd","styles","scripts"]),E=t=>{const r=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const n=typeof e=="string"?e:JSON.stringify(e),s=String(n).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${j(n)}">${s}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const n=String(e).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${j(n)}">${n}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const n=typeof e=="string",s=n?e:e.src;if(!s&&!e.body)continue;const o=[];s&&o.push(`src="${p(s)}"`),n||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(s||j(e.body||""))}"`;if(!n&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else r.push(`<script ${o.join(" ")}${l}><\/script>`)}return r},R=t=>`${t.hreflang||""}|${t.href||""}`,K=t=>(0,m.isObject)(t)?j(JSON.stringify(t)):String(t),Y=(t,r,e)=>t==="favicons"?Array.isArray(r)&&(typeof e=="string"||(0,m.isObject)(e))?` data-smbls-favicon="${p(K(e))}"`:"":(t==="icon"||t==="favicon")&&typeof r=="string"?` data-smbls-single-icon="${p(r)}"`:"",G=t=>(0,m.isObject)(t)?` data-smbls-alternate="${p(R(t))}"`:"",I=(t,r)=>{r||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((n,[s,o])=>{if(!o&&o!==0&&o!==!1||H.has(s))return n;if(s==="title")return n.push(`<title>${p(o)}</title>`),n;if(s==="canonical")return n.push(`<link rel="canonical" href="${p(o)}">`),n;if(s==="manifest")return n.push(`<link rel="manifest" href="${p(o)}">`),n;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=Y(s,o,c);if(typeof c=="string")n.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const i=J(c);/rel=/.test(i)?n.push(`<link ${i}${u}>`):n.push(`<link rel="icon" ${i}${u}>`)}}),n;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([i,g])=>g!==void 0).map(([i,g])=>`${i}="${p(g)}"`).join(" ");n.push(`<link rel="alternate" ${u}${G(c)}>`)}}),n;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(i=>{if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")n.push(`<meta ${u}="${p(f)}" content="${p(i)}">`);else if(typeof i=="object"){const g=Object.entries(i).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");n.push(`<meta ${g}>`)}});else if(typeof c=="object"){const i=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");n.push(`<meta ${i}>`)}};if(s.startsWith("http-equiv:")){const f=s.replace("http-equiv:","");return l(f,o,"http-equiv"),n}if(s.startsWith("itemprop:")){const f=s.replace("itemprop:","");return l(f,o,"itemprop"),n}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>s.startsWith(f));if(h){const f=s.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),n}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const f=s.startsWith("apple:")?"apple-":"msapplication-",c=s.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),n}return l(s,o),n},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...E(t)),e.join(`
2
+ `)},z=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),A=t=>typeof t=="string"&&t.length>0,N=t=>{if(!t||typeof t!="object")return null;if(A(t.src))return t.src;const r=t.content;return!r||typeof r!="object"?null:A(r.src)?r.src:A(r.storageUrl)?r.storageUrl:null};function T(t,r){if(!r||typeof r!="object")return t;const e=s=>!z(s)||!Object.prototype.hasOwnProperty.call(r,s)?s:N(r[s])||s,n={...t};for(const[s,o]of Object.entries(n))typeof o=="string"?n[s]=e(o):Array.isArray(o)&&(n[s]=o.map(l=>typeof l=="string"?e(l):l));return n}function O(t,r){if(!t||!r)return;const e=r.split(".");let n=t;for(const s of e){if(n==null||typeof n!="object")return;n=n[s]}return n}function Q(t,r){const e=O(t,r);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!(0,L.isStringFunction)(e))return e}function X(t,r,e){const s=(r.config||r.settings||{}).polyglot||r.polyglot,o=e?.lang||s?.defaultLang||"en",d=(s?.translations||{})[o]||{},h=[e?.state,r.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const i of h){const g=Q(i,u);if(g!==void 0)return g}},c={...t};for(const[u,i]of Object.entries(c))typeof i!="string"||!i.includes("{{")||(c[u]=i.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??O(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const b=f(a);return b!==void 0?b:d[a]??O(d,a)??g}));return c}function w(t){if(!(0,m.isObject)(t))return{};const r={...t};for(const[e,n]of Object.entries(r))if(typeof n=="function"){const s=n.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){r[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=s.match(/s\.(\w+(?:\.\w+)+)/);if(d){r[e]=`{{ ${d[1]} }}`;continue}delete r[e]}else if(typeof n=="string"){const s=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){r[e]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[e]=`{{ ${o[1]} | polyglot }}`;continue}if(n.includes("=>")&&n.includes("s.")){const l=n.match(/s\.(\w+(?:\.\w+)+)/);if(l){r[e]=`{{ ${l[1]} }}`;continue}}(0,L.isStringFunction)(n)&&delete r[e]}return r}function Z(t,r,e,{isProduction:n=!1,channel:s="production"}={}){const o=t.pages?.[r],l=(0,m.isObject)(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=w(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=w(c);let i={};if(t.integrations?.seo?i={...t.integrations.seo,...u,...h}:Object.keys(u).length?i={...u,...h}:i={...h},!i.title){const a=t.name||t.key;a?n?i.title=a:s==="development"?i.title=`${a} / dev:symbo.ls`:s==="staging"?i.title=`${a} / staging:symbo.ls`:i.title=`${a} / symbo.ls`:i.title="Symbols demo"}i=X(i,t,e),i.title&&(f.has("title")||!i["og:title"])&&(f.has("og:title")||(i["og:title"]=i.title)),i.description&&(f.has("description")||!i["og:description"])&&(f.has("og:description")||(i["og:description"]=i.description)),i.title&&!i["twitter:title"]&&(i["twitter:title"]=i.title),i.description&&!i["twitter:description"]&&(i["twitter:description"]=i.description);const g=f.has("og:url")?i["og:url"]:f.has("url")?i.url:void 0,y=e?.actualPathname||r;if(g)i["og:url"]=g;else if(i["og:url"]||i.url){const a=(i["og:url"]||i.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const b=y.startsWith("/")?y:"/"+y;i["og:url"]=a+b}}i=T(i,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,b]of Object.entries(i))if(typeof b=="string"&&b.includes("{{")){const M=b.replace(/\{\{[^}]*\}\}/g,"").trim();M?i[a]=M:a==="title"?i[a]=$:delete i[a]}return i}
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(t,a)=>{for(var n in a)o(t,n,{get:a[n],enumerable:!0})},_=(t,a,n,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of r(a))!c.call(t,e)&&e!==n&&o(t,e,{get:()=>a[e],enumerable:!(s=L(a,e))||s.enumerable});return t};var p=t=>_(o({},"__esModule",{value:!0}),t);var K={};l(K,{POLYGLOT_LANG_STORAGE_KEY:()=>g,polyglotFallbackLang:()=>G,polyglotLangStorageKey:()=>x});module.exports=p(K);const g="smbls_lang",x=t=>t&&t.storageLangKey||g,G=(t,a)=>t||a&&a.defaultLang||"en";
@@ -1,4 +1,4 @@
1
- "use strict";var $=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var be=(e,n)=>{for(var o in n)$(e,o,{get:n[o],enumerable:!0})},de=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of pe(n))!ye.call(e,s)&&s!==o&&$(e,s,{get:()=>n[s],enumerable:!(t=ue(n,s))||t.enumerable});return e};var he=e=>de($({},"__esModule",{value:!0}),e);var nt={};be(nt,{LIBRARY_PACKAGES:()=>le,LIBRARY_SCOPES_KEY:()=>k,__resetBuiltinMethodWarnings:()=>Oe,bindLibraryGlobalScopes:()=>Ue,deepDefaults:()=>A,exposeBagGlobalScopes:()=>ze,fetchLibraryData:()=>fe,isWrappedLibrary:()=>_,libraryPackageSpecs:()=>ce,mergeSharedLibraries:()=>ve,mergeSharedLibraryDesignSystems:()=>xe,normalizeIgnoreList:()=>B,normalizeLibraryKey:()=>S,resolveSharedLibraries:()=>tt,sharedLibrary:()=>we,warnLibraryAliasCollision:()=>ae});module.exports=he(nt);var f=require("./types.js"),L=require("./keys.js"),ie=require("./env.js"),b=require("./object.js");const R="system",me="https://smbls-kv.nika-980.workers.dev",ge="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:R,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=R);const s=t?`${o}/${t}`:"";return{owner:o,key:t,full:s}}const A=(e,n,o,t)=>{for(const s in n){const i=t?`${t}/${s}`:s;o&&o.has(i)||(s in e?(0,f.isObject)(e[s])&&(0,f.isObject)(n[s])&&A(e[s],n[s],o,i):e[s]=n[s])}},N=(e,n,o)=>{if(!(0,f.isObject)(e)||!n.size)return e;const t=`${o}/`;let s=!1;for(const c of n)if(c.startsWith(t)){s=!0;break}if(!s)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const r=`${o}/${c}`;n.has(r)||(i[c]=N(e[c],n,r))}return i},Se=new Set,_e=new Set(["components","pages","functions","snippets","methods"]),F=(e,n)=>n===""&&_e.has(e),V=["fontFamily","fontfamily","font_family","FONT_FAMILY"],D=e=>{const n=new Map;if(!(0,f.isObject)(e))return n;for(const o of V){const t=e[o];if((0,f.isObject)(t))for(const s in t)!(0,f.isObject)(t[s])||!t[s].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(s))}return n},G=(e,n)=>{for(const o of V){const t=e[o];if(!(0,f.isObject)(t))continue;const s=n.get(o);let i=null;for(const c in t){const r=t[c];if(!(0,f.isObject)(r)||!r.isDefault||s&&s.has(c))continue;const l={...r};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},ke=e=>e.replace(/\.js$/iu,""),B=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!(0,f.isString)(o))continue;const t=o.split("/").map(s=>ke(s.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},we=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>(0,f.isObject)(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),U=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,Oe=()=>{j.clear()},Le=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);(0,ie.isLoudDevRuntime)()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},Ae=(e,n,o)=>{let t=null;for(const s in e)if((0,L.isProtectedElementMethod)(s)&&(n.has(`methods/${s}`)||o.push(s),!t)){t={};for(const i in e)(0,L.isProtectedElementMethod)(i)||(t[i]=e[i])}return t||e},Y=(e,n)=>{const o=B(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],W=["components","pages"],K=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,$e=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),Re=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,z=e=>{try{return(0,b.getFunctionSource)(e)}catch{return null}},J=e=>{if(typeof e!="function")return null;const n=z(e);return(0,f.isString)(n)&&Re.test(n)&&(0,b.hasFunction)(n)?n:null},H=e=>(0,f.isString)(e)&&(0,b.hasFunction)(e)||J(e)!==null,je=e=>{const n=e.globalScope;return(0,f.isObject)(n)&&Object.keys(n).some(o=>H(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(s=>H(t[s]))})},Ee=(e,n,o)=>{const t=e.globalScope,s=n.globalScope;if(o.has("globalScope")||!(0,f.isObject)(t)||!(0,f.isObject)(s)||!je(n))return 0;let i=0;for(const c of Object.keys(s))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},Ie=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Pe=e=>{const n=e.split(""),o=[];let t=0,s=0;const i=(r,l)=>{for(let p=r;p<l;p++)n[p]!==`
1
+ "use strict";var $=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var de=(e,n)=>{for(var o in n)$(e,o,{get:n[o],enumerable:!0})},he=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ye(n))!be.call(e,s)&&s!==o&&$(e,s,{get:()=>n[s],enumerable:!(t=pe(n,s))||t.enumerable});return e};var me=e=>he($({},"__esModule",{value:!0}),e);var ot={};de(ot,{LIBRARY_PACKAGES:()=>fe,LIBRARY_SCOPES_KEY:()=>k,__resetBuiltinMethodWarnings:()=>Le,bareLibraryKey:()=>C,bindLibraryGlobalScopes:()=>Ye,deepDefaults:()=>A,exposeBagGlobalScopes:()=>Je,fetchLibraryData:()=>ue,isWrappedLibrary:()=>_,libraryPackageSpecs:()=>ae,librarySpecsFor:()=>ce,mergeSharedLibraries:()=>ve,mergeSharedLibraryDesignSystems:()=>et,normalizeIgnoreList:()=>B,normalizeLibraryKey:()=>S,resolveSharedLibraries:()=>nt,sharedLibrary:()=>Oe,warnLibraryAliasCollision:()=>le});module.exports=me(ot);var f=require("./types.js"),L=require("./keys.js"),ie=require("./env.js"),b=require("./object.js");const R="system",ge="https://smbls-kv.nika-980.workers.dev",Se="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:R,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=R);const s=t?`${o}/${t}`:"";return{owner:o,key:t,full:s}}const A=(e,n,o,t)=>{for(const s in n){const i=t?`${t}/${s}`:s;o&&o.has(i)||(s in e?(0,f.isObject)(e[s])&&(0,f.isObject)(n[s])&&A(e[s],n[s],o,i):e[s]=n[s])}},F=(e,n,o)=>{if(!(0,f.isObject)(e)||!n.size)return e;const t=`${o}/`;let s=!1;for(const c of n)if(c.startsWith(t)){s=!0;break}if(!s)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const r=`${o}/${c}`;n.has(r)||(i[c]=F(e[c],n,r))}return i},_e=new Set,ke=new Set(["components","pages","functions","snippets","methods"]),V=(e,n)=>n===""&&ke.has(e),D=["fontFamily","fontfamily","font_family","FONT_FAMILY"],G=e=>{const n=new Map;if(!(0,f.isObject)(e))return n;for(const o of D){const t=e[o];if((0,f.isObject)(t))for(const s in t)!(0,f.isObject)(t[s])||!t[s].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(s))}return n},U=(e,n)=>{for(const o of D){const t=e[o];if(!(0,f.isObject)(t))continue;const s=n.get(o);let i=null;for(const c in t){const r=t[c];if(!(0,f.isObject)(r)||!r.isDefault||s&&s.has(c))continue;const l={...r};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},we=e=>e.replace(/\.js$/iu,""),B=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!(0,f.isString)(o))continue;const t=o.split("/").map(s=>we(s.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},Oe=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>(0,f.isObject)(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),Y=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,Le=()=>{j.clear()},Ae=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);(0,ie.isLoudDevRuntime)()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},$e=(e,n,o)=>{let t=null;for(const s in e)if((0,L.isProtectedElementMethod)(s)&&(n.has(`methods/${s}`)||o.push(s),!t)){t={};for(const i in e)(0,L.isProtectedElementMethod)(i)||(t[i]=e[i])}return t||e},W=(e,n)=>{const o=B(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],K=["components","pages"],z=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,Re=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),je=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,J=e=>{try{return(0,b.getFunctionSource)(e)}catch{return null}},H=e=>{if(typeof e!="function")return null;const n=J(e);return(0,f.isString)(n)&&je.test(n)&&(0,b.hasFunction)(n)?n:null},q=e=>(0,f.isString)(e)&&(0,b.hasFunction)(e)||H(e)!==null,Ee=e=>{const n=e.globalScope;return(0,f.isObject)(n)&&Object.keys(n).some(o=>q(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(s=>q(t[s]))})},Ie=(e,n,o)=>{const t=e.globalScope,s=n.globalScope;if(o.has("globalScope")||!(0,f.isObject)(t)||!(0,f.isObject)(s)||!Ee(n))return 0;let i=0;for(const c of Object.keys(s))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},Pe=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Te=e=>{const n=e.split(""),o=[];let t=0,s=0;const i=(r,l)=>{for(let p=r;p<l;p++)n[p]!==`
2
2
  `&&(n[p]="~")},c=()=>{const r=t;for(;t<e.length;){const l=e[t];if(l==="\\"){t+=2;continue}if(l==="`"){i(r,t),t++;return}if(l==="$"&&e[t+1]==="{"){i(r,t),t+=2,o.push(s),s++;return}t++}i(r,t)};for(;t<e.length;){const r=e[t];if(r==="/"&&e[t+1]==="/"){const l=e.indexOf(`
3
3
  `,t),p=l===-1?e.length:l;i(t,p),t=p;continue}if(r==="/"&&e[t+1]==="*"){const l=e.indexOf("*/",t+2),p=l===-1?e.length:l+2;i(t,p),t=p;continue}if(r==='"'||r==="'"){const l=r,p=++t;for(;t<e.length&&e[t]!==l&&e[t]!==`
4
- `;)e[t]==="\\"&&t++,t++;i(p,t),t++;continue}if(r==="`"){t++,c();continue}if(r==="{"){s++,t++;continue}if(r==="}"){if(s--,o.length&&s===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},q=(e,n)=>{if(!(0,f.isString)(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!(0,b.hasFunction)(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[s,i]of Ie){const c=Pe(t);t=t.replace(s,(...r)=>{const l=r[r.length-2];return c[l]==="~"||c[l]!==t[l]?r[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(p,a)=>r[Number(a)])})}return t},w=(e,n)=>{if((0,f.isString)(e))return q(e,n);const o=J(e);return o===null?e:q(o,n)},Te={lazy:!0,window:globalThis},Z=(e,n)=>{const o=w(e,n);if(o===e||!(0,f.isString)(o))return o;try{const t=(0,b.deepDestringifyFunctions)({v:o},{},Te).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Q=(e,n,o=new WeakMap)=>{if((0,f.isString)(e)||typeof e=="function")return Z(e,n);if((0,b.isStringTag)(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const s of Object.keys(e))t[s]=Q(e[s],n,o);return t},Be=(e,n)=>{const o={...e},t={};for(const s of Object.keys(e.globalScope))t[s]=w(e.globalScope[s],n);o.globalScope=t;for(const s of E){const i=e[s];if(!P(i))continue;const c={};for(const r of Object.keys(i))c[r]=Z(i[r],n);o[s]=c}for(const s of W)P(e[s])&&(o[s]=Q(e[s],n));return o},X=new WeakMap,Ce=(e,n,o)=>{let t=X.get(e);t||X.set(e,t=new Map);let s=t.get(n);if(s)return s;const i=(c,r)=>h(o,c)&&o[c]===r;return s=new Proxy(e,{get(c,r){if(typeof r=="symbol"||h(c,r))return Reflect.get(c,r);const l=Reflect.get(c,r);return h(n,r)&&(l===void 0||i(r,l))||l===void 0?n[r]:l},set(c,r,l){return typeof r!="symbol"&&!h(c,r)&&h(n,r)?(n[r]=l,!0):Reflect.set(c,r,l)},has:(c,r)=>Reflect.has(c,r)||r in n}),t.set(n,s),s},Me=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",Ne=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Me(n)?Ce(n,o.libGs,o.consumerGs):n:n},Fe=()=>{typeof globalThis[K]!="function"&&Object.defineProperty(globalThis,K,{value:Ne,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,Ve=(e,n,o)=>{const t=O(e);return!!t&&t.some(s=>s&&s.index===n&&(!s.key||s.key===o.key)&&(0,f.isString)(s.id)&&De(e,s.id))},De=(e,n)=>{const o=JSON.stringify(n),t=new Set,s=i=>{if((0,f.isString)(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(s(i[c]))return!0;return!1};for(const i of["globalScope",...E,...W])if(s(e[i]))return!0;return!1},Ge=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},v=new WeakMap,Ue=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!(0,f.isObject)(t))return 0;const s=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=v.get(t);i||v.set(t,i=new Set),Fe();let c=0;for(const r of o){if(!r||!(0,f.isString)(r.id)||i.has(r.id))continue;const l=T(s[r.index]);if(!l||!(0,f.isObject)(l.globalScope)||r.key&&l.key!==r.key)continue;const p=y=>typeof y=="function"?z(y):y,a=(y,m)=>{if(y===m)return!0;const C=p(y),M=p(m);return(0,f.isString)(C)||(0,f.isString)(M)?C===M:JSON.stringify(y)===JSON.stringify(m)},u=(0,f.isObject)(n)?(Array.isArray(r.landed)?r.landed:[]).filter(y=>(0,f.isString)(y)&&h(l.globalScope,y)&&h(n,y)&&a(n[y],w(l.globalScope[y],r.id))):[],d=(0,b.destringifyGlobalScope)(Ge(l.globalScope,r.id));Object.setPrototypeOf(d,t),I.set(r.id,{libGs:d,consumerGs:t});for(const y of u)t[y]=d[y];i.add(r.id),c++}return c},Ye=/^@symbo[-.]ls\//,x=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,ce=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,s=(c,r,l)=>{for(const p of[`@symbo-ls/${c}`,`@symbo.ls/${c}`]){const a=t.get(p);if(a===void 0){t.set(p,r),o.push([p,r]);continue}a!==r&&l&&typeof n=="function"&&n({spec:p,kept:a,refused:r})}},i=[];for(const c of e){const r=T(c);if(!r||typeof r!="object"||r.__isStub)continue;const l=r.key||r.name||r.__libraryKey,p=[];for(const a of[r.key,r.name,r.__libraryKey,r.__libraryName]){if(typeof a!="string"||!a||a!==l&&!Ye.test(a))continue;const u=x(a);u&&!p.includes(u)&&p.push(u)}p.forEach((a,u)=>{u===0&&l&&x(l)===a?s(a,r,!1):i.push([a,r])})}for(const[c,r]of i)s(c,r,!0);return o},ae=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],le=Symbol.for("smbls.libraryPackages"),g=new WeakMap,We=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ke=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const s of Object.keys(e))t[s]=e[s];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:Ke(n)}),g.set(t,o),t},ne=e=>!We(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),ze=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const s=e[t];ne(s)||g.get(s)===e||(e[t]=te(s,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((s,i)=>{const c=_(s)&&s&&"library"in s,r=T(s);if(!r||typeof r!="object"||r.__isStub||g.get(r)===e)return s;const l=t.find(u=>u&&u.index===i&&(!u.key||u.key===r.key)),p=()=>{const u=l&&I.get(l.id);return u&&u.consumerGs===e.globalScope?u.libGs:e.globalScope},a={...r};for(const u of ee)ne(r[u])||(a[u]=te(r[u],p,e));return g.set(a,e),c?{...s,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[s,i]of ce(e.sharedLibraries,ae))t[s]=i;try{Object.defineProperty(o,le,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},Je=(e,n,o,t="library",s=-1)=>{const i=Y(n,o),c=!Ve(e,s,n)&&Ee(e,n,i)>0?`${t}#${$e()}`:null,r=c?Be(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,p=[];for(const a in r)if(Object.prototype.hasOwnProperty.call(r,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if((0,f.isObject)(r[a])&&(0,f.isObject)(e[a])){if(a==="designSystem")A(e[a],r[a],i,a);else for(const u in r[a])if(!i.has(`${a}/${u}`)){if(a==="methods"&&(0,L.isProtectedElementMethod)(u)){u in e[a]||p.push(u);continue}u in e[a]?F(a,e[a][u])&&!F(a,r[a][u])&&(e[a][u]=r[a][u]):e[a][u]=r[a][u]}}else if(!(a in e)){const u=r[a],d=a==="methods"&&u&&typeof u=="object"?Ae(u,i,p):u;e[a]=N(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:s,key:(0,f.isString)(n.key)?n.key:null,landed:Object.keys(r.globalScope).filter(a=>!l.has(a))})),p.length&&Le(t,p)},He=(e,n,o)=>{if(e!==n){const t=U(e);if((0,f.isString)(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},qe=`${R}/default`,Ze=e=>(0,f.isString)(e)&&e!==""&&S(e).full===qe,Qe=(e,n)=>{if((0,f.isString)(n.key)&&n.key)return n.key;if(e!==n){if((0,f.isString)(e.key)&&e.key)return e.key;if((0,f.isString)(e.name)&&e.name)return e.name}return null},Xe=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const s=e[t];let i=s,c=Se;if(_(i)&&(c=B(i.ignoreList),i=i.library),!(0,f.isObject)(i))continue;const r={entry:s,lib:i,ignore:c,index:t};Ze(Qe(s,i))?o.push(r):n.push(r)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=D(n()),{linked:s,bases:i}=Xe(e);for(const r of s)o(r);const c=!t.size&&i.length?D(n()):null;for(const r of i)o(r);return t.size?t:c&&c.size?c:null},ve=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:s,lib:i,ignore:c,index:r})=>Je(e,i,c,He(s,i,r),r));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),G(e.designSystem,t))},xe=(e,n,o=A)=>{if(!(0,f.isObject)(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:s,ignore:i})=>{const c=s.designSystem;if(!c||typeof c!="object")return;const r=Y(s,i);r.has("designSystem")||o(e,c,r,"designSystem")});return t&&G(e,t),e};async function fe(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await et(e,n);return t||se(e,n)}async function et(e,n={}){const o=n.kvBaseUrl||me,t=n.env||"production",s=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(s,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||ge,{key:t}=S(e);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(s,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(y=>{const{key:m}=S(y?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const p=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(p)}/data?branch=main`,u=await fetch(a,{method:"GET"});if(!u.ok)return null;const d=await u.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if((0,f.isObject)(e))return e;if((0,f.isString)(e)){const{full:o}=S(e);if(!o)return null;try{const t=await fe(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function tt(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const s=await re(U(t),n);return s?{library:s,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}
4
+ `;)e[t]==="\\"&&t++,t++;i(p,t),t++;continue}if(r==="`"){t++,c();continue}if(r==="{"){s++,t++;continue}if(r==="}"){if(s--,o.length&&s===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},Z=(e,n)=>{if(!(0,f.isString)(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!(0,b.hasFunction)(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[s,i]of Pe){const c=Te(t);t=t.replace(s,(...r)=>{const l=r[r.length-2];return c[l]==="~"||c[l]!==t[l]?r[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(p,a)=>r[Number(a)])})}return t},w=(e,n)=>{if((0,f.isString)(e))return Z(e,n);const o=H(e);return o===null?e:Z(o,n)},Be={lazy:!0,window:globalThis},Q=(e,n)=>{const o=w(e,n);if(o===e||!(0,f.isString)(o))return o;try{const t=(0,b.deepDestringifyFunctions)({v:o},{},Be).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},X=(e,n,o=new WeakMap)=>{if((0,f.isString)(e)||typeof e=="function")return Q(e,n);if((0,b.isStringTag)(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const s of Object.keys(e))t[s]=X(e[s],n,o);return t},Ce=(e,n)=>{const o={...e},t={};for(const s of Object.keys(e.globalScope))t[s]=w(e.globalScope[s],n);o.globalScope=t;for(const s of E){const i=e[s];if(!P(i))continue;const c={};for(const r of Object.keys(i))c[r]=Q(i[r],n);o[s]=c}for(const s of K)P(e[s])&&(o[s]=X(e[s],n));return o},x=new WeakMap,Me=(e,n,o)=>{let t=x.get(e);t||x.set(e,t=new Map);let s=t.get(n);if(s)return s;const i=(c,r)=>h(o,c)&&o[c]===r;return s=new Proxy(e,{get(c,r){if(typeof r=="symbol"||h(c,r))return Reflect.get(c,r);const l=Reflect.get(c,r);return h(n,r)&&(l===void 0||i(r,l))||l===void 0?n[r]:l},set(c,r,l){return typeof r!="symbol"&&!h(c,r)&&h(n,r)?(n[r]=l,!0):Reflect.set(c,r,l)},has:(c,r)=>Reflect.has(c,r)||r in n}),t.set(n,s),s},Ne=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",Fe=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Ne(n)?Me(n,o.libGs,o.consumerGs):n:n},Ve=()=>{typeof globalThis[z]!="function"&&Object.defineProperty(globalThis,z,{value:Fe,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,De=(e,n,o)=>{const t=O(e);return!!t&&t.some(s=>s&&s.index===n&&(!s.key||s.key===o.key)&&(0,f.isString)(s.id)&&Ge(e,s.id))},Ge=(e,n)=>{const o=JSON.stringify(n),t=new Set,s=i=>{if((0,f.isString)(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(s(i[c]))return!0;return!1};for(const i of["globalScope",...E,...K])if(s(e[i]))return!0;return!1},Ue=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},v=new WeakMap,Ye=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!(0,f.isObject)(t))return 0;const s=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=v.get(t);i||v.set(t,i=new Set),Ve();let c=0;for(const r of o){if(!r||!(0,f.isString)(r.id)||i.has(r.id))continue;const l=T(s[r.index]);if(!l||!(0,f.isObject)(l.globalScope)||r.key&&l.key!==r.key)continue;const p=y=>typeof y=="function"?J(y):y,a=(y,m)=>{if(y===m)return!0;const M=p(y),N=p(m);return(0,f.isString)(M)||(0,f.isString)(N)?M===N:JSON.stringify(y)===JSON.stringify(m)},u=(0,f.isObject)(n)?(Array.isArray(r.landed)?r.landed:[]).filter(y=>(0,f.isString)(y)&&h(l.globalScope,y)&&h(n,y)&&a(n[y],w(l.globalScope[y],r.id))):[],d=(0,b.destringifyGlobalScope)(Ue(l.globalScope,r.id));Object.setPrototypeOf(d,t),I.set(r.id,{libGs:d,consumerGs:t});for(const y of u)t[y]=d[y];i.add(r.id),c++}return c},We=/^@symbo[-.]ls\//,C=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,ce=e=>[`@symbo-ls/${e}`,`@symbo.ls/${e}`],ae=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,s=(c,r,l)=>{for(const p of ce(c)){const a=t.get(p);if(a===void 0){t.set(p,r),o.push([p,r]);continue}a!==r&&l&&typeof n=="function"&&n({spec:p,kept:a,refused:r})}},i=[];for(const c of e){const r=T(c);if(!r||typeof r!="object"||r.__isStub)continue;const l=r.key||r.name||r.__libraryKey,p=[];for(const a of[r.key,r.name,r.__libraryKey,r.__libraryName]){if(typeof a!="string"||!a||a!==l&&!We.test(a))continue;const u=C(a);u&&!p.includes(u)&&p.push(u)}p.forEach((a,u)=>{u===0&&l&&C(l)===a?s(a,r,!1):i.push([a,r])})}for(const[c,r]of i)s(c,r,!0);return o},le=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],fe=Symbol.for("smbls.libraryPackages"),g=new WeakMap,Ke=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ze=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const s of Object.keys(e))t[s]=e[s];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:ze(n)}),g.set(t,o),t},ne=e=>!Ke(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),Je=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const s=e[t];ne(s)||g.get(s)===e||(e[t]=te(s,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((s,i)=>{const c=_(s)&&s&&"library"in s,r=T(s);if(!r||typeof r!="object"||r.__isStub||g.get(r)===e)return s;const l=t.find(u=>u&&u.index===i&&(!u.key||u.key===r.key)),p=()=>{const u=l&&I.get(l.id);return u&&u.consumerGs===e.globalScope?u.libGs:e.globalScope},a={...r};for(const u of ee)ne(r[u])||(a[u]=te(r[u],p,e));return g.set(a,e),c?{...s,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[s,i]of ae(e.sharedLibraries,le))t[s]=i;try{Object.defineProperty(o,fe,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},He=(e,n,o,t="library",s=-1)=>{const i=W(n,o),c=!De(e,s,n)&&Ie(e,n,i)>0?`${t}#${Re()}`:null,r=c?Ce(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,p=[];for(const a in r)if(Object.prototype.hasOwnProperty.call(r,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if((0,f.isObject)(r[a])&&(0,f.isObject)(e[a])){if(a==="designSystem")A(e[a],r[a],i,a);else for(const u in r[a])if(!i.has(`${a}/${u}`)){if(a==="methods"&&(0,L.isProtectedElementMethod)(u)){u in e[a]||p.push(u);continue}u in e[a]?V(a,e[a][u])&&!V(a,r[a][u])&&(e[a][u]=r[a][u]):e[a][u]=r[a][u]}}else if(!(a in e)){const u=r[a],d=a==="methods"&&u&&typeof u=="object"?$e(u,i,p):u;e[a]=F(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:s,key:(0,f.isString)(n.key)?n.key:null,landed:Object.keys(r.globalScope).filter(a=>!l.has(a))})),p.length&&Ae(t,p)},qe=(e,n,o)=>{if(e!==n){const t=Y(e);if((0,f.isString)(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},Ze=`${R}/default`,Qe=e=>(0,f.isString)(e)&&e!==""&&S(e).full===Ze,Xe=(e,n)=>{if((0,f.isString)(n.key)&&n.key)return n.key;if(e!==n){if((0,f.isString)(e.key)&&e.key)return e.key;if((0,f.isString)(e.name)&&e.name)return e.name}return null},xe=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const s=e[t];let i=s,c=_e;if(_(i)&&(c=B(i.ignoreList),i=i.library),!(0,f.isObject)(i))continue;const r={entry:s,lib:i,ignore:c,index:t};Qe(Xe(s,i))?o.push(r):n.push(r)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=G(n()),{linked:s,bases:i}=xe(e);for(const r of s)o(r);const c=!t.size&&i.length?G(n()):null;for(const r of i)o(r);return t.size?t:c&&c.size?c:null},ve=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:s,lib:i,ignore:c,index:r})=>He(e,i,c,qe(s,i,r),r));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),U(e.designSystem,t))},et=(e,n,o=A)=>{if(!(0,f.isObject)(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:s,ignore:i})=>{const c=s.designSystem;if(!c||typeof c!="object")return;const r=W(s,i);r.has("designSystem")||o(e,c,r,"designSystem")});return t&&U(e,t),e};async function ue(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await tt(e,n);return t||se(e,n)}async function tt(e,n={}){const o=n.kvBaseUrl||ge,t=n.env||"production",s=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(s,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||Se,{key:t}=S(e);try{const s=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(s,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(y=>{const{key:m}=S(y?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const p=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(p)}/data?branch=main`,u=await fetch(a,{method:"GET"});if(!u.ok)return null;const d=await u.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if((0,f.isObject)(e))return e;if((0,f.isString)(e)){const{full:o}=S(e);if(!o)return null;try{const t=await ue(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function nt(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const s=await re(Y(t),n);return s?{library:s,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var O=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},R=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of j(n))!N.call(e,c)&&c!==t&&w(e,c,{get:()=>n[c],enumerable:!(s=L(n,c))||s.enumerable});return e};var I=e=>R(w({},"__esModule",{value:!0}),e);var W={};O(W,{customDecodeURIComponent:()=>M,customEncodeURIComponent:()=>z,decodeNewlines:()=>P,encodeNewlines:()=>K,findKeyPosition:()=>U,lowercaseFirstLetter:()=>v,replaceLiteralsWithObjectFields:()=>T,replaceOctalEscapeSequences:()=>D,stringIncludesAny:()=>k,trimStringFromSymbols:()=>E});module.exports=I(W);const k=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},E=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},$={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),F=(e,n)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const s=t.__ref&&t.__ref.__authoredTemplates;if(s&&s.has(n))return!0;t=t.parent}return!1};function T(e,n,t={}){const{bracketsLength:s=2,authored:c=!1}=t,h=s===3?"{{{":"{{";if(!e.includes(h)||c!==!0&&!F(this,e))return e;const p=$[s],f=n||this.state||{},l=this;return e.replace(p,(x,r,b,g)=>{const i=b.trim();if(g){const a=l?.context,o=a?.functions?.[g]||a?.utils?.[g]||a?.methods?.[g]||a?.snippets?.[g]||l?.[g];if(o&&typeof o=="function")try{return String(o.call(l,i)??"")}catch{return""}return""}if(r){const a=(r.match(/\.\.\//g)||[]).length;let o=f;for(let u=0;u<a;u++){if(!o||!o.parent)return"";o=o.parent}if(i==="parent")return String(o.value??"");const d=m(o,i);return d!=null&&typeof d=="object"?"":String(d??"")}else{const a=m(f,i);if(a!=null&&typeof a!="object")return String(a);const o=l?.context?.polyglot;if(o?.translations){const d=f?.root?.lang||f?.lang||l?.context?.state?.lang||o.defaultLang||"en",u=o.translations[d];if(u){const S=m(u,i);if(S!=null&&typeof S!="object")return String(S);for(const A in u){const y=u[A];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,i);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,i);if(C!=null&&typeof C!="object")return String(C)}return""}})}const v=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,U=(e,n)=>{const t=e.split(`
2
- `);let s=-1,c=-1,h=-1,p=-1;const f=new RegExp(`\\b${n}\\b\\s*:\\s*`);let l=0,x=!1;for(let r=0;r<t.length;r++)if(f.test(t[r])&&!x){if(x=!0,s=r+1,h=t[r].indexOf(n)+1,t[r].includes("{}")){c=s,p=t[r].indexOf("{}")+3;break}const b=t[r].slice(h+n.length);if(b.includes("{")||b.includes("["))l=1;else{c=r+1,p=t[r].length+1;break}}else if(x&&(l+=(t[r].match(/{/g)||[]).length,l+=(t[r].match(/\[/g)||[]).length,l-=(t[r].match(/}/g)||[]).length,l-=(t[r].match(/]/g)||[]).length,l===0)){c=r+1,p=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:s,endLineNumber:c}},V=/\\([0-7]{1,3})/g,D=e=>e.replace(V,(n,t)=>String.fromCharCode(parseInt(t,8))),K=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),P=e=>e.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),q=/[^a-zA-Z0-9\s]/g,z=e=>e.replace(q,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),M=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
1
+ "use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var N=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},O=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of j(n))!R.call(e,c)&&c!==t&&w(e,c,{get:()=>n[c],enumerable:!(s=L(n,c))||s.enumerable});return e};var $=e=>O(w({},"__esModule",{value:!0}),e);var Z={};N(Z,{customDecodeURIComponent:()=>W,customEncodeURIComponent:()=>M,decodeNewlines:()=>q,encodeNewlines:()=>P,escapeRegExp:()=>E,findKeyPosition:()=>V,lowercaseFirstLetter:()=>U,replaceLiteralsWithObjectFields:()=>v,replaceOctalEscapeSequences:()=>K,stringIncludesAny:()=>I,trimStringFromSymbols:()=>k});module.exports=$(Z);const E=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=(e,n)=>{for(const t of n)if(e.includes(t))return!0;return!1},k=(e,n)=>{const t=new RegExp(`[${n.join("\\")}]`,"g");return e.replace(t,"")},F={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),T=(e,n)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const s=t.__ref&&t.__ref.__authoredTemplates;if(s&&s.has(n))return!0;t=t.parent}return!1};function v(e,n,t={}){const{bracketsLength:s=2,authored:c=!1}=t,h=s===3?"{{{":"{{";if(!e.includes(h)||c!==!0&&!T(this,e))return e;const p=F[s],g=n||this.state||{},l=this;return e.replace(p,(x,r,b,f)=>{const i=b.trim();if(f){const a=l?.context,o=a?.functions?.[f]||a?.utils?.[f]||a?.methods?.[f]||a?.snippets?.[f]||l?.[f];if(o&&typeof o=="function")try{return String(o.call(l,i)??"")}catch{return""}return""}if(r){const a=(r.match(/\.\.\//g)||[]).length;let o=g;for(let u=0;u<a;u++){if(!o||!o.parent)return"";o=o.parent}if(i==="parent")return String(o.value??"");const d=m(o,i);return d!=null&&typeof d=="object"?"":String(d??"")}else{const a=m(g,i);if(a!=null&&typeof a!="object")return String(a);const o=l?.context?.polyglot;if(o?.translations){const d=g?.root?.lang||g?.lang||l?.context?.state?.lang||o.defaultLang||"en",u=o.translations[d];if(u){const S=m(u,i);if(S!=null&&typeof S!="object")return String(S);for(const A in u){const y=u[A];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,i);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,i);if(C!=null&&typeof C!="object")return String(C)}return""}})}const U=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,V=(e,n)=>{const t=e.split(`
2
+ `);let s=-1,c=-1,h=-1,p=-1;const g=new RegExp(`\\b${n}\\b\\s*:\\s*`);let l=0,x=!1;for(let r=0;r<t.length;r++)if(g.test(t[r])&&!x){if(x=!0,s=r+1,h=t[r].indexOf(n)+1,t[r].includes("{}")){c=s,p=t[r].indexOf("{}")+3;break}const b=t[r].slice(h+n.length);if(b.includes("{")||b.includes("["))l=1;else{c=r+1,p=t[r].length+1;break}}else if(x&&(l+=(t[r].match(/{/g)||[]).length,l+=(t[r].match(/\[/g)||[]).length,l-=(t[r].match(/}/g)||[]).length,l-=(t[r].match(/]/g)||[]).length,l===0)){c=r+1,p=t[r].lastIndexOf("}")!==-1?t[r].lastIndexOf("}")+2:t[r].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:s,endLineNumber:c}},D=/\\([0-7]{1,3})/g,K=e=>e.replace(D,(n,t)=>String.fromCharCode(parseInt(t,8))),P=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),q=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),z=/[^a-zA-Z0-9\s]/g,M=e=>e.replace(z,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),W=e=>e.replace(/%[0-9A-Fa-f]{2}/g,n=>String.fromCharCode(parseInt(n.slice(1),16)));
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./key.js";export*from"./env.js";export*from"./types.js";export*from"./object.js";export*from"./function.js";export*from"./array.js";export*from"./node.js";export*from"./if.js";export*from"./log.js";export*from"./string.js";export*from"./globals.js";export*from"./cookie.js";export*from"./tags.js";export*from"./component.js";export*from"./props.js";export*from"./extends.js";export*from"./element.js";export*from"./state.js";export*from"./keys.js";export*from"./scope.js";export*from"./methods.js";export*from"./cache.js";export*from"./update.js";export*from"./triggerEvent.js";export*from"./projectKeys.js";export*from"./legacyScopePreamble.js";export*from"./browser.js";export*from"./cdn.js";export*from"./date.js";export*from"./detectHeight.js";export*from"./fibonacci.js";export*from"./files.js";export*from"./load.js";export*from"./metadata.js";export*from"./scaling.js";export*from"./sharedLibraries.js";export*from"./string-extra.js";export*from"./style.js";export*from"./assets.js";
1
+ export*from"./key.js";export*from"./env.js";export*from"./types.js";export*from"./object.js";export*from"./function.js";export*from"./array.js";export*from"./node.js";export*from"./if.js";export*from"./log.js";export*from"./string.js";export*from"./globals.js";export*from"./cookie.js";export*from"./tags.js";export*from"./component.js";export*from"./props.js";export*from"./extends.js";export*from"./element.js";export*from"./state.js";export*from"./keys.js";export*from"./scope.js";export*from"./methods.js";export*from"./cache.js";export*from"./update.js";export*from"./triggerEvent.js";export*from"./projectKeys.js";export*from"./legacyScopePreamble.js";export*from"./polyglotLang.js";export*from"./browser.js";export*from"./cdn.js";export*from"./date.js";export*from"./detectHeight.js";export*from"./fibonacci.js";export*from"./files.js";export*from"./load.js";export*from"./metadata.js";export*from"./scaling.js";export*from"./sharedLibraries.js";export*from"./string-extra.js";export*from"./style.js";export*from"./assets.js";
package/dist/esm/keys.js CHANGED
@@ -1 +1 @@
1
- const a=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),s=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),p=["ref","parent","__element","__depends","__ref","__children","root"],o=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),n=new Set(["update","__element"]),t=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),d=e=>t.has(e),r=new Set(["log","warn","error","verbose"]),l=e=>t.has(e)&&!r.has(e),c=new Set(["node","context","extends","__element","__ref",...t,...o,...n]),_=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);export{_ as DOMQL_EVENTS,a as DOMQ_PROPERTIES,r as ELEMENT_METHOD_OVERRIDE_POINTS,t as METHODS,c as METHODS_EXL,s as PARSED_DOMQ_PROPERTIES,n as PROPS_METHODS,o as STATE_METHODS,p as STATE_PROPERTIES,d as isBuiltinElementMethod,l as isProtectedElementMethod};
1
+ const a=new Set(["attr","style","text","html","content","data","classlist","state","scope","root","deps","extend","extends","$router","routes","children","childExtend","childExtends","childExtendRecursive","childExtendsRecursive","props","if","define","__name","__ref","__hash","__text","key","tag","query","parent","node","variables","on","fetch","component","context","preventContentUpdate","preventContentRecreate"]),s=new Set(["attr","style","text","html","content","data","class","state","scope","children","props","if","key","tag","query","on","context"]),p=["ref","parent","__element","__depends","__ref","__children","root"],o=new Set(["update","parse","clean","create","destroy","add","toggle","remove","apply","set","reset","replace","quietReplace","quietUpdate","applyReplace","applyFunction","keys","values","ref","rootUpdate","parentUpdate","parent","__element","__depends","__ref","__children","root","setByPath","setPathCollection","removeByPath","removePathCollection","getByPath"]),n=new Set(["update","__element"]),t=new Set(["set","reset","update","remove","updateContent","removeContent","lookup","lookdown","lookdownAll","whenConnected","getRef","getPath","setNodeStyles","spotByPath","keys","parse","setProps","parseDeep","variables","if","log","verbose","warn","error","call","nextElement","previousElement","getRootState","getRoot","getRootData","getRootContext","getContext","getQuery","getDB","getChildren","preventContentUpdate","preventContentRecreate"]),d=e=>t.has(e),r=new Set(["log","warn","error","verbose"]),l=e=>t.has(e)&&!r.has(e),c=new Set(["node","context","extends","__element","__ref",...t,...o,...n]),_=new Set(["init","beforeClassAssign","render","renderRouter","attachNode","stateInit","stateCreated","beforeStateUpdate","stateUpdate","beforeUpdate","done","create","complete","frame","update","fetchError","fetchComplete"]);export{_ as DOMQL_EVENTS,a as DOMQ_PROPERTIES,r as ELEMENT_METHOD_OVERRIDE_POINTS,t as METHODS,c as METHODS_EXL,s as PARSED_DOMQ_PROPERTIES,n as PROPS_METHODS,o as STATE_METHODS,p as STATE_PROPERTIES,d as isBuiltinElementMethod,l as isProtectedElementMethod};
@@ -1 +1 @@
1
- const p=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],_=(t,e)=>t.split("$R").join(e),y=p.map(t=>[_(t,"this"),t]),g="const __scope = ",O=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,b=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,R=/^[A-Za-z_$][\w$]*$/,n=(t,e)=>typeof t=="string"&&new RegExp("^"+e+"\\d*$").test(t),u=t=>t.length>=2&&n(t[0],"el")?t[0]:t.length>=2&&n(t[1],"el")?t[1]:t.length>=1&&n(t[0],"el")||n(t[0],"element")||n(t[0],"node")?t[0]:t.find(e=>n(e,"element"))||null,$=t=>{if(typeof t!="string"||t.indexOf(g)===-1||t.indexOf("this")===-1)return t;const e=b.exec(t);if(!e)return t;let o=e[0].length;if(!t.startsWith(g,o))return t;o+=g.length;const c=O.exec(t.slice(o,o+400));c&&(o+=c[0].length);const r=y.find(([s])=>t.startsWith(s,o));if(!r)return t;const i=o+r[0].length;if(t[i]!==(c?")":";"))return t;const l=(e[1]!==void 0?e[1]:e[2]).split(",").map(s=>s.split("=")[0].trim()).filter(Boolean);if(l.some(s=>!R.test(s)))return t;const f=u(l);return f?t.slice(0,o)+_(r[1],f)+t.slice(i):t};export{$ as repairLegacyArrowScopePreamble};
1
+ const g=["$R?.scope ?? $R?.context?.globalScope ?? {}","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) Object.setPrototypeOf(s, g); return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { try { Object.setPrototypeOf(s, g) } catch (_) {} } return s ?? g ?? {}; })()","(() => { const s = $R?.scope; const g = $R?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? {}; })()","(() => { const r = $R; const s = r?.scope; const g = r?.context?.globalScope; if (s && g && s !== g && Object.getPrototypeOf(s) !== g) { let __p = g, __cyc = false; while (__p) { if (__p === s) { __cyc = true; break } __p = Object.getPrototypeOf(__p) } if (!__cyc) { try { Object.setPrototypeOf(s, g) } catch (_) {} } } return s ?? g ?? (r && typeof r === 'object' && r !== globalThis ? r : {}); })()"],i=(t,o)=>t.split("$R").join(o),y=g.map(t=>[i(t,"this"),t]),$=t=>i(g[g.length-1],t),f="const __scope = ",O=/^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /,b=/^\s*(?:async\s*)?(?:\(([^()[\]{}'"`/]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*\{\s*/,u=/^[A-Za-z_$][\w$]*$/,n=(t,o)=>typeof t=="string"&&new RegExp("^"+o+"\\d*$").test(t),R=(t,o)=>{if(t.length>=2&&n(t[0],"el"))return t[0];if(t.length>=2&&n(t[1],"el"))return t[1];if(t.length>=1&&n(t[0],"el")||n(t[0],"element")||n(t[0],"node"))return t[0];if(typeof o=="function"){const e=o();if(e&&t.includes(e))return e}return t.find(e=>n(e,"element"))||null},P=t=>{if(typeof t!="string"||t.indexOf(f)===-1||t.indexOf("this")===-1)return t;const o=b.exec(t);if(!o)return t;let e=o[0].length;if(!t.startsWith(f,e))return t;e+=f.length;const c=O.exec(t.slice(e,e+400));c&&(e+=c[0].length);const r=y.find(([s])=>t.startsWith(s,e));if(!r)return t;const l=e+r[0].length;if(t[l]!==(c?")":";"))return t;const _=(o[1]!==void 0?o[1]:o[2]).split(",").map(s=>s.split("=")[0].trim()).filter(Boolean);if(_.some(s=>!u.test(s)))return t;const p=R(_);return p?t.slice(0,e)+i(r[1],p)+t.slice(l):t};export{P as repairLegacyArrowScopePreamble,R as scopeElementParam,$ as scopeReceiverExpression};
@@ -1,2 +1,2 @@
1
- import{isObject as b}from"./types.js";import{isStringFunction as M}from"./function.js";const p=e=>{if(e==null)return"";const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.toString().replace(/[&<>"']/g,t=>r[t])},L=e=>Object.entries(e||{}).filter(([r,t])=>t!==void 0).map(([r,t])=>`${r}="${p(t)}"`).join(" "),j=e=>{let r=5381;const t=String(e);for(let s=0;s<t.length;s++)r=(r*33^t.charCodeAt(s))>>>0;return r.toString(36)},E=new Set(["jsonLd","styles","scripts"]),W=e=>{const r=[];if(Array.isArray(e.jsonLd))for(const t of e.jsonLd){if(t==null)continue;const s=typeof t=="string"?t:JSON.stringify(t),i=String(s).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${j(s)}">${i}<\/script>`)}if(Array.isArray(e.styles))for(const t of e.styles){if(t==null||!String(t).trim())continue;const s=String(t).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${j(s)}">${s}</style>`)}if(Array.isArray(e.scripts))for(const t of e.scripts){if(!t)continue;const s=typeof t=="string",i=s?t:t.src;if(!i&&!t.body)continue;const o=[];i&&o.push(`src="${p(i)}"`),s||(t.type&&o.push(`type="${p(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${p(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${p(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${p(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(i||j(t.body||""))}"`;if(!s&&t.body){const d=String(t.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else r.push(`<script ${o.join(" ")}${l}><\/script>`)}return r},x=(e,r,t)=>e==="favicons"?Array.isArray(r)?typeof t=="string"?` data-smbls-favicon="${p(t)}"`:b(t)?` data-smbls-favicon="${j(JSON.stringify(t))}"`:"":"":(e==="icon"||e==="favicon")&&typeof r=="string"?` data-smbls-single-icon="${p(r)}"`:"",T=e=>b(e)?` data-smbls-alternate="${p(`${e.hreflang||""}|${e.href||""}`)}"`:"",q=(e,r)=>{r||(e={...e,robots:"noindex"});const t=Object.entries(e).reduce((s,[i,o])=>{if(!o&&o!==0&&o!==!1||E.has(i))return s;if(i==="title")return s.push(`<title>${p(o)}</title>`),s;if(i==="canonical")return s.push(`<link rel="canonical" href="${p(o)}">`),s;if(i==="manifest")return s.push(`<link rel="manifest" href="${p(o)}">`),s;if(i==="favicon"||i==="favicons"||i==="icon"||i==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=x(i,o,c);if(typeof c=="string")s.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const n=L(c);/rel=/.test(n)?s.push(`<link ${n}${u}>`):s.push(`<link rel="icon" ${n}${u}>`)}}),s;if(i==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${p(g)}"`).join(" ");s.push(`<link rel="alternate" ${u}${T(c)}>`)}}),s;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")s.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")s.push(`<meta ${u}="${p(f)}" content="${p(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");s.push(`<meta ${g}>`)}});else if(typeof c=="object"){const n=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");s.push(`<meta ${n}>`)}};if(i.startsWith("http-equiv:")){const f=i.replace("http-equiv:","");return l(f,o,"http-equiv"),s}if(i.startsWith("itemprop:")){const f=i.replace("itemprop:","");return l(f,o,"itemprop"),s}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>i.startsWith(f));if(h){const f=i.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),s}if(i.startsWith("apple:")||i.startsWith("msapplication:")){const f=i.startsWith("apple:")?"apple-":"msapplication-",c=i.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),s}return l(i,o),s},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...W(e)),t.join(`
2
- `)},F=e=>typeof e=="string"&&e.length>0&&!e.startsWith("/")&&!e.startsWith("http"),A=e=>typeof e=="string"&&e.length>0,K=e=>{if(!e||typeof e!="object")return null;if(A(e.src))return e.src;const r=e.content;return!r||typeof r!="object"?null:A(r.src)?r.src:A(r.storageUrl)?r.storageUrl:null};function U(e,r){if(!r||typeof r!="object")return e;const t=i=>!F(i)||!Object.prototype.hasOwnProperty.call(r,i)?i:K(r[i])||i,s={...e};for(const[i,o]of Object.entries(s))typeof o=="string"?s[i]=t(o):Array.isArray(o)&&(s[i]=o.map(l=>typeof l=="string"?t(l):l));return s}function S(e,r){if(!e||!r)return;const t=r.split(".");let s=e;for(const i of t){if(s==null||typeof s!="object")return;s=s[i]}return s}function D(e,r){const t=S(e,r);if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&!M(t))return t}function P(e,r,t){const i=(r.config||r.settings||{}).polyglot||r.polyglot,o=t?.lang||i?.defaultLang||"en",d=(i?.translations||{})[o]||{},h=[t?.state,r.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const n of h){const g=D(n,u);if(g!==void 0)return g}},c={...e};for(const[u,n]of Object.entries(c))typeof n!="string"||!n.includes("{{")||(c[u]=n.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??S(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const m=f(a);return m!==void 0?m:d[a]??S(d,a)??g}));return c}function O(e){if(!b(e))return{};const r={...e};for(const[t,s]of Object.entries(r))if(typeof s=="function"){const i=s.toString(),o=i.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=i.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){r[t]=`{{ ${l[1]} | polyglot }}`;continue}const d=i.match(/s\.(\w+(?:\.\w+)+)/);if(d){r[t]=`{{ ${d[1]} }}`;continue}delete r[t]}else if(typeof s=="string"){const i=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){r[t]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const o=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | polyglot }}`;continue}if(s.includes("=>")&&s.includes("s.")){const l=s.match(/s\.(\w+(?:\.\w+)+)/);if(l){r[t]=`{{ ${l[1]} }}`;continue}}M(s)&&delete r[t]}return r}function C(e,r,t,{isProduction:s=!1,channel:i="production"}={}){const o=e.pages?.[r],l=b(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=O(d),f=new Set(Object.keys(h)),c=e.app?.metadata||{},u=O(c);let n={};if(e.integrations?.seo?n={...e.integrations.seo,...u,...h}:Object.keys(u).length?n={...u,...h}:n={...h},!n.title){const a=e.name||e.key;a?s?n.title=a:i==="development"?n.title=`${a} / dev:symbo.ls`:i==="staging"?n.title=`${a} / staging:symbo.ls`:n.title=`${a} / symbo.ls`:n.title="Symbols demo"}n=P(n,e,t),n.title&&(f.has("title")||!n["og:title"])&&(f.has("og:title")||(n["og:title"]=n.title)),n.description&&(f.has("description")||!n["og:description"])&&(f.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=f.has("og:url")?n["og:url"]:f.has("url")?n.url:void 0,y=t?.actualPathname||r;if(g)n["og:url"]=g;else if(n["og:url"]||n.url){const a=(n["og:url"]||n.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const m=y.startsWith("/")?y:"/"+y;n["og:url"]=a+m}}n=U(n,e.files);const $=e.name||e.app?.metadata?.title||e.app?.name||"";for(const[a,m]of Object.entries(n))if(typeof m=="string"&&m.includes("{{")){const w=m.replace(/\{\{[^}]*\}\}/g,"").trim();w?n[a]=w:a==="title"?n[a]=$:delete n[a]}return n}export{K as fileEntryUrl,W as generateHeadArrayTags,q as generateMetaTags,C as getPageMetadata,j as hashContent,U as resolveFileReferences};
1
+ import{isObject as m}from"./types.js";import{isStringFunction as L}from"./function.js";const p=t=>{if(t==null)return"";const i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.toString().replace(/[&<>"']/g,e=>i[e])},w=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),B=(t,i,{remove:e=!1,warn:r}={})=>{if(!t||typeof t.querySelector!="function")return null;let s=null;try{s=t.querySelector(i)}catch{return null}if(!s)return null;e&&s.parentNode&&s.parentNode.removeChild(s);let o;try{o=JSON.parse(s.textContent||"")}catch(l){r&&r(l)}return{value:o,block:s}},J='script[type="application/json"][data-brender="registry"]',H=t=>'<script type="application/json" data-brender="registry">'+w(t)+"<\/script>",x=t=>Object.entries(t||{}).filter(([i,e])=>e!==void 0).map(([i,e])=>`${i}="${p(e)}"`).join(" "),j=t=>{let i=5381;const e=String(t);for(let r=0;r<e.length;r++)i=(i*33^e.charCodeAt(r))>>>0;return i.toString(36)},E=new Set(["jsonLd","styles","scripts"]),R=t=>{const i=[];if(Array.isArray(t.jsonLd))for(const e of t.jsonLd){if(e==null)continue;const r=typeof e=="string"?e:JSON.stringify(e),s=String(r).replace(/<\/script/gi,"<\\/script");i.push(`<script type="application/ld+json" data-smbls-jsonld="${j(r)}">${s}<\/script>`)}if(Array.isArray(t.styles))for(const e of t.styles){if(e==null||!String(e).trim())continue;const r=String(e).replace(/<\/style/gi,"<\\/style");i.push(`<style data-smbls-style="${j(r)}">${r}</style>`)}if(Array.isArray(t.scripts))for(const e of t.scripts){if(!e)continue;const r=typeof e=="string",s=r?e:e.src;if(!s&&!e.body)continue;const o=[];s&&o.push(`src="${p(s)}"`),r||(e.type&&o.push(`type="${p(e.type)}"`),e.async&&o.push("async"),e.defer&&o.push("defer"),e.integrity&&o.push(`integrity="${p(e.integrity)}"`),e.crossorigin&&o.push(`crossorigin="${p(e.crossorigin)}"`),e.referrerpolicy&&o.push(`referrerpolicy="${p(e.referrerpolicy)}"`),e.nomodule&&o.push("nomodule"));const l=` data-smbls-script="${p(s||j(e.body||""))}"`;if(!r&&e.body){const d=String(e.body).replace(/<\/script/gi,"<\\/script");i.push(`<script ${o.join(" ")}${l}>${d}<\/script>`)}else i.push(`<script ${o.join(" ")}${l}><\/script>`)}return i},K=t=>`${t.hreflang||""}|${t.href||""}`,N=t=>m(t)?j(JSON.stringify(t)):String(t),T=(t,i,e)=>t==="favicons"?Array.isArray(i)&&(typeof e=="string"||m(e))?` data-smbls-favicon="${p(N(e))}"`:"":(t==="icon"||t==="favicon")&&typeof i=="string"?` data-smbls-single-icon="${p(i)}"`:"",W=t=>m(t)?` data-smbls-alternate="${p(K(t))}"`:"",Y=(t,i)=>{i||(t={...t,robots:"noindex"});const e=Object.entries(t).reduce((r,[s,o])=>{if(!o&&o!==0&&o!==!1||E.has(s))return r;if(s==="title")return r.push(`<title>${p(o)}</title>`),r;if(s==="canonical")return r.push(`<link rel="canonical" href="${p(o)}">`),r;if(s==="manifest")return r.push(`<link rel="manifest" href="${p(o)}">`),r;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(c=>{const u=T(s,o,c);if(typeof c=="string")r.push(`<link rel="icon" href="${p(c)}"${u}>`);else if(typeof c=="object"){const n=x(c);/rel=/.test(n)?r.push(`<link ${n}${u}>`):r.push(`<link rel="icon" ${n}${u}>`)}}),r;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(c=>{if(c&&typeof c=="object"){const u=Object.entries(c).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${p(g)}"`).join(" ");r.push(`<link rel="alternate" ${u}${W(c)}>`)}}),r;const l=(f,c,u="name")=>{if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(c)}">`);else if(Array.isArray(c))c.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")r.push(`<meta ${u}="${p(f)}" content="${p(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([y,$])=>$!==void 0).map(([y,$])=>`${y}="${p($)}"`).join(" ");r.push(`<meta ${g}>`)}});else if(typeof c=="object"){const n=Object.entries(c).filter(([g,y])=>y!==void 0).map(([g,y])=>`${g}="${p(y)}"`).join(" ");r.push(`<meta ${n}>`)}};if(s.startsWith("http-equiv:")){const f=s.replace("http-equiv:","");return l(f,o,"http-equiv"),r}if(s.startsWith("itemprop:")){const f=s.replace("itemprop:","");return l(f,o,"itemprop"),r}const h=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(f=>s.startsWith(f));if(h){const f=s.replace(h,"");return l(`${h.replace(":","")}:${f}`,o,h==="twitter:"||h==="DC:"||h==="DCTERMS:"?"name":"property"),r}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const f=s.startsWith("apple:")?"apple-":"msapplication-",c=s.replace(/^apple:|^msapplication:/,"");return l(`${f}${c}`,o,"name"),r}return l(s,o),r},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...R(t)),e.join(`
2
+ `)},D=t=>typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.startsWith("http"),S=t=>typeof t=="string"&&t.length>0,F=t=>{if(!t||typeof t!="object")return null;if(S(t.src))return t.src;const i=t.content;return!i||typeof i!="object"?null:S(i.src)?i.src:S(i.storageUrl)?i.storageUrl:null};function _(t,i){if(!i||typeof i!="object")return t;const e=s=>!D(s)||!Object.prototype.hasOwnProperty.call(i,s)?s:F(i[s])||s,r={...t};for(const[s,o]of Object.entries(r))typeof o=="string"?r[s]=e(o):Array.isArray(o)&&(r[s]=o.map(l=>typeof l=="string"?e(l):l));return r}function A(t,i){if(!t||!i)return;const e=i.split(".");let r=t;for(const s of e){if(r==null||typeof r!="object")return;r=r[s]}return r}function q(t,i){const e=A(t,i);if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string"&&!L(e))return e}function C(t,i,e){const s=(i.config||i.settings||{}).polyglot||i.polyglot,o=e?.lang||s?.defaultLang||"en",d=(s?.translations||{})[o]||{},h=[e?.state,i.state].filter(u=>u&&typeof u=="object"),f=u=>{for(const n of h){const g=q(n,u);if(g!==void 0)return g}},c={...t};for(const[u,n]of Object.entries(c))typeof n!="string"||!n.includes("{{")||(c[u]=n.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(g,y,$)=>{const a=y.trim();if($==="polyglot")return d[a]??A(d,a)??g;if($==="getLocalStateLang")return f(a+o)??g;const b=f(a);return b!==void 0?b:d[a]??A(d,a)??g}));return c}function M(t){if(!m(t))return{};const i={...t};for(const[e,r]of Object.entries(i))if(typeof r=="function"){const s=r.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[e]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const l=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(l){i[e]=`{{ ${l[1]} | polyglot }}`;continue}const d=s.match(/s\.(\w+(?:\.\w+)+)/);if(d){i[e]=`{{ ${d[1]} }}`;continue}delete i[e]}else if(typeof r=="string"){const s=r.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){i[e]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=r.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){i[e]=`{{ ${o[1]} | polyglot }}`;continue}if(r.includes("=>")&&r.includes("s.")){const l=r.match(/s\.(\w+(?:\.\w+)+)/);if(l){i[e]=`{{ ${l[1]} }}`;continue}}L(r)&&delete i[e]}return i}function G(t,i,e,{isProduction:r=!1,channel:s="production"}={}){const o=t.pages?.[i],l=m(o?.state)&&o?.state,d=o?.metadata||o?.helmet||l||{},h=M(d),f=new Set(Object.keys(h)),c=t.app?.metadata||{},u=M(c);let n={};if(t.integrations?.seo?n={...t.integrations.seo,...u,...h}:Object.keys(u).length?n={...u,...h}:n={...h},!n.title){const a=t.name||t.key;a?r?n.title=a:s==="development"?n.title=`${a} / dev:symbo.ls`:s==="staging"?n.title=`${a} / staging:symbo.ls`:n.title=`${a} / symbo.ls`:n.title="Symbols demo"}n=C(n,t,e),n.title&&(f.has("title")||!n["og:title"])&&(f.has("og:title")||(n["og:title"]=n.title)),n.description&&(f.has("description")||!n["og:description"])&&(f.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=f.has("og:url")?n["og:url"]:f.has("url")?n.url:void 0,y=e?.actualPathname||i;if(g)n["og:url"]=g;else if(n["og:url"]||n.url){const a=(n["og:url"]||n.url||"").replace(/\/$/,"");if(a&&y&&y!=="/"){const b=y.startsWith("/")?y:"/"+y;n["og:url"]=a+b}}n=_(n,t.files);const $=t.name||t.app?.metadata?.title||t.app?.name||"";for(const[a,b]of Object.entries(n))if(typeof b=="string"&&b.includes("{{")){const O=b.replace(/\{\{[^}]*\}\}/g,"").trim();O?n[a]=O:a==="title"?n[a]=$:delete n[a]}return n}export{J as BRENDER_REGISTRY_BLOCK,K as alternateLinkKey,H as brenderRegistryBlock,p as escapeHtml,N as faviconLinkKey,F as fileEntryUrl,R as generateHeadArrayTags,Y as generateMetaTags,G as getPageMetadata,j as hashContent,w as jsonForScript,B as readJsonDataBlock,_ as resolveFileReferences};
@@ -0,0 +1 @@
1
+ const e="smbls_lang",n=t=>t&&t.storageLangKey||e,o=(t,a)=>t||a&&a.defaultLang||"en";export{e as POLYGLOT_LANG_STORAGE_KEY,o as polyglotFallbackLang,n as polyglotLangStorageKey};
@@ -1,4 +1,4 @@
1
- import{isObject as p,isString as y}from"./types.js";import{isProtectedElementMethod as L}from"./keys.js";import{isLoudDevRuntime as ie}from"./env.js";import{destringifyGlobalScope as ce,hasFunction as A,getFunctionSource as ae,deepDestringifyFunctions as le,isStringTag as fe}from"./object.js";const $="system",ue="https://smbls-kv.nika-980.workers.dev",pe="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:$,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=$);const r=t?`${o}/${t}`:"";return{owner:o,key:t,full:r}}const R=(e,n,o,t)=>{for(const r in n){const i=t?`${t}/${r}`:r;o&&o.has(i)||(r in e?p(e[r])&&p(n[r])&&R(e[r],n[r],o,i):e[r]=n[r])}},M=(e,n,o)=>{if(!p(e)||!n.size)return e;const t=`${o}/`;let r=!1;for(const c of n)if(c.startsWith(t)){r=!0;break}if(!r)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const s=`${o}/${c}`;n.has(s)||(i[c]=M(e[c],n,s))}return i},ye=new Set,be=new Set(["components","pages","functions","snippets","methods"]),N=(e,n)=>n===""&&be.has(e),F=["fontFamily","fontfamily","font_family","FONT_FAMILY"],V=e=>{const n=new Map;if(!p(e))return n;for(const o of F){const t=e[o];if(p(t))for(const r in t)!p(t[r])||!t[r].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(r))}return n},D=(e,n)=>{for(const o of F){const t=e[o];if(!p(t))continue;const r=n.get(o);let i=null;for(const c in t){const s=t[c];if(!p(s)||!s.isDefault||r&&r.has(c))continue;const l={...s};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},de=e=>e.replace(/\.js$/iu,""),G=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!y(o))continue;const t=o.split("/").map(r=>de(r.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},Xe=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>p(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),U=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,ve=()=>{j.clear()},he=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);ie()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},me=(e,n,o)=>{let t=null;for(const r in e)if(L(r)&&(n.has(`methods/${r}`)||o.push(r),!t)){t={};for(const i in e)L(i)||(t[i]=e[i])}return t||e},Y=(e,n)=>{const o=G(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],W=["components","pages"],K=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,ge=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),Se=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,z=e=>{try{return ae(e)}catch{return null}},J=e=>{if(typeof e!="function")return null;const n=z(e);return y(n)&&Se.test(n)&&A(n)?n:null},H=e=>y(e)&&A(e)||J(e)!==null,_e=e=>{const n=e.globalScope;return p(n)&&Object.keys(n).some(o=>H(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(r=>H(t[r]))})},ke=(e,n,o)=>{const t=e.globalScope,r=n.globalScope;if(o.has("globalScope")||!p(t)||!p(r)||!_e(n))return 0;let i=0;for(const c of Object.keys(r))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},we=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Oe=e=>{const n=e.split(""),o=[];let t=0,r=0;const i=(s,l)=>{for(let u=s;u<l;u++)n[u]!==`
1
+ import{isObject as p,isString as y}from"./types.js";import{isProtectedElementMethod as L}from"./keys.js";import{isLoudDevRuntime as ie}from"./env.js";import{destringifyGlobalScope as ce,hasFunction as A,getFunctionSource as ae,deepDestringifyFunctions as le,isStringTag as fe}from"./object.js";const $="system",ue="https://smbls-kv.nika-980.workers.dev",pe="https://api.symbols.app";function S(e){const n=String(e||"").trim();if(!n)return{owner:$,key:"",full:""};let o=null,t=n;if(n.includes("/")){const i=n.indexOf("/");o=n.slice(0,i),t=n.slice(i+1)}t=t.replace(/\.symbo\.ls$/iu,""),o||(o=$);const r=t?`${o}/${t}`:"";return{owner:o,key:t,full:r}}const R=(e,n,o,t)=>{for(const r in n){const i=t?`${t}/${r}`:r;o&&o.has(i)||(r in e?p(e[r])&&p(n[r])&&R(e[r],n[r],o,i):e[r]=n[r])}},M=(e,n,o)=>{if(!p(e)||!n.size)return e;const t=`${o}/`;let r=!1;for(const c of n)if(c.startsWith(t)){r=!0;break}if(!r)return e;const i={};for(const c in e){if(!Object.prototype.hasOwnProperty.call(e,c))continue;const s=`${o}/${c}`;n.has(s)||(i[c]=M(e[c],n,s))}return i},ye=new Set,be=new Set(["components","pages","functions","snippets","methods"]),N=(e,n)=>n===""&&be.has(e),F=["fontFamily","fontfamily","font_family","FONT_FAMILY"],V=e=>{const n=new Map;if(!p(e))return n;for(const o of F){const t=e[o];if(p(t))for(const r in t)!p(t[r])||!t[r].isDefault||(n.has(o)||n.set(o,new Set),n.get(o).add(r))}return n},D=(e,n)=>{for(const o of F){const t=e[o];if(!p(t))continue;const r=n.get(o);let i=null;for(const c in t){const s=t[c];if(!p(s)||!s.isDefault||r&&r.has(c))continue;const l={...s};delete l.isDefault,i||(i={...t}),i[c]=l}i&&(e[o]=i)}},de=e=>e.replace(/\.js$/iu,""),G=e=>{const n=new Set;if(!Array.isArray(e))return n;for(const o of e){if(!y(o))continue;const t=o.split("/").map(r=>de(r.trim())).filter(Boolean).join("/");t&&n.add(t)}return n},xe=(e,n={})=>({library:e,ignoreList:Array.isArray(n.ignoreList)?n.ignoreList:[]}),_=e=>p(e)&&Array.isArray(e.ignoreList)&&("library"in e||"key"in e||"name"in e),U=e=>e.library!==void 0?e.library:e.key??e.name,j=new Set,ve=()=>{j.clear()},he=(e,n)=>{const o=n.filter(t=>!j.has(t));if(o.length){for(const t of o)j.add(t);ie()&&console.warn(`[smbls] shared library "${e}" ships ${o.map(t=>`methods.${t}`).join(", ")} \u2014 named like a built-in element method. Refused: the built-in wins; a library cannot replace an element method on the consuming app. If the app wants this version, declare it in the app's OWN methods.`)}},me=(e,n,o)=>{let t=null;for(const r in e)if(L(r)&&(n.has(`methods/${r}`)||o.push(r),!t)){t={};for(const i in e)L(i)||(t[i]=e[i])}return t||e},Y=(e,n)=>{const o=G(e.sharedLibIgnore);return e.sharePages===!1&&o.add("pages"),o.size?new Set([...n,...o]):n},E=["functions","methods","snippets"],W=["components","pages"],K=Symbol.for("smbls.libraryScope"),k="__libraryScopes",I=new Map,ge=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),h=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),Se=/const __scope = |const __peers_* = |const _s = el\?\.scope|\?\.context\?\.globalScope\?\./,z=e=>{try{return ae(e)}catch{return null}},J=e=>{if(typeof e!="function")return null;const n=z(e);return y(n)&&Se.test(n)&&A(n)?n:null},H=e=>y(e)&&A(e)||J(e)!==null,_e=e=>{const n=e.globalScope;return p(n)&&Object.keys(n).some(o=>H(n[o]))?!0:E.some(o=>{const t=e[o];return!!t&&typeof t=="object"&&Object.keys(t).some(r=>H(t[r]))})},ke=(e,n,o)=>{const t=e.globalScope,r=n.globalScope;if(o.has("globalScope")||!p(t)||!p(r)||!_e(n))return 0;let i=0;for(const c of Object.keys(r))o.has(`globalScope/${c}`)||h(t,c)&&i++;return i},we=[[/const __scope = (\(\(\) => \{ const r = [\s\S]*?\}\)\(\));/g,"const __scope = $RESOLVE($1);"],[/const __scope = this \?\? \{\};/g,"const __scope = $RESOLVE(this ?? {});"],[/const (__peers_*) = (this && this !== globalThis && this\.context && this\.context\.globalScope \? this\.scope \?\? this\.context\.globalScope : this);/g,"const $1 = $RESOLVE($2);"],[/const _s = (el\?\.scope \?\? el\?\.context\?\.globalScope \?\? \{\});/g,"const _s = $RESOLVE($1);"],[/(?<![\w$.])(this|[A-Za-z_$][\w$]*)\?\.context\?\.globalScope\?\./g,"$RESOLVE($1?.context?.globalScope)?."]],Oe=e=>{const n=e.split(""),o=[];let t=0,r=0;const i=(s,l)=>{for(let u=s;u<l;u++)n[u]!==`
2
2
  `&&(n[u]="~")},c=()=>{const s=t;for(;t<e.length;){const l=e[t];if(l==="\\"){t+=2;continue}if(l==="`"){i(s,t),t++;return}if(l==="$"&&e[t+1]==="{"){i(s,t),t+=2,o.push(r),r++;return}t++}i(s,t)};for(;t<e.length;){const s=e[t];if(s==="/"&&e[t+1]==="/"){const l=e.indexOf(`
3
3
  `,t),u=l===-1?e.length:l;i(t,u),t=u;continue}if(s==="/"&&e[t+1]==="*"){const l=e.indexOf("*/",t+2),u=l===-1?e.length:l+2;i(t,u),t=u;continue}if(s==='"'||s==="'"){const l=s,u=++t;for(;t<e.length&&e[t]!==l&&e[t]!==`
4
- `;)e[t]==="\\"&&t++,t++;i(u,t),t++;continue}if(s==="`"){t++,c();continue}if(s==="{"){r++,t++;continue}if(s==="}"){if(r--,o.length&&r===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},q=(e,n)=>{if(!y(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!A(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[r,i]of we){const c=Oe(t);t=t.replace(r,(...s)=>{const l=s[s.length-2];return c[l]==="~"||c[l]!==t[l]?s[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(u,a)=>s[Number(a)])})}return t},w=(e,n)=>{if(y(e))return q(e,n);const o=J(e);return o===null?e:q(o,n)},Le={lazy:!0,window:globalThis},Z=(e,n)=>{const o=w(e,n);if(o===e||!y(o))return o;try{const t=le({v:o},{},Le).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Q=(e,n,o=new WeakMap)=>{if(y(e)||typeof e=="function")return Z(e,n);if(fe(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const r of Object.keys(e))t[r]=Q(e[r],n,o);return t},Ae=(e,n)=>{const o={...e},t={};for(const r of Object.keys(e.globalScope))t[r]=w(e.globalScope[r],n);o.globalScope=t;for(const r of E){const i=e[r];if(!P(i))continue;const c={};for(const s of Object.keys(i))c[s]=Z(i[s],n);o[r]=c}for(const r of W)P(e[r])&&(o[r]=Q(e[r],n));return o},X=new WeakMap,$e=(e,n,o)=>{let t=X.get(e);t||X.set(e,t=new Map);let r=t.get(n);if(r)return r;const i=(c,s)=>h(o,c)&&o[c]===s;return r=new Proxy(e,{get(c,s){if(typeof s=="symbol"||h(c,s))return Reflect.get(c,s);const l=Reflect.get(c,s);return h(n,s)&&(l===void 0||i(s,l))||l===void 0?n[s]:l},set(c,s,l){return typeof s!="symbol"&&!h(c,s)&&h(n,s)?(n[s]=l,!0):Reflect.set(c,s,l)},has:(c,s)=>Reflect.has(c,s)||s in n}),t.set(n,r),r},Re=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",je=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Re(n)?$e(n,o.libGs,o.consumerGs):n:n},Ee=()=>{typeof globalThis[K]!="function"&&Object.defineProperty(globalThis,K,{value:je,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,Ie=(e,n,o)=>{const t=O(e);return!!t&&t.some(r=>r&&r.index===n&&(!r.key||r.key===o.key)&&y(r.id)&&Pe(e,r.id))},Pe=(e,n)=>{const o=JSON.stringify(n),t=new Set,r=i=>{if(y(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(r(i[c]))return!0;return!1};for(const i of["globalScope",...E,...W])if(r(e[i]))return!0;return!1},Te=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},v=new WeakMap,xe=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!p(t))return 0;const r=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=v.get(t);i||v.set(t,i=new Set),Ee();let c=0;for(const s of o){if(!s||!y(s.id)||i.has(s.id))continue;const l=T(r[s.index]);if(!l||!p(l.globalScope)||s.key&&l.key!==s.key)continue;const u=b=>typeof b=="function"?z(b):b,a=(b,m)=>{if(b===m)return!0;const B=u(b),C=u(m);return y(B)||y(C)?B===C:JSON.stringify(b)===JSON.stringify(m)},f=p(n)?(Array.isArray(s.landed)?s.landed:[]).filter(b=>y(b)&&h(l.globalScope,b)&&h(n,b)&&a(n[b],w(l.globalScope[b],s.id))):[],d=ce(Te(l.globalScope,s.id));Object.setPrototypeOf(d,t),I.set(s.id,{libGs:d,consumerGs:t});for(const b of f)t[b]=d[b];i.add(s.id),c++}return c},Be=/^@symbo[-.]ls\//,x=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,Ce=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,r=(c,s,l)=>{for(const u of[`@symbo-ls/${c}`,`@symbo.ls/${c}`]){const a=t.get(u);if(a===void 0){t.set(u,s),o.push([u,s]);continue}a!==s&&l&&typeof n=="function"&&n({spec:u,kept:a,refused:s})}},i=[];for(const c of e){const s=T(c);if(!s||typeof s!="object"||s.__isStub)continue;const l=s.key||s.name||s.__libraryKey,u=[];for(const a of[s.key,s.name,s.__libraryKey,s.__libraryName]){if(typeof a!="string"||!a||a!==l&&!Be.test(a))continue;const f=x(a);f&&!u.includes(f)&&u.push(f)}u.forEach((a,f)=>{f===0&&l&&x(l)===a?r(a,s,!1):i.push([a,s])})}for(const[c,s]of i)r(c,s,!0);return o},Me=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],Ne=Symbol.for("smbls.libraryPackages"),g=new WeakMap,Fe=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ve=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const r of Object.keys(e))t[r]=e[r];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:Ve(n)}),g.set(t,o),t},ne=e=>!Fe(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),et=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const r=e[t];ne(r)||g.get(r)===e||(e[t]=te(r,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((r,i)=>{const c=_(r)&&r&&"library"in r,s=T(r);if(!s||typeof s!="object"||s.__isStub||g.get(s)===e)return r;const l=t.find(f=>f&&f.index===i&&(!f.key||f.key===s.key)),u=()=>{const f=l&&I.get(l.id);return f&&f.consumerGs===e.globalScope?f.libGs:e.globalScope},a={...s};for(const f of ee)ne(s[f])||(a[f]=te(s[f],u,e));return g.set(a,e),c?{...r,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[r,i]of Ce(e.sharedLibraries,Me))t[r]=i;try{Object.defineProperty(o,Ne,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},De=(e,n,o,t="library",r=-1)=>{const i=Y(n,o),c=!Ie(e,r,n)&&ke(e,n,i)>0?`${t}#${ge()}`:null,s=c?Ae(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,u=[];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if(p(s[a])&&p(e[a])){if(a==="designSystem")R(e[a],s[a],i,a);else for(const f in s[a])if(!i.has(`${a}/${f}`)){if(a==="methods"&&L(f)){f in e[a]||u.push(f);continue}f in e[a]?N(a,e[a][f])&&!N(a,s[a][f])&&(e[a][f]=s[a][f]):e[a][f]=s[a][f]}}else if(!(a in e)){const f=s[a],d=a==="methods"&&f&&typeof f=="object"?me(f,i,u):f;e[a]=M(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:r,key:y(n.key)?n.key:null,landed:Object.keys(s.globalScope).filter(a=>!l.has(a))})),u.length&&he(t,u)},Ge=(e,n,o)=>{if(e!==n){const t=U(e);if(y(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},Ue=`${$}/default`,Ye=e=>y(e)&&e!==""&&S(e).full===Ue,We=(e,n)=>{if(y(n.key)&&n.key)return n.key;if(e!==n){if(y(e.key)&&e.key)return e.key;if(y(e.name)&&e.name)return e.name}return null},Ke=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const r=e[t];let i=r,c=ye;if(_(i)&&(c=G(i.ignoreList),i=i.library),!p(i))continue;const s={entry:r,lib:i,ignore:c,index:t};Ye(We(r,i))?o.push(s):n.push(s)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=V(n()),{linked:r,bases:i}=Ke(e);for(const s of r)o(s);const c=!t.size&&i.length?V(n()):null;for(const s of i)o(s);return t.size?t:c&&c.size?c:null},tt=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:r,lib:i,ignore:c,index:s})=>De(e,i,c,Ge(r,i,s),s));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),D(e.designSystem,t))},nt=(e,n,o=R)=>{if(!p(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:r,ignore:i})=>{const c=r.designSystem;if(!c||typeof c!="object")return;const s=Y(r,i);s.has("designSystem")||o(e,c,s,"designSystem")});return t&&D(e,t),e};async function ze(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await Je(e,n);return t||se(e,n)}async function Je(e,n={}){const o=n.kvBaseUrl||ue,t=n.env||"production",r=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(r,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||pe,{key:t}=S(e);try{const r=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(r,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(b=>{const{key:m}=S(b?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const u=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(u)}/data?branch=main`,f=await fetch(a,{method:"GET"});if(!f.ok)return null;const d=await f.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if(p(e))return e;if(y(e)){const{full:o}=S(e);if(!o)return null;try{const t=await ze(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function ot(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const r=await re(U(t),n);return r?{library:r,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}export{Ne as LIBRARY_PACKAGES,k as LIBRARY_SCOPES_KEY,ve as __resetBuiltinMethodWarnings,xe as bindLibraryGlobalScopes,R as deepDefaults,et as exposeBagGlobalScopes,ze as fetchLibraryData,_ as isWrappedLibrary,Ce as libraryPackageSpecs,tt as mergeSharedLibraries,nt as mergeSharedLibraryDesignSystems,G as normalizeIgnoreList,S as normalizeLibraryKey,ot as resolveSharedLibraries,Xe as sharedLibrary,Me as warnLibraryAliasCollision};
4
+ `;)e[t]==="\\"&&t++,t++;i(u,t),t++;continue}if(s==="`"){t++,c();continue}if(s==="{"){r++,t++;continue}if(s==="}"){if(r--,o.length&&r===o[o.length-1]){o.pop(),t++,c();continue}t++;continue}t++}return n.join("")},q=(e,n)=>{if(!y(e)||!e.includes("__scope = ")&&!e.includes("__peers")&&!e.includes("const _s = ")&&!e.includes("?.context?.globalScope?.")||!A(e))return e;const o=`(globalThis[Symbol.for('smbls.libraryScope')] || ((_, v) => v))(${JSON.stringify(n)}, `;let t=e;for(const[r,i]of we){const c=Oe(t);t=t.replace(r,(...s)=>{const l=s[s.length-2];return c[l]==="~"||c[l]!==t[l]?s[0]:i.replace(/\$RESOLVE\(/g,o).replace(/\$(\d)/g,(u,a)=>s[Number(a)])})}return t},w=(e,n)=>{if(y(e))return q(e,n);const o=J(e);return o===null?e:q(o,n)},Le={lazy:!0,window:globalThis},Z=(e,n)=>{const o=w(e,n);if(o===e||!y(o))return o;try{const t=le({v:o},{},Le).v;return typeof t!="function"?o:(Object.defineProperty(t,"toJSON",{value:()=>o,configurable:!0}),t)}catch{return o}},P=e=>{if(!e||typeof e!="object")return!1;if(Array.isArray(e))return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Q=(e,n,o=new WeakMap)=>{if(y(e)||typeof e=="function")return Z(e,n);if(fe(e)||!P(e))return e;if(o.has(e))return o.get(e);const t=Array.isArray(e)?[]:Object.getPrototypeOf(e)===null?Object.create(null):{};o.set(e,t);for(const r of Object.keys(e))t[r]=Q(e[r],n,o);return t},Ae=(e,n)=>{const o={...e},t={};for(const r of Object.keys(e.globalScope))t[r]=w(e.globalScope[r],n);o.globalScope=t;for(const r of E){const i=e[r];if(!P(i))continue;const c={};for(const s of Object.keys(i))c[s]=Z(i[s],n);o[r]=c}for(const r of W)P(e[r])&&(o[r]=Q(e[r],n));return o},X=new WeakMap,$e=(e,n,o)=>{let t=X.get(e);t||X.set(e,t=new Map);let r=t.get(n);if(r)return r;const i=(c,s)=>h(o,c)&&o[c]===s;return r=new Proxy(e,{get(c,s){if(typeof s=="symbol"||h(c,s))return Reflect.get(c,s);const l=Reflect.get(c,s);return h(n,s)&&(l===void 0||i(s,l))||l===void 0?n[s]:l},set(c,s,l){return typeof s!="symbol"&&!h(c,s)&&h(n,s)?(n[s]=l,!0):Reflect.set(c,s,l)},has:(c,s)=>Reflect.has(c,s)||s in n}),t.set(n,r),r},Re=e=>!!e&&typeof e=="object"&&!!e.__raw&&typeof e.__raw=="object",je=(e,n)=>{const o=I.get(e);return o?n===o.consumerGs?o.libGs:Re(n)?$e(n,o.libGs,o.consumerGs):n:n},Ee=()=>{typeof globalThis[K]!="function"&&Object.defineProperty(globalThis,K,{value:je,configurable:!0})},O=e=>{const n=e[k];return Array.isArray(n)?n:null},T=e=>_(e)?e.library:e,Ie=(e,n,o)=>{const t=O(e);return!!t&&t.some(r=>r&&r.index===n&&(!r.key||r.key===o.key)&&y(r.id)&&Pe(e,r.id))},Pe=(e,n)=>{const o=JSON.stringify(n),t=new Set,r=i=>{if(y(i))return i.includes(o);if(!i||typeof i!="object"||t.has(i))return!1;t.add(i);for(const c in i)if(r(i[c]))return!0;return!1};for(const i of["globalScope",...E,...W])if(r(e[i]))return!0;return!1},Te=(e,n)=>{const o={};for(const t of Object.keys(e))o[t]=w(e[t],n);return o},x=new WeakMap,et=(e,n=null)=>{const o=e&&O(e);if(!o||!o.length)return 0;const t=e.globalScope;if(!p(t))return 0;const r=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];let i=x.get(t);i||x.set(t,i=new Set),Ee();let c=0;for(const s of o){if(!s||!y(s.id)||i.has(s.id))continue;const l=T(r[s.index]);if(!l||!p(l.globalScope)||s.key&&l.key!==s.key)continue;const u=b=>typeof b=="function"?z(b):b,a=(b,m)=>{if(b===m)return!0;const B=u(b),C=u(m);return y(B)||y(C)?B===C:JSON.stringify(b)===JSON.stringify(m)},f=p(n)?(Array.isArray(s.landed)?s.landed:[]).filter(b=>y(b)&&h(l.globalScope,b)&&h(n,b)&&a(n[b],w(l.globalScope[b],s.id))):[],d=ce(Te(l.globalScope,s.id));Object.setPrototypeOf(d,t),I.set(s.id,{libGs:d,consumerGs:t});for(const b of f)t[b]=d[b];i.add(s.id),c++}return c},Be=/^@symbo[-.]ls\//,v=e=>e.includes("/")?e.slice(e.indexOf("/")+1):e,Ce=e=>[`@symbo-ls/${e}`,`@symbo.ls/${e}`],Me=(e,n)=>{const o=[];if(!Array.isArray(e))return o;const t=new Map,r=(c,s,l)=>{for(const u of Ce(c)){const a=t.get(u);if(a===void 0){t.set(u,s),o.push([u,s]);continue}a!==s&&l&&typeof n=="function"&&n({spec:u,kept:a,refused:s})}},i=[];for(const c of e){const s=T(c);if(!s||typeof s!="object"||s.__isStub)continue;const l=s.key||s.name||s.__libraryKey,u=[];for(const a of[s.key,s.name,s.__libraryKey,s.__libraryName]){if(typeof a!="string"||!a||a!==l&&!Be.test(a))continue;const f=v(a);f&&!u.includes(f)&&u.push(f)}u.forEach((a,f)=>{f===0&&l&&v(l)===a?r(a,s,!1):i.push([a,s])})}for(const[c,s]of i)r(c,s,!0);return o},Ne=({spec:e,kept:n,refused:o})=>{typeof console>"u"||console.warn(`[smbls] shared library "${o&&o.key}" also claims ${e}, which "${n&&n.key}" already owns; ${e} stays with "${n&&n.key}".`)},ee=["functions","methods","snippets"],Fe=Symbol.for("smbls.libraryPackages"),g=new WeakMap,Ve=e=>!!e&&typeof e=="object"&&!Array.isArray(e),De=e=>({get globalScope(){return e()}}),te=(e,n,o)=>{const t={};for(const r of Object.keys(e))t[r]=e[r];return Object.defineProperty(t,"context",{configurable:!0,enumerable:!1,writable:!0,value:De(n)}),g.set(t,o),t},ne=e=>!Ve(e)||!g.has(e)&&Object.prototype.hasOwnProperty.call(e,"context"),tt=e=>{if(!e||typeof e!="object")return;const n=()=>e.globalScope;for(const t of ee){const r=e[t];ne(r)||g.get(r)===e||(e[t]=te(r,n,e))}if(Array.isArray(e.sharedLibraries)){const t=O(e)||[];e.sharedLibraries=e.sharedLibraries.map((r,i)=>{const c=_(r)&&r&&"library"in r,s=T(r);if(!s||typeof s!="object"||s.__isStub||g.get(s)===e)return r;const l=t.find(f=>f&&f.index===i&&(!f.key||f.key===s.key)),u=()=>{const f=l&&I.get(l.id);return f&&f.consumerGs===e.globalScope?f.libGs:e.globalScope},a={...s};for(const f of ee)ne(s[f])||(a[f]=te(s[f],u,e));return g.set(a,e),c?{...r,library:a}:a})}const o=e.globalScope;if(o&&typeof o=="object"){const t={};for(const[r,i]of Me(e.sharedLibraries,Ne))t[r]=i;try{Object.defineProperty(o,Fe,{configurable:!0,enumerable:!1,writable:!0,value:t})}catch{}}},Ge=(e,n,o,t="library",r=-1)=>{const i=Y(n,o),c=!Ie(e,r,n)&&ke(e,n,i)>0?`${t}#${ge()}`:null,s=c?Ae(n,c):n,l=c?new Set(Object.keys(e.globalScope)):null,u=[];for(const a in s)if(Object.prototype.hasOwnProperty.call(s,a)&&!(a==="sharePages"||a==="sharedLibIgnore")&&a!==k&&!a.startsWith("__")&&a!=="app"&&!i.has(a)){if(p(s[a])&&p(e[a])){if(a==="designSystem")R(e[a],s[a],i,a);else for(const f in s[a])if(!i.has(`${a}/${f}`)){if(a==="methods"&&L(f)){f in e[a]||u.push(f);continue}f in e[a]?N(a,e[a][f])&&!N(a,s[a][f])&&(e[a][f]=s[a][f]):e[a][f]=s[a][f]}}else if(!(a in e)){const f=s[a],d=a==="methods"&&f&&typeof f=="object"?me(f,i,u):f;e[a]=M(d,i,a)}}c&&(O(e)||(e[k]=[]),e[k].push({id:c,index:r,key:y(n.key)?n.key:null,landed:Object.keys(s.globalScope).filter(a=>!l.has(a))})),u.length&&he(t,u)},Ue=(e,n,o)=>{if(e!==n){const t=U(e);if(y(t)&&t)return t;if(e.key||e.name)return e.key||e.name}return n&&(n.key||n.name)||`sharedLibraries[${o}]`},Ye=`${$}/default`,We=e=>y(e)&&e!==""&&S(e).full===Ye,Ke=(e,n)=>{if(y(n.key)&&n.key)return n.key;if(e!==n){if(y(e.key)&&e.key)return e.key;if(y(e.name)&&e.name)return e.name}return null},ze=e=>{const n=[],o=[];for(let t=0;t<e.length;t++){const r=e[t];let i=r,c=ye;if(_(i)&&(c=G(i.ignoreList),i=i.library),!p(i))continue;const s={entry:r,lib:i,ignore:c,index:t};We(Ke(r,i))?o.push(s):n.push(s)}return{linked:n,bases:o}},oe=(e,n,o)=>{const t=V(n()),{linked:r,bases:i}=ze(e);for(const s of r)o(s);const c=!t.size&&i.length?V(n()):null;for(const s of i)o(s);return t.size?t:c&&c.size?c:null},nt=(e,n)=>{if(!n||!n.length)return;const o=e.designSystem,t=oe(n,()=>e.designSystem,({entry:r,lib:i,ignore:c,index:s})=>Ge(e,i,c,Ue(r,i,s),s));t&&(e.designSystem!==o&&(e.designSystem={...e.designSystem}),D(e.designSystem,t))},ot=(e,n,o=R)=>{if(!p(e)||!Array.isArray(n)||!n.length)return e;const t=oe(n,()=>e,({lib:r,ignore:i})=>{const c=r.designSystem;if(!c||typeof c!="object")return;const s=Y(r,i);s.has("designSystem")||o(e,c,s,"designSystem")});return t&&D(e,t),e};async function Je(e,n={}){if((n.provider||"kv")==="api")return se(e,n);const t=await He(e,n);return t||se(e,n)}async function He(e,n={}){const o=n.kvBaseUrl||ue,t=n.env||"production",r=`${o}/kv/${encodeURIComponent(e)}?env=${t}`;try{const i=await fetch(r,{method:"GET"});return i.ok&&(await i.json())?.value||null}catch{return null}}async function se(e,n={}){const o=n.apiBaseUrl||pe,{key:t}=S(e);try{const r=`${o}/core/projects/libraries/available?search=${encodeURIComponent(t)}&limit=10`,i=await fetch(r,{method:"GET"});if(!i.ok)return null;const c=await i.json(),l=(c?.items||c?.data||(Array.isArray(c)?c:[])).find(b=>{const{key:m}=S(b?.key);return m.toLowerCase()===t.toLowerCase()});if(!l?.id&&!l?._id)return null;const u=l.id||l._id,a=`${o}/core/projects/${encodeURIComponent(u)}/data?branch=main`,f=await fetch(a,{method:"GET"});if(!f.ok)return null;const d=await f.json();return d?.data||d||null}catch{return null}}async function re(e,n={}){if(p(e))return e;if(y(e)){const{full:o}=S(e);if(!o)return null;try{const t=await Je(o,n);return t||console.warn(`[smbls] Shared library "${o}" not found`),t}catch(t){return console.warn(`[smbls] Failed to fetch shared library "${o}":`,t.message),null}}return null}async function st(e,n={}){return!e||!e.length?[]:(await Promise.all(e.map(async t=>{if(_(t)){const r=await re(U(t),n);return r?{library:r,ignoreList:t.ignoreList}:null}return re(t,n)}))).filter(Boolean)}export{Fe as LIBRARY_PACKAGES,k as LIBRARY_SCOPES_KEY,ve as __resetBuiltinMethodWarnings,v as bareLibraryKey,et as bindLibraryGlobalScopes,R as deepDefaults,tt as exposeBagGlobalScopes,Je as fetchLibraryData,_ as isWrappedLibrary,Me as libraryPackageSpecs,Ce as librarySpecsFor,nt as mergeSharedLibraries,ot as mergeSharedLibraryDesignSystems,G as normalizeIgnoreList,S as normalizeLibraryKey,st as resolveSharedLibraries,xe as sharedLibrary,Ne as warnLibraryAliasCollision};
@@ -1,3 +1,3 @@
1
- const O=(t,r)=>{for(const e of r)if(t.includes(e))return!0;return!1},R=(t,r)=>{const e=new RegExp(`[${r.join("\\")}]`,"g");return t.replace(e,"")},A={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(t,r)=>r.split(".").reduce((e,c)=>e?.[c],t),L=(t,r)=>{if(!t||!t.__ref)return!0;let e=t;for(;e;){if(e.allowRuntimeTemplates===!0)return!0;const c=e.__ref&&e.__ref.__authoredTemplates;if(c&&c.has(r))return!0;e=e.parent}return!1};function I(t,r,e={}){const{bracketsLength:c=2,authored:u=!1}=e,h=c===3?"{{{":"{{";if(!t.includes(h)||u!==!0&&!L(this,t))return t;const p=A[c],f=r||this.state||{},s=this;return t.replace(p,(x,n,b,g)=>{const a=b.trim();if(g){const l=s?.context,o=l?.functions?.[g]||l?.utils?.[g]||l?.methods?.[g]||l?.snippets?.[g]||s?.[g];if(o&&typeof o=="function")try{return String(o.call(s,a)??"")}catch{return""}return""}if(n){const l=(n.match(/\.\.\//g)||[]).length;let o=f;for(let i=0;i<l;i++){if(!o||!o.parent)return"";o=o.parent}if(a==="parent")return String(o.value??"");const d=m(o,a);return d!=null&&typeof d=="object"?"":String(d??"")}else{const l=m(f,a);if(l!=null&&typeof l!="object")return String(l);const o=s?.context?.polyglot;if(o?.translations){const d=f?.root?.lang||f?.lang||s?.context?.state?.lang||o.defaultLang||"en",i=o.translations[d];if(i){const S=m(i,a);if(S!=null&&typeof S!="object")return String(S);for(const w in i){const y=i[w];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,a);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,a);if(C!=null&&typeof C!="object")return String(C)}return""}})}const k=t=>`${t.charAt(0).toLowerCase()}${t.slice(1)}`,E=(t,r)=>{const e=t.split(`
2
- `);let c=-1,u=-1,h=-1,p=-1;const f=new RegExp(`\\b${r}\\b\\s*:\\s*`);let s=0,x=!1;for(let n=0;n<e.length;n++)if(f.test(e[n])&&!x){if(x=!0,c=n+1,h=e[n].indexOf(r)+1,e[n].includes("{}")){u=c,p=e[n].indexOf("{}")+3;break}const b=e[n].slice(h+r.length);if(b.includes("{")||b.includes("["))s=1;else{u=n+1,p=e[n].length+1;break}}else if(x&&(s+=(e[n].match(/{/g)||[]).length,s+=(e[n].match(/\[/g)||[]).length,s-=(e[n].match(/}/g)||[]).length,s-=(e[n].match(/]/g)||[]).length,s===0)){u=n+1,p=e[n].lastIndexOf("}")!==-1?e[n].lastIndexOf("}")+2:e[n].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:c,endLineNumber:u}},j=/\\([0-7]{1,3})/g,$=t=>t.replace(j,(r,e)=>String.fromCharCode(parseInt(e,8))),F=t=>t.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),T=t=>t.replace(/\/\/\/\/\/n/g,`
3
- `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),N=/[^a-zA-Z0-9\s]/g,v=t=>t.replace(N,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),U=t=>t.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{U as customDecodeURIComponent,v as customEncodeURIComponent,T as decodeNewlines,F as encodeNewlines,E as findKeyPosition,k as lowercaseFirstLetter,I as replaceLiteralsWithObjectFields,$ as replaceOctalEscapeSequences,O as stringIncludesAny,R as trimStringFromSymbols};
1
+ const N=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=(e,r)=>{for(const t of r)if(e.includes(t))return!0;return!1},$=(e,r)=>{const t=new RegExp(`[${r.join("\\")}]`,"g");return e.replace(t,"")},A={2:/{{\s*((?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}/g,3:/{{{(\s*(?:\.\.\/)*)([\w\d.]+)\s*(?:\|\s*([\w\d.]+))?\s*}}}/g},m=(e,r)=>r.split(".").reduce((t,c)=>t?.[c],e),L=(e,r)=>{if(!e||!e.__ref)return!0;let t=e;for(;t;){if(t.allowRuntimeTemplates===!0)return!0;const c=t.__ref&&t.__ref.__authoredTemplates;if(c&&c.has(r))return!0;t=t.parent}return!1};function E(e,r,t={}){const{bracketsLength:c=2,authored:u=!1}=t,h=c===3?"{{{":"{{";if(!e.includes(h)||u!==!0&&!L(this,e))return e;const p=A[c],g=r||this.state||{},s=this;return e.replace(p,(x,n,b,f)=>{const a=b.trim();if(f){const l=s?.context,o=l?.functions?.[f]||l?.utils?.[f]||l?.methods?.[f]||l?.snippets?.[f]||s?.[f];if(o&&typeof o=="function")try{return String(o.call(s,a)??"")}catch{return""}return""}if(n){const l=(n.match(/\.\.\//g)||[]).length;let o=g;for(let i=0;i<l;i++){if(!o||!o.parent)return"";o=o.parent}if(a==="parent")return String(o.value??"");const d=m(o,a);return d!=null&&typeof d=="object"?"":String(d??"")}else{const l=m(g,a);if(l!=null&&typeof l!="object")return String(l);const o=s?.context?.polyglot;if(o?.translations){const d=g?.root?.lang||g?.lang||s?.context?.state?.lang||o.defaultLang||"en",i=o.translations[d];if(i){const S=m(i,a);if(S!=null&&typeof S!="object")return String(S);for(const w in i){const y=i[w];if(y&&typeof y=="object"&&!Array.isArray(y)){const _=m(y,a);if(_!=null&&typeof _!="object")return String(_)}}}const C=m(o.translations,a);if(C!=null&&typeof C!="object")return String(C)}return""}})}const I=e=>`${e.charAt(0).toLowerCase()}${e.slice(1)}`,k=(e,r)=>{const t=e.split(`
2
+ `);let c=-1,u=-1,h=-1,p=-1;const g=new RegExp(`\\b${r}\\b\\s*:\\s*`);let s=0,x=!1;for(let n=0;n<t.length;n++)if(g.test(t[n])&&!x){if(x=!0,c=n+1,h=t[n].indexOf(r)+1,t[n].includes("{}")){u=c,p=t[n].indexOf("{}")+3;break}const b=t[n].slice(h+r.length);if(b.includes("{")||b.includes("["))s=1;else{u=n+1,p=t[n].length+1;break}}else if(x&&(s+=(t[n].match(/{/g)||[]).length,s+=(t[n].match(/\[/g)||[]).length,s-=(t[n].match(/}/g)||[]).length,s-=(t[n].match(/]/g)||[]).length,s===0)){u=n+1,p=t[n].lastIndexOf("}")!==-1?t[n].lastIndexOf("}")+2:t[n].length+1;break}return{startColumn:h,endColumn:p,startLineNumber:c,endLineNumber:u}},j=/\\([0-7]{1,3})/g,F=e=>e.replace(j,(r,t)=>String.fromCharCode(parseInt(t,8))),T=e=>e.replace(/\n/g,"/////n").replace(/`/g,"/////tilde").replace(/\$/g,"/////dlrsgn"),v=e=>e.replace(/\/\/\/\/\/n/g,`
3
+ `).replace(/\/\/\/\/\/tilde/g,"`").replace(/\/\/\/\/\/dlrsgn/g,"$"),R=/[^a-zA-Z0-9\s]/g,U=e=>e.replace(R,r=>"%"+r.charCodeAt(0).toString(16).toUpperCase()),V=e=>e.replace(/%[0-9A-Fa-f]{2}/g,r=>String.fromCharCode(parseInt(r.slice(1),16)));export{V as customDecodeURIComponent,U as customEncodeURIComponent,v as decodeNewlines,T as encodeNewlines,N as escapeRegExp,k as findKeyPosition,I as lowercaseFirstLetter,E as replaceLiteralsWithObjectFields,F as replaceOctalEscapeSequences,O as stringIncludesAny,$ as trimStringFromSymbols};
package/index.js CHANGED
@@ -26,6 +26,7 @@ export * from './update.js'
26
26
  export * from './triggerEvent.js'
27
27
  export * from './projectKeys.js'
28
28
  export * from './legacyScopePreamble.js'
29
+ export * from './polyglotLang.js'
29
30
 
30
31
  // ── Merged from the former @symbo.ls/smbls-utils package (4.x) ────────────
31
32
  export * from './browser.js'
package/keys.js CHANGED
@@ -119,6 +119,7 @@ export const METHODS = new Set([
119
119
  'lookup',
120
120
  'lookdown',
121
121
  'lookdownAll',
122
+ 'whenConnected',
122
123
  'getRef',
123
124
  'getPath',
124
125
  'setNodeStyles',
@@ -44,6 +44,18 @@ const TEMPLATES = [
44
44
  const withReceiver = (tpl, ref) => tpl.split('$R').join(ref)
45
45
  const THIS_FORMS = TEMPLATES.map((tpl) => [withReceiver(tpl, 'this'), tpl])
46
46
 
47
+ /**
48
+ * The scope expression CURRENT frank emits for a receiver `ref` — the newest
49
+ * template above. frank scopeRewriter buildScopeDecl reads it from here, so
50
+ * the preamble frank writes and the forms this repair recognises cannot
51
+ * drift: a new preamble shape is a new last entry of TEMPLATES (never an edit
52
+ * of one — payloads pushed with it stay in the wild).
53
+ *
54
+ * @param {string} ref - the receiver expression (a parameter name, `this`)
55
+ * @returns {string}
56
+ */
57
+ export const scopeReceiverExpression = (ref) => withReceiver(TEMPLATES[TEMPLATES.length - 1], ref)
58
+
47
59
  const DECL = 'const __scope = '
48
60
  // sharedLibraries.js scopeLibraryText's wrapper around a preamble's value
49
61
  const LIBRARY_WRAPPER_RE = /^\(globalThis\[Symbol\.for\('smbls\.libraryScope'\)\] \|\| \(\(_, v\) => v\)\)\("(?:[^"\\]|\\.)*", /
@@ -54,12 +66,29 @@ const IDENT_RE = /^[A-Za-z_$][\w$]*$/
54
66
 
55
67
  const named = (p, base) => typeof p === 'string' && new RegExp('^' + base + '\\d*$').test(p)
56
68
 
57
- // Mirror of frank scopeRewriter getElementRef for component / page paths.
58
- const elementParam = (params) => {
69
+ /**
70
+ * The parameter of a component / page function that receives the element —
71
+ * the receiver of its scope preamble. frank scopeRewriter getElementRef uses
72
+ * it (one rule for the preamble frank writes and the one this repair writes):
73
+ * `el\d*` first or second (esbuild renames `el` to `el2`), `element\d*` /
74
+ * `node\d*` first, then `boundElement` — the parameter a destructuring
75
+ * pattern binds to the `element` key (frank reads it from the function text;
76
+ * a thunk, called only when the rules before it found none) — then any
77
+ * `element\d*`. null when none.
78
+ *
79
+ * @param {string[]} params - the parameter names, in order
80
+ * @param {() => (string|null)} [boundElement]
81
+ * @returns {string|null}
82
+ */
83
+ export const scopeElementParam = (params, boundElement) => {
59
84
  if (params.length >= 2 && named(params[0], 'el')) return params[0]
60
85
  if (params.length >= 2 && named(params[1], 'el')) return params[1]
61
86
  if (params.length >= 1 && named(params[0], 'el')) return params[0]
62
87
  if (named(params[0], 'element') || named(params[0], 'node')) return params[0]
88
+ if (typeof boundElement === 'function') {
89
+ const bound = boundElement()
90
+ if (bound && params.includes(bound)) return bound
91
+ }
63
92
  return params.find((p) => named(p, 'element')) || null
64
93
  }
65
94
 
@@ -87,7 +116,7 @@ export const repairLegacyArrowScopePreamble = (src) => {
87
116
  const raw = head[1] !== undefined ? head[1] : head[2]
88
117
  const params = raw.split(',').map((p) => p.split('=')[0].trim()).filter(Boolean)
89
118
  if (params.some((p) => !IDENT_RE.test(p))) return src
90
- const ref = elementParam(params)
119
+ const ref = scopeElementParam(params)
91
120
  if (!ref) return src
92
121
  return src.slice(0, at) + withReceiver(form[1], ref) + src.slice(end)
93
122
  }
package/metadata.js CHANGED
@@ -3,12 +3,67 @@
3
3
  import { isObject } from './types.js'
4
4
  import { isStringFunction } from './function.js'
5
5
 
6
- const escapeHtml = (text) => {
6
+ // HTML text / attribute-value escape shared by every server head builder —
7
+ // this file's generateMetaTags and helmet's generateHeadHtml (SSR) — so the
8
+ // two emit the same bytes for the same value.
9
+ export const escapeHtml = (text) => {
7
10
  if (text === null || text === undefined) return ''
8
11
  const map = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' }
9
12
  return text.toString().replace(/[&<>"']/g, (m) => map[m])
10
13
  }
11
14
 
15
+ /**
16
+ * `value` as JSON that is safe INSIDE an inline <script>: `<` is escaped (no
17
+ * `</script>` can end the tag early), and so are U+2028 / U+2029 (line
18
+ * terminators to a pre-ES2019 parser). Still valid JSON and the same value.
19
+ * The server pages' boot scripts use it — brender's element-path registry,
20
+ * @symbo.ls/fetch's seed of recorded answers.
21
+ */
22
+ export const jsonForScript = (value) => JSON.stringify(value)
23
+ .replace(/</g, '\\u003c')
24
+ .replace(/\u2028/g, '\\u2028')
25
+ .replace(/\u2029/g, '\\u2029')
26
+
27
+ /**
28
+ * Read a JSON data block — `<script type="application/json" data-…>` — that a
29
+ * server render left in `doc` for the client: the brender element-path
30
+ * registry (BRENDER_REGISTRY_BLOCK), @symbo.ls/fetch's recorded answers. No
31
+ * Content-Security-Policy blocks a data block (only inline scripts do).
32
+ * @param {Document} doc
33
+ * @param {string} selector - the block's CSS selector
34
+ * @param {object} [options]
35
+ * @param {boolean} [options.remove] - take the block out of the document as
36
+ * it is read
37
+ * @param {(err: Error) => void} [options.warn] - told when the block is not
38
+ * JSON (its value is then undefined)
39
+ * @returns {{ value: *, block: Element } | null} null when the document has
40
+ * no such block
41
+ */
42
+ export const readJsonDataBlock = (doc, selector, { remove = false, warn } = {}) => {
43
+ if (!doc || typeof doc.querySelector !== 'function') return null
44
+ let block = null
45
+ try { block = doc.querySelector(selector) } catch (e) { return null }
46
+ if (!block) return null
47
+ if (remove && block.parentNode) block.parentNode.removeChild(block)
48
+ let value
49
+ try {
50
+ value = JSON.parse(block.textContent || '')
51
+ } catch (err) {
52
+ if (warn) warn(err)
53
+ }
54
+ return { value, block }
55
+ }
56
+
57
+ /** The data block that carries a pre-rendered page's element-path registry. */
58
+ export const BRENDER_REGISTRY_BLOCK = 'script[type="application/json"][data-brender="registry"]'
59
+
60
+ /**
61
+ * The element-path registry as the data block BRENDER_REGISTRY_BLOCK selects,
62
+ * its JSON embedded with jsonForScript (a key can never close the block).
63
+ */
64
+ export const brenderRegistryBlock = (registry) =>
65
+ '<script type="application/json" data-brender="registry">' + jsonForScript(registry) + '</script>'
66
+
12
67
  const buildAttrs = (obj) =>
13
68
  Object.entries(obj || {})
14
69
  .filter(([_, v]) => v !== undefined)
@@ -26,9 +81,7 @@ const buildAttrs = (obj) =>
26
81
  * Lives here because `utils` is the lowest package in the graph:
27
82
  * `@symbo.ls/helmet` already depends on `@symbo.ls/utils`, never the
28
83
  * reverse, so this is the only place the three pipelines can share one
29
- * implementation without a cycle. The helmet plugin still carries a
30
- * byte-identical private `_hashContent` (`plugins/helmet/index.js`); it can
31
- * drop it in favour of this export whenever that package is next touched.
84
+ * implementation without a cycle.
32
85
  */
33
86
  export const hashContent = (s) => {
34
87
  let h = 5381
@@ -50,10 +103,11 @@ const HEAD_ARRAY_KEYS = new Set(['jsonLd', 'styles', 'scripts'])
50
103
  /**
51
104
  * Render the `jsonLd` / `styles` / `scripts` head extensions.
52
105
  *
53
- * Emission semantics mirror `generateHeadHtml` (`plugins/helmet/index.js`)
54
- * exactly — same `data-smbls-*` key attributes, same escaping, same hash
55
- * inputs — so a published page and an SSR'd page produce interchangeable
56
- * head markup and the client runtime reconciles both without re-emitting.
106
+ * The one emitter of these tags for both server heads — helmet's SSR
107
+ * `generateHeadHtml` (`plugins/helmet/index.js`) calls it too — so a
108
+ * published page and an SSR'd page carry the same `data-smbls-*` keys, the
109
+ * same escaping and the same hash inputs, and the client runtime reconciles
110
+ * both without re-emitting.
57
111
  *
58
112
  * metadata.jsonLd: [{ '@context': 'https://schema.org', '@type': 'Organization', … }]
59
113
  * metadata.styles: ['@media (prefers-color-scheme: dark) { :root { --c: #111 } }']
@@ -125,12 +179,17 @@ export const generateHeadArrayTags = (metadata) => {
125
179
  * stayed on every page after it. helmet's SSR builder (`generateHeadHtml`)
126
180
  * emits the same keys. A shape the client never renders (`icons`, an icon
127
181
  * array, a lone `favicons` value) stays unkeyed, so the client never owns it.
182
+ *
183
+ * The two keys below are the ONE definition all three use (unescaped — each
184
+ * server builder escapes it into its attribute; the client sets it as is).
128
185
  */
186
+ export const alternateLinkKey = (alt) => `${alt.hreflang || ''}|${alt.href || ''}`
187
+ export const faviconLinkKey = (fav) => isObject(fav) ? hashContent(JSON.stringify(fav)) : String(fav)
188
+
129
189
  const iconKeyAttr = (key, value, item) => {
130
190
  if (key === 'favicons') {
131
191
  if (!Array.isArray(value)) return ''
132
- if (typeof item === 'string') return ` data-smbls-favicon="${escapeHtml(item)}"`
133
- if (isObject(item)) return ` data-smbls-favicon="${hashContent(JSON.stringify(item))}"`
192
+ if (typeof item === 'string' || isObject(item)) return ` data-smbls-favicon="${escapeHtml(faviconLinkKey(item))}"`
134
193
  return ''
135
194
  }
136
195
  if ((key === 'icon' || key === 'favicon') && typeof value === 'string') {
@@ -140,7 +199,7 @@ const iconKeyAttr = (key, value, item) => {
140
199
  }
141
200
 
142
201
  const alternateKeyAttr = (alt) =>
143
- isObject(alt) ? ` data-smbls-alternate="${escapeHtml(`${alt.hreflang || ''}|${alt.href || ''}`)}"` : ''
202
+ isObject(alt) ? ` data-smbls-alternate="${escapeHtml(alternateLinkKey(alt))}"` : ''
144
203
 
145
204
  /**
146
205
  * Generates HTML meta tags from a flat metadata object.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.785",
3
+ "version": "3.14.787",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
49
49
  "peerDependencies": {
50
- "@symbo.ls/fetch": "^3.14.662"
50
+ "@symbo.ls/fetch": "^3.14.665"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@symbo.ls/fetch": {
@@ -0,0 +1,22 @@
1
+ 'use strict'
2
+
3
+ // The language a polyglot app starts in — shared by @symbo.ls/polyglot (the
4
+ // runtime: initPolyglot, setLang, getActiveLang) and @symbo.ls/fetch's
5
+ // pre-boot script build (earlyScript.js languageRule), which must ask in the
6
+ // language the app will boot in. They kept one copy each of the storage key
7
+ // and the fallback order; a change to one would have sent the early requests
8
+ // in another language than the app's, and nothing would have failed.
9
+
10
+ /** Where polyglot keeps a visitor's chosen language, unless `storageLangKey` says otherwise. */
11
+ export const POLYGLOT_LANG_STORAGE_KEY = 'smbls_lang'
12
+
13
+ /** The storage key of the chosen language for a `polyglot` config. */
14
+ export const polyglotLangStorageKey = (polyglot) =>
15
+ (polyglot && polyglot.storageLangKey) || POLYGLOT_LANG_STORAGE_KEY
16
+
17
+ /**
18
+ * The language when no choice is stored: the language the state already
19
+ * resolved (`stateLang`), else the config's `defaultLang`, else 'en'.
20
+ */
21
+ export const polyglotFallbackLang = (stateLang, polyglot) =>
22
+ stateLang || (polyglot && polyglot.defaultLang) || 'en'
@@ -753,7 +753,16 @@ export const bindLibraryGlobalScopes = (context, mergedGlobalScope = null) => {
753
753
  // alias, so a library cannot take a slot another library owns by record key;
754
754
  // an alias two libraries claim stays with the first and is reported.
755
755
  const NPM_SCOPED_LIBRARY_ID_RE = /^@symbo[-.]ls\//
756
- const bareLibraryKey = (raw) => (raw.includes('/') ? raw.slice(raw.indexOf('/') + 1) : raw)
756
+
757
+ /** A library identifier without its owner / npm scope: `owner/key` → `key`. */
758
+ export const bareLibraryKey = (raw) => (raw.includes('/') ? raw.slice(raw.indexOf('/') + 1) : raw)
759
+
760
+ /**
761
+ * The package names a library key is imported under — both npm scopes. frank
762
+ * (scopeRewriter buildDeclaredLibraryPackageSet) and the registry below take
763
+ * them from here, so the specifiers frank rewrites are the ones registered.
764
+ */
765
+ export const librarySpecsFor = (key) => [`@symbo-ls/${key}`, `@symbo.ls/${key}`]
757
766
 
758
767
  /**
759
768
  * Ordered [spec, library] pairs for `libraries` (entries or wrappers), stubs
@@ -765,7 +774,7 @@ export const libraryPackageSpecs = (libraries, onCollision) => {
765
774
  if (!Array.isArray(libraries)) return out
766
775
  const owner = new Map()
767
776
  const take = (key, lib, isAlias) => {
768
- for (const spec of [`@symbo-ls/${key}`, `@symbo.ls/${key}`]) {
777
+ for (const spec of librarySpecsFor(key)) {
769
778
  const have = owner.get(spec)
770
779
  if (have === undefined) { owner.set(spec, lib); out.push([spec, lib]); continue }
771
780
  if (have !== lib && isAlias && typeof onCollision === 'function') onCollision({ spec, kept: have, refused: lib })
package/string.js CHANGED
@@ -1,5 +1,8 @@
1
1
  'use strict'
2
2
 
3
+ /** `str` with every RegExp special character escaped, to match it literally. */
4
+ export const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
5
+
3
6
  export const stringIncludesAny = (str, characters) => {
4
7
  for (const char of characters) {
5
8
  if (str.includes(char)) {