styled-components 6.0.0-beta.1 → 6.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/constructors/constructWithOptions.d.ts +16 -21
  2. package/dist/constructors/css.d.ts +2 -2
  3. package/dist/constructors/styled.d.ts +179 -179
  4. package/dist/models/StyledComponent.d.ts +1 -1
  5. package/dist/models/StyledNativeComponent.d.ts +2 -2
  6. package/dist/native/index.d.ts +29 -29
  7. package/dist/styled-components-macro.cjs.js +47 -1
  8. package/dist/styled-components-macro.cjs.js.map +1 -1
  9. package/dist/styled-components-macro.esm.js +38 -1
  10. package/dist/styled-components-macro.esm.js.map +1 -1
  11. package/dist/styled-components.browser.cjs.js +1854 -1
  12. package/dist/styled-components.browser.cjs.js.map +1 -1
  13. package/dist/styled-components.browser.esm.js +1829 -1
  14. package/dist/styled-components.browser.esm.js.map +1 -1
  15. package/dist/styled-components.cjs.js +1874 -1
  16. package/dist/styled-components.cjs.js.map +1 -1
  17. package/dist/styled-components.esm.js +1849 -1
  18. package/dist/styled-components.esm.js.map +1 -1
  19. package/dist/styled-components.js +2074 -1
  20. package/dist/styled-components.js.map +1 -1
  21. package/dist/styled-components.min.js +1 -1
  22. package/dist/styled-components.min.js.map +1 -1
  23. package/dist/test/utils.d.ts +178 -178
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/types.d.ts +32 -43
  26. package/dist/utils/generateDisplayName.d.ts +1 -1
  27. package/dist/utils/getComponentName.d.ts +1 -1
  28. package/dist/utils/isStyledComponent.d.ts +1 -1
  29. package/dist/utils/isTag.d.ts +1 -1
  30. package/native/dist/constructors/constructWithOptions.d.ts +16 -21
  31. package/native/dist/constructors/css.d.ts +2 -2
  32. package/native/dist/constructors/styled.d.ts +179 -179
  33. package/native/dist/models/StyledComponent.d.ts +1 -1
  34. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  35. package/native/dist/native/index.d.ts +29 -29
  36. package/native/dist/styled-components.native.cjs.js +6 -10
  37. package/native/dist/styled-components.native.cjs.js.map +1 -1
  38. package/native/dist/styled-components.native.esm.js +6 -10
  39. package/native/dist/styled-components.native.esm.js.map +1 -1
  40. package/native/dist/test/utils.d.ts +178 -178
  41. package/native/dist/types.d.ts +32 -43
  42. package/native/dist/utils/generateDisplayName.d.ts +1 -1
  43. package/native/dist/utils/getComponentName.d.ts +1 -1
  44. package/native/dist/utils/isStyledComponent.d.ts +1 -1
  45. package/native/dist/utils/isTag.d.ts +1 -1
  46. package/package.json +1 -2
@@ -1,2 +1,1830 @@
1
- import{__spreadArray as e,__assign as t,__rest as n}from"tslib";import o from"@emotion/is-prop-valid";import r,{useRef as i,useState as s,useContext as a,useMemo as c,useEffect as u,createElement as l,useDebugValue as p}from"react";import d from"shallowequal";import{prefixer as h,stringify as f,middleware as m,compile as y,RULESET as v}from"stylis";import g from"@emotion/unitless";var S="undefined"!=typeof process&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",w="6.0.0-beta.1",b="undefined"!=typeof window&&"HTMLElement"in window,E=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),N={},_=/invalid hook call/i,C=new Set,A=function(t,n){if("production"!==process.env.NODE_ENV){var o=n?' with the id of "'.concat(n,'"'):"",r="The component ".concat(t).concat(o," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.",s=console.error;try{var a=!0;console.error=function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];_.test(t)?(a=!1,C.delete(r)):s.apply(void 0,e([t],n,!1))},i(),a&&!C.has(r)&&(console.warn(r),C.add(r))}catch(e){_.test(e.message)&&C.delete(r)}finally{console.error=s}}},P=Object.freeze([]),I=Object.freeze({});function O(e,t,n){return void 0===n&&(n=I),e.theme!==n.theme&&e.theme||t||n.theme}var D=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],R=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,j=/(^-|-$)/g;function T(e){return e.replace(R,"-").replace(j,"")}var x=/(a)(d)/gi,k=function(e){return String.fromCharCode(e+(e>25?39:97))};function V(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=k(t%52)+n;return(k(t%52)+n).replace(x,"$1-$2")}var B,$=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},z=function(e){return $(5381,e)};function M(e){return V(z(e)>>>0)}function L(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function F(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var G="function"==typeof Symbol&&Symbol.for,Y=G?Symbol.for("react.memo"):60115,q=G?Symbol.for("react.forward_ref"):60112,H={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},W={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},U={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},J=((B={})[q]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},B[Y]=U,B);function X(e){return("type"in(t=e)&&t.type.$$typeof)===Y?U:"$$typeof"in e?J[e.$$typeof]:H;var t}var Z=Object.defineProperty,K=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,ee=Object.getOwnPropertyDescriptor,te=Object.getPrototypeOf,ne=Object.prototype;function oe(e,t,n){if("string"!=typeof t){if(ne){var o=te(t);o&&o!==ne&&oe(e,o,n)}var r=K(t);Q&&(r=r.concat(Q(t)));for(var i=X(e),s=X(t),a=0;a<r.length;++a){var c=r[a];if(!(c in W||n&&n[c]||s&&c in s||i&&c in i)){var u=ee(t,c);try{Z(e,c,u)}catch(e){}}}}return e}function re(e){return"object"==typeof e&&"styledComponentId"in e}function ie(e){return!(null===e||"object"!=typeof e||e.constructor&&"Object"!==e.constructor.name||"[object Object]"!==(e.toString?e.toString():Object.prototype.toString.call(e))||"props"in e&&(e.$$typeof||void 0===e.constructor))}function se(e,t,n){if(void 0===n&&(n=!1),!n&&!ie(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var o=0;o<t.length;o++)e[o]=se(e[o],t[o]);else if(ie(t))for(var o in t)e[o]=se(e[o],t[o]);return e}var ae="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n"}:{};function ce(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],o=[],r=1,i=e.length;r<i;r+=1)o.push(e[r]);return o.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function ue(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(n.length>0?" Args: ".concat(n.join(", ")):"")):new Error(ce.apply(void 0,e([ae[t]],n,!1)).trim())}var le=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,o=n.length,r=o;e>=r;)if((r<<=1)<0)throw ue(16,"".concat(e));this.groupSizes=new Uint32Array(r),this.groupSizes.set(n),this.length=r;for(var i=o;i<r;i++)this.groupSizes[i]=0}var s=this.indexOfGroup(e+1);if(Array.isArray(t)){i=0;for(var a=t.length;i<a;i++)this.tag.insertRule(s,t[i])&&(this.groupSizes[e]++,s++)}else this.tag.insertRule(s,t)&&this.groupSizes[e]++},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),o=n+t;this.groupSizes[e]=0;for(var r=n;r<o;r++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],o=this.indexOfGroup(e),r=o+n,i=o;i<r;i++)t+="".concat(this.tag.getRule(i)).concat("/*!sc*/\n");return t},e}(),pe=new Map,de=new Map,he=1,fe=function(e){if(pe.has(e))return pe.get(e);for(;de.has(he);)he++;var t=he++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>1073741824))throw ue(16,"".concat(t));return pe.set(e,t),de.set(t,e),t},me=function(e,t){pe.set(e,t),de.set(t,e)},ye="style[".concat(S,"][").concat("data-styled-version",'="').concat(w,'"]'),ve=new RegExp("^".concat(S,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),ge=function(e,t,n){for(var o,r=n.split(","),i=0,s=r.length;i<s;i++)(o=r[i])&&e.registerName(t,o)},Se=function(e,t){for(var n,o=(null!==(n=t.textContent)&&void 0!==n?n:"").split("/*!sc*/\n"),r=[],i=0,s=o.length;i<s;i++){var a=o[i].trim();if(a){var c=a.match(ve);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(me(l,u),ge(e,l,c[3]),e.getTag().insertRules(u,r)),r.length=0}else r.push(a)}}};function we(){return"undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null}var be=function(e){var t=document.head,n=e||t,o=document.createElement("style"),r=function(e){for(var t=e.childNodes,n=t.length;n>=0;n--){var o=t[n];if(o&&1===o.nodeType&&o.hasAttribute(S))return o}}(n),i=void 0!==r?r.nextSibling:null;o.setAttribute(S,"active"),o.setAttribute("data-styled-version",w);var s=we();return s&&o.setAttribute("nonce",s),n.insertBefore(o,i),o},Ee=function(){function e(e){var t=this.element=be(e);t.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,o=t.length;n<o;n++){var r=t[n];if(r.ownerNode===e)return r}throw ue(17)}(t),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return void 0!==t&&"string"==typeof t.cssText?t.cssText:""},e}(),Ne=function(){function e(e){var t=this.element=be(e);this.nodes=t.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),_e=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Ce=b,Ae={isServer:!b,useCSSOMInjection:!E},Pe=function(){function e(e,n,o){void 0===e&&(e=I),void 0===n&&(n={}),this.options=t(t({},Ae),e),this.gs=n,this.names=new Map(o),this.server=!!e.isServer,!this.server&&b&&Ce&&(Ce=!1,function(e){for(var t=document.querySelectorAll(ye),n=0,o=t.length;n<o;n++){var r=t[n];r&&"active"!==r.getAttribute(S)&&(Se(e,r),r.parentNode&&r.parentNode.removeChild(r))}}(this))}return e.registerId=function(e){return fe(e)},e.prototype.reconstructWithOptions=function(n,o){return void 0===o&&(o=!0),new e(t(t({},this.options),n),this.gs,o&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new _e(n):t?new Ee(n):new Ne(n)}(this.options),new le(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(fe(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(fe(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(fe(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e.prototype.toString=function(){return function(e){for(var t=e.getTag(),n=t.length,o="",r=function(n){var r=function(e){return de.get(e)}(n);if(void 0===r)return"continue";var i=e.names.get(r),s=t.getGroup(n);if(void 0===i||0===s.length)return"continue";var a="".concat(S,".g").concat(n,'[id="').concat(r,'"]'),c="";void 0!==i&&i.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),o+="".concat(s).concat(a,'{content:"').concat(c,'"}').concat("/*!sc*/\n")},i=0;i<n;i++)r(i);return o}(this)},e}(),Ie=/^\s*\/\/.*$/gm,Oe=[":","[",".","#"];function De(e){var t,n,o,r,i=void 0===e?I:e,s=i.options,a=void 0===s?I:s,c=i.plugins,u=void 0===c?P:c,l=function(e,o,i){return 0===o&&Oe.includes(i[n.length])||i.match(r)?e:".".concat(t)},p=function(e){if(e.type===v&&e.value.includes("&")){var t=e.props;t[0]=t[0].replace(o,l)}},d=function(e,i,s,c){void 0===i&&(i=""),void 0===s&&(s=""),void 0===c&&(c="&");var l=e.replace(Ie,"");t=c,n=i,o=new RegExp("\\".concat(n,"\\b"),"g"),r=new RegExp("(\\".concat(n,"\\b){2,}"));var d,v,g=u.slice();return(a.prefix||void 0===a.prefix)&&g.unshift(h),g.push(p,f),d=y(s||i?"".concat(s," ").concat(i," { ").concat(l," }"):l),v=m(g),d.map(function(e,t){return v(e,t,d,v)}).filter(Boolean)};return d.hash=u.length?u.reduce(function(e,t){return t.name||ue(15),$(e,t.name)},5381).toString():"",d}var Re=r.createContext(void 0),je=Re.Consumer,Te=r.createContext(void 0),xe=new Pe,ke=De();function Ve(){return a(Re)||xe}function Be(){return a(Te)||ke}function $e(e){var t=s(e.stylisPlugins),n=t[0],o=t[1],i=Ve(),a=c(function(){var t=i;return e.sheet?t=e.sheet:e.target&&(t=t.reconstructWithOptions({target:e.target},!1)),e.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[e.disableCSSOMInjection,e.sheet,e.target]),l=c(function(){return De({options:{prefix:!e.disableVendorPrefixes},plugins:n})},[e.disableVendorPrefixes,n]);return u(function(){d(n,e.stylisPlugins)||o(e.stylisPlugins)},[e.stylisPlugins]),r.createElement(Re.Provider,{value:a},r.createElement(Te.Provider,{value:l},"production"!==process.env.NODE_ENV?r.Children.only(e.children):e.children))}var ze=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=ke);var o=n.name+t.hash;e.hasNameForId(n.id,o)||e.insertRules(n.id,o,t(n.rules,o,"@keyframes"))},this.toString=function(){throw ue(12,String(n.name))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=ke),this.name+e.hash},e}(),Me=/([A-Z])/,Le=/([A-Z])/g,Fe=/^ms-/,Ge=function(e){return"-".concat(e.toLowerCase())};function Ye(e){return Me.test(e)?e.replace(Le,Ge).replace(Fe,"-ms-"):e}function qe(e){return"function"==typeof e}var He=function(e){return null==e||!1===e||""===e},We=function(t,n){var o,r=[];for(var i in t)t.hasOwnProperty(i)&&!He(t[i])&&(Array.isArray(t[i])&&t[i].isCss||qe(t[i])?r.push("".concat(Ye(i),":"),t[i],";"):ie(t[i])?r.push.apply(r,We(t[i],i)):r.push("".concat(Ye(i),": ").concat(null==(o=t[i])||"boolean"==typeof o||""===o?"":"number"!=typeof o||0===o||i in g?String(o).trim():"".concat(o,"px"),";")));return n?e(e(["".concat(n," {")],r,!0),["}"],!1):r};function Ue(e,t,n,o){if(Array.isArray(e)){for(var r=[],i=0,s=e.length,a=void 0;i<s;i+=1)""!==(a=Ue(e[i],t,n,o))&&(Array.isArray(a)?r.push.apply(r,a):r.push(a));return r}if(He(e))return"";if(re(e))return".".concat(e.styledComponentId);if(qe(e)){if("function"!=typeof(u=e)||u.prototype&&u.prototype.isReactComponent||!t)return e;var c=e;return a=c(t),"production"===process.env.NODE_ENV||"object"!=typeof a||Array.isArray(a)||a instanceof ze||ie(a)||console.error("".concat(L(c)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Ue(a,t,n,o)}var u;return e instanceof ze?n?(e.inject(n,o),e.getName(o)):e:ie(e)?We(e):e.toString()}function Je(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(qe(n)&&!re(n))return!1}return!0}var Xe=z(w),Ze=function(){function e(e,t,n){this.names=[],this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&Je(e),this.componentId=t,this.baseHash=$(Xe,t),this.baseStyle=n,Pe.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var o=this.componentId;if(this.names.length=0,this.baseStyle&&this.names.push(this.baseStyle.generateAndInjectStyles(e,t,n)),this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(o,this.staticRulesId))this.names.push(this.staticRulesId);else{var r=Ue(this.rules,e,t,n).join(""),i=V($(this.baseHash,r)>>>0);if(!t.hasNameForId(o,i)){var s=n(r,".".concat(i),void 0,o);t.insertRules(o,i,s)}this.names.push(i),this.staticRulesId=i}else{for(var a=this.rules.length,c=$(this.baseHash,n.hash),u="",l=0;l<a;l++){var p=this.rules[l];if("string"==typeof p)u+=p,"production"!==process.env.NODE_ENV&&(c=$(c,p));else if(p){var d=Ue(p,e,t,n),h=Array.isArray(d)?d.join(""):d;c=$(c,h),u+=h}}if(u){var f=V(c>>>0);if(!t.hasNameForId(o,f)){var m=n(u,".".concat(f),void 0,o);t.insertRules(o,f,m)}this.names.push(f)}}return this.names.join(" ")},e}(),Ke=r.createContext(void 0),Qe=Ke.Consumer;function et(e){var n=a(Ke),o=c(function(){return function(e,n){if(!e)throw ue(14);if(qe(e)){var o=e(n);if("production"!==process.env.NODE_ENV&&(null===o||Array.isArray(o)||"object"!=typeof o))throw ue(7);return o}if(Array.isArray(e)||"object"!=typeof e)throw ue(8);return n?t(t({},n),e):e}(e.theme,n)},[e.theme,n]);return e.children?r.createElement(Ke.Provider,{value:o},e.children):null}var tt={};function nt(e,i,s){var c=re(e),u=e,d=!F(e),h=i.attrs,f=void 0===h?P:h,m=i.componentId,y=void 0===m?function(e,t){var n="string"!=typeof e?"sc":T(e);tt[n]=(tt[n]||0)+1;var o="".concat(n,"-").concat(M(w+n+tt[n]));return t?"".concat(t,"-").concat(o):o}(i.displayName,i.parentComponentId):m,v=i.displayName,g=void 0===v?function(e){return F(e)?"styled.".concat(e):"Styled(".concat(L(e),")")}(e):v,S=i.displayName&&i.componentId?"".concat(T(i.displayName),"-").concat(i.componentId):i.componentId||y,b=c&&u.attrs?u.attrs.concat(f).filter(Boolean):f,E=i.shouldForwardProp;if(c&&u.shouldForwardProp){var N=u.shouldForwardProp;if(i.shouldForwardProp){var _=i.shouldForwardProp;E=function(e,t,n){return N(e,t,n)&&_(e,t,n)}}else E=N}var C=new Ze(s,S,c?u.componentStyle:void 0),R=C.isStatic&&0===f.length;function j(e,n){return function(e,n,r,i){var s=e.attrs,c=e.componentStyle,u=e.defaultProps,d=e.foldedComponentIds,h=e.shouldForwardProp,f=e.styledComponentId,m=e.target;"production"!==process.env.NODE_ENV&&p(f);var y=function(e,n,o){void 0===e&&(e=I);var r=t(t({},n),{theme:e});return o.forEach(function(e){var n,o,i,s="function"==typeof e?e(r):e;for(n in s)r[n]="className"===n?(i=s[n],(o=r[n])&&i?"".concat(o," ").concat(i):o||i):"style"===n?t(t({},r[n]),s[n]):s[n]}),r}(O(n,a(Ke),u)||I,n,s),v=function(e,t,n,o){var r=Ve(),i=Be(),s=e.generateAndInjectStyles(t?I:n,r,i);return"production"!==process.env.NODE_ENV&&p(s),"production"!==process.env.NODE_ENV&&!t&&o&&o(s),s}(c,i,y,"production"!==process.env.NODE_ENV?e.warnTooManyClasses:void 0),g=r,S=y.$as||y.as||m,w=F(S),b={};for(var E in y)"$"!==E[0]&&"as"!==E&&"theme"!==E&&("forwardedAs"===E?b.as=y[E]:(h?h(E,o,S):!w||o(E))&&(b[E]=y[E]));return b[w&&-1===D.indexOf(S)?"class":"className"]=d.concat(f,v!==f?v:null,y.className).filter(Boolean).join(" "),b.ref=g,l(S,b)}(x,e,n,R)}j.displayName=g;var x=r.forwardRef(j);return x.attrs=b,x.componentStyle=C,x.displayName=g,x.shouldForwardProp=E,x.foldedComponentIds=c?u.foldedComponentIds.concat(u.styledComponentId):P,x.styledComponentId=S,x.target=c?u.target:e,x.withComponent=function(e){var o=i.componentId,r=n(i,["componentId"]),a=o&&"".concat(o,"-").concat(F(e)?e:T(L(e)));return nt(e,t(t({},r),{attrs:b,componentId:a}),s)},Object.defineProperty(x,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=c?function(e){void 0===e&&(e={});for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var o=0,r=t;o<r.length;o++)se(e,r[o],!0);return e}({},u.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(A(g,S),x.warnTooManyClasses=function(e,t){var n={},o=!1;return function(r){if(!o&&(n[r]=!0,Object.keys(n).length>=200)){var i=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(i,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),o=!0,n={}}}}(g,S)),x.toString=function(){return".".concat(x.styledComponentId)},d&&oe(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0,withComponent:!0}),x}function ot(e,t){for(var n=[e[0]],o=0,r=t.length;o<r;o+=1)n.push(t[o],e[o+1]);return n}var rt=function(e){return Array.isArray(e)&&(e.isCss=!0),e};function it(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(qe(t)||ie(t)){var r=t;return rt(Ue(ot(P,e([r],n,!0))))}var i=t;return 0===n.length&&1===i.length&&"string"==typeof i[0]?i:rt(Ue(ot(i,n)))}function st(n,o,r){if(void 0===r&&(r=I),!o)throw ue(1,o);var i=function(t){for(var i=[],s=1;s<arguments.length;s++)i[s-1]=arguments[s];return n(o,r,it.apply(void 0,e([t],i,!1)))};return i.attrs=function(e){return st(n,o,t(t({},r),{attrs:Array.prototype.concat(r.attrs,e).filter(Boolean)}))},i.withConfig=function(e){return st(n,o,t(t({},r),e))},i}var at=function(e){return st(nt,e)},ct=at;D.forEach(function(e){ct[e]=at(e)});var ut=function(){function e(e,t){this.rules=e,this.componentId=t,this.isStatic=Je(e),Pe.registerId(this.componentId+1)}return e.prototype.createStyles=function(e,t,n,o){var r=o(Ue(this.rules,t,n,o).join(""),""),i=this.componentId+e;n.insertRules(i,i,r)},e.prototype.removeStyles=function(e,t){t.clearRules(this.componentId+e)},e.prototype.renderStyles=function(e,t,n,o){e>2&&Pe.registerId(this.componentId+e),this.removeStyles(e,n),this.createStyles(e,t,n,o)},e}();function lt(n){for(var o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];var s=it.apply(void 0,e([n],o,!1)),a="sc-global-".concat(M(JSON.stringify(s))),c=new ut(s,a);"production"!==process.env.NODE_ENV&&A(a);var u=function(e){var t=Ve(),n=Be(),o=r.useContext(Ke),i=r.useRef(t.allocateGSInstance(a)).current;return"production"!==process.env.NODE_ENV&&r.Children.count(e.children)&&console.warn("The global style component ".concat(a," was given child JSX. createGlobalStyle does not render children.")),"production"!==process.env.NODE_ENV&&s.some(function(e){return"string"==typeof e&&-1!==e.indexOf("@import")})&&console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app."),t.server&&l(i,e,t,o,n),(r.useInsertionEffect||r.useLayoutEffect)(function(){if(!t.server)return l(i,e,t,o,n),function(){return c.removeStyles(i,t)}},[i,e,t,o,n]),null};function l(e,n,o,r,i){if(c.isStatic)c.renderStyles(e,N,o,i);else{var s=t(t({},n),{theme:O(n,r,u.defaultProps)});c.renderStyles(e,s,o,i)}}return r.memo(u)}function pt(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var r=it.apply(void 0,e([t],n,!1)).join(""),i=M(r);return new ze(i,r)}function dt(e){var n=r.forwardRef(function(n,o){var i=O(n,r.useContext(Ke),e.defaultProps);return"production"!==process.env.NODE_ENV&&void 0===i&&console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "'.concat(L(e),'"')),r.createElement(e,t({},n,{theme:i,ref:o}))});return n.displayName="WithTheme(".concat(L(e),")"),oe(n,e)}var ht=function(){return a(Ke)},ft=function(){function e(){var e=this;this._emitSheetCSS=function(){var t=e.instance.toString(),n=we(),o=[n&&'nonce="'.concat(n,'"'),"".concat(S,'="true"'),"".concat("data-styled-version",'="').concat(w,'"')].filter(Boolean).join(" ");return"<style ".concat(o,">").concat(t,"</style>")},this.getStyleTags=function(){if(e.sealed)throw ue(2);return e._emitSheetCSS()},this.getStyleElement=function(){var n;if(e.sealed)throw ue(2);var o=((n={})[S]="",n["data-styled-version"]=w,n.dangerouslySetInnerHTML={__html:e.instance.toString()},n),i=we();return i&&(o.nonce=i),[r.createElement("style",t({},o,{key:"sc-0-0"}))]},this.seal=function(){e.sealed=!0},this.instance=new Pe({isServer:!0}),this.sealed=!1}return e.prototype.collectStyles=function(e){if(this.sealed)throw ue(2);return r.createElement($e,{sheet:this.instance},e)},e.prototype.interleaveWithNodeStream=function(e){throw ue(3)},e}(),mt={StyleSheet:Pe,mainSheet:xe};"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native"),"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window["__styled-components-init__"]||(window["__styled-components-init__"]=0),1===window["__styled-components-init__"]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window["__styled-components-init__"]+=1);export{ft as ServerStyleSheet,je as StyleSheetConsumer,Re as StyleSheetContext,$e as StyleSheetManager,Qe as ThemeConsumer,Ke as ThemeContext,et as ThemeProvider,mt as __PRIVATE__,lt as createGlobalStyle,it as css,ct as default,re as isStyledComponent,pt as keyframes,ht as useTheme,w as version,dt as withTheme};
1
+ import { __spreadArray, __assign, __rest } from 'tslib';
2
+ import React, { useRef, useState, useContext, useMemo, useEffect, createElement, useDebugValue } from 'react';
3
+ import shallowequal from 'shallowequal';
4
+ import { prefixer, stringify, middleware, compile, RULESET } from 'stylis';
5
+ import unitless from '@emotion/unitless';
6
+
7
+ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
8
+ 'data-styled';
9
+ var SC_ATTR_ACTIVE = 'active';
10
+ var SC_ATTR_VERSION = 'data-styled-version';
11
+ var SC_VERSION = "6.0.0-beta.2";
12
+ var SPLITTER = '/*!sc*/\n';
13
+ var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
14
+ var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
15
+ ? SC_DISABLE_SPEEDY
16
+ : typeof process !== 'undefined' &&
17
+ typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
18
+ process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
19
+ ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
20
+ ? false
21
+ : process.env.REACT_APP_SC_DISABLE_SPEEDY
22
+ : typeof process !== 'undefined' &&
23
+ typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
24
+ process.env.SC_DISABLE_SPEEDY !== ''
25
+ ? process.env.SC_DISABLE_SPEEDY === 'false'
26
+ ? false
27
+ : process.env.SC_DISABLE_SPEEDY
28
+ : process.env.NODE_ENV !== 'production');
29
+ // Shared empty execution context when generating static styles
30
+ var STATIC_EXECUTION_CONTEXT = {};
31
+
32
+ var invalidHookCallRe = /invalid hook call/i;
33
+ var seen = new Set();
34
+ var checkDynamicCreation = function (displayName, componentId) {
35
+ if (process.env.NODE_ENV !== 'production') {
36
+ var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
37
+ var message_1 = "The component ".concat(displayName).concat(parsedIdString, " has been created dynamically.\n") +
38
+ "You may see this warning because you've called styled inside another component.\n" +
39
+ 'To resolve this only create new StyledComponents outside of any render method and function component.';
40
+ // If a hook is called outside of a component:
41
+ // React 17 and earlier throw an error
42
+ // React 18 and above use console.error
43
+ var originalConsoleError_1 = console.error;
44
+ try {
45
+ var didNotCallInvalidHook_1 = true;
46
+ console.error = function (consoleErrorMessage) {
47
+ var consoleErrorArgs = [];
48
+ for (var _i = 1; _i < arguments.length; _i++) {
49
+ consoleErrorArgs[_i - 1] = arguments[_i];
50
+ }
51
+ // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
52
+ // be called outside of a React component.
53
+ if (invalidHookCallRe.test(consoleErrorMessage)) {
54
+ didNotCallInvalidHook_1 = false;
55
+ // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
56
+ seen.delete(message_1);
57
+ }
58
+ else {
59
+ originalConsoleError_1.apply(void 0, __spreadArray([consoleErrorMessage], consoleErrorArgs, false));
60
+ }
61
+ };
62
+ // We purposefully call `useRef` outside of a component and expect it to throw
63
+ // If it doesn't, then we're inside another component.
64
+ // eslint-disable-next-line react-hooks/rules-of-hooks
65
+ useRef();
66
+ if (didNotCallInvalidHook_1 && !seen.has(message_1)) {
67
+ // eslint-disable-next-line no-console
68
+ console.warn(message_1);
69
+ seen.add(message_1);
70
+ }
71
+ }
72
+ catch (error) {
73
+ // The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
74
+ // be called outside of a React component.
75
+ if (invalidHookCallRe.test(error.message)) {
76
+ // This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
77
+ seen.delete(message_1);
78
+ }
79
+ }
80
+ finally {
81
+ console.error = originalConsoleError_1;
82
+ }
83
+ }
84
+ };
85
+
86
+ var LIMIT = 200;
87
+ var createWarnTooManyClasses = (function (displayName, componentId) {
88
+ var generatedClasses = {};
89
+ var warningSeen = false;
90
+ return function (className) {
91
+ if (!warningSeen) {
92
+ generatedClasses[className] = true;
93
+ if (Object.keys(generatedClasses).length >= LIMIT) {
94
+ // Unable to find latestRule in test environment.
95
+ /* eslint-disable no-console, prefer-template */
96
+ var parsedIdString = componentId ? " with the id of \"".concat(componentId, "\"") : '';
97
+ console.warn("Over ".concat(LIMIT, " classes were generated for component ").concat(displayName).concat(parsedIdString, ".\n") +
98
+ 'Consider using the attrs method, together with a style object for frequently changed styles.\n' +
99
+ 'Example:\n' +
100
+ ' const Component = styled.div.attrs(props => ({\n' +
101
+ ' style: {\n' +
102
+ ' background: props.background,\n' +
103
+ ' },\n' +
104
+ ' }))`width: 100%;`\n\n' +
105
+ ' <Component />');
106
+ warningSeen = true;
107
+ generatedClasses = {};
108
+ }
109
+ }
110
+ };
111
+ });
112
+
113
+ var EMPTY_ARRAY = Object.freeze([]);
114
+ var EMPTY_OBJECT = Object.freeze({});
115
+
116
+ function determineTheme(props, providedTheme, defaultProps) {
117
+ if (defaultProps === void 0) { defaultProps = EMPTY_OBJECT; }
118
+ return (props.theme !== defaultProps.theme && props.theme) || providedTheme || defaultProps.theme;
119
+ }
120
+
121
+ // Thanks to ReactDOMFactories for this handy list!
122
+ var domElements = [
123
+ 'a',
124
+ 'abbr',
125
+ 'address',
126
+ 'area',
127
+ 'article',
128
+ 'aside',
129
+ 'audio',
130
+ 'b',
131
+ 'base',
132
+ 'bdi',
133
+ 'bdo',
134
+ 'big',
135
+ 'blockquote',
136
+ 'body',
137
+ 'br',
138
+ 'button',
139
+ 'canvas',
140
+ 'caption',
141
+ 'cite',
142
+ 'code',
143
+ 'col',
144
+ 'colgroup',
145
+ 'data',
146
+ 'datalist',
147
+ 'dd',
148
+ 'del',
149
+ 'details',
150
+ 'dfn',
151
+ 'dialog',
152
+ 'div',
153
+ 'dl',
154
+ 'dt',
155
+ 'em',
156
+ 'embed',
157
+ 'fieldset',
158
+ 'figcaption',
159
+ 'figure',
160
+ 'footer',
161
+ 'form',
162
+ 'h1',
163
+ 'h2',
164
+ 'h3',
165
+ 'h4',
166
+ 'h5',
167
+ 'h6',
168
+ 'head',
169
+ 'header',
170
+ 'hgroup',
171
+ 'hr',
172
+ 'html',
173
+ 'i',
174
+ 'iframe',
175
+ 'img',
176
+ 'input',
177
+ 'ins',
178
+ 'kbd',
179
+ 'keygen',
180
+ 'label',
181
+ 'legend',
182
+ 'li',
183
+ 'link',
184
+ 'main',
185
+ 'map',
186
+ 'mark',
187
+ 'menu',
188
+ 'menuitem',
189
+ 'meta',
190
+ 'meter',
191
+ 'nav',
192
+ 'noscript',
193
+ 'object',
194
+ 'ol',
195
+ 'optgroup',
196
+ 'option',
197
+ 'output',
198
+ 'p',
199
+ 'param',
200
+ 'picture',
201
+ 'pre',
202
+ 'progress',
203
+ 'q',
204
+ 'rp',
205
+ 'rt',
206
+ 'ruby',
207
+ 's',
208
+ 'samp',
209
+ 'script',
210
+ 'section',
211
+ 'select',
212
+ 'small',
213
+ 'source',
214
+ 'span',
215
+ 'strong',
216
+ 'style',
217
+ 'sub',
218
+ 'summary',
219
+ 'sup',
220
+ 'table',
221
+ 'tbody',
222
+ 'td',
223
+ 'textarea',
224
+ 'tfoot',
225
+ 'th',
226
+ 'thead',
227
+ 'time',
228
+ 'title',
229
+ 'tr',
230
+ 'track',
231
+ 'u',
232
+ 'ul',
233
+ 'var',
234
+ 'video',
235
+ 'wbr',
236
+ 'circle',
237
+ 'clipPath',
238
+ 'defs',
239
+ 'ellipse',
240
+ 'foreignObject',
241
+ 'g',
242
+ 'image',
243
+ 'line',
244
+ 'linearGradient',
245
+ 'marker',
246
+ 'mask',
247
+ 'path',
248
+ 'pattern',
249
+ 'polygon',
250
+ 'polyline',
251
+ 'radialGradient',
252
+ 'rect',
253
+ 'stop',
254
+ 'svg',
255
+ 'text',
256
+ 'tspan',
257
+ ];
258
+
259
+ // Source: https://www.w3.org/TR/cssom-1/#serialize-an-identifier
260
+ // Control characters and non-letter first symbols are not supported
261
+ var escapeRegex = /[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g;
262
+ var dashesAtEnds = /(^-|-$)/g;
263
+ /**
264
+ * TODO: Explore using CSS.escape when it becomes more available
265
+ * in evergreen browsers.
266
+ */
267
+ function escape(str) {
268
+ return str // Replace all possible CSS selectors
269
+ .replace(escapeRegex, '-') // Remove extraneous hyphens at the start and end
270
+ .replace(dashesAtEnds, '');
271
+ }
272
+
273
+ var AD_REPLACER_R = /(a)(d)/gi;
274
+ /* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
275
+ * counterparts */
276
+ var charsLength = 52;
277
+ /* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
278
+ var getAlphabeticChar = function (code) { return String.fromCharCode(code + (code > 25 ? 39 : 97)); };
279
+ /* input a number, usually a hash and convert it to base-52 */
280
+ function generateAlphabeticName(code) {
281
+ var name = '';
282
+ var x;
283
+ /* get a char and divide by alphabet-length */
284
+ for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
285
+ name = getAlphabeticChar(x % charsLength) + name;
286
+ }
287
+ return (getAlphabeticChar(x % charsLength) + name).replace(AD_REPLACER_R, '$1-$2');
288
+ }
289
+
290
+ var SEED$1 = 5381;
291
+ // When we have separate strings it's useful to run a progressive
292
+ // version of djb2 where we pretend that we're still looping over
293
+ // the same string
294
+ var phash = function (h, x) {
295
+ var i = x.length;
296
+ while (i) {
297
+ h = (h * 33) ^ x.charCodeAt(--i);
298
+ }
299
+ return h;
300
+ };
301
+ // This is a djb2 hashing function
302
+ var hash = function (x) {
303
+ return phash(SEED$1, x);
304
+ };
305
+
306
+ function generateComponentId(str) {
307
+ return generateAlphabeticName(hash(str) >>> 0);
308
+ }
309
+
310
+ function getComponentName(target) {
311
+ return ((process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) ||
312
+ target.displayName ||
313
+ target.name ||
314
+ 'Component');
315
+ }
316
+
317
+ function isTag(target) {
318
+ return (typeof target === 'string' &&
319
+ (process.env.NODE_ENV !== 'production'
320
+ ? target.charAt(0) === target.charAt(0).toLowerCase()
321
+ : true));
322
+ }
323
+
324
+ function generateDisplayName(target) {
325
+ return isTag(target) ? "styled.".concat(target) : "Styled(".concat(getComponentName(target), ")");
326
+ }
327
+
328
+ var _a;
329
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
330
+ // copied from react-is
331
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
332
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
333
+ /**
334
+ * Adapted from hoist-non-react-statics to avoid the react-is dependency.
335
+ */
336
+ var REACT_STATICS = {
337
+ childContextTypes: true,
338
+ contextType: true,
339
+ contextTypes: true,
340
+ defaultProps: true,
341
+ displayName: true,
342
+ getDefaultProps: true,
343
+ getDerivedStateFromError: true,
344
+ getDerivedStateFromProps: true,
345
+ mixins: true,
346
+ propTypes: true,
347
+ type: true,
348
+ };
349
+ var KNOWN_STATICS = {
350
+ name: true,
351
+ length: true,
352
+ prototype: true,
353
+ caller: true,
354
+ callee: true,
355
+ arguments: true,
356
+ arity: true,
357
+ };
358
+ var FORWARD_REF_STATICS = {
359
+ $$typeof: true,
360
+ render: true,
361
+ defaultProps: true,
362
+ displayName: true,
363
+ propTypes: true,
364
+ };
365
+ var MEMO_STATICS = {
366
+ $$typeof: true,
367
+ compare: true,
368
+ defaultProps: true,
369
+ displayName: true,
370
+ propTypes: true,
371
+ type: true,
372
+ };
373
+ var TYPE_STATICS = (_a = {},
374
+ _a[REACT_FORWARD_REF_TYPE] = FORWARD_REF_STATICS,
375
+ _a[REACT_MEMO_TYPE] = MEMO_STATICS,
376
+ _a);
377
+ // adapted from react-is
378
+ function isMemo(object) {
379
+ var $$typeofType = 'type' in object && object.type.$$typeof;
380
+ return $$typeofType === REACT_MEMO_TYPE;
381
+ }
382
+ function getStatics(component) {
383
+ // React v16.11 and below
384
+ if (isMemo(component)) {
385
+ return MEMO_STATICS;
386
+ }
387
+ // React v16.12 and above
388
+ return '$$typeof' in component
389
+ ? TYPE_STATICS[component['$$typeof']]
390
+ : REACT_STATICS;
391
+ }
392
+ var defineProperty = Object.defineProperty;
393
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
394
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
395
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
396
+ var getPrototypeOf = Object.getPrototypeOf;
397
+ var objectPrototype = Object.prototype;
398
+ function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
399
+ if (typeof sourceComponent !== 'string') {
400
+ // don't hoist over string (html) components
401
+ if (objectPrototype) {
402
+ var inheritedComponent = getPrototypeOf(sourceComponent);
403
+ if (inheritedComponent && inheritedComponent !== objectPrototype) {
404
+ hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);
405
+ }
406
+ }
407
+ var keys = getOwnPropertyNames(sourceComponent);
408
+ if (getOwnPropertySymbols) {
409
+ keys = keys.concat(getOwnPropertySymbols(sourceComponent));
410
+ }
411
+ var targetStatics = getStatics(targetComponent);
412
+ var sourceStatics = getStatics(sourceComponent);
413
+ for (var i = 0; i < keys.length; ++i) {
414
+ var key = keys[i];
415
+ if (!(key in KNOWN_STATICS) &&
416
+ !(excludelist && excludelist[key]) &&
417
+ !(sourceStatics && key in sourceStatics) &&
418
+ !(targetStatics && key in targetStatics)) {
419
+ var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
420
+ try {
421
+ // Avoid failures from read-only properties
422
+ defineProperty(targetComponent, key, descriptor);
423
+ }
424
+ catch (e) {
425
+ /* ignore */
426
+ }
427
+ }
428
+ }
429
+ }
430
+ return targetComponent;
431
+ }
432
+
433
+ function isStyledComponent(target) {
434
+ return typeof target === 'object' && 'styledComponentId' in target;
435
+ }
436
+
437
+ /**
438
+ * Convenience function for joining strings to form className chains
439
+ */
440
+ function joinStrings(a, b) {
441
+ return a && b ? "".concat(a, " ").concat(b) : a || b;
442
+ }
443
+
444
+ function isPlainObject(x) {
445
+ return (x !== null &&
446
+ typeof x === 'object' &&
447
+ /* a check for empty prototype would be more typical, but that
448
+ doesn't play well with objects created in different vm contexts */
449
+ (!x.constructor || x.constructor.name === 'Object') &&
450
+ (x.toString ? x.toString() : Object.prototype.toString.call(x)) === '[object Object]' &&
451
+ /* check for reasonable markers that the object isn't an element for react & preact/compat */
452
+ !('props' in x && (x.$$typeof || x.constructor === undefined)));
453
+ }
454
+
455
+ function mixinRecursively(target, source, forceMerge) {
456
+ if (forceMerge === void 0) { forceMerge = false; }
457
+ /* only merge into POJOs, Arrays, but for top level objects only
458
+ * allow to merge into anything by passing forceMerge = true */
459
+ if (!forceMerge && !isPlainObject(target) && !Array.isArray(target)) {
460
+ return source;
461
+ }
462
+ if (Array.isArray(source)) {
463
+ for (var key = 0; key < source.length; key++) {
464
+ target[key] = mixinRecursively(target[key], source[key]);
465
+ }
466
+ }
467
+ else if (isPlainObject(source)) {
468
+ for (var key in source) {
469
+ target[key] = mixinRecursively(target[key], source[key]);
470
+ }
471
+ }
472
+ return target;
473
+ }
474
+ /**
475
+ * Arrays & POJOs merged recursively, other objects and value types are overridden
476
+ * If target is not a POJO or an Array, it will get source properties injected via shallow merge
477
+ * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
478
+ */
479
+ function mixinDeep(target) {
480
+ if (target === void 0) { target = {}; }
481
+ var sources = [];
482
+ for (var _i = 1; _i < arguments.length; _i++) {
483
+ sources[_i - 1] = arguments[_i];
484
+ }
485
+ for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
486
+ var source = sources_1[_a];
487
+ mixinRecursively(target, source, true);
488
+ }
489
+ return target;
490
+ }
491
+
492
+ var errorMap = {
493
+ '1': 'Cannot create styled-component for component: %s.\n\n',
494
+ '2': "Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",
495
+ '3': 'Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n',
496
+ '4': 'The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n',
497
+ '5': 'The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n',
498
+ '6': "Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",
499
+ '7': 'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',
500
+ '8': 'ThemeProvider: Please make your "theme" prop an object.\n\n',
501
+ '9': 'Missing document `<head>`\n\n',
502
+ '10': 'Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n',
503
+ '11': '_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n',
504
+ '12': 'It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n',
505
+ '13': '%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n',
506
+ '14': 'ThemeProvider: "theme" prop is required.\n\n',
507
+ '15': "A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",
508
+ '16': "Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",
509
+ '17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
510
+ };
511
+
512
+ var ERRORS = process.env.NODE_ENV !== 'production' ? errorMap : {};
513
+ /**
514
+ * super basic version of sprintf
515
+ */
516
+ function format() {
517
+ var args = [];
518
+ for (var _i = 0; _i < arguments.length; _i++) {
519
+ args[_i] = arguments[_i];
520
+ }
521
+ var a = args[0];
522
+ var b = [];
523
+ for (var c = 1, len = args.length; c < len; c += 1) {
524
+ b.push(args[c]);
525
+ }
526
+ b.forEach(function (d) {
527
+ a = a.replace(/%[a-z]/, d);
528
+ });
529
+ return a;
530
+ }
531
+ /**
532
+ * Create an error file out of errors.md for development and a simple web link to the full errors
533
+ * in production mode.
534
+ */
535
+ function throwStyledComponentsError(code) {
536
+ var interpolations = [];
537
+ for (var _i = 1; _i < arguments.length; _i++) {
538
+ interpolations[_i - 1] = arguments[_i];
539
+ }
540
+ if (process.env.NODE_ENV === 'production') {
541
+ return new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(code, " for more information.").concat(interpolations.length > 0 ? " Args: ".concat(interpolations.join(', ')) : ''));
542
+ }
543
+ else {
544
+ return new Error(format.apply(void 0, __spreadArray([ERRORS[code]], interpolations, false)).trim());
545
+ }
546
+ }
547
+
548
+ /** Create a GroupedTag with an underlying Tag implementation */
549
+ var makeGroupedTag = function (tag) {
550
+ return new DefaultGroupedTag(tag);
551
+ };
552
+ var BASE_SIZE = 1 << 9;
553
+ var DefaultGroupedTag = /** @class */ (function () {
554
+ function DefaultGroupedTag(tag) {
555
+ this.groupSizes = new Uint32Array(BASE_SIZE);
556
+ this.length = BASE_SIZE;
557
+ this.tag = tag;
558
+ }
559
+ DefaultGroupedTag.prototype.indexOfGroup = function (group) {
560
+ var index = 0;
561
+ for (var i = 0; i < group; i++) {
562
+ index += this.groupSizes[i];
563
+ }
564
+ return index;
565
+ };
566
+ DefaultGroupedTag.prototype.insertRules = function (group, rules) {
567
+ if (group >= this.groupSizes.length) {
568
+ var oldBuffer = this.groupSizes;
569
+ var oldSize = oldBuffer.length;
570
+ var newSize = oldSize;
571
+ while (group >= newSize) {
572
+ newSize <<= 1;
573
+ if (newSize < 0) {
574
+ throw throwStyledComponentsError(16, "".concat(group));
575
+ }
576
+ }
577
+ this.groupSizes = new Uint32Array(newSize);
578
+ this.groupSizes.set(oldBuffer);
579
+ this.length = newSize;
580
+ for (var i = oldSize; i < newSize; i++) {
581
+ this.groupSizes[i] = 0;
582
+ }
583
+ }
584
+ var ruleIndex = this.indexOfGroup(group + 1);
585
+ if (Array.isArray(rules)) {
586
+ for (var i = 0, l = rules.length; i < l; i++) {
587
+ if (this.tag.insertRule(ruleIndex, rules[i])) {
588
+ this.groupSizes[group]++;
589
+ ruleIndex++;
590
+ }
591
+ }
592
+ }
593
+ else {
594
+ if (this.tag.insertRule(ruleIndex, rules)) {
595
+ this.groupSizes[group]++;
596
+ }
597
+ }
598
+ };
599
+ DefaultGroupedTag.prototype.clearGroup = function (group) {
600
+ if (group < this.length) {
601
+ var length_1 = this.groupSizes[group];
602
+ var startIndex = this.indexOfGroup(group);
603
+ var endIndex = startIndex + length_1;
604
+ this.groupSizes[group] = 0;
605
+ for (var i = startIndex; i < endIndex; i++) {
606
+ this.tag.deleteRule(startIndex);
607
+ }
608
+ }
609
+ };
610
+ DefaultGroupedTag.prototype.getGroup = function (group) {
611
+ var css = '';
612
+ if (group >= this.length || this.groupSizes[group] === 0) {
613
+ return css;
614
+ }
615
+ var length = this.groupSizes[group];
616
+ var startIndex = this.indexOfGroup(group);
617
+ var endIndex = startIndex + length;
618
+ for (var i = startIndex; i < endIndex; i++) {
619
+ css += "".concat(this.tag.getRule(i)).concat(SPLITTER);
620
+ }
621
+ return css;
622
+ };
623
+ return DefaultGroupedTag;
624
+ }());
625
+
626
+ var MAX_SMI = 1 << (31 - 1);
627
+ var groupIDRegister = new Map();
628
+ var reverseRegister = new Map();
629
+ var nextFreeGroup = 1;
630
+ var getGroupForId = function (id) {
631
+ if (groupIDRegister.has(id)) {
632
+ return groupIDRegister.get(id);
633
+ }
634
+ while (reverseRegister.has(nextFreeGroup)) {
635
+ nextFreeGroup++;
636
+ }
637
+ var group = nextFreeGroup++;
638
+ if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
639
+ throw throwStyledComponentsError(16, "".concat(group));
640
+ }
641
+ groupIDRegister.set(id, group);
642
+ reverseRegister.set(group, id);
643
+ return group;
644
+ };
645
+ var getIdForGroup = function (group) {
646
+ return reverseRegister.get(group);
647
+ };
648
+ var setGroupForId = function (id, group) {
649
+ groupIDRegister.set(id, group);
650
+ reverseRegister.set(group, id);
651
+ };
652
+
653
+ var SELECTOR = "style[".concat(SC_ATTR, "][").concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\"]");
654
+ var MARKER_RE = new RegExp("^".concat(SC_ATTR, "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"));
655
+ var outputSheet = function (sheet) {
656
+ var tag = sheet.getTag();
657
+ var length = tag.length;
658
+ var css = '';
659
+ var _loop_1 = function (group) {
660
+ var id = getIdForGroup(group);
661
+ if (id === undefined)
662
+ return "continue";
663
+ var names = sheet.names.get(id);
664
+ var rules = tag.getGroup(group);
665
+ if (names === undefined || rules.length === 0)
666
+ return "continue";
667
+ var selector = "".concat(SC_ATTR, ".g").concat(group, "[id=\"").concat(id, "\"]");
668
+ var content = '';
669
+ if (names !== undefined) {
670
+ names.forEach(function (name) {
671
+ if (name.length > 0) {
672
+ content += "".concat(name, ",");
673
+ }
674
+ });
675
+ }
676
+ // NOTE: It's easier to collect rules and have the marker
677
+ // after the actual rules to simplify the rehydration
678
+ css += "".concat(rules).concat(selector, "{content:\"").concat(content, "\"}").concat(SPLITTER);
679
+ };
680
+ for (var group = 0; group < length; group++) {
681
+ _loop_1(group);
682
+ }
683
+ return css;
684
+ };
685
+ var rehydrateNamesFromContent = function (sheet, id, content) {
686
+ var names = content.split(',');
687
+ var name;
688
+ for (var i = 0, l = names.length; i < l; i++) {
689
+ // eslint-disable-next-line
690
+ if ((name = names[i])) {
691
+ sheet.registerName(id, name);
692
+ }
693
+ }
694
+ };
695
+ var rehydrateSheetFromTag = function (sheet, style) {
696
+ var _a;
697
+ var parts = ((_a = style.textContent) !== null && _a !== void 0 ? _a : '').split(SPLITTER);
698
+ var rules = [];
699
+ for (var i = 0, l = parts.length; i < l; i++) {
700
+ var part = parts[i].trim();
701
+ if (!part)
702
+ continue;
703
+ var marker = part.match(MARKER_RE);
704
+ if (marker) {
705
+ var group = parseInt(marker[1], 10) | 0;
706
+ var id = marker[2];
707
+ if (group !== 0) {
708
+ // Rehydrate componentId to group index mapping
709
+ setGroupForId(id, group);
710
+ // Rehydrate names and rules
711
+ // looks like: data-styled.g11[id="idA"]{content:"nameA,"}
712
+ rehydrateNamesFromContent(sheet, id, marker[3]);
713
+ sheet.getTag().insertRules(group, rules);
714
+ }
715
+ rules.length = 0;
716
+ }
717
+ else {
718
+ rules.push(part);
719
+ }
720
+ }
721
+ };
722
+ var rehydrateSheet = function (sheet) {
723
+ var nodes = document.querySelectorAll(SELECTOR);
724
+ for (var i = 0, l = nodes.length; i < l; i++) {
725
+ var node = nodes[i];
726
+ if (node && node.getAttribute(SC_ATTR) !== SC_ATTR_ACTIVE) {
727
+ rehydrateSheetFromTag(sheet, node);
728
+ if (node.parentNode) {
729
+ node.parentNode.removeChild(node);
730
+ }
731
+ }
732
+ }
733
+ };
734
+
735
+ function getNonce() {
736
+ return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
737
+ }
738
+
739
+ var ELEMENT_TYPE = 1;
740
+ /* Node.ELEMENT_TYPE */
741
+ /** Find last style element if any inside target */
742
+ var findLastStyleTag = function (target) {
743
+ var childNodes = target.childNodes;
744
+ for (var i = childNodes.length; i >= 0; i--) {
745
+ var child = childNodes[i];
746
+ if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
747
+ return child;
748
+ }
749
+ }
750
+ return undefined;
751
+ };
752
+ /** Create a style element inside `target` or <head> after the last */
753
+ var makeStyleTag = function (target) {
754
+ var head = document.head;
755
+ var parent = target || head;
756
+ var style = document.createElement('style');
757
+ var prevStyle = findLastStyleTag(parent);
758
+ var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
759
+ style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
760
+ style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
761
+ var nonce = getNonce();
762
+ if (nonce)
763
+ style.setAttribute('nonce', nonce);
764
+ parent.insertBefore(style, nextSibling);
765
+ return style;
766
+ };
767
+ /** Get the CSSStyleSheet instance for a given style element */
768
+ var getSheet = function (tag) {
769
+ if (tag.sheet) {
770
+ return tag.sheet;
771
+ }
772
+ // Avoid Firefox quirk where the style element might not have a sheet property
773
+ var styleSheets = document.styleSheets;
774
+ for (var i = 0, l = styleSheets.length; i < l; i++) {
775
+ var sheet = styleSheets[i];
776
+ if (sheet.ownerNode === tag) {
777
+ return sheet;
778
+ }
779
+ }
780
+ throw throwStyledComponentsError(17);
781
+ };
782
+
783
+ /** Create a CSSStyleSheet-like tag depending on the environment */
784
+ var makeTag = function (_a) {
785
+ var isServer = _a.isServer, useCSSOMInjection = _a.useCSSOMInjection, target = _a.target;
786
+ if (isServer) {
787
+ return new VirtualTag(target);
788
+ }
789
+ else if (useCSSOMInjection) {
790
+ return new CSSOMTag(target);
791
+ }
792
+ else {
793
+ return new TextTag(target);
794
+ }
795
+ };
796
+ var CSSOMTag = /** @class */ (function () {
797
+ function CSSOMTag(target) {
798
+ var element = (this.element = makeStyleTag(target));
799
+ // Avoid Edge bug where empty style elements don't create sheets
800
+ element.appendChild(document.createTextNode(''));
801
+ this.sheet = getSheet(element);
802
+ this.length = 0;
803
+ }
804
+ CSSOMTag.prototype.insertRule = function (index, rule) {
805
+ try {
806
+ this.sheet.insertRule(rule, index);
807
+ this.length++;
808
+ return true;
809
+ }
810
+ catch (_error) {
811
+ return false;
812
+ }
813
+ };
814
+ CSSOMTag.prototype.deleteRule = function (index) {
815
+ this.sheet.deleteRule(index);
816
+ this.length--;
817
+ };
818
+ CSSOMTag.prototype.getRule = function (index) {
819
+ var rule = this.sheet.cssRules[index];
820
+ // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
821
+ if (rule !== undefined && typeof rule.cssText === 'string') {
822
+ return rule.cssText;
823
+ }
824
+ else {
825
+ return '';
826
+ }
827
+ };
828
+ return CSSOMTag;
829
+ }());
830
+ /** A Tag that emulates the CSSStyleSheet API but uses text nodes */
831
+ var TextTag = /** @class */ (function () {
832
+ function TextTag(target) {
833
+ var element = (this.element = makeStyleTag(target));
834
+ this.nodes = element.childNodes;
835
+ this.length = 0;
836
+ }
837
+ TextTag.prototype.insertRule = function (index, rule) {
838
+ if (index <= this.length && index >= 0) {
839
+ var node = document.createTextNode(rule);
840
+ var refNode = this.nodes[index];
841
+ this.element.insertBefore(node, refNode || null);
842
+ this.length++;
843
+ return true;
844
+ }
845
+ else {
846
+ return false;
847
+ }
848
+ };
849
+ TextTag.prototype.deleteRule = function (index) {
850
+ this.element.removeChild(this.nodes[index]);
851
+ this.length--;
852
+ };
853
+ TextTag.prototype.getRule = function (index) {
854
+ if (index < this.length) {
855
+ return this.nodes[index].textContent;
856
+ }
857
+ else {
858
+ return '';
859
+ }
860
+ };
861
+ return TextTag;
862
+ }());
863
+ /** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
864
+ var VirtualTag = /** @class */ (function () {
865
+ function VirtualTag(_target) {
866
+ this.rules = [];
867
+ this.length = 0;
868
+ }
869
+ VirtualTag.prototype.insertRule = function (index, rule) {
870
+ if (index <= this.length) {
871
+ this.rules.splice(index, 0, rule);
872
+ this.length++;
873
+ return true;
874
+ }
875
+ else {
876
+ return false;
877
+ }
878
+ };
879
+ VirtualTag.prototype.deleteRule = function (index) {
880
+ this.rules.splice(index, 1);
881
+ this.length--;
882
+ };
883
+ VirtualTag.prototype.getRule = function (index) {
884
+ if (index < this.length) {
885
+ return this.rules[index];
886
+ }
887
+ else {
888
+ return '';
889
+ }
890
+ };
891
+ return VirtualTag;
892
+ }());
893
+
894
+ var SHOULD_REHYDRATE = IS_BROWSER;
895
+ var defaultOptions = {
896
+ isServer: !IS_BROWSER,
897
+ useCSSOMInjection: !DISABLE_SPEEDY,
898
+ };
899
+ /** Contains the main stylesheet logic for stringification and caching */
900
+ var StyleSheet = /** @class */ (function () {
901
+ function StyleSheet(options, globalStyles, names) {
902
+ if (options === void 0) { options = EMPTY_OBJECT; }
903
+ if (globalStyles === void 0) { globalStyles = {}; }
904
+ this.options = __assign(__assign({}, defaultOptions), options);
905
+ this.gs = globalStyles;
906
+ this.names = new Map(names);
907
+ this.server = !!options.isServer;
908
+ // We rehydrate only once and use the sheet that is created first
909
+ if (!this.server && IS_BROWSER && SHOULD_REHYDRATE) {
910
+ SHOULD_REHYDRATE = false;
911
+ rehydrateSheet(this);
912
+ }
913
+ }
914
+ /** Register a group ID to give it an index */
915
+ StyleSheet.registerId = function (id) {
916
+ return getGroupForId(id);
917
+ };
918
+ StyleSheet.prototype.reconstructWithOptions = function (options, withNames) {
919
+ if (withNames === void 0) { withNames = true; }
920
+ return new StyleSheet(__assign(__assign({}, this.options), options), this.gs, (withNames && this.names) || undefined);
921
+ };
922
+ StyleSheet.prototype.allocateGSInstance = function (id) {
923
+ return (this.gs[id] = (this.gs[id] || 0) + 1);
924
+ };
925
+ /** Lazily initialises a GroupedTag for when it's actually needed */
926
+ StyleSheet.prototype.getTag = function () {
927
+ return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));
928
+ };
929
+ /** Check whether a name is known for caching */
930
+ StyleSheet.prototype.hasNameForId = function (id, name) {
931
+ return this.names.has(id) && this.names.get(id).has(name);
932
+ };
933
+ /** Mark a group's name as known for caching */
934
+ StyleSheet.prototype.registerName = function (id, name) {
935
+ getGroupForId(id);
936
+ if (!this.names.has(id)) {
937
+ var groupNames = new Set();
938
+ groupNames.add(name);
939
+ this.names.set(id, groupNames);
940
+ }
941
+ else {
942
+ this.names.get(id).add(name);
943
+ }
944
+ };
945
+ /** Insert new rules which also marks the name as known */
946
+ StyleSheet.prototype.insertRules = function (id, name, rules) {
947
+ this.registerName(id, name);
948
+ this.getTag().insertRules(getGroupForId(id), rules);
949
+ };
950
+ /** Clears all cached names for a given group ID */
951
+ StyleSheet.prototype.clearNames = function (id) {
952
+ if (this.names.has(id)) {
953
+ this.names.get(id).clear();
954
+ }
955
+ };
956
+ /** Clears all rules for a given group ID */
957
+ StyleSheet.prototype.clearRules = function (id) {
958
+ this.getTag().clearGroup(getGroupForId(id));
959
+ this.clearNames(id);
960
+ };
961
+ /** Clears the entire tag which deletes all rules but not its names */
962
+ StyleSheet.prototype.clearTag = function () {
963
+ // NOTE: This does not clear the names, since it's only used during SSR
964
+ // so that we can continuously output only new rules
965
+ this.tag = undefined;
966
+ };
967
+ /** Outputs the current sheet as a CSS string with markers for SSR */
968
+ StyleSheet.prototype.toString = function () {
969
+ return outputSheet(this);
970
+ };
971
+ return StyleSheet;
972
+ }());
973
+
974
+ var COMMENT_REGEX = /^\s*\/\/.*$/gm;
975
+ var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
976
+ /**
977
+ * Serialize stylis output as an array of css strings. It is important that rules are
978
+ * separated when using CSSOM injection.
979
+ */
980
+ function serialize(children, callback) {
981
+ return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
982
+ }
983
+ function createStylisInstance(_a) {
984
+ var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
985
+ var _componentId;
986
+ var _selector;
987
+ var _selectorRegexp;
988
+ var _consecutiveSelfRefRegExp;
989
+ var selfReferenceReplacer = function (match, offset, string) {
990
+ if (
991
+ // do not replace the first occurrence if it is complex (has a modifier)
992
+ (offset === 0 ? !COMPLEX_SELECTOR_PREFIX.includes(string[_selector.length]) : true) && // no consecutive self refs (.b.b); that is a precedence boost and treated differently
993
+ !string.match(_consecutiveSelfRefRegExp)) {
994
+ return ".".concat(_componentId);
995
+ }
996
+ return match;
997
+ };
998
+ /**
999
+ * When writing a style like
1000
+ *
1001
+ * & + & {
1002
+ * color: red;
1003
+ * }
1004
+ *
1005
+ * The second ampersand should be a reference to the static component class. stylis
1006
+ * has no knowledge of static class so we have to intelligently replace the base selector.
1007
+ *
1008
+ * https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
1009
+ */
1010
+ var selfReferenceReplacementPlugin = function (element) {
1011
+ if (element.type === RULESET && element.value.includes('&')) {
1012
+ var props = element.props;
1013
+ props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
1014
+ }
1015
+ };
1016
+ var stringifyRules = function (css, selector, prefix, componentId) {
1017
+ if (selector === void 0) { selector = ''; }
1018
+ if (prefix === void 0) { prefix = ''; }
1019
+ if (componentId === void 0) { componentId = '&'; }
1020
+ var flatCSS = css.replace(COMMENT_REGEX, '');
1021
+ // stylis has no concept of state to be passed to plugins
1022
+ // but since JS is single-threaded, we can rely on that to ensure
1023
+ // these properties stay in sync with the current stylis run
1024
+ _componentId = componentId;
1025
+ _selector = selector;
1026
+ _selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
1027
+ _consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
1028
+ var middlewares = plugins.slice();
1029
+ if (options.prefix || options.prefix === undefined) {
1030
+ middlewares.unshift(prefixer);
1031
+ }
1032
+ middlewares.push(selfReferenceReplacementPlugin, stringify);
1033
+ return serialize(compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS), middleware(middlewares));
1034
+ };
1035
+ stringifyRules.hash = plugins.length
1036
+ ? plugins
1037
+ .reduce(function (acc, plugin) {
1038
+ if (!plugin.name) {
1039
+ throwStyledComponentsError(15);
1040
+ }
1041
+ return phash(acc, plugin.name);
1042
+ }, SEED$1)
1043
+ .toString()
1044
+ : '';
1045
+ return stringifyRules;
1046
+ }
1047
+
1048
+ var StyleSheetContext = React.createContext(undefined);
1049
+ var StyleSheetConsumer = StyleSheetContext.Consumer;
1050
+ var StylisContext = React.createContext(undefined);
1051
+ StylisContext.Consumer;
1052
+ var mainSheet = new StyleSheet();
1053
+ var mainStylis = createStylisInstance();
1054
+ function useStyleSheet() {
1055
+ return useContext(StyleSheetContext) || mainSheet;
1056
+ }
1057
+ function useStylis() {
1058
+ return useContext(StylisContext) || mainStylis;
1059
+ }
1060
+ function StyleSheetManager(props) {
1061
+ var _a = useState(props.stylisPlugins), plugins = _a[0], setPlugins = _a[1];
1062
+ var contextStyleSheet = useStyleSheet();
1063
+ var styleSheet = useMemo(function () {
1064
+ var sheet = contextStyleSheet;
1065
+ if (props.sheet) {
1066
+ // eslint-disable-next-line prefer-destructuring
1067
+ sheet = props.sheet;
1068
+ }
1069
+ else if (props.target) {
1070
+ sheet = sheet.reconstructWithOptions({ target: props.target }, false);
1071
+ }
1072
+ if (props.disableCSSOMInjection) {
1073
+ sheet = sheet.reconstructWithOptions({ useCSSOMInjection: false });
1074
+ }
1075
+ return sheet;
1076
+ }, [props.disableCSSOMInjection, props.sheet, props.target]);
1077
+ var stylis = useMemo(function () {
1078
+ return createStylisInstance({
1079
+ options: { prefix: !props.disableVendorPrefixes },
1080
+ plugins: plugins,
1081
+ });
1082
+ }, [props.disableVendorPrefixes, plugins]);
1083
+ useEffect(function () {
1084
+ if (!shallowequal(plugins, props.stylisPlugins))
1085
+ setPlugins(props.stylisPlugins);
1086
+ }, [props.stylisPlugins]);
1087
+ return (React.createElement(StyleSheetContext.Provider, { value: styleSheet },
1088
+ React.createElement(StylisContext.Provider, { value: stylis }, process.env.NODE_ENV !== 'production'
1089
+ ? React.Children.only(props.children)
1090
+ : props.children)));
1091
+ }
1092
+
1093
+ var Keyframes = /** @class */ (function () {
1094
+ function Keyframes(name, rules) {
1095
+ var _this = this;
1096
+ this.inject = function (styleSheet, stylisInstance) {
1097
+ if (stylisInstance === void 0) { stylisInstance = mainStylis; }
1098
+ var resolvedName = _this.name + stylisInstance.hash;
1099
+ if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
1100
+ styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
1101
+ }
1102
+ };
1103
+ this.toString = function () {
1104
+ throw throwStyledComponentsError(12, String(_this.name));
1105
+ };
1106
+ this.name = name;
1107
+ this.id = "sc-keyframes-".concat(name);
1108
+ this.rules = rules;
1109
+ }
1110
+ Keyframes.prototype.getName = function (stylisInstance) {
1111
+ if (stylisInstance === void 0) { stylisInstance = mainStylis; }
1112
+ return this.name + stylisInstance.hash;
1113
+ };
1114
+ return Keyframes;
1115
+ }());
1116
+
1117
+ // Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
1118
+ function addUnitIfNeeded(name, value) {
1119
+ // https://github.com/amilajack/eslint-plugin-flowtype-errors/issues/133
1120
+ if (value == null || typeof value === 'boolean' || value === '') {
1121
+ return '';
1122
+ }
1123
+ if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
1124
+ return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
1125
+ }
1126
+ return String(value).trim();
1127
+ }
1128
+
1129
+ /**
1130
+ * inlined version of
1131
+ * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
1132
+ */
1133
+ var uppercaseCheck = /([A-Z])/;
1134
+ var uppercasePattern = /([A-Z])/g;
1135
+ var msPattern = /^ms-/;
1136
+ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
1137
+ /**
1138
+ * Hyphenates a camelcased CSS property name, for example:
1139
+ *
1140
+ * > hyphenateStyleName('backgroundColor')
1141
+ * < "background-color"
1142
+ * > hyphenateStyleName('MozTransition')
1143
+ * < "-moz-transition"
1144
+ * > hyphenateStyleName('msTransition')
1145
+ * < "-ms-transition"
1146
+ *
1147
+ * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
1148
+ * is converted to `-ms-`.
1149
+ */
1150
+ function hyphenateStyleName(string) {
1151
+ return uppercaseCheck.test(string)
1152
+ ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
1153
+ : string;
1154
+ }
1155
+
1156
+ function isFunction(test) {
1157
+ return typeof test === 'function';
1158
+ }
1159
+
1160
+ function isStatelessFunction(test) {
1161
+ return typeof test === 'function' && !(test.prototype && test.prototype.isReactComponent);
1162
+ }
1163
+
1164
+ /**
1165
+ * It's falsish not falsy because 0 is allowed.
1166
+ */
1167
+ var isFalsish = function (chunk) {
1168
+ return chunk === undefined || chunk === null || chunk === false || chunk === '';
1169
+ };
1170
+ var objToCssArray = function (obj, prevKey) {
1171
+ var rules = [];
1172
+ for (var key in obj) {
1173
+ if (!obj.hasOwnProperty(key) || isFalsish(obj[key]))
1174
+ continue;
1175
+ if ((Array.isArray(obj[key]) && obj[key].isCss) || isFunction(obj[key])) {
1176
+ rules.push("".concat(hyphenateStyleName(key), ":"), obj[key], ';');
1177
+ }
1178
+ else if (isPlainObject(obj[key])) {
1179
+ rules.push.apply(rules, objToCssArray(obj[key], key));
1180
+ }
1181
+ else {
1182
+ rules.push("".concat(hyphenateStyleName(key), ": ").concat(addUnitIfNeeded(key, obj[key]), ";"));
1183
+ }
1184
+ }
1185
+ return prevKey ? __spreadArray(__spreadArray(["".concat(prevKey, " {")], rules, true), ['}'], false) : rules;
1186
+ };
1187
+ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
1188
+ if (Array.isArray(chunk)) {
1189
+ var ruleSet = [];
1190
+ for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
1191
+ result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
1192
+ if (result === '')
1193
+ continue;
1194
+ else if (Array.isArray(result))
1195
+ ruleSet.push.apply(ruleSet, result);
1196
+ else
1197
+ ruleSet.push(result);
1198
+ }
1199
+ return ruleSet;
1200
+ }
1201
+ if (isFalsish(chunk)) {
1202
+ return '';
1203
+ }
1204
+ /* Handle other components */
1205
+ if (isStyledComponent(chunk)) {
1206
+ return ".".concat(chunk.styledComponentId);
1207
+ }
1208
+ /* Either execute or defer the function */
1209
+ if (isFunction(chunk)) {
1210
+ if (isStatelessFunction(chunk) && executionContext) {
1211
+ var chunkFn = chunk;
1212
+ var result = chunkFn(executionContext);
1213
+ if (process.env.NODE_ENV !== 'production' &&
1214
+ typeof result === 'object' &&
1215
+ !Array.isArray(result) &&
1216
+ !(result instanceof Keyframes) &&
1217
+ !isPlainObject(result)) {
1218
+ // eslint-disable-next-line no-console
1219
+ console.error("".concat(getComponentName(chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
1220
+ }
1221
+ return flatten(result, executionContext, styleSheet, stylisInstance);
1222
+ }
1223
+ else
1224
+ return chunk;
1225
+ }
1226
+ if (chunk instanceof Keyframes) {
1227
+ if (styleSheet) {
1228
+ chunk.inject(styleSheet, stylisInstance);
1229
+ return chunk.getName(stylisInstance);
1230
+ }
1231
+ else
1232
+ return chunk;
1233
+ }
1234
+ /* Handle objects */
1235
+ return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
1236
+ }
1237
+
1238
+ function isStaticRules(rules) {
1239
+ for (var i = 0; i < rules.length; i += 1) {
1240
+ var rule = rules[i];
1241
+ if (isFunction(rule) &&
1242
+ !isStyledComponent(rule)) {
1243
+ // functions are allowed to be static if they're just being
1244
+ // used to get the classname of a nested styled component
1245
+ return false;
1246
+ }
1247
+ }
1248
+ return true;
1249
+ }
1250
+
1251
+ var SEED = hash(SC_VERSION);
1252
+ /**
1253
+ * ComponentStyle is all the CSS-specific stuff, not the React-specific stuff.
1254
+ */
1255
+ var ComponentStyle = /** @class */ (function () {
1256
+ function ComponentStyle(rules, componentId, baseStyle) {
1257
+ this.names = [];
1258
+ this.rules = rules;
1259
+ this.staticRulesId = '';
1260
+ this.isStatic =
1261
+ process.env.NODE_ENV === 'production' &&
1262
+ (baseStyle === undefined || baseStyle.isStatic) &&
1263
+ isStaticRules(rules);
1264
+ this.componentId = componentId;
1265
+ // SC_VERSION gives us isolation between multiple runtimes on the page at once
1266
+ // this is improved further with use of the babel plugin "namespace" feature
1267
+ this.baseHash = phash(SEED, componentId);
1268
+ this.baseStyle = baseStyle;
1269
+ // NOTE: This registers the componentId, which ensures a consistent order
1270
+ // for this component's styles compared to others
1271
+ StyleSheet.registerId(componentId);
1272
+ }
1273
+ /*
1274
+ * Flattens a rule set into valid CSS
1275
+ * Hashes it, wraps the whole chunk in a .hash1234 {}
1276
+ * Returns the hash to be injected on render()
1277
+ * */
1278
+ ComponentStyle.prototype.generateAndInjectStyles = function (executionContext, styleSheet, stylis) {
1279
+ var componentId = this.componentId;
1280
+ this.names.length = 0;
1281
+ if (this.baseStyle) {
1282
+ this.names.push(this.baseStyle.generateAndInjectStyles(executionContext, styleSheet, stylis));
1283
+ }
1284
+ // force dynamic classnames if user-supplied stylis plugins are in use
1285
+ if (this.isStatic && !stylis.hash) {
1286
+ if (this.staticRulesId && styleSheet.hasNameForId(componentId, this.staticRulesId)) {
1287
+ this.names.push(this.staticRulesId);
1288
+ }
1289
+ else {
1290
+ var cssStatic = flatten(this.rules, executionContext, styleSheet, stylis).join('');
1291
+ var name_1 = generateAlphabeticName(phash(this.baseHash, cssStatic) >>> 0);
1292
+ if (!styleSheet.hasNameForId(componentId, name_1)) {
1293
+ var cssStaticFormatted = stylis(cssStatic, ".".concat(name_1), undefined, componentId);
1294
+ styleSheet.insertRules(componentId, name_1, cssStaticFormatted);
1295
+ }
1296
+ this.names.push(name_1);
1297
+ this.staticRulesId = name_1;
1298
+ }
1299
+ }
1300
+ else {
1301
+ var length_1 = this.rules.length;
1302
+ var dynamicHash = phash(this.baseHash, stylis.hash);
1303
+ var css = '';
1304
+ for (var i = 0; i < length_1; i++) {
1305
+ var partRule = this.rules[i];
1306
+ if (typeof partRule === 'string') {
1307
+ css += partRule;
1308
+ if (process.env.NODE_ENV !== 'production')
1309
+ dynamicHash = phash(dynamicHash, partRule);
1310
+ }
1311
+ else if (partRule) {
1312
+ var partChunk = flatten(partRule, executionContext, styleSheet, stylis);
1313
+ var partString = Array.isArray(partChunk) ? partChunk.join('') : partChunk;
1314
+ dynamicHash = phash(dynamicHash, partString);
1315
+ css += partString;
1316
+ }
1317
+ }
1318
+ if (css) {
1319
+ var name_2 = generateAlphabeticName(dynamicHash >>> 0);
1320
+ if (!styleSheet.hasNameForId(componentId, name_2)) {
1321
+ var cssFormatted = stylis(css, ".".concat(name_2), undefined, componentId);
1322
+ styleSheet.insertRules(componentId, name_2, cssFormatted);
1323
+ }
1324
+ this.names.push(name_2);
1325
+ }
1326
+ }
1327
+ return this.names.join(' ');
1328
+ };
1329
+ return ComponentStyle;
1330
+ }());
1331
+
1332
+ var ThemeContext = React.createContext(undefined);
1333
+ var ThemeConsumer = ThemeContext.Consumer;
1334
+ function mergeTheme(theme, outerTheme) {
1335
+ if (!theme) {
1336
+ throw throwStyledComponentsError(14);
1337
+ }
1338
+ if (isFunction(theme)) {
1339
+ var themeFn = theme;
1340
+ var mergedTheme = themeFn(outerTheme);
1341
+ if (process.env.NODE_ENV !== 'production' &&
1342
+ (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')) {
1343
+ throw throwStyledComponentsError(7);
1344
+ }
1345
+ return mergedTheme;
1346
+ }
1347
+ if (Array.isArray(theme) || typeof theme !== 'object') {
1348
+ throw throwStyledComponentsError(8);
1349
+ }
1350
+ return outerTheme ? __assign(__assign({}, outerTheme), theme) : theme;
1351
+ }
1352
+ /**
1353
+ * Provide a theme to an entire react component tree via context
1354
+ */
1355
+ function ThemeProvider(props) {
1356
+ var outerTheme = useContext(ThemeContext);
1357
+ var themeContext = useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
1358
+ if (!props.children) {
1359
+ return null;
1360
+ }
1361
+ return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
1362
+ }
1363
+
1364
+ var identifiers = {};
1365
+ /* We depend on components having unique IDs */
1366
+ function generateId(displayName, parentComponentId) {
1367
+ var name = typeof displayName !== 'string' ? 'sc' : escape(displayName);
1368
+ // Ensure that no displayName can lead to duplicate componentIds
1369
+ identifiers[name] = (identifiers[name] || 0) + 1;
1370
+ var componentId = "".concat(name, "-").concat(generateComponentId(
1371
+ // SC_VERSION gives us isolation between multiple runtimes on the page at once
1372
+ // this is improved further with use of the babel plugin "namespace" feature
1373
+ SC_VERSION + name + identifiers[name]));
1374
+ return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
1375
+ }
1376
+ function useResolvedAttrs(theme, props, attrs) {
1377
+ if (theme === void 0) { theme = EMPTY_OBJECT; }
1378
+ // NOTE: can't memoize this
1379
+ // returns [context, resolvedAttrs]
1380
+ // where resolvedAttrs is only the things injected by the attrs themselves
1381
+ var context = __assign(__assign({}, props), { theme: theme });
1382
+ attrs.forEach(function (attrDef) {
1383
+ // @ts-expect-error narrowing isn't working properly for some reason
1384
+ var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
1385
+ var key;
1386
+ /* eslint-disable guard-for-in */
1387
+ for (key in resolvedAttrDef) {
1388
+ // @ts-expect-error bad types
1389
+ context[key] =
1390
+ key === 'className'
1391
+ ? joinStrings(context[key], resolvedAttrDef[key])
1392
+ : key === 'style'
1393
+ ? __assign(__assign({}, context[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
1394
+ }
1395
+ /* eslint-enable guard-for-in */
1396
+ });
1397
+ return context;
1398
+ }
1399
+ function useInjectedStyle(componentStyle, isStatic, resolvedAttrs, warnTooManyClasses) {
1400
+ var styleSheet = useStyleSheet();
1401
+ var stylis = useStylis();
1402
+ var className = isStatic
1403
+ ? componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet, stylis)
1404
+ : componentStyle.generateAndInjectStyles(resolvedAttrs, styleSheet, stylis);
1405
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1406
+ if (process.env.NODE_ENV !== 'production')
1407
+ useDebugValue(className);
1408
+ if (process.env.NODE_ENV !== 'production' && !isStatic && warnTooManyClasses) {
1409
+ warnTooManyClasses(className);
1410
+ }
1411
+ return className;
1412
+ }
1413
+ function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStatic) {
1414
+ var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, shouldForwardProp = forwardedComponent.shouldForwardProp, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
1415
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1416
+ if (process.env.NODE_ENV !== 'production')
1417
+ useDebugValue(styledComponentId);
1418
+ // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
1419
+ // but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
1420
+ // should be an immutable value, but behave for now.
1421
+ var theme = determineTheme(props, useContext(ThemeContext), defaultProps);
1422
+ var context = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs);
1423
+ var generatedClassName = useInjectedStyle(componentStyle, isStatic, context, process.env.NODE_ENV !== 'production' ? forwardedComponent.warnTooManyClasses : undefined);
1424
+ var refToForward = forwardedRef;
1425
+ var elementToBeCreated = context.$as || context.as || target;
1426
+ var isTargetTag = isTag(elementToBeCreated);
1427
+ var propsForElement = {};
1428
+ // eslint-disable-next-line guard-for-in
1429
+ for (var key in context) {
1430
+ if (key[0] === '$' || key === 'as' || key === 'theme')
1431
+ continue;
1432
+ else if (key === 'forwardedAs') {
1433
+ propsForElement.as = context[key];
1434
+ }
1435
+ else if (shouldForwardProp ? shouldForwardProp(key, elementToBeCreated) : true) {
1436
+ // Don't pass through non HTML tags through to HTML elements
1437
+ propsForElement[key] = context[key];
1438
+ }
1439
+ }
1440
+ propsForElement[
1441
+ // handle custom elements which React doesn't properly alias
1442
+ isTargetTag &&
1443
+ domElements.indexOf(elementToBeCreated) === -1
1444
+ ? 'class'
1445
+ : 'className'] = foldedComponentIds
1446
+ .concat(styledComponentId, (generatedClassName !== styledComponentId ? generatedClassName : null), context.className)
1447
+ .filter(Boolean)
1448
+ .join(' ');
1449
+ propsForElement.ref = refToForward;
1450
+ return createElement(elementToBeCreated, propsForElement);
1451
+ }
1452
+ function createStyledComponent(target, options, rules) {
1453
+ var isTargetStyledComp = isStyledComponent(target);
1454
+ var styledComponentTarget = target;
1455
+ var isCompositeComponent = !isTag(target);
1456
+ var _a = options.attrs, attrs = _a === void 0 ? EMPTY_ARRAY : _a, _b = options.componentId, componentId = _b === void 0 ? generateId(options.displayName, options.parentComponentId) : _b, _c = options.displayName, displayName = _c === void 0 ? generateDisplayName(target) : _c;
1457
+ var styledComponentId = options.displayName && options.componentId
1458
+ ? "".concat(escape(options.displayName), "-").concat(options.componentId)
1459
+ : options.componentId || componentId;
1460
+ // fold the underlying StyledComponent attrs up (implicit extend)
1461
+ var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
1462
+ ? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
1463
+ : attrs;
1464
+ var shouldForwardProp = options.shouldForwardProp;
1465
+ if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
1466
+ var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
1467
+ if (options.shouldForwardProp) {
1468
+ var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1469
+ // compose nested shouldForwardProp calls
1470
+ shouldForwardProp = function (prop, elementToBeCreated) {
1471
+ return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1472
+ passedShouldForwardPropFn_1(prop, elementToBeCreated);
1473
+ };
1474
+ }
1475
+ else {
1476
+ shouldForwardProp = shouldForwardPropFn_1;
1477
+ }
1478
+ }
1479
+ var componentStyle = new ComponentStyle(rules, styledComponentId, isTargetStyledComp ? styledComponentTarget.componentStyle : undefined);
1480
+ // statically styled-components don't need to build an execution context object,
1481
+ // and shouldn't be increasing the number of class names
1482
+ var isStatic = componentStyle.isStatic && attrs.length === 0;
1483
+ function forwardRef(props, ref) {
1484
+ // eslint-disable-next-line
1485
+ return useStyledComponentImpl(WrappedStyledComponent, props, ref, isStatic);
1486
+ }
1487
+ forwardRef.displayName = displayName;
1488
+ /**
1489
+ * forwardRef creates a new interim component, which we'll take advantage of
1490
+ * instead of extending ParentComponent to create _another_ interim class
1491
+ */
1492
+ var WrappedStyledComponent = React.forwardRef(forwardRef);
1493
+ WrappedStyledComponent.attrs = finalAttrs;
1494
+ WrappedStyledComponent.componentStyle = componentStyle;
1495
+ WrappedStyledComponent.displayName = displayName;
1496
+ WrappedStyledComponent.shouldForwardProp = shouldForwardProp;
1497
+ // this static is used to preserve the cascade of static classes for component selector
1498
+ // purposes; this is especially important with usage of the css prop
1499
+ WrappedStyledComponent.foldedComponentIds = isTargetStyledComp
1500
+ ? styledComponentTarget.foldedComponentIds.concat(styledComponentTarget.styledComponentId)
1501
+ : EMPTY_ARRAY;
1502
+ WrappedStyledComponent.styledComponentId = styledComponentId;
1503
+ // fold the underlying StyledComponent target up since we folded the styles
1504
+ WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
1505
+ WrappedStyledComponent.withComponent = function withComponent(tag) {
1506
+ var previousComponentId = options.componentId, optionsToCopy = __rest(options, ["componentId"]);
1507
+ var newComponentId = previousComponentId &&
1508
+ "".concat(previousComponentId, "-").concat(isTag(tag) ? tag : escape(getComponentName(tag)));
1509
+ var newOptions = __assign(__assign({}, optionsToCopy), { attrs: finalAttrs, componentId: newComponentId });
1510
+ return createStyledComponent(tag, newOptions, rules);
1511
+ };
1512
+ Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
1513
+ get: function () {
1514
+ return this._foldedDefaultProps;
1515
+ },
1516
+ set: function (obj) {
1517
+ this._foldedDefaultProps = isTargetStyledComp
1518
+ ? mixinDeep({}, styledComponentTarget.defaultProps, obj)
1519
+ : obj;
1520
+ },
1521
+ });
1522
+ if (process.env.NODE_ENV !== 'production') {
1523
+ checkDynamicCreation(displayName, styledComponentId);
1524
+ WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
1525
+ }
1526
+ WrappedStyledComponent.toString = function () { return ".".concat(WrappedStyledComponent.styledComponentId); };
1527
+ if (isCompositeComponent) {
1528
+ var compositeComponentTarget = target;
1529
+ hoistNonReactStatics(WrappedStyledComponent, compositeComponentTarget, {
1530
+ // all SC-specific things should not be hoisted
1531
+ attrs: true,
1532
+ componentStyle: true,
1533
+ displayName: true,
1534
+ foldedComponentIds: true,
1535
+ shouldForwardProp: true,
1536
+ styledComponentId: true,
1537
+ target: true,
1538
+ withComponent: true,
1539
+ });
1540
+ }
1541
+ return WrappedStyledComponent;
1542
+ }
1543
+
1544
+ function interleave(strings, interpolations) {
1545
+ var result = [strings[0]];
1546
+ for (var i = 0, len = interpolations.length; i < len; i += 1) {
1547
+ result.push(interpolations[i], strings[i + 1]);
1548
+ }
1549
+ return result;
1550
+ }
1551
+
1552
+ /**
1553
+ * Used when flattening object styles to determine if we should
1554
+ * expand an array of styles.
1555
+ */
1556
+ var addTag = function (arg) {
1557
+ if (Array.isArray(arg)) {
1558
+ // eslint-disable-next-line no-param-reassign
1559
+ arg.isCss = true;
1560
+ }
1561
+ return arg;
1562
+ };
1563
+ function css(styles) {
1564
+ var interpolations = [];
1565
+ for (var _i = 1; _i < arguments.length; _i++) {
1566
+ interpolations[_i - 1] = arguments[_i];
1567
+ }
1568
+ if (isFunction(styles) || isPlainObject(styles)) {
1569
+ var styleFunctionOrObject = styles;
1570
+ return addTag(flatten(interleave(EMPTY_ARRAY, __spreadArray([
1571
+ styleFunctionOrObject
1572
+ ], interpolations, true))));
1573
+ }
1574
+ var styleStringArray = styles;
1575
+ if (interpolations.length === 0 &&
1576
+ styleStringArray.length === 1 &&
1577
+ typeof styleStringArray[0] === 'string') {
1578
+ return styleStringArray;
1579
+ }
1580
+ return addTag(flatten(interleave(styleStringArray, interpolations)));
1581
+ }
1582
+
1583
+ function constructWithOptions(componentConstructor, tag, options) {
1584
+ if (options === void 0) { options = EMPTY_OBJECT; }
1585
+ // We trust that the tag is a valid component as long as it isn't falsish
1586
+ // Typically the tag here is a string or function (i.e. class or pure function component)
1587
+ // However a component may also be an object if it uses another utility, e.g. React.memo
1588
+ // React will output an appropriate warning however if the `tag` isn't valid
1589
+ if (!tag) {
1590
+ throw throwStyledComponentsError(1, tag);
1591
+ }
1592
+ /* This is callable directly as a template function */
1593
+ var templateFunction = function (initialStyles) {
1594
+ var interpolations = [];
1595
+ for (var _i = 1; _i < arguments.length; _i++) {
1596
+ interpolations[_i - 1] = arguments[_i];
1597
+ }
1598
+ return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], interpolations, false)));
1599
+ };
1600
+ /* Modify/inject new props at runtime */
1601
+ templateFunction.attrs = function (attrs) {
1602
+ return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), { attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean) }));
1603
+ };
1604
+ /**
1605
+ * If config methods are called, wrap up a new template function and merge options */
1606
+ templateFunction.withConfig = function (config) {
1607
+ return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), config));
1608
+ };
1609
+ return templateFunction;
1610
+ }
1611
+
1612
+ var baseStyled = function (tag) {
1613
+ return constructWithOptions(createStyledComponent, tag);
1614
+ };
1615
+ var styled = baseStyled;
1616
+ // Shorthands for all valid HTML Elements
1617
+ domElements.forEach(function (domElement) {
1618
+ // @ts-expect-error someday they'll handle imperative assignment properly
1619
+ styled[domElement] = baseStyled(domElement);
1620
+ });
1621
+
1622
+ var GlobalStyle = /** @class */ (function () {
1623
+ function GlobalStyle(rules, componentId) {
1624
+ this.rules = rules;
1625
+ this.componentId = componentId;
1626
+ this.isStatic = isStaticRules(rules);
1627
+ // pre-register the first instance to ensure global styles
1628
+ // load before component ones
1629
+ StyleSheet.registerId(this.componentId + 1);
1630
+ }
1631
+ GlobalStyle.prototype.createStyles = function (instance, executionContext, styleSheet, stylis) {
1632
+ var flatCSS = flatten(this.rules, executionContext, styleSheet, stylis);
1633
+ var css = stylis(flatCSS.join(''), '');
1634
+ var id = this.componentId + instance;
1635
+ // NOTE: We use the id as a name as well, since these rules never change
1636
+ styleSheet.insertRules(id, id, css);
1637
+ };
1638
+ GlobalStyle.prototype.removeStyles = function (instance, styleSheet) {
1639
+ styleSheet.clearRules(this.componentId + instance);
1640
+ };
1641
+ GlobalStyle.prototype.renderStyles = function (instance, executionContext, styleSheet, stylis) {
1642
+ if (instance > 2)
1643
+ StyleSheet.registerId(this.componentId + instance);
1644
+ // NOTE: Remove old styles, then inject the new ones
1645
+ this.removeStyles(instance, styleSheet);
1646
+ this.createStyles(instance, executionContext, styleSheet, stylis);
1647
+ };
1648
+ return GlobalStyle;
1649
+ }());
1650
+
1651
+ function createGlobalStyle(strings) {
1652
+ var interpolations = [];
1653
+ for (var _i = 1; _i < arguments.length; _i++) {
1654
+ interpolations[_i - 1] = arguments[_i];
1655
+ }
1656
+ var rules = css.apply(void 0, __spreadArray([strings], interpolations, false));
1657
+ var styledComponentId = "sc-global-".concat(generateComponentId(JSON.stringify(rules)));
1658
+ var globalStyle = new GlobalStyle(rules, styledComponentId);
1659
+ if (process.env.NODE_ENV !== 'production') {
1660
+ checkDynamicCreation(styledComponentId);
1661
+ }
1662
+ var GlobalStyleComponent = function (props) {
1663
+ var styleSheet = useStyleSheet();
1664
+ var stylis = useStylis();
1665
+ var theme = React.useContext(ThemeContext);
1666
+ var instanceRef = React.useRef(styleSheet.allocateGSInstance(styledComponentId));
1667
+ var instance = instanceRef.current;
1668
+ if (process.env.NODE_ENV !== 'production' && React.Children.count(props.children)) {
1669
+ // eslint-disable-next-line no-console
1670
+ console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
1671
+ }
1672
+ if (process.env.NODE_ENV !== 'production' &&
1673
+ rules.some(function (rule) { return typeof rule === 'string' && rule.indexOf('@import') !== -1; })) {
1674
+ // eslint-disable-next-line no-console
1675
+ console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app.");
1676
+ }
1677
+ if (styleSheet.server) {
1678
+ renderStyles(instance, props, styleSheet, theme, stylis);
1679
+ }
1680
+ {
1681
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1682
+ // @ts-expect-error still using React 17 types for the time being
1683
+ (React.useInsertionEffect || React.useLayoutEffect)(function () {
1684
+ if (!styleSheet.server) {
1685
+ renderStyles(instance, props, styleSheet, theme, stylis);
1686
+ return function () { return globalStyle.removeStyles(instance, styleSheet); };
1687
+ }
1688
+ }, [instance, props, styleSheet, theme, stylis]);
1689
+ }
1690
+ return null;
1691
+ };
1692
+ function renderStyles(instance, props, styleSheet, theme, stylis) {
1693
+ if (globalStyle.isStatic) {
1694
+ globalStyle.renderStyles(instance, STATIC_EXECUTION_CONTEXT, styleSheet, stylis);
1695
+ }
1696
+ else {
1697
+ var context = __assign(__assign({}, props), { theme: determineTheme(props, theme, GlobalStyleComponent.defaultProps) });
1698
+ globalStyle.renderStyles(instance, context, styleSheet, stylis);
1699
+ }
1700
+ }
1701
+ return React.memo(GlobalStyleComponent);
1702
+ }
1703
+
1704
+ function keyframes(strings) {
1705
+ var interpolations = [];
1706
+ for (var _i = 1; _i < arguments.length; _i++) {
1707
+ interpolations[_i - 1] = arguments[_i];
1708
+ }
1709
+ /* Warning if you've used keyframes on React Native */
1710
+ if (process.env.NODE_ENV !== 'production' &&
1711
+ typeof navigator !== 'undefined' &&
1712
+ navigator.product === 'ReactNative') {
1713
+ // eslint-disable-next-line no-console
1714
+ console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
1715
+ }
1716
+ var rules = css.apply(void 0, __spreadArray([strings], interpolations, false)).join('');
1717
+ var name = generateComponentId(rules);
1718
+ return new Keyframes(name, rules);
1719
+ }
1720
+
1721
+ function withTheme(Component) {
1722
+ var WithTheme = React.forwardRef(function (props, ref) {
1723
+ var theme = React.useContext(ThemeContext);
1724
+ var themeProp = determineTheme(props, theme, Component.defaultProps);
1725
+ if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
1726
+ // eslint-disable-next-line no-console
1727
+ console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
1728
+ }
1729
+ return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
1730
+ });
1731
+ WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1732
+ return hoistNonReactStatics(WithTheme, Component);
1733
+ }
1734
+
1735
+ var useTheme = function () { return useContext(ThemeContext); };
1736
+
1737
+ var ServerStyleSheet = /** @class */ (function () {
1738
+ function ServerStyleSheet() {
1739
+ var _this = this;
1740
+ this._emitSheetCSS = function () {
1741
+ var css = _this.instance.toString();
1742
+ var nonce = getNonce();
1743
+ var attrs = [
1744
+ nonce && "nonce=\"".concat(nonce, "\""),
1745
+ "".concat(SC_ATTR, "=\"true\""),
1746
+ "".concat(SC_ATTR_VERSION, "=\"").concat(SC_VERSION, "\""),
1747
+ ];
1748
+ var htmlAttr = attrs.filter(Boolean).join(' ');
1749
+ return "<style ".concat(htmlAttr, ">").concat(css, "</style>");
1750
+ };
1751
+ this.getStyleTags = function () {
1752
+ if (_this.sealed) {
1753
+ throw throwStyledComponentsError(2);
1754
+ }
1755
+ return _this._emitSheetCSS();
1756
+ };
1757
+ this.getStyleElement = function () {
1758
+ var _a;
1759
+ if (_this.sealed) {
1760
+ throw throwStyledComponentsError(2);
1761
+ }
1762
+ var props = (_a = {},
1763
+ _a[SC_ATTR] = '',
1764
+ _a[SC_ATTR_VERSION] = SC_VERSION,
1765
+ _a.dangerouslySetInnerHTML = {
1766
+ __html: _this.instance.toString(),
1767
+ },
1768
+ _a);
1769
+ var nonce = getNonce();
1770
+ if (nonce) {
1771
+ props.nonce = nonce;
1772
+ }
1773
+ // v4 returned an array for this fn, so we'll do the same for v5 for backward compat
1774
+ return [React.createElement("style", __assign({}, props, { key: "sc-0-0" }))];
1775
+ };
1776
+ this.seal = function () {
1777
+ _this.sealed = true;
1778
+ };
1779
+ this.instance = new StyleSheet({ isServer: true });
1780
+ this.sealed = false;
1781
+ }
1782
+ ServerStyleSheet.prototype.collectStyles = function (children) {
1783
+ if (this.sealed) {
1784
+ throw throwStyledComponentsError(2);
1785
+ }
1786
+ return React.createElement(StyleSheetManager, { sheet: this.instance }, children);
1787
+ };
1788
+ // eslint-disable-next-line consistent-return
1789
+ // @ts-expect-error alternate return types are not possible due to code transformation
1790
+ ServerStyleSheet.prototype.interleaveWithNodeStream = function (input) {
1791
+ {
1792
+ throw throwStyledComponentsError(3);
1793
+ }
1794
+ };
1795
+ return ServerStyleSheet;
1796
+ }());
1797
+
1798
+ /* eslint-disable */
1799
+ var __PRIVATE__ = {
1800
+ StyleSheet: StyleSheet,
1801
+ mainSheet: mainSheet,
1802
+ };
1803
+
1804
+ /* Import singletons */
1805
+ /* Warning if you've imported this file on React Native */
1806
+ if (process.env.NODE_ENV !== 'production' &&
1807
+ typeof navigator !== 'undefined' &&
1808
+ navigator.product === 'ReactNative') {
1809
+ // eslint-disable-next-line no-console
1810
+ console.warn("It looks like you've imported 'styled-components' on React Native.\n" +
1811
+ "Perhaps you're looking to import 'styled-components/native'?\n" +
1812
+ 'Read more about this at https://www.styled-components.com/docs/basics#react-native');
1813
+ }
1814
+ /* Warning if there are several instances of styled-components */
1815
+ if (process.env.NODE_ENV !== 'production' &&
1816
+ process.env.NODE_ENV !== 'test' &&
1817
+ typeof window !== 'undefined') {
1818
+ window['__styled-components-init__'] || (window['__styled-components-init__'] = 0);
1819
+ if (window['__styled-components-init__'] === 1) {
1820
+ // eslint-disable-next-line no-console
1821
+ console.warn("It looks like there are several instances of 'styled-components' initialized in this application. " +
1822
+ 'This may cause dynamic styles to not render properly, errors during the rehydration process, ' +
1823
+ 'a missing theme prop, and makes your application bigger without good reason.\n\n' +
1824
+ 'See https://s-c.sh/2BAXzed for more info.');
1825
+ }
1826
+ window['__styled-components-init__'] += 1;
1827
+ }
1828
+
1829
+ export { ServerStyleSheet, StyleSheetConsumer, StyleSheetContext, StyleSheetManager, ThemeConsumer, ThemeContext, ThemeProvider, __PRIVATE__, createGlobalStyle, css, styled as default, isStyledComponent, keyframes, useTheme, SC_VERSION as version, withTheme };
2
1830
  //# sourceMappingURL=styled-components.browser.esm.js.map