+import{Fragment as e,options as t}from"preact";var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,o=/[\s\n\\/='"\0<>]/,a=/^xlink:?./,i=/["&<]/;function l(e){if(!1===i.test(e+=""))return e;for(var t=0,r=0,n="",o="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:o=""";break;case 38:o="&";break;case 60:o="<";break;default:continue}r!==t&&(n+=e.slice(t,r)),n+=o,t=r+1}return r!==t&&(n+=e.slice(t,r)),n}var s=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},f=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},c={},u=/([A-Z])/g;function p(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:c[n]||(c[n]=n.replace(u,"-$1").toLowerCase()),t="number"==typeof o&&!1===r.test(n)?t+": "+o+"px;":t+": "+o+";")}return t||void 0}function _(e,t){return Array.isArray(t)?t.reduce(_,e):null!=t&&!1!==t&&e.push(t),e}function d(){this.__d=!0}function v(e,t){return{__v:e,context:t,props:e.props,setState:d,forceUpdate:d,__d:!0,__h:[]}}function h(e,t){var r=e.contextType,n=r&&t[r.__c];return null!=r?n?n.props.value:r.__:t}var g=/^(acceptC|httpE|(clip|color|fill|font|glyph|marker|stop|stroke|text|vert)[A-Z])/,y=/^(isP|viewB)/,m=/^(xlink|xml|xmlns)[A-Z]/,x=/([A-Z])/g;function b(e){return y.test(e)?e:g.test(e)?e.replace(x,"-$1").toLowerCase():m.test(e)?e.replace(x,":$1").toLowerCase():e.toLowerCase()}var k=[];function w(r,i,c,u,d,g){if(null==r||"boolean"==typeof r)return"";if("object"!=typeof r)return l(r);var y=c.pretty,m=y&&"string"==typeof y?y:"\t";if(Array.isArray(r)){for(var x="",S=0;S<r.length;S++)y&&S>0&&(x+="\n"),x+=w(r[S],i,c,u,d,g);return x}var C,A=r.type,O=r.props,j=!1;if("function"==typeof A){if(j=!0,!c.shallow||!u&&!1!==c.renderRootComponent){if(A===e){var L=[];return _(L,r.props.children),w(L,i,c,!1!==c.shallowHighOrder,d,g)}var F,H=r.__c=v(r,i);t.__b&&t.__b(r);var M=t.__r;if(A.prototype&&"function"==typeof A.prototype.render){var $=h(A,i);(H=r.__c=new A(O,$)).__v=r,H._dirty=H.__d=!0,H.props=O,null==H.state&&(H.state={}),null==H._nextState&&null==H.__s&&(H._nextState=H.__s=H.state),H.context=$,A.getDerivedStateFromProps?H.state=Object.assign({},H.state,A.getDerivedStateFromProps(H.props,H.state)):H.componentWillMount&&(H.componentWillMount(),H.state=H._nextState!==H.state?H._nextState:H.__s!==H.state?H.__s:H.state),M&&M(r),F=H.render(H.props,H.state,H.context)}else for(var E=h(A,i),T=0;H.__d&&T++<25;)H.__d=!1,M&&M(r),F=A.call(r.__c,O,E);return H.getChildContext&&(i=Object.assign({},i,H.getChildContext())),t.diffed&&t.diffed(r),w(F,i,c,!1!==c.shallowHighOrder,d,g)}A=(C=A).displayName||C!==Function&&C.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=k.length;n--;)if(k[n]===e){r=n;break}r<0&&(r=k.push(e)-1),t="UnnamedComponent"+r}return t}(C)}var P,D,N="<"+A;if(O){var W=Object.keys(O);c&&!0===c.sortAttributes&&W.sort();for(var Z=0;Z<W.length;Z++){var I=W[Z],R=O[I];if("children"!==I){if(!o.test(I)&&(c&&c.allAttributes||"key"!==I&&"ref"!==I&&"__self"!==I&&"__source"!==I)){if("defaultValue"===I)I="value";else if("defaultChecked"===I)I="checked";else if("defaultSelected"===I)I="selected";else if("className"===I){if(void 0!==O.class)continue;I="class"}else d&&a.test(I)&&(I=I.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===I){if(O.for)continue;I="for"}"style"===I&&R&&"object"==typeof R&&(R=p(R)),"a"===I[0]&&"r"===I[1]&&"boolean"==typeof R&&(R=String(R));var U=c.attributeHook&&c.attributeHook(I,R,i,c,j);if(U||""===U)N+=U;else if("dangerouslySetInnerHTML"===I)D=R&&R.__html;else if("textarea"===A&&"value"===I)P=R;else if((R||0===R||""===R)&&"function"!=typeof R){if(I=b(I),!(!0!==R&&""!==R||(R=I,c&&c.xml))){N=N+" "+I;continue}if("value"===I){if("select"===A){g=R;continue}"option"===A&&g==R&&void 0===O.selected&&(N+=" selected")}N=N+" "+I+'="'+l(R)+'"'}}}else P=R}}if(y){var V=N.replace(/\n\s*/," ");V===N||~V.indexOf("\n")?y&&~N.indexOf("\n")&&(N+="\n"):N=V}if(N+=">",o.test(A))throw new Error(A+" is not a valid HTML tag name in "+N);var q,z=n.test(A)||c.voidElements&&c.voidElements.test(A),B=[];if(D)y&&f(D)&&(D="\n"+m+s(D,m)),N+=D;else if(null!=P&&_(q=[],P).length){for(var G=y&&~N.indexOf("\n"),J=!1,K=0;K<q.length;K++){var Q=q[K];if(null!=Q&&!1!==Q){var X=w(Q,i,c,!0,"svg"===A||"foreignObject"!==A&&d,g);if(y&&!G&&f(X)&&(G=!0),X)if(y){var Y=X.length>0&&"<"!=X[0];J&&Y?B[B.length-1]+=X:B.push(X),J=Y}else B.push(X)}}if(y&&G)for(var ee=B.length;ee--;)B[ee]="\n"+m+s(B[ee],m)}if(B.length||D)N+=B.join("");else if(c&&c.xml)return N.substring(0,N.length-1)+" />";return!z||q||D?(y&&~N.indexOf("\n")&&(N+="\n"),N=N+"</"+A+">"):N=N.replace(/>$/," />"),N}var S={shallow:!0};O.render=O;var C=function(e,t){return O(e,t,S)},A=[];function O(e,r,n){r=r||{};var o,a=t.__s;return t.__s=!0,o=n&&(n.pretty||n.voidElements||n.sortAttributes||n.shallow||n.allAttributes||n.xml||n.attributeHook)?w(e,r,n):M(e,r,!1,void 0),t.__c&&t.__c(e,A),t.__s=a,A.length=0,o}function j(e,t){return"className"===e?"class":"htmlFor"===e?"for":"defaultValue"===e?"value":"defaultChecked"===e?"checked":"defaultSelected"===e?"selected":t&&a.test(e)?e.toLowerCase().replace(/^xlink:?/,"xlink:"):e}function L(e,t){return"style"===e&&null!=t&&"object"==typeof t?p(t):"a"===e[0]&&"r"===e[1]&&"boolean"==typeof t?String(t):t}var F=Array.isArray,H=Object.assign;function M(r,a,i,s){if(null==r||!0===r||!1===r||""===r)return"";if("object"!=typeof r)return l(r);if(F(r)){for(var f="",c=0;c<r.length;c++)f+=M(r[c],a,i,s);return f}var u=r.type,p=r.props;if("function"==typeof u){if(u===e)return M(r.props.children,a,i,s);var _;t.__b&&t.__b(r),_=u.prototype&&"function"==typeof u.prototype.render?function(e,r){var n=e.type,o=h(n,r),a=new n(e.props,o);e.__c=a,a.__v=e,a.__d=!0,a.props=e.props,null==a.state&&(a.state={}),null==a.__s&&(a.__s=a.state),a.context=o,n.getDerivedStateFromProps?a.state=H({},a.state,n.getDerivedStateFromProps(a.props,a.state)):a.componentWillMount&&(a.componentWillMount(),a.state=a.__s!==a.state?a.__s:a.state);var i=t.__r;return i&&i(e),a.render(a.props,a.state,a.context)}(r,a):function(e,r){var n,o=v(e,r),a=h(e.type,r);e.__c=o;for(var i=t.__r,l=0;o.__d&&l++<25;)o.__d=!1,i&&i(e),n=e.type.call(o,e.props,a);return n}(r,a);var d=r.__c;return d.getChildContext&&(a=H({},a,d.getChildContext())),t.diffed&&t.diffed(r),M(_,a,i,s)}var g,y,m="<";if(m+=u,p)for(var x in g=p.children,p){var k=p[x];if(!("key"===x||"ref"===x||"__self"===x||"__source"===x||"children"===x||"className"===x&&"class"in p||"htmlFor"===x&&"for"in p||o.test(x)))if(k=L(x=j(x,i),k),"dangerouslySetInnerHTML"===x)y=k&&k.__html;else if("textarea"===u&&"value"===x)g=k;else if((k||0===k||""===k)&&"function"!=typeof k){if(x=b(x),!0===k||""===k){k=x,m=m+" "+x;continue}if("value"===x){if("select"===u){s=k;continue}"option"!==u||s!=k||"selected"in p||(m+=" selected")}m=m+" "+x+'="'+l(k)+'"'}}var w=m;if(m+=">",o.test(u))throw new Error(u+" is not a valid HTML tag name in "+m);var S="",C=!1;if(y)S+=y,C=!0;else if("string"==typeof g)S+=l(g),C=!0;else if(F(g))for(var A=0;A<g.length;A++){var O=g[A];if(null!=O&&!1!==O){var $=M(O,a,"svg"===u||"foreignObject"!==u&&i,s);$&&(S+=$,C=!0)}}else if(null!=g&&!1!==g&&!0!==g){var E=M(g,a,"svg"===u||"foreignObject"!==u&&i,s);E&&(S+=E,C=!0)}if(C)m+=S;else if(n.test(u))return w+" />";return m+"</"+u+">"}O.shallowRender=C;export default O;export{O as render,O as renderToStaticMarkup,O as renderToString,C as shallowRender};
0 commit comments