-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathesm.js
More file actions
5 lines (5 loc) · 10.4 KB
/
Copy pathesm.js
File metadata and controls
5 lines (5 loc) · 10.4 KB
1
2
3
4
5
function e(e){this.observe(e,{subtree:!0,childList:!0})}function t(e){e.type in this&&this[e.type](e)}let n=null,r=new Set;const s=e=>{const{$:t,r:n,h:r}=e;p(n)&&(l.get(r).delete(e),n()),p(e.r=t())&&l.get(r).add(e)},o=()=>{const e=r;r=new Set,e.forEach((({h:e,c:t,a:n,e:r})=>{r&&e.apply(t,n)}))},l=new WeakMap,c=[],a=[];function i(e,t){return e!==this[t]}const u=e=>{const t=l.get(e);t&&g.then((()=>{t.forEach((e=>{e.r(),e.r=null,e.d=!0})),t.clear()}))},d=()=>n,h=e=>l.has(e),p=e=>"function"==typeof e,f=e=>{const t={h:r,c:null,a:null,e:0,i:0,s:[]};return r;function r(){const r=n;n=t,t.e=t.i=0;try{return e.apply(t.c=this,t.a=arguments)}finally{n=r,c.length&&g.then(c.forEach.bind(c.splice(0),s)),a.length&&a.splice(0).forEach(s)}}},g=Promise.resolve(),m=e=>({_:new Set,provide:w,value:e}),y=({_:e,value:t})=>(e.add(d()),t);function w(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach((({h:e,c:t,a:n})=>{e.apply(t,n)})))}const v=(e,t)=>b((()=>e),t),b=(e,t)=>{const n=d(),{i:r,s:s}=n;return r!==s.length&&t&&!t.some(i,s[r]._)||(s[r]={$:e(),_:t}),s[n.i++].$},E=e=>(t,n)=>{const r=d(),{i:s,s:o,h:c}=r,a=s===o.length;r.i++,a&&(l.has(c)||l.set(c,new Set),o[s]={$:t,_:n,r:null,d:!1,h:c}),(a||!n||o[s].d||n.some(i,o[s]._))&&e.push(o[s]),o[s].$=t,o[s]._=n,o[s].d=!1},x=E(c),k=E(a),N=(e,t)=>p(t)?t(e):t,$=(e,t,n)=>{const s=d(),{i:l,s:c}=s;l===c.length&&c.push({$:p(n)?n(t):N(void 0,t),set:t=>{c[l].$=e(c[l].$,t),(e=>{r.has(e)||(e.e=1,r.add(e),g.then(o))})(s)}});const{$:a,set:i}=c[s.i++];return[a,i]},C=e=>{const t=d(),{i:n,s:r}=t;return n===r.length&&r.push({current:e}),r[t.i++]};
/*! (c) Andrea Giammarchi - ISC */
let A=null,M=null,S=null;const T=new WeakMap,_=new WeakMap,O=(e,t,n,r)=>{const s=s=>{T.has(e)||(T.set(e,0),g.then((()=>{T.delete(e),e.apply(t,n)}))),r(s)};return _.set(r,s),s},L=(e,t,n,r)=>e?[r[0],_.get(r[1])||O(e,t,n,r[1])]:r,W=(e,t)=>{const n=f(t?function(){const[t,r,s]=[A,M,S];[A,M,S]=[n,this,arguments];try{return e.apply(M,S)}finally{[A,M,S]=[t,r,s]}}:e);return n},j=(e,t,n)=>L(A,M,S,$(e,t,n)),B=e=>L(A,M,S,(e=>$(N,e))(e))
/*! (c) Andrea Giammarchi - ISC */,D=((n,r,s,o)=>{const l=new WeakMap,c=new WeakMap,a=new WeakMap,i=e=>l.has(e),u=e=>{i(e)&&(d(e,e.removeEventListener,l.get(e)),l.delete(e))},d=(e,t,n)=>{t.call(e,"disconnected",n),t.call(e,"connected",n)},h=(e,t,n,r)=>{for(let{length:s}=e,o=0;o<s;o++)p(e[o],t,n,r)},p=(e,t,n,o)=>{i(e)&&!n.has(e)&&(o.delete(e),n.set(e,0),e.dispatchEvent(new(s||CustomEvent)(t))),h(e[r||"children"]||[],t,n,o)},f=new(o||MutationObserver)((e=>{for(let{length:t}=e,n=0;n<t;n++){const{removedNodes:t,addedNodes:r}=e[n];h(t,"disconnected",a,c),h(r,"connected",c,a)}}));f.add=e,f.add(n||document);const{attachShadow:g}=Element.prototype;return g&&(Element.prototype.attachShadow=function(e){const t=g.call(this,e);return f.add(t),t}),{has:i,connect:(e,n)=>{u(e),(n||(n={})).handleEvent||(n.handleEvent=t),d(e,e.addEventListener,n),l.set(e,n)},disconnect:u,kill(){f.disconnect()}}})(document,"children",CustomEvent),z=({firstChild:e})=>{if(e&&1!==e.nodeType&&!(e=e.nextElementSibling))throw"unobservable";return e},H=e=>{const{nodeType:t}=e;if(t)return 1===t?e:z(e);{const t=e.valueOf();return t!==e?H(t):z(t)}},P=(e,t)=>{const n=W(e,t);return function(){const e=n.apply(this,arguments);if(h(n)){const t=H(e);D.has(t)||D.connect(t,{disconnected(){u(n)}})}return e}};var R=e=>({get:t=>e.get(t),set:(t,n)=>(e.set(t,n),n)});const{isArray:F}=Array;class q extends Map{set(e,t){return super.set(e,t),t}}class G extends WeakMap{set(e,t){return super.set(e,t),t}}
/*! (c) Andrea Giammarchi - ISC */const I=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,J=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g,K=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,Q=/[\x01\x02]/g;const U=(e,t)=>111===e.nodeType?1/t<0?t?(({firstChild:e,lastChild:t})=>{const n=document.createRange();return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e})(e):e.lastChild:t?e.valueOf():e.firstChild:e,V=(e,t)=>{let n,r,s=t.slice(2);return!(t in e)&&(r=t.toLowerCase())in e&&(s=r.slice(2)),t=>{const r=F(t)?t:[t,!1];n!==r[0]&&(n&&e.removeEventListener(s,n,r[1]),(n=r[0])&&e.addEventListener(s,n,r[1]))}};const{isArray:X,prototype:Y}=Array,{indexOf:Z}=Y,{createDocumentFragment:ee,createElement:te,createElementNS:ne,createTextNode:re,createTreeWalker:se,importNode:oe}=new Proxy(document,{get:(e,t)=>e[t].bind(e)});let le;const ce=(e,t)=>t?(e=>{le||(le=ne("http://www.w3.org/2000/svg","svg")),le.innerHTML=e;const t=ee();return t.append(...le.childNodes),t})(e):(e=>{const t=te("template");return t.innerHTML=e,t.content})(e),ae=({childNodes:e},t)=>e[t],ie=(e,t,n)=>((e,t,n,r,s)=>{const o=n.length;let l=t.length,c=o,a=0,i=0,u=null;for(;a<l||i<c;)if(l===a){const t=c<o?i?r(n[i-1],-0).nextSibling:r(n[c-i],0):s;for(;i<c;)e.insertBefore(r(n[i++],1),t)}else if(c===i)for(;a<l;)u&&u.has(t[a])||e.removeChild(r(t[a],-1)),a++;else if(t[a]===n[i])a++,i++;else if(t[l-1]===n[c-1])l--,c--;else if(t[a]===n[c-1]&&n[i]===t[l-1]){const s=r(t[--l],-1).nextSibling;e.insertBefore(r(n[i++],1),r(t[a++],-1).nextSibling),e.insertBefore(r(n[--c],1),s),t[l]=n[c]}else{if(!u){u=new Map;let e=i;for(;e<c;)u.set(n[e],e++)}if(u.has(t[a])){const s=u.get(t[a]);if(i<s&&s<c){let o=a,d=1;for(;++o<l&&o<c&&u.get(t[o])===s+d;)d++;if(d>s-i){const o=r(t[a],0);for(;i<s;)e.insertBefore(r(n[i++],1),o)}else e.replaceChild(r(n[i++],1),r(t[a++],-1))}else a++}else e.removeChild(r(t[a++],-1))}return n})(e.parentNode,t,n,U,e),ue=(e,t)=>{switch(t[0]){case"?":return((e,t,n)=>r=>{n!==!!r&&((n=!!r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const r=t[n];null==r?delete e[n]:e[n]=r}})(e):n=>{e[t]=n})(e,t.slice(1));case"@":return V(e,"on"+t.slice(1));case"o":if("n"===t[1])return V(e,t)}switch(t){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(e);case"aria":return(e=>t=>{for(const n in t){const r="role"===n?n:`aria-${n}`,s=t[n];null==s?e.removeAttribute(r):e.setAttribute(r,s)}})(e)}return((e,t)=>{let n,r=!0;const s=document.createAttributeNS(null,t);return t=>{if(n!==t)if(n=t,null==n)r||(e.removeAttributeNode(s),r=!0);else{const n=t;null==n?(r||e.removeAttributeNode(s),r=!0):(s.value=n,r&&(e.setAttributeNodeNS(s),r=!1))}}})(e,t)};function de(e){const{type:t,path:n}=e,r=n.reduceRight(ae,this);return"node"===t?(e=>{let t,n,r=[];const s=o=>{switch(typeof o){case"string":case"number":case"boolean":t!==o&&(t=o,n||(n=re("")),n.data=o,r=ie(e,r,[n]));break;case"object":case"undefined":if(null==o){t!=o&&(t=o,r=ie(e,r,[]));break}if(X(o)){t=o,0===o.length?r=ie(e,r,[]):"object"==typeof o[0]?r=ie(e,r,o):s(String(o));break}t!==o&&"ELEMENT_NODE"in o&&(t=o,r=ie(e,r,11===o.nodeType?[...o.childNodes]:[o]));break;case"function":s(o(e))}};return s})(r):"attr"===t?ue(r,e.name):(e=>{let t;return n=>{t!=n&&(t=n,e.textContent=null==n?"":n)}})(r)}const he=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(Z.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},pe=new G,fe=/^(?:textarea|script|style|title|plaintext|xmp)$/,ge=(e,t)=>{const n="svg"===e,r=((e,t,n)=>{let r=0;return e.join("").trim().replace(J,((e,t,r,s)=>{let o=t+r.replace(K,"=$2$1").trimEnd();return s.length&&(o+=n||I.test(t)?" /":"></"+t),"<"+o+">"})).replace(Q,(e=>""===e?"\x3c!--"+t+r+++"--\x3e":t+r++))})(t,"isµ",n),s=ce(r,n),o=se(s,129),l=[],c=t.length-1;let a=0,i=`isµ${a}`;for(;a<c;){const e=o.nextNode();if(!e)throw`bad template: ${r}`;if(8===e.nodeType)e.data===i&&(l.push({type:"node",path:he(e)}),i="isµ"+ ++a);else{for(;e.hasAttribute(i);)l.push({type:"attr",path:he(e),name:e.getAttribute(i)}),e.removeAttribute(i),i="isµ"+ ++a;fe.test(e.localName)&&e.textContent.trim()===`\x3c!--${i}--\x3e`&&(e.textContent="",l.push({type:"text",path:he(e)}),i="isµ"+ ++a)}}return{content:s,nodes:l}},me=(e,t)=>{const{content:n,nodes:r}=pe.get(t)||pe.set(t,ge(e,t)),s=oe(n,!0);return{content:s,updates:r.map(de,s)}},ye=(e,{type:t,template:n,values:r})=>{const s=we(e,r);let{entry:o}=e;o&&o.template===n&&o.type===t||(e.entry=o=((e,t)=>{const{content:n,updates:r}=me(e,t);return{type:e,template:t,content:n,updates:r,wire:null}})(t,n));const{content:l,updates:c,wire:a}=o;for(let e=0;e<s;e++)c[e](r[e]);return a||(o.wire=(e=>{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:r}=e,s=[...r];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(r.length!==s.length&&e.append(...s),e)}})(l))},we=({stack:e},t)=>{const{length:n}=t;for(let r=0;r<n;r++){const n=t[r];n instanceof ve?t[r]=ye(e[r]||(e[r]={stack:[],entry:null,wire:null}),n):X(n)?we(e[r]||(e[r]={stack:[],entry:null,wire:null}),n):e[r]=null}return n<e.length&&e.splice(n),n};class ve{constructor(e,t,n){this.type=e,this.template=t,this.values=n}}const be=e=>{const t=new G;return Object.assign(((t,...n)=>new ve(e,t,n)),{for(n,r){const s=t.get(n)||t.set(n,new q);return s.get(r)||s.set(r,(t=>(n,...r)=>ye(t,{type:e,template:n,values:r}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>ye({stack:[],entry:null,wire:null},new ve(e,t,n)).valueOf()})},Ee=new G,xe=be("html"),ke=be("svg"),{create:Ne}=Object,$e=(e,...t)=>new ve("html",e,t);$e.for=De(xe);const Ce=(e,...t)=>new ve("svg",e,t);Ce.for=De(ke);const Ae=R(new WeakMap),Me=(e,t)=>(Ae.get(e)||Ae.set(e,{c:Te(),h:P((function(t){const n="function"==typeof t?t():t;return((e,t)=>{const n="function"==typeof t?t():t,r=Ee.get(e)||Ee.set(e,{stack:[],entry:null,wire:null}),s=n instanceof ve?ye(r,n):n;return s!==r.wire&&(r.wire=s,e.replaceChildren(s.valueOf())),e})(e,n instanceof Be?_e(this.c,n):(Oe(this.c,n),n))}),e)})).h(t),Se=(e,t)=>P((function(){const n=t.f.apply(this,arguments);return n instanceof ve?(Oe(e,n),t.$=We(t,n)):t.$=n,t.$})),Te=()=>({s:[],e:null}),_e=(e,{f:t,c:n,a:r})=>{let{e:s}=e;return s&&s.f===t||(e.e=s={f:t,h:null,$:null},s.h=Se(Te(),s)),s.h.apply(n,r)},Oe=(e,{values:t})=>{Le(e,t)},Le=(e,t)=>{const{s:n}=e,{length:r}=t;for(let e=0;e<r;e++){const r=t[e];r instanceof Be?t[e]=_e(n[e]||(n[e]=Te()),r):r instanceof ve?Oe(n[e]||(n[e]=Te()),r):F(r)?Le(n[e]||(n[e]=Te()),r):n[e]=null}r<n.length&&n.splice(r)},We=(e,{type:t,template:n,values:r})=>("svg"===t?ke:xe).for(e,t)(n,...r);function je(e){return function(){return new Be(e,this,arguments)}}function Be(e,t,n){this.f=e,this.c=t,this.a=n}function De(e){const t=R(new WeakMap);return(n,r)=>{const s=t.get(n)||t.set(n,Ne(null)),o=s[r]||(s[r]=Te());return(t,...s)=>(Le(o,s),e.for(n,r)(t,...s))}}export{je as Component,m as createContext,$e as html,Me as render,Ce as svg,v as useCallback,y as useContext,x as useEffect,k as useLayoutEffect,b as useMemo,j as useReducer,C as useRef,B as useState};