@symbo.ls/element 3.14.671 → 3.14.672
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 +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ct=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var Kt=(t,s)=>{for(var n in s)ct(t,n,{get:s[n],enumerable:!0})},Ut=(t,s,n,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of Mt(s))!It.call(t,f)&&f!==n&&ct(t,f,{get:()=>s[f],enumerable:!(c=Nt(s,f))||c.enumerable});return t};var Vt=t=>Ut(ct({},"__esModule",{value:!0}),t);var ro={};Kt(ro,{create:()=>U,default:()=>co,flushMounts:()=>ht});module.exports=Vt(ro);var E=require("@symbo.ls/signal"),j=require("@symbo.ls/signal"),V=require("./cache.js"),$=require("./registry.js"),Tt=require("./delegate.js"),$t=require("./extends.js"),Rt=require("./methods.js"),ao=require("./dispose.js"),yt=require("./devRuntime.js"),st=require("@symbo.ls/utils"),K=require("@symbo.ls/utils/function.js"),Z=require("@symbo.ls/state"),A=require("css-in-props"),W=require("@symbo.ls/css"),b=require("@symbo.ls/scratch"),z=require("attrs-in-props");let Wt=1;const tt=[];let rt=!1;function Bt(){rt||(rt=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(ht):setTimeout(ht,0))}function ht(){if(rt=!1,!tt.length)return;const t=tt.splice(0,tt.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 bt(t,s){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=s,tt.push(t),Bt())}function At(t,s){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&(0,K.runPluginHook)("contentUpdate",t,s);const n=t.context?.designSystem;n&&(0,b.pushConfig)(n);try{t.onContentUpdate(t,t.state,t.context,s)}catch(c){if(t.context?.plugins?.length&&(0,K.runPluginHook)("error",t,{hook:"onContentUpdate",error:c})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',c),t.context?.strictMode)throw c}finally{n&&(0,b.popConfig)()}}function H(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function Ht(t){return t.charAt(2).toLowerCase()+t.slice(3)}function Yt(t){return t.toLowerCase()}function Ct(t){const s=t.charCodeAt(0);return s===58||s===64||s===38}function Q(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=Q(f,o):n[c]=o}return n}function U(t,s,n,c={},f){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||`_${Wt++}`,o.parent=s||null,o.context=t.context||s?.context||c.context||{},o.context.__create||(o.context.__create=U);const i=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:s?.__ref?.root||o,path:s?.__ref?.path?[...s.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const u=n.indexOf("_");if(u>0){const h=n.substring(0,u),g=o.context?.components;g&&(g[h]||g["smbls."+h])?t={...t,extends:h}:g&&(0,yt.isLoudDevRuntime)()&&/^[A-Z]\w*_\d+$/.test(n)&&console.warn(`[smbls] auto-extend: key "${n}" looks like a multi-instance (${h}_N) but neither "${h}" nor "smbls.${h}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}(0,$t.applyExtends)(o,t,c);const e=new Set(["childProps","attr","style","scope","data"]),r=o.props&&typeof o.props=="object"?o.props:null;for(const u in t){if(u==="parent"||u==="node"||u==="__ref"||u==="extends"||u==="context"||u==="props")continue;const h=t[u],g=o[u],S=g&&h&&typeof g=="object"&&typeof h=="object"&&!Array.isArray(g)&&!Array.isArray(h)&&typeof g!="function"&&typeof h!="function";S&&u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90?o[u]=Q(g,h):S&&e.has(u)?o[u]={...g,...h}:S&&Ct(u)?o[u]=Q(g,h):o[u]=h}function a(u){for(const h in u){const g=u[h],S=o[h],x=S&&g&&typeof S=="object"&&typeof g=="object"&&!Array.isArray(S)&&!Array.isArray(g)&&typeof S!="function"&&typeof g!="function";x&&h.charCodeAt(0)>=65&&h.charCodeAt(0)<=90?o[h]=Q(S,g):x&&e.has(h)?o[h]={...S,...g}:x&&Ct(h)?o[h]=Q(S,g):o[h]=g}}r&&a(r),t.props&&typeof t.props=="object"&&a(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 d=o.scope&&typeof o.scope=="object"?o.scope:null,l=s?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,y=l||p||null;if(t.scope!==void 0||d){const u={};d&&Object.assign(u,d),t.scope!==void 0&&Object.assign(u,t.scope),o.scope=(0,E.createScopeStore)(u,y)}else y&&(o.scope=y);if(t.if!==void 0&&(o.if=t.if),(0,Rt.addMethods)(o),Gt(o,s,t),o.if!=null){let u;if(typeof o.if=="function")try{u=o.if(o,o.state,o.context)}catch(h){if(u=!1,i.__ifError=h,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,h?.message||h)}}else u=o.if;i.__if=!!u}if(i.__if)typeof o.if=="function"&&(i.__ifInitialized=!0);else return s&&(s[o.key]=o),typeof o.if=="function"&&kt(o,i,o.if),o;o.tag||(o.tag=(0,V.detectTag)(o)),I("Init",o,c);const _=o.node=(0,V.cacheNode)(o);if(!_)return o;if(o.tag==="fragment"){const h=(o.context?.document||globalThis.document).createComment("");_.appendChild(h),i.__fragmentAnchor=h}I("AttachNode",o,c),_.setAttribute&&o.key&&_.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))),_.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&_.setAttribute("data-smbls-app",o.context.key),o.id&&_.setAttribute&&(_.id=o.id),Lt(o,c),St(o),et(o),Pt(o),so(o);try{Dt(o,c)}catch(u){if(typeof console<"u"&&console.error){const h=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${h}:`,u?.message||u,u?.stack?`
|
|
2
2
|
`+u.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(ut(o,!0),pt(o,s,f),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const u=o.context?.designSystem;u&&(0,b.pushConfig)(u);try{const h=o.html(o,o.state,o.context);h!=null&&typeof h!="function"&&(o.node.innerHTML=h)}catch{}finally{u&&(0,b.popConfig)()}}if(I("Create",o,c),I("Complete",o,c),I("Render",o,c),I("RenderRouter",o,c),xt(o,c),typeof o.onFrame=="function"){const u=o.onFrame,h=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){h&&(0,b.pushConfig)(h);try{u(o,o.state,o.context)}catch(C){console.error("[DOMQL] onFrame error:",C)}finally{h&&(0,b.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function Yt(t,s,n){const c=!s,f=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=c&&f&&t.context?.state,i=n.state!==void 0&&!o?n.state:t.state&&!(0,j.isStore)(t.state)?t.state:void 0;if(i==null){if(s?.state)t.state=s.state,(0,Z.applyStateMethods)(t,t.state);else if(t.context?.state){const e=t.context.state,r={...e},a=t.context?.polyglot;if(a?.translations){const d=e.lang||a.defaultLang||"en",l=a.translations[d];if(l&&typeof l=="object")for(const y in l)r[y]===void 0&&(r[y]=l[y]);const p=new Set(a.languages||[]);for(const y in a.translations)!p.has(y)&&r[y]===void 0&&(r[y]=a.translations[y])}t.state=(0,j.isStore)(r)?r:(0,j.createStore)(r),t.state.__element=t,t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,Z.applyStateMethods)(t,t.state);return}if(typeof i=="string"){if(t.state=Ct(i,s),t.state&&typeof t.state=="object"&&!(0,j.isStore)(t.state)){const e=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:e,enumerable:!1,configurable:!0,writable:!0})}(0,Z.applyStateMethods)(t,t.state);return}if(typeof i=="function"){const e=i(t,s?.state);t.state=(0,j.isStore)(e)?e:(0,j.createStore)(e||{})}else(0,j.isStore)(i)?t.state=i:t.state=(0,j.createStore)({...i});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}function rt(t,s){if(!s)return t;const n=s.split("/");let c=t;for(const f of n){if(c==null)return{};c=c[f]}return c??{}}function Ct(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const f=t.slice(3);return f?rt(s.state,f):s.state??{}}if(t.startsWith("~/")){const f=s.state?.root||s.state,o=t.slice(2);return o?rt(f,o):f??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=rt(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const c=s.context?.polyglot;if(c?.translations){const f=s.state?.root?.lang||c.defaultLang||"en",o=c.translations[f];if(o?.[t]!==void 0)return o[t];if(c.translations[t]!==void 0)return c.translations[t]}return{}}function Gt(t){const s=t.__ref,n=t.tag||"div",c=t.context?.designSystem,f=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const e=o[i];if(typeof t[e]!="function"||T.REGISTRY.has(e))continue;const r=e.charCodeAt(0);r>=65&&r<=90||H(e)||A.CSS_PROPS_REGISTRY[e]||A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(e)||(0,q.checkAttributeByTagName)(n,e)||f.push({prop:e,fn:t[e]})}for(let i=0;i<f.length;i++){const{prop:e,fn:r}=f[i];s.__exec[e]=r,Object.defineProperty(t,e,{get(){c&&(0,b.pushConfig)(c);try{return r(t,t.state,t.context)}catch{return}finally{c&&(0,b.popConfig)()}},set(a){delete s.__exec[e],Object.defineProperty(t,e,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function Zt(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const c=s[n];try{typeof c=="function"?c(t,t.state,t.context):typeof c=="string"&&t.state?.[c]}catch{}}}function E(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...c){return Zt(t,s),n.apply(this,c)}}function X(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function vt(t,s){const n=t.__ref,c=!!(s&&s.skipIfEffect);if(Gt(t),typeof t.text=="function"){const o=t.text,i=E(t,t.textDeps,o),e=(0,w.createEffect)(()=>{if(!n.contentManaged)try{let r=i(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=ot.replaceLiteralsWithObjectFields.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,i=(0,w.createEffect)(()=>{if(n.contentManaged)return;const e=ot.replaceLiteralsWithObjectFields.call(t,o,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(i),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!T.REGISTRY.has(o)&&!H(o)&&!n.__exec[o]){if(A.CSS_PROPS_REGISTRY[o]){const i=t[o],e=E(t,t[o+"Deps"],i),r=o;let a;const d=(0,w.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,b.pushConfig)(l);try{const p=e(t,t.state,t.context),y=A.CSS_PROPS_REGISTRY[r](p,t,t.state,t.context);if(y&&t.node){const _=kt(y);(_===null||_!==a)&&(a=_,Y(t.node,y))}else t.node&&(r==="show"||r==="hide")&&(a=void 0,t.node.style.display="")}finally{l&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}else if(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const i=t[o],e=E(t,t[o+"Deps"],i),r=o;let a;const d=(0,w.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,b.pushConfig)(l);try{const p=e(t,t.state,t.context);if(t.node)if(p!=null){const y=r+":"+String(p);y!==a&&(a=y,Y(t.node,{[r]:p}))}else a=void 0,t.node.style[r]=""}finally{l&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}}if(typeof t.html=="function"){const o=t.html,i=E(t,t.htmlDeps,o),e=(0,w.createEffect)(()=>{const r=t.context?.designSystem;r&&(0,b.pushConfig)(r);try{const a=i(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&(t.node.innerHTML=a)}finally{r&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(e),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,i=E(t,t.valueDeps,o),e=(0,w.createEffect)(()=>{try{const r=i(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const a=r==null?"":String(r);if(t.node.value===a)return;const d=typeof document<"u"&&document.activeElement===t.node,l=d&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=d&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=a,d&&l!=null&&p!=null)try{t.node.setSelectionRange(l,p)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,i=E(t,t.styleDeps,o);let e;const r=(0,w.createEffect)(()=>{const a=i(t,t.state,t.context),d=kt(a);(d===null||d!==e)&&(e=d,Y(t.node,a))},{depth:n.path.length});n.__effects.push(r),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const i=t.style[o];if(typeof i!="function")continue;const e=E(t,X(t.styleDeps,o),i);let r;const a=(0,w.createEffect)(()=>{try{const d=e(t,t.state,t.context);if(t.node){const l=o+":"+String(d);l!==r&&(r=l,Y(t.node,{[o]:d}))}}catch{}},{depth:n.path.length});n.__effects.push(a)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const i=E(t,X(t.attrDeps,o),t.attr[o]),e=o,r=(0,w.createEffect)(()=>{try{const a=i(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(r)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const i=E(t,X(t.ariaDeps,o),t.aria[o]),e="aria-"+o.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),r=(0,w.createEffect)(()=>{try{const a=i(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const i=E(t,X(t.dataDeps,o),t.data[o]),r="data-"+o.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),a=(0,w.createEffect)(()=>{try{const d=i(t,t.state,t.context);if(!t.node?.setAttribute)return;d==null||d===!1?t.node.removeAttribute(r):typeof d!="function"&&typeof d!="object"&&t.node.setAttribute(r,d===!0?"":d)}catch{}},{depth:n.path.length});n.__effects.push(a)}const f=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(f)for(const o in f){if(typeof f[o]!="function")continue;const i=E(t,X(t.classDeps,o),f[o]),e=(0,w.createEffect)(()=>{try{const r=i(t,t.state,t.context);if(!t.node?.classList)return;typeof r=="string"?t.node.classList.add(r):r?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(e)}!c&&typeof t.if=="function"&&St(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 i=o.charCodeAt(0);if(i>=65&&i<=90||H(o))continue;const e=t[o];n.__exec[o]=e;const r=t.tag||"div";if((0,q.checkAttributeByTagName)(r,o)&&!A.CSS_PROPS_REGISTRY[o]&&!(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const a=o,d=E(t,t[o+"Deps"],e),l=(0,w.createEffect)(()=>{try{const p=d(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(a):typeof p!="function"&&typeof p!="object"&&(a==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(a,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(l)}}if(Qt(t),Jt(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,i=t.stateDeps;let e=!1,r=[];const a=(0,w.createEffect)(()=>{const d=[];for(let _=0;_<i.length;_++){const u=i[_];try{d[_]=typeof u=="function"?u(t,t.state,t.context):t.state?.[u]}catch{d[_]=void 0}}if(!e){e=!0,r=d;return}let l=d.length!==r.length;for(let _=0;!l&&_<d.length;_++)d[_]!==r[_]&&(l=!0);const p=r;if(r=d,!l)return;const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{o(t,t.state,t.context,{prev:p,next:d})}catch(_){if(t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{y&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(a)}}function St(t,s,n){const c=E(t,t.ifDeps,n),f=(0,w.createEffect)(()=>{let o;try{o=c(t,t.state,t.context)}catch(e){if(o=!1,s.__ifError=e,typeof console<"u"&&console.warn){const r=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${r} \u2014 treating as false:`,e?.message||e)}return}const i=s.__if;if(s.__if=!!o,i&&!s.__if&&t.node)t.node.remove();else if(!i&&s.__if)if(s.__ifInitialized){t.node||(t.node=(0,W.cacheNode)(t)),t.node&&(t.node.ref=t);const e=t.parent,r=e?.node;if(r&&t.node){let a=null;const d=Object.keys(e),l=d.indexOf(t.key);for(let p=l+1;p<d.length;p++){const y=e[d[p]];if(y?.node?.parentNode===r){a=y.node;break}}a?r.insertBefore(t.node,a):r.appendChild(t.node)}else pt(t,t.parent);it(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 r=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(r),s.__fragmentAnchor=r}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),Ot(t,{}),vt(t,{skipIfEffect:!0}),it(t),Et(t),Lt(t,{}),pt(t,t.parent),xt(t,{})}},{depth:s.path.length});s.__effects.push(f)}function it(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),to(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 c=t.attr[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.setAttribute&&s.setAttribute(n,c===!0?"":c)}if(t.data&&typeof t.data=="object")for(const n in t.data){const c=t.data[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.dataset&&(s.dataset[n]=c===!0?"":c)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(c=>c&&s.classList.add(c));else if(typeof n=="object")for(const c in n){const f=typeof n[c]=="function"?n[c](t,t.state,t.context):n[c];f&&s.classList.add(typeof f=="string"?f:c)}}}}function kt(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 c in s){const f=s[c];if(f!=null){if(c.charAt(0)==="&"&&typeof f=="object"){n||(n={}),n[c]=f;continue}try{const o=String(f),i=c.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),e=o.trim(),r=/\s*!important\s*$/.test(e),a=e.replace(/\s*!important\s*$/,"");t.style.setProperty(i,a,r?"important":"")}catch{}}}n&&zt(t,n)}let qt=0;function zt(t,s){const n=`_ds${qt++}`;t.classList.add(n);const c=t.ownerDocument;let f=c.querySelector("style[data-smbls-scoped]");f||(f=c.createElement("style"),f.setAttribute("data-smbls-scoped",""),c.head.appendChild(f));let o="";for(const i in s){const e="."+n,r=i.replace(/&/g,e).split(",").map(d=>{const l=d.trim();return l.includes(e)?l:e+l}).join(", "),a=s[i];if(typeof a=="object"){let d="",l="";for(const p in a){const y=a[p];if(typeof y=="object"){const _=p.includes("&")?r.split(", ").map(h=>p.replace(/&/g,h)).join(", "):r.split(", ").map(h=>`${h} ${p}`).join(", ");let u="";for(const h in y)u+=`${h.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[h]};`;l+=(0,B.wrapHoverRule)(`${_} { ${u} }`,_)+`
|
|
5
|
-
`}else d+=`${p.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${y};`}d&&(o+=(0,
|
|
6
|
-
`),l&&(o+=l)}}o&&(f.textContent+=o)}function Qt(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 c=0;c<s.length;c++){const f=s[c];if(typeof f!="string"||f.length===0)continue;const o=f.split("."),i=o[0],e=o.slice(1),r={value:!1},a=(0,w.createEffect)(()=>{const d=t.state&&((0,j.isStore)(t.state)?t.state.root:null);if(!d||!(0,j.isStore)(d))return;let l=d;l=l[i];for(let y=0;y<e.length&&!(l==null||typeof l!="object");y++)if((0,j.isStore)(l))l=l[e[y]];else break;if(!r.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0})===!1&&(p=!0)}catch(_){t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:_})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",_)}finally{y&&(0,b.popConfig)()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const _=n.__effects[y];_&&_!==a&&!_._disposed&&!_._isSubscribeToEffect&&typeof _._execute=="function"&&_._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{t.onUpdate(t,t.state,t.context)}catch(_){t.context?.plugins?.length&&(0,U.runPluginHook)("error",t,{hook:"onUpdate",error:_})||console.error("[DOMQL] subscribeTo onUpdate error:",_)}finally{y&&(0,b.popConfig)()}}},{depth:n.path.length});r.value=!0,a._isSubscribeToEffect=!0,n.__effects.push(a)}}function et(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 wt=new Set;function Xt(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",c=n+"::"+t;wt.has(c)||(wt.add(c),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 G(t,s,n){const c={},f=(o,i)=>{if(A.CSS_PROPS_REGISTRY[o]){const e=A.CSS_PROPS_REGISTRY[o](i,s,s.state,s.context);if(e){const r=Array.isArray(e)?e:[e];for(const a of r)a&&Object.assign(c,a)}}else c[o]=i};for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let i=t[o];if(typeof i=="function"&&(i=i(s,s.state,s.context)),!(i==null||typeof i=="function")){if(typeof i=="object"&&!Array.isArray(i)){if(o==="style"){for(const a in i){let d=i[a];typeof d=="function"&&(d=d(s,s.state,s.context)),!(d==null||typeof d=="function")&&f(a,d)}continue}if(et(o,s)){const a=G(i,s,!0);Object.keys(a).length&&(c[`[data-theme="${o.slice(1)}"] &`]=a);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(o)){(0,lt.isLoudDevRuntime)()&&Xt(o,s);continue}let e=o;if(o.charCodeAt(0)===64&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const a=s.context?.designSystem?.media?.[o.slice(1)];a&&(e=`@media ${a}`)}const r=G(i,s,!1);Object.keys(r).length&&(c[e]=r);continue}f(o,i)}}if(n)for(const o in c){const i=c[o];typeof i=="string"&&!i.includes("!important")&&(c[o]=i+" !important")}return c}function Jt(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const f=c.charAt(0);if(f!=="."&&f!=="!")continue;const o=c.slice(1);if(!o)continue;const i=t[c];if(!i||typeof i!="object")continue;const e=f==="!",r={lastMatch:!1,appliedKeys:null,appliedClasses:null},a=()=>{if(!t.node)return;let l;const p=t[o];if(p===void 0)if(t.state&&o in t.state)l=t.state[o];else{const u=t.context?.cases?.[o];if(u===void 0)return;try{l=typeof u=="function"?u.call(t,t):u}catch(h){l=!1,s.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}}else if(typeof p=="function")try{l=p(t,t.state,t.context)}catch(u){l=!1,s.__conditionalError=u,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,u?.message||u)}else l=p;const y=e?!l:!!l;if(y===r.lastMatch)return;r.lastMatch=y;const _=t.context?.designSystem;_&&(0,b.pushConfig)(_);try{if(y){const u={},h={};let g=!1;for(const x in i){if(!Object.prototype.hasOwnProperty.call(i,x))continue;const v=i[x],P=x.charAt(0);if((P===":"||P==="@"||P==="&")&&v&&typeof v=="object"&&!Array.isArray(v)){if(et(x,t)){const O=G(v,t,!0);Object.keys(O).length&&(h[`[data-theme="${x.slice(1)}"] &`]=O,g=!0)}else{let O=x;if(P==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const R=t.context?.designSystem?.media?.[x.slice(1)];R&&(O=`@media ${R}`)}const $=G(v,t,!1);Object.keys($).length&&(h[O]=$,g=!0)}continue}const K=typeof v=="function"?v(t,t.state,t.context):v;if(K!=null)if(A.CSS_PROPS_REGISTRY[x]){const O=A.CSS_PROPS_REGISTRY[x](K,t,t.state,t.context);if(O){const $=Array.isArray(O)?O:[O];for(const R of $)R&&Object.assign(u,R)}}else A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(u[x]=K)}const C=Object.keys(u);if(C.length){Y(t.node,u);for(const x of C)n.set(x,c);r.appliedKeys=C}else r.appliedKeys=null;if(g){const x=(0,B.css)(h,null,t.context?.cssPrefix),v=x?x.split(" ").filter(Boolean):[];if(v.length&&t.node.classList){for(const P of v)t.node.classList.add(P);r.appliedClasses=v}else r.appliedClasses=null}else if(r.appliedClasses){for(const x of r.appliedClasses)t.node.classList.remove(x);r.appliedClasses=null}}else{if(r.appliedKeys){for(const u of r.appliedKeys)n.get(u)===c&&(t.node.style[u]="",n.delete(u));r.appliedKeys=null}if(r.appliedClasses){for(const u of r.appliedClasses)t.node.classList.remove(u);r.appliedClasses=null}}}finally{_&&(0,b.popConfig)()}};s.__conditionalRunners.push(a);const d=(0,w.createEffect)(a,{depth:s.path.length});s.__effects.push(d)}}const ft=new WeakSet;function mt(t){const s=t.ownerDocument;!s||ft.has(s)||(ft.add(s),queueMicrotask(()=>{ft.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const at=new WeakSet;let jt=!1;function to(t){const{node:s}=t;if(!s)return;if(jt||(jt=!0,(0,B.css)({display:"none"})),at.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}at.add(t);const n=t.context?.designSystem;n&&(0,b.pushConfig)(n);try{const c={};let f=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||T.REGISTRY.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!H(o)){if(A.CSS_PROPS_REGISTRY[o]){const e=t[o],r=A.CSS_PROPS_REGISTRY[o](e,t,t.state,t.context);if(r){if(Array.isArray(r))for(const a of r)a&&Object.assign(c,a);else Object.assign(c,r);f=!0}}else if(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charCodeAt(0)===45){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="&"){const e=t[o];e&&typeof e=="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const e=t[o];if(e&&typeof e=="object"){if(et(o,t)){const r=G(e,t,!0);Object.keys(r).length&&(c[`[data-theme="${o.slice(1)}"] &`]=r,f=!0)}else{let r=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const d=t.context?.designSystem?.media?.[o.slice(1)];d&&(r=`@media ${d}`)}const a=G(e,t,!1);Object.keys(a).length&&(c[r]=a,f=!0)}f=!0}}}}if(f){c.display&&String(c.display).includes("!important")&&(s.style.setProperty("display",String(c.display).replace(/\s*!important\s*$/,""),"important"),delete c.display);const o=(0,B.css)(c,null,t.context?.cssPrefix);if(o&&s.classList){const e=o.split(" ").filter(Boolean);let r=!1;for(const a of e)s.classList.add(a),r||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(r=!0);r&&mt(s)}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const e=c.display;if(e&&e!==i)if(i==="none"){const r=[];for(const a of s.classList)a.startsWith("_d-")&&a!=="_d-none"&&r.push(a);for(const a of r)s.classList.remove(a);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&(0,b.popConfig)(),at.delete(t)}}function Et(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const f in t.aria){const o=t.aria[f];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+f.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());s.setAttribute(i,o===!0?"":o)}const n=(0,q.applyAttrTransforms)(t);for(const f in n){const o=n[f];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(f,o===!0?"":o)}const c=t.tag||"div";for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||typeof t[f]=="function"||T.REGISTRY.has(f)||f==="on"||n[f]!==void 0)continue;const o=f.charCodeAt(0);if(!(o>=65&&o<=90)&&!H(f)&&!(A.CSS_PROPS_REGISTRY[f]||A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(f))&&(0,q.checkAttributeByTagName)(c,f)){let i=t[f];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=(0,ot.replaceLiteralsWithObjectFields)(i,t,t.state,t.context),t[f]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;s.setAttribute(f,i===!0?"":i)}}}function oo(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,c=n&&typeof n=="object"&&n.max?String(n.max):null;c&&(s.style.maxHeight=c);const f=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};f(),s.addEventListener("input",f),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",f)}catch{}})}const Pt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Ot(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!H(n)||Pt.has(n))continue;let c=t[n];if(typeof c=="string"&&/^[A-Za-z_$][\w$]*$/.test(c)){const o=c;c=function(e){return t.call(o,e)}}if(typeof c!="function")continue;const f=Bt(n);T.LIFECYCLE_EVENTS.has(f)||(0,Dt.registerEvent)(Ht(f),t,c)}so(t)}function so(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let c=!1;for(const p of Pt){const y=t[p];typeof y=="function"&&(n[p]=y,c=!0)}if(!c)return;const f=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let i=0,e=0,r=0,a=!1;const d=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(i=y.clientX,e=y.clientY,r=Date.now(),a=!0)},l=p=>{if(!a)return;a=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const _=y.clientX-i,u=y.clientY-e,h=Date.now()-r;if(h>o)return;const g=Math.abs(_),C=Math.abs(u);if(Math.max(g,C)<f)return;let x;if(g>C*1.2)x=_<0?"left":"right";else if(C>g*1.2)x=u<0?"up":"down";else return;const v="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),P=n[v],K=n.onSwipe;P&&P.call(t,p,t,t.state,t.context),K&&K.call(t,{direction:x,dx:_,dy:u,dt:h,event:p},t,t.state,t.context)};s.addEventListener("touchstart",d,{passive:!0}),s.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",d)}catch{}try{s.removeEventListener("touchend",l)}catch{}})}function tt(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=tt(f,o):n[c]=o}return n}function dt(t,s,n){if(!s||!t.node)return;const c=t.childExtends;if(Array.isArray(s)){const f=t.tag==="fragment",o=t.context?.document||globalThis.document,i=f?null:o?.createDocumentFragment();if(!f&&!i)return;const e=t.childProps,r=t.childrenAs;for(let a=0;a<s.length;a++){let d=s[a];const l=d;(typeof d=="string"||typeof d=="number")&&(d={text:d});let p=e;if(typeof e=="function")try{p=e(t,d)}catch{p=null}if(r==="state"){let u=l;(typeof l=="string"||typeof l=="number")&&(u={value:l,text:l}),d=p?{...p,state:u}:{state:u}}else p&&(d=tt(p,d));if(c&&!d.ignoreChildExtends)if(d.extends){const u=Array.isArray(d.extends)?d.extends:[d.extends],h=Array.isArray(c)?c:[c];d={...d,extends:[...h,...u]}}else d={...d,extends:c};const y=d?.key||l&&typeof l=="object"&&l.key||`${a}`,_=V(d,t,y,n);!f&&_?.node&&i.appendChild(_.node)}f||t.node.appendChild(i);return}if(typeof s=="string"){const f=Ct(s,t);if(Array.isArray(f)){dt(t,f,n);return}}if(typeof s=="object")for(const f in s){if(T.REGISTRY.has(f))continue;let o=s[f];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=tt(t.childProps,o)),c&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],e=Array.isArray(c)?c:[c];o={...o,extends:[...e,...i]}}else o={...o,extends:c};V(o,t,f,n)}}}function ut(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const c=n.options;if(!c||!c.length)return;const f=t.__ref,o=f&&f.__exec&&f.__exec.value,i=typeof o=="function",e=t.value!=null&&typeof t.value!="function";if(i||e){let d;if(i)try{d=o(t,t.state,t.context)}catch{return}else d=t.value;const l=d==null?"":String(d);n.value!==l&&(n.value=l);return}const r=s||!(f&&f.__selectSynced);if(f&&(f.__selectSynced=!0),!r)return;let a=-1;for(let d=0;d<c.length;d++)c[d].defaultSelected&&(a=d);a>=0&&n.selectedIndex!==a&&(n.selectedIndex=a)}function Lt(t,s){let{children:n,content:c}=t;const f=t.childExtends;if(typeof n=="function"){const i=n;n=i(t,t.state,t.context),t.children=n;const e=t.__ref;let r=!1;const a=E(t,t.childrenDeps,i),d=(0,w.createEffect)(()=>{const l=a(t,t.state,t.context);if(!r){r=!0;return}if(l===t.children)return;t.children=l;const p=typeof t.onContentUpdate=="function",y=p?[]:null,_=p?[]:null,u=p?[]:null;if(Array.isArray(l)&&t.childrenAs==="state"){const x=t.childProps,v=[],P=new Map;for(let k=0;k<l.length;k++){const L=l[k];let S=x;if(typeof x=="function")try{S=x(t,L)}catch{S=null}const N=S&&S.key||L&&L.key||`${k}`;v.push(N),P.set(N,{rawChild:L,childProps:S})}const K=new Set(v),O=e.__children.slice();for(const k of O)if(!K.has(k)){const L=t[k];L?.remove&&L.remove(),delete t[k],_&&_.push(k)}const $=t.childExtends,R=t.tag==="fragment",Rt=t.context?.document||globalThis.document,z=R?null:Rt?.createDocumentFragment();for(const k of v){const L=P.get(k),S=L.rawChild,N=t[k];if(N&&N.state){if(S&&typeof S=="object"){const D=N.state,J=D.$replace||D.replace,gt=D.$update||D.update;if(typeof J=="function")J.call(D,S);else if(typeof gt=="function"){for(const M in D)if(!(M==="__element"||M==="root"||M==="parent"||M==="update")&&!Object.prototype.hasOwnProperty.call(S,M))try{D[M]=void 0}catch{}gt.call(D,S)}else for(const M in S)D[M]=S[M]}u&&u.push(k);continue}let st=S;(typeof S=="string"||typeof S=="number")&&(st={value:S,text:S});const ht=L.childProps;let F=ht?{...ht,state:st}:{state:st};if($&&!F.ignoreChildExtends)if(F.extends){const D=Array.isArray(F.extends)?F.extends:[F.extends],J=Array.isArray($)?$:[$];F={...F,extends:[...J,...D]}}else F={...F,extends:$};const _t=V(F,t,k,s);!R&&_t?.node&&z&&z.appendChild(_t.node),y&&y.push(k)}if(!R&&z&&z.childNodes.length&&t.node&&t.node.appendChild(z),!R&&t.node){let k=null;for(const L of v){const S=t[L]?.node;if(!S)continue;const N=k?k.nextSibling:t.node.firstChild;S!==N&&t.node.insertBefore(S,N),k=S}}e.__children=v,p&&(y.length||_.length)&&bt(t,{added:y,removed:_,kept:u}),ut(t,!1);return}const C=p?[...e.__children]:null;for(const x of[...e.__children]){const v=t[x];v?.remove&&v.remove(),delete t[x]}e.__children=[],dt(t,l,s),ut(t,!1),p&&bt(t,{added:[...e.__children],removed:C,kept:[]})},{depth:e.path.length});e.__effects.push(d)}if(dt(t,n||c,s),n||c)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let e=0;e<i.length;e++){const r=i[e];if(!r.endsWith("Extends")||typeof t[r]!="string")continue;const a=r.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const d={extends:t[r]};delete t[r];for(let l=e+1;l<i.length;l++){const p=i[l],y=p.charCodeAt(0);if(y>=65&&y<=90||T.REGISTRY.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const _=t[p];_!==void 0&&(d[p]=_,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...d,...t[a]}:t[a]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||T.REGISTRY.has(i)||typeof t[i]!="object"||t[i]===null)continue;const e=i.charCodeAt(0);if(e<65||e>90)continue;let r=t[i];if(!r.__ref){if(!r.extends&&!r.extend){const a=o[i]||o[`smbls.${i}`];a&&(r={...r,extends:a})}if(t.childProps&&(r=tt(t.childProps,r)),f&&!r.ignoreChildExtends)if(r.extends){const a=Array.isArray(r.extends)?r.extends:[r.extends],d=Array.isArray(f)?f:[f];r={...r,extends:[...d,...a]}}else r={...r,extends:f};V(r,t,i,s)}}}function pt(t,s,n){const{node:c}=t;if(!c)return;c.ref=t;const f=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(f){const i=f.parentNode;if(i){if(n?.position==="before"&&n.node)i.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const e=n.node.nextSibling;i.insertBefore(c,e||f)}else i.insertBefore(c,f);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;i?o.insertBefore(c,i):o.appendChild(c)}else o.appendChild(c)}function I(t,s,n){const c=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&(0,U.runPluginHook)(c,s,n);const f="on"+t,o=s[f];if(typeof o=="function"){const i=t==="Render"||t==="RenderRouter";if(i){if(s.__ref.__inRender)return!0;s.__ref.__inRender=!0}const e=s.context?.designSystem;e&&(0,b.pushConfig)(e);try{if(o(s,s.state,s.context,n)===!1)return!1}catch(r){if(s.context?.plugins?.length&&(0,U.runPluginHook)("error",s,{hook:f,error:r})||console.error(`[DOMQL] Lifecycle "${f}" error:`,r),s.context?.strictMode)throw r}finally{e&&(0,b.popConfig)(),i&&(s.__ref.__inRender=!1)}}return!0}var no=V;
|
|
4
|
+
`):"")}}if(pt(o,!0),lt(o,s,f),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const u=o.context?.designSystem;u&&(0,b.pushConfig)(u);try{const h=o.html(o,o.state,o.context);h!=null&&typeof h!="function"&&(o.node.innerHTML=h)}catch{}finally{u&&(0,b.popConfig)()}}if(I("Create",o,c),I("Complete",o,c),I("Render",o,c),I("RenderRouter",o,c),bt(o,c),typeof o.onFrame=="function"){const u=o.onFrame,h=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){h&&(0,b.pushConfig)(h);try{u(o,o.state,o.context)}catch(S){console.error("[DOMQL] onFrame error:",S)}finally{h&&(0,b.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function Gt(t,s,n){const c=!s,f=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=c&&f&&t.context?.state,i=n.state!==void 0&&!o?n.state:t.state&&!(0,E.isStore)(t.state)?t.state:void 0;if(i==null){if(s?.state)t.state=s.state,(0,Z.applyStateMethods)(t,t.state);else if(t.context?.state){const e=t.context.state,r={...e},a=t.context?.polyglot;if(a?.translations){const d=e.lang||a.defaultLang||"en",l=a.translations[d];if(l&&typeof l=="object")for(const y in l)r[y]===void 0&&(r[y]=l[y]);const p=new Set(a.languages||[]);for(const y in a.translations)!p.has(y)&&r[y]===void 0&&(r[y]=a.translations[y])}t.state=(0,E.isStore)(r)?r:(0,E.createStore)(r),t.state.__element=t,t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,Z.applyStateMethods)(t,t.state);return}if(typeof i=="string"){if(t.state=vt(i,s),t.state&&typeof t.state=="object"&&!(0,E.isStore)(t.state)){const e=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:e,enumerable:!1,configurable:!0,writable:!0})}(0,Z.applyStateMethods)(t,t.state);return}if(typeof i=="function"){const e=i(t,s?.state);t.state=(0,E.isStore)(e)?e:(0,E.createStore)(e||{})}else(0,E.isStore)(i)?t.state=i:t.state=(0,E.createStore)({...i});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,(0,Z.applyStateMethods)(t,t.state)}function it(t,s){if(!s)return t;const n=s.split("/");let c=t;for(const f of n){if(c==null)return{};c=c[f]}return c??{}}function vt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const f=t.slice(3);return f?it(s.state,f):s.state??{}}if(t.startsWith("~/")){const f=s.state?.root||s.state,o=t.slice(2);return o?it(f,o):f??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=it(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const c=s.context?.polyglot;if(c?.translations){const f=s.state?.root?.lang||c.defaultLang||"en",o=c.translations[f];if(o?.[t]!==void 0)return o[t];if(c.translations[t]!==void 0)return c.translations[t]}return{}}function Zt(t){const s=t.__ref,n=t.tag||"div",c=t.context?.designSystem,f=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const e=o[i];if(typeof t[e]!="function"||$.REGISTRY.has(e))continue;const r=e.charCodeAt(0);r>=65&&r<=90||H(e)||A.CSS_PROPS_REGISTRY[e]||A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(e)||(0,z.checkAttributeByTagName)(n,e)||f.push({prop:e,fn:t[e]})}for(let i=0;i<f.length;i++){const{prop:e,fn:r}=f[i];s.__exec[e]=r,Object.defineProperty(t,e,{get(){c&&(0,b.pushConfig)(c);try{return r(t,t.state,t.context)}catch{return}finally{c&&(0,b.popConfig)()}},set(a){delete s.__exec[e],Object.defineProperty(t,e,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function zt(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const c=s[n];try{typeof c=="function"?c(t,t.state,t.context):typeof c=="string"&&t.state?.[c]}catch{}}}function P(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...c){return zt(t,s),n.apply(this,c)}}function X(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function St(t,s){const n=t.__ref,c=!!(s&&s.skipIfEffect);if(Zt(t),typeof t.text=="function"){const o=t.text,i=P(t,t.textDeps,o),e=(0,j.createEffect)(()=>{if(!n.contentManaged)try{let r=i(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=st.replaceLiteralsWithObjectFields.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,i=(0,j.createEffect)(()=>{if(n.contentManaged)return;const e=st.replaceLiteralsWithObjectFields.call(t,o,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(i),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!$.REGISTRY.has(o)&&!H(o)&&!n.__exec[o]){if(A.CSS_PROPS_REGISTRY[o]){const i=t[o],e=P(t,t[o+"Deps"],i),r=o;let a;const d=(0,j.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,b.pushConfig)(l);try{const p=e(t,t.state,t.context),y=A.CSS_PROPS_REGISTRY[r](p,t,t.state,t.context);if(y&&t.node){const _=wt(y);(_===null||_!==a)&&(a=_,Y(t.node,y))}else t.node&&(r==="show"||r==="hide")&&(a=void 0,t.node.style.display="")}finally{l&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}else if(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const i=t[o],e=P(t,t[o+"Deps"],i),r=o;let a;const d=(0,j.createEffect)(()=>{const l=t.context?.designSystem;l&&(0,b.pushConfig)(l);try{const p=e(t,t.state,t.context);if(t.node)if(p!=null){const y=r+":"+String(p);y!==a&&(a=y,Y(t.node,{[r]:p}))}else a=void 0,t.node.style[r]=""}finally{l&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}}if(typeof t.html=="function"){const o=t.html,i=P(t,t.htmlDeps,o),e=(0,j.createEffect)(()=>{const r=t.context?.designSystem;r&&(0,b.pushConfig)(r);try{const a=i(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&(t.node.innerHTML=a)}finally{r&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(e),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,i=P(t,t.valueDeps,o),e=(0,j.createEffect)(()=>{try{const r=i(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const a=r==null?"":String(r);if(t.node.value===a)return;const d=typeof document<"u"&&document.activeElement===t.node,l=d&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=d&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=a,d&&l!=null&&p!=null)try{t.node.setSelectionRange(l,p)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,i=P(t,t.styleDeps,o);let e;const r=(0,j.createEffect)(()=>{const a=i(t,t.state,t.context),d=wt(a);(d===null||d!==e)&&(e=d,Y(t.node,a))},{depth:n.path.length});n.__effects.push(r),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const i=t.style[o];if(typeof i!="function")continue;const e=P(t,X(t.styleDeps,o),i);let r;const a=(0,j.createEffect)(()=>{try{const d=e(t,t.state,t.context);if(t.node){const l=o+":"+String(d);l!==r&&(r=l,Y(t.node,{[o]:d}))}}catch{}},{depth:n.path.length});n.__effects.push(a)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const i=P(t,X(t.attrDeps,o),t.attr[o]),e=o,r=(0,j.createEffect)(()=>{try{const a=i(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(r)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const i=P(t,X(t.ariaDeps,o),t.aria[o]),e="aria-"+o.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),r=(0,j.createEffect)(()=>{try{const a=i(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const i=P(t,X(t.dataDeps,o),t.data[o]),r="data-"+o.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),a=(0,j.createEffect)(()=>{try{const d=i(t,t.state,t.context);if(!t.node?.setAttribute)return;d==null||d===!1?t.node.removeAttribute(r):typeof d!="function"&&typeof d!="object"&&t.node.setAttribute(r,d===!0?"":d)}catch{}},{depth:n.path.length});n.__effects.push(a)}const f=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(f)for(const o in f){if(typeof f[o]!="function")continue;const i=P(t,X(t.classDeps,o),f[o]),e=(0,j.createEffect)(()=>{try{const r=i(t,t.state,t.context);if(!t.node?.classList)return;typeof r=="string"?t.node.classList.add(r):r?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(e)}!c&&typeof t.if=="function"&&kt(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||$.REGISTRY.has(o)||typeof t[o]!="function")continue;const i=o.charCodeAt(0);if(i>=65&&i<=90||H(o))continue;const e=t[o];n.__exec[o]=e;const r=t.tag||"div";if((0,z.checkAttributeByTagName)(r,o)&&!A.CSS_PROPS_REGISTRY[o]&&!(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o))){const a=o,d=P(t,t[o+"Deps"],e),l=(0,j.createEffect)(()=>{try{const p=d(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(a):typeof p!="function"&&typeof p!="object"&&(a==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(a,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(l)}}if(Xt(t),mt(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,i=t.stateDeps;let e=!1,r=[];const a=(0,j.createEffect)(()=>{const d=[];for(let _=0;_<i.length;_++){const u=i[_];try{d[_]=typeof u=="function"?u(t,t.state,t.context):t.state?.[u]}catch{d[_]=void 0}}if(!e){e=!0,r=d;return}let l=d.length!==r.length;for(let _=0;!l&&_<d.length;_++)d[_]!==r[_]&&(l=!0);const p=r;if(r=d,!l)return;const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{o(t,t.state,t.context,{prev:p,next:d})}catch(_){if(t.context?.plugins?.length&&(0,K.runPluginHook)("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{y&&(0,b.popConfig)()}},{depth:n.path.length});n.__effects.push(a)}}function kt(t,s,n){const c=P(t,t.ifDeps,n),f=(0,j.createEffect)(()=>{let o;try{o=c(t,t.state,t.context)}catch(e){if(o=!1,s.__ifError=e,typeof console<"u"&&console.warn){const r=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${r} \u2014 treating as false:`,e?.message||e)}return}const i=s.__if;if(s.__if=!!o,i&&!s.__if&&t.node)t.node.remove();else if(!i&&s.__if)if(s.__ifInitialized){t.node||(t.node=(0,V.cacheNode)(t)),t.node&&(t.node.ref=t);const e=t.parent,r=e?.node;if(r&&t.node){let a=null;const d=Object.keys(e),l=d.indexOf(t.key);for(let p=l+1;p<d.length;p++){const y=e[d[p]];if(y?.node?.parentNode===r){a=y.node;break}}a?r.insertBefore(t.node,a):r.appendChild(t.node)}else lt(t,t.parent);et(t)}else{if(s.__ifInitialized=!0,t.tag||(t.tag=(0,V.detectTag)(t)),I("Init",t,{}),t.node||(t.node=(0,V.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 r=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(r),s.__fragmentAnchor=r}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),Lt(t,{}),St(t,{skipIfEffect:!0}),et(t),Pt(t),Dt(t,{}),lt(t,t.parent),bt(t,{})}},{depth:s.path.length});s.__effects.push(f)}function et(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),oo(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 c=t.attr[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.setAttribute&&s.setAttribute(n,c===!0?"":c)}if(t.data&&typeof t.data=="object")for(const n in t.data){const c=t.data[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.dataset&&(s.dataset[n]=c===!0?"":c)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(c=>c&&s.classList.add(c));else if(typeof n=="object")for(const c in n){const f=typeof n[c]=="function"?n[c](t,t.state,t.context):n[c];f&&s.classList.add(typeof f=="string"?f:c)}}}}function wt(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 c in s){const f=s[c];if(f!=null){if(c.charAt(0)==="&"&&typeof f=="object"){n||(n={}),n[c]=f;continue}try{const o=String(f),i=c.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),e=o.trim(),r=/\s*!important\s*$/.test(e),a=e.replace(/\s*!important\s*$/,"");t.style.setProperty(i,a,r?"important":"")}catch{}}}n&&Qt(t,n)}let qt=0;function Qt(t,s){const n=`_ds${qt++}`;t.classList.add(n);const c=t.ownerDocument;let f=c.querySelector("style[data-smbls-scoped]");f||(f=c.createElement("style"),f.setAttribute("data-smbls-scoped",""),c.head.appendChild(f));let o="";for(const i in s){const e="."+n,r=i.replace(/&/g,e).split(",").map(d=>{const l=d.trim();return l.includes(e)?l:e+l}).join(", "),a=s[i];if(typeof a=="object"){let d="",l="";for(const p in a){const y=a[p];if(typeof y=="object"){const _=p.includes("&")?r.split(", ").map(h=>p.replace(/&/g,h)).join(", "):r.split(", ").map(h=>`${h} ${p}`).join(", ");let u="";for(const h in y)u+=`${h.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[h]};`;l+=(0,W.wrapHoverRule)(`${_} { ${u} }`,_)+`
|
|
5
|
+
`}else d+=`${p.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${y};`}d&&(o+=(0,W.wrapHoverRule)(`${r} { ${d} }`,r)+`
|
|
6
|
+
`),l&&(o+=l)}}o&&(f.textContent+=o)}function Xt(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 c=0;c<s.length;c++){const f=s[c];if(typeof f!="string"||f.length===0)continue;const o=f.split("."),i=o[0],e=o.slice(1),r={value:!1},a=(0,j.createEffect)(()=>{const d=t.state&&((0,E.isStore)(t.state)?t.state.root:null);if(!d||!(0,E.isStore)(d))return;let l=d;l=l[i];for(let y=0;y<e.length&&!(l==null||typeof l!="object");y++)if((0,E.isStore)(l))l=l[e[y]];else break;if(!r.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0})===!1&&(p=!0)}catch(_){t.context?.plugins?.length&&(0,K.runPluginHook)("error",t,{hook:"onBeforeUpdate",error:_})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",_)}finally{y&&(0,b.popConfig)()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const _=n.__effects[y];_&&_!==a&&!_._disposed&&!_._isSubscribeToEffect&&typeof _._execute=="function"&&_._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&(0,b.pushConfig)(y);try{t.onUpdate(t,t.state,t.context)}catch(_){t.context?.plugins?.length&&(0,K.runPluginHook)("error",t,{hook:"onUpdate",error:_})||console.error("[DOMQL] subscribeTo onUpdate error:",_)}finally{y&&(0,b.popConfig)()}}},{depth:n.path.length});r.value=!0,a._isSubscribeToEffect=!0,n.__effects.push(a)}}function ft(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 jt=new Set;function Jt(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",c=n+"::"+t;jt.has(c)||(jt.add(c),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 G(t,s,n){const c={},f=(o,i)=>{if(A.CSS_PROPS_REGISTRY[o]){const e=A.CSS_PROPS_REGISTRY[o](i,s,s.state,s.context);if(e){const r=Array.isArray(e)?e:[e];for(const a of r)a&&Object.assign(c,a)}}else c[o]=i};for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let i=t[o];if(typeof i=="function"&&(i=i(s,s.state,s.context)),!(i==null||typeof i=="function")){if(typeof i=="object"&&!Array.isArray(i)){if(o==="style"){for(const a in i){let d=i[a];typeof d=="function"&&(d=d(s,s.state,s.context)),!(d==null||typeof d=="function")&&f(a,d)}continue}if(ft(o,s)){const a=G(i,s,!0);Object.keys(a).length&&(c[`[data-theme="${o.slice(1)}"] &`]=a);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(o)){(0,yt.isLoudDevRuntime)()&&Jt(o,s);continue}let e=o;if(o.charCodeAt(0)===64&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const a=s.context?.designSystem?.media?.[o.slice(1)];a&&(e=`@media ${a}`)}const r=G(i,s,!1);Object.keys(r).length&&(c[e]=r);continue}f(o,i)}}if(n)for(const o in c){const i=c[o];typeof i=="string"&&!i.includes("!important")&&(c[o]=i+" !important")}return c}function mt(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const f=c.charAt(0);if(f!=="."&&f!=="!")continue;const o=c.slice(1);if(!o)continue;const i=t[c];if(!i||typeof i!="object")continue;const e=f==="!",r={lastMatch:!1,appliedKeys:null,appliedClasses:null},a=()=>{if(!t.node)return;let l;const p=t[o];if(p===void 0)if(t.state&&o in t.state)l=t.state[o];else{const u=t.context?.cases?.[o];if(u===void 0)return;try{l=typeof u=="function"?u.call(t,t):u}catch(h){l=!1,s.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}}else if(typeof p=="function")try{l=p(t,t.state,t.context)}catch(u){l=!1,s.__conditionalError=u,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,u?.message||u)}else l=p;const y=e?!l:!!l;if(y===r.lastMatch)return;r.lastMatch=y;const _=t.context?.designSystem;_&&(0,b.pushConfig)(_);try{if(y){const u={},h={};let g=!1;for(const x in i){if(!Object.prototype.hasOwnProperty.call(i,x))continue;const C=i[x],k=x.charAt(0);if((k===":"||k==="@"||k==="&")&&C&&typeof C=="object"&&!Array.isArray(C)){if(ft(x,t)){const O=G(C,t,!0);Object.keys(O).length&&(h[`[data-theme="${x.slice(1)}"] &`]=O,g=!0)}else{let O=x;if(k==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const D=t.context?.designSystem?.media?.[x.slice(1)];D&&(O=`@media ${D}`)}const B=G(C,t,!1);Object.keys(B).length&&(h[O]=B,g=!0)}continue}const F=typeof C=="function"?C(t,t.state,t.context):C;if(F!=null)if(A.CSS_PROPS_REGISTRY[x]){const O=A.CSS_PROPS_REGISTRY[x](F,t,t.state,t.context);if(O){const B=Array.isArray(O)?O:[O];for(const D of B)D&&Object.assign(u,D)}}else A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(x)&&(u[x]=F)}const S=Object.keys(u);if(S.length){Y(t.node,u);for(const x of S)n.set(x,c);r.appliedKeys=S}else r.appliedKeys=null;if(g){const x=(0,W.css)(h,null,t.context?.cssPrefix),C=x?x.split(" ").filter(Boolean):[];if(C.length&&t.node.classList){for(const k of C)t.node.classList.add(k);r.appliedClasses=C}else r.appliedClasses=null}else if(r.appliedClasses){for(const x of r.appliedClasses)t.node.classList.remove(x);r.appliedClasses=null}}else{if(r.appliedKeys){for(const u of r.appliedKeys)n.get(u)===c&&(t.node.style[u]="",n.delete(u));r.appliedKeys=null}if(r.appliedClasses){for(const u of r.appliedClasses)t.node.classList.remove(u);r.appliedClasses=null}}}finally{_&&(0,b.popConfig)()}};s.__conditionalRunners.push(a);const d=(0,j.createEffect)(a,{depth:s.path.length});s.__effects.push(d)}}const at=new WeakSet;function to(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 dt=new WeakSet;let Et=!1;function oo(t){const{node:s}=t;if(!s)return;if(Et||(Et=!0,(0,W.css)({display:"none"})),dt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}dt.add(t);const n=t.context?.designSystem;n&&(0,b.pushConfig)(n);try{const c={};let f=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||$.REGISTRY.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!H(o)){if(A.CSS_PROPS_REGISTRY[o]){const e=t[o],r=A.CSS_PROPS_REGISTRY[o](e,t,t.state,t.context);if(r){if(Array.isArray(r))for(const a of r)a&&Object.assign(c,a);else Object.assign(c,r);f=!0}}else if(A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charCodeAt(0)===45){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="&"){const e=t[o];e&&typeof e=="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const e=t[o];if(e&&typeof e=="object"){if(ft(o,t)){const r=G(e,t,!0);Object.keys(r).length&&(c[`[data-theme="${o.slice(1)}"] &`]=r,f=!0)}else{let r=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const d=t.context?.designSystem?.media?.[o.slice(1)];d&&(r=`@media ${d}`)}const a=G(e,t,!1);Object.keys(a).length&&(c[r]=a,f=!0)}f=!0}}}}if(f){c.display&&String(c.display).includes("!important")&&(s.style.setProperty("display",String(c.display).replace(/\s*!important\s*$/,""),"important"),delete c.display);const o=(0,W.css)(c,null,t.context?.cssPrefix);if(o&&s.classList){const e=o.split(" ").filter(Boolean);let r=!1;for(const a of e)s.classList.add(a),r||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(r=!0);r&&to(s)}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const e=c.display;if(e&&e!==i)if(i==="none"){const r=[];for(const a of s.classList)a.startsWith("_d-")&&a!=="_d-none"&&r.push(a);for(const a of r)s.classList.remove(a);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&(0,b.popConfig)(),dt.delete(t)}}function Pt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const f in t.aria){const o=t.aria[f];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+f.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());s.setAttribute(i,o===!0?"":o)}const n=(0,z.applyAttrTransforms)(t);for(const f in n){const o=n[f];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(f,o===!0?"":o)}const c=t.tag||"div";for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||typeof t[f]=="function"||$.REGISTRY.has(f)||f==="on"||n[f]!==void 0)continue;const o=f.charCodeAt(0);if(!(o>=65&&o<=90)&&!H(f)&&!(A.CSS_PROPS_REGISTRY[f]||A.DEFAULT_CSS_PROPERTIES_LIST&&A.DEFAULT_CSS_PROPERTIES_LIST.has(f))&&(0,z.checkAttributeByTagName)(c,f)){let i=t[f];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=(0,st.replaceLiteralsWithObjectFields)(i,t,t.state,t.context),t[f]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;s.setAttribute(f,i===!0?"":i)}}}function so(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,c=n&&typeof n=="object"&&n.max?String(n.max):null;c&&(s.style.maxHeight=c);const f=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};f(),s.addEventListener("input",f),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",f)}catch{}})}const Ot=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Lt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!H(n)||Ot.has(n))continue;let c=t[n];if(typeof c=="string"&&/^[A-Za-z_$][\w$]*$/.test(c)){const o=c;c=function(e){return t.call(o,e)}}if(typeof c!="function")continue;const f=Ht(n);$.LIFECYCLE_EVENTS.has(f)||(0,Tt.registerEvent)(Yt(f),t,c)}no(t)}function no(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let c=!1;for(const p of Ot){const y=t[p];typeof y=="function"&&(n[p]=y,c=!0)}if(!c)return;const f=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let i=0,e=0,r=0,a=!1;const d=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(i=y.clientX,e=y.clientY,r=Date.now(),a=!0)},l=p=>{if(!a)return;a=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const _=y.clientX-i,u=y.clientY-e,h=Date.now()-r;if(h>o)return;const g=Math.abs(_),S=Math.abs(u);if(Math.max(g,S)<f)return;let x;if(g>S*1.2)x=_<0?"left":"right";else if(S>g*1.2)x=u<0?"up":"down";else return;const C="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),k=n[C],F=n.onSwipe;k&&k.call(t,p,t,t.state,t.context),F&&F.call(t,{direction:x,dx:_,dy:u,dt:h,event:p},t,t.state,t.context)};s.addEventListener("touchstart",d,{passive:!0}),s.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",d)}catch{}try{s.removeEventListener("touchend",l)}catch{}})}function ot(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=ot(f,o):n[c]=o}return n}function ut(t,s,n){if(!s||!t.node)return;const c=t.childExtends;if(Array.isArray(s)){const f=t.tag==="fragment",o=t.context?.document||globalThis.document,i=f?null:o?.createDocumentFragment();if(!f&&!i)return;const e=t.childProps,r=t.childrenAs;for(let a=0;a<s.length;a++){let d=s[a];const l=d;(typeof d=="string"||typeof d=="number")&&(d={text:d});let p=e;if(typeof e=="function")try{p=e(t,d)}catch{p=null}if(r==="state"){let u=l;(typeof l=="string"||typeof l=="number")&&(u={value:l,text:l}),d=p?{...p,state:u}:{state:u}}else p&&(d=ot(p,d));if(c&&!d.ignoreChildExtends)if(d.extends){const u=Array.isArray(d.extends)?d.extends:[d.extends],h=Array.isArray(c)?c:[c];d={...d,extends:[...h,...u]}}else d={...d,extends:c};const y=d?.key||l&&typeof l=="object"&&l.key||`${a}`,_=U(d,t,y,n);!f&&_?.node&&i.appendChild(_.node)}f||t.node.appendChild(i);return}if(typeof s=="string"){const f=vt(s,t);if(Array.isArray(f)){ut(t,f,n);return}}if(typeof s=="object")for(const f in s){if($.REGISTRY.has(f))continue;let o=s[f];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=ot(t.childProps,o)),c&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],e=Array.isArray(c)?c:[c];o={...o,extends:[...e,...i]}}else o={...o,extends:c};U(o,t,f,n)}}}function pt(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const c=n.options;if(!c||!c.length)return;const f=t.__ref,o=f&&f.__exec&&f.__exec.value,i=typeof o=="function",e=t.value!=null&&typeof t.value!="function";if(i||e){let d;if(i)try{d=o(t,t.state,t.context)}catch{return}else d=t.value;const l=d==null?"":String(d);n.value!==l&&(n.value=l);return}const r=s||!(f&&f.__selectSynced);if(f&&(f.__selectSynced=!0),!r)return;let a=-1;for(let d=0;d<c.length;d++)c[d].defaultSelected&&(a=d);a>=0&&n.selectedIndex!==a&&(n.selectedIndex=a)}function Dt(t,s){let{children:n,content:c}=t;const f=t.childExtends;if(typeof n=="function"){const i=n;try{n=i(t,t.state,t.context)}catch(l){if(n=void 0,typeof console<"u"&&console.error){const p=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${p} (initial run, treating as empty):`,l?.message||l)}}t.children=n;const e=t.__ref;let r=!1;const a=P(t,t.childrenDeps,i),d=(0,j.createEffect)(()=>{const l=r;r=!0;let p;try{p=a(t,t.state,t.context)}catch(C){if(typeof console<"u"&&console.error){const k=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${k}${l?"":" (initial tracking run)"}:`,C?.message||C)}return}if(!l||p===t.children)return;t.children=p;const y=typeof t.onContentUpdate=="function",_=y?[]:null,u=y?[]:null,h=y?[]:null;if(Array.isArray(p)&&t.childrenAs==="state"){const C=t.childProps,k=[],F=new Map;for(let w=0;w<p.length;w++){const L=p[w];let v=C;if(typeof C=="function")try{v=C(t,L)}catch{v=null}const N=v&&v.key||L&&L.key||`${w}`;k.push(N),F.set(N,{rawChild:L,childProps:v})}const O=new Set(k),B=e.__children.slice();for(const w of B)if(!O.has(w)){const L=t[w];L?.remove&&L.remove(),delete t[w],u&&u.push(w)}const D=t.childExtends,J=t.tag==="fragment",Ft=t.context?.document||globalThis.document,q=J?null:Ft?.createDocumentFragment();for(const w of k){const L=F.get(w),v=L.rawChild,N=t[w];if(N&&N.state){if(v&&typeof v=="object"){const T=N.state,m=T.$replace||T.replace,xt=T.$update||T.update;if(typeof m=="function")m.call(T,v);else if(typeof xt=="function"){for(const M in T)if(!(M==="__element"||M==="root"||M==="parent"||M==="update")&&!Object.prototype.hasOwnProperty.call(v,M))try{T[M]=void 0}catch{}xt.call(T,v)}else for(const M in v)T[M]=v[M]}h&&h.push(w);continue}let nt=v;(typeof v=="string"||typeof v=="number")&&(nt={value:v,text:v});const _t=L.childProps;let R=_t?{..._t,state:nt}:{state:nt};if(D&&!R.ignoreChildExtends)if(R.extends){const T=Array.isArray(R.extends)?R.extends:[R.extends],m=Array.isArray(D)?D:[D];R={...R,extends:[...m,...T]}}else R={...R,extends:D};const gt=U(R,t,w,s);!J&>?.node&&q&&q.appendChild(gt.node),_&&_.push(w)}if(!J&&q&&q.childNodes.length&&t.node&&t.node.appendChild(q),!J&&t.node){let w=null;for(const L of k){const v=t[L]?.node;if(!v)continue;const N=w?w.nextSibling:t.node.firstChild;v!==N&&t.node.insertBefore(v,N),w=v}}e.__children=k,y&&(_.length||u.length)&&At(t,{added:_,removed:u,kept:h}),pt(t,!1);return}const x=y?[...e.__children]:null;for(const C of[...e.__children]){const k=t[C];k?.remove&&k.remove(),delete t[C]}e.__children=[],ut(t,p,s),pt(t,!1),y&&At(t,{added:[...e.__children],removed:x,kept:[]})},{depth:e.path.length});e.__effects.push(d)}if(ut(t,n||c,s),n||c)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let e=0;e<i.length;e++){const r=i[e];if(!r.endsWith("Extends")||typeof t[r]!="string")continue;const a=r.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const d={extends:t[r]};delete t[r];for(let l=e+1;l<i.length;l++){const p=i[l],y=p.charCodeAt(0);if(y>=65&&y<=90||$.REGISTRY.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const _=t[p];_!==void 0&&(d[p]=_,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...d,...t[a]}:t[a]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||$.REGISTRY.has(i)||typeof t[i]!="object"||t[i]===null)continue;const e=i.charCodeAt(0);if(e<65||e>90)continue;let r=t[i];if(!r.__ref){if(!r.extends&&!r.extend){const a=o[i]||o[`smbls.${i}`];a&&(r={...r,extends:a})}if(t.childProps&&(r=ot(t.childProps,r)),f&&!r.ignoreChildExtends)if(r.extends){const a=Array.isArray(r.extends)?r.extends:[r.extends],d=Array.isArray(f)?f:[f];r={...r,extends:[...d,...a]}}else r={...r,extends:f};U(r,t,i,s)}}}function lt(t,s,n){const{node:c}=t;if(!c)return;c.ref=t;const f=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(f){const i=f.parentNode;if(i){if(n?.position==="before"&&n.node)i.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const e=n.node.nextSibling;i.insertBefore(c,e||f)}else i.insertBefore(c,f);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;i?o.insertBefore(c,i):o.appendChild(c)}else o.appendChild(c)}function I(t,s,n){const c=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&(0,K.runPluginHook)(c,s,n);const f="on"+t,o=s[f];if(typeof o=="function"){const i=t==="Render"||t==="RenderRouter";if(i){if(s.__ref.__inRender)return!0;s.__ref.__inRender=!0}const e=s.context?.designSystem;e&&(0,b.pushConfig)(e);try{if(o(s,s.state,s.context,n)===!1)return!1}catch(r){if(s.context?.plugins?.length&&(0,K.runPluginHook)("error",s,{hook:f,error:r})||console.error(`[DOMQL] Lifecycle "${f}" error:`,r),s.context?.strictMode)throw r}finally{e&&(0,b.popConfig)(),i&&(s.__ref.__inRender=!1)}}return!0}var co=U;
|
package/dist/esm/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{createStore as
|
|
1
|
+
import{createStore as st,createScopeStore as Mt,isStore as K}from"@symbo.ls/signal";import{createEffect as k}from"@symbo.ls/signal";import{cacheNode as nt,detectTag as bt}from"./cache.js";import{REGISTRY as U,LIFECYCLE_EVENTS as It}from"./registry.js";import{registerEvent as Kt}from"./delegate.js";import{applyExtends as Ut}from"./extends.js";import{addMethods as Vt}from"./methods.js";import"./dispose.js";import{isLoudDevRuntime as At}from"./devRuntime.js";import{replaceLiteralsWithObjectFields as ct}from"@symbo.ls/utils";import{runPluginHook as V}from"@symbo.ls/utils/function.js";import{applyStateMethods as z}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as $,DEFAULT_CSS_PROPERTIES_LIST as L}from"css-in-props";import{css as rt,wrapHoverRule as Ct}from"@symbo.ls/css";import{pushConfig as j,popConfig as E}from"@symbo.ls/scratch";import{checkAttributeByTagName as it,applyAttrTransforms as Wt}from"attrs-in-props";let Bt=1;const m=[];let et=!1;function Ht(){et||(et=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(vt):setTimeout(vt,0))}function vt(){if(et=!1,!m.length)return;const t=m.splice(0,m.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 St(t,s){typeof t.onMounted=="function"&&(t.__ref.__mountOptions=s,m.push(t),Ht())}function kt(t,s){if(typeof t.onContentUpdate!="function")return;t.context?.plugins?.length&&V("contentUpdate",t,s);const n=t.context?.designSystem;n&&j(n);try{t.onContentUpdate(t,t.state,t.context,s)}catch(c){if(t.context?.plugins?.length&&V("error",t,{hook:"onContentUpdate",error:c})||console.error('[DOMQL] Lifecycle "onContentUpdate" error:',c),t.context?.strictMode)throw c}finally{n&&E()}}function B(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function Yt(t){return t.charAt(2).toLowerCase()+t.slice(3)}function Gt(t){return t.toLowerCase()}function wt(t){const s=t.charCodeAt(0);return s===58||s===64||s===38}function q(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=q(f,o):n[c]=o}return n}function H(t,s,n,c={},f){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||`_${Bt++}`,o.parent=s||null,o.context=t.context||s?.context||c.context||{},o.context.__create||(o.context.__create=H);const i=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:s?.__ref?.root||o,path:s?.__ref?.path?[...s.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const u=n.indexOf("_");if(u>0){const h=n.substring(0,u),g=o.context?.components;g&&(g[h]||g["smbls."+h])?t={...t,extends:h}:g&&At()&&/^[A-Z]\w*_\d+$/.test(n)&&console.warn(`[smbls] auto-extend: key "${n}" looks like a multi-instance (${h}_N) but neither "${h}" nor "smbls.${h}" is registered in context.components \u2014 element will render as a plain <div>. Register the base component or rename the key.`)}}Ut(o,t,c);const e=new Set(["childProps","attr","style","scope","data"]),r=o.props&&typeof o.props=="object"?o.props:null;for(const u in t){if(u==="parent"||u==="node"||u==="__ref"||u==="extends"||u==="context"||u==="props")continue;const h=t[u],g=o[u],C=g&&h&&typeof g=="object"&&typeof h=="object"&&!Array.isArray(g)&&!Array.isArray(h)&&typeof g!="function"&&typeof h!="function";C&&u.charCodeAt(0)>=65&&u.charCodeAt(0)<=90?o[u]=q(g,h):C&&e.has(u)?o[u]={...g,...h}:C&&wt(u)?o[u]=q(g,h):o[u]=h}function a(u){for(const h in u){const g=u[h],C=o[h],x=C&&g&&typeof C=="object"&&typeof g=="object"&&!Array.isArray(C)&&!Array.isArray(g)&&typeof C!="function"&&typeof g!="function";x&&h.charCodeAt(0)>=65&&h.charCodeAt(0)<=90?o[h]=q(C,g):x&&e.has(h)?o[h]={...C,...g}:x&&wt(h)?o[h]=q(C,g):o[h]=g}}r&&a(r),t.props&&typeof t.props=="object"&&a(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 d=o.scope&&typeof o.scope=="object"?o.scope:null,l=s?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,y=l||p||null;if(t.scope!==void 0||d){const u={};d&&Object.assign(u,d),t.scope!==void 0&&Object.assign(u,t.scope),o.scope=Mt(u,y)}else y&&(o.scope=y);if(t.if!==void 0&&(o.if=t.if),Vt(o),Zt(o,s,t),o.if!=null){let u;if(typeof o.if=="function")try{u=o.if(o,o.state,o.context)}catch(h){if(u=!1,i.__ifError=h,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,h?.message||h)}}else u=o.if;i.__if=!!u}if(i.__if)typeof o.if=="function"&&(i.__ifInitialized=!0);else return s&&(s[o.key]=o),typeof o.if=="function"&&Pt(o,i,o.if),o;o.tag||(o.tag=bt(o)),I("Init",o,c);const _=o.node=nt(o);if(!_)return o;if(o.tag==="fragment"){const h=(o.context?.document||globalThis.document).createComment("");_.appendChild(h),i.__fragmentAnchor=h}I("AttachNode",o,c),_.setAttribute&&o.key&&_.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))),_.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&_.setAttribute("data-smbls-app",o.context.key),o.id&&_.setAttribute&&(_.id=o.id),Rt(o,c),Et(o),at(o),Tt(o),no(o);try{Ft(o,c)}catch(u){if(typeof console<"u"&&console.error){const h=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${h}:`,u?.message||u,u?.stack?`
|
|
2
2
|
`+u.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(lt(o,!0),yt(o,s,f),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const u=o.context?.designSystem;u&&w(u);try{const h=o.html(o,o.state,o.context);h!=null&&typeof h!="function"&&(o.node.innerHTML=h)}catch{}finally{u&&j()}}if(I("Create",o,c),I("Complete",o,c),I("Render",o,c),I("RenderRouter",o,c),vt(o,c),typeof o.onFrame=="function"){const u=o.onFrame,h=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){h&&w(h);try{u(o,o.state,o.context)}catch(b){console.error("[DOMQL] onFrame error:",b)}finally{h&&j()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function Gt(t,s,n){const c=!s,f=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=c&&f&&t.context?.state,i=n.state!==void 0&&!o?n.state:t.state&&!U(t.state)?t.state:void 0;if(i==null){if(s?.state)t.state=s.state,q(t,t.state);else if(t.context?.state){const e=t.context.state,r={...e},a=t.context?.polyglot;if(a?.translations){const d=e.lang||a.defaultLang||"en",l=a.translations[d];if(l&&typeof l=="object")for(const y in l)r[y]===void 0&&(r[y]=l[y]);const p=new Set(a.languages||[]);for(const y in a.translations)!p.has(y)&&r[y]===void 0&&(r[y]=a.translations[y])}t.state=U(r)?r:ot(r),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 i=="string"){if(t.state=wt(i,s),t.state&&typeof t.state=="object"&&!U(t.state)){const e=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:e,enumerable:!1,configurable:!0,writable:!0})}q(t,t.state);return}if(typeof i=="function"){const e=i(t,s?.state);t.state=U(e)?e:ot(e||{})}else U(i)?t.state=i:t.state=ot({...i});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 et(t,s){if(!s)return t;const n=s.split("/");let c=t;for(const f of n){if(c==null)return{};c=c[f]}return c??{}}function wt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const f=t.slice(3);return f?et(s.state,f):s.state??{}}if(t.startsWith("~/")){const f=s.state?.root||s.state,o=t.slice(2);return o?et(f,o):f??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=et(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const c=s.context?.polyglot;if(c?.translations){const f=s.state?.root?.lang||c.defaultLang||"en",o=c.translations[f];if(o?.[t]!==void 0)return o[t];if(c.translations[t]!==void 0)return c.translations[t]}return{}}function Zt(t){const s=t.__ref,n=t.tag||"div",c=t.context?.designSystem,f=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const e=o[i];if(typeof t[e]!="function"||V.has(e))continue;const r=e.charCodeAt(0);r>=65&&r<=90||B(e)||T[e]||L&&L.has(e)||rt(n,e)||f.push({prop:e,fn:t[e]})}for(let i=0;i<f.length;i++){const{prop:e,fn:r}=f[i];s.__exec[e]=r,Object.defineProperty(t,e,{get(){c&&w(c);try{return r(t,t.state,t.context)}catch{return}finally{c&&j()}},set(a){delete s.__exec[e],Object.defineProperty(t,e,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function qt(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const c=s[n];try{typeof c=="function"?c(t,t.state,t.context):typeof c=="string"&&t.state?.[c]}catch{}}}function k(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...c){return qt(t,s),n.apply(this,c)}}function Q(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function jt(t,s){const n=t.__ref,c=!!(s&&s.skipIfEffect);if(Zt(t),typeof t.text=="function"){const o=t.text,i=k(t,t.textDeps,o),e=S(()=>{if(!n.contentManaged)try{let r=i(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=nt.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,i=S(()=>{if(n.contentManaged)return;const e=nt.call(t,o,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(i),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!V.has(o)&&!B(o)&&!n.__exec[o]){if(T[o]){const i=t[o],e=k(t,t[o+"Deps"],i),r=o;let a;const d=S(()=>{const l=t.context?.designSystem;l&&w(l);try{const p=e(t,t.state,t.context),y=T[r](p,t,t.state,t.context);if(y&&t.node){const _=Pt(y);(_===null||_!==a)&&(a=_,Y(t.node,y))}else t.node&&(r==="show"||r==="hide")&&(a=void 0,t.node.style.display="")}finally{l&&j()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}else if(L&&L.has(o)){const i=t[o],e=k(t,t[o+"Deps"],i),r=o;let a;const d=S(()=>{const l=t.context?.designSystem;l&&w(l);try{const p=e(t,t.state,t.context);if(t.node)if(p!=null){const y=r+":"+String(p);y!==a&&(a=y,Y(t.node,{[r]:p}))}else a=void 0,t.node.style[r]=""}finally{l&&j()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}}if(typeof t.html=="function"){const o=t.html,i=k(t,t.htmlDeps,o),e=S(()=>{const r=t.context?.designSystem;r&&w(r);try{const a=i(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&(t.node.innerHTML=a)}finally{r&&j()}},{depth:n.path.length});n.__effects.push(e),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,i=k(t,t.valueDeps,o),e=S(()=>{try{const r=i(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const a=r==null?"":String(r);if(t.node.value===a)return;const d=typeof document<"u"&&document.activeElement===t.node,l=d&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=d&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=a,d&&l!=null&&p!=null)try{t.node.setSelectionRange(l,p)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,i=k(t,t.styleDeps,o);let e;const r=S(()=>{const a=i(t,t.state,t.context),d=Pt(a);(d===null||d!==e)&&(e=d,Y(t.node,a))},{depth:n.path.length});n.__effects.push(r),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const i=t.style[o];if(typeof i!="function")continue;const e=k(t,Q(t.styleDeps,o),i);let r;const a=S(()=>{try{const d=e(t,t.state,t.context);if(t.node){const l=o+":"+String(d);l!==r&&(r=l,Y(t.node,{[o]:d}))}}catch{}},{depth:n.path.length});n.__effects.push(a)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const i=k(t,Q(t.attrDeps,o),t.attr[o]),e=o,r=S(()=>{try{const a=i(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(r)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const i=k(t,Q(t.ariaDeps,o),t.aria[o]),e="aria-"+o.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),r=S(()=>{try{const a=i(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const i=k(t,Q(t.dataDeps,o),t.data[o]),r="data-"+o.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),a=S(()=>{try{const d=i(t,t.state,t.context);if(!t.node?.setAttribute)return;d==null||d===!1?t.node.removeAttribute(r):typeof d!="function"&&typeof d!="object"&&t.node.setAttribute(r,d===!0?"":d)}catch{}},{depth:n.path.length});n.__effects.push(a)}const f=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(f)for(const o in f){if(typeof f[o]!="function")continue;const i=k(t,Q(t.classDeps,o),f[o]),e=S(()=>{try{const r=i(t,t.state,t.context);if(!t.node?.classList)return;typeof r=="string"?t.node.classList.add(r):r?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(e)}!c&&typeof t.if=="function"&&Et(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||V.has(o)||typeof t[o]!="function")continue;const i=o.charCodeAt(0);if(i>=65&&i<=90||B(o))continue;const e=t[o];n.__exec[o]=e;const r=t.tag||"div";if(rt(r,o)&&!T[o]&&!(L&&L.has(o))){const a=o,d=k(t,t[o+"Deps"],e),l=S(()=>{try{const p=d(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(a):typeof p!="function"&&typeof p!="object"&&(a==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(a,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(l)}}if(Xt(t),mt(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,i=t.stateDeps;let e=!1,r=[];const a=S(()=>{const d=[];for(let _=0;_<i.length;_++){const u=i[_];try{d[_]=typeof u=="function"?u(t,t.state,t.context):t.state?.[u]}catch{d[_]=void 0}}if(!e){e=!0,r=d;return}let l=d.length!==r.length;for(let _=0;!l&&_<d.length;_++)d[_]!==r[_]&&(l=!0);const p=r;if(r=d,!l)return;const y=t.context?.designSystem;y&&w(y);try{o(t,t.state,t.context,{prev:p,next:d})}catch(_){if(t.context?.plugins?.length&&W("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{y&&j()}},{depth:n.path.length});n.__effects.push(a)}}function Et(t,s,n){const c=k(t,t.ifDeps,n),f=S(()=>{let o;try{o=c(t,t.state,t.context)}catch(e){if(o=!1,s.__ifError=e,typeof console<"u"&&console.warn){const r=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${r} \u2014 treating as false:`,e?.message||e)}return}const i=s.__if;if(s.__if=!!o,i&&!s.__if&&t.node)t.node.remove();else if(!i&&s.__if)if(s.__ifInitialized){t.node||(t.node=st(t)),t.node&&(t.node.ref=t);const e=t.parent,r=e?.node;if(r&&t.node){let a=null;const d=Object.keys(e),l=d.indexOf(t.key);for(let p=l+1;p<d.length;p++){const y=e[d[p]];if(y?.node?.parentNode===r){a=y.node;break}}a?r.insertBefore(t.node,a):r.appendChild(t.node)}else yt(t,t.parent);ft(t)}else{if(s.__ifInitialized=!0,t.tag||(t.tag=xt(t)),I("Init",t,{}),t.node||(t.node=st(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 r=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(r),s.__fragmentAnchor=r}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),$t(t,{}),jt(t,{skipIfEffect:!0}),ft(t),Dt(t),Rt(t,{}),yt(t,t.parent),vt(t,{})}},{depth:s.path.length});s.__effects.push(f)}function ft(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),oo(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 c=t.attr[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.setAttribute&&s.setAttribute(n,c===!0?"":c)}if(t.data&&typeof t.data=="object")for(const n in t.data){const c=t.data[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.dataset&&(s.dataset[n]=c===!0?"":c)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(c=>c&&s.classList.add(c));else if(typeof n=="object")for(const c in n){const f=typeof n[c]=="function"?n[c](t,t.state,t.context):n[c];f&&s.classList.add(typeof f=="string"?f:c)}}}}function Pt(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 c in s){const f=s[c];if(f!=null){if(c.charAt(0)==="&"&&typeof f=="object"){n||(n={}),n[c]=f;continue}try{const o=String(f),i=c.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),e=o.trim(),r=/\s*!important\s*$/.test(e),a=e.replace(/\s*!important\s*$/,"");t.style.setProperty(i,a,r?"important":"")}catch{}}}n&&Qt(t,n)}let zt=0;function Qt(t,s){const n=`_ds${zt++}`;t.classList.add(n);const c=t.ownerDocument;let f=c.querySelector("style[data-smbls-scoped]");f||(f=c.createElement("style"),f.setAttribute("data-smbls-scoped",""),c.head.appendChild(f));let o="";for(const i in s){const e="."+n,r=i.replace(/&/g,e).split(",").map(d=>{const l=d.trim();return l.includes(e)?l:e+l}).join(", "),a=s[i];if(typeof a=="object"){let d="",l="";for(const p in a){const y=a[p];if(typeof y=="object"){const _=p.includes("&")?r.split(", ").map(h=>p.replace(/&/g,h)).join(", "):r.split(", ").map(h=>`${h} ${p}`).join(", ");let u="";for(const h in y)u+=`${h.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[h]};`;l+=At(`${_} { ${u} }`,_)+`
|
|
5
|
-
`}else d+=`${p.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${y};`}d&&(o+=
|
|
6
|
-
`),l&&(o+=l)}}o&&(f.textContent+=o)}function Xt(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 c=0;c<s.length;c++){const f=s[c];if(typeof f!="string"||f.length===0)continue;const o=f.split("."),i=o[0],e=o.slice(1),r={value:!1},a=S(()=>{const d=t.state&&(U(t.state)?t.state.root:null);if(!d||!U(d))return;let l=d;l=l[i];for(let y=0;y<e.length&&!(l==null||typeof l!="object");y++)if(U(l))l=l[e[y]];else break;if(!r.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&w(y);try{t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0})===!1&&(p=!0)}catch(_){t.context?.plugins?.length&&W("error",t,{hook:"onBeforeUpdate",error:_})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",_)}finally{y&&j()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const _=n.__effects[y];_&&_!==a&&!_._disposed&&!_._isSubscribeToEffect&&typeof _._execute=="function"&&_._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&w(y);try{t.onUpdate(t,t.state,t.context)}catch(_){t.context?.plugins?.length&&W("error",t,{hook:"onUpdate",error:_})||console.error("[DOMQL] subscribeTo onUpdate error:",_)}finally{y&&j()}}},{depth:n.path.length});r.value=!0,a._isSubscribeToEffect=!0,n.__effects.push(a)}}function at(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 Ot=new Set;function Jt(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",c=n+"::"+t;Ot.has(c)||(Ot.add(c),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 G(t,s,n){const c={},f=(o,i)=>{if(T[o]){const e=T[o](i,s,s.state,s.context);if(e){const r=Array.isArray(e)?e:[e];for(const a of r)a&&Object.assign(c,a)}}else c[o]=i};for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let i=t[o];if(typeof i=="function"&&(i=i(s,s.state,s.context)),!(i==null||typeof i=="function")){if(typeof i=="object"&&!Array.isArray(i)){if(o==="style"){for(const a in i){let d=i[a];typeof d=="function"&&(d=d(s,s.state,s.context)),!(d==null||typeof d=="function")&&f(a,d)}continue}if(at(o,s)){const a=G(i,s,!0);Object.keys(a).length&&(c[`[data-theme="${o.slice(1)}"] &`]=a);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(o)){bt()&&Jt(o,s);continue}let e=o;if(o.charCodeAt(0)===64&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const a=s.context?.designSystem?.media?.[o.slice(1)];a&&(e=`@media ${a}`)}const r=G(i,s,!1);Object.keys(r).length&&(c[e]=r);continue}f(o,i)}}if(n)for(const o in c){const i=c[o];typeof i=="string"&&!i.includes("!important")&&(c[o]=i+" !important")}return c}function mt(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const f=c.charAt(0);if(f!=="."&&f!=="!")continue;const o=c.slice(1);if(!o)continue;const i=t[c];if(!i||typeof i!="object")continue;const e=f==="!",r={lastMatch:!1,appliedKeys:null,appliedClasses:null},a=()=>{if(!t.node)return;let l;const p=t[o];if(p===void 0)if(t.state&&o in t.state)l=t.state[o];else{const u=t.context?.cases?.[o];if(u===void 0)return;try{l=typeof u=="function"?u.call(t,t):u}catch(h){l=!1,s.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}}else if(typeof p=="function")try{l=p(t,t.state,t.context)}catch(u){l=!1,s.__conditionalError=u,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,u?.message||u)}else l=p;const y=e?!l:!!l;if(y===r.lastMatch)return;r.lastMatch=y;const _=t.context?.designSystem;_&&w(_);try{if(y){const u={},h={};let g=!1;for(const x in i){if(!Object.prototype.hasOwnProperty.call(i,x))continue;const A=i[x],E=x.charAt(0);if((E===":"||E==="@"||E==="&")&&A&&typeof A=="object"&&!Array.isArray(A)){if(at(x,t)){const P=G(A,t,!0);Object.keys(P).length&&(h[`[data-theme="${x.slice(1)}"] &`]=P,g=!0)}else{let P=x;if(E==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const R=t.context?.designSystem?.media?.[x.slice(1)];R&&(P=`@media ${R}`)}const $=G(A,t,!1);Object.keys($).length&&(h[P]=$,g=!0)}continue}const K=typeof A=="function"?A(t,t.state,t.context):A;if(K!=null)if(T[x]){const P=T[x](K,t,t.state,t.context);if(P){const $=Array.isArray(P)?P:[P];for(const R of $)R&&Object.assign(u,R)}}else L&&L.has(x)&&(u[x]=K)}const b=Object.keys(u);if(b.length){Y(t.node,u);for(const x of b)n.set(x,c);r.appliedKeys=b}else r.appliedKeys=null;if(g){const x=ct(h,null,t.context?.cssPrefix),A=x?x.split(" ").filter(Boolean):[];if(A.length&&t.node.classList){for(const E of A)t.node.classList.add(E);r.appliedClasses=A}else r.appliedClasses=null}else if(r.appliedClasses){for(const x of r.appliedClasses)t.node.classList.remove(x);r.appliedClasses=null}}else{if(r.appliedKeys){for(const u of r.appliedKeys)n.get(u)===c&&(t.node.style[u]="",n.delete(u));r.appliedKeys=null}if(r.appliedClasses){for(const u of r.appliedClasses)t.node.classList.remove(u);r.appliedClasses=null}}}finally{_&&j()}};s.__conditionalRunners.push(a);const d=S(a,{depth:s.path.length});s.__effects.push(d)}}const dt=new WeakSet;function to(t){const s=t.ownerDocument;!s||dt.has(s)||(dt.add(s),queueMicrotask(()=>{dt.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const ut=new WeakSet;let Lt=!1;function oo(t){const{node:s}=t;if(!s)return;if(Lt||(Lt=!0,ct({display:"none"})),ut.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}ut.add(t);const n=t.context?.designSystem;n&&w(n);try{const c={};let f=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||V.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!B(o)){if(T[o]){const e=t[o],r=T[o](e,t,t.state,t.context);if(r){if(Array.isArray(r))for(const a of r)a&&Object.assign(c,a);else Object.assign(c,r);f=!0}}else if(L&&L.has(o)){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charCodeAt(0)===45){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="&"){const e=t[o];e&&typeof e=="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const e=t[o];if(e&&typeof e=="object"){if(at(o,t)){const r=G(e,t,!0);Object.keys(r).length&&(c[`[data-theme="${o.slice(1)}"] &`]=r,f=!0)}else{let r=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const d=t.context?.designSystem?.media?.[o.slice(1)];d&&(r=`@media ${d}`)}const a=G(e,t,!1);Object.keys(a).length&&(c[r]=a,f=!0)}f=!0}}}}if(f){c.display&&String(c.display).includes("!important")&&(s.style.setProperty("display",String(c.display).replace(/\s*!important\s*$/,""),"important"),delete c.display);const o=ct(c,null,t.context?.cssPrefix);if(o&&s.classList){const e=o.split(" ").filter(Boolean);let r=!1;for(const a of e)s.classList.add(a),r||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(r=!0);r&&to(s)}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const e=c.display;if(e&&e!==i)if(i==="none"){const r=[];for(const a of s.classList)a.startsWith("_d-")&&a!=="_d-none"&&r.push(a);for(const a of r)s.classList.remove(a);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&j(),ut.delete(t)}}function Dt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const f in t.aria){const o=t.aria[f];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+f.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());s.setAttribute(i,o===!0?"":o)}const n=Vt(t);for(const f in n){const o=n[f];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(f,o===!0?"":o)}const c=t.tag||"div";for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||typeof t[f]=="function"||V.has(f)||f==="on"||n[f]!==void 0)continue;const o=f.charCodeAt(0);if(!(o>=65&&o<=90)&&!B(f)&&!(T[f]||L&&L.has(f))&&rt(c,f)){let i=t[f];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=nt(i,t,t.state,t.context),t[f]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;s.setAttribute(f,i===!0?"":i)}}}function so(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,c=n&&typeof n=="object"&&n.max?String(n.max):null;c&&(s.style.maxHeight=c);const f=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};f(),s.addEventListener("input",f),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",f)}catch{}})}const Tt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function $t(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!B(n)||Tt.has(n))continue;let c=t[n];if(typeof c=="string"&&/^[A-Za-z_$][\w$]*$/.test(c)){const o=c;c=function(e){return t.call(o,e)}}if(typeof c!="function")continue;const f=Ht(n);Mt.has(f)||It(Yt(f),t,c)}no(t)}function no(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let c=!1;for(const p of Tt){const y=t[p];typeof y=="function"&&(n[p]=y,c=!0)}if(!c)return;const f=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let i=0,e=0,r=0,a=!1;const d=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(i=y.clientX,e=y.clientY,r=Date.now(),a=!0)},l=p=>{if(!a)return;a=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const _=y.clientX-i,u=y.clientY-e,h=Date.now()-r;if(h>o)return;const g=Math.abs(_),b=Math.abs(u);if(Math.max(g,b)<f)return;let x;if(g>b*1.2)x=_<0?"left":"right";else if(b>g*1.2)x=u<0?"up":"down";else return;const A="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),E=n[A],K=n.onSwipe;E&&E.call(t,p,t,t.state,t.context),K&&K.call(t,{direction:x,dx:_,dy:u,dt:h,event:p},t,t.state,t.context)};s.addEventListener("touchstart",d,{passive:!0}),s.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",d)}catch{}try{s.removeEventListener("touchend",l)}catch{}})}function m(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=m(f,o):n[c]=o}return n}function pt(t,s,n){if(!s||!t.node)return;const c=t.childExtends;if(Array.isArray(s)){const f=t.tag==="fragment",o=t.context?.document||globalThis.document,i=f?null:o?.createDocumentFragment();if(!f&&!i)return;const e=t.childProps,r=t.childrenAs;for(let a=0;a<s.length;a++){let d=s[a];const l=d;(typeof d=="string"||typeof d=="number")&&(d={text:d});let p=e;if(typeof e=="function")try{p=e(t,d)}catch{p=null}if(r==="state"){let u=l;(typeof l=="string"||typeof l=="number")&&(u={value:l,text:l}),d=p?{...p,state:u}:{state:u}}else p&&(d=m(p,d));if(c&&!d.ignoreChildExtends)if(d.extends){const u=Array.isArray(d.extends)?d.extends:[d.extends],h=Array.isArray(c)?c:[c];d={...d,extends:[...h,...u]}}else d={...d,extends:c};const y=d?.key||l&&typeof l=="object"&&l.key||`${a}`,_=H(d,t,y,n);!f&&_?.node&&i.appendChild(_.node)}f||t.node.appendChild(i);return}if(typeof s=="string"){const f=wt(s,t);if(Array.isArray(f)){pt(t,f,n);return}}if(typeof s=="object")for(const f in s){if(V.has(f))continue;let o=s[f];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=m(t.childProps,o)),c&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],e=Array.isArray(c)?c:[c];o={...o,extends:[...e,...i]}}else o={...o,extends:c};H(o,t,f,n)}}}function lt(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const c=n.options;if(!c||!c.length)return;const f=t.__ref,o=f&&f.__exec&&f.__exec.value,i=typeof o=="function",e=t.value!=null&&typeof t.value!="function";if(i||e){let d;if(i)try{d=o(t,t.state,t.context)}catch{return}else d=t.value;const l=d==null?"":String(d);n.value!==l&&(n.value=l);return}const r=s||!(f&&f.__selectSynced);if(f&&(f.__selectSynced=!0),!r)return;let a=-1;for(let d=0;d<c.length;d++)c[d].defaultSelected&&(a=d);a>=0&&n.selectedIndex!==a&&(n.selectedIndex=a)}function Rt(t,s){let{children:n,content:c}=t;const f=t.childExtends;if(typeof n=="function"){const i=n;n=i(t,t.state,t.context),t.children=n;const e=t.__ref;let r=!1;const a=k(t,t.childrenDeps,i),d=S(()=>{const l=a(t,t.state,t.context);if(!r){r=!0;return}if(l===t.children)return;t.children=l;const p=typeof t.onContentUpdate=="function",y=p?[]:null,_=p?[]:null,u=p?[]:null;if(Array.isArray(l)&&t.childrenAs==="state"){const x=t.childProps,A=[],E=new Map;for(let v=0;v<l.length;v++){const O=l[v];let C=x;if(typeof x=="function")try{C=x(t,O)}catch{C=null}const N=C&&C.key||O&&O.key||`${v}`;A.push(N),E.set(N,{rawChild:O,childProps:C})}const K=new Set(A),P=e.__children.slice();for(const v of P)if(!K.has(v)){const O=t[v];O?.remove&&O.remove(),delete t[v],_&&_.push(v)}const $=t.childExtends,R=t.tag==="fragment",Ft=t.context?.document||globalThis.document,Z=R?null:Ft?.createDocumentFragment();for(const v of A){const O=E.get(v),C=O.rawChild,N=t[v];if(N&&N.state){if(C&&typeof C=="object"){const D=N.state,X=D.$replace||D.replace,gt=D.$update||D.update;if(typeof X=="function")X.call(D,C);else if(typeof gt=="function"){for(const M in D)if(!(M==="__element"||M==="root"||M==="parent"||M==="update")&&!Object.prototype.hasOwnProperty.call(C,M))try{D[M]=void 0}catch{}gt.call(D,C)}else for(const M in C)D[M]=C[M]}u&&u.push(v);continue}let tt=C;(typeof C=="string"||typeof C=="number")&&(tt={value:C,text:C});const ht=O.childProps;let F=ht?{...ht,state:tt}:{state:tt};if($&&!F.ignoreChildExtends)if(F.extends){const D=Array.isArray(F.extends)?F.extends:[F.extends],X=Array.isArray($)?$:[$];F={...F,extends:[...X,...D]}}else F={...F,extends:$};const _t=H(F,t,v,s);!R&&_t?.node&&Z&&Z.appendChild(_t.node),y&&y.push(v)}if(!R&&Z&&Z.childNodes.length&&t.node&&t.node.appendChild(Z),!R&&t.node){let v=null;for(const O of A){const C=t[O]?.node;if(!C)continue;const N=v?v.nextSibling:t.node.firstChild;C!==N&&t.node.insertBefore(C,N),v=C}}e.__children=A,p&&(y.length||_.length)&&St(t,{added:y,removed:_,kept:u}),lt(t,!1);return}const b=p?[...e.__children]:null;for(const x of[...e.__children]){const A=t[x];A?.remove&&A.remove(),delete t[x]}e.__children=[],pt(t,l,s),lt(t,!1),p&&St(t,{added:[...e.__children],removed:b,kept:[]})},{depth:e.path.length});e.__effects.push(d)}if(pt(t,n||c,s),n||c)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let e=0;e<i.length;e++){const r=i[e];if(!r.endsWith("Extends")||typeof t[r]!="string")continue;const a=r.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const d={extends:t[r]};delete t[r];for(let l=e+1;l<i.length;l++){const p=i[l],y=p.charCodeAt(0);if(y>=65&&y<=90||V.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const _=t[p];_!==void 0&&(d[p]=_,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...d,...t[a]}:t[a]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||V.has(i)||typeof t[i]!="object"||t[i]===null)continue;const e=i.charCodeAt(0);if(e<65||e>90)continue;let r=t[i];if(!r.__ref){if(!r.extends&&!r.extend){const a=o[i]||o[`smbls.${i}`];a&&(r={...r,extends:a})}if(t.childProps&&(r=m(t.childProps,r)),f&&!r.ignoreChildExtends)if(r.extends){const a=Array.isArray(r.extends)?r.extends:[r.extends],d=Array.isArray(f)?f:[f];r={...r,extends:[...d,...a]}}else r={...r,extends:f};H(r,t,i,s)}}}function yt(t,s,n){const{node:c}=t;if(!c)return;c.ref=t;const f=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(f){const i=f.parentNode;if(i){if(n?.position==="before"&&n.node)i.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const e=n.node.nextSibling;i.insertBefore(c,e||f)}else i.insertBefore(c,f);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;i?o.insertBefore(c,i):o.appendChild(c)}else o.appendChild(c)}function I(t,s,n){const c=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&W(c,s,n);const f="on"+t,o=s[f];if(typeof o=="function"){const i=t==="Render"||t==="RenderRouter";if(i){if(s.__ref.__inRender)return!0;s.__ref.__inRender=!0}const e=s.context?.designSystem;e&&w(e);try{if(o(s,s.state,s.context,n)===!1)return!1}catch(r){if(s.context?.plugins?.length&&W("error",s,{hook:f,error:r})||console.error(`[DOMQL] Lifecycle "${f}" error:`,r),s.context?.strictMode)throw r}finally{e&&j(),i&&(s.__ref.__inRender=!1)}}return!0}var wo=H;export{H as create,wo as default,Ct as flushMounts};
|
|
4
|
+
`):"")}}if(yt(o,!0),ht(o,s,f),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const u=o.context?.designSystem;u&&j(u);try{const h=o.html(o,o.state,o.context);h!=null&&typeof h!="function"&&(o.node.innerHTML=h)}catch{}finally{u&&E()}}if(I("Create",o,c),I("Complete",o,c),I("Render",o,c),I("RenderRouter",o,c),St(o,c),typeof o.onFrame=="function"){const u=o.onFrame,h=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){h&&j(h);try{u(o,o.state,o.context)}catch(C){console.error("[DOMQL] onFrame error:",C)}finally{h&&E()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function Zt(t,s,n){const c=!s,f=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=c&&f&&t.context?.state,i=n.state!==void 0&&!o?n.state:t.state&&!K(t.state)?t.state:void 0;if(i==null){if(s?.state)t.state=s.state,z(t,t.state);else if(t.context?.state){const e=t.context.state,r={...e},a=t.context?.polyglot;if(a?.translations){const d=e.lang||a.defaultLang||"en",l=a.translations[d];if(l&&typeof l=="object")for(const y in l)r[y]===void 0&&(r[y]=l[y]);const p=new Set(a.languages||[]);for(const y in a.translations)!p.has(y)&&r[y]===void 0&&(r[y]=a.translations[y])}t.state=K(r)?r:st(r),t.state.__element=t,t.state.root=t.state,z(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),z(t,t.state);return}if(typeof i=="string"){if(t.state=jt(i,s),t.state&&typeof t.state=="object"&&!K(t.state)){const e=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:e,enumerable:!1,configurable:!0,writable:!0})}z(t,t.state);return}if(typeof i=="function"){const e=i(t,s?.state);t.state=K(e)?e:st(e||{})}else K(i)?t.state=i:t.state=st({...i});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,z(t,t.state)}function ft(t,s){if(!s)return t;const n=s.split("/");let c=t;for(const f of n){if(c==null)return{};c=c[f]}return c??{}}function jt(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const f=t.slice(3);return f?ft(s.state,f):s.state??{}}if(t.startsWith("~/")){const f=s.state?.root||s.state,o=t.slice(2);return o?ft(f,o):f??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=ft(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const c=s.context?.polyglot;if(c?.translations){const f=s.state?.root?.lang||c.defaultLang||"en",o=c.translations[f];if(o?.[t]!==void 0)return o[t];if(c.translations[t]!==void 0)return c.translations[t]}return{}}function zt(t){const s=t.__ref,n=t.tag||"div",c=t.context?.designSystem,f=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const e=o[i];if(typeof t[e]!="function"||U.has(e))continue;const r=e.charCodeAt(0);r>=65&&r<=90||B(e)||$[e]||L&&L.has(e)||it(n,e)||f.push({prop:e,fn:t[e]})}for(let i=0;i<f.length;i++){const{prop:e,fn:r}=f[i];s.__exec[e]=r,Object.defineProperty(t,e,{get(){c&&j(c);try{return r(t,t.state,t.context)}catch{return}finally{c&&E()}},set(a){delete s.__exec[e],Object.defineProperty(t,e,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function qt(t,s){if(!(!Array.isArray(s)||s.length===0))for(let n=0;n<s.length;n++){const c=s[n];try{typeof c=="function"?c(t,t.state,t.context):typeof c=="string"&&t.state?.[c]}catch{}}}function w(t,s,n){return!Array.isArray(s)||s.length===0?n:function(...c){return qt(t,s),n.apply(this,c)}}function Q(t,s){if(!(!t||Array.isArray(t)||typeof t!="object"))return t[s]}function Et(t,s){const n=t.__ref,c=!!(s&&s.skipIfEffect);if(zt(t),typeof t.text=="function"){const o=t.text,i=w(t,t.textDeps,o),e=k(()=>{if(!n.contentManaged)try{let r=i(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=ct.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.text=o}else if(typeof t.text=="string"&&t.text.includes("{{")){const o=t.text,i=k(()=>{if(n.contentManaged)return;const e=ct.call(t,o,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(i),n.__exec.text=o}for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&typeof t[o]=="function"&&!U.has(o)&&!B(o)&&!n.__exec[o]){if($[o]){const i=t[o],e=w(t,t[o+"Deps"],i),r=o;let a;const d=k(()=>{const l=t.context?.designSystem;l&&j(l);try{const p=e(t,t.state,t.context),y=$[r](p,t,t.state,t.context);if(y&&t.node){const _=Ot(y);(_===null||_!==a)&&(a=_,Y(t.node,y))}else t.node&&(r==="show"||r==="hide")&&(a=void 0,t.node.style.display="")}finally{l&&E()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}else if(L&&L.has(o)){const i=t[o],e=w(t,t[o+"Deps"],i),r=o;let a;const d=k(()=>{const l=t.context?.designSystem;l&&j(l);try{const p=e(t,t.state,t.context);if(t.node)if(p!=null){const y=r+":"+String(p);y!==a&&(a=y,Y(t.node,{[r]:p}))}else a=void 0,t.node.style[r]=""}finally{l&&E()}},{depth:n.path.length});n.__effects.push(d),n.__exec[o]=i}}if(typeof t.html=="function"){const o=t.html,i=w(t,t.htmlDeps,o),e=k(()=>{const r=t.context?.designSystem;r&&j(r);try{const a=i(t,t.state,t.context);t.node&&a!=null&&typeof a!="function"&&(t.node.innerHTML=a)}finally{r&&E()}},{depth:n.path.length});n.__effects.push(e),n.__exec.html=o}if(typeof t.value=="function"){const o=t.value,i=w(t,t.valueDeps,o),e=k(()=>{try{const r=i(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const a=r==null?"":String(r);if(t.node.value===a)return;const d=typeof document<"u"&&document.activeElement===t.node,l=d&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,p=d&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=a,d&&l!=null&&p!=null)try{t.node.setSelectionRange(l,p)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(e),n.__exec.value=o}if(typeof t.style=="function"){const o=t.style,i=w(t,t.styleDeps,o);let e;const r=k(()=>{const a=i(t,t.state,t.context),d=Ot(a);(d===null||d!==e)&&(e=d,Y(t.node,a))},{depth:n.path.length});n.__effects.push(r),n.__exec.style=o}else if(t.style&&typeof t.style=="object")for(const o in t.style){const i=t.style[o];if(typeof i!="function")continue;const e=w(t,Q(t.styleDeps,o),i);let r;const a=k(()=>{try{const d=e(t,t.state,t.context);if(t.node){const l=o+":"+String(d);l!==r&&(r=l,Y(t.node,{[o]:d}))}}catch{}},{depth:n.path.length});n.__effects.push(a)}if(t.attr&&typeof t.attr=="object"){for(const o in t.attr)if(typeof t.attr[o]=="function"){const i=w(t,Q(t.attrDeps,o),t.attr[o]),e=o,r=k(()=>{try{const a=i(t,t.state,t.context);t.node?.setAttribute&&(a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a))}catch{}},{depth:n.path.length});n.__effects.push(r)}}if(t.aria&&typeof t.aria=="object")for(const o in t.aria){if(typeof t.aria[o]!="function")continue;const i=w(t,Q(t.ariaDeps,o),t.aria[o]),e="aria-"+o.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),r=k(()=>{try{const a=i(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(e):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(e,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.data&&typeof t.data=="object")for(const o in t.data){if(typeof t.data[o]!="function")continue;const i=w(t,Q(t.dataDeps,o),t.data[o]),r="data-"+o.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),a=k(()=>{try{const d=i(t,t.state,t.context);if(!t.node?.setAttribute)return;d==null||d===!1?t.node.removeAttribute(r):typeof d!="function"&&typeof d!="object"&&t.node.setAttribute(r,d===!0?"":d)}catch{}},{depth:n.path.length});n.__effects.push(a)}const f=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(f)for(const o in f){if(typeof f[o]!="function")continue;const i=w(t,Q(t.classDeps,o),f[o]),e=k(()=>{try{const r=i(t,t.state,t.context);if(!t.node?.classList)return;typeof r=="string"?t.node.classList.add(r):r?t.node.classList.add(o):t.node.classList.remove(o)}catch{}},{depth:n.path.length});n.__effects.push(e)}!c&&typeof t.if=="function"&&Pt(t,n,t.if);for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||U.has(o)||typeof t[o]!="function")continue;const i=o.charCodeAt(0);if(i>=65&&i<=90||B(o))continue;const e=t[o];n.__exec[o]=e;const r=t.tag||"div";if(it(r,o)&&!$[o]&&!(L&&L.has(o))){const a=o,d=w(t,t[o+"Deps"],e),l=k(()=>{try{const p=d(t,t.state,t.context);t.node?.setAttribute&&(p==null||p===!1?t.node.removeAttribute(a):typeof p!="function"&&typeof p!="object"&&(a==="src"&&"src"in t.node?t.node.src=p:t.node.setAttribute(a,p===!0?"":p)))}catch{}},{depth:n.path.length});n.__effects.push(l)}}if(Jt(t),to(t),typeof t.onStateUpdate=="function"&&Array.isArray(t.stateDeps)){const o=t.onStateUpdate,i=t.stateDeps;let e=!1,r=[];const a=k(()=>{const d=[];for(let _=0;_<i.length;_++){const u=i[_];try{d[_]=typeof u=="function"?u(t,t.state,t.context):t.state?.[u]}catch{d[_]=void 0}}if(!e){e=!0,r=d;return}let l=d.length!==r.length;for(let _=0;!l&&_<d.length;_++)d[_]!==r[_]&&(l=!0);const p=r;if(r=d,!l)return;const y=t.context?.designSystem;y&&j(y);try{o(t,t.state,t.context,{prev:p,next:d})}catch(_){if(t.context?.plugins?.length&&V("error",t,{hook:"onStateUpdate",error:_})||console.error('[DOMQL] Lifecycle "onStateUpdate" error:',_),t.context?.strictMode)throw _}finally{y&&E()}},{depth:n.path.length});n.__effects.push(a)}}function Pt(t,s,n){const c=w(t,t.ifDeps,n),f=k(()=>{let o;try{o=c(t,t.state,t.context)}catch(e){if(o=!1,s.__ifError=e,typeof console<"u"&&console.warn){const r=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${r} \u2014 treating as false:`,e?.message||e)}return}const i=s.__if;if(s.__if=!!o,i&&!s.__if&&t.node)t.node.remove();else if(!i&&s.__if)if(s.__ifInitialized){t.node||(t.node=nt(t)),t.node&&(t.node.ref=t);const e=t.parent,r=e?.node;if(r&&t.node){let a=null;const d=Object.keys(e),l=d.indexOf(t.key);for(let p=l+1;p<d.length;p++){const y=e[d[p]];if(y?.node?.parentNode===r){a=y.node;break}}a?r.insertBefore(t.node,a):r.appendChild(t.node)}else ht(t,t.parent);at(t)}else{if(s.__ifInitialized=!0,t.tag||(t.tag=bt(t)),I("Init",t,{}),t.node||(t.node=nt(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 r=(t.context?.document||globalThis.document).createComment("");t.node.appendChild(r),s.__fragmentAnchor=r}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),Rt(t,{}),Et(t,{skipIfEffect:!0}),at(t),Tt(t),Ft(t,{}),ht(t,t.parent),St(t,{})}},{depth:s.path.length});s.__effects.push(f)}function at(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),so(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 c=t.attr[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.setAttribute&&s.setAttribute(n,c===!0?"":c)}if(t.data&&typeof t.data=="object")for(const n in t.data){const c=t.data[n];typeof c=="function"||typeof c=="object"||c==null||c===!1||s.dataset&&(s.dataset[n]=c===!0?"":c)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(c=>c&&s.classList.add(c));else if(typeof n=="object")for(const c in n){const f=typeof n[c]=="function"?n[c](t,t.state,t.context):n[c];f&&s.classList.add(typeof f=="string"?f:c)}}}}function Ot(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 c in s){const f=s[c];if(f!=null){if(c.charAt(0)==="&"&&typeof f=="object"){n||(n={}),n[c]=f;continue}try{const o=String(f),i=c.replace(/[A-Z]/g,d=>"-"+d.toLowerCase()),e=o.trim(),r=/\s*!important\s*$/.test(e),a=e.replace(/\s*!important\s*$/,"");t.style.setProperty(i,a,r?"important":"")}catch{}}}n&&Xt(t,n)}let Qt=0;function Xt(t,s){const n=`_ds${Qt++}`;t.classList.add(n);const c=t.ownerDocument;let f=c.querySelector("style[data-smbls-scoped]");f||(f=c.createElement("style"),f.setAttribute("data-smbls-scoped",""),c.head.appendChild(f));let o="";for(const i in s){const e="."+n,r=i.replace(/&/g,e).split(",").map(d=>{const l=d.trim();return l.includes(e)?l:e+l}).join(", "),a=s[i];if(typeof a=="object"){let d="",l="";for(const p in a){const y=a[p];if(typeof y=="object"){const _=p.includes("&")?r.split(", ").map(h=>p.replace(/&/g,h)).join(", "):r.split(", ").map(h=>`${h} ${p}`).join(", ");let u="";for(const h in y)u+=`${h.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${y[h]};`;l+=Ct(`${_} { ${u} }`,_)+`
|
|
5
|
+
`}else d+=`${p.replace(/[A-Z]/g,_=>"-"+_.toLowerCase())}: ${y};`}d&&(o+=Ct(`${r} { ${d} }`,r)+`
|
|
6
|
+
`),l&&(o+=l)}}o&&(f.textContent+=o)}function Jt(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 c=0;c<s.length;c++){const f=s[c];if(typeof f!="string"||f.length===0)continue;const o=f.split("."),i=o[0],e=o.slice(1),r={value:!1},a=k(()=>{const d=t.state&&(K(t.state)?t.state.root:null);if(!d||!K(d))return;let l=d;l=l[i];for(let y=0;y<e.length&&!(l==null||typeof l!="object");y++)if(K(l))l=l[e[y]];else break;if(!r.value)return;let p=!1;if(typeof t.onBeforeUpdate=="function"){const y=t.context?.designSystem;y&&j(y);try{t.onBeforeUpdate(t,t.state,t.context,{updateBySubscription:!0})===!1&&(p=!0)}catch(_){t.context?.plugins?.length&&V("error",t,{hook:"onBeforeUpdate",error:_})||console.error("[DOMQL] subscribeTo onBeforeUpdate error:",_)}finally{y&&E()}}if(!p&&t.node&&n.__effects)for(let y=0;y<n.__effects.length;y++){const _=n.__effects[y];_&&_!==a&&!_._disposed&&!_._isSubscribeToEffect&&typeof _._execute=="function"&&_._execute()}if(!p&&typeof t.onUpdate=="function"){const y=t.context?.designSystem;y&&j(y);try{t.onUpdate(t,t.state,t.context)}catch(_){t.context?.plugins?.length&&V("error",t,{hook:"onUpdate",error:_})||console.error("[DOMQL] subscribeTo onUpdate error:",_)}finally{y&&E()}}},{depth:n.path.length});r.value=!0,a._isSubscribeToEffect=!0,n.__effects.push(a)}}function dt(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 Lt=new Set;function mt(t,s){const n=s?.__ref?.path?s.__ref.path.join("."):s?.key||"?",c=n+"::"+t;Lt.has(c)||(Lt.add(c),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 G(t,s,n){const c={},f=(o,i)=>{if($[o]){const e=$[o](i,s,s.state,s.context);if(e){const r=Array.isArray(e)?e:[e];for(const a of r)a&&Object.assign(c,a)}}else c[o]=i};for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let i=t[o];if(typeof i=="function"&&(i=i(s,s.state,s.context)),!(i==null||typeof i=="function")){if(typeof i=="object"&&!Array.isArray(i)){if(o==="style"){for(const a in i){let d=i[a];typeof d=="function"&&(d=d(s,s.state,s.context)),!(d==null||typeof d=="function")&&f(a,d)}continue}if(dt(o,s)){const a=G(i,s,!0);Object.keys(a).length&&(c[`[data-theme="${o.slice(1)}"] &`]=a);continue}if(/^[A-Z][A-Za-z0-9]*$/.test(o)){At()&&mt(o,s);continue}let e=o;if(o.charCodeAt(0)===64&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const a=s.context?.designSystem?.media?.[o.slice(1)];a&&(e=`@media ${a}`)}const r=G(i,s,!1);Object.keys(r).length&&(c[e]=r);continue}f(o,i)}}if(n)for(const o in c){const i=c[o];typeof i=="string"&&!i.includes("!important")&&(c[o]=i+" !important")}return c}function to(t){const s=t.__ref;s.__conditionalRunners=[];const n=new Map;for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;const f=c.charAt(0);if(f!=="."&&f!=="!")continue;const o=c.slice(1);if(!o)continue;const i=t[c];if(!i||typeof i!="object")continue;const e=f==="!",r={lastMatch:!1,appliedKeys:null,appliedClasses:null},a=()=>{if(!t.node)return;let l;const p=t[o];if(p===void 0)if(t.state&&o in t.state)l=t.state[o];else{const u=t.context?.cases?.[o];if(u===void 0)return;try{l=typeof u=="function"?u.call(t,t):u}catch(h){l=!1,s.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}}else if(typeof p=="function")try{l=p(t,t.state,t.context)}catch(u){l=!1,s.__conditionalError=u,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${c}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,u?.message||u)}else l=p;const y=e?!l:!!l;if(y===r.lastMatch)return;r.lastMatch=y;const _=t.context?.designSystem;_&&j(_);try{if(y){const u={},h={};let g=!1;for(const x in i){if(!Object.prototype.hasOwnProperty.call(i,x))continue;const b=i[x],v=x.charAt(0);if((v===":"||v==="@"||v==="&")&&b&&typeof b=="object"&&!Array.isArray(b)){if(dt(x,t)){const P=G(b,t,!0);Object.keys(P).length&&(h[`[data-theme="${x.slice(1)}"] &`]=P,g=!0)}else{let P=x;if(v==="@"&&!x.startsWith("@media")&&!x.startsWith("@keyframes")){const D=t.context?.designSystem?.media?.[x.slice(1)];D&&(P=`@media ${D}`)}const W=G(b,t,!1);Object.keys(W).length&&(h[P]=W,g=!0)}continue}const F=typeof b=="function"?b(t,t.state,t.context):b;if(F!=null)if($[x]){const P=$[x](F,t,t.state,t.context);if(P){const W=Array.isArray(P)?P:[P];for(const D of W)D&&Object.assign(u,D)}}else L&&L.has(x)&&(u[x]=F)}const C=Object.keys(u);if(C.length){Y(t.node,u);for(const x of C)n.set(x,c);r.appliedKeys=C}else r.appliedKeys=null;if(g){const x=rt(h,null,t.context?.cssPrefix),b=x?x.split(" ").filter(Boolean):[];if(b.length&&t.node.classList){for(const v of b)t.node.classList.add(v);r.appliedClasses=b}else r.appliedClasses=null}else if(r.appliedClasses){for(const x of r.appliedClasses)t.node.classList.remove(x);r.appliedClasses=null}}else{if(r.appliedKeys){for(const u of r.appliedKeys)n.get(u)===c&&(t.node.style[u]="",n.delete(u));r.appliedKeys=null}if(r.appliedClasses){for(const u of r.appliedClasses)t.node.classList.remove(u);r.appliedClasses=null}}}finally{_&&E()}};s.__conditionalRunners.push(a);const d=k(a,{depth:s.path.length});s.__effects.push(d)}}const ut=new WeakSet;function oo(t){const s=t.ownerDocument;!s||ut.has(s)||(ut.add(s),queueMicrotask(()=>{ut.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const pt=new WeakSet;let Dt=!1;function so(t){const{node:s}=t;if(!s)return;if(Dt||(Dt=!0,rt({display:"none"})),pt.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}pt.add(t);const n=t.context?.designSystem;n&&j(n);try{const c={};let f=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||U.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!B(o)){if($[o]){const e=t[o],r=$[o](e,t,t.state,t.context);if(r){if(Array.isArray(r))for(const a of r)a&&Object.assign(c,a);else Object.assign(c,r);f=!0}}else if(L&&L.has(o)){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charCodeAt(0)===45){const e=t[o];e!=null&&typeof e!="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="&"){const e=t[o];e&&typeof e=="object"&&(c[o]=e,f=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const e=t[o];if(e&&typeof e=="object"){if(dt(o,t)){const r=G(e,t,!0);Object.keys(r).length&&(c[`[data-theme="${o.slice(1)}"] &`]=r,f=!0)}else{let r=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const d=t.context?.designSystem?.media?.[o.slice(1)];d&&(r=`@media ${d}`)}const a=G(e,t,!1);Object.keys(a).length&&(c[r]=a,f=!0)}f=!0}}}}if(f){c.display&&String(c.display).includes("!important")&&(s.style.setProperty("display",String(c.display).replace(/\s*!important\s*$/,""),"important"),delete c.display);const o=rt(c,null,t.context?.cssPrefix);if(o&&s.classList){const e=o.split(" ").filter(Boolean);let r=!1;for(const a of e)s.classList.add(a),r||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(r=!0);r&&oo(s)}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const e=c.display;if(e&&e!==i)if(i==="none"){const r=[];for(const a of s.classList)a.startsWith("_d-")&&a!=="_d-none"&&r.push(a);for(const a of r)s.classList.remove(a);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&E(),pt.delete(t)}}function Tt(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const f in t.aria){const o=t.aria[f];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+f.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());s.setAttribute(i,o===!0?"":o)}const n=Wt(t);for(const f in n){const o=n[f];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(f,o===!0?"":o)}const c=t.tag||"div";for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||typeof t[f]=="function"||U.has(f)||f==="on"||n[f]!==void 0)continue;const o=f.charCodeAt(0);if(!(o>=65&&o<=90)&&!B(f)&&!($[f]||L&&L.has(f))&&it(c,f)){let i=t[f];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=ct(i,t,t.state,t.context),t[f]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;s.setAttribute(f,i===!0?"":i)}}}function no(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,c=n&&typeof n=="object"&&n.max?String(n.max):null;c&&(s.style.maxHeight=c);const f=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};f(),s.addEventListener("input",f),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",f)}catch{}})}const $t=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function Rt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!B(n)||$t.has(n))continue;let c=t[n];if(typeof c=="string"&&/^[A-Za-z_$][\w$]*$/.test(c)){const o=c;c=function(e){return t.call(o,e)}}if(typeof c!="function")continue;const f=Yt(n);It.has(f)||Kt(Gt(f),t,c)}co(t)}function co(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let c=!1;for(const p of $t){const y=t[p];typeof y=="function"&&(n[p]=y,c=!0)}if(!c)return;const f=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let i=0,e=0,r=0,a=!1;const d=p=>{const y=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];y&&(i=y.clientX,e=y.clientY,r=Date.now(),a=!0)},l=p=>{if(!a)return;a=!1;const y=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!y)return;const _=y.clientX-i,u=y.clientY-e,h=Date.now()-r;if(h>o)return;const g=Math.abs(_),C=Math.abs(u);if(Math.max(g,C)<f)return;let x;if(g>C*1.2)x=_<0?"left":"right";else if(C>g*1.2)x=u<0?"up":"down";else return;const b="onSwipe"+x.charAt(0).toUpperCase()+x.slice(1),v=n[b],F=n.onSwipe;v&&v.call(t,p,t,t.state,t.context),F&&F.call(t,{direction:x,dx:_,dy:u,dt:h,event:p},t,t.state,t.context)};s.addEventListener("touchstart",d,{passive:!0}),s.addEventListener("touchend",l,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",d)}catch{}try{s.removeEventListener("touchend",l)}catch{}})}function tt(t,s){const n={...t};for(const c in s){const f=n[c],o=s[c];f&&o&&typeof f=="object"&&typeof o=="object"&&!Array.isArray(f)&&!Array.isArray(o)&&typeof f!="function"&&typeof o!="function"?n[c]=tt(f,o):n[c]=o}return n}function lt(t,s,n){if(!s||!t.node)return;const c=t.childExtends;if(Array.isArray(s)){const f=t.tag==="fragment",o=t.context?.document||globalThis.document,i=f?null:o?.createDocumentFragment();if(!f&&!i)return;const e=t.childProps,r=t.childrenAs;for(let a=0;a<s.length;a++){let d=s[a];const l=d;(typeof d=="string"||typeof d=="number")&&(d={text:d});let p=e;if(typeof e=="function")try{p=e(t,d)}catch{p=null}if(r==="state"){let u=l;(typeof l=="string"||typeof l=="number")&&(u={value:l,text:l}),d=p?{...p,state:u}:{state:u}}else p&&(d=tt(p,d));if(c&&!d.ignoreChildExtends)if(d.extends){const u=Array.isArray(d.extends)?d.extends:[d.extends],h=Array.isArray(c)?c:[c];d={...d,extends:[...h,...u]}}else d={...d,extends:c};const y=d?.key||l&&typeof l=="object"&&l.key||`${a}`,_=H(d,t,y,n);!f&&_?.node&&i.appendChild(_.node)}f||t.node.appendChild(i);return}if(typeof s=="string"){const f=jt(s,t);if(Array.isArray(f)){lt(t,f,n);return}}if(typeof s=="object")for(const f in s){if(U.has(f))continue;let o=s[f];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=tt(t.childProps,o)),c&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],e=Array.isArray(c)?c:[c];o={...o,extends:[...e,...i]}}else o={...o,extends:c};H(o,t,f,n)}}}function yt(t,s){const n=t.node;if(!n||n.tagName!=="SELECT")return;const c=n.options;if(!c||!c.length)return;const f=t.__ref,o=f&&f.__exec&&f.__exec.value,i=typeof o=="function",e=t.value!=null&&typeof t.value!="function";if(i||e){let d;if(i)try{d=o(t,t.state,t.context)}catch{return}else d=t.value;const l=d==null?"":String(d);n.value!==l&&(n.value=l);return}const r=s||!(f&&f.__selectSynced);if(f&&(f.__selectSynced=!0),!r)return;let a=-1;for(let d=0;d<c.length;d++)c[d].defaultSelected&&(a=d);a>=0&&n.selectedIndex!==a&&(n.selectedIndex=a)}function Ft(t,s){let{children:n,content:c}=t;const f=t.childExtends;if(typeof n=="function"){const i=n;try{n=i(t,t.state,t.context)}catch(l){if(n=void 0,typeof console<"u"&&console.error){const p=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${p} (initial run, treating as empty):`,l?.message||l)}}t.children=n;const e=t.__ref;let r=!1;const a=w(t,t.childrenDeps,i),d=k(()=>{const l=r;r=!0;let p;try{p=a(t,t.state,t.context)}catch(b){if(typeof console<"u"&&console.error){const v=t.__ref?.path?.join(".")||t.key||"<root>";console.error(`[smbls] \`children:\` factory threw at ${v}${l?"":" (initial tracking run)"}:`,b?.message||b)}return}if(!l||p===t.children)return;t.children=p;const y=typeof t.onContentUpdate=="function",_=y?[]:null,u=y?[]:null,h=y?[]:null;if(Array.isArray(p)&&t.childrenAs==="state"){const b=t.childProps,v=[],F=new Map;for(let S=0;S<p.length;S++){const O=p[S];let A=b;if(typeof b=="function")try{A=b(t,O)}catch{A=null}const N=A&&A.key||O&&O.key||`${S}`;v.push(N),F.set(N,{rawChild:O,childProps:A})}const P=new Set(v),W=e.__children.slice();for(const S of W)if(!P.has(S)){const O=t[S];O?.remove&&O.remove(),delete t[S],u&&u.push(S)}const D=t.childExtends,X=t.tag==="fragment",Nt=t.context?.document||globalThis.document,Z=X?null:Nt?.createDocumentFragment();for(const S of v){const O=F.get(S),A=O.rawChild,N=t[S];if(N&&N.state){if(A&&typeof A=="object"){const T=N.state,J=T.$replace||T.replace,xt=T.$update||T.update;if(typeof J=="function")J.call(T,A);else if(typeof xt=="function"){for(const M in T)if(!(M==="__element"||M==="root"||M==="parent"||M==="update")&&!Object.prototype.hasOwnProperty.call(A,M))try{T[M]=void 0}catch{}xt.call(T,A)}else for(const M in A)T[M]=A[M]}h&&h.push(S);continue}let ot=A;(typeof A=="string"||typeof A=="number")&&(ot={value:A,text:A});const _t=O.childProps;let R=_t?{..._t,state:ot}:{state:ot};if(D&&!R.ignoreChildExtends)if(R.extends){const T=Array.isArray(R.extends)?R.extends:[R.extends],J=Array.isArray(D)?D:[D];R={...R,extends:[...J,...T]}}else R={...R,extends:D};const gt=H(R,t,S,s);!X&>?.node&&Z&&Z.appendChild(gt.node),_&&_.push(S)}if(!X&&Z&&Z.childNodes.length&&t.node&&t.node.appendChild(Z),!X&&t.node){let S=null;for(const O of v){const A=t[O]?.node;if(!A)continue;const N=S?S.nextSibling:t.node.firstChild;A!==N&&t.node.insertBefore(A,N),S=A}}e.__children=v,y&&(_.length||u.length)&&kt(t,{added:_,removed:u,kept:h}),yt(t,!1);return}const x=y?[...e.__children]:null;for(const b of[...e.__children]){const v=t[b];v?.remove&&v.remove(),delete t[b]}e.__children=[],lt(t,p,s),yt(t,!1),y&&kt(t,{added:[...e.__children],removed:x,kept:[]})},{depth:e.path.length});e.__effects.push(d)}if(lt(t,n||c,s),n||c)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let e=0;e<i.length;e++){const r=i[e];if(!r.endsWith("Extends")||typeof t[r]!="string")continue;const a=r.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const d={extends:t[r]};delete t[r];for(let l=e+1;l<i.length;l++){const p=i[l],y=p.charCodeAt(0);if(y>=65&&y<=90||U.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const _=t[p];_!==void 0&&(d[p]=_,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...d,...t[a]}:t[a]=d}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||U.has(i)||typeof t[i]!="object"||t[i]===null)continue;const e=i.charCodeAt(0);if(e<65||e>90)continue;let r=t[i];if(!r.__ref){if(!r.extends&&!r.extend){const a=o[i]||o[`smbls.${i}`];a&&(r={...r,extends:a})}if(t.childProps&&(r=tt(t.childProps,r)),f&&!r.ignoreChildExtends)if(r.extends){const a=Array.isArray(r.extends)?r.extends:[r.extends],d=Array.isArray(f)?f:[f];r={...r,extends:[...d,...a]}}else r={...r,extends:f};H(r,t,i,s)}}}function ht(t,s,n){const{node:c}=t;if(!c)return;c.ref=t;const f=s?.tag==="fragment"?s.__ref?.__fragmentAnchor:null;if(f){const i=f.parentNode;if(i){if(n?.position==="before"&&n.node)i.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const e=n.node.nextSibling;i.insertBefore(c,e||f)}else i.insertBefore(c,f);return}}const o=s?.node||(s?.nodeType?s:null);if(o)if(n?.position==="before"&&n.node)o.insertBefore(c,n.node);else if(n?.position==="after"&&n.node){const i=n.node.nextSibling;i?o.insertBefore(c,i):o.appendChild(c)}else o.appendChild(c)}function I(t,s,n){const c=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&V(c,s,n);const f="on"+t,o=s[f];if(typeof o=="function"){const i=t==="Render"||t==="RenderRouter";if(i){if(s.__ref.__inRender)return!0;s.__ref.__inRender=!0}const e=s.context?.designSystem;e&&j(e);try{if(o(s,s.state,s.context,n)===!1)return!1}catch(r){if(s.context?.plugins?.length&&V("error",s,{hook:f,error:r})||console.error(`[DOMQL] Lifecycle "${f}" error:`,r),s.context?.strictMode)throw r}finally{e&&E(),i&&(s.__ref.__inRender=!1)}}return!0}var jo=H;export{H as create,jo as default,vt as flushMounts};
|