import { createElement as v$1, Fragment as p$1, options as n$1 } from './preact.js';

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

export default h;
export { h as render, h as renderToStaticMarkup, h as renderToString, v as shallowRender };
//# sourceMappingURL=preact-render-to-string.js.map
