@symbo.ls/element 3.14.756 → 3.14.765
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/src/create.js +4 -4
- package/dist/esm/src/create.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var zt=Object.prototype.hasOwnProperty;var Yt=(t,s)=>{for(var n in s)ut(t,n,{get:s[n],enumerable:!0})},Zt=(t,s,n,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of Gt(s))!zt.call(t,i)&&i!==n&&ut(t,i,{get:()=>s[i],enumerable:!(r=Ht(s,i))||r.enumerable});return t};var qt=t=>Zt(ut({},"__esModule",{value:!0}),t);var bo={};Yt(bo,{BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES:()=>it,acquireBeforeUpdateGuard:()=>Vt,create:()=>
|
|
1
|
+
"use strict";var ut=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var zt=Object.prototype.hasOwnProperty;var Yt=(t,s)=>{for(var n in s)ut(t,n,{get:s[n],enumerable:!0})},Zt=(t,s,n,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of Gt(s))!zt.call(t,i)&&i!==n&&ut(t,i,{get:()=>s[i],enumerable:!(r=Ht(s,i))||r.enumerable});return t};var qt=t=>Zt(ut({},"__esModule",{value:!0}),t);var bo={};Yt(bo,{BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES:()=>it,acquireBeforeUpdateGuard:()=>Vt,create:()=>B,default:()=>go,flushMounts:()=>kt,releaseBeforeUpdateGuard:()=>ot});module.exports=qt(bo);var P=require("@symbo.ls/signal"),v=require("@symbo.ls/signal"),W=require("./cache.js"),T=require("./registry.js"),It=require("./delegate.js"),Bt=require("./extends.js"),Kt=require("./methods.js"),ko=require("./dispose.js"),rt=require("./devRuntime.js"),ct=require("@symbo.ls/utils"),N=require("@symbo.ls/utils/function.js"),q=require("@symbo.ls/state"),b=require("css-in-props"),K=require("@symbo.ls/css"),A=require("@symbo.ls/scratch"),$=require("attrs-in-props");let Qt=1;const nt=[];let dt=!1;function Xt(){dt||(dt=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(kt):setTimeout(kt,0))}function kt(){if(dt=!1,!nt.length)return;const t=nt.splice(0,nt.length);for(let s=0;s<t.length;s++){const n=t[s];!n.node||!n.node.isConnected||I("Mounted",n,n.__ref?.__mountOptions||{})}}function wt(t,s){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=s,nt.push(t),Xt())}function jt(t,s){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&(0,N.runPluginHook)("contentUpdate",t,s);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{t.onContentUpdate(t,t.state,t.context,s)}catch(r){if(t.context?.plugins?.length&&(0,N.runPluginHook)("error",t,{hook:"onContentUpdate",error:r})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',r),t.context?.strictMode)throw r}finally{n&&(0,A.popConfig)()}}function z(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function Jt(t){return t.charAt(2).toLowerCase()+t.slice(3)}function mt(t){return t.toLowerCase()}function lt(t){const s=t.charCodeAt(0);return s===58||s===64||s===38}function J(t,s){const n={...t};for(const r in s){const i=n[r],o=s[r];i&&o&&typeof i=="object"&&typeof o=="object"&&!Array.isArray(i)&&!Array.isArray(o)&&typeof i!="function"&&typeof o!="function"?n[r]=J(i,o):n[r]=o}return n}function B(t,s,n,r={},i){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${Qt++}`,o.parent=s||null,o.context=t.context||s?.context||r.context||{},o.context.__create||(o.context.__create=B);const a=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:s?.__ref?.root||o,path:s?.__ref?.path?[...s.__ref.path,o.key]:[o.key],origin:t};if(n&&!t.extends&&!t.extend){const l=n.indexOf("_");if(l>0){const _=n.substring(0,l),g=o.context?.components;g&&(g[_]||g["smbls."+_])?t={...t,extends:_}:g&&(0,rt.isLoudDevRuntime)()&&/^[A-Z]\w*_\d+$/.test(n)&&console.warn(`[smbls] auto-extend: key "${n}" looks like a multi-instance (${_}_N) but neither "${_}" nor "smbls.${_}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}(0,Bt.applyExtends)(o,t,r);const c=new Set(["childProps","attr","style","scope","data"]),e=o.props&&typeof o.props=="object"?o.props:null;for(const l in t){if(l==="parent"||l==="node"||l==="__ref"||l==="extends"||l==="context"||l==="props")continue;const _=t[l],g=o[l],C=g&&_&&typeof g=="object"&&typeof _=="object"&&!Array.isArray(g)&&!Array.isArray(_)&&typeof g!="function"&&typeof _!="function";C&&l.charCodeAt(0)>=65&&l.charCodeAt(0)<=90?o[l]=J(g,_):C&&c.has(l)?o[l]={...g,..._}:C&<(l)?o[l]=J(g,_):o[l]=_}function f(l){for(const _ in l){const g=l[_],C=o[_],x=C&&g&&typeof C=="object"&&typeof g=="object"&&!Array.isArray(C)&&!Array.isArray(g)&&typeof C!="function"&&typeof g!="function";x&&_.charCodeAt(0)>=65&&_.charCodeAt(0)<=90?o[_]=J(C,g):x&&c.has(_)?o[_]={...C,...g}:x&<(_)?o[_]=J(C,g):o[_]=g}}e&&f(e),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,d=s?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,y=d||p||null;if(t.scope!==void 0||u){const l={};u&&Object.assign(l,u),t.scope!==void 0&&Object.assign(l,t.scope),o.scope=(0,P.createScopeStore)(l,y)}else y&&(o.scope=y);if(t.if!==void 0&&(o.if=t.if),(0,Kt.addMethods)(o),to(o,s,t),o.if!=null){let l;if(typeof o.if=="function")try{l=o.if(o,o.state,o.context)}catch(_){if(l=!1,a.__ifError=_,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,_?.message||_)}}else l=o.if;a.__if=!!l}if(a.__if)typeof o.if=="function"&&(a.__ifInitialized=!0);else return s&&(s[o.key]=o),typeof o.if=="function"&&Lt(o,a,o.if),o;o.tag||(o.tag=(0,W.detectTag)(o)),I("Init",o,r);const h=o.node=(0,W.cacheNode)(o);if(!h)return o;if(o.tag==="fragment"){const _=(o.context?.document||globalThis.document).createComment("");h.appendChild(_),a.__fragmentAnchor=_}I("AttachNode",o,r),h.setAttribute&&o.key&&h.setAttribute("data-key",o.key),s&&(s[o.key]=o,s.__ref?.__children&&(s.__ref.__children.includes(o.key)||s.__ref.__children.push(o.key))),h.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&h.setAttribute("data-smbls-app",o.context.key),o.id&&h.setAttribute&&(h.id=o.id),Nt(o,r),Pt(o),yt(o),Tt(o),ho(o);try{Mt(o,r)}catch(l){if(typeof console<"u"&&console.error){const _=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${_}:`,l?.message||l,l?.stack?`
|
|
2
2
|
`+l.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(Ct(o,!0),Ut(o,s,i),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),wt(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 to(t,s,n){const r=!s,i=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&i&&t.context?.state,a=n.state!==void 0&&!o?n.state:t.state&&!(0,P.isStore)(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,(0,q.applyStateMethods)(t,t.state);else if(t.context?.state){const c=t.context.state,e={...c},f=t.context?.polyglot;if(f?.translations){const u=c.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=(0,P.isStore)(e)?e:(0,P.createStore)(e),t.state.__element=t,t.state.root=t.state,(0,q.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,q.applyStateMethods)(t,t.state);return}if(typeof a=="string"){if(t.state=Et(a,s),t.state&&typeof t.state=="object"&&!(0,P.isStore)(t.state)){const c=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:c,enumerable:!1,configurable:!0,writable:!0})}(0,q.applyStateMethods)(t,t.state);return}if(typeof a=="function"){const c=a(t,s?.state);t.state=(0,P.isStore)(c)?c:(0,P.createStore)(c||{})}else(0,P.isStore)(a)?t.state=a:t.state=(0,P.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,q.applyStateMethods)(t,t.state)}function pt(t,s){if(!s)return t;const n=s.split("/");let r=t;for(const i of n){if(r==null)return{};r=r[i]}return r??{}}function Et(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const i=t.slice(3);return i?pt(s.state,i):s.state??{}}if(t.startsWith("~/")){const i=s.state?.root||s.state,o=t.slice(2);return o?pt(i,o):i??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=pt(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=s.context?.polyglot;if(r?.translations){const i=s.state?.root?.lang||r.defaultLang||"en",o=r.translations[i];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}const oo=new Set(["s","state","ctx","context"]);function so(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 no(t){if(typeof t!="function"||t.length!==2)return!1;const s=so(t);if(s.length<2)return!1;const n=s[1].replace(/[{}[\]]/g,"").trim();return n.length>0&&!oo.has(n)}function ro(t){const s=t.__ref,n=t.tag||"div",r=t.context?.designSystem,i=[],o=Object.keys(t);for(let a=0;a<o.length;a++){const c=o[a];if(typeof t[c]!="function"||T.REGISTRY.has(c))continue;const e=c.charCodeAt(0);e>=65&&e<=90||z(c)||b.CSS_PROPS_REGISTRY[c]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(c)||(0,$.checkAttributeByTagName)(n,c)||((0,rt.isLoudDevRuntime)()&&no(t[c])&&console.warn(`[smbls] custom prop "${c}"${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('${c}', \u2026) instead of reading el.${c}(\u2026) directly (see RULES.md Rule 8).`),i.push({prop:c,fn:t[c]}))}for(let a=0;a<i.length;a++){const{prop:c,fn:e}=i[a];s.__exec[c]=e,Object.defineProperty(t,c,{get(){r&&(0,A.pushConfig)(r);try{return e(t,t.state,t.context)}catch{return}finally{r&&(0,A.popConfig)()}},set(f){delete s.__exec[c],Object.defineProperty(t,c,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function co(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 co(t,s),n.apply(this,r)}}function m(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Pt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(ro(t),typeof t.text=="function"){const o=t.text,a=L(t,t.textDeps,o),c=(0,v.createEffect)(()=>{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=ct.replaceLiteralsWithObjectFields.call(t,e,t.state)),t.tag==="string"?t.node.nodeValue=e:t.node.textContent=e)}catch{}},{depth:n.path.length});n.__effects.push(c),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 c=ct.replaceLiteralsWithObjectFields.call(t,o,t.state);c!=null&&(t.text=c),t.node&&(t.tag==="string"?t.node.nodeValue=c??"":t.node.textContent=c??"")},{depth:n.path.length});n.__effects.push(a),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!T.REGISTRY.has(o)&&!z(o)&&!n.__exec[o]){if(b.CSS_PROPS_REGISTRY[o]){const a=t[o],c=L(t,t[o+"Deps"],a),e=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=c(t,t.state,t.context),y=b.CSS_PROPS_REGISTRY[e](p,t,t.state,t.context);if(y&&t.node){const h=ht(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&&(0,A.popConfig)()}},{depth:n.path.length});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],c=L(t,t[o+"Deps"],a),e=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=c(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&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=L(t,t.htmlDeps,o),c=(0,v.createEffect)(()=>{const e=t.context?.designSystem;e&&(0,A.pushConfig)(e);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{e&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(c),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=L(t,t.valueDeps,o),c=(0,v.createEffect)(()=>{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});n.__effects.push(c),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=L(t,t.styleDeps,o);let c;const e=(0,v.createEffect)(()=>{const f=a(t,t.state,t.context),u=ht(f);(u===null||u!==c)&&(c=u,Y(t.node,f))},{depth:n.path.length});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 c=L(t,m(t.styleDeps,o),a);let e;const f=(0,v.createEffect)(()=>{try{const u=c(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});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,m(t.attrDeps,o),t.attr[o]),c=o,e=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f))}catch{}},{depth:n.path.length});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,m(t.ariaDeps,o),t.aria[o]),c="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),e=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f)}catch{}},{depth:n.path.length});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,m(t.dataDeps,o),t.data[o]),e="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(e):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(e,u===!0?"":u)}catch{}},{depth:n.path.length});n.__effects.push(f)}const i=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(i)for(const o in i){if(typeof i[o]!="function")continue;const a=L(t,m(t.classDeps,o),i[o]),c=(0,v.createEffect)(()=>{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});n.__effects.push(c)}!r&&typeof t.if=="function"&&Lt(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||T.REGISTRY.has(o)||typeof t[o]!="function")continue;const a=o.charCodeAt(0);if(a>=65&&a<=90||z(o))continue;const c=t[o];n.__exec[o]=c;const e=t.tag||"div";if((0,$.checkAttributeByTagName)(e,o)&&!b.CSS_PROPS_REGISTRY[o]&&!(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const f=(0,$.camelToAttr)(o)||o,u=L(t,t[o+"Deps"],c),d=(0,v.createEffect)(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(d)}}if(ao(t),lo(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let c=!1,e=[];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(!c){c=!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&&(0,A.pushConfig)(y);try{o(t,t.state,t.context,{prev:p,next:u})}catch(h){if(t.context?.plugins?.length&&(0,N.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});n.__effects.push(f)}uo(t)}function Ot(t){const s=t.parent,n=s?.node;if(!n||!t.node){Ut(t,t.parent);return}let r=null;const i=Object.keys(s),o=i.indexOf(t.key);for(let a=o+1;a<i.length;a++){const c=s[i[a]];if(c?.node?.parentNode===n){r=c.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function Lt(t,s,n){const r=L(t,t.ifDeps,n),i=(0,v.createEffect)(()=>{let o;try{o=r(t,t.state,t.context)}catch(c){if(o=!1,s.__ifError=c,typeof console<"u"&&console.warn){const e=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${e} \u2014 treating as false:`,c?.message||c)}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,W.cacheNode)(t)),t.node&&(t.node.ref=t),Ot(t),yt(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=(0,W.detectTag)(t)),I("Init",t,{}),t.node||(t.node=(0,W.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 e=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(e),s.__fragmentAnchor=e}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),Nt(t,{}),Pt(t,{skipIfEffect:!0}),yt(t),Tt(t),Mt(t,{}),Ot(t),wt(t,{})}},{depth:s.path.length});s.__effects.push(i)}function yt(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),yo(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||s.setAttribute&&s.setAttribute(n,r===!0?"":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 i=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];i&&s.classList.add(typeof i=="string"?i:r)}}}}function ht(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 i=s[r];if(i!=null){if(r.charAt(0)==="&"&&typeof i=="object"){n||(n={}),n[r]=i;continue}try{const o=String(i),a=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),c=o.trim(),e=/\s*!important\s*$/.test(c),f=c.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,e?"important":"")}catch{}}}n&&eo(t,n)}let io=0;function eo(t,s){const n=`_ds${io++}`;t.classList.add(n);const r=t.ownerDocument;let i=r.querySelector("style[data-smbls-scoped]");i||(i=r.createElement("style"),i.setAttribute("data-smbls-scoped",""),r.head.appendChild(i));let o="";for(const a in s){const c="."+n,e=a.replace(/&/g,c).split(",").map(u=>{const d=u.trim();return d.includes(c)?d:c+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+=(0,B.wrapHoverRule)(`${h} { ${l} }`,h)+`
|
|
5
|
-
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${y};`}u&&(o+=(0,
|
|
6
|
-
`),d&&(o+=d)}}o&&(i.textContent+=o)}function ao(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 i=s[r];if(typeof i!="string"||i.length===0)continue;const o=i.split("."),a=o[0],c=o.slice(1),e={value:!1},f=(0,v.createEffect)(()=>{const u=t.state&&((0,P.isStore)(t.state)?t.state.root:null);if(!u||!(0,P.isStore)(u))return;let d=u;d=d[a];for(let y=0;y<c.length&&!(d==null||typeof d!="object");y++)if((0,P.isStore)(d))d=d[c[y]];else break;if(!e.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&(0,A.pushConfig)(y);try{if(Vt(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>tt(n,!1),l=>{tt(n,!0),t.context?.plugins?.length&&(0,N.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(tt(n,!1),h===!1&&(p=!0))}}catch(h){tt(n,!0),t.context?.plugins?.length&&(0,N.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,N.runPluginHook)("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&(0,A.popConfig)()}}},{depth:n.path.length});e.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function _t(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 fo(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 Z(t,s,n){const r={},i=new Set,o=(a,c,e)=>{const f=e?new Set(Object.keys(r)):null;if(b.CSS_PROPS_REGISTRY[a]){const u=b.CSS_PROPS_REGISTRY[a](c,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]=c;if(e)for(const u in r)f.has(u)||i.add(u)};for(const a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;let c=t[a];if(typeof c=="function"&&(c=c(s,s.state,s.context)),c==null||typeof c=="function")continue;if(typeof c=="object"&&!Array.isArray(c)){if(a==="style"){for(const d in c){let p=c[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(_t(a,s)){const d=Z(c,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)()&&fo(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=Z(c,s,!1);Object.keys(u).length&&(r[f]=u);continue}const e=typeof s[a]=="function"&&(b.CSS_PROPS_REGISTRY[a]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(a));o(a,c,e)}if(n)for(const a in r)i.add(a);for(const a of i){const c=r[a];typeof c=="string"&&!c.includes("!important")&&(r[a]=c+" !important")}return r}function gt(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)&>(t[n],s+1))return!0}return!1}function Dt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(_t(t,n)){const o=Z(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 i=Z(s,n,!1);return Object.keys(i).length?{cssProp:r,block:i}:null}function uo(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!lt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!gt(r))continue;let i=null,o;const a=(0,v.createEffect)(()=>{if(!t.node)return;const c=t.context?.designSystem;c&&(0,A.pushConfig)(c);let e,f=!1;try{const u=Dt(n,r,t),d=u?ht(u.block)+"::"+u.cssProp:null;if(d!==null&&d===o)f=!0;else if(o=d,u){const p=(0,B.css)({[u.cssProp]:u.block},null,t.context?.cssPrefix);e=p?p.split(" ").filter(Boolean):null}else e=null}finally{c&&(0,A.popConfig)()}if(!(f||!t.node.classList)){if(i)for(const u of i)t.node.classList.remove(u);if(e&&e.length)for(const u of e)t.node.classList.add(u);i=e}},{depth:s.path.length});s.__effects.push(a)}}function lo(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 i=r.charAt(0);if(i!=="."&&i!=="!")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 \`${i}\` is read as one prop name. Nest the selector inside instead: \`${i}${d}: { '${o.slice(d.length)}': {...} }\`.`)}continue}const a=t[r];if(!a||typeof a!="object")continue;const c=i==="!",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(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=c?!d:!!d;if(!t.node||y===e.lastMatch)return;e.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 E=a[x],w=x.charAt(0);if((w===":"||w==="@"||w==="&")&&E&&typeof E=="object"&&!Array.isArray(E)){if(_t(x,t)){const D=Z(E,t,!1);Object.keys(D).length&&(_[`[data-theme="${x.slice(1)}"] &`]=D,g=!0)}else{let D=x;if(w==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const K=t.context?.designSystem?.media?.[x.slice(1)];K&&(D=`@media ${K}`)}const H=Z(E,t,!1);Object.keys(H).length&&(_[D]=H,g=!0)}continue}const j=typeof E=="function"?E(t,t.state,t.context):E;if(j!=null)if(b.CSS_PROPS_REGISTRY[x]){const D=b.CSS_PROPS_REGISTRY[x](j,t,t.state,t.context);if(D){const H=Array.isArray(D)?D:[D];for(const K of H)K&&Object.assign(l,K)}}else b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(l[x]=j)}const C=Object.keys(l);if(C.length){Y(t.node,l);for(const x of C)n.set(x,r);e.appliedKeys=C}else e.appliedKeys=null;if(g){const x=(0,B.css)(_,null,t.context?.cssPrefix),E=x?x.split(" ").filter(Boolean):[];if(E.length&&t.node.classList){for(const w of E)t.node.classList.add(w);e.appliedClasses=E}else e.appliedClasses=null}else if(e.appliedClasses){for(const x of e.appliedClasses)t.node.classList.remove(x);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&&(0,A.popConfig)()}};s.__conditionalRunners.push(f);const u=(0,v.createEffect)(f,{depth:s.path.length});s.__effects.push(u)}}const bt=new WeakSet;function po(t){const s=t.ownerDocument;!s||bt.has(s)||(bt.add(s),queueMicrotask(()=>{bt.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const xt=new WeakSet;let Rt=!1;function yo(t){const{node:s}=t;if(!s)return;if(Rt||(Rt=!0,(0,B.css)({display:"none"})),xt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}xt.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const r={};let i=!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);i=!0}}for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||T.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 c=t[o],e=b.CSS_PROPS_REGISTRY[o](c,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);i=!0}}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,i=!0)}else if(o.charCodeAt(0)===45){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,i=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const c=t[o];if(c&&typeof c=="object"&&!Array.isArray(c)){if(gt(c))continue;const e=Dt(o,c,t);e&&(r[e.cssProp]=e.block,i=!0)}}}}if(i){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,B.css)(r,null,t.context?.cssPrefix);if(o&&s.classList){const c=o.split(" ").filter(Boolean);let e=!1;for(const f of c)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&&po(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const c=r.display;if(c&&c!==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&&(0,A.popConfig)(),xt.delete(t)}}function Tt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const i in t.aria){const o=t.aria[i];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const a="aria-"+i.replace(/[A-Z]/g,c=>"-"+c.toLowerCase());s.setAttribute(a,o===!0?"":o)}const n=(0,$.applyAttrTransforms)(t);for(const i in n){const o=n[i];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(i,o===!0?"":o)}const r=t.tag||"div";for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||typeof t[i]=="function"||T.REGISTRY.has(i)||i==="on"||n[i]!==void 0)continue;const o=i.charCodeAt(0);if(!(o>=65&&o<=90)&&!z(i)&&!(b.CSS_PROPS_REGISTRY[i]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(i))&&(0,$.checkAttributeByTagName)(r,i)){let a=t[i];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=(0,ct.replaceLiteralsWithObjectFields)(a,t,t.state,t.context),t[i]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!(0,$.isEnumeratedTrueFalseAttr)((0,$.camelToAttr)(i)||i))continue;const c=(0,$.camelToAttr)(i)||i;s.setAttribute(c,(0,$.serializeAttrValue)(c,a))}}}function ho(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 i=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};i(),s.addEventListener("input",i),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",i)}catch{}})}const Ft=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Nt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!z(n)||Ft.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(c){return t.call(o,c)}}if(typeof r!="function")continue;const i=Jt(n);T.LIFECYCLE_EVENTS.has(i)||(0,It.registerEvent)(mt(i),t,r)}_o(t)}function _o(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Ft){const y=t[p];typeof y=="function"&&(n[p]=y,r=!0)}if(!r)return;const i=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let a=0,c=0,e=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,c=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-c,_=Date.now()-e;if(_>o)return;const g=Math.abs(h),C=Math.abs(l);if(Math.max(g,C)<i)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 E="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),w=n[E],j=n.onSwipe;w&&w.call(t,p,t,t.state,t.context),j&&j.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 nt(t,s){const n={...t};for(const r in s){const i=n[r],o=s[r];i&&o&&typeof i=="object"&&typeof o=="object"&&!Array.isArray(i)&&!Array.isArray(o)&&typeof i!="function"&&typeof o!="function"?n[r]=nt(i,o):n[r]=o}return n}function At(t,s,n){if(!s||!t.node)return;const r=t.childExtends;if(Array.isArray(s)){const i=t.tag==="fragment",o=t.context?.document||globalThis.document,a=i?null:o?.createDocumentFragment();if(!i&&!a)return;const c=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=c;if(typeof c=="function")try{p=c(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=nt(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}!i&&h?.node&&a.appendChild(h.node)}return i||t.node.appendChild(a),!0}if(typeof s=="string"){const i=Et(s,t);if(Array.isArray(i))return At(t,i,n)}if(typeof s=="object")for(const i in s){if(T.REGISTRY.has(i))continue;let o=s[i];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=nt(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],c=Array.isArray(r)?r:[r];o={...o,extends:[...c,...a]}}else o={...o,extends:r};V(o,t,i,n)}}}function Ct(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const r=n.options;if(!r||!r.length)return;const i=t.__ref,o=i&&i.__exec&&i.__exec.value,a=typeof o=="function",c=t.value!=null&&typeof t.value!="function";if(a||c){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||!(i&&i.__selectSynced);if(i&&(i.__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 Mt(t,s){let{children:n,content:r}=t;const i=t.childExtends;if(typeof n=="function"){const c=n;try{n=c(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,c),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 j=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${j}${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,j=[],D=new Map;for(let k=0;k<y.length;k++){const R=y[k];let S=w;if(typeof w=="function")try{S=w(t,R)}catch{S=null}const M=S&&S.key||R&&R.key||`${k}`;j.push(M),D.set(M,{rawChild:R,childProps:S})}const H=new Set(j),K=e.__children.slice();for(const k of K)if(!H.has(k)){const R=t[k];R?.remove&&R.remove(),delete t[k],_&&_.push(k)}const Q=t.childExtends,ot=t.tag==="fragment",Wt=t.context?.document||globalThis.document,X=ot?null:Wt?.createDocumentFragment(),et=new Set;for(const k of j){const R=D.get(k),S=R.rawChild,M=t[k];if(M&&M.state){if(S&&typeof S=="object"){const O=M.state,G=O.$replace||O.replace,vt=O.$update||O.update;if(typeof G=="function")G.call(O,S);else if(typeof vt=="function"){for(const U in O)if(!(U==="__element"||U==="root"||U==="parent"||U==="update")&&!Object.prototype.hasOwnProperty.call(S,U))try{O[U]=void 0}catch{}vt.call(O,S)}else for(const U in S)O[U]=S[U]}g&&g.push(k);continue}let at=S;(typeof S=="string"||typeof S=="number")&&(at={value:S,text:S});const St=R.childProps;let F=St?{...St,state:at}:{state:at};if(Q&&!F.ignoreChildExtends)if(F.extends){const O=Array.isArray(F.extends)?F.extends:[F.extends],G=Array.isArray(Q)?Q:[Q];F={...F,extends:[...G,...O]}}else F={...F,extends:Q};let ft;try{ft=V(F,t,k,s)}catch(O){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):`,O?.message||O)}et.add(k);continue}!ot&&ft?.node&&X&&X.appendChild(ft.node),l&&l.push(k)}if(!ot&&X&&X.childNodes.length&&t.node&&t.node.appendChild(X),!ot&&t.node){let k=null;for(const R of j){const S=t[R]?.node;if(!S)continue;const M=k?k.nextSibling:t.node.firstChild;S!==M&&t.node.insertBefore(S,M),k=S}}e.__children=et.size?j.filter(k=>!et.has(k)):j,h&&(l.length||_.length)&&jt(t,{added:l,removed:_,kept:g}),Ct(t,!1);return}const E=h?[...e.__children]:null;for(const w of[...e.__children]){const j=t[w];j?.remove&&j.remove(),delete t[w]}e.__children=[],At(t,y,s),Ct(t,!1),h&&jt(t,{added:[...e.__children],removed:E,kept:[]})},{depth:e.path.length});e.__effects.push(d)}const o=At(t,n||r,s);if((n||r)&&!o)return;const a=t.context?.components||{};{const c=Object.keys(t);for(let e=0;e<c.length;e++){const f=c[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<c.length;p++){const y=c[p],h=y.charCodeAt(0);if(h>=65&&h<=90||T.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 c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||T.REGISTRY.has(c)||typeof t[c]!="object"||t[c]===null)continue;const e=c.charCodeAt(0);if(e<65||e>90)continue;let f=t[c];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[c]||a[`smbls.${c}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=nt(t.childProps,f)),i&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],d=Array.isArray(i)?i:[i];f={...f,extends:[...d,...u]}}else f={...f,extends:i};V(f,t,c,s)}}}function Ut(t,s,n){const{node:r}=t;if(!r)return;r.ref=t;const i=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(i){const a=i.parentNode;if(a){if(n?.position==="before"&&n.node)a.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const c=n.node.nextSibling;a.insertBefore(r,c||i)}else a.insertBefore(r,i);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 it=3;function Vt(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=it?!1:(t.__inBeforeUpdate=!0,!0)}function tt(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===it&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${it}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,N.runPluginHook)(r,s,n);const i="on"+t,o=s[i];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&&(0,A.pushConfig)(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&&(0,N.runPluginHook)("error",s,{hook:i,error:y})||console.error(`[DOMQL] Lifecycle "${i}" error:`,y)}).finally(()=>{e&&p&&(p[e]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&(0,N.runPluginHook)("error",s,{hook:i,error:d})||console.error(`[DOMQL] Lifecycle "${i}" error:`,d),s.context?.strictMode)throw d}finally{f&&(0,A.popConfig)(),u&&s.__ref&&(s.__ref[e]=!1)}}return!0}var go=V;
|
|
4
|
+
`):"")}}if(Ct(o,!0),Ut(o,s,i),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),wt(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 to(t,s,n){const r=!s,i=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&i&&t.context?.state,a=n.state!==void 0&&!o?n.state:t.state&&!(0,P.isStore)(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,(0,q.applyStateMethods)(t,t.state);else if(t.context?.state){const c=t.context.state,e={...c},f=t.context?.polyglot;if(f?.translations){const u=c.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=(0,P.isStore)(e)?e:(0,P.createStore)(e),t.state.__element=t,t.state.root=t.state,(0,q.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,q.applyStateMethods)(t,t.state);return}if(typeof a=="string"){if(t.state=Et(a,s),t.state&&typeof t.state=="object"&&!(0,P.isStore)(t.state)){const c=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:c,enumerable:!1,configurable:!0,writable:!0})}(0,q.applyStateMethods)(t,t.state);return}if(typeof a=="function"){const c=a(t,s?.state);t.state=(0,P.isStore)(c)?c:(0,P.createStore)(c||{})}else(0,P.isStore)(a)?t.state=a:t.state=(0,P.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,q.applyStateMethods)(t,t.state)}function pt(t,s){if(!s)return t;const n=s.split("/");let r=t;for(const i of n){if(r==null)return{};r=r[i]}return r??{}}function Et(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const i=t.slice(3);return i?pt(s.state,i):s.state??{}}if(t.startsWith("~/")){const i=s.state?.root||s.state,o=t.slice(2);return o?pt(i,o):i??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=pt(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=s.context?.polyglot;if(r?.translations){const i=s.state?.root?.lang||r.defaultLang||"en",o=r.translations[i];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}const oo=new Set(["s","state","ctx","context"]);function so(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 no(t){if(typeof t!="function"||t.length!==2)return!1;const s=so(t);if(s.length<2)return!1;const n=s[1].replace(/[{}[\]]/g,"").trim();return n.length>0&&!oo.has(n)}function ro(t){const s=t.__ref,n=t.tag||"div",r=t.context?.designSystem,i=[],o=Object.keys(t);for(let a=0;a<o.length;a++){const c=o[a];if(typeof t[c]!="function"||T.REGISTRY.has(c))continue;const e=c.charCodeAt(0);e>=65&&e<=90||z(c)||b.CSS_PROPS_REGISTRY[c]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(c)||(0,$.checkAttributeByTagName)(n,c)||((0,rt.isLoudDevRuntime)()&&no(t[c])&&console.warn(`[smbls] custom prop "${c}"${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('${c}', \u2026) instead of reading el.${c}(\u2026) directly (see RULES.md Rule 8).`),i.push({prop:c,fn:t[c]}))}for(let a=0;a<i.length;a++){const{prop:c,fn:e}=i[a];s.__exec[c]=e,Object.defineProperty(t,c,{get(){r&&(0,A.pushConfig)(r);try{return e(t,t.state,t.context)}catch{return}finally{r&&(0,A.popConfig)()}},set(f){delete s.__exec[c],Object.defineProperty(t,c,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function co(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 co(t,s),n.apply(this,r)}}function m(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Pt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(ro(t),typeof t.text=="function"){const o=t.text,a=L(t,t.textDeps,o),c=(0,v.createEffect)(()=>{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=ct.replaceLiteralsWithObjectFields.call(t,e,t.state)),t.tag==="string"?t.node.nodeValue=e:t.node.textContent=e)}catch{}},{depth:n.path.length});n.__effects.push(c),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 c=ct.replaceLiteralsWithObjectFields.call(t,o,t.state);c!=null&&(t.text=c),t.node&&(t.tag==="string"?t.node.nodeValue=c??"":t.node.textContent=c??"")},{depth:n.path.length});n.__effects.push(a),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!T.REGISTRY.has(o)&&!z(o)&&!n.__exec[o]){if(b.CSS_PROPS_REGISTRY[o]){const a=t[o],c=L(t,t[o+"Deps"],a),e=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=c(t,t.state,t.context),y=b.CSS_PROPS_REGISTRY[e](p,t,t.state,t.context);if(y&&t.node){const h=ht(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&&(0,A.popConfig)()}},{depth:n.path.length});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],c=L(t,t[o+"Deps"],a),e=o;let f;const u=(0,v.createEffect)(()=>{const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{const p=c(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&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=L(t,t.htmlDeps,o),c=(0,v.createEffect)(()=>{const e=t.context?.designSystem;e&&(0,A.pushConfig)(e);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{e&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(c),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=L(t,t.valueDeps,o),c=(0,v.createEffect)(()=>{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});n.__effects.push(c),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=L(t,t.styleDeps,o);let c;const e=(0,v.createEffect)(()=>{const f=a(t,t.state,t.context),u=ht(f);(u===null||u!==c)&&(c=u,Y(t.node,f))},{depth:n.path.length});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 c=L(t,m(t.styleDeps,o),a);let e;const f=(0,v.createEffect)(()=>{try{const u=c(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});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,m(t.attrDeps,o),t.attr[o]),c=o,e=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f))}catch{}},{depth:n.path.length});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,m(t.ariaDeps,o),t.aria[o]),c="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),e=(0,v.createEffect)(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f)}catch{}},{depth:n.path.length});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,m(t.dataDeps,o),t.data[o]),e="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(e):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(e,u===!0?"":u)}catch{}},{depth:n.path.length});n.__effects.push(f)}const i=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(i)for(const o in i){if(typeof i[o]!="function")continue;const a=L(t,m(t.classDeps,o),i[o]),c=(0,v.createEffect)(()=>{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});n.__effects.push(c)}!r&&typeof t.if=="function"&&Lt(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||T.REGISTRY.has(o)||typeof t[o]!="function")continue;const a=o.charCodeAt(0);if(a>=65&&a<=90||z(o))continue;const c=t[o];n.__exec[o]=c;const e=t.tag||"div";if((0,$.checkAttributeByTagName)(e,o)&&!b.CSS_PROPS_REGISTRY[o]&&!(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const f=(0,$.camelToAttr)(o)||o,u=L(t,t[o+"Deps"],c),d=(0,v.createEffect)(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(d)}}if(ao(t),lo(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let c=!1,e=[];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(!c){c=!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&&(0,A.pushConfig)(y);try{o(t,t.state,t.context,{prev:p,next:u})}catch(h){if(t.context?.plugins?.length&&(0,N.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});n.__effects.push(f)}uo(t)}function Ot(t){const s=t.parent,n=s?.node;if(!n||!t.node){Ut(t,t.parent);return}let r=null;const i=Object.keys(s),o=i.indexOf(t.key);for(let a=o+1;a<i.length;a++){const c=s[i[a]];if(c?.node?.parentNode===n){r=c.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function Lt(t,s,n){const r=L(t,t.ifDeps,n),i=(0,v.createEffect)(()=>{let o;try{o=r(t,t.state,t.context)}catch(c){if(o=!1,s.__ifError=c,typeof console<"u"&&console.warn){const e=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${e} \u2014 treating as false:`,c?.message||c)}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,W.cacheNode)(t)),t.node&&(t.node.ref=t),Ot(t),yt(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=(0,W.detectTag)(t)),I("Init",t,{}),t.node||(t.node=(0,W.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 e=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(e),s.__fragmentAnchor=e}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),Nt(t,{}),Pt(t,{skipIfEffect:!0}),yt(t),Tt(t),Mt(t,{}),Ot(t),wt(t,{})}},{depth:s.path.length});s.__effects.push(i)}function yt(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),yo(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||s.setAttribute&&s.setAttribute(n,r===!0?"":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 i=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];i&&s.classList.add(typeof i=="string"?i:r)}}}}function ht(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 i=s[r];if(i!=null){if(r.charAt(0)==="&"&&typeof i=="object"){n||(n={}),n[r]=i;continue}try{const o=String(i),a=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),c=o.trim(),e=/\s*!important\s*$/.test(c),f=c.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,e?"important":"")}catch{}}}n&&eo(t,n)}let io=0;function eo(t,s){const n=`_ds${io++}`;t.classList.add(n);const r=t.ownerDocument;let i=r.querySelector("style[data-smbls-scoped]");i||(i=r.createElement("style"),i.setAttribute("data-smbls-scoped",""),r.head.appendChild(i));let o="";for(const a in s){const c="."+n,e=a.replace(/&/g,c).split(",").map(u=>{const d=u.trim();return d.includes(c)?d:c+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+=(0,K.wrapHoverRule)(`${h} { ${l} }`,h)+`
|
|
5
|
+
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${y};`}u&&(o+=(0,K.wrapHoverRule)(`${e} { ${u} }`,e)+`
|
|
6
|
+
`),d&&(o+=d)}}o&&(i.textContent+=o)}function ao(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 i=s[r];if(typeof i!="string"||i.length===0)continue;const o=i.split("."),a=o[0],c=o.slice(1),e={value:!1},f=(0,v.createEffect)(()=>{const u=t.state&&((0,P.isStore)(t.state)?t.state.root:null);if(!u||!(0,P.isStore)(u))return;let d=u;d=d[a];for(let y=0;y<c.length&&!(d==null||typeof d!="object");y++)if((0,P.isStore)(d))d=d[c[y]];else break;if(!e.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&(0,A.pushConfig)(y);try{if(Vt(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>ot(n,!1),l=>{ot(n,!0),t.context?.plugins?.length&&(0,N.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(ot(n,!1),h===!1&&(p=!0))}}catch(h){ot(n,!0),t.context?.plugins?.length&&(0,N.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,N.runPluginHook)("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&(0,A.popConfig)()}}},{depth:n.path.length});e.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function _t(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 fo(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 Z(t,s,n){const r={},i=new Set,o=(a,c,e)=>{const f=e?new Set(Object.keys(r)):null;if(b.CSS_PROPS_REGISTRY[a]){const u=b.CSS_PROPS_REGISTRY[a](c,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]=c;if(e)for(const u in r)f.has(u)||i.add(u)};for(const a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;let c=t[a];if(typeof c=="function"&&(c=c(s,s.state,s.context)),c==null||typeof c=="function")continue;if(typeof c=="object"&&!Array.isArray(c)){if(a==="style"){for(const d in c){let p=c[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(_t(a,s)){const d=Z(c,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)()&&fo(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=Z(c,s,!1);Object.keys(u).length&&(r[f]=u);continue}const e=typeof s[a]=="function"&&(b.CSS_PROPS_REGISTRY[a]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(a));o(a,c,e)}if(n)for(const a in r)i.add(a);for(const a of i){const c=r[a];typeof c=="string"&&!c.includes("!important")&&(r[a]=c+" !important")}return r}function gt(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)&>(t[n],s+1))return!0}return!1}function Dt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(_t(t,n)){const o=Z(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 i=Z(s,n,!1);return Object.keys(i).length?{cssProp:r,block:i}:null}function uo(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!lt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!gt(r))continue;let i=null,o;const a=(0,v.createEffect)(()=>{if(!t.node)return;const c=t.context?.designSystem;c&&(0,A.pushConfig)(c);let e,f=!1;try{const u=Dt(n,r,t),d=u?ht(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);e=p?p.split(" ").filter(Boolean):null}else e=null}finally{c&&(0,A.popConfig)()}if(!(f||!t.node.classList)){if(i)for(const u of i)t.node.classList.remove(u);if(e&&e.length)for(const u of e)t.node.classList.add(u);i=e}},{depth:s.path.length});s.__effects.push(a)}}function lo(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 i=r.charAt(0);if(i!=="."&&i!=="!")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 \`${i}\` is read as one prop name. Nest the selector inside instead: \`${i}${d}: { '${o.slice(d.length)}': {...} }\`.`)}continue}const a=t[r];if(!a||typeof a!="object")continue;const c=i==="!",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(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=c?!d:!!d;if(!t.node||y===e.lastMatch)return;e.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 E=a[x],w=x.charAt(0);if((w===":"||w==="@"||w==="&")&&E&&typeof E=="object"&&!Array.isArray(E)){if(_t(x,t)){const D=Z(E,t,!1);Object.keys(D).length&&(_[`[data-theme="${x.slice(1)}"] &`]=D,g=!0)}else{let D=x;if(w==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const V=t.context?.designSystem?.media?.[x.slice(1)];V&&(D=`@media ${V}`)}const H=Z(E,t,!1);Object.keys(H).length&&(_[D]=H,g=!0)}continue}const j=typeof E=="function"?E(t,t.state,t.context):E;if(j!=null)if(b.CSS_PROPS_REGISTRY[x]){const D=b.CSS_PROPS_REGISTRY[x](j,t,t.state,t.context);if(D){const H=Array.isArray(D)?D:[D];for(const V of H)V&&Object.assign(l,V)}}else b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(l[x]=j)}const C=Object.keys(l);if(C.length){Y(t.node,l);for(const x of C)n.set(x,r);e.appliedKeys=C}else e.appliedKeys=null;if(g){const x=(0,K.css)(_,null,t.context?.cssPrefix),E=x?x.split(" ").filter(Boolean):[];if(E.length&&t.node.classList){for(const w of E)t.node.classList.add(w);e.appliedClasses=E}else e.appliedClasses=null}else if(e.appliedClasses){for(const x of e.appliedClasses)t.node.classList.remove(x);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&&(0,A.popConfig)()}};s.__conditionalRunners.push(f);const u=(0,v.createEffect)(f,{depth:s.path.length});s.__effects.push(u)}}const bt=new WeakSet;function po(t){const s=t.ownerDocument;!s||bt.has(s)||(bt.add(s),queueMicrotask(()=>{bt.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const xt=new WeakSet;let Rt=!1;function yo(t){const{node:s}=t;if(!s)return;if(Rt||(Rt=!0,(0,K.css)({display:"none"})),xt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}xt.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const r={};let i=!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);i=!0}}for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||T.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 c=t[o],e=b.CSS_PROPS_REGISTRY[o](c,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);i=!0}}else if(b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,i=!0)}else if(o.charCodeAt(0)===45){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,i=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const c=t[o];if(c&&typeof c=="object"&&!Array.isArray(c)){if(gt(c))continue;const e=Dt(o,c,t);e&&(r[e.cssProp]=e.block,i=!0)}}}}if(i){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 c=o.split(" ").filter(Boolean);let e=!1;for(const f of c)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&&po(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const c=r.display;if(c&&c!==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&&(0,A.popConfig)(),xt.delete(t)}}function Tt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const i in t.aria){const o=t.aria[i];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const a="aria-"+i.replace(/[A-Z]/g,c=>"-"+c.toLowerCase());s.setAttribute(a,o===!0?"":o)}const n=(0,$.applyAttrTransforms)(t);for(const i in n){const o=n[i];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(i,o===!0?"":o)}const r=t.tag||"div";for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||typeof t[i]=="function"||T.REGISTRY.has(i)||i==="on"||n[i]!==void 0)continue;const o=i.charCodeAt(0);if(!(o>=65&&o<=90)&&!z(i)&&!(b.CSS_PROPS_REGISTRY[i]||b.DEFAULT_CSS_PROPERTIES_LIST&&b.DEFAULT_CSS_PROPERTIES_LIST.has(i))&&(0,$.checkAttributeByTagName)(r,i)){let a=t[i];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=(0,ct.replaceLiteralsWithObjectFields)(a,t,t.state,t.context),t[i]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!(0,$.isEnumeratedTrueFalseAttr)((0,$.camelToAttr)(i)||i))continue;const c=(0,$.camelToAttr)(i)||i;s.setAttribute(c,(0,$.serializeAttrValue)(c,a))}}}function ho(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 i=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};i(),s.addEventListener("input",i),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",i)}catch{}})}const Ft=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Nt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!z(n)||Ft.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(c){return t.call(o,c)}}if(typeof r!="function")continue;const i=Jt(n);T.LIFECYCLE_EVENTS.has(i)||(0,It.registerEvent)(mt(i),t,r)}_o(t)}function _o(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Ft){const y=t[p];typeof y=="function"&&(n[p]=y,r=!0)}if(!r)return;const i=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let a=0,c=0,e=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,c=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-c,_=Date.now()-e;if(_>o)return;const g=Math.abs(h),C=Math.abs(l);if(Math.max(g,C)<i)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 E="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),w=n[E],j=n.onSwipe;w&&w.call(t,p,t,t.state,t.context),j&&j.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 tt(t,s){const n={...t};for(const r in s){const i=n[r],o=s[r];i&&o&&typeof i=="object"&&typeof o=="object"&&!Array.isArray(i)&&!Array.isArray(o)&&typeof i!="function"&&typeof o!="function"?n[r]=tt(i,o):n[r]=o}return n}function At(t,s,n){if(!s||!t.node)return;const r=t.childExtends;if(Array.isArray(s)){const i=t.tag==="fragment",o=t.context?.document||globalThis.document,a=i?null:o?.createDocumentFragment();if(!i&&!a)return;const c=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=c;if(typeof c=="function")try{p=c(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=tt(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}!i&&h?.node&&a.appendChild(h.node)}return i||t.node.appendChild(a),!0}if(typeof s=="string"){const i=Et(s,t);if(Array.isArray(i))return At(t,i,n)}if(typeof s=="object")for(const i in s){if(T.REGISTRY.has(i))continue;let o=s[i];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=tt(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],c=Array.isArray(r)?r:[r];o={...o,extends:[...c,...a]}}else o={...o,extends:r};B(o,t,i,n)}}}function Ct(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const r=n.options;if(!r||!r.length)return;const i=t.__ref,o=i&&i.__exec&&i.__exec.value,a=typeof o=="function",c=t.value!=null&&typeof t.value!="function";if(a||c){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||!(i&&i.__selectSynced);if(i&&(i.__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 Mt(t,s){let{children:n,content:r}=t;const i=t.childExtends;if(typeof n=="function"){const c=n;try{n=c(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,c),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 j=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${j}${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,j=[],D=new Map;for(let k=0;k<y.length;k++){const R=y[k];let S=w;if(typeof w=="function")try{S=w(t,R)}catch{S=null}const M=S&&S.key||R&&R.key||`${k}`;j.push(M),D.set(M,{rawChild:R,childProps:S})}const H=new Set(j),V=e.__children.slice();for(const k of V)if(!H.has(k)){const R=t[k];R?.remove&&R.remove(),delete t[k],_&&_.push(k)}const Q=t.childExtends,st=t.tag==="fragment",Wt=t.context?.document||globalThis.document,X=st?null:Wt?.createDocumentFragment(),et=new Set;for(const k of j){const R=D.get(k),S=R.rawChild,M=t[k];if(M&&M.state){if(S&&typeof S=="object"){const O=M.state,G=O.$replace||O.replace,vt=O.$update||O.update;if(typeof G=="function")G.call(O,S);else if(typeof vt=="function"){for(const U in O)if(!(U==="__element"||U==="root"||U==="parent"||U==="update")&&!Object.prototype.hasOwnProperty.call(S,U))try{O[U]=void 0}catch{}vt.call(O,S)}else for(const U in S)O[U]=S[U]}g&&g.push(k);continue}let at=S;(typeof S=="string"||typeof S=="number")&&(at={value:S,text:S});const St=R.childProps;let F=St?{...St,state:at}:{state:at};if(Q&&!F.ignoreChildExtends)if(F.extends){const O=Array.isArray(F.extends)?F.extends:[F.extends],G=Array.isArray(Q)?Q:[Q];F={...F,extends:[...G,...O]}}else F={...F,extends:Q};let ft;try{ft=B(F,t,k,s)}catch(O){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):`,O?.message||O)}et.add(k);continue}!st&&ft?.node&&X&&X.appendChild(ft.node),l&&l.push(k)}if(!st&&X&&X.childNodes.length&&t.node&&t.node.appendChild(X),!st&&t.node){let k=null;for(const R of j){const S=t[R]?.node;if(!S)continue;const M=k?k.nextSibling:t.node.firstChild;S!==M&&t.node.insertBefore(S,M),k=S}}e.__children=et.size?j.filter(k=>!et.has(k)):j,h&&(l.length||_.length)&&jt(t,{added:l,removed:_,kept:g}),Ct(t,!1);return}const E=h?[...e.__children]:null;for(const w of[...e.__children]){const j=t[w];j?.remove&&j.remove(),delete t[w]}e.__children=[],At(t,y,s),Ct(t,!1),h&&jt(t,{added:[...e.__children],removed:E,kept:[]})},{depth:e.path.length});e.__effects.push(d)}const o=At(t,n,s);if(r!=null&&!(r&&r.__ref)){let c=r;if(typeof c=="string"||typeof c=="number"?c={text:c}:typeof c!="object"&&(c={}),t.childProps&&(c=tt(t.childProps,c)),i&&!c.ignoreChildExtends)if(c.extends){const e=Array.isArray(c.extends)?c.extends:[c.extends],f=Array.isArray(i)?i:[i];c={...c,extends:[...f,...e]}}else c={...c,extends:i};B(c,t,"content",s)}if(n&&!o)return;const a=t.context?.components||{};{const c=Object.keys(t);for(let e=0;e<c.length;e++){const f=c[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<c.length;p++){const y=c[p],h=y.charCodeAt(0);if(h>=65&&h<=90||T.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 c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||T.REGISTRY.has(c)||typeof t[c]!="object"||t[c]===null)continue;const e=c.charCodeAt(0);if(e<65||e>90)continue;let f=t[c];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[c]||a[`smbls.${c}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=tt(t.childProps,f)),i&&!f.ignoreChildExtends)if(f.extends){const u=Array.isArray(f.extends)?f.extends:[f.extends],d=Array.isArray(i)?i:[i];f={...f,extends:[...d,...u]}}else f={...f,extends:i};B(f,t,c,s)}}}function Ut(t,s,n){const{node:r}=t;if(!r)return;r.ref=t;const i=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(i){const a=i.parentNode;if(a){if(n?.position==="before"&&n.node)a.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const c=n.node.nextSibling;a.insertBefore(r,c||i)}else a.insertBefore(r,i);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 it=3;function Vt(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=it?!1:(t.__inBeforeUpdate=!0,!0)}function ot(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===it&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${it}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,N.runPluginHook)(r,s,n);const i="on"+t,o=s[i];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&&(0,A.pushConfig)(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&&(0,N.runPluginHook)("error",s,{hook:i,error:y})||console.error(`[DOMQL] Lifecycle "${i}" error:`,y)}).finally(()=>{e&&p&&(p[e]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&(0,N.runPluginHook)("error",s,{hook:i,error:d})||console.error(`[DOMQL] Lifecycle "${i}" error:`,d),s.context?.strictMode)throw d}finally{f&&(0,A.popConfig)(),u&&s.__ref&&(s.__ref[e]=!1)}}return!0}var go=B;
|
package/dist/esm/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{createStore as et,createScopeStore as Gt,isStore as I}from"@symbo.ls/signal";import{createEffect as S}from"@symbo.ls/signal";import{cacheNode as at,detectTag as Et}from"./cache.js";import{REGISTRY as B,LIFECYCLE_EVENTS as zt}from"./registry.js";import{registerEvent as Yt}from"./delegate.js";import{applyExtends as Zt}from"./extends.js";import{addMethods as qt}from"./methods.js";import"./dispose.js";import{isLoudDevRuntime as ft}from"./devRuntime.js";import{replaceLiteralsWithObjectFields as ut}from"@symbo.ls/utils";import{runPluginHook as M}from"@symbo.ls/utils/function.js";import{applyStateMethods as Q}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as E,DEFAULT_CSS_PROPERTIES_LIST as j}from"css-in-props";import{css as
|
|
1
|
+
import{createStore as et,createScopeStore as Gt,isStore as I}from"@symbo.ls/signal";import{createEffect as S}from"@symbo.ls/signal";import{cacheNode as at,detectTag as Et}from"./cache.js";import{REGISTRY as B,LIFECYCLE_EVENTS as zt}from"./registry.js";import{registerEvent as Yt}from"./delegate.js";import{applyExtends as Zt}from"./extends.js";import{addMethods as qt}from"./methods.js";import"./dispose.js";import{isLoudDevRuntime as ft}from"./devRuntime.js";import{replaceLiteralsWithObjectFields as ut}from"@symbo.ls/utils";import{runPluginHook as M}from"@symbo.ls/utils/function.js";import{applyStateMethods as Q}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as E,DEFAULT_CSS_PROPERTIES_LIST as j}from"css-in-props";import{css as ot,wrapHoverRule as Pt}from"@symbo.ls/css";import{pushConfig as O,popConfig as L}from"@symbo.ls/scratch";import{checkAttributeByTagName as dt,applyAttrTransforms as Qt,camelToAttr as lt,serializeAttrValue as Xt,isEnumeratedTrueFalseAttr as Jt}from"attrs-in-props";let mt=1;const st=[];let pt=!1;function to(){pt||(pt=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(Ot):setTimeout(Ot,0))}function Ot(){if(pt=!1,!st.length)return;const t=st.splice(0,st.length);for(let s=0;s<t.length;s++){const n=t[s];!n.node||!n.node.isConnected||U("Mounted",n,n.__ref?.__mountOptions||{})}}function Lt(t,s){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=s,st.push(t),to())}function $t(t,s){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&M("contentUpdate",t,s);const n=t.context?.designSystem;n&&O(n);try{t.onContentUpdate(t,t.state,t.context,s)}catch(r){if(t.context?.plugins?.length&&M("error",t,{hook:"onContentUpdate",error:r})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',r),t.context?.strictMode)throw r}finally{n&&L()}}function G(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function oo(t){return t.charAt(2).toLowerCase()+t.slice(3)}function so(t){return t.toLowerCase()}function yt(t){const s=t.charCodeAt(0);return s===58||s===64||s===38}function X(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]=X(e,o):n[r]=o}return n}function V(t,s,n,r={},e){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${mt++}`,o.parent=s||null,o.context=t.context||s?.context||r.context||{},o.context.__create||(o.context.__create=V);const a=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:s?.__ref?.root||o,path:s?.__ref?.path?[...s.__ref.path,o.key]:[o.key],origin:t};if(n&&!t.extends&&!t.extend){const l=n.indexOf("_");if(l>0){const _=n.substring(0,l),g=o.context?.components;g&&(g[_]||g["smbls."+_])?t={...t,extends:_}:g&&ft()&&/^[A-Z]\w*_\d+$/.test(n)&&console.warn(`[smbls] auto-extend: key "${n}" looks like a multi-instance (${_}_N) but neither "${_}" nor "smbls.${_}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}Zt(o,t,r);const c=new Set(["childProps","attr","style","scope","data"]),i=o.props&&typeof o.props=="object"?o.props:null;for(const l in t){if(l==="parent"||l==="node"||l==="__ref"||l==="extends"||l==="context"||l==="props")continue;const _=t[l],g=o[l],x=g&&_&&typeof g=="object"&&typeof _=="object"&&!Array.isArray(g)&&!Array.isArray(_)&&typeof g!="function"&&typeof _!="function";x&&l.charCodeAt(0)>=65&&l.charCodeAt(0)<=90?o[l]=X(g,_):x&&c.has(l)?o[l]={...g,..._}:x&&yt(l)?o[l]=X(g,_):o[l]=_}function f(l){for(const _ in l){const g=l[_],x=o[_],b=x&&g&&typeof x=="object"&&typeof g=="object"&&!Array.isArray(x)&&!Array.isArray(g)&&typeof x!="function"&&typeof g!="function";b&&_.charCodeAt(0)>=65&&_.charCodeAt(0)<=90?o[_]=X(x,g):b&&c.has(_)?o[_]={...x,...g}:b&&yt(_)?o[_]=X(x,g):o[_]=g}}i&&f(i),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,d=s?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,y=d||p||null;if(t.scope!==void 0||u){const l={};u&&Object.assign(l,u),t.scope!==void 0&&Object.assign(l,t.scope),o.scope=Gt(l,y)}else y&&(o.scope=y);if(t.if!==void 0&&(o.if=t.if),qt(o),no(o,s,t),o.if!=null){let l;if(typeof o.if=="function")try{l=o.if(o,o.state,o.context)}catch(_){if(l=!1,a.__ifError=_,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,_?.message||_)}}else l=o.if;a.__if=!!l}if(a.__if)typeof o.if=="function"&&(a.__ifInitialized=!0);else return s&&(s[o.key]=o),typeof o.if=="function"&&Ft(o,a,o.if),o;o.tag||(o.tag=Et(o)),U("Init",o,r);const h=o.node=at(o);if(!h)return o;if(o.tag==="fragment"){const _=(o.context?.document||globalThis.document).createComment("");h.appendChild(_),a.__fragmentAnchor=_}U("AttachNode",o,r),h.setAttribute&&o.key&&h.setAttribute("data-key",o.key),s&&(s[o.key]=o,s.__ref?.__children&&(s.__ref.__children.includes(o.key)||s.__ref.__children.push(o.key))),h.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&h.setAttribute("data-smbls-app",o.context.key),o.id&&h.setAttribute&&(h.id=o.id),Kt(o,r),Rt(o),_t(o),It(o),bo(o);try{Vt(o,r)}catch(l){if(typeof console<"u"&&console.error){const _=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${_}:`,l?.message||l,l?.stack?`
|
|
2
2
|
`+l.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(St(o,!0),Wt(o,s,e),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&&L()}}if(U("Create",o,r),U("Complete",o,r),U("Render",o,r),U("RenderRouter",o,r),Lt(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{_&&L()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function no(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&&!I(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,Q(t,t.state);else if(t.context?.state){const c=t.context.state,i={...c},f=t.context?.polyglot;if(f?.translations){const u=c.lang||f.defaultLang||"en",d=f.translations[u];if(d&&typeof d=="object")for(const y in d)i[y]===void 0&&(i[y]=d[y]);const p=new Set(f.languages||[]);for(const y in f.translations)!p.has(y)&&i[y]===void 0&&(i[y]=f.translations[y])}t.state=I(i)?i:et(i),t.state.__element=t,t.state.root=t.state,Q(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),Q(t,t.state);return}if(typeof a=="string"){if(t.state=Dt(a,s),t.state&&typeof t.state=="object"&&!I(t.state)){const c=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:c,enumerable:!1,configurable:!0,writable:!0})}Q(t,t.state);return}if(typeof a=="function"){const c=a(t,s?.state);t.state=I(c)?c:et(c||{})}else I(a)?t.state=a:t.state=et({...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,Q(t,t.state)}function ht(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 Dt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const e=t.slice(3);return e?ht(s.state,e):s.state??{}}if(t.startsWith("~/")){const e=s.state?.root||s.state,o=t.slice(2);return o?ht(e,o):e??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=ht(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 ro=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 io(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&&!ro.has(n)}function eo(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 c=o[a];if(typeof t[c]!="function"||B.has(c))continue;const i=c.charCodeAt(0);i>=65&&i<=90||H(c)||E[c]||j&&j.has(c)||dt(n,c)||(ft()&&io(t[c])&&console.warn(`[smbls] custom prop "${c}"${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('${c}', \u2026) instead of reading el.${c}(\u2026) directly (see RULES.md Rule 8).`),e.push({prop:c,fn:t[c]}))}for(let a=0;a<e.length;a++){const{prop:c,fn:i}=e[a];s.__exec[c]=i,Object.defineProperty(t,c,{get(){r&&O(r);try{return i(t,t.state,t.context)}catch{return}finally{r&&L()}},set(f){delete s.__exec[c],Object.defineProperty(t,c,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function ao(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 $(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...r){return ao(t,s),n.apply(this,r)}}function J(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Rt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(eo(t),typeof t.text=="function"){const o=t.text,a=$(t,t.textDeps,o),c=S(()=>{if(!n.contentManaged)try{let i=a(t,t.state,t.context);t.node&&i!=null&&typeof i!="function"&&typeof i!="object"&&(typeof i=="string"&&i.includes("{{")&&(i=ut.call(t,i,t.state)),t.tag==="string"?t.node.nodeValue=i:t.node.textContent=i)}catch{}},{depth:n.path.length});n.__effects.push(c),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,a=S(()=>{if(n.contentManaged)return;const c=ut.call(t,o,t.state);c!=null&&(t.text=c),t.node&&(t.tag==="string"?t.node.nodeValue=c??"":t.node.textContent=c??"")},{depth:n.path.length});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)&&!H(o)&&!n.__exec[o]){if(E[o]){const a=t[o],c=$(t,t[o+"Deps"],a),i=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=c(t,t.state,t.context),y=E[i](p,t,t.state,t.context);if(y&&t.node){const h=gt(y);(h===null||h!==f)&&(f=h,z(t.node,y))}else t.node&&(i==="show"||i==="hide")&&(f=void 0,t.node.style.display="")}finally{d&&L()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}else if(j&&j.has(o)){const a=t[o],c=$(t,t[o+"Deps"],a),i=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=c(t,t.state,t.context);if(t.node)if(p!=null){const y=i+":"+String(p);y!==f&&(f=y,z(t.node,{[i]:p}))}else f=void 0,t.node.style[i]=""}finally{d&&L()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=$(t,t.htmlDeps,o),c=S(()=>{const i=t.context?.designSystem;i&&O(i);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{i&&L()}},{depth:n.path.length});n.__effects.push(c),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=$(t,t.valueDeps,o),c=S(()=>{try{const i=a(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=i==null?"":String(i);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});n.__effects.push(c),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=$(t,t.styleDeps,o);let c;const i=S(()=>{const f=a(t,t.state,t.context),u=gt(f);(u===null||u!==c)&&(c=u,z(t.node,f))},{depth:n.path.length});n.__effects.push(i),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 c=$(t,J(t.styleDeps,o),a);let i;const f=S(()=>{try{const u=c(t,t.state,t.context);if(t.node){const d=o+":"+String(u);d!==i&&(i=d,z(t.node,{[o]:u}))}}catch{}},{depth:n.path.length});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=$(t,J(t.attrDeps,o),t.attr[o]),c=o,i=S(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f))}catch{}},{depth:n.path.length});n.__effects.push(i)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const a=$(t,J(t.ariaDeps,o),t.aria[o]),c="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),i=S(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f)}catch{}},{depth:n.path.length});n.__effects.push(i)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const a=$(t,J(t.dataDeps,o),t.data[o]),i="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(i):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(i,u===!0?"":u)}catch{}},{depth:n.path.length});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=$(t,J(t.classDeps,o),e[o]),c=S(()=>{try{const i=a(t,t.state,t.context);if(!t.node?.classList)return;typeof i=="string"?t.node.classList.add(i):i?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(c)}!r&&typeof t.if=="function"&&Ft(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||H(o))continue;const c=t[o];n.__exec[o]=c;const i=t.tag||"div";if(dt(i,o)&&!E[o]&&!(j&&j.has(o))){const f=lt(o)||o,u=$(t,t[o+"Deps"],c),d=S(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(d)}}if(lo(t),ho(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let c=!1,i=[];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(!c){c=!0,i=u;return}let d=u.length!==i.length;for(let h=0;!d&&h<u.length;h++)u[h]!==i[h]&&(d=!0);const p=i;if(i=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&&M("error",t,{hook:"onStateUpdate",error:h})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',h),t.context?.strictMode)throw h}finally{y&&L()}},{depth:n.path.length});n.__effects.push(f)}yo(t)}function Tt(t){const s=t.parent,n=s?.node;if(!n||!t.node){Wt(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 c=s[e[a]];if(c?.node?.parentNode===n){r=c.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function Ft(t,s,n){const r=$(t,t.ifDeps,n),e=S(()=>{let o;try{o=r(t,t.state,t.context)}catch(c){if(o=!1,s.__ifError=c,typeof console<"u"&&console.warn){const i=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${i} \u2014 treating as false:`,c?.message||c)}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=at(t)),t.node&&(t.node.ref=t),Tt(t),_t(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=Et(t)),U("Init",t,{}),t.node||(t.node=at(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 i=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(i),s.__fragmentAnchor=i}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),Kt(t,{}),Rt(t,{skipIfEffect:!0}),_t(t),It(t),Vt(t,{}),Tt(t),Lt(t,{})}},{depth:s.path.length});s.__effects.push(e)}function _t(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),go(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"&&z(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||s.setAttribute&&s.setAttribute(n,r===!0?"":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 gt(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function z(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()),c=o.trim(),i=/\s*!important\s*$/.test(c),f=c.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,i?"important":"")}catch{}}}n&&uo(t,n)}let fo=0;function uo(t,s){const n=`_ds${fo++}`;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 c="."+n,i=a.replace(/&/g,c).split(",").map(u=>{const d=u.trim();return d.includes(c)?d:c+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("&")?i.split(", ").map(_=>p.replace(/&/g,_)).join(", "):i.split(", ").map(_=>`${_} ${p}`).join(", ");let l="";for(const _ in y)l+=`${_.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[_]};`;d+=Pt(`${h} { ${l} }`,h)+`
|
|
4
|
+
`):"")}}if(St(o,!0),Wt(o,s,e),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&&L()}}if(U("Create",o,r),U("Complete",o,r),U("Render",o,r),U("RenderRouter",o,r),Lt(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{_&&L()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function no(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&&!I(t.state)?t.state:void 0;if(a==null){if(s?.state)t.state=s.state,Q(t,t.state);else if(t.context?.state){const c=t.context.state,i={...c},f=t.context?.polyglot;if(f?.translations){const u=c.lang||f.defaultLang||"en",d=f.translations[u];if(d&&typeof d=="object")for(const y in d)i[y]===void 0&&(i[y]=d[y]);const p=new Set(f.languages||[]);for(const y in f.translations)!p.has(y)&&i[y]===void 0&&(i[y]=f.translations[y])}t.state=I(i)?i:et(i),t.state.__element=t,t.state.root=t.state,Q(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),Q(t,t.state);return}if(typeof a=="string"){if(t.state=Dt(a,s),t.state&&typeof t.state=="object"&&!I(t.state)){const c=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:c,enumerable:!1,configurable:!0,writable:!0})}Q(t,t.state);return}if(typeof a=="function"){const c=a(t,s?.state);t.state=I(c)?c:et(c||{})}else I(a)?t.state=a:t.state=et({...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,Q(t,t.state)}function ht(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 Dt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const e=t.slice(3);return e?ht(s.state,e):s.state??{}}if(t.startsWith("~/")){const e=s.state?.root||s.state,o=t.slice(2);return o?ht(e,o):e??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=ht(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 ro=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 io(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&&!ro.has(n)}function eo(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 c=o[a];if(typeof t[c]!="function"||B.has(c))continue;const i=c.charCodeAt(0);i>=65&&i<=90||G(c)||E[c]||j&&j.has(c)||dt(n,c)||(ft()&&io(t[c])&&console.warn(`[smbls] custom prop "${c}"${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('${c}', \u2026) instead of reading el.${c}(\u2026) directly (see RULES.md Rule 8).`),e.push({prop:c,fn:t[c]}))}for(let a=0;a<e.length;a++){const{prop:c,fn:i}=e[a];s.__exec[c]=i,Object.defineProperty(t,c,{get(){r&&O(r);try{return i(t,t.state,t.context)}catch{return}finally{r&&L()}},set(f){delete s.__exec[c],Object.defineProperty(t,c,{value:f,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function ao(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 $(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...r){return ao(t,s),n.apply(this,r)}}function J(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Rt(t,s){const n=t.__ref,r=!!(s&&s.skipIfEffect);if(eo(t),typeof t.text=="function"){const o=t.text,a=$(t,t.textDeps,o),c=S(()=>{if(!n.contentManaged)try{let i=a(t,t.state,t.context);t.node&&i!=null&&typeof i!="function"&&typeof i!="object"&&(typeof i=="string"&&i.includes("{{")&&(i=ut.call(t,i,t.state)),t.tag==="string"?t.node.nodeValue=i:t.node.textContent=i)}catch{}},{depth:n.path.length});n.__effects.push(c),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,a=S(()=>{if(n.contentManaged)return;const c=ut.call(t,o,t.state);c!=null&&(t.text=c),t.node&&(t.tag==="string"?t.node.nodeValue=c??"":t.node.textContent=c??"")},{depth:n.path.length});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)&&!G(o)&&!n.__exec[o]){if(E[o]){const a=t[o],c=$(t,t[o+"Deps"],a),i=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=c(t,t.state,t.context),y=E[i](p,t,t.state,t.context);if(y&&t.node){const h=gt(y);(h===null||h!==f)&&(f=h,z(t.node,y))}else t.node&&(i==="show"||i==="hide")&&(f=void 0,t.node.style.display="")}finally{d&&L()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}else if(j&&j.has(o)){const a=t[o],c=$(t,t[o+"Deps"],a),i=o;let f;const u=S(()=>{const d=t.context?.designSystem;d&&O(d);try{const p=c(t,t.state,t.context);if(t.node)if(p!=null){const y=i+":"+String(p);y!==f&&(f=y,z(t.node,{[i]:p}))}else f=void 0,t.node.style[i]=""}finally{d&&L()}},{depth:n.path.length});n.__effects.push(u),n.__exec[o]=a}}if(typeof t.html=="function"){const o=t.html,a=$(t,t.htmlDeps,o),c=S(()=>{const i=t.context?.designSystem;i&&O(i);try{const f=a(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{i&&L()}},{depth:n.path.length});n.__effects.push(c),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,a=$(t,t.valueDeps,o),c=S(()=>{try{const i=a(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=i==null?"":String(i);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});n.__effects.push(c),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,a=$(t,t.styleDeps,o);let c;const i=S(()=>{const f=a(t,t.state,t.context),u=gt(f);(u===null||u!==c)&&(c=u,z(t.node,f))},{depth:n.path.length});n.__effects.push(i),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 c=$(t,J(t.styleDeps,o),a);let i;const f=S(()=>{try{const u=c(t,t.state,t.context);if(t.node){const d=o+":"+String(u);d!==i&&(i=d,z(t.node,{[o]:u}))}}catch{}},{depth:n.path.length});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=$(t,J(t.attrDeps,o),t.attr[o]),c=o,i=S(()=>{try{const f=a(t,t.state,t.context);t.node?.setAttribute&&(f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f))}catch{}},{depth:n.path.length});n.__effects.push(i)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const a=$(t,J(t.ariaDeps,o),t.aria[o]),c="aria-"+o.replace(/[A-Z]/g,f=>"-"+f.toLowerCase()),i=S(()=>{try{const f=a(t,t.state,t.context);if(!t.node?.setAttribute)return;f==null||f===!1?t.node.removeAttribute(c):typeof f!="function"&&typeof f!="object"&&t.node.setAttribute(c,f===!0?"":f)}catch{}},{depth:n.path.length});n.__effects.push(i)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const a=$(t,J(t.dataDeps,o),t.data[o]),i="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(i):typeof u!="function"&&typeof u!="object"&&t.node.setAttribute(i,u===!0?"":u)}catch{}},{depth:n.path.length});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=$(t,J(t.classDeps,o),e[o]),c=S(()=>{try{const i=a(t,t.state,t.context);if(!t.node?.classList)return;typeof i=="string"?t.node.classList.add(i):i?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(c)}!r&&typeof t.if=="function"&&Ft(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||G(o))continue;const c=t[o];n.__exec[o]=c;const i=t.tag||"div";if(dt(i,o)&&!E[o]&&!(j&&j.has(o))){const f=lt(o)||o,u=$(t,t[o+"Deps"],c),d=S(()=>{try{const p=u(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(f):typeof p!="function"&&typeof p!="object"&&(f==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(f,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(d)}}if(lo(t),ho(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,a=t.stateDeps;let c=!1,i=[];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(!c){c=!0,i=u;return}let d=u.length!==i.length;for(let h=0;!d&&h<u.length;h++)u[h]!==i[h]&&(d=!0);const p=i;if(i=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&&M("error",t,{hook:"onStateUpdate",error:h})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',h),t.context?.strictMode)throw h}finally{y&&L()}},{depth:n.path.length});n.__effects.push(f)}yo(t)}function Tt(t){const s=t.parent,n=s?.node;if(!n||!t.node){Wt(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 c=s[e[a]];if(c?.node?.parentNode===n){r=c.node;break}}r?n.insertBefore(t.node,r):n.appendChild(t.node)}function Ft(t,s,n){const r=$(t,t.ifDeps,n),e=S(()=>{let o;try{o=r(t,t.state,t.context)}catch(c){if(o=!1,s.__ifError=c,typeof console<"u"&&console.warn){const i=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${i} \u2014 treating as false:`,c?.message||c)}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=at(t)),t.node&&(t.node.ref=t),Tt(t),_t(t);else{if(s.__ifInitialized=!0,t.tag||(t.tag=Et(t)),U("Init",t,{}),t.node||(t.node=at(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 i=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(i),s.__fragmentAnchor=i}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),Kt(t,{}),Rt(t,{skipIfEffect:!0}),_t(t),It(t),Vt(t,{}),Tt(t),Lt(t,{})}},{depth:s.path.length});s.__effects.push(e)}function _t(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),go(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"&&z(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||s.setAttribute&&s.setAttribute(n,r===!0?"":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 gt(t){if(t==null||typeof t!="object")return"s:"+String(t);try{return"o:"+JSON.stringify(t)}catch{return null}}function z(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()),c=o.trim(),i=/\s*!important\s*$/.test(c),f=c.replace(/\s*!important\s*$/,"");t.style.setProperty(a,f,i?"important":"")}catch{}}}n&&uo(t,n)}let fo=0;function uo(t,s){const n=`_ds${fo++}`;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 c="."+n,i=a.replace(/&/g,c).split(",").map(u=>{const d=u.trim();return d.includes(c)?d:c+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("&")?i.split(", ").map(_=>p.replace(/&/g,_)).join(", "):i.split(", ").map(_=>`${_} ${p}`).join(", ");let l="";for(const _ in y)l+=`${_.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[_]};`;d+=Pt(`${h} { ${l} }`,h)+`
|
|
5
5
|
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${y};`}u&&(o+=Pt(`${i} { ${u} }`,i)+`
|
|
6
|
-
`),d&&(o+=d)}}o&&(e.textContent+=o)}function lo(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],c=o.slice(1),i={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<c.length&&!(d==null||typeof d!="object");y++)if(I(d))d=d[c[y]];else break;if(!i.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&O(y);try{if(Ao(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>nt(n,!1),l=>{nt(n,!0),t.context?.plugins?.length&&M("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(nt(n,!1),h===!1&&(p=!0))}}catch(h){nt(n,!0),t.context?.plugins?.length&&M("error",t,{hook:"onBeforeUpdate",error:h})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",h)}finally{y&&L()}}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&&M("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&L()}}},{depth:n.path.length});i.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function bt(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 Nt=new Set;function po(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",r=n+"::"+t;Nt.has(r)||(Nt.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 Y(t,s,n){const r={},e=new Set,o=(a,c,i)=>{const f=i?new Set(Object.keys(r)):null;if(E[a]){const u=E[a](c,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]=c;if(i)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 c=t[a];if(typeof c=="function"&&(c=c(s,s.state,s.context)),c==null||typeof c=="function")continue;if(typeof c=="object"&&!Array.isArray(c)){if(a==="style"){for(const d in c){let p=c[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]||j&&j.has(d));o(d,p,y)}continue}if(bt(a,s)){const d=Y(c,s,!1);Object.keys(d).length&&(r[`[data-theme="${a.slice(1)}"] &`]=d);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(a)){ft()&&po(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=Y(c,s,!1);Object.keys(u).length&&(r[f]=u);continue}const i=typeof s[a]=="function"&&(E[a]||j&&j.has(a));o(a,c,i)}if(n)for(const a in r)e.add(a);for(const a of e){const c=r[a];typeof c=="string"&&!c.includes("!important")&&(r[a]=c+" !important")}return r}function xt(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)&&xt(t[n],s+1))return!0}return!1}function Mt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(bt(t,n)){const o=Y(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=Y(s,n,!1);return Object.keys(e).length?{cssProp:r,block:e}:null}function yo(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!yt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!xt(r))continue;let e=null,o;const a=S(()=>{if(!t.node)return;const c=t.context?.designSystem;c&&O(c);let i,f=!1;try{const u=Mt(n,r,t),d=u?gt(u.block)+"::"+u.cssProp:null;if(d!==null&&d===o)f=!0;else if(o=d,u){const p=tt({[u.cssProp]:u.block},null,t.context?.cssPrefix);i=p?p.split(" ").filter(Boolean):null}else i=null}finally{c&&L()}if(!(f||!t.node.classList)){if(e)for(const u of e)t.node.classList.remove(u);if(i&&i.length)for(const u of i)t.node.classList.add(u);e=i}},{depth:s.path.length});s.__effects.push(a)}}function ho(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 c=e==="!",i={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=c?!d:!!d;if(!t.node||y===i.lastMatch)return;i.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 w=a[b],k=b.charAt(0);if((k===":"||k==="@"||k==="&")&&w&&typeof w=="object"&&!Array.isArray(w)){if(bt(b,t)){const D=Y(w,t,!1);Object.keys(D).length&&(_[`[data-theme="${b.slice(1)}"] &`]=D,g=!0)}else{let D=b;if(k==="@"&&!b.startsWith("@media")&&!b.startsWith("@keyframes")){const K=t.context?.designSystem?.media?.[b.slice(1)];K&&(D=`@media ${K}`)}const V=Y(w,t,!1);Object.keys(V).length&&(_[D]=V,g=!0)}continue}const v=typeof w=="function"?w(t,t.state,t.context):w;if(v!=null)if(E[b]){const D=E[b](v,t,t.state,t.context);if(D){const V=Array.isArray(D)?D:[D];for(const K of V)K&&Object.assign(l,K)}}else j&&j.has(b)&&(l[b]=v)}const x=Object.keys(l);if(x.length){z(t.node,l);for(const b of x)n.set(b,r);i.appliedKeys=x}else i.appliedKeys=null;if(g){const b=tt(_,null,t.context?.cssPrefix),w=b?b.split(" ").filter(Boolean):[];if(w.length&&t.node.classList){for(const k of w)t.node.classList.add(k);i.appliedClasses=w}else i.appliedClasses=null}else if(i.appliedClasses){for(const b of i.appliedClasses)t.node.classList.remove(b);i.appliedClasses=null}}else{if(i.appliedKeys){for(const l of i.appliedKeys)n.get(l)===r&&(t.node.style[l]="",n.delete(l));i.appliedKeys=null}if(i.appliedClasses){for(const l of i.appliedClasses)t.node.classList.remove(l);i.appliedClasses=null}}}finally{h&&L()}};s.__conditionalRunners.push(f);const u=S(f,{depth:s.path.length});s.__effects.push(u)}}const At=new WeakSet;function _o(t){const s=t.ownerDocument;!s||At.has(s)||(At.add(s),queueMicrotask(()=>{At.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const Ct=new WeakSet;let Ut=!1;function go(t){const{node:s}=t;if(!s)return;if(Ut||(Ut=!0,tt({display:"none"})),Ct.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}Ct.add(t);const n=t.context?.designSystem;n&&O(n);try{const r={};let e=!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);e=!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)&&!H(o)){if(E[o]){const c=t[o],i=E[o](c,t,t.state,t.context);if(i){if(Array.isArray(i))for(const f of i)f&&Object.assign(r,f);else Object.assign(r,i);e=!0}}else if(j&&j.has(o)){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,e=!0)}else if(o.charCodeAt(0)===45){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,e=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const c=t[o];if(c&&typeof c=="object"&&!Array.isArray(c)){if(xt(c))continue;const i=Mt(o,c,t);i&&(r[i.cssProp]=i.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=tt(r,null,t.context?.cssPrefix);if(o&&s.classList){const c=o.split(" ").filter(Boolean);let i=!1;for(const f of c)s.classList.add(f),i||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(i=!0);i&&_o(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const c=r.display;if(c&&c!==a)if(a==="none"){const i=[];for(const f of s.classList)f.startsWith("_d-")&&f!=="_d-none"&&i.push(f);for(const f of i)s.classList.remove(f);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&L(),Ct.delete(t)}}function It(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||o===!1)continue;const a="aria-"+e.replace(/[A-Z]/g,c=>"-"+c.toLowerCase());s.setAttribute(a,o===!0?"":o)}const n=Qt(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"||B.has(e)||e==="on"||n[e]!==void 0)continue;const o=e.charCodeAt(0);if(!(o>=65&&o<=90)&&!H(e)&&!(E[e]||j&&j.has(e))&&dt(r,e)){let a=t[e];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=ut(a,t,t.state,t.context),t[e]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!Jt(lt(e)||e))continue;const c=lt(e)||e;s.setAttribute(c,Xt(c,a))}}}function bo(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 Bt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Kt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!H(n)||Bt.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(c){return t.call(o,c)}}if(typeof r!="function")continue;const e=oo(n);zt.has(e)||Yt(so(e),t,r)}xo(t)}function xo(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Bt){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,c=0,i=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,c=y.clientY,i=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-c,_=Date.now()-i;if(_>o)return;const g=Math.abs(h),x=Math.abs(l);if(Math.max(g,x)<e)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 w="onSwipe"+b.charAt(0).toUpperCase()+b.slice(1),k=n[w],v=n.onSwipe;k&&k.call(t,p,t,t.state,t.context),v&&v.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 st(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]=st(e,o):n[r]=o}return n}function kt(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 c=t.childProps,i=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=c;if(typeof c=="function")try{p=c(t,u)}catch{p=null}if(i==="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=st(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=G(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=Dt(s,t);if(Array.isArray(e))return kt(t,e,n)}if(typeof s=="object")for(const e in s){if(B.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=st(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],c=Array.isArray(r)?r:[r];o={...o,extends:[...c,...a]}}else o={...o,extends:r};G(o,t,e,n)}}}function St(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",c=t.value!=null&&typeof t.value!="function";if(a||c){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 i=s||!(e&&e.__selectSynced);if(e&&(e.__selectSynced=!0),!i)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 Vt(t,s){let{children:n,content:r}=t;const e=t.childExtends;if(typeof n=="function"){const c=n;try{n=c(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 i=t.__ref;let f=!1;const u=$(t,t.childrenDeps,c),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 v=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${v}${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,v=[],D=new Map;for(let A=0;A<y.length;A++){const R=y[A];let C=k;if(typeof k=="function")try{C=k(t,R)}catch{C=null}const F=C&&C.key||R&&R.key||`${A}`;v.push(F),D.set(F,{rawChild:R,childProps:C})}const V=new Set(v),K=i.__children.slice();for(const A of K)if(!V.has(A)){const R=t[A];R?.remove&&R.remove(),delete t[A],_&&_.push(A)}const Z=t.childExtends,m=t.tag==="fragment",Ht=t.context?.document||globalThis.document,q=m?null:Ht?.createDocumentFragment(),rt=new Set;for(const A of v){const R=D.get(A),C=R.rawChild,F=t[A];if(F&&F.state){if(C&&typeof C=="object"){const P=F.state,W=P.$replace||P.replace,jt=P.$update||P.update;if(typeof W=="function")W.call(P,C);else if(typeof jt=="function"){for(const N in P)if(!(N==="__element"||N==="root"||N==="parent"||N==="update")&&!Object.prototype.hasOwnProperty.call(C,N))try{P[N]=void 0}catch{}jt.call(P,C)}else for(const N in C)P[N]=C[N]}g&&g.push(A);continue}let ct=C;(typeof C=="string"||typeof C=="number")&&(ct={value:C,text:C});const wt=R.childProps;let T=wt?{...wt,state:ct}:{state:ct};if(Z&&!T.ignoreChildExtends)if(T.extends){const P=Array.isArray(T.extends)?T.extends:[T.extends],W=Array.isArray(Z)?Z:[Z];T={...T,extends:[...W,...P]}}else T={...T,extends:Z};let it;try{it=G(T,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)}rt.add(A);continue}!m&&it?.node&&q&&q.appendChild(it.node),l&&l.push(A)}if(!m&&q&&q.childNodes.length&&t.node&&t.node.appendChild(q),!m&&t.node){let A=null;for(const R of v){const C=t[R]?.node;if(!C)continue;const F=A?A.nextSibling:t.node.firstChild;C!==F&&t.node.insertBefore(C,F),A=C}}i.__children=rt.size?v.filter(A=>!rt.has(A)):v,h&&(l.length||_.length)&&$t(t,{added:l,removed:_,kept:g}),St(t,!1);return}const w=h?[...i.__children]:null;for(const k of[...i.__children]){const v=t[k];v?.remove&&v.remove(),delete t[k]}i.__children=[],kt(t,y,s),St(t,!1),h&&$t(t,{added:[...i.__children],removed:w,kept:[]})},{depth:i.path.length});i.__effects.push(d)}const o=kt(t,n||r,s);if((n||r)&&!o)return;const a=t.context?.components||{};{const c=Object.keys(t);for(let i=0;i<c.length;i++){const f=c[i];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=i+1;p<c.length;p++){const y=c[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 c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||B.has(c)||typeof t[c]!="object"||t[c]===null)continue;const i=c.charCodeAt(0);if(i<65||i>90)continue;let f=t[c];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[c]||a[`smbls.${c}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=st(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};G(f,t,c,s)}}}function Wt(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 c=n.node.nextSibling;a.insertBefore(r,c||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 vt=3;function Ao(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=vt?!1:(t.__inBeforeUpdate=!0,!0)}function nt(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===vt&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${vt}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&&M(r,s,n);const e="on"+t,o=s[e];if(typeof o=="function"){const i=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(i){if(s.__ref[i])return!0;s.__ref[i]=!0}const f=s.context?.designSystem;f&&O(f);let u=!!i;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&&M("error",s,{hook:e,error:y})||console.error(`[DOMQL] Lifecycle "${e}" error:`,y)}).finally(()=>{i&&p&&(p[i]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&M("error",s,{hook:e,error:d})||console.error(`[DOMQL] Lifecycle "${e}" error:`,d),s.context?.strictMode)throw d}finally{f&&L(),u&&s.__ref&&(s.__ref[i]=!1)}}return!0}var Ko=G;export{vt as BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES,Ao as acquireBeforeUpdateGuard,G as create,Ko as default,Ot as flushMounts,nt as releaseBeforeUpdateGuard};
|
|
6
|
+
`),d&&(o+=d)}}o&&(e.textContent+=o)}function lo(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],c=o.slice(1),i={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<c.length&&!(d==null||typeof d!="object");y++)if(I(d))d=d[c[y]];else break;if(!i.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&O(y);try{if(Ao(n)){const h=t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0});h&&typeof h.then=="function"?h.then(()=>nt(n,!1),l=>{nt(n,!0),t.context?.plugins?.length&&M("error",t,{hook:"onBeforeUpdate",error:l})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",l)}):(nt(n,!1),h===!1&&(p=!0))}}catch(h){nt(n,!0),t.context?.plugins?.length&&M("error",t,{hook:"onBeforeUpdate",error:h})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",h)}finally{y&&L()}}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&&M("error",t,{hook:"onUpdate",error:h})||console.error("[DOMQL] subscribeTo onUpdate error:",h)}finally{y&&L()}}},{depth:n.path.length});i.value=!0,f._isSubscribeToEffect=!0,n.__effects.push(f)}}function bt(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 Nt=new Set;function po(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",r=n+"::"+t;Nt.has(r)||(Nt.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 Y(t,s,n){const r={},e=new Set,o=(a,c,i)=>{const f=i?new Set(Object.keys(r)):null;if(E[a]){const u=E[a](c,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]=c;if(i)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 c=t[a];if(typeof c=="function"&&(c=c(s,s.state,s.context)),c==null||typeof c=="function")continue;if(typeof c=="object"&&!Array.isArray(c)){if(a==="style"){for(const d in c){let p=c[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]||j&&j.has(d));o(d,p,y)}continue}if(bt(a,s)){const d=Y(c,s,!1);Object.keys(d).length&&(r[`[data-theme="${a.slice(1)}"] &`]=d);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(a)){ft()&&po(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=Y(c,s,!1);Object.keys(u).length&&(r[f]=u);continue}const i=typeof s[a]=="function"&&(E[a]||j&&j.has(a));o(a,c,i)}if(n)for(const a in r)e.add(a);for(const a of e){const c=r[a];typeof c=="string"&&!c.includes("!important")&&(r[a]=c+" !important")}return r}function xt(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)&&xt(t[n],s+1))return!0}return!1}function Mt(t,s,n){if(!s||typeof s!="object"||Array.isArray(s))return null;if(bt(t,n)){const o=Y(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=Y(s,n,!1);return Object.keys(e).length?{cssProp:r,block:e}:null}function yo(t){const s=t.__ref;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!yt(n))continue;const r=t[n];if(!r||typeof r!="object"||Array.isArray(r)||!xt(r))continue;let e=null,o;const a=S(()=>{if(!t.node)return;const c=t.context?.designSystem;c&&O(c);let i,f=!1;try{const u=Mt(n,r,t),d=u?gt(u.block)+"::"+u.cssProp:null;if(d!==null&&d===o)f=!0;else if(o=d,u){const p=ot({[u.cssProp]:u.block},null,t.context?.cssPrefix);i=p?p.split(" ").filter(Boolean):null}else i=null}finally{c&&L()}if(!(f||!t.node.classList)){if(e)for(const u of e)t.node.classList.remove(u);if(i&&i.length)for(const u of i)t.node.classList.add(u);e=i}},{depth:s.path.length});s.__effects.push(a)}}function ho(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 c=e==="!",i={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=c?!d:!!d;if(!t.node||y===i.lastMatch)return;i.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 w=a[b],k=b.charAt(0);if((k===":"||k==="@"||k==="&")&&w&&typeof w=="object"&&!Array.isArray(w)){if(bt(b,t)){const D=Y(w,t,!1);Object.keys(D).length&&(_[`[data-theme="${b.slice(1)}"] &`]=D,g=!0)}else{let D=b;if(k==="@"&&!b.startsWith("@media")&&!b.startsWith("@keyframes")){const K=t.context?.designSystem?.media?.[b.slice(1)];K&&(D=`@media ${K}`)}const W=Y(w,t,!1);Object.keys(W).length&&(_[D]=W,g=!0)}continue}const v=typeof w=="function"?w(t,t.state,t.context):w;if(v!=null)if(E[b]){const D=E[b](v,t,t.state,t.context);if(D){const W=Array.isArray(D)?D:[D];for(const K of W)K&&Object.assign(l,K)}}else j&&j.has(b)&&(l[b]=v)}const x=Object.keys(l);if(x.length){z(t.node,l);for(const b of x)n.set(b,r);i.appliedKeys=x}else i.appliedKeys=null;if(g){const b=ot(_,null,t.context?.cssPrefix),w=b?b.split(" ").filter(Boolean):[];if(w.length&&t.node.classList){for(const k of w)t.node.classList.add(k);i.appliedClasses=w}else i.appliedClasses=null}else if(i.appliedClasses){for(const b of i.appliedClasses)t.node.classList.remove(b);i.appliedClasses=null}}else{if(i.appliedKeys){for(const l of i.appliedKeys)n.get(l)===r&&(t.node.style[l]="",n.delete(l));i.appliedKeys=null}if(i.appliedClasses){for(const l of i.appliedClasses)t.node.classList.remove(l);i.appliedClasses=null}}}finally{h&&L()}};s.__conditionalRunners.push(f);const u=S(f,{depth:s.path.length});s.__effects.push(u)}}const At=new WeakSet;function _o(t){const s=t.ownerDocument;!s||At.has(s)||(At.add(s),queueMicrotask(()=>{At.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const Ct=new WeakSet;let Ut=!1;function go(t){const{node:s}=t;if(!s)return;if(Ut||(Ut=!0,ot({display:"none"})),Ct.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}Ct.add(t);const n=t.context?.designSystem;n&&O(n);try{const r={};let e=!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);e=!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)&&!G(o)){if(E[o]){const c=t[o],i=E[o](c,t,t.state,t.context);if(i){if(Array.isArray(i))for(const f of i)f&&Object.assign(r,f);else Object.assign(r,i);e=!0}}else if(j&&j.has(o)){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,e=!0)}else if(o.charCodeAt(0)===45){const c=t[o];c!=null&&typeof c!="object"&&(r[o]=c,e=!0)}else if(o.charAt(0)==="&"||o.charAt(0)==="@"||o.charAt(0)===":"){const c=t[o];if(c&&typeof c=="object"&&!Array.isArray(c)){if(xt(c))continue;const i=Mt(o,c,t);i&&(r[i.cssProp]=i.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=ot(r,null,t.context?.cssPrefix);if(o&&s.classList){const c=o.split(" ").filter(Boolean);let i=!1;for(const f of c)s.classList.add(f),i||(f.charCodeAt(0)===95&&f.charCodeAt(1)===99||f.charCodeAt(0)===95&&f.indexOf("_c",1)!==-1)&&(i=!0);i&&_o(s)}const a=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(a!=null){const c=r.display;if(c&&c!==a)if(a==="none"){const i=[];for(const f of s.classList)f.startsWith("_d-")&&f!=="_d-none"&&i.push(f);for(const f of i)s.classList.remove(f);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&L(),Ct.delete(t)}}function It(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||o===!1)continue;const a="aria-"+e.replace(/[A-Z]/g,c=>"-"+c.toLowerCase());s.setAttribute(a,o===!0?"":o)}const n=Qt(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"||B.has(e)||e==="on"||n[e]!==void 0)continue;const o=e.charCodeAt(0);if(!(o>=65&&o<=90)&&!G(e)&&!(E[e]||j&&j.has(e))&&dt(r,e)){let a=t[e];if(a==null||(typeof a=="string"&&a.includes("{{")&&(a=ut(a,t,t.state,t.context),t[e]=a),a==null||typeof a=="function"||typeof a=="object")||a===!1&&!Jt(lt(e)||e))continue;const c=lt(e)||e;s.setAttribute(c,Xt(c,a))}}}function bo(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 Bt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Kt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!G(n)||Bt.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(c){return t.call(o,c)}}if(typeof r!="function")continue;const e=oo(n);zt.has(e)||Yt(so(e),t,r)}xo(t)}function xo(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of Bt){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,c=0,i=0,f=!1;const u=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(a=y.clientX,c=y.clientY,i=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-c,_=Date.now()-i;if(_>o)return;const g=Math.abs(h),x=Math.abs(l);if(Math.max(g,x)<e)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 w="onSwipe"+b.charAt(0).toUpperCase()+b.slice(1),k=n[w],v=n.onSwipe;k&&k.call(t,p,t,t.state,t.context),v&&v.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 m(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]=m(e,o):n[r]=o}return n}function kt(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 c=t.childProps,i=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=c;if(typeof c=="function")try{p=c(t,u)}catch{p=null}if(i==="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=m(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}!e&&h?.node&&a.appendChild(h.node)}return e||t.node.appendChild(a),!0}if(typeof s=="string"){const e=Dt(s,t);if(Array.isArray(e))return kt(t,e,n)}if(typeof s=="object")for(const e in s){if(B.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=m(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const a=Array.isArray(o.extends)?o.extends:[o.extends],c=Array.isArray(r)?r:[r];o={...o,extends:[...c,...a]}}else o={...o,extends:r};V(o,t,e,n)}}}function St(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",c=t.value!=null&&typeof t.value!="function";if(a||c){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 i=s||!(e&&e.__selectSynced);if(e&&(e.__selectSynced=!0),!i)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 Vt(t,s){let{children:n,content:r}=t;const e=t.childExtends;if(typeof n=="function"){const c=n;try{n=c(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 i=t.__ref;let f=!1;const u=$(t,t.childrenDeps,c),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 v=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${v}${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,v=[],D=new Map;for(let A=0;A<y.length;A++){const R=y[A];let C=k;if(typeof k=="function")try{C=k(t,R)}catch{C=null}const F=C&&C.key||R&&R.key||`${A}`;v.push(F),D.set(F,{rawChild:R,childProps:C})}const W=new Set(v),K=i.__children.slice();for(const A of K)if(!W.has(A)){const R=t[A];R?.remove&&R.remove(),delete t[A],_&&_.push(A)}const Z=t.childExtends,tt=t.tag==="fragment",Ht=t.context?.document||globalThis.document,q=tt?null:Ht?.createDocumentFragment(),rt=new Set;for(const A of v){const R=D.get(A),C=R.rawChild,F=t[A];if(F&&F.state){if(C&&typeof C=="object"){const P=F.state,H=P.$replace||P.replace,jt=P.$update||P.update;if(typeof H=="function")H.call(P,C);else if(typeof jt=="function"){for(const N in P)if(!(N==="__element"||N==="root"||N==="parent"||N==="update")&&!Object.prototype.hasOwnProperty.call(C,N))try{P[N]=void 0}catch{}jt.call(P,C)}else for(const N in C)P[N]=C[N]}g&&g.push(A);continue}let ct=C;(typeof C=="string"||typeof C=="number")&&(ct={value:C,text:C});const wt=R.childProps;let T=wt?{...wt,state:ct}:{state:ct};if(Z&&!T.ignoreChildExtends)if(T.extends){const P=Array.isArray(T.extends)?T.extends:[T.extends],H=Array.isArray(Z)?Z:[Z];T={...T,extends:[...H,...P]}}else T={...T,extends:Z};let it;try{it=V(T,t,A,s)}catch(P){if(typeof console<"u"&&console.error){const H=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] child "${A}" failed to construct at ${H} (reconcile, skipping this row):`,P?.message||P)}rt.add(A);continue}!tt&&it?.node&&q&&q.appendChild(it.node),l&&l.push(A)}if(!tt&&q&&q.childNodes.length&&t.node&&t.node.appendChild(q),!tt&&t.node){let A=null;for(const R of v){const C=t[R]?.node;if(!C)continue;const F=A?A.nextSibling:t.node.firstChild;C!==F&&t.node.insertBefore(C,F),A=C}}i.__children=rt.size?v.filter(A=>!rt.has(A)):v,h&&(l.length||_.length)&&$t(t,{added:l,removed:_,kept:g}),St(t,!1);return}const w=h?[...i.__children]:null;for(const k of[...i.__children]){const v=t[k];v?.remove&&v.remove(),delete t[k]}i.__children=[],kt(t,y,s),St(t,!1),h&&$t(t,{added:[...i.__children],removed:w,kept:[]})},{depth:i.path.length});i.__effects.push(d)}const o=kt(t,n,s);if(r!=null&&!(r&&r.__ref)){let c=r;if(typeof c=="string"||typeof c=="number"?c={text:c}:typeof c!="object"&&(c={}),t.childProps&&(c=m(t.childProps,c)),e&&!c.ignoreChildExtends)if(c.extends){const i=Array.isArray(c.extends)?c.extends:[c.extends],f=Array.isArray(e)?e:[e];c={...c,extends:[...f,...i]}}else c={...c,extends:e};V(c,t,"content",s)}if(n&&!o)return;const a=t.context?.components||{};{const c=Object.keys(t);for(let i=0;i<c.length;i++){const f=c[i];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=i+1;p<c.length;p++){const y=c[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 c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||B.has(c)||typeof t[c]!="object"||t[c]===null)continue;const i=c.charCodeAt(0);if(i<65||i>90)continue;let f=t[c];if(!f.__ref){if(!f.extends&&!f.extend){const u=a[c]||a[`smbls.${c}`];u&&(f={...f,extends:u})}if(t.childProps&&(f=m(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};V(f,t,c,s)}}}function Wt(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 c=n.node.nextSibling;a.insertBefore(r,c||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 vt=3;function Ao(t){return!t||t.__inBeforeUpdate||(t.__beforeUpdateFailCount||0)>=vt?!1:(t.__inBeforeUpdate=!0,!0)}function nt(t,s){t&&(t.__inBeforeUpdate=!1,s?(t.__beforeUpdateFailCount=(t.__beforeUpdateFailCount||0)+1,t.__beforeUpdateFailCount===vt&&typeof console<"u"&&console.error&&console.error(`[DOMQL] onBeforeUpdate failed ${vt}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&&M(r,s,n);const e="on"+t,o=s[e];if(typeof o=="function"){const i=t==="Render"?"__inRender":t==="RenderRouter"?"__inRenderRouter":null;if(i){if(s.__ref[i])return!0;s.__ref[i]=!0}const f=s.context?.designSystem;f&&O(f);let u=!!i;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&&M("error",s,{hook:e,error:y})||console.error(`[DOMQL] Lifecycle "${e}" error:`,y)}).finally(()=>{i&&p&&(p[i]=!1)}),u=!1,!0}if(d===!1)return!1}catch(d){if(s.context?.plugins?.length&&M("error",s,{hook:e,error:d})||console.error(`[DOMQL] Lifecycle "${e}" error:`,d),s.context?.strictMode)throw d}finally{f&&L(),u&&s.__ref&&(s.__ref[i]=!1)}}return!0}var Ko=V;export{vt as BEFORE_UPDATE_MAX_CONSECUTIVE_FAILURES,Ao as acquireBeforeUpdateGuard,V as create,Ko as default,Ot as flushMounts,nt as releaseBeforeUpdateGuard};
|