1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-04-06 05:35:54 +02:00
deka-dom-el/dist/iife.min.js
2025-03-10 16:35:09 +01:00

2 lines
8.8 KiB
JavaScript

var DDE=(()=>{var M=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})},ot=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of et(e))!nt.call(t,o)&&o!==n&&M(t,o,{get:()=>e[o],enumerable:!(r=tt(e,o))||r.enumerable});return t};var ct=t=>ot(M({},"__esModule",{value:!0}),t);var bt={};rt(bt,{assign:()=>L,assignAttribute:()=>W,chainableAppend:()=>G,classListDeclarative:()=>J,createElement:()=>P,createElementNS:()=>at,customElementRender:()=>gt,customElementWithDDE:()=>X,dispatchEvent:()=>ut,el:()=>P,elNS:()=>at,elementAttribute:()=>K,lifecyclesToEvents:()=>X,on:()=>S,queue:()=>ft,registerReactivity:()=>$,scope:()=>C,simulateSlots:()=>dt});function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function I(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function j(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var D={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function $(t,e=!0){return e?v(D,t):(Object.setPrototypeOf(t,D),t)}function R(t){return I(t,D)&&t!==D?t:D}var f={setDeleteAttr:st,ssr:"",D:globalThis.document,N:globalThis.Node,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function st(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,f.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var y="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",U="dde:attributeChanged";var O=f.M?it():new Proxy({},{get(){return()=>{}}});function it(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new f.M(n(a));return{observe(s){let u=new f.M(n(()=>{}));return u.observe(s,{childList:!0,subtree:!0}),()=>u.disconnect()},onConnected(s,u){d();let i=c(s);i.connected.has(u)||(i.connected.add(u),i.length_c+=1)},offConnected(s,u){if(!t.has(s))return;let i=t.get(s);i.connected.has(u)&&(i.connected.delete(u),i.length_c-=1,o(s,i))},onDisconnected(s,u){d();let i=c(s);i.disconnected.has(u)||(i.disconnected.add(u),i.length_d+=1)},offDisconnected(s,u){if(!t.has(s))return;let i=t.get(s);i.disconnected.delete(u),i.length_d-=1,o(s,i)}};function o(s,u){u.length_c||u.length_d||(t.delete(s),a())}function c(s){if(t.has(s))return t.get(s);let u={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(s,u),u}function d(){e||(e=!0,r.observe(f.D.body,{childList:!0,subtree:!0}))}function a(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(s){(requestIdleCallback||requestAnimationFrame)(s)})}async function b(s){t.size>30&&await p();let u=[];if(!g(s,f.N))return u;for(let i of t.keys())i===s||!g(i,f.N)||s.contains(i)&&u.push(i);return u}function l(s,u){let i=!1;for(let h of s){if(u&&b(h).then(l),!t.has(h))continue;let A=t.get(h);A.length_c&&(h.dispatchEvent(new Event(m)),A.connected=new WeakSet,A.length_c=0,A.length_d||t.delete(h),i=!0)}return i}function E(s,u){let i=!1;for(let h of s)u&&b(h).then(E),!(!t.has(h)||!t.get(h).length_d)&&((globalThis.queueMicrotask||setTimeout)(Y(h)),i=!0);return i}function Y(s){return()=>{s.isConnected||(s.dispatchEvent(new Event(_)),t.delete(s))}}}function ut(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let d=c.length?new CustomEvent(t,v({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(d)}}function S(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var H=t=>v({},typeof t=="object"?t:null,{once:!0});S.connected=function(t,e){return e=H(e),function(r){return r.addEventListener(m,t,e),r[y]?r:r.isConnected?(r.dispatchEvent(new Event(m)),r):(j(e.signal,()=>O.offConnected(r,t))&&O.onConnected(r,t),r)}};S.disconnected=function(t,e){return e=H(e),function(r){return r.addEventListener(_,t,e),r[y]||j(e.signal,()=>O.offDisconnected(r,t))&&O.onDisconnected(r,t),r}};function ft(t){return f.q(t)}var x=[{get scope(){return f.D.body},host:t=>t?t(f.D.body):f.D.body,prevent:!0}],k=new WeakMap,C={get current(){return x[x.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(k.has(t))return k.get(t);let e=new AbortController;return k.set(t,e),t(S.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function z(...t){return this.appendOriginal(...t),this}function G(t){return t.append===z||(t.appendOriginal=t.append,t.append=z),t}var T;function P(t,e,...n){let r=R(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let a=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;C.push({scope:t,host:a}),c=t(e||void 0);let p=g(c,f.F);if(c.nodeName==="#comment")break;let b=P.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=L.call(this,f.D.createTextNode(""),e);break;case(t==="<>"||!t):c=L.call(this,f.D.createDocumentFragment(),e);break;case!!T:c=L.call(this,f.D.createElementNS(T,t),e);break;case!c:c=L.call(this,f.D.createElement(t),e)}return G(c),d||(d=c),n.forEach(a=>a(d)),o&&C.pop(),o=2,c}P.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=f.D.createComment(`<dde:mark ${t}${f.ssr}${n}>`);return e&&(r.end=f.D.createComment("</dde:mark>")),r};function at(t){let e=this;return function(...r){T=t;let o=P.call(e,...r);return T=void 0,o}}function dt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,a){if(a[0]===e)return c.apply(t,a);for(let p of a){let b=(p.slot||"")+n;try{K(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:B}=f;function L(t,...e){if(!e.length)return t;N.set(t,V(t,this));for(let[n,r]of Object.entries(v({},...e)))W.call(this,t,n,r);return N.delete(t),t}function W(t,e,n){let{setRemoveAttr:r,s:o}=V(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(a,p)=>W.call(c,t,a,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return Z(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return B(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return q(o,e,t,n,Z.bind(null,t[e]));case"ariaset":return q(o,e,t,n,(a,p)=>r("aria-"+a,p));case"classList":return J.call(c,t,n)}return pt(t,e)?B(t,e,n):r(e,n)}function V(t,e){if(N.has(t))return N.get(t);let r=(g(t,f.S)?ht:lt).bind(null,t,"Attribute"),o=R(e);return{setRemoveAttr:r,s:o}}function J(t,e){let n=R(this);return q(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function K(t,e,n,r){return g(t,f.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function pt(t,e){if(!(e in t))return!1;let n=Q(t,e);return!w(n.set)}function Q(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Q(t,e)}function q(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([a,p]){a&&(a=new c(a),a.target=e,p=t.processReactiveAttribute(n,a,p,o),o(a,p))})}function lt(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function ht(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function Z(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}function gt(t,e,n={}){let r=t.host||t;C.push({scope:r,host:(...d)=>d.length?d.forEach(a=>a(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[y];o||X(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(m)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(_,O.observe(t),{once:!0}),C.pop(),t.append(c)}function X(t){return F(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(m))}),F(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(_)))}),F(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(U,{detail:[o,c]})),e.apply(n,r)}),t.prototype[y]=!0,t}function F(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}return ct(bt);})();