UNPKG

11.4 kBJavaScriptView Raw
1!function(n,l){"object"==typeof exports&&"undefined"!=typeof module?l(exports):"function"==typeof define&&define.amd?define(["exports"],l):l((n||self).preact={})}(this,function(n){var l,u,t,i,o,e,f,r,c,s,a,h,d=65536,p=1<<17,v={},y=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function g(n,l){for(var u in l)n[u]=l[u];return n}function k(n){var l=n.parentNode;l&&l.removeChild(n)}function m(n,u,t){var i,o,e,f={};for(e in u)"key"==e?i=u[e]:"ref"==e?o=u[e]:f[e]=u[e];if(arguments.length>2&&(f.children=arguments.length>3?l.call(arguments,2):t),"function"==typeof n&&null!=n.defaultProps)for(e in n.defaultProps)void 0===f[e]&&(f[e]=n.defaultProps[e]);return w(n,f,i,o,null)}function w(n,l,i,o,e){var f={type:n,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==e?++t:e,__i:-1,__u:0};return null==e&&null!=u.vnode&&u.vnode(f),f}function x(n){return n.children}function C(n,l){this.props=n,this.context=l}function P(n,l){if(null==l)return n.__?P(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?P(n):null}function S(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return S(n)}}function T(n){(!n.__d&&(n.__d=!0)&&o.push(n)&&!$.__r++||e!==u.debounceRendering)&&((e=u.debounceRendering)||f)($)}function $(){var n,l,t,i,e,f,c,s;for(o.sort(r);n=o.shift();)n.__d&&(l=o.length,i=void 0,f=(e=(t=n).__v).__e,c=[],s=[],t.__P&&((i=g({},e)).__v=e.__v+1,u.vnode&&u.vnode(i),O(t.__P,i,e,t.__n,void 0!==t.__P.ownerSVGElement,32&e.__u?[f]:null,c,null==f?P(e):f,!!(32&e.__u),s),i.__v=e.__v,i.__.__k[i.__i]=i,z(c,i,s),i.__e!=f&&S(i)),o.length>l&&o.sort(r));$.__r=0}function I(n,l,u,t,i,o,e,f,r,c,s){var a,h,p,_,b,g=t&&t.__k||y,k=l.length;for(u.__d=r,H(u,l,g),r=u.__d,a=0;a<k;a++)null!=(p=u.__k[a])&&"boolean"!=typeof p&&"function"!=typeof p&&(h=-1===p.__i?v:g[p.__i]||v,p.__i=a,O(n,p,h,i,o,e,f,r,c,s),_=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&V(h.ref,null,p),s.push(p.ref,p.__c||_,p)),null==b&&null!=_&&(b=_),p.__u&d||h.__k===p.__k?(r&&!r.isConnected&&(r=P(h)),r=j(p,r,n)):"function"==typeof p.type&&void 0!==p.__d?r=p.__d:_&&(r=_.nextSibling),p.__d=void 0,p.__u&=-196609);u.__d=r,u.__e=b}function H(n,l,u){var t,i,o,e,f,r=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<r;t++)e=t+a,null!=(i=n.__k[t]=null==(i=l[t])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?w(null,i,null,null,null):b(i)?w(x,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?w(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=A(i,u,e,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=p)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=d)):f!==e&&(f===e+1?a++:f>e?s>r-e?a+=f-e:a--:f<e?f==e-1&&(a=f-e):a=0,f!==t+a&&(i.__u|=d))):(o=u[e])&&null==o.key&&o.__e&&0==(o.__u&p)&&(o.__e==n.__d&&(n.__d=P(o)),q(o,o,!1),u[e]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(o.__u&p)&&(o.__e==n.__d&&(n.__d=P(o)),q(o,o))}function j(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=j(t[i],l,u));return l}n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling}while(null!=l&&8===l.nodeType);return l}function A(n,l,u,t){var i=n.key,o=n.type,e=u-1,f=u+1,r=l[u];if(null===r||r&&i==r.key&&o===r.type&&0==(r.__u&p))return u;if(t>(null!=r&&0==(r.__u&p)?1:0))for(;e>=0||f<l.length;){if(e>=0){if((r=l[e])&&0==(r.__u&p)&&i==r.key&&o===r.type)return e;e--}if(f<l.length){if((r=l[f])&&0==(r.__u&p)&&i==r.key&&o===r.type)return f;f++}}return-1}function F(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||_.test(l)?u:u+"px"}function L(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||F(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||F(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/i,"$1")),l=l.toLowerCase()in n||"onFocusOut"===l||"onFocusIn"===l?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=c,n.addEventListener(l,o?a:s,o)):n.removeEventListener(l,o?a:s,o);else{if(i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=l&&"height"!=l&&"href"!=l&&"list"!=l&&"form"!=l&&"tabIndex"!=l&&"download"!=l&&"rowSpan"!=l&&"colSpan"!=l&&"role"!=l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u))}}function M(n){return function(l){if(this.l){var t=this.l[l.type+n];if(null==l.t)l.t=c++;else if(l.t<t.u)return;return t(u.event?u.event(l):l)}}}function O(n,l,t,i,o,e,f,r,c,s){var a,h,d,p,v,y,_,k,m,w,P,S,T,$,H,j=l.type;if(void 0!==l.constructor)return null;128&t.__u&&(c=!!(32&t.__u),e=[r=l.__e=t.__e]),(a=u.__b)&&a(l);n:if("function"==typeof j)try{if(k=l.props,m=(a=j.contextType)&&i[a.__c],w=a?m?m.props.value:a.__:i,t.__c?_=(h=l.__c=t.__c).__=h.__E:("prototype"in j&&j.prototype.render?l.__c=h=new j(k,w):(l.__c=h=new C(k,w),h.constructor=j,h.render=B),m&&m.sub(h),h.props=k,h.state||(h.state={}),h.context=w,h.__n=i,d=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=j.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=g({},h.__s)),g(h.__s,j.getDerivedStateFromProps(k,h.__s))),p=h.props,v=h.state,h.__v=l,d)null==j.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==j.getDerivedStateFromProps&&k!==p&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(k,w),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(k,h.__s,w)||l.__v===t.__v)){for(l.__v!==t.__v&&(h.props=k,h.state=h.__s,h.__d=!1),l.__e=t.__e,l.__k=t.__k,l.__k.forEach(function(n){n&&(n.__=l)}),P=0;P<h._sb.length;P++)h.__h.push(h._sb[P]);h._sb=[],h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(k,h.__s,w),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(p,v,y)})}if(h.context=w,h.props=k,h.__P=n,h.__e=!1,S=u.__r,T=0,"prototype"in j&&j.prototype.render){for(h.state=h.__s,h.__d=!1,S&&S(l),a=h.render(h.props,h.state,h.context),$=0;$<h._sb.length;$++)h.__h.push(h._sb[$]);h._sb=[]}else do{h.__d=!1,S&&S(l),a=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++T<25);h.state=h.__s,null!=h.getChildContext&&(i=g(g({},i),h.getChildContext())),d||null==h.getSnapshotBeforeUpdate||(y=h.getSnapshotBeforeUpdate(p,v)),I(n,b(H=null!=a&&a.type===x&&null==a.key?a.props.children:a)?H:[H],l,t,i,o,e,f,r,c,s),h.base=l.__e,l.__u&=-161,h.__h.length&&f.push(h),_&&(h.__E=h.__=null)}catch(n){l.__v=null,c||null!=e?(l.__e=r,l.__u|=c?160:32,e[e.indexOf(r)]=null):(l.__e=t.__e,l.__k=t.__k),u.__e(n,l,t)}else null==e&&l.__v===t.__v?(l.__k=t.__k,l.__e=t.__e):l.__e=N(t.__e,l,t,i,o,e,f,c,s);(a=u.diffed)&&a(l)}function z(n,l,t){l.__d=void 0;for(var i=0;i<t.length;i++)V(t[i],t[++i],t[++i]);u.__c&&u.__c(l,n),n.some(function(l){try{n=l.__h,l.__h=[],n.some(function(n){n.call(l)})}catch(n){u.__e(n,l.__v)}})}function N(n,u,t,i,o,e,f,r,c){var s,a,h,d,p,y,_,g=t.props,m=u.props,w=u.type;if("svg"===w&&(o=!0),null!=e)for(s=0;s<e.length;s++)if((p=e[s])&&"setAttribute"in p==!!w&&(w?p.localName===w:3===p.nodeType)){n=p,e[s]=null;break}if(null==n){if(null===w)return document.createTextNode(m);n=o?document.createElementNS("http://www.w3.org/2000/svg",w):document.createElement(w,m.is&&m),e=null,r=!1}if(null===w)g===m||r&&n.data===m||(n.data=m);else{if(e=e&&l.call(n.childNodes),g=t.props||v,!r&&null!=e)for(g={},s=0;s<n.attributes.length;s++)g[(p=n.attributes[s]).name]=p.value;for(s in g)if(p=g[s],"children"==s);else if("dangerouslySetInnerHTML"==s)h=p;else if("key"!==s&&!(s in m)){if("value"==s&&"defaultValue"in m||"checked"==s&&"defaultChecked"in m)continue;L(n,s,null,p,o)}for(s in m)p=m[s],"children"==s?d=p:"dangerouslySetInnerHTML"==s?a=p:"value"==s?y=p:"checked"==s?_=p:"key"===s||r&&"function"!=typeof p||g[s]===p||L(n,s,p,g[s],o);if(a)r||h&&(a.__html===h.__html||a.__html===n.innerHTML)||(n.innerHTML=a.__html),u.__k=[];else if(h&&(n.innerHTML=""),I(n,b(d)?d:[d],u,t,i,o&&"foreignObject"!==w,e,f,e?e[0]:t.__k&&P(t,0),r,c),null!=e)for(s=e.length;s--;)null!=e[s]&&k(e[s]);r||(s="value",void 0!==y&&(y!==n[s]||"progress"===w&&!y||"option"===w&&y!==g[s])&&L(n,s,y,g[s],!1),s="checked",void 0!==_&&_!==n[s]&&L(n,s,_,g[s],!1))}return n}function V(n,l,t){try{"function"==typeof n?n(l):n.current=l}catch(n){u.__e(n,t)}}function q(n,l,t){var i,o;if(u.unmount&&u.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||V(i,null,l)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){u.__e(n,l)}i.base=i.__P=null}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&q(i[o],l,t||"function"!=typeof n.type);t||null==n.__e||k(n.__e),n.__c=n.__=n.__e=n.__d=void 0}function B(n,l,u){return this.constructor(n,u)}function D(n,t,i){var o,e,f,r;u.__&&u.__(n,t),e=(o="function"==typeof i)?null:i&&i.__k||t.__k,f=[],r=[],O(t,n=(!o&&i||t).__k=m(x,null,[n]),e||v,v,void 0!==t.ownerSVGElement,!o&&i?[i]:e?null:t.firstChild?l.call(t.childNodes):null,f,!o&&i?i:e?e.__e:t.firstChild,o,r),z(f,n,r)}l=y.slice,u={__e:function(n,l,u,t){for(var i,o,e;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),e=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),e=i.__d),e)return i.__E=i}catch(l){n=l}throw n}},t=0,i=function(n){return null!=n&&null==n.constructor},C.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=g({},this.state),"function"==typeof n&&(n=n(g({},u),this.props)),n&&g(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),T(this))},C.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),T(this))},C.prototype.render=x,o=[],f="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,r=function(n,l){return n.__v.__b-l.__v.__b},$.__r=0,c=0,s=M(!1),a=M(!0),h=0,n.Component=C,n.Fragment=x,n.cloneElement=function(n,u,t){var i,o,e,f,r=g({},n.props);for(e in n.type&&n.type.defaultProps&&(f=n.type.defaultProps),u)"key"==e?i=u[e]:"ref"==e?o=u[e]:r[e]=void 0===u[e]&&void 0!==f?f[e]:u[e];return arguments.length>2&&(r.children=arguments.length>3?l.call(arguments,2):t),w(n.type,r,i||n.key,o||n.ref,null)},n.createContext=function(n,l){var u={__c:l="__cC"+h++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,T(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u},n.createElement=m,n.createRef=function(){return{current:null}},n.h=m,n.hydrate=function n(l,u){D(l,u,n)},n.isValidElement=i,n.options=u,n.render=D,n.toChildArray=function n(l,u){return u=u||[],null==l||"boolean"==typeof l||(b(l)?l.some(function(l){n(l,u)}):u.push(l)),u}});
2//# sourceMappingURL=preact.umd.js.map