@symbo.ls/element 3.14.779 → 3.14.780
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/dist/cjs/src/create.js +5 -5
- package/dist/cjs/src/delegate.js +1 -1
- package/dist/cjs/src/dispose.js +1 -1
- package/dist/cjs/src/index.js +1 -1
- package/dist/cjs/src/update.js +1 -1
- package/dist/esm/src/create.js +5 -5
- package/dist/esm/src/delegate.js +1 -1
- package/dist/esm/src/dispose.js +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/update.js +1 -1
- package/package.json +1 -1
package/dist/cjs/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`+
|
|
1
|
+
"use strict";var yt=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var to=(t,n)=>{for(var s in n)yt(t,s,{get:n[s],enumerable:!0})},oo=(t,n,s,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Jt(n))!mt.call(t,r)&&r!==s&&yt(t,r,{get:()=>n[r],enumerable:!(e=Xt(n,r))||e.enumerable});return t};var so=t=>oo(yt({},"__esModule",{value:!0}),t);var Do={};to(Do,{BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES:()=>ut,acquireBeforeUpdateGuard:()=>qt,create:()=>K,default:()=>Po,flushMounts:()=>ft,releaseBeforeUpdateGuard:()=>it,writeElementText:()=>rt});module.exports=so(Do);var L=require("@symbo.ls/signal"),w=require("@symbo.ls/signal"),G=require("./cache.js"),N=require("./registry.js"),X=require("./delegate.js"),zt=require("./extends.js"),Yt=require("./methods.js"),Mo=require("./dispose.js"),et=require("./devRuntime.js"),at=require("@symbo.ls/utils"),U=require("@symbo.ls/utils/function.js"),Z=require("@symbo.ls/state"),b=require("css-in-props"),V=require("@symbo.ls/css"),A=require("@symbo.ls/scratch"),v=require("attrs-in-props");let no=1;const tt=[];let ht=!1;function Tt(){return typeof Date<"u"&&typeof Date.now=="function"?Date.now():0}function eo(){return typeof document<"u"&&document.visibilityState==="hidden"}const ro=250;function Pt(){if(!ht){if(ht=!0,typeof requestAnimationFrame!="function"){setTimeout(ft,0);return}eo()?setTimeout(ft,ro):requestAnimationFrame(ft)}}const io=300,co=15e4;function ft(){if(ht=!1,!tt.length)return;const t=tt.splice(0,tt.length);for(let n=0;n<t.length;n++){const s=t[n];if(s.node){if(!s.node.isConnected){const e=s.__ref||(s.__ref={});e.__mountAttempts=(e.__mountAttempts||0)+1,e.__mountFirstAttemptAt==null&&(e.__mountFirstAttemptAt=Tt());const r=Tt()-e.__mountFirstAttemptAt;e.__mountAttempts<=io&&r<co?(tt.push(s),Pt()):console.warn("[DOMQL] onMounted dropped after",e.__mountAttempts,"attempts /",r,"ms \u2014 node never connected:",s.key||s.tag||s);continue}B("Mounted",s,s.__ref?.__mountOptions||{})}}}function Dt(t,n){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=n,tt.push(t),Pt())}function Lt(t,n){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&(0,U.runPluginHook)("contentUpdate",t,n);const s=t.context?.designSystem;s&&(0,A.pushConfig)(s);try{t.onContentUpdate(t,t.state,t.context,n)}catch(e){if(t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onContentUpdate",error:e})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',e),t.context?.strictMode)throw e}finally{s&&(0,A.popConfig)()}}function Y(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function ao(t){return t.charAt(2).toLowerCase()+t.slice(3)}function fo(t){return t.toLowerCase()}function _t(t){const n=t.charCodeAt(0);return n===58||n===64||n===38}function ot(t,n){const s={...t};for(const e in n){const r=s[e],o=n[e];r&&o&&typeof r=="object"&&typeof o=="object"&&!Array.isArray(r)&&!Array.isArray(o)&&typeof r!="function"&&typeof o!="function"?s[e]=ot(r,o):s[e]=o}return s}function K(t,n,s,e={},r){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=s||t.key||`_${no++}`,o.parent=n||null,o.context=t.context||n?.context||e.context||{},o.context.__create||(o.context.__create=K);const c=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:n?.__ref?.root||o,path:n?.__ref?.path?[...n.__ref.path,o.key]:[o.key],origin:t};if(s&&!t.extends&&!t.extend){const d=s.indexOf("_");if(d>0){const p=s.substring(0,d),g=o.context?.components;g&&(g[p]||g["smbls."+p])?t={...t,extends:p}:g&&(0,et.isLoudDevRuntime)()&&/^[A-Z]\w*_\d+$/.test(s)&&console.warn(`[smbls] auto-extend: key "${s}" looks like a multi-instance (${p}_N) but neither "${p}" nor "smbls.${p}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}(0,zt.applyExtends)(o,t,e);const i=new Set(["childProps","attr","style","scope","data"]),a=o.props&&typeof o.props=="object"?o.props:null;for(const d in t){if(d==="parent"||d==="node"||d==="__ref"||d==="extends"||d==="context"||d==="props")continue;const p=t[d],g=o[d],k=g&&p&&typeof g=="object"&&typeof p=="object"&&!Array.isArray(g)&&!Array.isArray(p)&&typeof g!="function"&&typeof p!="function";k&&d.charCodeAt(0)>=65&&d.charCodeAt(0)<=90?o[d]=ot(g,p):k&&i.has(d)?o[d]={...g,...p}:k&&_t(d)?o[d]=ot(g,p):o[d]=p}function f(d){for(const p in d){const g=d[p],k=o[p],x=k&&g&&typeof k=="object"&&typeof g=="object"&&!Array.isArray(k)&&!Array.isArray(g)&&typeof k!="function"&&typeof g!="function";x&&p.charCodeAt(0)>=65&&p.charCodeAt(0)<=90?o[p]=ot(k,g):x&&i.has(p)?o[p]={...k,...g}:x&&_t(p)?o[p]=ot(k,g):o[p]=g}}a&&f(a),t.props&&typeof t.props=="object"&&f(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const u=o.scope&&typeof o.scope=="object"?o.scope:null,l=n?.scope,y=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,h=l||y||null;if(t.scope!==void 0||u){const d={};u&&Object.assign(d,u),t.scope!==void 0&&Object.assign(d,t.scope),o.scope=(0,L.createScopeStore)(d,h)}else h&&(o.scope=h);if(t.if!==void 0&&(o.if=t.if),(0,Yt.addMethods)(o),uo(o,n,t),o.if!=null){let d;if(typeof o.if=="function")try{d=o.if(o,o.state,o.context)}catch(p){if(d=!1,c.__ifError=p,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,p?.message||p)}}else d=o.if;c.__if=!!d}if(c.__if)typeof o.if=="function"&&(c.__ifInitialized=!0);else return n&&(n[o.key]=o),typeof o.if=="function"&&Rt(o,c,o.if),o;o.tag||(o.tag=(0,G.detectTag)(o)),B("Init",o,e);const _=o.node=(0,G.cacheNode)(o);if(!_)return o;if(o.tag==="fragment"){const p=(o.context?.document||globalThis.document).createComment("");_.appendChild(p),c.__fragmentAnchor=p}B("AttachNode",o,e),_.setAttribute&&o.key&&_.setAttribute("data-key",o.key),n&&(n[o.key]=o,n.__ref?.__children&&(n.__ref.__children.includes(o.key)||n.__ref.__children.push(o.key))),_.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&_.setAttribute("data-smbls-app",o.context.key),o.id&&_.setAttribute&&(_.id=o.id),Ht(o,e),$t(o),bt(o),Kt(o),Eo(o);try{Gt(o,e)}catch(d){if(typeof console<"u"&&console.error){const p=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${p}:`,d?.message||d,d?.stack?`
|
|
2
|
+
`+d.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(kt(o,!0),Bt(o,s,e),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&(0,A.pushConfig)(l);try{const _=o.html(o,o.state,o.context);_!=null&&typeof _!="function"&&(o.node.innerHTML=_)}catch{}finally{l&&(0,A.popConfig)()}}if(I("Create",o,r),I("Complete",o,r),I("Render",o,r),I("RenderRouter",o,r),Et(o,r),typeof o.onFrame=="function"){const l=o.onFrame,_=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){_&&(0,A.pushConfig)(_);try{l(o,o.state,o.context)}catch(C){console.error("[DOMQL] onFrame error:",C)}finally{_&&(0,A.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function io(t,s,n){const r=!s,e=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&e&&t.context?.state,a=n.state!==void 0&&!o?n.state:t.state&&!(0,O.isStore)(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,(0,Z.applyStateMethods)(t,t.state);else if(t.context?.state){const i=t.context.state,c={...i},f=t.context?.polyglot;if(f?.translations){const u=i.lang||f.defaultLang||"en",d=f.translations[u];if(d&&typeof d=="object")for(const y in d)c[y]===void 0&&(c[y]=d[y]);const p=new Set(f.languages||[]);for(const y in f.translations)!p.has(y)&&c[y]===void 0&&(c[y]=f.translations[y])}t.state=(0,O.isStore)(c)?c:(0,O.createStore)(c),t.state.__element=t,t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,Z.applyStateMethods)(t,t.state);return}if(typeof a=="string"){if(t.state=Ot(a,s),t.state&&typeof t.state=="object"&&!(0,O.isStore)(t.state)){const i=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:i,enumerable:!1,configurable:!0,writable:!0})}(0,Z.applyStateMethods)(t,t.state);return}if(typeof a=="function"){const i=a(t,s?.state);t.state=(0,O.isStore)(i)?i:(0,O.createStore)(i||{})}else(0,O.isStore)(a)?t.state=a:t.state=(0,O.createStore)({...a});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}function yt(t,s){if(!s)return t;const n=s.split("/");let r=t;for(const e of n){if(r==null)return{};r=r[e]}return r??{}}function Ot(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const e=t.slice(3);return e?yt(s.state,e):s.state??{}}if(t.startsWith("~/")){const e=s.state?.root||s.state,o=t.slice(2);return o?yt(e,o):e??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=yt(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=s.context?.polyglot;if(r?.translations){const e=s.state?.root?.lang||r.defaultLang||"en",o=r.translations[e];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}const eo=new Set(["s","state","ctx","context"]);function co(t){try{const n=Function.prototype.toString.call(t).match(/^[^(]*\(([^)]*)\)/);return n?n[1].split(",").map(r=>r.trim().split("=")[0].trim()).filter(Boolean):[]}catch{return[]}}function ao(t){if(typeof t!="function"||t.length!==2)return!1;const s=co(t);if(s.length<2)return!1;const n=s[1].replace(/[{}[\]]/g,"").trim();return n.length>0&&!eo.has(n)}function fo(t){const s=t.__ref,n=t.tag||"div",r=t.context?.designSystem,e=[],o=Object.keys(t);for(let a=0;a<o.length;a++){const i=o[a];if(typeof t[i]!="function"||R.REGISTRY.has(i))continue;const c=i.charCodeAt(0);c>=65&&c<=90||z(i)||b.CSS_PROPS_REGISTRY[i]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(i)||(0,j.checkAttributeByTagName)(n,i)||((0,rt.isLoudDevRuntime)()&&ao(t[i])&&console.warn(`[smbls] custom prop "${i}"${t.key?` on key "${t.key}"`:""} is a function \u2014 it will be auto-invoked on read and its RETURN VALUE stored, not preserved as a callable reference. If you meant to stash a callback, use el.call('${i}', \u2026) instead of reading el.${i}(\u2026) directly (see RULES.md Rule 8).`),e.push({prop:i,fn:t[i]}))}for(let a=0;a<e.length;a++){const{prop:i,fn:c}=e[a];s.__exec[i]=c,Object.defineProperty(t,i,{get(){r&&(0,A.pushConfig)(r);try{return c(t,t.state,t.context)}catch{return}finally{r&&(0,A.popConfig)()}},set(f){delete s.__exec[i],Object.defineProperty(t,i,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function uo(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const r=s[n];try{typeof r=="function"?r(t,t.state,t.context):typeof r=="string"&&t.state?.[r]}catch{}}}function L(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...r){return uo(t,s),n.apply(this,r)}}function tt(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Dt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(fo(t),typeof t.text=="function"){const o=t.text,a=L(t,t.textDeps,o),i=(0,v.createEffect)(()=>{if(!n.contentManaged)try{let c=a(t,t.state,t.context);t.node&&c!=null&&typeof c!="function"&&typeof c!="object"&&(typeof c=="string"&&c.includes("{{")&&(c=it.replaceLiteralsWithObjectFields.call(t,c,t.state)),t.tag==="string"?t.node.nodeValue=c:t.node.textContent=c)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,a=(0,v.createEffect)(()=>{if(n.contentManaged)return;const i=it.replaceLiteralsWithObjectFields.call(t,o,t.state);i!=null&&(t.text=i),t.node&&(t.tag==="string"?t.node.nodeValue=i??"":t.node.textContent=i??"")},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(a),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!R.REGISTRY.has(o)&&!z(o)&&!n.__exec[o]){if(b.CSS_PROPS_REGISTRY[o]){const a=t[o],i=L(t,t[o+"Deps"],a),c=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=i(t,t.state,t.context),y=b.CSS_PROPS_REGISTRY[c](p,t,t.state,t.context);if(y&&t.node){const h=_t(y);(h===null||h!==f)&&(f=h,Y(t.node,y))}else t.node&&(c==="show"||c==="hide")&&(f=void 0,t.node.style.display="")}finally{d&&(0,A.popConfig)()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(u),n.__exec[o]=a}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const a=t[o],i=L(t,t[o+"Deps"],a),c=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=i(t,t.state,t.context);if(t.node)if(p!=null){const y=c+":"+String(p);y!==f&&(f=y,Y(t.node,{[c]:p}))}else f=void 0,t.node.style[c]=""}finally{d&&(0,A.popConfig)()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=L(t,t.htmlDeps,o),i=(0,v.createEffect)(()=>{const c=t.context?.designSystem;c&&(0,A.pushConfig)(c);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{c&&(0,A.popConfig)()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=L(t,t.valueDeps,o),i=(0,v.createEffect)(()=>{try{const c=a(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=c==null?"":String(c);if(t.node.value===f)return;const u=typeof document<"u"&&document.activeElement===t.node,d=u&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=u&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,u&&d!=null&&p!=null)try{t.node.setSelectionRange(d,p)}catch{}}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=L(t,t.styleDeps,o);let i;const c=(0,v.createEffect)(()=>{const f=a(t,t.state,t.context),u=_t(f);(u===null||u!==i)&&(i=u,Y(t.node,f))},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(c),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const a=t.style[o];if(typeof a!="function")continue;const i=L(t,tt(t.styleDeps,o),a);let c;const f=(0,v.createEffect)(()=>{try{const u=i(t,t.state,t.context);if(t.node){const d=o+":"+String(u);d!==c&&(c=d,Y(t.node,{[o]:u}))}}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const a=L(t,tt(t.attrDeps,o),t.attr[o]),i=o,c=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1&&!(0,j.isEnumeratedTrueFalseAttr)(i)?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,(0,j.serializeAttrValue)(i,f)))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(c)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const a=L(t,tt(t.ariaDeps,o),t.aria[o]),i="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),c=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,(0,j.serializeAttrValue)(i,f))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(c)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const a=L(t,tt(t.dataDeps,o),t.data[o]),c="data-"+o.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=(0,v.createEffect)(()=>{try{const u=a(t,t.state,t.context);if(!t.node?.setAttribute)return;u==null||u===!1?t.node.removeAttribute(c):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(c,u===!0?"":u)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}const e=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(e)for(const o in e){if(typeof e[o]!="function")continue;const a=L(t,tt(t.classDeps,o),e[o]),i=(0,v.createEffect)(()=>{try{const c=a(t,t.state,t.context);if(!t.node?.classList)return;typeof c=="string"?t.node.classList.add(c):c?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i)}!r&&typeof t.if=="function"&&Tt(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||R.REGISTRY.has(o)||typeof t[o]!="function")continue;const a=o.charCodeAt(0);if(a>=65&&a<=90||z(o))continue;const i=t[o];n.__exec[o]=i;const c=t.tag||"div";if((0,j.checkAttributeByTagName)(c,o)&&!b.CSS_PROPS_REGISTRY[o]&&!(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const f=(0,j.camelToAttr)(o)||o,u=L(t,t[o+"Deps"],i),d=(0,v.createEffect)(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1&&!(0,j.isEnumeratedTrueFalseAttr)(f)?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,(0,j.serializeAttrValue)(f,p))))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(d)}}if(yo(t),go(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let i=!1,c=[];const f=(0,v.createEffect)(()=>{const u=[];for(let h=0;h<a.length;h++){const l=a[h];try{u[h]=typeof l=="function"?l(t,t.state,t.context):t.state?.[l]}catch{u[h]=void 0}}if(!i){i=!0,c=u;return}let d=u.length!==c.length;for(let h=0;!d&&h<u.length;h++)u[h]!==c[h]&&(d=!0);const p=c;if(c=u,!d)return;const y=t.context?.designSystem;y&&(0,A.pushConfig)(y);try{o(t,t.state,t.context,{prev:p,next:u})}catch(h){if(t.context?.plugins?.length&&(0,M.runPluginHook)("error",t,{hook:"onStateUpdate",error:h})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',h),t.context?.strictMode)throw h}finally{y&&(0,A.popConfig)()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}_o(t)}function Lt(t){const s=t.parent,n=s?.node;if(!n||!t.node){Bt(t,t.parent);return}let r=null;const e=Object.keys(s),o=e.indexOf(t.key);for(let a=o+1;a<e.length;a++){const i=s[e[a]];if(i?.node?.parentNode===n){r=i.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function Tt(t,s,n){const r=L(t,t.ifDeps,n),e=(0,v.createEffect)(()=>{let o;try{o=r(t,t.state,t.context)}catch(i){if(o=!1,s.__ifError=i,typeof console<"u"&&console.warn){const c=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${c} \u2014 treating as false:`,i?.message||i)}return}const a=s.__if;if(s.__if=!!o,a&&!s.__if&&t.node)t.node.remove();else if(!a&&s.__if)if(s.__ifInitialized)t.node||(t.node=(0,H.cacheNode)(t)),t.node&&(t.node.ref=t),Lt(t),ht(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=(0,H.detectTag)(t)),I("Init",t,{}),t.node||(t.node=(0,H.cacheNode)(t)),!t.node)return;if(t.parent?.__ref?.__children&&!t.parent.__ref.__children.includes(t.key)&&t.parent.__ref.__children.push(t.key),t.tag==="fragment"&&!s.__fragmentAnchor){const c=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(c),s.__fragmentAnchor=c}I("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),Ut(t,{}),Dt(t,{skipIfEffect:!0}),ht(t),Mt(t),It(t,{}),Lt(t),Et(t,{})}},{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(e)}function ht(t){const{node:s}=t;if(s){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?s.nodeValue=t.text:s.textContent=t.text:typeof t.text=="number"&&(s.textContent=t.text),xo(t),typeof t.html=="string"&&(s.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in s){const n=String(t.value);s.value!==n&&(s.value=n)}if(t.style&&typeof t.style=="object"&&Y(s,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const r=t.attr[n];typeof r=="function"||typeof r=="object"||r!=null&&(r===!1&&!(0,j.isEnumeratedTrueFalseAttr)(n)||s.setAttribute&&s.setAttribute(n,(0,j.serializeAttrValue)(n,r)))}if(t.data&&typeof t.data=="object")for(const n in t.data){const r=t.data[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||s.dataset&&(s.dataset[n]=r===!0?"":r)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(r=>r&&s.classList.add(r));else if(typeof n=="object")for(const r in n){const e=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];e&&s.classList.add(typeof e=="string"?e:r)}}}}function _t(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function Y(t,s){if(!t||!s||!t.style)return;let n=null;for(const r in s){const e=s[r];if(e!=null){if(r.charAt(0)==="&"&&typeof e=="object"){n||(n={}),n[r]=e;continue}try{const o=String(e),a=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),i=o.trim(),c=/\s*!important\s*$/.test(i),f=i.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,c?"important":"")}catch{}}}n&&po(t,n)}let lo=0;function po(t,s){const n=`_ds${lo++}`;t.classList.add(n);const r=t.ownerDocument;let e=r.querySelector("style[data-smbls-scoped]");e||(e=r.createElement("style"),e.setAttribute("data-smbls-scoped",""),r.head.appendChild(e));let o="";for(const a in s){const i="."+n,c=a.replace(/&/g,i).split(",").map(u=>{const d=u.trim();return d.includes(i)?d:i+d}).join(", "),f=s[a];if(typeof f=="object"){let u="",d="";for(const p in f){const y=f[p];if(typeof y=="object"){const h=p.includes("&")?c.split(", ").map(_=>p.replace(/&/g,_)).join(", "):c.split(", ").map(_=>`${_} ${p}`).join(", ");let l="";for(const _ in y)l+=`${_.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[_]};`;d+=(0,K.wrapHoverRule)(`${h} { ${l} }`,h)+`
|
|
5
|
-
`}else u+=`${
|
|
6
|
-
`),d&&(o+=d)}}o&&(e.textContent+=o)}function yo(t){let s=t.subscribeTo;if(typeof s=="function")try{s=s(t,t.state,t.context)}catch{s=null}if(!Array.isArray(s)||s.length===0)return;const n=t.__ref;for(let r=0;r<s.length;r++){const e=s[r];if(typeof e!="string"||e.length===0)continue;const o=e.split("."),a=o[0],i=o.slice(1),c={value:!1},f=(0,v.createEffect)(()=>{const u=t.state&&((0,O.isStore)(t.state)?t.state.root:null);if(!u||!(0,O.isStore)(u))return;let d=u;d=d[a];for(let y=0;y<i.length&&!(d==null||typeof d!="object");y++)if((0,O.isStore)(d))d=d[i[y]];else break;if(!c.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&(0,A.pushConfig)(y);try{if(Wt(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>st(n,!1),l=>{st(n,!0),t.context?.plugins?.length&&(0,M.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(st(n,!1),h===!1&&(p=!0))}}catch(h){st(n,!0),t.context?.plugins?.length&&(0,M.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:h})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",h)}finally{y&&(0,A.popConfig)()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const h=n.__effects[y];h&&h!==f&&!h._disposed&&!h._isSubscribeToEffect&&typeof h._execute=="function"&&h._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&(0,A.pushConfig)(y);try{t.onUpdate(t,t.state,t.context)}catch(h){t.context?.plugins?.length&&(0,M.runPluginHook)("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&(0,A.popConfig)()}}},{depth:n.path.length,label:()=>n.path.join(".")});c.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function gt(t,s){return t.charCodeAt(0)===64&&t.length>1&&!t.startsWith("@media")&&!t.startsWith("@keyframes")&&!t.startsWith("@supports")&&(t==="@dark"||t==="@light"||!s.context?.designSystem?.media?.[t.slice(1)])}const $t=new Set;function ho(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",r=n+"::"+t;$t.has(r)||($t.add(r),console.warn(`[smbls/css] "${t}" at ${n} is a CHILD-COMPONENT key nested inside a pseudo/selector block (":hover", "@dark", etc.) \u2014 that is never a valid CSS selector fragment. The rule is DROPPED (not shipped as a dead/never-matching selector). To reveal a child on a parent state, target the child's OWN class from the parent selector instead, e.g. move the declaration onto the child element itself, or use a sibling-selector combinator in a top-level style block.`))}function Q(t,s,n){const r={},e=new Set,o=(a,i,c)=>{const f=c?new Set(Object.keys(r)):null;if(b.CSS_PROPS_REGISTRY[a]){const u=b.CSS_PROPS_REGISTRY[a](i,s,s.state,s.context);if(u){const d=Array.isArray(u)?u:[u];for(const p of d)p&&Object.assign(r,p)}}else r[a]=i;if(c)for(const u in r)f.has(u)||e.add(u)};for(const a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;let i=t[a];if(typeof i=="function"&&(i=i(s,s.state,s.context)),i==null||typeof i=="function")continue;if(typeof i=="object"&&!Array.isArray(i)){if(a==="style"){for(const d in i){let p=i[d];if(typeof p=="function"&&(p=p(s,s.state,s.context)),p==null||typeof p=="function")continue;const y=typeof s[d]=="function"&&(b.CSS_PROPS_REGISTRY[d]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(d));o(d,p,y)}continue}if(gt(a,s)){const d=Q(i,s,!1);Object.keys(d).length&&(r[`[data-theme="${a.slice(1)}"] &`]=d);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(a)){(0,rt.isLoudDevRuntime)()&&ho(a,s);continue}let f=a;if(a.charCodeAt(0)===64&&!a.startsWith("@media")&&!a.startsWith("@keyframes")){const d=s.context?.designSystem?.media?.[a.slice(1)];d&&(f=`@media ${d}`)}const u=Q(i,s,!1);Object.keys(u).length&&(r[f]=u);continue}const c=typeof s[a]=="function"&&(b.CSS_PROPS_REGISTRY[a]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(a));o(a,i,c)}if(n)for(const a in r)e.add(a);for(const a of e){const i=r[a];typeof i=="string"&&!i.includes("!important")&&(r[a]=i+" !important")}return r}function bt(t,s){if(s===void 0&&(s=0),s>8)return!1;if(typeof t=="function")return!0;if(t&&typeof t=="object"&&!Array.isArray(t)){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&bt(t[n],s+1))return!0}return!1}function Rt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(gt(t,n)){const o=Q(s,n,!1);return Object.keys(o).length?{cssProp:`[data-theme="${t.slice(1)}"] &`,block:o}:null}let r=t;if(t.charAt(0)==="@"&&!t.startsWith("@media")&&!t.startsWith("@keyframes")){const o=n.context?.designSystem?.media?.[t.slice(1)];o&&(r=`@media ${o}`)}const e=Q(s,n,!1);return Object.keys(e).length?{cssProp:r,block:e}:null}function _o(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!pt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!bt(r))continue;let e=null,o;const a=(0,v.createEffect)(()=>{if(!t.node)return;const i=t.context?.designSystem;i&&(0,A.pushConfig)(i);let c,f=!1;try{const u=Rt(n,r,t),d=u?_t(u.block)+"::"+u.cssProp:null;if(d!==null&&d===o)f=!0;else if(o=d,u){const p=(0,K.css)({[u.cssProp]:u.block},null,t.context?.cssPrefix);c=p?p.split(" ").filter(Boolean):null}else c=null}finally{i&&(0,A.popConfig)()}if(!(f||!t.node.classList)){if(e)for(const u of e)t.node.classList.remove(u);if(c&&c.length)for(const u of c)t.node.classList.add(u);e=c}},{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(a)}}function go(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const e=r.charAt(0);if(e!=="."&&e!=="!")continue;const o=r.slice(1);if(!o)continue;if(/[:@\s>~+[\]]/.test(o)){if(typeof console<"u"&&console.warn){const d=o.split(/[:@\s>~+[\]]/)[0];console.warn(`[smbls] conditional \`${r}\` on ${t.key||"?"} will never match \u2014 the whole string after \`${e}\` is read as one prop name. Nest the selector inside instead: \`${e}${d}: { '${o.slice(d.length)}': {...} }\`.`)}continue}const a=t[r];if(!a||typeof a!="object")continue;const i=e==="!",c={lastMatch:!1,appliedKeys:null,appliedClasses:null},f=()=>{let d;const p=t[o];if(p===void 0){const l=!!t.state&&o in t.state,_=t.state?t.state[o]:void 0;if(l||_!==void 0)d=_;else{const g=t.context?.cases?.[o];if(g===void 0)return;try{d=typeof g=="function"?g.call(t,t):g}catch(C){d=!1,s.__conditionalError=C,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${r}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,C?.message||C)}}}else if(typeof p=="function")try{d=p(t,t.state,t.context)}catch(l){d=!1,s.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${r}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}else d=p;const y=i?!d:!!d;if(!t.node||y===c.lastMatch)return;c.lastMatch=y;const h=t.context?.designSystem;h&&(0,A.pushConfig)(h);try{if(y){const l={},_={};let g=!1;for(const x in a){if(!Object.prototype.hasOwnProperty.call(a,x))continue;const P=a[x],w=x.charAt(0);if((w===":"||w==="@"||w==="&")&&P&&typeof P=="object"&&!Array.isArray(P)){if(gt(x,t)){const T=Q(P,t,!1);Object.keys(T).length&&(_[`[data-theme="${x.slice(1)}"] &`]=T,g=!0)}else{let T=x;if(w==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const V=t.context?.designSystem?.media?.[x.slice(1)];V&&(T=`@media ${V}`)}const W=Q(P,t,!1);Object.keys(W).length&&(_[T]=W,g=!0)}continue}const E=typeof P=="function"?P(t,t.state,t.context):P;if(E!=null)if(b.CSS_PROPS_REGISTRY[x]){const T=b.CSS_PROPS_REGISTRY[x](E,t,t.state,t.context);if(T){const W=Array.isArray(T)?T:[T];for(const V of W)V&&Object.assign(l,V)}}else b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(l[x]=E)}const C=Object.keys(l);if(C.length){Y(t.node,l);for(const x of C)n.set(x,r);c.appliedKeys=C}else c.appliedKeys=null;if(g){const x=(0,K.css)(_,null,t.context?.cssPrefix),P=x?x.split(" ").filter(Boolean):[];if(P.length&&t.node.classList){for(const w of P)t.node.classList.add(w);c.appliedClasses=P}else c.appliedClasses=null}else if(c.appliedClasses){for(const x of c.appliedClasses)t.node.classList.remove(x);c.appliedClasses=null}}else{if(c.appliedKeys){for(const l of c.appliedKeys)n.get(l)===r&&(t.node.style[l]="",n.delete(l));c.appliedKeys=null}if(c.appliedClasses){for(const l of c.appliedClasses)t.node.classList.remove(l);c.appliedClasses=null}}}finally{h&&(0,A.popConfig)()}};s.__conditionalRunners.push(f);const u=(0,v.createEffect)(f,{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(u)}}const xt=new WeakSet;function bo(t){const s=t.ownerDocument;!s||xt.has(s)||(xt.add(s),queueMicrotask(()=>{xt.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const At=new WeakSet;let Ft=!1;function xo(t){const{node:s}=t;if(!s)return;if(Ft||(Ft=!0,(0,K.css)({display:"none"})),At.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}At.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const r={};let e=!1;if(Object.prototype.hasOwnProperty.call(t,"theme")&&typeof t.theme!="function"&&b.CSS_PROPS_REGISTRY.theme){const o=b.CSS_PROPS_REGISTRY.theme(t.theme,t,t.state,t.context);if(o){if(Array.isArray(o))for(const a of o)a&&Object.assign(r,a);else Object.assign(r,o);e=!0}}for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||R.REGISTRY.has(o)||o==="theme")continue;const a=o.charCodeAt(0);if(!(a>=65&&a<=90)&&!z(o)){if(b.CSS_PROPS_REGISTRY[o]){const i=t[o],c=b.CSS_PROPS_REGISTRY[o](i,t,t.state,t.context);if(c){if(Array.isArray(c))for(const f of c)f&&Object.assign(r,f);else Object.assign(r,c);e=!0}}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const i=t[o];i!=null&&typeof i!="object"&&(r[o]=i,e=!0)}else if(o.charCodeAt(0)===45){const i=t[o];i!=null&&typeof i!="object"&&(r[o]=i,e=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const i=t[o];if(i&&typeof i=="object"&&!Array.isArray(i)){if(bt(i))continue;const c=Rt(o,i,t);c&&(r[c.cssProp]=c.block,e=!0)}}}}if(e){r.display&&String(r.display).includes("!important")&&(s.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=(0,K.css)(r,null,t.context?.cssPrefix);if(o&&s.classList){const i=o.split(" ").filter(Boolean);let c=!1;for(const f of i)s.classList.add(f),c||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(c=!0);c&&bo(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const i=r.display;if(i&&i!==a)if(a==="none"){const c=[];for(const f of s.classList)f.startsWith("_d-")&&f!=="_d-none"&&c.push(f);for(const f of c)s.classList.remove(f);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&(0,A.popConfig)(),At.delete(t)}}function Mt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const e in t.aria){const o=t.aria[e];if(typeof o=="function"||typeof o=="object"||o==null)continue;const a="aria-"+e.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());s.setAttribute(a,(0,j.serializeAttrValue)(a,o))}const n=(0,j.applyAttrTransforms)(t);for(const e in n){const o=n[e];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(e,o===!0?"":o)}const r=t.tag||"div";for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e)||typeof t[e]=="function"||R.REGISTRY.has(e)||e==="on"||n[e]!==void 0)continue;const o=e.charCodeAt(0);if(!(o>=65&&o<=90)&&!z(e)&&!(b.CSS_PROPS_REGISTRY[e]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(e))&&(0,j.checkAttributeByTagName)(r,e)){let a=t[e];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=(0,it.replaceLiteralsWithObjectFields)(a,t,t.state,t.context),t[e]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!(0,j.isEnumeratedTrueFalseAttr)((0,j.camelToAttr)(e)||e))continue;const i=(0,j.camelToAttr)(e)||e;s.setAttribute(i,(0,j.serializeAttrValue)(i,a))}}}function Ao(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,r=n&&typeof n=="object"&&n.max?String(n.max):null;r&&(s.style.maxHeight=r);const e=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};e(),s.addEventListener("input",e),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",e)}catch{}})}const Nt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Ut(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!z(n)||Nt.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(i){return t.call(o,i)}}if(typeof r!="function")continue;const e=no(n);R.LIFECYCLE_EVENTS.has(e)||(0,Kt.registerEvent)(ro(e),t,r)}Co(t)}function Co(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Nt){const y=t[p];typeof y=="function"&&(n[p]=y,r=!0)}if(!r)return;const e=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let a=0,i=0,c=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,i=y.clientY,c=Date.now(),f=!0)},d=p=>{if(!f)return;f=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const h=y.clientX-a,l=y.clientY-i,_=Date.now()-c;if(_>o)return;const g=Math.abs(h),C=Math.abs(l);if(Math.max(g,C)<e)return;let x;if(g>C*1.2)x=h<0?"left":"right";else if(C>g*1.2)x=l<0?"up":"down";else return;const P="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),w=n[P],E=n.onSwipe;w&&w.call(t,p,t,t.state,t.context),E&&E.call(t,{direction:x,dx:h,dy:l,dt:_,event:p},t,t.state,t.context)};s.addEventListener("touchstart",u,{passive:!0}),s.addEventListener("touchend",d,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",u)}catch{}try{s.removeEventListener("touchend",d)}catch{}})}function ot(t,s){const n={...t};for(const r in s){const e=n[r],o=s[r];e&&o&&typeof e=="object"&&typeof o=="object"&&!Array.isArray(e)&&!Array.isArray(o)&&typeof e!="function"&&typeof o!="function"?n[r]=ot(e,o):n[r]=o}return n}function Ct(t,s,n){if(!s||!t.node)return;const r=t.childExtends;if(Array.isArray(s)){const e=t.tag==="fragment",o=t.context?.document||globalThis.document,a=e?null:o?.createDocumentFragment();if(!e&&!a)return;const i=t.childProps,c=t.childrenAs;for(let f=0;f<s.length;f++){let u=s[f];const d=u;(typeof u=="string"||typeof u=="number")&&(u={text:u});let p=i;if(typeof i=="function")try{p=i(t,u)}catch{p=null}if(c==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),u=p?{...p,state:l}:{state:l}}else p&&(u=ot(p,u));if(r&&!u.ignoreChildExtends)if(u.extends){const l=Array.isArray(u.extends)?u.extends:[u.extends],_=Array.isArray(r)?r:[r];u={...u,extends:[..._,...l]}}else u={...u,extends:r};const y=u?.key||d&&typeof d=="object"&&d.key||`${f}`;let h;try{h=B(u,t,y,n)}catch(l){if(typeof console<"u"&&console.error){const _=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${y}" failed to construct at ${_} (initial render, skipping this row):`,l?.message||l)}continue}!e&&h?.node&&a.appendChild(h.node)}return e||t.node.appendChild(a),!0}if(typeof s=="string"){const e=Ot(s,t);if(Array.isArray(e))return Ct(t,e,n)}if(typeof s=="object")for(const e in s){if(R.REGISTRY.has(e))continue;let o=s[e];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=ot(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],i=Array.isArray(r)?r:[r];o={...o,extends:[...i,...a]}}else o={...o,extends:r};B(o,t,e,n)}}}function kt(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const r=n.options;if(!r||!r.length)return;const e=t.__ref,o=e&&e.__exec&&e.__exec.value,a=typeof o=="function",i=t.value!=null&&typeof t.value!="function";if(a||i){let u;if(a)try{u=o(t,t.state,t.context)}catch{return}else u=t.value;const d=u==null?"":String(u);n.value!==d&&(n.value=d);return}const c=s||!(e&&e.__selectSynced);if(e&&(e.__selectSynced=!0),!c)return;let f=-1;for(let u=0;u<r.length;u++)r[u].defaultSelected&&(f=u);f>=0&&n.selectedIndex!==f&&(n.selectedIndex=f)}function It(t,s){let{children:n,content:r}=t;const e=t.childExtends;if(typeof n=="function"){const i=n;try{n=i(t,t.state,t.context)}catch(p){if(n=void 0,typeof console<"u"&&console.error){const y=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${y} (initial run, treating as empty):`,p?.message||p)}}t.children=n;const c=t.__ref;let f=!1;const u=L(t,t.childrenDeps,i),d=(0,v.createEffect)(()=>{const p=f;f=!0;let y;try{y=u(t,t.state,t.context)}catch(w){if(typeof console<"u"&&console.error){const E=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${E}${p?"":" (initial tracking run)"}:`,w?.message||w)}return}if(!p||y===t.children)return;t.children=y;const h=typeof t.onContentUpdate=="function",l=h?[]:null,_=h?[]:null,g=h?[]:null;if(Array.isArray(y)&&t.childrenAs==="state"){const w=t.childProps,E=[],T=new Map;for(let k=0;k<y.length;k++){const $=y[k];let S=w;if(typeof w=="function")try{S=w(t,$)}catch{S=null}const N=S&&S.key||$&&$.key||`${k}`;E.push(N),T.set(N,{rawChild:$,childProps:S})}const W=new Set(E),V=c.__children.slice();for(const k of V)if(!W.has(k)){const $=t[k];$?.remove&&$.remove(),delete t[k],_&&_.push(k)}const q=t.childExtends,nt=t.tag==="fragment",Gt=t.context?.document||globalThis.document,X=nt?null:Gt?.createDocumentFragment(),at=new Set;for(const k of E){const $=T.get(k),S=$.rawChild,N=t[k];if(N&&N.state){if(S&&typeof S=="object"){const D=N.state,G=D.$replace||D.replace,jt=D.$update||D.update;if(typeof G=="function")G.call(D,S);else if(typeof jt=="function"){for(const U in D)if(!(U==="__element"||U==="root"||U==="parent"||U==="update")&&!Object.prototype.hasOwnProperty.call(S,U))try{D[U]=void 0}catch{}jt.call(D,S)}else for(const U in S)D[U]=S[U]}g&&g.push(k);continue}let ft=S;(typeof S=="string"||typeof S=="number")&&(ft={value:S,text:S});const St=$.childProps;let F=St?{...St,state:ft}:{state:ft};if(q&&!F.ignoreChildExtends)if(F.extends){const D=Array.isArray(F.extends)?F.extends:[F.extends],G=Array.isArray(q)?q:[q];F={...F,extends:[...G,...D]}}else F={...F,extends:q};let ut;try{ut=B(F,t,k,s)}catch(D){if(typeof console<"u"&&console.error){const G=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${k}" failed to construct at ${G} (reconcile, skipping this row):`,D?.message||D)}at.add(k);continue}!nt&&ut?.node&&X&&X.appendChild(ut.node),l&&l.push(k)}if(!nt&&X&&X.childNodes.length&&t.node&&t.node.appendChild(X),!nt&&t.node){let k=null;for(const $ of E){const S=t[$]?.node;if(!S)continue;const N=k?k.nextSibling:t.node.firstChild;S!==N&&t.node.insertBefore(S,N),k=S}}c.__children=at.size?E.filter(k=>!at.has(k)):E,h&&(l.length||_.length)&&Pt(t,{added:l,removed:_,kept:g}),kt(t,!1);return}const P=h?[...c.__children]:null;for(const w of[...c.__children]){const E=t[w];E?.remove&&E.remove(),delete t[w]}c.__children=[],Ct(t,y,s),kt(t,!1),h&&Pt(t,{added:[...c.__children],removed:P,kept:[]})},{depth:c.path.length,label:()=>c.path.join(".")});c.__effects.push(d)}const o=Ct(t,n,s);if(r!=null&&!(r&&r.__ref)){let i=r;if(typeof i=="string"||typeof i=="number"?i={text:i}:typeof i!="object"&&(i={}),t.childProps&&(i=ot(t.childProps,i)),e&&!i.ignoreChildExtends)if(i.extends){const c=Array.isArray(i.extends)?i.extends:[i.extends],f=Array.isArray(e)?e:[e];i={...i,extends:[...f,...c]}}else i={...i,extends:e};B(i,t,"content",s)}if(n&&!o)return;const a=t.context?.components||{};{const i=Object.keys(t);for(let c=0;c<i.length;c++){const f=i[c];if(!f.endsWith("Extends")||typeof t[f]!="string")continue;const u=f.slice(0,-7);if(!u||u.charCodeAt(0)<65||u.charCodeAt(0)>90)continue;const d={extends:t[f]};delete t[f];for(let p=c+1;p<i.length;p++){const y=i[p],h=y.charCodeAt(0);if(h>=65&&h<=90||R.REGISTRY.has(y)||typeof t[y]=="function"&&(y.startsWith("on")||y.startsWith(".")))break;const l=t[y];l!==void 0&&(d[y]=l,delete t[y])}t[u]&&typeof t[u]=="object"?t[u]={...d,...t[u]}:t[u]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||R.REGISTRY.has(i)||typeof t[i]!="object"||t[i]===null)continue;const c=i.charCodeAt(0);if(c<65||c>90)continue;let f=t[i];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[i]||a[`smbls.${i}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=ot(t.childProps,f)),e&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],d=Array.isArray(e)?e:[e];f={...f,extends:[...d,...u]}}else f={...f,extends:e};B(f,t,i,s)}}}function Bt(t,s,n){const{node:r}=t;if(!r)return;r.ref=t;const e=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(e){const a=e.parentNode;if(a){if(n?.position==="before"&&n.node)a.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;a.insertBefore(r,i||e)}else a.insertBefore(r,e);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const a=n.node.nextSibling;a?o.insertBefore(r,a):o.appendChild(r)}else o.appendChild(r)}const ct=3;function Wt(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=ct?!1:(t.__inBeforeUpdate=!0,!0)}function st(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===ct&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${ct}x in a row on this element \u2014 pausing automatic retries until a future prop/state change re-arms it.`)):t.__beforeUpdateFailCount=0)}function I(t,s,n){const r=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&(0,M.runPluginHook)(r,s,n);const e="on"+t,o=s[e];if(typeof o=="function"){const c=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(c){if(s.__ref[c])return!0;s.__ref[c]=!0}const f=s.context?.designSystem;f&&(0,A.pushConfig)(f);let u=!!c;try{const d=o(s,s.state,s.context,n);if(d&&typeof d.then=="function"){const p=s.__ref;return d.catch(y=>{s.context?.plugins?.length&&(0,M.runPluginHook)("error",s,{hook:e,error:y})||console.error(`[DOMQL] Lifecycle "${e}" error:`,y)}).finally(()=>{c&&p&&(p[c]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&(0,M.runPluginHook)("error",s,{hook:e,error:d})||console.error(`[DOMQL] Lifecycle "${e}" error:`,d),s.context?.strictMode)throw d}finally{f&&(0,A.popConfig)(),u&&s.__ref&&(s.__ref[c]=!1)}}return!0}var ko=B;
|
|
4
|
+
`):"")}}if(wt(o,!0),Wt(o,n,r),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const d=o.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=o.html(o,o.state,o.context);p!=null&&typeof p!="function"&&(o.node.innerHTML=p)}catch{}finally{d&&(0,A.popConfig)()}}if(B("Create",o,e),B("Complete",o,e),B("Render",o,e),B("RenderRouter",o,e),Dt(o,e),typeof o.onFrame=="function"){const d=o.onFrame,p=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){p&&(0,A.pushConfig)(p);try{d(o,o.state,o.context)}catch(k){console.error("[DOMQL] onFrame error:",k)}finally{p&&(0,A.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function uo(t,n,s){const e=!n,r=s.state&&typeof s.state=="object"&&!Array.isArray(s.state)&&Object.keys(s.state).length===0,o=e&&r&&t.context?.state,c=s.state!==void 0&&!o?s.state:t.state&&!(0,L.isStore)(t.state)?t.state:void 0;if(c==null){if(n?.state)t.state=n.state,(0,Z.applyStateMethods)(t,t.state);else if(t.context?.state){const i=t.context.state,a={...i},f=t.context?.polyglot;if(f?.translations){const u=i.lang||f.defaultLang||"en",l=f.translations[u];if(l&&typeof l=="object")for(const h in l)a[h]===void 0&&(a[h]=l[h]);const y=new Set(f.languages||[]);for(const h in f.translations)!y.has(h)&&a[h]===void 0&&(a[h]=f.translations[h])}t.state=(0,L.isStore)(a)?a:(0,L.createStore)(a),t.state.__element=t,t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,Z.applyStateMethods)(t,t.state);return}if(typeof c=="string"){if(t.state=Ot(c,n),t.state&&typeof t.state=="object"&&!(0,L.isStore)(t.state)){const i=n?.state?.root||n?.state||t.state;Object.defineProperty(t.state,"root",{value:i,enumerable:!1,configurable:!0,writable:!0})}(0,Z.applyStateMethods)(t,t.state);return}if(typeof c=="function"){const i=c(t,n?.state);t.state=(0,L.isStore)(i)?i:(0,L.createStore)(i||{})}else(0,L.isStore)(c)?t.state=c:t.state=(0,L.createStore)({...c});t.state.__element=t,n?.state?(t.state.parent=n.state,t.state.root=n.state.root||n.state):t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}function gt(t,n){if(!n)return t;const s=n.split("/");let e=t;for(const r of s){if(e==null)return{};e=e[r]}return e??{}}function Ot(t,n){if(!n)return{};if(t===".")return n.state||{};if(t.startsWith("../")){const r=t.slice(3);return r?gt(n.state,r):n.state??{}}if(t.startsWith("~/")){const r=n.state?.root||n.state,o=t.slice(2);return o?gt(r,o):r??{}}if(n.state?.[t]!==void 0)return n.state[t];const s=gt(n.state,t);if(s!=null&&Object.keys(s).length>0)return s;const e=n.context?.polyglot;if(e?.translations){const r=n.state?.root?.lang||e.defaultLang||"en",o=e.translations[r];if(o?.[t]!==void 0)return o[t];if(e.translations[t]!==void 0)return e.translations[t]}return{}}const lo=new Set(["s","state","ctx","context"]);function po(t){try{const s=Function.prototype.toString.call(t).match(/^[^(]*\(([^)]*)\)/);return s?s[1].split(",").map(e=>e.trim().split("=")[0].trim()).filter(Boolean):[]}catch{return[]}}function yo(t){if(typeof t!="function"||t.length!==2)return!1;const n=po(t);if(n.length<2)return!1;const s=n[1].replace(/[{}[\]]/g,"").trim();return s.length>0&&!lo.has(s)}function ho(t){const n=t.__ref,s=t.tag||"div",e=t.context?.designSystem,r=[],o=Object.keys(t);for(let c=0;c<o.length;c++){const i=o[c];if(typeof t[i]!="function"||N.REGISTRY.has(i))continue;const a=i.charCodeAt(0);a>=65&&a<=90||Y(i)||b.CSS_PROPS_REGISTRY[i]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(i)||(0,v.checkAttributeByTagName)(s,i)||((0,et.isLoudDevRuntime)()&&yo(t[i])&&console.warn(`[smbls] custom prop "${i}"${t.key?` on key "${t.key}"`:""} is a function \u2014 it will be auto-invoked on read and its RETURN VALUE stored, not preserved as a callable reference. If you meant to stash a callback, use el.call('${i}', \u2026) instead of reading el.${i}(\u2026) directly (see RULES.md Rule 8).`),r.push({prop:i,fn:t[i]}))}for(let c=0;c<r.length;c++){const{prop:i,fn:a}=r[c];n.__exec[i]=a,Object.defineProperty(t,i,{get(){e&&(0,A.pushConfig)(e);try{return a(t,t.state,t.context)}catch{return}finally{e&&(0,A.popConfig)()}},set(f){delete n.__exec[i],Object.defineProperty(t,i,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function _o(t,n){if(!(!Array.isArray(n)||n.length===0))for(let s=0;s<n.length;s++){const e=n[s];try{typeof e=="function"?e(t,t.state,t.context):typeof e=="string"&&t.state?.[e]}catch{}}}function D(t,n,s){return!Array.isArray(n)||n.length===0?s:function(...e){return _o(t,n),s.apply(this,e)}}function st(t,n){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[n]}function j(t,n){return()=>t.path.join(".")+"::"+n}function $t(t,n){const s=t.__ref,e=!!(n&&n.skipIfEffect);if(ho(t),typeof t.text=="function"){const o=t.text,c=D(t,t.textDeps,o),i=(0,w.createEffect)(()=>{if(!s.contentManaged)try{let a=c(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&typeof a!="object"&&(typeof a=="string"&&a.includes("{{")&&(a=at.replaceLiteralsWithObjectFields.call(t,a,t.state)),rt(t,a))}catch{}},{depth:s.path.length,label:j(s,"text")});s.__effects.push(i),s.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,c=(0,w.createEffect)(()=>{if(s.contentManaged)return;const i=at.replaceLiteralsWithObjectFields.call(t,o,t.state);i!=null&&(t.text=i),t.node&&rt(t,i??"")},{depth:s.path.length,label:j(s,"text")});s.__effects.push(c),s.__exec.text=o}for(const o of Object.keys(t))if(typeof t[o]=="function"&&!N.REGISTRY.has(o)&&!Y(o)&&!s.__exec[o]){if(b.CSS_PROPS_REGISTRY[o]){const c=t[o],i=D(t,t[o+"Deps"],c),a=o;let f;const u=(0,w.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,A.pushConfig)(l);try{const y=i(t,t.state,t.context),h=b.CSS_PROPS_REGISTRY[a](y,t,t.state,t.context),_=a==="show"||a==="hide";if(h&&t.node){const d=xt(h),p=_&&t.node.style.display!=="none";(d===null||d!==f||p)&&(f=d,q(t.node,h))}else if(t.node&&_){f=void 0;const d=s.__explicitDisplay;t.node.style.display=typeof d=="string"?d:""}}finally{l&&(0,A.popConfig)()}},{depth:s.path.length,label:j(s,a)});s.__effects.push(u),s.__exec[o]=c}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const c=t[o],i=D(t,t[o+"Deps"],c),a=o;let f;const u=(0,w.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,A.pushConfig)(l);try{const y=i(t,t.state,t.context);if(t.node)if(y!=null){const h=a+":"+String(y);h!==f&&(f=h,q(t.node,{[a]:y}))}else f=void 0,t.node.style[a]=""}finally{l&&(0,A.popConfig)()}},{depth:s.path.length,label:j(s,a)});s.__effects.push(u),s.__exec[o]=c}}if(typeof t.html=="function"){const o=t.html,c=D(t,t.htmlDeps,o),i=(0,w.createEffect)(()=>{const a=t.context?.designSystem;a&&(0,A.pushConfig)(a);try{const f=c(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{a&&(0,A.popConfig)()}},{depth:s.path.length,label:j(s,"html")});s.__effects.push(i),s.__exec.html=o}if(typeof t.value=="function"){const o=t.value,c=D(t,t.valueDeps,o),i=(0,w.createEffect)(()=>{try{const a=c(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=a==null?"":String(a);if(t.node.value===f)return;const u=typeof document<"u"&&document.activeElement===t.node,l=u&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,y=u&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,u&&l!=null&&y!=null)try{t.node.setSelectionRange(l,y)}catch{}}catch{}},{depth:s.path.length,label:j(s,"value")});s.__effects.push(i),s.__exec.value=o}if(typeof t.style=="function"){const o=t.style,c=D(t,t.styleDeps,o);let i;const a=(0,w.createEffect)(()=>{const f=c(t,t.state,t.context),u=xt(f);(u===null||u!==i)&&(i=u,q(t.node,f))},{depth:s.path.length,label:j(s,"style")});s.__effects.push(a),s.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const c=t.style[o];if(typeof c!="function")continue;const i=D(t,st(t.styleDeps,o),c);let a;const f=(0,w.createEffect)(()=>{try{const u=i(t,t.state,t.context);if(t.node){const l=o+":"+String(u);l!==a&&(a=l,q(t.node,{[o]:u}))}}catch{}},{depth:s.path.length,label:j(s,"style."+o)});s.__effects.push(f)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const c=D(t,st(t.attrDeps,o),t.attr[o]),i=o,a=(0,w.createEffect)(()=>{try{const f=c(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1&&!(0,v.isEnumeratedTrueFalseAttr)(i)?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,(0,v.serializeAttrValue)(i,f)))}catch{}},{depth:s.path.length,label:j(s,"attr."+i)});s.__effects.push(a)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const c=D(t,st(t.ariaDeps,o),t.aria[o]),i="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),a=(0,w.createEffect)(()=>{try{const f=c(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,(0,v.serializeAttrValue)(i,f))}catch{}},{depth:s.path.length,label:j(s,"aria."+o)});s.__effects.push(a)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const c=D(t,st(t.dataDeps,o),t.data[o]),a="data-"+o.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=(0,w.createEffect)(()=>{try{const u=c(t,t.state,t.context);if(!t.node?.setAttribute)return;u==null||u===!1?t.node.removeAttribute(a):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(a,u===!0?"":u)}catch{}},{depth:s.path.length,label:j(s,"data."+o)});s.__effects.push(f)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const o in r){if(typeof r[o]!="function")continue;const c=D(t,st(t.classDeps,o),r[o]),i=(0,w.createEffect)(()=>{try{const a=c(t,t.state,t.context);if(!t.node?.classList)return;typeof a=="string"?t.node.classList.add(a):a?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:s.path.length,label:j(s,"class."+o)});s.__effects.push(i)}!e&&typeof t.if=="function"&&Rt(t,s,t.if);for(const o of Object.keys(t)){if(N.REGISTRY.has(o)||typeof t[o]!="function")continue;const c=o.charCodeAt(0);if(c>=65&&c<=90||Y(o))continue;const i=t[o];s.__exec[o]=i;const a=t.tag||"div";if((0,v.checkAttributeByTagName)(a,o)&&!b.CSS_PROPS_REGISTRY[o]&&!(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const f=(0,v.camelToAttr)(o)||o,u=D(t,t[o+"Deps"],i),l=(0,w.createEffect)(()=>{try{const y=u(t,t.state,t.context);t.node?.setAttribute&&(y==null||y===!1&&!(0,v.isEnumeratedTrueFalseAttr)(f)?t.node.removeAttribute(f):typeof y!="function"&&typeof y!="object"&&(f==="src"&&"src"in t.node?t.node.src=y:t.node.setAttribute(f,(0,v.serializeAttrValue)(f,y))))}catch{}},{depth:s.path.length,label:j(s,o)});s.__effects.push(l)}}if(Ao(t),So(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,c=t.stateDeps;let i=!1,a=[];const f=(0,w.createEffect)(()=>{const u=[];for(let _=0;_<c.length;_++){const d=c[_];try{u[_]=typeof d=="function"?d(t,t.state,t.context):t.state?.[d]}catch{u[_]=void 0}}if(!i){i=!0,a=u;return}let l=u.length!==a.length;for(let _=0;!l&&_<u.length;_++)u[_]!==a[_]&&(l=!0);const y=a;if(a=u,!l)return;const h=t.context?.designSystem;h&&(0,A.pushConfig)(h);try{o(t,t.state,t.context,{prev:y,next:u})}catch(_){if(t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{h&&(0,A.popConfig)()}},{depth:s.path.length,label:j(s,"onStateUpdate")});s.__effects.push(f)}Co(t)}function Mt(t){const n=t.parent,s=n?.node;if(!s||!t.node){Wt(t,t.parent);return}let e=null;const r=Object.keys(n),o=r.indexOf(t.key);for(let c=o+1;c<r.length;c++){const i=n[r[c]];if(i?.node?.parentNode===s){e=i.node;break}}e?s.insertBefore(t.node,e):s.appendChild(t.node)}function Rt(t,n,s){const e=D(t,t.ifDeps,s),r=(0,w.createEffect)(()=>{let o;try{o=e(t,t.state,t.context)}catch(i){if(o=!1,n.__ifError=i,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,i?.message||i)}return}const c=n.__if;if(n.__if=!!o,c&&!n.__if&&t.node)t.node.remove();else if(!c&&n.__if)if(n.__ifInitialized)t.node||(t.node=(0,G.cacheNode)(t)),t.node&&(t.node.ref=t),Mt(t),bt(t);else{if(n.__ifInitialized=!0,t.tag||(t.tag=(0,G.detectTag)(t)),B("Init",t,{}),t.node||(t.node=(0,G.cacheNode)(t)),!t.node)return;if(t.parent?.__ref?.__children&&!t.parent.__ref.__children.includes(t.key)&&t.parent.__ref.__children.push(t.key),t.tag==="fragment"&&!n.__fragmentAnchor){const a=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(a),n.__fragmentAnchor=a}B("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),Ht(t,{}),$t(t,{skipIfEffect:!0}),bt(t),Kt(t),Gt(t,{}),Mt(t),Dt(t,{})}},{depth:n.path.length,label:j(n,"if")});n.__effects.push(r)}function rt(t,n){const s=t.node;if(!s)return;const e=n==null?"":String(n);if(t.tag==="string"){s.nodeValue!==e&&(s.nodeValue=e);return}const r=t.__ref;let o=r?r.__textNode:null;if(o&&o.parentNode!==s&&(o=null),!o){const c=s.firstChild;c&&c.nodeType===3&&(o=c)}o?o.nodeValue!==e&&(o.nodeValue=e):s.firstChild?(o=(s.ownerDocument||t.context?.document||globalThis.document).createTextNode(e),s.insertBefore(o,s.firstChild)):(s.textContent=e,o=s.firstChild&&s.firstChild.nodeType===3?s.firstChild:null),r&&(r.__textNode=o||null)}function bt(t){const{node:n}=t;if(n){if((typeof t.text=="string"&&!t.text.includes("{{")||typeof t.text=="number")&&rt(t,t.text),wo(t),typeof t.html=="string"&&(n.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in n){const s=String(t.value);n.value!==s&&(n.value=s)}if(t.style&&typeof t.style=="object"&&q(n,t.style),t.attr&&typeof t.attr=="object")for(const s in t.attr){const e=t.attr[s];typeof e=="function"||typeof e=="object"||e!=null&&(e===!1&&!(0,v.isEnumeratedTrueFalseAttr)(s)||n.setAttribute&&n.setAttribute(s,(0,v.serializeAttrValue)(s,e)))}if(t.data&&typeof t.data=="object")for(const s in t.data){const e=t.data[s];typeof e=="function"||typeof e=="object"||e==null||e===!1||n.dataset&&(n.dataset[s]=e===!0?"":e)}if(t.classlist||t.class){const s=t.classlist||t.class;if(typeof s=="string")s.split(" ").forEach(e=>e&&n.classList.add(e));else if(typeof s=="object")for(const e in s){const r=typeof s[e]=="function"?s[e](t,t.state,t.context):s[e];r&&n.classList.add(typeof r=="string"?r:e)}}}}function xt(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function q(t,n){if(!t||!n||!t.style)return;let s=null;for(const e in n){const r=n[e];if(r!=null){if(e.charAt(0)==="&"&&typeof r=="object"){s||(s={}),s[e]=r;continue}try{const o=String(r),c=e.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),i=o.trim(),a=/\s*!important\s*$/.test(i),f=i.replace(/\s*!important\s*$/,"");t.style.setProperty(c,f,a?"important":"")}catch{}}}s&&bo(t,s)}let go=0;function bo(t,n){const s=`_ds${go++}`;t.classList.add(s);const e=t.ownerDocument;let r=e.querySelector("style[data-smbls-scoped]");r||(r=e.createElement("style"),r.setAttribute("data-smbls-scoped",""),e.head.appendChild(r));let o="";for(const c in n){const i="."+s,a=c.replace(/&/g,i).split(",").map(u=>{const l=u.trim();return l.includes(i)?l:i+l}).join(", "),f=n[c];if(typeof f=="object"){let u="",l="";for(const y in f){const h=f[y];if(typeof h=="object"){const _=y.includes("&")?a.split(", ").map(p=>y.replace(/&/g,p)).join(", "):a.split(", ").map(p=>`${p} ${y}`).join(", ");let d="";for(const p in h)d+=`${p.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${h[p]};`;l+=(0,V.wrapHoverRule)(`${_} { ${d} }`,_)+`
|
|
5
|
+
`}else u+=`${y.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${h};`}u&&(o+=(0,V.wrapHoverRule)(`${a} { ${u} }`,a)+`
|
|
6
|
+
`),l&&(o+=l)}}o&&(r.textContent+=o)}const Nt=new Set;function Ft(t){if(!Array.isArray(t))return"";const n=[];for(let s=0;s<t.length;s++)typeof t[s]=="string"&&t[s].length&&n.push(t[s]);return n.sort(),n.join("|")}function xo(t,n,s){const e=Ft(s);queueMicrotask(()=>{if(!t.__ref)return;let r;try{r=n(t,t.state,t.context)}catch{return}if(Ft(r)===e)return;const o=t.__ref.path?t.__ref.path.join("."):t.key||"?";Nt.has(o)||(Nt.add(o),console.warn(`[smbls] subscribeTo function at "${o}" resolved to a DIFFERENT key list one microtask after create \u2014 wired [${s.join(", ")||"(none)"}], probed [${Array.isArray(r)?r.join(", "):String(r)}]. subscribeTo's function form is resolved ONCE at element-create time (registerSubscribeToEffects, @symbo.ls/element create.js) \u2014 this element stays wired to the ORIGINAL list for its whole lifetime, so this drift is invisible to the reactive effect and any key only present in the new list will never trigger onUpdate. If the watched key genuinely is not known until later (e.g. a module config that loads after shell boot), route the write through an imperative call instead of subscribeTo \u2014 see functions/moduleOpenBridge.js's moduleOpenPage (workspace repo) for the house pattern.`))})}function Ao(t){const n=t.subscribeTo,s=typeof n=="function";let e=n;if(s)try{e=n(t,t.state,t.context)}catch{e=null}if(s&&(0,et.isLoudDevRuntime)()&&xo(t,n,Array.isArray(e)?e:[]),!Array.isArray(e)||e.length===0)return;const r=t.__ref;for(let o=0;o<e.length;o++){const c=e[o];if(typeof c!="string"||c.length===0)continue;const i=c.split("."),a=i[0],f=i.slice(1),u={value:!1},l=(0,w.createEffect)(()=>{const y=t.state&&((0,L.isStore)(t.state)?t.state.root:null);if(!y||!(0,L.isStore)(y))return;let h=y;h=h[a];for(let d=0;d<f.length&&!(h==null||typeof h!="object");d++)if((0,L.isStore)(h))h=h[f[d]];else break;if(!u.value)return;let _=!1;if(typeof t.onBeforeUpdate=="function"){const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{if(qt(r)){const p=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});p&&typeof p.then=="function"?p.then(()=>it(r,!1),g=>{it(r,!0),t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:g})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",g)}):(it(r,!1),p===!1&&(_=!0))}}catch(p){it(r,!0),t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:p})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",p)}finally{d&&(0,A.popConfig)()}}if(!_&&t.node&&r.__effects)for(let d=0;d<r.__effects.length;d++){const p=r.__effects[d];p&&p!==l&&!p._disposed&&!p._isSubscribeToEffect&&typeof p._execute=="function"&&p._execute()}if(!_&&typeof t.onUpdate=="function"){const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{t.onUpdate(t,t.state,t.context)}catch(p){t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onUpdate",error:p})||console.error("[DOMQL] subscribeTo onUpdate error:",p)}finally{d&&(0,A.popConfig)()}}},{depth:r.path.length,label:j(r,"subscribeTo("+c+")")});u.value=!0,l._isSubscribeToEffect=!0,r.__effects.push(l)}}function At(t,n){return t.charCodeAt(0)===64&&t.length>1&&!t.startsWith("@media")&&!t.startsWith("@keyframes")&&!t.startsWith("@supports")&&(t==="@dark"||t==="@light"||!n.context?.designSystem?.media?.[t.slice(1)])}const Ut=new Set;function ko(t,n){const s=n?.__ref?.path?n.__ref.path.join("."):n?.key||"?",e=s+"::"+t;Ut.has(e)||(Ut.add(e),console.warn(`[smbls/css] "${t}" at ${s} is a CHILD-COMPONENT key nested inside a pseudo/selector block (":hover", "@dark", etc.) \u2014 that is never a valid CSS selector fragment. The rule is DROPPED (not shipped as a dead/never-matching selector). To reveal a child on a parent state, target the child's OWN class from the parent selector instead, e.g. move the declaration onto the child element itself, or use a sibling-selector combinator in a top-level style block.`))}function Q(t,n,s){const e={},r=new Set,o=(c,i,a)=>{const f=a?new Set(Object.keys(e)):null;if(b.CSS_PROPS_REGISTRY[c]){const u=b.CSS_PROPS_REGISTRY[c](i,n,n.state,n.context);if(u){const l=Array.isArray(u)?u:[u];for(const y of l)y&&Object.assign(e,y)}}else e[c]=i;if(a)for(const u in e)f.has(u)||r.add(u)};for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;let i=t[c];if(typeof i=="function"&&(i=i(n,n.state,n.context)),i==null||typeof i=="function")continue;if(typeof i=="object"&&!Array.isArray(i)){if(c==="style"){for(const l in i){let y=i[l];if(typeof y=="function"&&(y=y(n,n.state,n.context)),y==null||typeof y=="function")continue;const h=typeof n[l]=="function"&&(b.CSS_PROPS_REGISTRY[l]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(l));o(l,y,h)}continue}if(At(c,n)){const l=Q(i,n,!1);Object.keys(l).length&&(e[`[data-theme="${c.slice(1)}"] &`]=l);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(c)){(0,et.isLoudDevRuntime)()&&ko(c,n);continue}let f=c;if(c.charCodeAt(0)===64&&!c.startsWith("@media")&&!c.startsWith("@keyframes")){const l=n.context?.designSystem?.media?.[c.slice(1)];l&&(f=`@media ${l}`)}const u=Q(i,n,!1);Object.keys(u).length&&(e[f]=u);continue}const a=typeof n[c]=="function"&&(b.CSS_PROPS_REGISTRY[c]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(c));o(c,i,a)}if(s)for(const c in e)r.add(c);for(const c of r){const i=e[c];typeof i=="string"&&!i.includes("!important")&&(e[c]=i+" !important")}return e}function kt(t,n){if(n===void 0&&(n=0),n>8)return!1;if(typeof t=="function")return!0;if(t&&typeof t=="object"&&!Array.isArray(t)){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&kt(t[s],n+1))return!0}return!1}function It(t,n,s){if(!n||typeof n!="object"||Array.isArray(n))return null;if(At(t,s)){const o=Q(n,s,!1);return Object.keys(o).length?{cssProp:`[data-theme="${t.slice(1)}"] &`,block:o}:null}let e=t;if(t.charAt(0)==="@"&&!t.startsWith("@media")&&!t.startsWith("@keyframes")){const o=s.context?.designSystem?.media?.[t.slice(1)];o&&(e=`@media ${o}`)}const r=Q(n,s,!1);return Object.keys(r).length?{cssProp:e,block:r}:null}function Co(t){const n=t.__ref;for(const s of Object.keys(t)){if(!_t(s))continue;const e=t[s];if(!e||typeof e!="object"||Array.isArray(e)||!kt(e))continue;let r=null,o;const c=(0,w.createEffect)(()=>{if(!t.node)return;const i=t.context?.designSystem;i&&(0,A.pushConfig)(i);let a,f=!1;try{const u=It(s,e,t),l=u?xt(u.block)+"::"+u.cssProp:null;if(l!==null&&l===o)f=!0;else if(o=l,u){const y=(0,V.css)({[u.cssProp]:u.block},null,t.context?.cssPrefix);a=y?y.split(" ").filter(Boolean):null}else a=null}finally{i&&(0,A.popConfig)()}if(!(f||!t.node.classList)){if(r)for(const u of r)t.node.classList.remove(u);if(a&&a.length)for(const u of a)t.node.classList.add(u);r=a}},{depth:n.path.length,label:j(n,"cssBlock("+s+")")});n.__effects.push(c)}}function So(t){const n=t.__ref;n.__conditionalRunners=[];const s=new Map;for(const e of Object.keys(t)){const r=e.charAt(0);if(r!=="."&&r!=="!")continue;const o=e.slice(1);if(!o)continue;if(/[:@\s>~+[\]]/.test(o)){if(typeof console<"u"&&console.warn){const l=o.split(/[:@\s>~+[\]]/)[0];console.warn(`[smbls] conditional \`${e}\` on ${t.key||"?"} will never match \u2014 the whole string after \`${r}\` is read as one prop name. Nest the selector inside instead: \`${r}${l}: { '${o.slice(l.length)}': {...} }\`.`)}continue}const c=t[e];if(!c||typeof c!="object")continue;const i=r==="!",a={lastMatch:!1,appliedKeys:null,appliedClasses:null},f=()=>{let l;const y=t[o];if(y===void 0){const d=!!t.state&&o in t.state,p=t.state?t.state[o]:void 0;if(d||p!==void 0)l=p;else{const g=t.context?.cases?.[o];if(g===void 0)return;try{l=typeof g=="function"?g.call(t,t):g}catch(k){l=!1,n.__conditionalError=k,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${e}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,k?.message||k)}}}else if(typeof y=="function")try{l=y(t,t.state,t.context)}catch(d){l=!1,n.__conditionalError=d,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${e}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,d?.message||d)}else l=y;const h=i?!l:!!l;if(!t.node||h===a.lastMatch)return;a.lastMatch=h;const _=t.context?.designSystem;_&&(0,A.pushConfig)(_);try{if(h){const d={},p={};let g=!1;for(const x in c){if(!Object.prototype.hasOwnProperty.call(c,x))continue;const P=c[x],E=x.charAt(0);if((E===":"||E==="@"||E==="&")&&P&&typeof P=="object"&&!Array.isArray(P)){if(At(x,t)){const $=Q(P,t,!1);Object.keys($).length&&(p[`[data-theme="${x.slice(1)}"] &`]=$,g=!0)}else{let $=x;if(E==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const H=t.context?.designSystem?.media?.[x.slice(1)];H&&($=`@media ${H}`)}const W=Q(P,t,!1);Object.keys(W).length&&(p[$]=W,g=!0)}continue}const T=typeof P=="function"?P(t,t.state,t.context):P;if(T!=null)if(b.CSS_PROPS_REGISTRY[x]){const $=b.CSS_PROPS_REGISTRY[x](T,t,t.state,t.context);if($){const W=Array.isArray($)?$:[$];for(const H of W)H&&Object.assign(d,H)}}else b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(d[x]=T)}const k=Object.keys(d);if(k.length){q(t.node,d);for(const x of k)s.set(x,e);a.appliedKeys=k}else a.appliedKeys=null;if(g){const x=(0,V.css)(p,null,t.context?.cssPrefix),P=x?x.split(" ").filter(Boolean):[];if(P.length&&t.node.classList){for(const E of P)t.node.classList.add(E);a.appliedClasses=P}else a.appliedClasses=null}else if(a.appliedClasses){for(const x of a.appliedClasses)t.node.classList.remove(x);a.appliedClasses=null}}else{if(a.appliedKeys){for(const d of a.appliedKeys)s.get(d)===e&&(t.node.style[d]="",s.delete(d));a.appliedKeys=null}if(a.appliedClasses){for(const d of a.appliedClasses)t.node.classList.remove(d);a.appliedClasses=null}}}finally{_&&(0,A.popConfig)()}};n.__conditionalRunners.push(f);const u=(0,w.createEffect)(f,{depth:n.path.length,label:j(n,"conditional("+e+")")});n.__effects.push(u)}}const Ct=new WeakSet;function vo(t){const n=t.ownerDocument;!n||Ct.has(n)||(Ct.add(n),queueMicrotask(()=>{Ct.delete(n);const s=n.body||n.documentElement;s&&s.offsetWidth}))}const St=new WeakSet;let Bt=!1;function wo(t){const{node:n}=t;if(!n)return;if(Bt||(Bt=!0,(0,V.css)({display:"none"})),St.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}St.add(t);const s=t.context?.designSystem;s&&(0,A.pushConfig)(s),(0,b.pushStaticCssPass)();try{const e={};let r=!1;if(Object.prototype.hasOwnProperty.call(t,"theme")&&typeof t.theme!="function"&&b.CSS_PROPS_REGISTRY.theme){const o=b.CSS_PROPS_REGISTRY.theme(t.theme,t,t.state,t.context);if(o){if(Array.isArray(o))for(const c of o)c&&Object.assign(e,c);else Object.assign(e,o);r=!0}}for(const o of Object.keys(t)){if(typeof t[o]=="function"||N.REGISTRY.has(o)||o==="theme")continue;const c=o.charCodeAt(0);if(!(c>=65&&c<=90)&&!Y(o)){if(b.CSS_PROPS_REGISTRY[o]){const i=t[o],a=b.CSS_PROPS_REGISTRY[o](i,t,t.state,t.context);if(a){if(Array.isArray(a))for(const f of a)f&&Object.assign(e,f);else Object.assign(e,a);r=!0}}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const i=t[o];i!=null&&typeof i!="object"&&(e[o]=i,r=!0)}else if(o.charCodeAt(0)===45){const i=t[o];i!=null&&typeof i!="object"&&(e[o]=i,r=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const i=t[o];if(i&&typeof i=="object"&&!Array.isArray(i)){if(kt(i))continue;const a=It(o,i,t);a&&(e[a.cssProp]=a.block,r=!0)}}}}if(r){e.display&&String(e.display).includes("!important")&&(n.style.setProperty("display",String(e.display).replace(/\s*!important\s*$/,""),"important"),delete e.display);const o=(0,V.css)(e,null,t.context?.cssPrefix);if(o&&n.classList){const i=o.split(" ").filter(Boolean);let a=!1;for(const f of i)n.classList.add(f),a||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(a=!0);a&&vo(n)}const c=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(c!=null){const i=e.display;if(i&&i!==c)if(c==="none"){const a=[];for(const f of n.classList)f.startsWith("_d-")&&f!=="_d-none"&&a.push(f);for(const f of a)n.classList.remove(f);n.classList.add("_d-none")}else n.style.display==="none"&&(typeof t.hide=="function"||typeof t.show=="function")||(n.style.display=t.display),t.__ref&&(t.__ref.__explicitDisplay=t.display)}}}finally{(0,b.popStaticCssPass)(),s&&(0,A.popConfig)(),St.delete(t)}}function Kt(t){const{node:n}=t;if(!n||!n.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const r in t.aria){const o=t.aria[r];if(typeof o=="function"||typeof o=="object"||o==null)continue;const c="aria-"+r.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());n.setAttribute(c,(0,v.serializeAttrValue)(c,o))}const s=(0,v.applyAttrTransforms)(t);for(const r in s){const o=s[r];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&n.setAttribute(r,o===!0?"":o)}const e=t.tag||"div";for(const r of Object.keys(t)){if(typeof t[r]=="function"||N.REGISTRY.has(r)||r==="on"||s[r]!==void 0)continue;const o=r.charCodeAt(0);if(!(o>=65&&o<=90)&&!Y(r)&&!(b.CSS_PROPS_REGISTRY[r]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(r))&&(0,v.checkAttributeByTagName)(e,r)){let c=t[r];if(c==null||(typeof c=="string"&&c.includes("{{")&&(c=(0,at.replaceLiteralsWithObjectFields)(c,t,t.state,t.context),t[r]=c),c==null||typeof c=="function"||typeof c=="object")||c===!1&&!(0,v.isEnumeratedTrueFalseAttr)((0,v.camelToAttr)(r)||r))continue;const i=(0,v.camelToAttr)(r)||r;n.setAttribute(i,(0,v.serializeAttrValue)(i,c))}}}function jo(t,n){const s=t.node,e=t.__ref;let r=e.__autoGrow;if(!n){if(r&&r.active){try{s.removeEventListener("input",r.resize)}catch{}s.style.height="",r.appliedMax!=null&&s.style.maxHeight===r.appliedMax&&(s.style.maxHeight=""),r.active=!1,r.appliedMax=null,r.lastMeasure=0}return}r||(r=e.__autoGrow={active:!1,appliedMax:null,lastMeasure:0,resize:()=>{if(s.scrollHeight===0&&r.lastMeasure>0)return;s.style.height="auto";const c=s.scrollHeight;s.style.height=c+"px",c>0&&(r.lastMeasure=c)}},e.__eventCleanup||(e.__eventCleanup=[]),e.__eventCleanup.push(()=>{try{s.removeEventListener("input",r.resize)}catch{}})),r.active||(s.addEventListener("input",r.resize),r.active=!0);const o=typeof n=="object"&&n.max!=null?String(n.max):null;o!==r.appliedMax&&(o==null?r.appliedMax!=null&&s.style.maxHeight===r.appliedMax&&(s.style.maxHeight=""):s.style.maxHeight=o,r.appliedMax=o),r.resize()}function Eo(t){if(!t.autoGrow)return;const n=t.node;if(!n||n.tagName!=="TEXTAREA")return;const s=t.__ref,e=t.autoGrow,r=typeof e=="function"?D(t,t.autoGrowDeps,e):null,o=(0,w.createEffect)(()=>{const c=t.autoGrow;let i=c;if(typeof c=="function")try{i=(c===e&&r?r:c)(t,t.state,t.context)}catch{i=null}jo(t,i)},{depth:s.path.length,label:j(s,"autoGrow")});s.__effects||(s.__effects=[]),s.__effects.push(o),r&&(s.__exec.autoGrow=e)}const Vt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Ht(t,n){for(const s of Object.keys(t)){if(!Y(s)||Vt.has(s))continue;const e=(0,X.globalEventKeyInfo)(s);if(e){(0,X.registerGlobalEvent)(e,t,t[s]);continue}let r=t[s];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const c=r;r=function(a){return t.call(c,a)}}if(typeof r!="function")continue;const o=ao(s);N.LIFECYCLE_EVENTS.has(o)||(0,X.registerEvent)(fo(o),t,r)}To(t)}function To(t){const n=t.node;if(!n||!n.addEventListener)return;const s={};let e=!1;for(const y of Vt){const h=t[y];typeof h=="function"&&(s[y]=h,e=!0)}if(!e)return;const r=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let c=0,i=0,a=0,f=!1;const u=y=>{const h=y.touches&&y.touches[0]||y.changedTouches&&y.changedTouches[0];h&&(c=h.clientX,i=h.clientY,a=Date.now(),f=!0)},l=y=>{if(!f)return;f=!1;const h=y.changedTouches&&y.changedTouches[0]||y.touches&&y.touches[0];if(!h)return;const _=h.clientX-c,d=h.clientY-i,p=Date.now()-a;if(p>o)return;const g=Math.abs(_),k=Math.abs(d);if(Math.max(g,k)<r)return;let x;if(g>k*1.2)x=_<0?"left":"right";else if(k>g*1.2)x=d<0?"up":"down";else return;const P="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),E=s[P],T=s.onSwipe;E&&E.call(t,y,t,t.state,t.context),T&&T.call(t,{direction:x,dx:_,dy:d,dt:p,event:y},t,t.state,t.context)};n.addEventListener("touchstart",u,{passive:!0}),n.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{n.removeEventListener("touchstart",u)}catch{}try{n.removeEventListener("touchend",l)}catch{}})}function nt(t,n){const s={...t};for(const e in n){const r=s[e],o=n[e];r&&o&&typeof r=="object"&&typeof o=="object"&&!Array.isArray(r)&&!Array.isArray(o)&&typeof r!="function"&&typeof o!="function"?s[e]=nt(r,o):s[e]=o}return s}function vt(t,n,s){if(!n||!t.node)return;const e=t.childExtends;if(Array.isArray(n)){const r=t.tag==="fragment",o=t.context?.document||globalThis.document,c=r?null:o?.createDocumentFragment();if(!r&&!c)return;const i=t.childProps,a=t.childrenAs;for(let f=0;f<n.length;f++){let u=n[f];const l=u;(typeof u=="string"||typeof u=="number")&&(u={text:u});let y=i;if(typeof i=="function")try{y=i(t,u)}catch{y=null}if(a==="state"){let d=l;(typeof l=="string"||typeof l=="number")&&(d={value:l,text:l}),u=y?{...y,state:d}:{state:d}}else y&&(u=nt(y,u));if(e&&!u.ignoreChildExtends)if(u.extends){const d=Array.isArray(u.extends)?u.extends:[u.extends],p=Array.isArray(e)?e:[e];u={...u,extends:[...p,...d]}}else u={...u,extends:e};const h=u?.key||l&&typeof l=="object"&&l.key||`${f}`;let _;try{_=K(u,t,h,s)}catch(d){if(typeof console<"u"&&console.error){const p=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${h}" failed to construct at ${p} (initial render, skipping this row):`,d?.message||d)}continue}!r&&_?.node&&c.appendChild(_.node)}return r||t.node.appendChild(c),!0}if(typeof n=="string"){const r=Ot(n,t);if(Array.isArray(r))return vt(t,r,s)}if(typeof n=="object")for(const r in n){if(N.REGISTRY.has(r))continue;let o=n[r];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=nt(t.childProps,o)),e&&!o.ignoreChildExtends)if(o.extends){const c=Array.isArray(o.extends)?o.extends:[o.extends],i=Array.isArray(e)?e:[e];o={...o,extends:[...i,...c]}}else o={...o,extends:e};K(o,t,r,s)}}}function wt(t,n){const s=t.node;if(!s||s.tagName!=="SELECT")return;const e=s.options;if(!e||!e.length)return;const r=t.__ref,o=r&&r.__exec&&r.__exec.value,c=typeof o=="function",i=t.value!=null&&typeof t.value!="function";if(c||i){let u;if(c)try{u=o(t,t.state,t.context)}catch{return}else u=t.value;const l=u==null?"":String(u);s.value!==l&&(s.value=l);return}const a=n||!(r&&r.__selectSynced);if(r&&(r.__selectSynced=!0),!a)return;let f=-1;for(let u=0;u<e.length;u++)e[u].defaultSelected&&(f=u);f>=0&&s.selectedIndex!==f&&(s.selectedIndex=f)}function Gt(t,n){let{children:s,content:e}=t;const r=t.childExtends;if(typeof s=="function"){const i=s;try{s=i(t,t.state,t.context)}catch(y){if(s=void 0,typeof console<"u"&&console.error){const h=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${h} (initial run, treating as empty):`,y?.message||y)}}t.children=s;const a=t.__ref;let f=!1;const u=D(t,t.childrenDeps,i),l=(0,w.createEffect)(()=>{const y=f;f=!0;let h;try{h=u(t,t.state,t.context)}catch(E){if(typeof console<"u"&&console.error){const T=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${T}${y?"":" (initial tracking run)"}:`,E?.message||E)}return}if(!y||h===t.children)return;t.children=h;const _=typeof t.onContentUpdate=="function",d=_?[]:null,p=_?[]:null,g=_?[]:null;if(Array.isArray(h)&&t.childrenAs==="state"){const E=t.childProps,T=[],$=new Map;for(let C=0;C<h.length;C++){const M=h[C];let S=E;if(typeof E=="function")try{S=E(t,M)}catch{S=null}const I=S&&S.key||M&&M.key||`${C}`;T.push(I),$.set(I,{rawChild:M,childProps:S})}const W=new Set(T),H=a.__children.slice();for(const C of H)if(!W.has(C)){const M=t[C];M?.remove&&M.remove(),delete t[C],p&&p.push(C)}const J=t.childExtends,ct=t.tag==="fragment",Qt=t.context?.document||globalThis.document,m=ct?null:Qt?.createDocumentFragment(),dt=new Set;for(const C of T){const M=$.get(C),S=M.rawChild,I=t[C];if(I&&I.state){if(S&&typeof S=="object"){const O=I.state,z=O.$replace||O.replace,Et=O.$update||O.update;try{if(typeof z=="function")z.call(O,S);else if(typeof Et=="function"){for(const R in O)if(!(R==="__element"||R==="root"||R==="parent"||R==="update")&&!Object.prototype.hasOwnProperty.call(S,R))try{O[R]=void 0}catch{}Et.call(O,S)}else for(const R in S)O[R]=S[R]}catch(R){if(typeof console<"u"&&console.error){const Zt=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${C}" failed to patch at ${Zt} (reconcile, keeping its previous data for this pass):`,R?.message||R)}}}g&&g.push(C);continue}let lt=S;(typeof S=="string"||typeof S=="number")&&(lt={value:S,text:S});const jt=M.childProps;let F=jt?{...jt,state:lt}:{state:lt};if(J&&!F.ignoreChildExtends)if(F.extends){const O=Array.isArray(F.extends)?F.extends:[F.extends],z=Array.isArray(J)?J:[J];F={...F,extends:[...z,...O]}}else F={...F,extends:J};let pt;try{pt=K(F,t,C,n)}catch(O){if(typeof console<"u"&&console.error){const z=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${C}" failed to construct at ${z} (reconcile, skipping this row):`,O?.message||O)}dt.add(C);continue}!ct&&pt?.node&&m&&m.appendChild(pt.node),d&&d.push(C)}if(!ct&&m&&m.childNodes.length&&t.node&&t.node.appendChild(m),!ct&&t.node){let C=null;for(const M of T){const S=t[M]?.node;if(!S)continue;const I=C?C.nextSibling:t.node.firstChild;S!==I&&t.node.insertBefore(S,I),C=S}}a.__children=dt.size?T.filter(C=>!dt.has(C)):T,_&&(d.length||p.length)&&Lt(t,{added:d,removed:p,kept:g}),wt(t,!1);return}const P=_?[...a.__children]:null;for(const E of[...a.__children]){const T=t[E];T?.remove&&T.remove(),delete t[E]}a.__children=[],vt(t,h,n),wt(t,!1),_&&Lt(t,{added:[...a.__children],removed:P,kept:[]})},{depth:a.path.length,label:j(a,"children")});a.__effects.push(l)}const o=vt(t,s,n);if(e!=null&&!(e&&e.__ref)){let i=e;if(typeof i=="string"||typeof i=="number"?i={text:i}:typeof i!="object"&&(i={}),t.childProps&&(i=nt(t.childProps,i)),r&&!i.ignoreChildExtends)if(i.extends){const a=Array.isArray(i.extends)?i.extends:[i.extends],f=Array.isArray(r)?r:[r];i={...i,extends:[...f,...a]}}else i={...i,extends:r};K(i,t,"content",n)}if(s&&!o)return;const c=t.context?.components||{};{const i=Object.keys(t);for(let a=0;a<i.length;a++){const f=i[a];if(!f.endsWith("Extends")||typeof t[f]!="string")continue;const u=f.slice(0,-7);if(!u||u.charCodeAt(0)<65||u.charCodeAt(0)>90)continue;const l={extends:t[f]};delete t[f];for(let y=a+1;y<i.length;y++){const h=i[y],_=h.charCodeAt(0);if(_>=65&&_<=90||N.REGISTRY.has(h)||typeof t[h]=="function"&&(h.startsWith("on")||h.startsWith(".")))break;const d=t[h];d!==void 0&&(l[h]=d,delete t[h])}t[u]&&typeof t[u]=="object"?t[u]={...l,...t[u]}:t[u]=l}}for(const i of Object.keys(t)){if(N.REGISTRY.has(i)||typeof t[i]!="object"||t[i]===null)continue;const a=i.charCodeAt(0);if(a<65||a>90)continue;let f=t[i];if(!f.__ref){if(!f.extends&&!f.extend){const u=c[i]||c[`smbls.${i}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=nt(t.childProps,f)),r&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],l=Array.isArray(r)?r:[r];f={...f,extends:[...l,...u]}}else f={...f,extends:r};K(f,t,i,n)}}}function Wt(t,n,s){const{node:e}=t;if(!e)return;e.ref=t;const r=n?.tag==="fragment"?n.__ref?.__fragmentAnchor:null;if(r){const c=r.parentNode;if(c){if(s?.position==="before"&&s.node)c.insertBefore(e,s.node);else if(s?.position==="after"&&s.node){const i=s.node.nextSibling;c.insertBefore(e,i||r)}else c.insertBefore(e,r);return}}const o=n?.node||(n?.nodeType?n:null);if(o)if(s?.position==="before"&&s.node)o.insertBefore(e,s.node);else if(s?.position==="after"&&s.node){const c=s.node.nextSibling;c?o.insertBefore(e,c):o.appendChild(e)}else o.appendChild(e)}const ut=3;function qt(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=ut?!1:(t.__inBeforeUpdate=!0,!0)}function it(t,n){t&&(t.__inBeforeUpdate=!1,n?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===ut&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${ut}x in a row on this element \u2014 pausing automatic retries until a future prop/state change re-arms it.`)):t.__beforeUpdateFailCount=0)}function B(t,n,s){const e=t.charAt(0).toLowerCase()+t.slice(1);n.context?.plugins?.length&&(0,U.runPluginHook)(e,n,s);const r="on"+t,o=n[r];if(typeof o=="function"){const a=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(a){if(n.__ref[a])return!0;n.__ref[a]=!0}const f=n.context?.designSystem;f&&(0,A.pushConfig)(f);let u=!!a;try{const l=o(n,n.state,n.context,s);if(l&&typeof l.then=="function"){const y=n.__ref;return l.catch(h=>{n.context?.plugins?.length&&(0,U.runPluginHook)("error",n,{hook:r,error:h})||console.error(`[DOMQL] Lifecycle "${r}" error:`,h)}).finally(()=>{a&&y&&(y[a]=!1)}),u=!1,!0}if(l===!1)return!1}catch(l){if(n.context?.plugins?.length&&(0,U.runPluginHook)("error",n,{hook:r,error:l})||console.error(`[DOMQL] Lifecycle "${r}" error:`,l),n.context?.strictMode)throw l}finally{f&&(0,A.popConfig)(),u&&n.__ref&&(n.__ref[a]=!1)}}return!0}var Po=K;
|
package/dist/cjs/src/delegate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},T=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!S.call(t,o)&&o!==r&&d(t,o,{get:()=>e[o],enumerable:!(n=D(e,o))||n.enumerable});return t};var I=t=>T(d({},"__esModule",{value:!0}),t);var F={};y(F,{addDelegatedEvent:()=>b,globalEventKeyInfo:()=>V,isDelegatable:()=>g,registerEvent:()=>M,registerGlobalEvent:()=>W,removeDelegatedEvent:()=>L});module.exports=I(F);var l=require("./registry.js"),f=require("@symbo.ls/scratch");const p=new WeakMap,x={passive:!0},A={passive:!0,capture:!0},E=(t,e)=>l.PASSIVE_EVENTS.has(t)?e?A:x:e||!1;function h(t){let e=p.get(t);return e||(e={handlers:new Map,installed:new Set},p.set(t,e)),e}function B(t,e){const r=h(e);if(r.installed.has(t))return;r.installed.add(t);const n=t==="focus"||t==="blur"||t==="focusin"||t==="focusout"||t==="mouseenter"||t==="mouseleave",o=t==="mouseenter"||t==="mouseleave";e.addEventListener(t,s=>{let c=s.target;for(;c&&c!==e;){const i=r.handlers.get(t);if(i){const u=i.get(c);if(u){if(o&&s.relatedTarget&&c.contains(s.relatedTarget)){c=c.parentNode;continue}if(u(s),s.cancelBubble)return}}c=c.parentNode}},E(t,n))}function b(t,e,r,n){n||(n=e.ownerDocument?.documentElement||e.getRootNode());const o=h(n);B(t,n),o.handlers.has(t)||o.handlers.set(t,new WeakMap),o.handlers.get(t).set(e,r)}function L(t,e,r){r||(r=e.ownerDocument?.documentElement||e.getRootNode());const n=p.get(r);if(!n)return;const o=n.handlers.get(t);o&&o.delete(e)}function g(t){return l.DELEGATED_EVENTS.has(t)&&!l.LIFECYCLE_EVENTS.has(t)}function w(t,e){const{context:r}=t,n=r?.designSystem;return o=>{n&&(0,f.pushConfig)(n);try{const s=e.call(t,o,t,t.state,r);if(s&&typeof s.then=="function"){s.catch(c=>{t.error=c,console.error("[DOMQL] Async event error:",c)}).finally(()=>{n&&(0,f.popConfig)()});return}}catch(s){if(t.error=s,console.error("[DOMQL] Event error:",s),r?.strictMode)throw s}n&&(0,f.popConfig)()}}function M(t,e,r){const{node:n,context:o}=e;if(!n)return;const s=w(e,r),c=l.NON_BUBBLING_EVENTS.has(t);if(!c&&g(t)){const i=o?.rootNode||n.ownerDocument?.documentElement;b(t,n,s,i)}else n.addEventListener(t,s,E(t,!1));e.__ref.__eventCleanup||(e.__ref.__eventCleanup=[]),e.__ref.__eventCleanup.push(()=>{if(!c&&g(t)){const i=o?.rootNode||n.ownerDocument?.documentElement;L(t,n,i)}else n.removeEventListener(t,s,E(t,!1))})}const _=[["onDocument","document"],["onWindow","window"]];function V(t){if(typeof t!="string")return null;for(let e=0;e<_.length;e++){const r=_[e][0];if(t.length<=r.length||!t.startsWith(r))continue;const n=t.charCodeAt(r.length);if(!(n<65||n>90))return{target:_[e][1],eventName:t.slice(r.length).toLowerCase()}}return null}const R=/^[A-Za-z_$][\w$]*$/;function G(t,e,r){let n=e,o=!1,s,c=!1;if(e&&typeof e=="object"&&typeof e!="function"&&(n=e.handler,o=!!e.capture,c=!!e.once,typeof e.passive=="boolean"&&(s=e.passive)),typeof n=="string"&&R.test(n)){const i=n;n=function(a){return t.call(i,a)}}return typeof n!="function"?null:(s===void 0&&(s=l.PASSIVE_EVENTS.has(r)),{handler:n,capture:o,passive:s,once:c})}function O(t,e){const r=t.node?.ownerDocument||t.context?.document||(typeof document<"u"?document:null);if(!r||typeof r.addEventListener!="function")return null;if(e==="document")return r;const n=r.defaultView||(typeof window<"u"?window:null);return n&&typeof n.addEventListener=="function"?n:null}function P(t){const e=t.node;if(!e)return!1;const r=e.nodeType===11?t.__ref?.__fragmentAnchor:e;return r?r.isConnected!==!1:!1}function W(t,e,r){const n=e.__ref;if(!n)return;const o=G(e,r,t.eventName);if(!o)return;const s=O(e,t.target);if(!s)return;n.__globalEvents||(n.__globalEvents=new Map);const c=t.target+":"+t.eventName+":"+(o.capture?1:0);if(n.__globalEvents.has(c))return;const i=w(e,o.handler),u=v=>{P(e)&&i(v)},a={capture:o.capture,passive:o.passive,once:o.once};s.addEventListener(t.eventName,u,a),n.__globalEvents.set(c,{target:s,eventName:t.eventName,listener:u,options:a}),n.__eventCleanup||(n.__eventCleanup=[]),n.__eventCleanup.push(()=>{s.removeEventListener(t.eventName,u,a),n.__globalEvents&&n.__globalEvents.delete(c)})}
|
package/dist/cjs/src/dispose.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var t in o)n(r,t,{get:o[t],enumerable:!0})},h=(r,o,t,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let _ of s(o))!a.call(r,_)&&_!==t&&n(r,_,{get:()=>o[_],enumerable:!(f=c(o,_))||f.enumerable});return r};var p=r=>h(n({},"__esModule",{value:!0}),r);var v={};d(v,{dispose:()=>i,remove:()=>u});module.exports=p(v);function i(r){if(!r)return;const o=r.__ref;if(!o)return;try{typeof r.onBeforeRemove=="function"&&r.onBeforeRemove(r,r.state,r.context)}catch(f){console.error("[smbls] onBeforeRemove error:",f)}if(o.__effects){for(let f=0;f<o.__effects.length;f++)o.__effects[f].dispose();o.__effects.length=0}if(o.__eventCleanup){for(let f=0;f<o.__eventCleanup.length;f++)o.__eventCleanup[f]();o.__eventCleanup.length=0}if(o.__children){const f=o.__children.slice();o.__children.length=0;for(let _=0;_<f.length;_++){const e=r[f[_]];e&&e.__ref&&i(e)}}r.node?.parentNode?r.node.remove():r.tag==="fragment"&&o.__fragmentAnchor?.parentNode&&o.__fragmentAnchor.remove();const t=r.state?.$destroy||r.state?.destroy;if(typeof t=="function"&&r.state.__element===r&&t.call(r.state),r.parent?.__ref?.__children){const f=r.parent.__ref.__children.indexOf(r.key);f!==-1&&r.parent.__ref.__children.splice(f,1),delete r.parent[r.key]}try{typeof r.onRemove=="function"&&r.onRemove(r)}catch(f){console.error("[smbls] onRemove error:",f)}r.node=null,r.parent=null,r.__ref=null}function u(){i(this)}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.create;var p=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var a in t)p(e,a,{get:t[a],enumerable:!0})},x=(e,t,a,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of v(t))!i.call(e,f)&&f!==a&&p(e,f,{get:()=>t[f],enumerable:!(m=N(t,f))||m.enumerable});return e};var I=(e,t,a)=>(a=e!=null?n(S(e)):{},x(t||!e||!e.__esModule?p(a,"default",{value:e,enumerable:!0}):a,e)),c=e=>x(p({},"__esModule",{value:!0}),e);var L={};G(L,{DELEGATED_EVENTS:()=>r.DELEGATED_EVENTS,LIFECYCLE_EVENTS:()=>r.LIFECYCLE_EVENTS,MIXINS:()=>r.MIXINS,NON_BUBBLING_EVENTS:()=>r.NON_BUBBLING_EVENTS,REGISTRY:()=>r.REGISTRY,SVG_TAGS:()=>o.SVG_TAGS,addDelegatedEvent:()=>E.addDelegatedEvent,addMethods:()=>l.addMethods,applyExtends:()=>g.applyExtends,cacheNode:()=>o.cacheNode,create:()=>d.create,createHTMLNode:()=>o.createHTMLNode,default:()=>d.default,detectTag:()=>o.detectTag,dispose:()=>s.dispose,flushMounts:()=>d.flushMounts,globalEventKeyInfo:()=>E.globalEventKeyInfo,isSvgTag:()=>o.isSvgTag,isValidTag:()=>o.isValidTag,refreshContextProto:()=>l.refreshContextProto,registerEvent:()=>E.registerEvent,registerGlobalEvent:()=>E.registerGlobalEvent,remove:()=>s.remove,removeDelegatedEvent:()=>E.removeDelegatedEvent,update:()=>T.update});module.exports=c(L);var d=I(require("./create.js"),1),T=require("./update.js"),s=require("./dispose.js"),r=require("./registry.js"),E=require("./delegate.js"),o=require("./cache.js"),g=require("./extends.js"),l=require("./methods.js");
|
package/dist/cjs/src/update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var A=(n,i)=>{for(var e in i)a(n,e,{get:i[e],enumerable:!0})},U=(n,i,e,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of g(i))!p.call(n,c)&&c!==e&&a(n,c,{get:()=>i[c],enumerable:!(f=b(i,c))||f.enumerable});return n};var j=n=>U(a({},"__esModule",{value:!0}),n);var B={};A(B,{default:()=>v,update:()=>h});module.exports=j(B);var d=require("@symbo.ls/signal"),_=require("./registry.js"),r=require("./create.js"),y=require("@symbo.ls/utils/function.js"),u=require("attrs-in-props");function h(n={},i={}){const e=this,f=e.__ref;if(!f)return;if((typeof n=="string"||typeof n=="number")&&(n={text:n}),!i.preventListeners&&typeof e.onBeforeUpdate=="function"&&(0,r.acquireBeforeUpdateGuard)(f))try{const t=e.onBeforeUpdate(e,e.state,e.context,i);if(t&&typeof t.then=="function")t.then(()=>(0,r.releaseBeforeUpdateGuard)(f,!1),o=>{(0,r.releaseBeforeUpdateGuard)(f,!0),e.context?.plugins?.length&&(0,y.runPluginHook)("error",e,{hook:"onBeforeUpdate",error:o})||console.error("[DOMQL] onBeforeUpdate error:",o)});else if((0,r.releaseBeforeUpdateGuard)(f,!1),t===!1)return e}catch(t){throw(0,r.releaseBeforeUpdateGuard)(f,!0),t}const c=!n||Object.keys(n).length===0;if((0,d.batch)(()=>{if(n.state&&(0,d.isStore)(e.state)&&e.state.$update(n.state),n.text!==void 0&&(e.text=n.text,!f.__exec.text&&e.node&&(
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var A=(n,i)=>{for(var e in i)a(n,e,{get:i[e],enumerable:!0})},U=(n,i,e,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of g(i))!p.call(n,c)&&c!==e&&a(n,c,{get:()=>i[c],enumerable:!(f=b(i,c))||f.enumerable});return n};var j=n=>U(a({},"__esModule",{value:!0}),n);var B={};A(B,{default:()=>v,update:()=>h});module.exports=j(B);var d=require("@symbo.ls/signal"),_=require("./registry.js"),r=require("./create.js"),y=require("@symbo.ls/utils/function.js"),u=require("attrs-in-props");function h(n={},i={}){const e=this,f=e.__ref;if(!f)return;if((typeof n=="string"||typeof n=="number")&&(n={text:n}),!i.preventListeners&&typeof e.onBeforeUpdate=="function"&&(0,r.acquireBeforeUpdateGuard)(f))try{const t=e.onBeforeUpdate(e,e.state,e.context,i);if(t&&typeof t.then=="function")t.then(()=>(0,r.releaseBeforeUpdateGuard)(f,!1),o=>{(0,r.releaseBeforeUpdateGuard)(f,!0),e.context?.plugins?.length&&(0,y.runPluginHook)("error",e,{hook:"onBeforeUpdate",error:o})||console.error("[DOMQL] onBeforeUpdate error:",o)});else if((0,r.releaseBeforeUpdateGuard)(f,!1),t===!1)return e}catch(t){throw(0,r.releaseBeforeUpdateGuard)(f,!0),t}const c=!n||Object.keys(n).length===0;if((0,d.batch)(()=>{if(n.state&&(0,d.isStore)(e.state)&&e.state.$update(n.state),n.text!==void 0&&(e.text=n.text,!f.__exec.text&&e.node&&(0,r.writeElementText)(e,n.text??"")),n.html!==void 0&&(e.html=n.html,!f.__exec.html&&e.node&&(e.node.innerHTML=n.html)),n.style&&e.node?.style){if(!f.__exec.style)for(const t in n.style){const o=n.style[t];if(o==null)continue;const s=t.replace(/[A-Z]/g,x=>"-"+x.toLowerCase()),l=String(o).replace(/\s*!important\s*$/,"");e.node.style.setProperty(s,l,"important")}e.style||(e.style={}),Object.assign(e.style,n.style)}if(n.attr&&e.node?.setAttribute){for(const t in n.attr){const o=n.attr[t];o==null||o===!1&&!(0,u.isEnumeratedTrueFalseAttr)(t)?e.node.removeAttribute(t):typeof o!="function"&&typeof o!="object"&&e.node.setAttribute(t,(0,u.serializeAttrValue)(t,o))}e.attr||(e.attr={}),Object.assign(e.attr,n.attr)}if(n.data&&e.node?.dataset){for(const t in n.data)e.node.dataset[t]=n.data[t];e.data||(e.data={}),Object.assign(e.data,n.data)}for(const t in n){if(_.REGISTRY.has(t)||t==="state")continue;const o=n[t],s=e[t];if(s&&s.__ref&&typeof s.update=="function")s.update(o,i);else if(typeof o=="object"&&o!==null){const l=t.charCodeAt(0);l>=65&&l<=90&&(0,r.create)(o,e,t,i)}else t!=="text"&&t!=="html"&&t!=="style"&&t!=="attr"&&t!=="data"&&(e[t]=o)}}),e.node&&c&&f.__effects&&f.__effects.length)for(let t=0;t<f.__effects.length;t++){const o=f.__effects[t];o&&!o._disposed&&!o._isSubscribeToEffect&&typeof o._execute=="function"&&o._execute()}else if(e.node&&f.__conditionalRunners)for(const t of f.__conditionalRunners)t();return(0,y.runPluginHook)("update",e),!i.preventListeners&&typeof e.onUpdate=="function"&&e.onUpdate(e,e.state,e.context,i),e}var v=h;
|
package/dist/esm/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{createStore as
|
|
2
|
-
`+
|
|
1
|
+
import{createStore as lt,createScopeStore as to,isStore as B}from"@symbo.ls/signal";import{createEffect as C}from"@symbo.ls/signal";import{cacheNode as pt,detectTag as Ot}from"./cache.js";import{REGISTRY as K,LIFECYCLE_EVENTS as oo}from"./registry.js";import{registerEvent as so,registerGlobalEvent as no,globalEventKeyInfo as eo}from"./delegate.js";import{applyExtends as ro}from"./extends.js";import{addMethods as io}from"./methods.js";import"./dispose.js";import{isLoudDevRuntime as et}from"./devRuntime.js";import{replaceLiteralsWithObjectFields as yt}from"@symbo.ls/utils";import{runPluginHook as U}from"@symbo.ls/utils/function.js";import{applyStateMethods as J}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as T,DEFAULT_CSS_PROPERTIES_LIST as E,pushStaticCssPass as co,popStaticCssPass as ao}from"css-in-props";import{css as rt,wrapHoverRule as $t}from"@symbo.ls/css";import{pushConfig as L,popConfig as O}from"@symbo.ls/scratch";import{checkAttributeByTagName as ht,applyAttrTransforms as fo,camelToAttr as _t,serializeAttrValue as z,isEnumeratedTrueFalseAttr as it}from"attrs-in-props";let uo=1;const m=[];let gt=!1;function Mt(){return typeof Date<"u"&&typeof Date.now=="function"?Date.now():0}function lo(){return typeof document<"u"&&document.visibilityState==="hidden"}const po=250;function Rt(){if(!gt){if(gt=!0,typeof requestAnimationFrame!="function"){setTimeout(bt,0);return}lo()?setTimeout(bt,po):requestAnimationFrame(bt)}}const yo=300,ho=15e4;function bt(){if(gt=!1,!m.length)return;const t=m.splice(0,m.length);for(let n=0;n<t.length;n++){const s=t[n];if(s.node){if(!s.node.isConnected){const e=s.__ref||(s.__ref={});e.__mountAttempts=(e.__mountAttempts||0)+1,e.__mountFirstAttemptAt==null&&(e.__mountFirstAttemptAt=Mt());const r=Mt()-e.__mountFirstAttemptAt;e.__mountAttempts<=yo&&r<ho?(m.push(s),Rt()):console.warn("[DOMQL] onMounted dropped after",e.__mountAttempts,"attempts /",r,"ms \u2014 node never connected:",s.key||s.tag||s);continue}I("Mounted",s,s.__ref?.__mountOptions||{})}}}function Nt(t,n){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=n,m.push(t),Rt())}function Ft(t,n){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&U("contentUpdate",t,n);const s=t.context?.designSystem;s&&L(s);try{t.onContentUpdate(t,t.state,t.context,n)}catch(e){if(t.context?.plugins?.length&&U("error",t,{hook:"onContentUpdate",error:e})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',e),t.context?.strictMode)throw e}finally{s&&O()}}function Y(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function _o(t){return t.charAt(2).toLowerCase()+t.slice(3)}function go(t){return t.toLowerCase()}function xt(t){const n=t.charCodeAt(0);return n===58||n===64||n===38}function tt(t,n){const s={...t};for(const e in n){const r=s[e],o=n[e];r&&o&&typeof r=="object"&&typeof o=="object"&&!Array.isArray(r)&&!Array.isArray(o)&&typeof r!="function"&&typeof o!="function"?s[e]=tt(r,o):s[e]=o}return s}function H(t,n,s,e={},r){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=s||t.key||`_${uo++}`,o.parent=n||null,o.context=t.context||n?.context||e.context||{},o.context.__create||(o.context.__create=H);const c=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:n?.__ref?.root||o,path:n?.__ref?.path?[...n.__ref.path,o.key]:[o.key],origin:t};if(s&&!t.extends&&!t.extend){const d=s.indexOf("_");if(d>0){const p=s.substring(0,d),g=o.context?.components;g&&(g[p]||g["smbls."+p])?t={...t,extends:p}:g&&et()&&/^[A-Z]\w*_\d+$/.test(s)&&console.warn(`[smbls] auto-extend: key "${s}" looks like a multi-instance (${p}_N) but neither "${p}" nor "smbls.${p}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}ro(o,t,e);const i=new Set(["childProps","attr","style","scope","data"]),a=o.props&&typeof o.props=="object"?o.props:null;for(const d in t){if(d==="parent"||d==="node"||d==="__ref"||d==="extends"||d==="context"||d==="props")continue;const p=t[d],g=o[d],x=g&&p&&typeof g=="object"&&typeof p=="object"&&!Array.isArray(g)&&!Array.isArray(p)&&typeof g!="function"&&typeof p!="function";x&&d.charCodeAt(0)>=65&&d.charCodeAt(0)<=90?o[d]=tt(g,p):x&&i.has(d)?o[d]={...g,...p}:x&&xt(d)?o[d]=tt(g,p):o[d]=p}function f(d){for(const p in d){const g=d[p],x=o[p],b=x&&g&&typeof x=="object"&&typeof g=="object"&&!Array.isArray(x)&&!Array.isArray(g)&&typeof x!="function"&&typeof g!="function";b&&p.charCodeAt(0)>=65&&p.charCodeAt(0)<=90?o[p]=tt(x,g):b&&i.has(p)?o[p]={...x,...g}:b&&xt(p)?o[p]=tt(x,g):o[p]=g}}a&&f(a),t.props&&typeof t.props=="object"&&f(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const u=o.scope&&typeof o.scope=="object"?o.scope:null,l=n?.scope,y=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,h=l||y||null;if(t.scope!==void 0||u){const d={};u&&Object.assign(d,u),t.scope!==void 0&&Object.assign(d,t.scope),o.scope=to(d,h)}else h&&(o.scope=h);if(t.if!==void 0&&(o.if=t.if),io(o),bo(o,n,t),o.if!=null){let d;if(typeof o.if=="function")try{d=o.if(o,o.state,o.context)}catch(p){if(d=!1,c.__ifError=p,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,p?.message||p)}}else d=o.if;c.__if=!!d}if(c.__if)typeof o.if=="function"&&(c.__ifInitialized=!0);else return n&&(n[o.key]=o),typeof o.if=="function"&&Kt(o,c,o.if),o;o.tag||(o.tag=Ot(o)),I("Init",o,e);const _=o.node=pt(o);if(!_)return o;if(o.tag==="fragment"){const p=(o.context?.document||globalThis.document).createComment("");_.appendChild(p),c.__fragmentAnchor=p}I("AttachNode",o,e),_.setAttribute&&o.key&&_.setAttribute("data-key",o.key),n&&(n[o.key]=o,n.__ref?.__children&&(n.__ref.__children.includes(o.key)||n.__ref.__children.push(o.key))),_.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&_.setAttribute("data-smbls-app",o.context.key),o.id&&_.setAttribute&&(_.id=o.id),Qt(o,e),It(o),kt(o),Yt(o),Mo(o);try{Zt(o,e)}catch(d){if(typeof console<"u"&&console.error){const p=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${p}:`,d?.message||d,d?.stack?`
|
|
2
|
+
`+d.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(wt(o,!0),Yt(o,s,c),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&O(l);try{const _=o.html(o,o.state,o.context);_!=null&&typeof _!="function"&&(o.node.innerHTML=_)}catch{}finally{l&&D()}}if(U("Create",o,r),U("Complete",o,r),U("Render",o,r),U("RenderRouter",o,r),Rt(o,r),typeof o.onFrame=="function"){const l=o.onFrame,_=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){_&&O(_);try{l(o,o.state,o.context)}catch(x){console.error("[DOMQL] onFrame error:",x)}finally{_&&D()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function ao(t,s,n){const r=!s,c=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&c&&t.context?.state,a=n.state!==void 0&&!o?n.state:t.state&&!I(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,X(t,t.state);else if(t.context?.state){const i=t.context.state,e={...i},f=t.context?.polyglot;if(f?.translations){const u=i.lang||f.defaultLang||"en",d=f.translations[u];if(d&&typeof d=="object")for(const y in d)e[y]===void 0&&(e[y]=d[y]);const p=new Set(f.languages||[]);for(const y in f.translations)!p.has(y)&&e[y]===void 0&&(e[y]=f.translations[y])}t.state=I(e)?e:ft(e),t.state.__element=t,t.state.root=t.state,X(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),X(t,t.state);return}if(typeof a=="string"){if(t.state=Mt(a,s),t.state&&typeof t.state=="object"&&!I(t.state)){const i=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:i,enumerable:!1,configurable:!0,writable:!0})}X(t,t.state);return}if(typeof a=="function"){const i=a(t,s?.state);t.state=I(i)?i:ft(i||{})}else I(a)?t.state=a:t.state=ft({...a});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,X(t,t.state)}function bt(t,s){if(!s)return t;const n=s.split("/");let r=t;for(const c of n){if(r==null)return{};r=r[c]}return r??{}}function Mt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const c=t.slice(3);return c?bt(s.state,c):s.state??{}}if(t.startsWith("~/")){const c=s.state?.root||s.state,o=t.slice(2);return o?bt(c,o):c??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=bt(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=s.context?.polyglot;if(r?.translations){const c=s.state?.root?.lang||r.defaultLang||"en",o=r.translations[c];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}const fo=new Set(["s","state","ctx","context"]);function uo(t){try{const n=Function.prototype.toString.call(t).match(/^[^(]*\(([^)]*)\)/);return n?n[1].split(",").map(r=>r.trim().split("=")[0].trim()).filter(Boolean):[]}catch{return[]}}function lo(t){if(typeof t!="function"||t.length!==2)return!1;const s=uo(t);if(s.length<2)return!1;const n=s[1].replace(/[{}[\]]/g,"").trim();return n.length>0&&!fo.has(n)}function po(t){const s=t.__ref,n=t.tag||"div",r=t.context?.designSystem,c=[],o=Object.keys(t);for(let a=0;a<o.length;a++){const i=o[a];if(typeof t[i]!="function"||B.has(i))continue;const e=i.charCodeAt(0);e>=65&&e<=90||z(i)||E[i]||w&&w.has(i)||pt(n,i)||(dt()&&lo(t[i])&&console.warn(`[smbls] custom prop "${i}"${t.key?` on key "${t.key}"`:""} is a function \u2014 it will be auto-invoked on read and its RETURN VALUE stored, not preserved as a callable reference. If you meant to stash a callback, use el.call('${i}', \u2026) instead of reading el.${i}(\u2026) directly (see RULES.md Rule 8).`),c.push({prop:i,fn:t[i]}))}for(let a=0;a<c.length;a++){const{prop:i,fn:e}=c[a];s.__exec[i]=e,Object.defineProperty(t,i,{get(){r&&O(r);try{return e(t,t.state,t.context)}catch{return}finally{r&&D()}},set(f){delete s.__exec[i],Object.defineProperty(t,i,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function yo(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const r=s[n];try{typeof r=="function"?r(t,t.state,t.context):typeof r=="string"&&t.state?.[r]}catch{}}}function L(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...r){return yo(t,s),n.apply(this,r)}}function tt(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Nt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(po(t),typeof t.text=="function"){const o=t.text,a=L(t,t.textDeps,o),i=S(()=>{if(!n.contentManaged)try{let e=a(t,t.state,t.context);t.node&&e!=null&&typeof e!="function"&&typeof e!="object"&&(typeof e=="string"&&e.includes("{{")&&(e=lt.call(t,e,t.state)),t.tag==="string"?t.node.nodeValue=e:t.node.textContent=e)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,a=S(()=>{if(n.contentManaged)return;const i=lt.call(t,o,t.state);i!=null&&(t.text=i),t.node&&(t.tag==="string"?t.node.nodeValue=i??"":t.node.textContent=i??"")},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(a),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!B.has(o)&&!z(o)&&!n.__exec[o]){if(E[o]){const a=t[o],i=L(t,t[o+"Deps"],a),e=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=i(t,t.state,t.context),y=E[e](p,t,t.state,t.context);if(y&&t.node){const h=At(y);(h===null||h!==f)&&(f=h,Y(t.node,y))}else t.node&&(e==="show"||e==="hide")&&(f=void 0,t.node.style.display="")}finally{d&&D()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(u),n.__exec[o]=a}else if(w&&w.has(o)){const a=t[o],i=L(t,t[o+"Deps"],a),e=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=i(t,t.state,t.context);if(t.node)if(p!=null){const y=e+":"+String(p);y!==f&&(f=y,Y(t.node,{[e]:p}))}else f=void 0,t.node.style[e]=""}finally{d&&D()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=L(t,t.htmlDeps,o),i=S(()=>{const e=t.context?.designSystem;e&&O(e);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{e&&D()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=L(t,t.valueDeps,o),i=S(()=>{try{const e=a(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=e==null?"":String(e);if(t.node.value===f)return;const u=typeof document<"u"&&document.activeElement===t.node,d=u&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=u&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,u&&d!=null&&p!=null)try{t.node.setSelectionRange(d,p)}catch{}}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=L(t,t.styleDeps,o);let i;const e=S(()=>{const f=a(t,t.state,t.context),u=At(f);(u===null||u!==i)&&(i=u,Y(t.node,f))},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(e),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const a=t.style[o];if(typeof a!="function")continue;const i=L(t,tt(t.styleDeps,o),a);let e;const f=S(()=>{try{const u=i(t,t.state,t.context);if(t.node){const d=o+":"+String(u);d!==e&&(e=d,Y(t.node,{[o]:u}))}}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const a=L(t,tt(t.attrDeps,o),t.attr[o]),i=o,e=S(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1&&!rt(i)?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,G(i,f)))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(e)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const a=L(t,tt(t.ariaDeps,o),t.aria[o]),i="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),e=S(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,G(i,f))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(e)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const a=L(t,tt(t.dataDeps,o),t.data[o]),e="data-"+o.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=S(()=>{try{const u=a(t,t.state,t.context);if(!t.node?.setAttribute)return;u==null||u===!1?t.node.removeAttribute(e):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(e,u===!0?"":u)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}const c=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(c)for(const o in c){if(typeof c[o]!="function")continue;const a=L(t,tt(t.classDeps,o),c[o]),i=S(()=>{try{const e=a(t,t.state,t.context);if(!t.node?.classList)return;typeof e=="string"?t.node.classList.add(e):e?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(i)}!r&&typeof t.if=="function"&&It(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||B.has(o)||typeof t[o]!="function")continue;const a=o.charCodeAt(0);if(a>=65&&a<=90||z(o))continue;const i=t[o];n.__exec[o]=i;const e=t.tag||"div";if(pt(e,o)&&!E[o]&&!(w&&w.has(o))){const f=yt(o)||o,u=L(t,t[o+"Deps"],i),d=S(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1&&!rt(f)?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,G(f,p))))}catch{}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(d)}}if(go(t),Ao(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let i=!1,e=[];const f=S(()=>{const u=[];for(let h=0;h<a.length;h++){const l=a[h];try{u[h]=typeof l=="function"?l(t,t.state,t.context):t.state?.[l]}catch{u[h]=void 0}}if(!i){i=!0,e=u;return}let d=u.length!==e.length;for(let h=0;!d&&h<u.length;h++)u[h]!==e[h]&&(d=!0);const p=e;if(e=u,!d)return;const y=t.context?.designSystem;y&&O(y);try{o(t,t.state,t.context,{prev:p,next:u})}catch(h){if(t.context?.plugins?.length&&N("error",t,{hook:"onStateUpdate",error:h})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',h),t.context?.strictMode)throw h}finally{y&&D()}},{depth:n.path.length,label:()=>n.path.join(".")});n.__effects.push(f)}xo(t)}function Ut(t){const s=t.parent,n=s?.node;if(!n||!t.node){Yt(t,t.parent);return}let r=null;const c=Object.keys(s),o=c.indexOf(t.key);for(let a=o+1;a<c.length;a++){const i=s[c[a]];if(i?.node?.parentNode===n){r=i.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function It(t,s,n){const r=L(t,t.ifDeps,n),c=S(()=>{let o;try{o=r(t,t.state,t.context)}catch(i){if(o=!1,s.__ifError=i,typeof console<"u"&&console.warn){const e=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${e} \u2014 treating as false:`,i?.message||i)}return}const a=s.__if;if(s.__if=!!o,a&&!s.__if&&t.node)t.node.remove();else if(!a&&s.__if)if(s.__ifInitialized)t.node||(t.node=ut(t)),t.node&&(t.node.ref=t),Ut(t),xt(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=Dt(t)),U("Init",t,{}),t.node||(t.node=ut(t)),!t.node)return;if(t.parent?.__ref?.__children&&!t.parent.__ref.__children.includes(t.key)&&t.parent.__ref.__children.push(t.key),t.tag==="fragment"&&!s.__fragmentAnchor){const e=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(e),s.__fragmentAnchor=e}U("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),Gt(t,{}),Nt(t,{skipIfEffect:!0}),xt(t),Ht(t),zt(t,{}),Ut(t),Rt(t,{})}},{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(c)}function xt(t){const{node:s}=t;if(s){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?s.nodeValue=t.text:s.textContent=t.text:typeof t.text=="number"&&(s.textContent=t.text),ko(t),typeof t.html=="string"&&(s.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in s){const n=String(t.value);s.value!==n&&(s.value=n)}if(t.style&&typeof t.style=="object"&&Y(s,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const r=t.attr[n];typeof r=="function"||typeof r=="object"||r!=null&&(r===!1&&!rt(n)||s.setAttribute&&s.setAttribute(n,G(n,r)))}if(t.data&&typeof t.data=="object")for(const n in t.data){const r=t.data[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||s.dataset&&(s.dataset[n]=r===!0?"":r)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(r=>r&&s.classList.add(r));else if(typeof n=="object")for(const r in n){const c=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];c&&s.classList.add(typeof c=="string"?c:r)}}}}function At(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function Y(t,s){if(!t||!s||!t.style)return;let n=null;for(const r in s){const c=s[r];if(c!=null){if(r.charAt(0)==="&"&&typeof c=="object"){n||(n={}),n[r]=c;continue}try{const o=String(c),a=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),i=o.trim(),e=/\s*!important\s*$/.test(i),f=i.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,e?"important":"")}catch{}}}n&&_o(t,n)}let ho=0;function _o(t,s){const n=`_ds${ho++}`;t.classList.add(n);const r=t.ownerDocument;let c=r.querySelector("style[data-smbls-scoped]");c||(c=r.createElement("style"),c.setAttribute("data-smbls-scoped",""),r.head.appendChild(c));let o="";for(const a in s){const i="."+n,e=a.replace(/&/g,i).split(",").map(u=>{const d=u.trim();return d.includes(i)?d:i+d}).join(", "),f=s[a];if(typeof f=="object"){let u="",d="";for(const p in f){const y=f[p];if(typeof y=="object"){const h=p.includes("&")?e.split(", ").map(_=>p.replace(/&/g,_)).join(", "):e.split(", ").map(_=>`${_} ${p}`).join(", ");let l="";for(const _ in y)l+=`${_.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[_]};`;d+=Lt(`${h} { ${l} }`,h)+`
|
|
5
|
-
`}else u+=`${
|
|
6
|
-
`),d&&(o+=d)}}o&&(c.textContent+=o)}function go(t){let s=t.subscribeTo;if(typeof s=="function")try{s=s(t,t.state,t.context)}catch{s=null}if(!Array.isArray(s)||s.length===0)return;const n=t.__ref;for(let r=0;r<s.length;r++){const c=s[r];if(typeof c!="string"||c.length===0)continue;const o=c.split("."),a=o[0],i=o.slice(1),e={value:!1},f=S(()=>{const u=t.state&&(I(t.state)?t.state.root:null);if(!u||!I(u))return;let d=u;d=d[a];for(let y=0;y<i.length&&!(d==null||typeof d!="object");y++)if(I(d))d=d[i[y]];else break;if(!e.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&O(y);try{if(vo(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>it(n,!1),l=>{it(n,!0),t.context?.plugins?.length&&N("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(it(n,!1),h===!1&&(p=!0))}}catch(h){it(n,!0),t.context?.plugins?.length&&N("error",t,{hook:"onBeforeUpdate",error:h})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",h)}finally{y&&D()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const h=n.__effects[y];h&&h!==f&&!h._disposed&&!h._isSubscribeToEffect&&typeof h._execute=="function"&&h._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&O(y);try{t.onUpdate(t,t.state,t.context)}catch(h){t.context?.plugins?.length&&N("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&D()}}},{depth:n.path.length,label:()=>n.path.join(".")});e.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function Ct(t,s){return t.charCodeAt(0)===64&&t.length>1&&!t.startsWith("@media")&&!t.startsWith("@keyframes")&&!t.startsWith("@supports")&&(t==="@dark"||t==="@light"||!s.context?.designSystem?.media?.[t.slice(1)])}const Bt=new Set;function bo(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",r=n+"::"+t;Bt.has(r)||(Bt.add(r),console.warn(`[smbls/css] "${t}" at ${n} is a CHILD-COMPONENT key nested inside a pseudo/selector block (":hover", "@dark", etc.) \u2014 that is never a valid CSS selector fragment. The rule is DROPPED (not shipped as a dead/never-matching selector). To reveal a child on a parent state, target the child's OWN class from the parent selector instead, e.g. move the declaration onto the child element itself, or use a sibling-selector combinator in a top-level style block.`))}function Q(t,s,n){const r={},c=new Set,o=(a,i,e)=>{const f=e?new Set(Object.keys(r)):null;if(E[a]){const u=E[a](i,s,s.state,s.context);if(u){const d=Array.isArray(u)?u:[u];for(const p of d)p&&Object.assign(r,p)}}else r[a]=i;if(e)for(const u in r)f.has(u)||c.add(u)};for(const a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;let i=t[a];if(typeof i=="function"&&(i=i(s,s.state,s.context)),i==null||typeof i=="function")continue;if(typeof i=="object"&&!Array.isArray(i)){if(a==="style"){for(const d in i){let p=i[d];if(typeof p=="function"&&(p=p(s,s.state,s.context)),p==null||typeof p=="function")continue;const y=typeof s[d]=="function"&&(E[d]||w&&w.has(d));o(d,p,y)}continue}if(Ct(a,s)){const d=Q(i,s,!1);Object.keys(d).length&&(r[`[data-theme="${a.slice(1)}"] &`]=d);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(a)){dt()&&bo(a,s);continue}let f=a;if(a.charCodeAt(0)===64&&!a.startsWith("@media")&&!a.startsWith("@keyframes")){const d=s.context?.designSystem?.media?.[a.slice(1)];d&&(f=`@media ${d}`)}const u=Q(i,s,!1);Object.keys(u).length&&(r[f]=u);continue}const e=typeof s[a]=="function"&&(E[a]||w&&w.has(a));o(a,i,e)}if(n)for(const a in r)c.add(a);for(const a of c){const i=r[a];typeof i=="string"&&!i.includes("!important")&&(r[a]=i+" !important")}return r}function kt(t,s){if(s===void 0&&(s=0),s>8)return!1;if(typeof t=="function")return!0;if(t&&typeof t=="object"&&!Array.isArray(t)){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&kt(t[n],s+1))return!0}return!1}function Kt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(Ct(t,n)){const o=Q(s,n,!1);return Object.keys(o).length?{cssProp:`[data-theme="${t.slice(1)}"] &`,block:o}:null}let r=t;if(t.charAt(0)==="@"&&!t.startsWith("@media")&&!t.startsWith("@keyframes")){const o=n.context?.designSystem?.media?.[t.slice(1)];o&&(r=`@media ${o}`)}const c=Q(s,n,!1);return Object.keys(c).length?{cssProp:r,block:c}:null}function xo(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!gt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!kt(r))continue;let c=null,o;const a=S(()=>{if(!t.node)return;const i=t.context?.designSystem;i&&O(i);let e,f=!1;try{const u=Kt(n,r,t),d=u?At(u.block)+"::"+u.cssProp:null;if(d!==null&&d===o)f=!0;else if(o=d,u){const p=nt({[u.cssProp]:u.block},null,t.context?.cssPrefix);e=p?p.split(" ").filter(Boolean):null}else e=null}finally{i&&D()}if(!(f||!t.node.classList)){if(c)for(const u of c)t.node.classList.remove(u);if(e&&e.length)for(const u of e)t.node.classList.add(u);c=e}},{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(a)}}function Ao(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const c=r.charAt(0);if(c!=="."&&c!=="!")continue;const o=r.slice(1);if(!o)continue;if(/[:@\s>~+[\]]/.test(o)){if(typeof console<"u"&&console.warn){const d=o.split(/[:@\s>~+[\]]/)[0];console.warn(`[smbls] conditional \`${r}\` on ${t.key||"?"} will never match \u2014 the whole string after \`${c}\` is read as one prop name. Nest the selector inside instead: \`${c}${d}: { '${o.slice(d.length)}': {...} }\`.`)}continue}const a=t[r];if(!a||typeof a!="object")continue;const i=c==="!",e={lastMatch:!1,appliedKeys:null,appliedClasses:null},f=()=>{let d;const p=t[o];if(p===void 0){const l=!!t.state&&o in t.state,_=t.state?t.state[o]:void 0;if(l||_!==void 0)d=_;else{const g=t.context?.cases?.[o];if(g===void 0)return;try{d=typeof g=="function"?g.call(t,t):g}catch(x){d=!1,s.__conditionalError=x,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${r}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,x?.message||x)}}}else if(typeof p=="function")try{d=p(t,t.state,t.context)}catch(l){d=!1,s.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${r}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}else d=p;const y=i?!d:!!d;if(!t.node||y===e.lastMatch)return;e.lastMatch=y;const h=t.context?.designSystem;h&&O(h);try{if(y){const l={},_={};let g=!1;for(const b in a){if(!Object.prototype.hasOwnProperty.call(a,b))continue;const v=a[b],k=b.charAt(0);if((k===":"||k==="@"||k==="&")&&v&&typeof v=="object"&&!Array.isArray(v)){if(Ct(b,t)){const T=Q(v,t,!1);Object.keys(T).length&&(_[`[data-theme="${b.slice(1)}"] &`]=T,g=!0)}else{let T=b;if(k==="@"&&!b.startsWith("@media")&&!b.startsWith("@keyframes")){const K=t.context?.designSystem?.media?.[b.slice(1)];K&&(T=`@media ${K}`)}const H=Q(v,t,!1);Object.keys(H).length&&(_[T]=H,g=!0)}continue}const j=typeof v=="function"?v(t,t.state,t.context):v;if(j!=null)if(E[b]){const T=E[b](j,t,t.state,t.context);if(T){const H=Array.isArray(T)?T:[T];for(const K of H)K&&Object.assign(l,K)}}else w&&w.has(b)&&(l[b]=j)}const x=Object.keys(l);if(x.length){Y(t.node,l);for(const b of x)n.set(b,r);e.appliedKeys=x}else e.appliedKeys=null;if(g){const b=nt(_,null,t.context?.cssPrefix),v=b?b.split(" ").filter(Boolean):[];if(v.length&&t.node.classList){for(const k of v)t.node.classList.add(k);e.appliedClasses=v}else e.appliedClasses=null}else if(e.appliedClasses){for(const b of e.appliedClasses)t.node.classList.remove(b);e.appliedClasses=null}}else{if(e.appliedKeys){for(const l of e.appliedKeys)n.get(l)===r&&(t.node.style[l]="",n.delete(l));e.appliedKeys=null}if(e.appliedClasses){for(const l of e.appliedClasses)t.node.classList.remove(l);e.appliedClasses=null}}}finally{h&&D()}};s.__conditionalRunners.push(f);const u=S(f,{depth:s.path.length,label:()=>s.path.join(".")});s.__effects.push(u)}}const St=new WeakSet;function Co(t){const s=t.ownerDocument;!s||St.has(s)||(St.add(s),queueMicrotask(()=>{St.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const jt=new WeakSet;let Vt=!1;function ko(t){const{node:s}=t;if(!s)return;if(Vt||(Vt=!0,nt({display:"none"})),jt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}jt.add(t);const n=t.context?.designSystem;n&&O(n);try{const r={};let c=!1;if(Object.prototype.hasOwnProperty.call(t,"theme")&&typeof t.theme!="function"&&E.theme){const o=E.theme(t.theme,t,t.state,t.context);if(o){if(Array.isArray(o))for(const a of o)a&&Object.assign(r,a);else Object.assign(r,o);c=!0}}for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||B.has(o)||o==="theme")continue;const a=o.charCodeAt(0);if(!(a>=65&&a<=90)&&!z(o)){if(E[o]){const i=t[o],e=E[o](i,t,t.state,t.context);if(e){if(Array.isArray(e))for(const f of e)f&&Object.assign(r,f);else Object.assign(r,e);c=!0}}else if(w&&w.has(o)){const i=t[o];i!=null&&typeof i!="object"&&(r[o]=i,c=!0)}else if(o.charCodeAt(0)===45){const i=t[o];i!=null&&typeof i!="object"&&(r[o]=i,c=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const i=t[o];if(i&&typeof i=="object"&&!Array.isArray(i)){if(kt(i))continue;const e=Kt(o,i,t);e&&(r[e.cssProp]=e.block,c=!0)}}}}if(c){r.display&&String(r.display).includes("!important")&&(s.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=nt(r,null,t.context?.cssPrefix);if(o&&s.classList){const i=o.split(" ").filter(Boolean);let e=!1;for(const f of i)s.classList.add(f),e||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(e=!0);e&&Co(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const i=r.display;if(i&&i!==a)if(a==="none"){const e=[];for(const f of s.classList)f.startsWith("_d-")&&f!=="_d-none"&&e.push(f);for(const f of e)s.classList.remove(f);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&D(),jt.delete(t)}}function Ht(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const c in t.aria){const o=t.aria[c];if(typeof o=="function"||typeof o=="object"||o==null)continue;const a="aria-"+c.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());s.setAttribute(a,G(a,o))}const n=to(t);for(const c in n){const o=n[c];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(c,o===!0?"":o)}const r=t.tag||"div";for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||typeof t[c]=="function"||B.has(c)||c==="on"||n[c]!==void 0)continue;const o=c.charCodeAt(0);if(!(o>=65&&o<=90)&&!z(c)&&!(E[c]||w&&w.has(c))&&pt(r,c)){let a=t[c];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=lt(a,t,t.state,t.context),t[c]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!rt(yt(c)||c))continue;const i=yt(c)||c;s.setAttribute(i,G(i,a))}}}function So(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,r=n&&typeof n=="object"&&n.max?String(n.max):null;r&&(s.style.maxHeight=r);const c=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};c(),s.addEventListener("input",c),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",c)}catch{}})}const Wt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Gt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!z(n)||Wt.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(i){return t.call(o,i)}}if(typeof r!="function")continue;const c=eo(n);qt.has(c)||Xt(co(c),t,r)}jo(t)}function jo(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Wt){const y=t[p];typeof y=="function"&&(n[p]=y,r=!0)}if(!r)return;const c=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let a=0,i=0,e=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,i=y.clientY,e=Date.now(),f=!0)},d=p=>{if(!f)return;f=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const h=y.clientX-a,l=y.clientY-i,_=Date.now()-e;if(_>o)return;const g=Math.abs(h),x=Math.abs(l);if(Math.max(g,x)<c)return;let b;if(g>x*1.2)b=h<0?"left":"right";else if(x>g*1.2)b=l<0?"up":"down";else return;const v="onSwipe"+b.charAt(0).toUpperCase()+b.slice(1),k=n[v],j=n.onSwipe;k&&k.call(t,p,t,t.state,t.context),j&&j.call(t,{direction:b,dx:h,dy:l,dt:_,event:p},t,t.state,t.context)};s.addEventListener("touchstart",u,{passive:!0}),s.addEventListener("touchend",d,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",u)}catch{}try{s.removeEventListener("touchend",d)}catch{}})}function ot(t,s){const n={...t};for(const r in s){const c=n[r],o=s[r];c&&o&&typeof c=="object"&&typeof o=="object"&&!Array.isArray(c)&&!Array.isArray(o)&&typeof c!="function"&&typeof o!="function"?n[r]=ot(c,o):n[r]=o}return n}function vt(t,s,n){if(!s||!t.node)return;const r=t.childExtends;if(Array.isArray(s)){const c=t.tag==="fragment",o=t.context?.document||globalThis.document,a=c?null:o?.createDocumentFragment();if(!c&&!a)return;const i=t.childProps,e=t.childrenAs;for(let f=0;f<s.length;f++){let u=s[f];const d=u;(typeof u=="string"||typeof u=="number")&&(u={text:u});let p=i;if(typeof i=="function")try{p=i(t,u)}catch{p=null}if(e==="state"){let l=d;(typeof d=="string"||typeof d=="number")&&(l={value:d,text:d}),u=p?{...p,state:l}:{state:l}}else p&&(u=ot(p,u));if(r&&!u.ignoreChildExtends)if(u.extends){const l=Array.isArray(u.extends)?u.extends:[u.extends],_=Array.isArray(r)?r:[r];u={...u,extends:[..._,...l]}}else u={...u,extends:r};const y=u?.key||d&&typeof d=="object"&&d.key||`${f}`;let h;try{h=V(u,t,y,n)}catch(l){if(typeof console<"u"&&console.error){const _=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${y}" failed to construct at ${_} (initial render, skipping this row):`,l?.message||l)}continue}!c&&h?.node&&a.appendChild(h.node)}return c||t.node.appendChild(a),!0}if(typeof s=="string"){const c=Mt(s,t);if(Array.isArray(c))return vt(t,c,n)}if(typeof s=="object")for(const c in s){if(B.has(c))continue;let o=s[c];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=ot(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],i=Array.isArray(r)?r:[r];o={...o,extends:[...i,...a]}}else o={...o,extends:r};V(o,t,c,n)}}}function wt(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const r=n.options;if(!r||!r.length)return;const c=t.__ref,o=c&&c.__exec&&c.__exec.value,a=typeof o=="function",i=t.value!=null&&typeof t.value!="function";if(a||i){let u;if(a)try{u=o(t,t.state,t.context)}catch{return}else u=t.value;const d=u==null?"":String(u);n.value!==d&&(n.value=d);return}const e=s||!(c&&c.__selectSynced);if(c&&(c.__selectSynced=!0),!e)return;let f=-1;for(let u=0;u<r.length;u++)r[u].defaultSelected&&(f=u);f>=0&&n.selectedIndex!==f&&(n.selectedIndex=f)}function zt(t,s){let{children:n,content:r}=t;const c=t.childExtends;if(typeof n=="function"){const i=n;try{n=i(t,t.state,t.context)}catch(p){if(n=void 0,typeof console<"u"&&console.error){const y=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${y} (initial run, treating as empty):`,p?.message||p)}}t.children=n;const e=t.__ref;let f=!1;const u=L(t,t.childrenDeps,i),d=S(()=>{const p=f;f=!0;let y;try{y=u(t,t.state,t.context)}catch(k){if(typeof console<"u"&&console.error){const j=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${j}${p?"":" (initial tracking run)"}:`,k?.message||k)}return}if(!p||y===t.children)return;t.children=y;const h=typeof t.onContentUpdate=="function",l=h?[]:null,_=h?[]:null,g=h?[]:null;if(Array.isArray(y)&&t.childrenAs==="state"){const k=t.childProps,j=[],T=new Map;for(let A=0;A<y.length;A++){const $=y[A];let C=k;if(typeof k=="function")try{C=k(t,$)}catch{C=null}const F=C&&C.key||$&&$.key||`${A}`;j.push(F),T.set(F,{rawChild:$,childProps:C})}const H=new Set(j),K=e.__children.slice();for(const A of K)if(!H.has(A)){const $=t[A];$?.remove&&$.remove(),delete t[A],_&&_.push(A)}const Z=t.childExtends,st=t.tag==="fragment",Qt=t.context?.document||globalThis.document,q=st?null:Qt?.createDocumentFragment(),et=new Set;for(const A of j){const $=T.get(A),C=$.rawChild,F=t[A];if(F&&F.state){if(C&&typeof C=="object"){const P=F.state,W=P.$replace||P.replace,Ot=P.$update||P.update;if(typeof W=="function")W.call(P,C);else if(typeof Ot=="function"){for(const M in P)if(!(M==="__element"||M==="root"||M==="parent"||M==="update")&&!Object.prototype.hasOwnProperty.call(C,M))try{P[M]=void 0}catch{}Ot.call(P,C)}else for(const M in C)P[M]=C[M]}g&&g.push(A);continue}let ct=C;(typeof C=="string"||typeof C=="number")&&(ct={value:C,text:C});const Pt=$.childProps;let R=Pt?{...Pt,state:ct}:{state:ct};if(Z&&!R.ignoreChildExtends)if(R.extends){const P=Array.isArray(R.extends)?R.extends:[R.extends],W=Array.isArray(Z)?Z:[Z];R={...R,extends:[...W,...P]}}else R={...R,extends:Z};let at;try{at=V(R,t,A,s)}catch(P){if(typeof console<"u"&&console.error){const W=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${A}" failed to construct at ${W} (reconcile, skipping this row):`,P?.message||P)}et.add(A);continue}!st&&at?.node&&q&&q.appendChild(at.node),l&&l.push(A)}if(!st&&q&&q.childNodes.length&&t.node&&t.node.appendChild(q),!st&&t.node){let A=null;for(const $ of j){const C=t[$]?.node;if(!C)continue;const F=A?A.nextSibling:t.node.firstChild;C!==F&&t.node.insertBefore(C,F),A=C}}e.__children=et.size?j.filter(A=>!et.has(A)):j,h&&(l.length||_.length)&&Ft(t,{added:l,removed:_,kept:g}),wt(t,!1);return}const v=h?[...e.__children]:null;for(const k of[...e.__children]){const j=t[k];j?.remove&&j.remove(),delete t[k]}e.__children=[],vt(t,y,s),wt(t,!1),h&&Ft(t,{added:[...e.__children],removed:v,kept:[]})},{depth:e.path.length,label:()=>e.path.join(".")});e.__effects.push(d)}const o=vt(t,n,s);if(r!=null&&!(r&&r.__ref)){let i=r;if(typeof i=="string"||typeof i=="number"?i={text:i}:typeof i!="object"&&(i={}),t.childProps&&(i=ot(t.childProps,i)),c&&!i.ignoreChildExtends)if(i.extends){const e=Array.isArray(i.extends)?i.extends:[i.extends],f=Array.isArray(c)?c:[c];i={...i,extends:[...f,...e]}}else i={...i,extends:c};V(i,t,"content",s)}if(n&&!o)return;const a=t.context?.components||{};{const i=Object.keys(t);for(let e=0;e<i.length;e++){const f=i[e];if(!f.endsWith("Extends")||typeof t[f]!="string")continue;const u=f.slice(0,-7);if(!u||u.charCodeAt(0)<65||u.charCodeAt(0)>90)continue;const d={extends:t[f]};delete t[f];for(let p=e+1;p<i.length;p++){const y=i[p],h=y.charCodeAt(0);if(h>=65&&h<=90||B.has(y)||typeof t[y]=="function"&&(y.startsWith("on")||y.startsWith(".")))break;const l=t[y];l!==void 0&&(d[y]=l,delete t[y])}t[u]&&typeof t[u]=="object"?t[u]={...d,...t[u]}:t[u]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||B.has(i)||typeof t[i]!="object"||t[i]===null)continue;const e=i.charCodeAt(0);if(e<65||e>90)continue;let f=t[i];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[i]||a[`smbls.${i}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=ot(t.childProps,f)),c&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],d=Array.isArray(c)?c:[c];f={...f,extends:[...d,...u]}}else f={...f,extends:c};V(f,t,i,s)}}}function Yt(t,s,n){const{node:r}=t;if(!r)return;r.ref=t;const c=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(c){const a=c.parentNode;if(a){if(n?.position==="before"&&n.node)a.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;a.insertBefore(r,i||c)}else a.insertBefore(r,c);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const a=n.node.nextSibling;a?o.insertBefore(r,a):o.appendChild(r)}else o.appendChild(r)}const Et=3;function vo(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=Et?!1:(t.__inBeforeUpdate=!0,!0)}function it(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===Et&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${Et}x in a row on this element \u2014 pausing automatic retries until a future prop/state change re-arms it.`)):t.__beforeUpdateFailCount=0)}function U(t,s,n){const r=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&N(r,s,n);const c="on"+t,o=s[c];if(typeof o=="function"){const e=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(e){if(s.__ref[e])return!0;s.__ref[e]=!0}const f=s.context?.designSystem;f&&O(f);let u=!!e;try{const d=o(s,s.state,s.context,n);if(d&&typeof d.then=="function"){const p=s.__ref;return d.catch(y=>{s.context?.plugins?.length&&N("error",s,{hook:c,error:y})||console.error(`[DOMQL] Lifecycle "${c}" error:`,y)}).finally(()=>{e&&p&&(p[e]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&N("error",s,{hook:c,error:d})||console.error(`[DOMQL] Lifecycle "${c}" error:`,d),s.context?.strictMode)throw d}finally{f&&D(),u&&s.__ref&&(s.__ref[e]=!1)}}return!0}var zo=V;export{Et as BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES,vo as acquireBeforeUpdateGuard,V as create,zo as default,_t as flushMounts,it as releaseBeforeUpdateGuard};
|
|
4
|
+
`):"")}}if(Tt(o,!0),Xt(o,n,r),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const d=o.context?.designSystem;d&&L(d);try{const p=o.html(o,o.state,o.context);p!=null&&typeof p!="function"&&(o.node.innerHTML=p)}catch{}finally{d&&O()}}if(I("Create",o,e),I("Complete",o,e),I("Render",o,e),I("RenderRouter",o,e),Nt(o,e),typeof o.onFrame=="function"){const d=o.onFrame,p=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){p&&L(p);try{d(o,o.state,o.context)}catch(x){console.error("[DOMQL] onFrame error:",x)}finally{p&&O()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function bo(t,n,s){const e=!n,r=s.state&&typeof s.state=="object"&&!Array.isArray(s.state)&&Object.keys(s.state).length===0,o=e&&r&&t.context?.state,c=s.state!==void 0&&!o?s.state:t.state&&!B(t.state)?t.state:void 0;if(c==null){if(n?.state)t.state=n.state,J(t,t.state);else if(t.context?.state){const i=t.context.state,a={...i},f=t.context?.polyglot;if(f?.translations){const u=i.lang||f.defaultLang||"en",l=f.translations[u];if(l&&typeof l=="object")for(const h in l)a[h]===void 0&&(a[h]=l[h]);const y=new Set(f.languages||[]);for(const h in f.translations)!y.has(h)&&a[h]===void 0&&(a[h]=f.translations[h])}t.state=B(a)?a:lt(a),t.state.__element=t,t.state.root=t.state,J(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),J(t,t.state);return}if(typeof c=="string"){if(t.state=Ut(c,n),t.state&&typeof t.state=="object"&&!B(t.state)){const i=n?.state?.root||n?.state||t.state;Object.defineProperty(t.state,"root",{value:i,enumerable:!1,configurable:!0,writable:!0})}J(t,t.state);return}if(typeof c=="function"){const i=c(t,n?.state);t.state=B(i)?i:lt(i||{})}else B(c)?t.state=c:t.state=lt({...c});t.state.__element=t,n?.state?(t.state.parent=n.state,t.state.root=n.state.root||n.state):t.state.root=t.state,J(t,t.state)}function At(t,n){if(!n)return t;const s=n.split("/");let e=t;for(const r of s){if(e==null)return{};e=e[r]}return e??{}}function Ut(t,n){if(!n)return{};if(t===".")return n.state||{};if(t.startsWith("../")){const r=t.slice(3);return r?At(n.state,r):n.state??{}}if(t.startsWith("~/")){const r=n.state?.root||n.state,o=t.slice(2);return o?At(r,o):r??{}}if(n.state?.[t]!==void 0)return n.state[t];const s=At(n.state,t);if(s!=null&&Object.keys(s).length>0)return s;const e=n.context?.polyglot;if(e?.translations){const r=n.state?.root?.lang||e.defaultLang||"en",o=e.translations[r];if(o?.[t]!==void 0)return o[t];if(e.translations[t]!==void 0)return e.translations[t]}return{}}const xo=new Set(["s","state","ctx","context"]);function Ao(t){try{const s=Function.prototype.toString.call(t).match(/^[^(]*\(([^)]*)\)/);return s?s[1].split(",").map(e=>e.trim().split("=")[0].trim()).filter(Boolean):[]}catch{return[]}}function ko(t){if(typeof t!="function"||t.length!==2)return!1;const n=Ao(t);if(n.length<2)return!1;const s=n[1].replace(/[{}[\]]/g,"").trim();return s.length>0&&!xo.has(s)}function Co(t){const n=t.__ref,s=t.tag||"div",e=t.context?.designSystem,r=[],o=Object.keys(t);for(let c=0;c<o.length;c++){const i=o[c];if(typeof t[i]!="function"||K.has(i))continue;const a=i.charCodeAt(0);a>=65&&a<=90||Y(i)||T[i]||E&&E.has(i)||ht(s,i)||(et()&&ko(t[i])&&console.warn(`[smbls] custom prop "${i}"${t.key?` on key "${t.key}"`:""} is a function \u2014 it will be auto-invoked on read and its RETURN VALUE stored, not preserved as a callable reference. If you meant to stash a callback, use el.call('${i}', \u2026) instead of reading el.${i}(\u2026) directly (see RULES.md Rule 8).`),r.push({prop:i,fn:t[i]}))}for(let c=0;c<r.length;c++){const{prop:i,fn:a}=r[c];n.__exec[i]=a,Object.defineProperty(t,i,{get(){e&&L(e);try{return a(t,t.state,t.context)}catch{return}finally{e&&O()}},set(f){delete n.__exec[i],Object.defineProperty(t,i,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function So(t,n){if(!(!Array.isArray(n)||n.length===0))for(let s=0;s<n.length;s++){const e=n[s];try{typeof e=="function"?e(t,t.state,t.context):typeof e=="string"&&t.state?.[e]}catch{}}}function P(t,n,s){return!Array.isArray(n)||n.length===0?s:function(...e){return So(t,n),s.apply(this,e)}}function ot(t,n){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[n]}function S(t,n){return()=>t.path.join(".")+"::"+n}function It(t,n){const s=t.__ref,e=!!(n&&n.skipIfEffect);if(Co(t),typeof t.text=="function"){const o=t.text,c=P(t,t.textDeps,o),i=C(()=>{if(!s.contentManaged)try{let a=c(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&typeof a!="object"&&(typeof a=="string"&&a.includes("{{")&&(a=yt.call(t,a,t.state)),ct(t,a))}catch{}},{depth:s.path.length,label:S(s,"text")});s.__effects.push(i),s.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,c=C(()=>{if(s.contentManaged)return;const i=yt.call(t,o,t.state);i!=null&&(t.text=i),t.node&&ct(t,i??"")},{depth:s.path.length,label:S(s,"text")});s.__effects.push(c),s.__exec.text=o}for(const o of Object.keys(t))if(typeof t[o]=="function"&&!K.has(o)&&!Y(o)&&!s.__exec[o]){if(T[o]){const c=t[o],i=P(t,t[o+"Deps"],c),a=o;let f;const u=C(()=>{const l=t.context?.designSystem;l&&L(l);try{const y=i(t,t.state,t.context),h=T[a](y,t,t.state,t.context),_=a==="show"||a==="hide";if(h&&t.node){const d=Ct(h),p=_&&t.node.style.display!=="none";(d===null||d!==f||p)&&(f=d,q(t.node,h))}else if(t.node&&_){f=void 0;const d=s.__explicitDisplay;t.node.style.display=typeof d=="string"?d:""}}finally{l&&O()}},{depth:s.path.length,label:S(s,a)});s.__effects.push(u),s.__exec[o]=c}else if(E&&E.has(o)){const c=t[o],i=P(t,t[o+"Deps"],c),a=o;let f;const u=C(()=>{const l=t.context?.designSystem;l&&L(l);try{const y=i(t,t.state,t.context);if(t.node)if(y!=null){const h=a+":"+String(y);h!==f&&(f=h,q(t.node,{[a]:y}))}else f=void 0,t.node.style[a]=""}finally{l&&O()}},{depth:s.path.length,label:S(s,a)});s.__effects.push(u),s.__exec[o]=c}}if(typeof t.html=="function"){const o=t.html,c=P(t,t.htmlDeps,o),i=C(()=>{const a=t.context?.designSystem;a&&L(a);try{const f=c(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{a&&O()}},{depth:s.path.length,label:S(s,"html")});s.__effects.push(i),s.__exec.html=o}if(typeof t.value=="function"){const o=t.value,c=P(t,t.valueDeps,o),i=C(()=>{try{const a=c(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=a==null?"":String(a);if(t.node.value===f)return;const u=typeof document<"u"&&document.activeElement===t.node,l=u&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,y=u&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,u&&l!=null&&y!=null)try{t.node.setSelectionRange(l,y)}catch{}}catch{}},{depth:s.path.length,label:S(s,"value")});s.__effects.push(i),s.__exec.value=o}if(typeof t.style=="function"){const o=t.style,c=P(t,t.styleDeps,o);let i;const a=C(()=>{const f=c(t,t.state,t.context),u=Ct(f);(u===null||u!==i)&&(i=u,q(t.node,f))},{depth:s.path.length,label:S(s,"style")});s.__effects.push(a),s.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const c=t.style[o];if(typeof c!="function")continue;const i=P(t,ot(t.styleDeps,o),c);let a;const f=C(()=>{try{const u=i(t,t.state,t.context);if(t.node){const l=o+":"+String(u);l!==a&&(a=l,q(t.node,{[o]:u}))}}catch{}},{depth:s.path.length,label:S(s,"style."+o)});s.__effects.push(f)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const c=P(t,ot(t.attrDeps,o),t.attr[o]),i=o,a=C(()=>{try{const f=c(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1&&!it(i)?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,z(i,f)))}catch{}},{depth:s.path.length,label:S(s,"attr."+i)});s.__effects.push(a)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const c=P(t,ot(t.ariaDeps,o),t.aria[o]),i="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),a=C(()=>{try{const f=c(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null?t.node.removeAttribute(i):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(i,z(i,f))}catch{}},{depth:s.path.length,label:S(s,"aria."+o)});s.__effects.push(a)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const c=P(t,ot(t.dataDeps,o),t.data[o]),a="data-"+o.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=C(()=>{try{const u=c(t,t.state,t.context);if(!t.node?.setAttribute)return;u==null||u===!1?t.node.removeAttribute(a):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(a,u===!0?"":u)}catch{}},{depth:s.path.length,label:S(s,"data."+o)});s.__effects.push(f)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const o in r){if(typeof r[o]!="function")continue;const c=P(t,ot(t.classDeps,o),r[o]),i=C(()=>{try{const a=c(t,t.state,t.context);if(!t.node?.classList)return;typeof a=="string"?t.node.classList.add(a):a?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:s.path.length,label:S(s,"class."+o)});s.__effects.push(i)}!e&&typeof t.if=="function"&&Kt(t,s,t.if);for(const o of Object.keys(t)){if(K.has(o)||typeof t[o]!="function")continue;const c=o.charCodeAt(0);if(c>=65&&c<=90||Y(o))continue;const i=t[o];s.__exec[o]=i;const a=t.tag||"div";if(ht(a,o)&&!T[o]&&!(E&&E.has(o))){const f=_t(o)||o,u=P(t,t[o+"Deps"],i),l=C(()=>{try{const y=u(t,t.state,t.context);t.node?.setAttribute&&(y==null||y===!1&&!it(f)?t.node.removeAttribute(f):typeof y!="function"&&typeof y!="object"&&(f==="src"&&"src"in t.node?t.node.src=y:t.node.setAttribute(f,z(f,y))))}catch{}},{depth:s.path.length,label:S(s,o)});s.__effects.push(l)}}if(Eo(t),Do(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,c=t.stateDeps;let i=!1,a=[];const f=C(()=>{const u=[];for(let _=0;_<c.length;_++){const d=c[_];try{u[_]=typeof d=="function"?d(t,t.state,t.context):t.state?.[d]}catch{u[_]=void 0}}if(!i){i=!0,a=u;return}let l=u.length!==a.length;for(let _=0;!l&&_<u.length;_++)u[_]!==a[_]&&(l=!0);const y=a;if(a=u,!l)return;const h=t.context?.designSystem;h&&L(h);try{o(t,t.state,t.context,{prev:y,next:u})}catch(_){if(t.context?.plugins?.length&&U("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{h&&O()}},{depth:s.path.length,label:S(s,"onStateUpdate")});s.__effects.push(f)}Po(t)}function Bt(t){const n=t.parent,s=n?.node;if(!s||!t.node){Xt(t,t.parent);return}let e=null;const r=Object.keys(n),o=r.indexOf(t.key);for(let c=o+1;c<r.length;c++){const i=n[r[c]];if(i?.node?.parentNode===s){e=i.node;break}}e?s.insertBefore(t.node,e):s.appendChild(t.node)}function Kt(t,n,s){const e=P(t,t.ifDeps,s),r=C(()=>{let o;try{o=e(t,t.state,t.context)}catch(i){if(o=!1,n.__ifError=i,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,i?.message||i)}return}const c=n.__if;if(n.__if=!!o,c&&!n.__if&&t.node)t.node.remove();else if(!c&&n.__if)if(n.__ifInitialized)t.node||(t.node=pt(t)),t.node&&(t.node.ref=t),Bt(t),kt(t);else{if(n.__ifInitialized=!0,t.tag||(t.tag=Ot(t)),I("Init",t,{}),t.node||(t.node=pt(t)),!t.node)return;if(t.parent?.__ref?.__children&&!t.parent.__ref.__children.includes(t.key)&&t.parent.__ref.__children.push(t.key),t.tag==="fragment"&&!n.__fragmentAnchor){const a=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(a),n.__fragmentAnchor=a}I("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),Qt(t,{}),It(t,{skipIfEffect:!0}),kt(t),Yt(t),Zt(t,{}),Bt(t),Nt(t,{})}},{depth:n.path.length,label:S(n,"if")});n.__effects.push(r)}function ct(t,n){const s=t.node;if(!s)return;const e=n==null?"":String(n);if(t.tag==="string"){s.nodeValue!==e&&(s.nodeValue=e);return}const r=t.__ref;let o=r?r.__textNode:null;if(o&&o.parentNode!==s&&(o=null),!o){const c=s.firstChild;c&&c.nodeType===3&&(o=c)}o?o.nodeValue!==e&&(o.nodeValue=e):s.firstChild?(o=(s.ownerDocument||t.context?.document||globalThis.document).createTextNode(e),s.insertBefore(o,s.firstChild)):(s.textContent=e,o=s.firstChild&&s.firstChild.nodeType===3?s.firstChild:null),r&&(r.__textNode=o||null)}function kt(t){const{node:n}=t;if(n){if((typeof t.text=="string"&&!t.text.includes("{{")||typeof t.text=="number")&&ct(t,t.text),Oo(t),typeof t.html=="string"&&(n.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in n){const s=String(t.value);n.value!==s&&(n.value=s)}if(t.style&&typeof t.style=="object"&&q(n,t.style),t.attr&&typeof t.attr=="object")for(const s in t.attr){const e=t.attr[s];typeof e=="function"||typeof e=="object"||e!=null&&(e===!1&&!it(s)||n.setAttribute&&n.setAttribute(s,z(s,e)))}if(t.data&&typeof t.data=="object")for(const s in t.data){const e=t.data[s];typeof e=="function"||typeof e=="object"||e==null||e===!1||n.dataset&&(n.dataset[s]=e===!0?"":e)}if(t.classlist||t.class){const s=t.classlist||t.class;if(typeof s=="string")s.split(" ").forEach(e=>e&&n.classList.add(e));else if(typeof s=="object")for(const e in s){const r=typeof s[e]=="function"?s[e](t,t.state,t.context):s[e];r&&n.classList.add(typeof r=="string"?r:e)}}}}function Ct(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function q(t,n){if(!t||!n||!t.style)return;let s=null;for(const e in n){const r=n[e];if(r!=null){if(e.charAt(0)==="&"&&typeof r=="object"){s||(s={}),s[e]=r;continue}try{const o=String(r),c=e.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),i=o.trim(),a=/\s*!important\s*$/.test(i),f=i.replace(/\s*!important\s*$/,"");t.style.setProperty(c,f,a?"important":"")}catch{}}}s&&wo(t,s)}let vo=0;function wo(t,n){const s=`_ds${vo++}`;t.classList.add(s);const e=t.ownerDocument;let r=e.querySelector("style[data-smbls-scoped]");r||(r=e.createElement("style"),r.setAttribute("data-smbls-scoped",""),e.head.appendChild(r));let o="";for(const c in n){const i="."+s,a=c.replace(/&/g,i).split(",").map(u=>{const l=u.trim();return l.includes(i)?l:i+l}).join(", "),f=n[c];if(typeof f=="object"){let u="",l="";for(const y in f){const h=f[y];if(typeof h=="object"){const _=y.includes("&")?a.split(", ").map(p=>y.replace(/&/g,p)).join(", "):a.split(", ").map(p=>`${p} ${y}`).join(", ");let d="";for(const p in h)d+=`${p.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${h[p]};`;l+=$t(`${_} { ${d} }`,_)+`
|
|
5
|
+
`}else u+=`${y.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${h};`}u&&(o+=$t(`${a} { ${u} }`,a)+`
|
|
6
|
+
`),l&&(o+=l)}}o&&(r.textContent+=o)}const Vt=new Set;function Ht(t){if(!Array.isArray(t))return"";const n=[];for(let s=0;s<t.length;s++)typeof t[s]=="string"&&t[s].length&&n.push(t[s]);return n.sort(),n.join("|")}function jo(t,n,s){const e=Ht(s);queueMicrotask(()=>{if(!t.__ref)return;let r;try{r=n(t,t.state,t.context)}catch{return}if(Ht(r)===e)return;const o=t.__ref.path?t.__ref.path.join("."):t.key||"?";Vt.has(o)||(Vt.add(o),console.warn(`[smbls] subscribeTo function at "${o}" resolved to a DIFFERENT key list one microtask after create \u2014 wired [${s.join(", ")||"(none)"}], probed [${Array.isArray(r)?r.join(", "):String(r)}]. subscribeTo's function form is resolved ONCE at element-create time (registerSubscribeToEffects, @symbo.ls/element create.js) \u2014 this element stays wired to the ORIGINAL list for its whole lifetime, so this drift is invisible to the reactive effect and any key only present in the new list will never trigger onUpdate. If the watched key genuinely is not known until later (e.g. a module config that loads after shell boot), route the write through an imperative call instead of subscribeTo \u2014 see functions/moduleOpenBridge.js's moduleOpenPage (workspace repo) for the house pattern.`))})}function Eo(t){const n=t.subscribeTo,s=typeof n=="function";let e=n;if(s)try{e=n(t,t.state,t.context)}catch{e=null}if(s&&et()&&jo(t,n,Array.isArray(e)?e:[]),!Array.isArray(e)||e.length===0)return;const r=t.__ref;for(let o=0;o<e.length;o++){const c=e[o];if(typeof c!="string"||c.length===0)continue;const i=c.split("."),a=i[0],f=i.slice(1),u={value:!1},l=C(()=>{const y=t.state&&(B(t.state)?t.state.root:null);if(!y||!B(y))return;let h=y;h=h[a];for(let d=0;d<f.length&&!(h==null||typeof h!="object");d++)if(B(h))h=h[f[d]];else break;if(!u.value)return;let _=!1;if(typeof t.onBeforeUpdate=="function"){const d=t.context?.designSystem;d&&L(d);try{if(No(r)){const p=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});p&&typeof p.then=="function"?p.then(()=>at(r,!1),g=>{at(r,!0),t.context?.plugins?.length&&U("error",t,{hook:"onBeforeUpdate",error:g})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",g)}):(at(r,!1),p===!1&&(_=!0))}}catch(p){at(r,!0),t.context?.plugins?.length&&U("error",t,{hook:"onBeforeUpdate",error:p})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",p)}finally{d&&O()}}if(!_&&t.node&&r.__effects)for(let d=0;d<r.__effects.length;d++){const p=r.__effects[d];p&&p!==l&&!p._disposed&&!p._isSubscribeToEffect&&typeof p._execute=="function"&&p._execute()}if(!_&&typeof t.onUpdate=="function"){const d=t.context?.designSystem;d&&L(d);try{t.onUpdate(t,t.state,t.context)}catch(p){t.context?.plugins?.length&&U("error",t,{hook:"onUpdate",error:p})||console.error("[DOMQL] subscribeTo onUpdate error:",p)}finally{d&&O()}}},{depth:r.path.length,label:S(r,"subscribeTo("+c+")")});u.value=!0,l._isSubscribeToEffect=!0,r.__effects.push(l)}}function St(t,n){return t.charCodeAt(0)===64&&t.length>1&&!t.startsWith("@media")&&!t.startsWith("@keyframes")&&!t.startsWith("@supports")&&(t==="@dark"||t==="@light"||!n.context?.designSystem?.media?.[t.slice(1)])}const Gt=new Set;function To(t,n){const s=n?.__ref?.path?n.__ref.path.join("."):n?.key||"?",e=s+"::"+t;Gt.has(e)||(Gt.add(e),console.warn(`[smbls/css] "${t}" at ${s} is a CHILD-COMPONENT key nested inside a pseudo/selector block (":hover", "@dark", etc.) \u2014 that is never a valid CSS selector fragment. The rule is DROPPED (not shipped as a dead/never-matching selector). To reveal a child on a parent state, target the child's OWN class from the parent selector instead, e.g. move the declaration onto the child element itself, or use a sibling-selector combinator in a top-level style block.`))}function Q(t,n,s){const e={},r=new Set,o=(c,i,a)=>{const f=a?new Set(Object.keys(e)):null;if(T[c]){const u=T[c](i,n,n.state,n.context);if(u){const l=Array.isArray(u)?u:[u];for(const y of l)y&&Object.assign(e,y)}}else e[c]=i;if(a)for(const u in e)f.has(u)||r.add(u)};for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;let i=t[c];if(typeof i=="function"&&(i=i(n,n.state,n.context)),i==null||typeof i=="function")continue;if(typeof i=="object"&&!Array.isArray(i)){if(c==="style"){for(const l in i){let y=i[l];if(typeof y=="function"&&(y=y(n,n.state,n.context)),y==null||typeof y=="function")continue;const h=typeof n[l]=="function"&&(T[l]||E&&E.has(l));o(l,y,h)}continue}if(St(c,n)){const l=Q(i,n,!1);Object.keys(l).length&&(e[`[data-theme="${c.slice(1)}"] &`]=l);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(c)){et()&&To(c,n);continue}let f=c;if(c.charCodeAt(0)===64&&!c.startsWith("@media")&&!c.startsWith("@keyframes")){const l=n.context?.designSystem?.media?.[c.slice(1)];l&&(f=`@media ${l}`)}const u=Q(i,n,!1);Object.keys(u).length&&(e[f]=u);continue}const a=typeof n[c]=="function"&&(T[c]||E&&E.has(c));o(c,i,a)}if(s)for(const c in e)r.add(c);for(const c of r){const i=e[c];typeof i=="string"&&!i.includes("!important")&&(e[c]=i+" !important")}return e}function vt(t,n){if(n===void 0&&(n=0),n>8)return!1;if(typeof t=="function")return!0;if(t&&typeof t=="object"&&!Array.isArray(t)){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&vt(t[s],n+1))return!0}return!1}function Wt(t,n,s){if(!n||typeof n!="object"||Array.isArray(n))return null;if(St(t,s)){const o=Q(n,s,!1);return Object.keys(o).length?{cssProp:`[data-theme="${t.slice(1)}"] &`,block:o}:null}let e=t;if(t.charAt(0)==="@"&&!t.startsWith("@media")&&!t.startsWith("@keyframes")){const o=s.context?.designSystem?.media?.[t.slice(1)];o&&(e=`@media ${o}`)}const r=Q(n,s,!1);return Object.keys(r).length?{cssProp:e,block:r}:null}function Po(t){const n=t.__ref;for(const s of Object.keys(t)){if(!xt(s))continue;const e=t[s];if(!e||typeof e!="object"||Array.isArray(e)||!vt(e))continue;let r=null,o;const c=C(()=>{if(!t.node)return;const i=t.context?.designSystem;i&&L(i);let a,f=!1;try{const u=Wt(s,e,t),l=u?Ct(u.block)+"::"+u.cssProp:null;if(l!==null&&l===o)f=!0;else if(o=l,u){const y=rt({[u.cssProp]:u.block},null,t.context?.cssPrefix);a=y?y.split(" ").filter(Boolean):null}else a=null}finally{i&&O()}if(!(f||!t.node.classList)){if(r)for(const u of r)t.node.classList.remove(u);if(a&&a.length)for(const u of a)t.node.classList.add(u);r=a}},{depth:n.path.length,label:S(n,"cssBlock("+s+")")});n.__effects.push(c)}}function Do(t){const n=t.__ref;n.__conditionalRunners=[];const s=new Map;for(const e of Object.keys(t)){const r=e.charAt(0);if(r!=="."&&r!=="!")continue;const o=e.slice(1);if(!o)continue;if(/[:@\s>~+[\]]/.test(o)){if(typeof console<"u"&&console.warn){const l=o.split(/[:@\s>~+[\]]/)[0];console.warn(`[smbls] conditional \`${e}\` on ${t.key||"?"} will never match \u2014 the whole string after \`${r}\` is read as one prop name. Nest the selector inside instead: \`${r}${l}: { '${o.slice(l.length)}': {...} }\`.`)}continue}const c=t[e];if(!c||typeof c!="object")continue;const i=r==="!",a={lastMatch:!1,appliedKeys:null,appliedClasses:null},f=()=>{let l;const y=t[o];if(y===void 0){const d=!!t.state&&o in t.state,p=t.state?t.state[o]:void 0;if(d||p!==void 0)l=p;else{const g=t.context?.cases?.[o];if(g===void 0)return;try{l=typeof g=="function"?g.call(t,t):g}catch(x){l=!1,n.__conditionalError=x,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${e}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,x?.message||x)}}}else if(typeof y=="function")try{l=y(t,t.state,t.context)}catch(d){l=!1,n.__conditionalError=d,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${e}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,d?.message||d)}else l=y;const h=i?!l:!!l;if(!t.node||h===a.lastMatch)return;a.lastMatch=h;const _=t.context?.designSystem;_&&L(_);try{if(h){const d={},p={};let g=!1;for(const b in c){if(!Object.prototype.hasOwnProperty.call(c,b))continue;const j=c[b],v=b.charAt(0);if((v===":"||v==="@"||v==="&")&&j&&typeof j=="object"&&!Array.isArray(j)){if(St(b,t)){const $=Q(j,t,!1);Object.keys($).length&&(p[`[data-theme="${b.slice(1)}"] &`]=$,g=!0)}else{let $=b;if(v==="@"&&!b.startsWith("@media")&&!b.startsWith("@keyframes")){const V=t.context?.designSystem?.media?.[b.slice(1)];V&&($=`@media ${V}`)}const G=Q(j,t,!1);Object.keys(G).length&&(p[$]=G,g=!0)}continue}const w=typeof j=="function"?j(t,t.state,t.context):j;if(w!=null)if(T[b]){const $=T[b](w,t,t.state,t.context);if($){const G=Array.isArray($)?$:[$];for(const V of G)V&&Object.assign(d,V)}}else E&&E.has(b)&&(d[b]=w)}const x=Object.keys(d);if(x.length){q(t.node,d);for(const b of x)s.set(b,e);a.appliedKeys=x}else a.appliedKeys=null;if(g){const b=rt(p,null,t.context?.cssPrefix),j=b?b.split(" ").filter(Boolean):[];if(j.length&&t.node.classList){for(const v of j)t.node.classList.add(v);a.appliedClasses=j}else a.appliedClasses=null}else if(a.appliedClasses){for(const b of a.appliedClasses)t.node.classList.remove(b);a.appliedClasses=null}}else{if(a.appliedKeys){for(const d of a.appliedKeys)s.get(d)===e&&(t.node.style[d]="",s.delete(d));a.appliedKeys=null}if(a.appliedClasses){for(const d of a.appliedClasses)t.node.classList.remove(d);a.appliedClasses=null}}}finally{_&&O()}};n.__conditionalRunners.push(f);const u=C(f,{depth:n.path.length,label:S(n,"conditional("+e+")")});n.__effects.push(u)}}const wt=new WeakSet;function Lo(t){const n=t.ownerDocument;!n||wt.has(n)||(wt.add(n),queueMicrotask(()=>{wt.delete(n);const s=n.body||n.documentElement;s&&s.offsetWidth}))}const jt=new WeakSet;let zt=!1;function Oo(t){const{node:n}=t;if(!n)return;if(zt||(zt=!0,rt({display:"none"})),jt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}jt.add(t);const s=t.context?.designSystem;s&&L(s),co();try{const e={};let r=!1;if(Object.prototype.hasOwnProperty.call(t,"theme")&&typeof t.theme!="function"&&T.theme){const o=T.theme(t.theme,t,t.state,t.context);if(o){if(Array.isArray(o))for(const c of o)c&&Object.assign(e,c);else Object.assign(e,o);r=!0}}for(const o of Object.keys(t)){if(typeof t[o]=="function"||K.has(o)||o==="theme")continue;const c=o.charCodeAt(0);if(!(c>=65&&c<=90)&&!Y(o)){if(T[o]){const i=t[o],a=T[o](i,t,t.state,t.context);if(a){if(Array.isArray(a))for(const f of a)f&&Object.assign(e,f);else Object.assign(e,a);r=!0}}else if(E&&E.has(o)){const i=t[o];i!=null&&typeof i!="object"&&(e[o]=i,r=!0)}else if(o.charCodeAt(0)===45){const i=t[o];i!=null&&typeof i!="object"&&(e[o]=i,r=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const i=t[o];if(i&&typeof i=="object"&&!Array.isArray(i)){if(vt(i))continue;const a=Wt(o,i,t);a&&(e[a.cssProp]=a.block,r=!0)}}}}if(r){e.display&&String(e.display).includes("!important")&&(n.style.setProperty("display",String(e.display).replace(/\s*!important\s*$/,""),"important"),delete e.display);const o=rt(e,null,t.context?.cssPrefix);if(o&&n.classList){const i=o.split(" ").filter(Boolean);let a=!1;for(const f of i)n.classList.add(f),a||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(a=!0);a&&Lo(n)}const c=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(c!=null){const i=e.display;if(i&&i!==c)if(c==="none"){const a=[];for(const f of n.classList)f.startsWith("_d-")&&f!=="_d-none"&&a.push(f);for(const f of a)n.classList.remove(f);n.classList.add("_d-none")}else n.style.display==="none"&&(typeof t.hide=="function"||typeof t.show=="function")||(n.style.display=t.display),t.__ref&&(t.__ref.__explicitDisplay=t.display)}}}finally{ao(),s&&O(),jt.delete(t)}}function Yt(t){const{node:n}=t;if(!n||!n.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const r in t.aria){const o=t.aria[r];if(typeof o=="function"||typeof o=="object"||o==null)continue;const c="aria-"+r.replace(/[A-Z]/g,i=>"-"+i.toLowerCase());n.setAttribute(c,z(c,o))}const s=fo(t);for(const r in s){const o=s[r];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&n.setAttribute(r,o===!0?"":o)}const e=t.tag||"div";for(const r of Object.keys(t)){if(typeof t[r]=="function"||K.has(r)||r==="on"||s[r]!==void 0)continue;const o=r.charCodeAt(0);if(!(o>=65&&o<=90)&&!Y(r)&&!(T[r]||E&&E.has(r))&&ht(e,r)){let c=t[r];if(c==null||(typeof c=="string"&&c.includes("{{")&&(c=yt(c,t,t.state,t.context),t[r]=c),c==null||typeof c=="function"||typeof c=="object")||c===!1&&!it(_t(r)||r))continue;const i=_t(r)||r;n.setAttribute(i,z(i,c))}}}function $o(t,n){const s=t.node,e=t.__ref;let r=e.__autoGrow;if(!n){if(r&&r.active){try{s.removeEventListener("input",r.resize)}catch{}s.style.height="",r.appliedMax!=null&&s.style.maxHeight===r.appliedMax&&(s.style.maxHeight=""),r.active=!1,r.appliedMax=null,r.lastMeasure=0}return}r||(r=e.__autoGrow={active:!1,appliedMax:null,lastMeasure:0,resize:()=>{if(s.scrollHeight===0&&r.lastMeasure>0)return;s.style.height="auto";const c=s.scrollHeight;s.style.height=c+"px",c>0&&(r.lastMeasure=c)}},e.__eventCleanup||(e.__eventCleanup=[]),e.__eventCleanup.push(()=>{try{s.removeEventListener("input",r.resize)}catch{}})),r.active||(s.addEventListener("input",r.resize),r.active=!0);const o=typeof n=="object"&&n.max!=null?String(n.max):null;o!==r.appliedMax&&(o==null?r.appliedMax!=null&&s.style.maxHeight===r.appliedMax&&(s.style.maxHeight=""):s.style.maxHeight=o,r.appliedMax=o),r.resize()}function Mo(t){if(!t.autoGrow)return;const n=t.node;if(!n||n.tagName!=="TEXTAREA")return;const s=t.__ref,e=t.autoGrow,r=typeof e=="function"?P(t,t.autoGrowDeps,e):null,o=C(()=>{const c=t.autoGrow;let i=c;if(typeof c=="function")try{i=(c===e&&r?r:c)(t,t.state,t.context)}catch{i=null}$o(t,i)},{depth:s.path.length,label:S(s,"autoGrow")});s.__effects||(s.__effects=[]),s.__effects.push(o),r&&(s.__exec.autoGrow=e)}const qt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Qt(t,n){for(const s of Object.keys(t)){if(!Y(s)||qt.has(s))continue;const e=eo(s);if(e){no(e,t,t[s]);continue}let r=t[s];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const c=r;r=function(a){return t.call(c,a)}}if(typeof r!="function")continue;const o=_o(s);oo.has(o)||so(go(o),t,r)}Ro(t)}function Ro(t){const n=t.node;if(!n||!n.addEventListener)return;const s={};let e=!1;for(const y of qt){const h=t[y];typeof h=="function"&&(s[y]=h,e=!0)}if(!e)return;const r=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let c=0,i=0,a=0,f=!1;const u=y=>{const h=y.touches&&y.touches[0]||y.changedTouches&&y.changedTouches[0];h&&(c=h.clientX,i=h.clientY,a=Date.now(),f=!0)},l=y=>{if(!f)return;f=!1;const h=y.changedTouches&&y.changedTouches[0]||y.touches&&y.touches[0];if(!h)return;const _=h.clientX-c,d=h.clientY-i,p=Date.now()-a;if(p>o)return;const g=Math.abs(_),x=Math.abs(d);if(Math.max(g,x)<r)return;let b;if(g>x*1.2)b=_<0?"left":"right";else if(x>g*1.2)b=d<0?"up":"down";else return;const j="onSwipe"+b.charAt(0).toUpperCase()+b.slice(1),v=s[j],w=s.onSwipe;v&&v.call(t,y,t,t.state,t.context),w&&w.call(t,{direction:b,dx:_,dy:d,dt:p,event:y},t,t.state,t.context)};n.addEventListener("touchstart",u,{passive:!0}),n.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{n.removeEventListener("touchstart",u)}catch{}try{n.removeEventListener("touchend",l)}catch{}})}function st(t,n){const s={...t};for(const e in n){const r=s[e],o=n[e];r&&o&&typeof r=="object"&&typeof o=="object"&&!Array.isArray(r)&&!Array.isArray(o)&&typeof r!="function"&&typeof o!="function"?s[e]=st(r,o):s[e]=o}return s}function Et(t,n,s){if(!n||!t.node)return;const e=t.childExtends;if(Array.isArray(n)){const r=t.tag==="fragment",o=t.context?.document||globalThis.document,c=r?null:o?.createDocumentFragment();if(!r&&!c)return;const i=t.childProps,a=t.childrenAs;for(let f=0;f<n.length;f++){let u=n[f];const l=u;(typeof u=="string"||typeof u=="number")&&(u={text:u});let y=i;if(typeof i=="function")try{y=i(t,u)}catch{y=null}if(a==="state"){let d=l;(typeof l=="string"||typeof l=="number")&&(d={value:l,text:l}),u=y?{...y,state:d}:{state:d}}else y&&(u=st(y,u));if(e&&!u.ignoreChildExtends)if(u.extends){const d=Array.isArray(u.extends)?u.extends:[u.extends],p=Array.isArray(e)?e:[e];u={...u,extends:[...p,...d]}}else u={...u,extends:e};const h=u?.key||l&&typeof l=="object"&&l.key||`${f}`;let _;try{_=H(u,t,h,s)}catch(d){if(typeof console<"u"&&console.error){const p=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${h}" failed to construct at ${p} (initial render, skipping this row):`,d?.message||d)}continue}!r&&_?.node&&c.appendChild(_.node)}return r||t.node.appendChild(c),!0}if(typeof n=="string"){const r=Ut(n,t);if(Array.isArray(r))return Et(t,r,s)}if(typeof n=="object")for(const r in n){if(K.has(r))continue;let o=n[r];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=st(t.childProps,o)),e&&!o.ignoreChildExtends)if(o.extends){const c=Array.isArray(o.extends)?o.extends:[o.extends],i=Array.isArray(e)?e:[e];o={...o,extends:[...i,...c]}}else o={...o,extends:e};H(o,t,r,s)}}}function Tt(t,n){const s=t.node;if(!s||s.tagName!=="SELECT")return;const e=s.options;if(!e||!e.length)return;const r=t.__ref,o=r&&r.__exec&&r.__exec.value,c=typeof o=="function",i=t.value!=null&&typeof t.value!="function";if(c||i){let u;if(c)try{u=o(t,t.state,t.context)}catch{return}else u=t.value;const l=u==null?"":String(u);s.value!==l&&(s.value=l);return}const a=n||!(r&&r.__selectSynced);if(r&&(r.__selectSynced=!0),!a)return;let f=-1;for(let u=0;u<e.length;u++)e[u].defaultSelected&&(f=u);f>=0&&s.selectedIndex!==f&&(s.selectedIndex=f)}function Zt(t,n){let{children:s,content:e}=t;const r=t.childExtends;if(typeof s=="function"){const i=s;try{s=i(t,t.state,t.context)}catch(y){if(s=void 0,typeof console<"u"&&console.error){const h=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${h} (initial run, treating as empty):`,y?.message||y)}}t.children=s;const a=t.__ref;let f=!1;const u=P(t,t.childrenDeps,i),l=C(()=>{const y=f;f=!0;let h;try{h=u(t,t.state,t.context)}catch(v){if(typeof console<"u"&&console.error){const w=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${w}${y?"":" (initial tracking run)"}:`,v?.message||v)}return}if(!y||h===t.children)return;t.children=h;const _=typeof t.onContentUpdate=="function",d=_?[]:null,p=_?[]:null,g=_?[]:null;if(Array.isArray(h)&&t.childrenAs==="state"){const v=t.childProps,w=[],$=new Map;for(let A=0;A<h.length;A++){const M=h[A];let k=v;if(typeof v=="function")try{k=v(t,M)}catch{k=null}const F=k&&k.key||M&&M.key||`${A}`;w.push(F),$.set(F,{rawChild:M,childProps:k})}const G=new Set(w),V=a.__children.slice();for(const A of V)if(!G.has(A)){const M=t[A];M?.remove&&M.remove(),delete t[A],p&&p.push(A)}const Z=t.childExtends,nt=t.tag==="fragment",Jt=t.context?.document||globalThis.document,X=nt?null:Jt?.createDocumentFragment(),ft=new Set;for(const A of w){const M=$.get(A),k=M.rawChild,F=t[A];if(F&&F.state){if(k&&typeof k=="object"){const D=F.state,W=D.$replace||D.replace,Lt=D.$update||D.update;try{if(typeof W=="function")W.call(D,k);else if(typeof Lt=="function"){for(const R in D)if(!(R==="__element"||R==="root"||R==="parent"||R==="update")&&!Object.prototype.hasOwnProperty.call(k,R))try{D[R]=void 0}catch{}Lt.call(D,k)}else for(const R in k)D[R]=k[R]}catch(R){if(typeof console<"u"&&console.error){const mt=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${A}" failed to patch at ${mt} (reconcile, keeping its previous data for this pass):`,R?.message||R)}}}g&&g.push(A);continue}let ut=k;(typeof k=="string"||typeof k=="number")&&(ut={value:k,text:k});const Dt=M.childProps;let N=Dt?{...Dt,state:ut}:{state:ut};if(Z&&!N.ignoreChildExtends)if(N.extends){const D=Array.isArray(N.extends)?N.extends:[N.extends],W=Array.isArray(Z)?Z:[Z];N={...N,extends:[...W,...D]}}else N={...N,extends:Z};let dt;try{dt=H(N,t,A,n)}catch(D){if(typeof console<"u"&&console.error){const W=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${A}" failed to construct at ${W} (reconcile, skipping this row):`,D?.message||D)}ft.add(A);continue}!nt&&dt?.node&&X&&X.appendChild(dt.node),d&&d.push(A)}if(!nt&&X&&X.childNodes.length&&t.node&&t.node.appendChild(X),!nt&&t.node){let A=null;for(const M of w){const k=t[M]?.node;if(!k)continue;const F=A?A.nextSibling:t.node.firstChild;k!==F&&t.node.insertBefore(k,F),A=k}}a.__children=ft.size?w.filter(A=>!ft.has(A)):w,_&&(d.length||p.length)&&Ft(t,{added:d,removed:p,kept:g}),Tt(t,!1);return}const j=_?[...a.__children]:null;for(const v of[...a.__children]){const w=t[v];w?.remove&&w.remove(),delete t[v]}a.__children=[],Et(t,h,n),Tt(t,!1),_&&Ft(t,{added:[...a.__children],removed:j,kept:[]})},{depth:a.path.length,label:S(a,"children")});a.__effects.push(l)}const o=Et(t,s,n);if(e!=null&&!(e&&e.__ref)){let i=e;if(typeof i=="string"||typeof i=="number"?i={text:i}:typeof i!="object"&&(i={}),t.childProps&&(i=st(t.childProps,i)),r&&!i.ignoreChildExtends)if(i.extends){const a=Array.isArray(i.extends)?i.extends:[i.extends],f=Array.isArray(r)?r:[r];i={...i,extends:[...f,...a]}}else i={...i,extends:r};H(i,t,"content",n)}if(s&&!o)return;const c=t.context?.components||{};{const i=Object.keys(t);for(let a=0;a<i.length;a++){const f=i[a];if(!f.endsWith("Extends")||typeof t[f]!="string")continue;const u=f.slice(0,-7);if(!u||u.charCodeAt(0)<65||u.charCodeAt(0)>90)continue;const l={extends:t[f]};delete t[f];for(let y=a+1;y<i.length;y++){const h=i[y],_=h.charCodeAt(0);if(_>=65&&_<=90||K.has(h)||typeof t[h]=="function"&&(h.startsWith("on")||h.startsWith(".")))break;const d=t[h];d!==void 0&&(l[h]=d,delete t[h])}t[u]&&typeof t[u]=="object"?t[u]={...l,...t[u]}:t[u]=l}}for(const i of Object.keys(t)){if(K.has(i)||typeof t[i]!="object"||t[i]===null)continue;const a=i.charCodeAt(0);if(a<65||a>90)continue;let f=t[i];if(!f.__ref){if(!f.extends&&!f.extend){const u=c[i]||c[`smbls.${i}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=st(t.childProps,f)),r&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],l=Array.isArray(r)?r:[r];f={...f,extends:[...l,...u]}}else f={...f,extends:r};H(f,t,i,n)}}}function Xt(t,n,s){const{node:e}=t;if(!e)return;e.ref=t;const r=n?.tag==="fragment"?n.__ref?.__fragmentAnchor:null;if(r){const c=r.parentNode;if(c){if(s?.position==="before"&&s.node)c.insertBefore(e,s.node);else if(s?.position==="after"&&s.node){const i=s.node.nextSibling;c.insertBefore(e,i||r)}else c.insertBefore(e,r);return}}const o=n?.node||(n?.nodeType?n:null);if(o)if(s?.position==="before"&&s.node)o.insertBefore(e,s.node);else if(s?.position==="after"&&s.node){const c=s.node.nextSibling;c?o.insertBefore(e,c):o.appendChild(e)}else o.appendChild(e)}const Pt=3;function No(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=Pt?!1:(t.__inBeforeUpdate=!0,!0)}function at(t,n){t&&(t.__inBeforeUpdate=!1,n?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===Pt&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${Pt}x in a row on this element \u2014 pausing automatic retries until a future prop/state change re-arms it.`)):t.__beforeUpdateFailCount=0)}function I(t,n,s){const e=t.charAt(0).toLowerCase()+t.slice(1);n.context?.plugins?.length&&U(e,n,s);const r="on"+t,o=n[r];if(typeof o=="function"){const a=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(a){if(n.__ref[a])return!0;n.__ref[a]=!0}const f=n.context?.designSystem;f&&L(f);let u=!!a;try{const l=o(n,n.state,n.context,s);if(l&&typeof l.then=="function"){const y=n.__ref;return l.catch(h=>{n.context?.plugins?.length&&U("error",n,{hook:r,error:h})||console.error(`[DOMQL] Lifecycle "${r}" error:`,h)}).finally(()=>{a&&y&&(y[a]=!1)}),u=!1,!0}if(l===!1)return!1}catch(l){if(n.context?.plugins?.length&&U("error",n,{hook:r,error:l})||console.error(`[DOMQL] Lifecycle "${r}" error:`,l),n.context?.strictMode)throw l}finally{f&&O(),u&&n.__ref&&(n.__ref[a]=!1)}}return!0}var ns=H;export{Pt as BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES,No as acquireBeforeUpdateGuard,H as create,ns as default,bt as flushMounts,at as releaseBeforeUpdateGuard,ct as writeElementText};
|
package/dist/esm/src/delegate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DELEGATED_EVENTS as
|
|
1
|
+
import{DELEGATED_EVENTS as b,LIFECYCLE_EVENTS as L,PASSIVE_EVENTS as p,NON_BUBBLING_EVENTS as v}from"./registry.js";import{pushConfig as D,popConfig as E}from"@symbo.ls/scratch";const a=new WeakMap,C={passive:!0},S={passive:!0,capture:!0},f=(t,e)=>p.has(t)?e?S:C:e||!1;function _(t){let e=a.get(t);return e||(e={handlers:new Map,installed:new Set},a.set(t,e)),e}function y(t,e){const r=_(e);if(r.installed.has(t))return;r.installed.add(t);const n=t==="focus"||t==="blur"||t==="focusin"||t==="focusout"||t==="mouseenter"||t==="mouseleave",s=t==="mouseenter"||t==="mouseleave";e.addEventListener(t,o=>{let c=o.target;for(;c&&c!==e;){const i=r.handlers.get(t);if(i){const l=i.get(c);if(l){if(s&&o.relatedTarget&&c.contains(o.relatedTarget)){c=c.parentNode;continue}if(l(o),o.cancelBubble)return}}c=c.parentNode}},f(t,n))}function T(t,e,r,n){n||(n=e.ownerDocument?.documentElement||e.getRootNode());const s=_(n);y(t,n),s.handlers.has(t)||s.handlers.set(t,new WeakMap),s.handlers.get(t).set(e,r)}function I(t,e,r){r||(r=e.ownerDocument?.documentElement||e.getRootNode());const n=a.get(r);if(!n)return;const s=n.handlers.get(t);s&&s.delete(e)}function g(t){return b.has(t)&&!L.has(t)}function h(t,e){const{context:r}=t,n=r?.designSystem;return s=>{n&&D(n);try{const o=e.call(t,s,t,t.state,r);if(o&&typeof o.then=="function"){o.catch(c=>{t.error=c,console.error("[DOMQL] Async event error:",c)}).finally(()=>{n&&E()});return}}catch(o){if(t.error=o,console.error("[DOMQL] Event error:",o),r?.strictMode)throw o}n&&E()}}function G(t,e,r){const{node:n,context:s}=e;if(!n)return;const o=h(e,r),c=v.has(t);if(!c&&g(t)){const i=s?.rootNode||n.ownerDocument?.documentElement;T(t,n,o,i)}else n.addEventListener(t,o,f(t,!1));e.__ref.__eventCleanup||(e.__ref.__eventCleanup=[]),e.__ref.__eventCleanup.push(()=>{if(!c&&g(t)){const i=s?.rootNode||n.ownerDocument?.documentElement;I(t,n,i)}else n.removeEventListener(t,o,f(t,!1))})}const d=[["onDocument","document"],["onWindow","window"]];function O(t){if(typeof t!="string")return null;for(let e=0;e<d.length;e++){const r=d[e][0];if(t.length<=r.length||!t.startsWith(r))continue;const n=t.charCodeAt(r.length);if(!(n<65||n>90))return{target:d[e][1],eventName:t.slice(r.length).toLowerCase()}}return null}const x=/^[A-Za-z_$][\w$]*$/;function A(t,e,r){let n=e,s=!1,o,c=!1;if(e&&typeof e=="object"&&typeof e!="function"&&(n=e.handler,s=!!e.capture,c=!!e.once,typeof e.passive=="boolean"&&(o=e.passive)),typeof n=="string"&&x.test(n)){const i=n;n=function(u){return t.call(i,u)}}return typeof n!="function"?null:(o===void 0&&(o=p.has(r)),{handler:n,capture:s,passive:o,once:c})}function B(t,e){const r=t.node?.ownerDocument||t.context?.document||(typeof document<"u"?document:null);if(!r||typeof r.addEventListener!="function")return null;if(e==="document")return r;const n=r.defaultView||(typeof window<"u"?window:null);return n&&typeof n.addEventListener=="function"?n:null}function M(t){const e=t.node;if(!e)return!1;const r=e.nodeType===11?t.__ref?.__fragmentAnchor:e;return r?r.isConnected!==!1:!1}function P(t,e,r){const n=e.__ref;if(!n)return;const s=A(e,r,t.eventName);if(!s)return;const o=B(e,t.target);if(!o)return;n.__globalEvents||(n.__globalEvents=new Map);const c=t.target+":"+t.eventName+":"+(s.capture?1:0);if(n.__globalEvents.has(c))return;const i=h(e,s.handler),l=w=>{M(e)&&i(w)},u={capture:s.capture,passive:s.passive,once:s.once};o.addEventListener(t.eventName,l,u),n.__globalEvents.set(c,{target:o,eventName:t.eventName,listener:l,options:u}),n.__eventCleanup||(n.__eventCleanup=[]),n.__eventCleanup.push(()=>{o.removeEventListener(t.eventName,l,u),n.__globalEvents&&n.__globalEvents.delete(c)})}export{T as addDelegatedEvent,O as globalEventKeyInfo,g as isDelegatable,G as registerEvent,P as registerGlobalEvent,I as removeDelegatedEvent};
|
package/dist/esm/src/dispose.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function n(r){if(!r)return;const f=r.__ref;if(!f)return;try{typeof r.onBeforeRemove=="function"&&r.onBeforeRemove(r,r.state,r.context)}catch(o){console.error("[smbls] onBeforeRemove error:",o)}if(f.__effects){for(let o=0;o<f.__effects.length;o++)f.__effects[o].dispose();f.__effects.length=0}if(f.__eventCleanup){for(let o=0;o<f.__eventCleanup.length;o++)f.__eventCleanup[o]();f.__eventCleanup.length=0}if(f.__children){const o=f.__children.slice();f.__children.length=0;for(let _=0;_<o.length;_++){const t=r[o[_]];t&&t.__ref&&n(t)}}r.node?.parentNode?r.node.remove():r.tag==="fragment"&&f.__fragmentAnchor?.parentNode&&f.__fragmentAnchor.remove();const e=r.state?.$destroy||r.state?.destroy;if(typeof e=="function"&&r.state.__element===r&&e.call(r.state),r.parent?.__ref?.__children){const o=r.parent.__ref.__children.indexOf(r.key);o!==-1&&r.parent.__ref.__children.splice(o,1),delete r.parent[r.key]}try{typeof r.onRemove=="function"&&r.onRemove(r)}catch(o){console.error("[smbls] onRemove error:",o)}r.node=null,r.parent=null,r.__ref=null}function i(){n(this)}export{n as dispose,i as remove};
|
package/dist/esm/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{create as t,default as r,flushMounts as E}from"./create.js";import{update as
|
|
1
|
+
import{create as t,default as r,flushMounts as E}from"./create.js";import{update as d}from"./update.js";import{dispose as p,remove as s}from"./dispose.js";import{REGISTRY as m,LIFECYCLE_EVENTS as x,DELEGATED_EVENTS as T,NON_BUBBLING_EVENTS as g,MIXINS as n}from"./registry.js";import{addDelegatedEvent as v,removeDelegatedEvent as S,registerEvent as i,registerGlobalEvent as G,globalEventKeyInfo as I}from"./delegate.js";import{cacheNode as L,detectTag as V,createHTMLNode as _,isValidTag as h,isSvgTag as u,SVG_TAGS as D}from"./cache.js";import{applyExtends as B}from"./extends.js";import{addMethods as b,refreshContextProto as y}from"./methods.js";export{T as DELEGATED_EVENTS,x as LIFECYCLE_EVENTS,n as MIXINS,g as NON_BUBBLING_EVENTS,m as REGISTRY,D as SVG_TAGS,v as addDelegatedEvent,b as addMethods,B as applyExtends,L as cacheNode,t as create,_ as createHTMLNode,r as default,V as detectTag,p as dispose,E as flushMounts,I as globalEventKeyInfo,u as isSvgTag,h as isValidTag,y as refreshContextProto,i as registerEvent,G as registerGlobalEvent,s as remove,S as removeDelegatedEvent,d as update};
|
package/dist/esm/src/update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{batch as a,isStore as y}from"@symbo.ls/signal";import{REGISTRY as _}from"./registry.js";import{create as h,acquireBeforeUpdateGuard as x,releaseBeforeUpdateGuard as s}from"./create.js";import{runPluginHook as l}from"@symbo.ls/utils/function.js";import{serializeAttrValue as
|
|
1
|
+
import{batch as a,isStore as y}from"@symbo.ls/signal";import{REGISTRY as _}from"./registry.js";import{create as h,acquireBeforeUpdateGuard as x,releaseBeforeUpdateGuard as s,writeElementText as b}from"./create.js";import{runPluginHook as l}from"@symbo.ls/utils/function.js";import{serializeAttrValue as g,isEnumeratedTrueFalseAttr as p}from"attrs-in-props";function A(n={},r={}){const e=this,f=e.__ref;if(!f)return;if((typeof n=="string"||typeof n=="number")&&(n={text:n}),!r.preventListeners&&typeof e.onBeforeUpdate=="function"&&x(f))try{const t=e.onBeforeUpdate(e,e.state,e.context,r);if(t&&typeof t.then=="function")t.then(()=>s(f,!1),o=>{s(f,!0),e.context?.plugins?.length&&l("error",e,{hook:"onBeforeUpdate",error:o})||console.error("[DOMQL] onBeforeUpdate error:",o)});else if(s(f,!1),t===!1)return e}catch(t){throw s(f,!0),t}const d=!n||Object.keys(n).length===0;if(a(()=>{if(n.state&&y(e.state)&&e.state.$update(n.state),n.text!==void 0&&(e.text=n.text,!f.__exec.text&&e.node&&b(e,n.text??"")),n.html!==void 0&&(e.html=n.html,!f.__exec.html&&e.node&&(e.node.innerHTML=n.html)),n.style&&e.node?.style){if(!f.__exec.style)for(const t in n.style){const o=n.style[t];if(o==null)continue;const i=t.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),c=String(o).replace(/\s*!important\s*$/,"");e.node.style.setProperty(i,c,"important")}e.style||(e.style={}),Object.assign(e.style,n.style)}if(n.attr&&e.node?.setAttribute){for(const t in n.attr){const o=n.attr[t];o==null||o===!1&&!p(t)?e.node.removeAttribute(t):typeof o!="function"&&typeof o!="object"&&e.node.setAttribute(t,g(t,o))}e.attr||(e.attr={}),Object.assign(e.attr,n.attr)}if(n.data&&e.node?.dataset){for(const t in n.data)e.node.dataset[t]=n.data[t];e.data||(e.data={}),Object.assign(e.data,n.data)}for(const t in n){if(_.has(t)||t==="state")continue;const o=n[t],i=e[t];if(i&&i.__ref&&typeof i.update=="function")i.update(o,r);else if(typeof o=="object"&&o!==null){const c=t.charCodeAt(0);c>=65&&c<=90&&h(o,e,t,r)}else t!=="text"&&t!=="html"&&t!=="style"&&t!=="attr"&&t!=="data"&&(e[t]=o)}}),e.node&&d&&f.__effects&&f.__effects.length)for(let t=0;t<f.__effects.length;t++){const o=f.__effects[t];o&&!o._disposed&&!o._isSubscribeToEffect&&typeof o._execute=="function"&&o._execute()}else if(e.node&&f.__conditionalRunners)for(const t of f.__conditionalRunners)t();return l("update",e),!r.preventListeners&&typeof e.onUpdate=="function"&&e.onUpdate(e,e.state,e.context,r),e}var E=A;export{E as default,A as update};
|