1import { P as PropTypes } from './index-54472d17.js'; 2import { g as getDefaultExportFromCjs } from './ort-bc46c4ad.js'; 3import { r as reactExports, R as React$1 } from './index-7eddb355.js'; 4 5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 6 7var React = reactExports; 8var React__default = _interopDefault(React); 9 10function _defineProperty(obj, key, value) { 11 if (key in obj) { 12 Object.defineProperty(obj, key, { 13 value: value, 14 enumerable: true, 15 configurable: true, 16 writable: true 17 }); 18 } else { 19 obj[key] = value; 20 } 21 22 return obj; 23} 24 25function _inheritsLoose(subClass, superClass) { 26 subClass.prototype = Object.create(superClass.prototype); 27 subClass.prototype.constructor = subClass; 28 subClass.__proto__ = superClass; 29} 30 31var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); 32function withSideEffect(reducePropsToState, handleStateChangeOnClient, mapStateOnServer) { 33 if (typeof reducePropsToState !== 'function') { 34 throw new Error('Expected reducePropsToState to be a function.'); 35 } 36 37 if (typeof handleStateChangeOnClient !== 'function') { 38 throw new Error('Expected handleStateChangeOnClient to be a function.'); 39 } 40 41 if (typeof mapStateOnServer !== 'undefined' && typeof mapStateOnServer !== 'function') { 42 throw new Error('Expected mapStateOnServer to either be undefined or a function.'); 43 } 44 45 function getDisplayName(WrappedComponent) { 46 return WrappedComponent.displayName || WrappedComponent.name || 'Component'; 47 } 48 49 return function wrap(WrappedComponent) { 50 if (typeof WrappedComponent !== 'function') { 51 throw new Error('Expected WrappedComponent to be a React component.'); 52 } 53 54 var mountedInstances = []; 55 var state; 56 57 function emitChange() { 58 state = reducePropsToState(mountedInstances.map(function (instance) { 59 return instance.props; 60 })); 61 62 if (SideEffect.canUseDOM) { 63 handleStateChangeOnClient(state); 64 } else if (mapStateOnServer) { 65 state = mapStateOnServer(state); 66 } 67 } 68 69 var SideEffect = 70 /*#__PURE__*/ 71 function (_PureComponent) { 72 _inheritsLoose(SideEffect, _PureComponent); 73 74 function SideEffect() { 75 return _PureComponent.apply(this, arguments) || this; 76 } 77 78 // Try to use displayName of wrapped component 79 // Expose canUseDOM so tests can monkeypatch it 80 SideEffect.peek = function peek() { 81 return state; 82 }; 83 84 SideEffect.rewind = function rewind() { 85 if (SideEffect.canUseDOM) { 86 throw new Error('You may only call rewind() on the server. Call peek() to read the current state.'); 87 } 88 89 var recordedState = state; 90 state = undefined; 91 mountedInstances = []; 92 return recordedState; 93 }; 94 95 var _proto = SideEffect.prototype; 96 97 _proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() { 98 mountedInstances.push(this); 99 emitChange(); 100 }; 101 102 _proto.componentDidUpdate = function componentDidUpdate() { 103 emitChange(); 104 }; 105 106 _proto.componentWillUnmount = function componentWillUnmount() { 107 var index = mountedInstances.indexOf(this); 108 mountedInstances.splice(index, 1); 109 emitChange(); 110 }; 111 112 _proto.render = function render() { 113 return React__default.createElement(WrappedComponent, this.props); 114 }; 115 116 return SideEffect; 117 }(React.PureComponent); 118 119 _defineProperty(SideEffect, "displayName", "SideEffect(" + getDisplayName(WrappedComponent) + ")"); 120 121 _defineProperty(SideEffect, "canUseDOM", canUseDOM); 122 123 return SideEffect; 124 }; 125} 126 127var lib = withSideEffect; 128 129const withSideEffect$1 = /*@__PURE__*/getDefaultExportFromCjs(lib); 130 131/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */ 132 133var hasElementType = typeof Element !== 'undefined'; 134var hasMap = typeof Map === 'function'; 135var hasSet = typeof Set === 'function'; 136var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView; 137 138// Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js 139 140function equal(a, b) { 141 // START: fast-deep-equal es6/index.js 3.1.3 142 if (a === b) return true; 143 144 if (a && b && typeof a == 'object' && typeof b == 'object') { 145 if (a.constructor !== b.constructor) return false;
146 147 var length, i, keys; 148 if (Array.isArray(a)) { 149 length = a.length; 150 if (length != b.length) return false; 151 for (i = length; i-- !== 0;) 152 if (!equal(a[i], b[i])) return false; 153 return true; 154 } 155 156 // START: Modifications: 157 // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code 158 // to co-exist with es5. 159 // 2. Replace `for of` with es5 compliant iteration using `for`. 160 // Basically, take: 161 // 162 // ```js 163 // for (i of a.entries()) 164 // if (!b.has(i[0])) return false; 165 // ``` 166 // 167 // ... and convert to: 168 // 169 // ```js 170 // it = a.entries(); 171 // while (!(i = it.next()).done) 172 // if (!b.has(i.value[0])) return false; 173 // ``` 174 // 175 // **Note**: `i` access switches to `i.value`. 176 var it; 177 if (hasMap && (a instanceof Map) && (b instanceof Map)) { 178 if (a.size !== b.size) return false; 179 it = a.entries(); 180 while (!(i = it.next()).done) 181 if (!b.has(i.value[0])) return false; 182 it = a.entries(); 183 while (!(i = it.next()).done) 184 if (!equal(i.value[1], b.get(i.value[0]))) return false; 185 return true; 186 } 187 188 if (hasSet && (a instanceof Set) && (b instanceof Set)) { 189 if (a.size !== b.size) return false; 190 it = a.entries(); 191 while (!(i = it.next()).done) 192 if (!b.has(i.value[0])) return false; 193 return true; 194 } 195 // END: Modifications 196 197 if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { 198 length = a.length; 199 if (length != b.length) return false; 200 for (i = length; i-- !== 0;) 201 if (a[i] !== b[i]) return false; 202 return true; 203 } 204 205 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; 206 // START: Modifications: 207 // Apply guards for `Object.create(null)` handling. See: 208 // - https://github.com/FormidableLabs/react-fast-compare/issues/64 209 // - https://github.com/epoberezkin/fast-deep-equal/issues/49 210 if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === 'function' && typeof b.valueOf === 'function') return a.valueOf() === b.valueOf(); 211 if (a.toString !== Object.prototype.toString && typeof a.toString === 'function' && typeof b.toString === 'function') return a.toString() === b.toString(); 212 // END: Modifications 213 214 keys = Object.keys(a); 215 length = keys.length; 216 if (length !== Object.keys(b).length) return false; 217 218 for (i = length; i-- !== 0;) 219 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; 220 // END: fast-deep-equal 221 222 // START: react-fast-compare 223 // custom handling for DOM elements 224 if (hasElementType && a instanceof Element) return false; 225 226 // custom handling for React/Preact 227 for (i = length; i-- !== 0;) { 228 if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) { 229 // React-specific: avoid traversing React elements' _owner 230 // Preact-specific: avoid traversing Preact elements' __v and __o 231 // __v = $_original / $_vnode 232 // __o = $_owner 233 // These properties contain circular references and are not needed when 234 // comparing the actual elements (and not their owners) 235 // .$$typeof and ._store on just reasonable markers of elements 236 237 continue; 238 } 239 240 // all other properties should be traversed as usual 241 if (!equal(a[keys[i]], b[keys[i]])) return false; 242 } 243 // END: react-fast-compare 244 245 // START: fast-deep-equal 246 return true; 247 } 248 249 return a !== a && b !== b; 250} 251// end fast-deep-equal 252 253var reactFastCompare = function isEqual(a, b) { 254 try { 255 return equal(a, b); 256 } catch (error) { 257 if (((error.message || '').match(/stack|recursion/i))) { 258 // warn on circular references, don't crash 259 // browsers give this different errors name and messages: 260 // chrome/safari: "RangeError", "Maximum call stack size exceeded" 261 // firefox: "InternalError", too much recursion" 262 // edge: "Error", "Out of stack space" 263 console.warn('react-fast-compare cannot handle circular refs'); 264 return false;
vendor: 36,285 bytes, lines 265-1255
265 } 266 // some other error. we should definitely know about these 267 throw error; 268 } 269}; 270 271const isEqual = /*@__PURE__*/getDefaultExportFromCjs(reactFastCompare); 272 273/* 274object-assign 275(c) Sindre Sorhus 276@license MIT 277*/ 278/* eslint-disable no-unused-vars */ 279var getOwnPropertySymbols = Object.getOwnPropertySymbols; 280var hasOwnProperty = Object.prototype.hasOwnProperty; 281var propIsEnumerable = Object.prototype.propertyIsEnumerable; 282 283function toObject(val) { 284 if (val === null || val === undefined) { 285 throw new TypeError('Object.assign cannot be called with null or undefined'); 286 } 287 288 return Object(val); 289} 290 291function shouldUseNative() { 292 try { 293 if (!Object.assign) { 294 return false; 295 } 296 297 // Detect buggy property enumeration order in older V8 versions. 298 299 // https://bugs.chromium.org/p/v8/issues/detail?id=4118 300 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers 301 test1[5] = 'de'; 302 if (Object.getOwnPropertyNames(test1)[0] === '5') { 303 return false; 304 } 305 306 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 307 var test2 = {}; 308 for (var i = 0; i < 10; i++) { 309 test2['_' + String.fromCharCode(i)] = i; 310 } 311 var order2 = Object.getOwnPropertyNames(test2).map(function (n) { 312 return test2[n]; 313 }); 314 if (order2.join('') !== '0123456789') { 315 return false; 316 } 317 318 // https://bugs.chromium.org/p/v8/issues/detail?id=3056 319 var test3 = {}; 320 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { 321 test3[letter] = letter; 322 }); 323 if (Object.keys(Object.assign({}, test3)).join('') !== 324 'abcdefghijklmnopqrst') { 325 return false; 326 } 327 328 return true; 329 } catch (err) { 330 // We don't expect any of the above to throw, but better to be safe. 331 return false; 332 } 333} 334 335var objectAssign = shouldUseNative() ? Object.assign : function (target, source) { 336 var from; 337 var to = toObject(target); 338 var symbols; 339 340 for (var s = 1; s < arguments.length; s++) { 341 from = Object(arguments[s]); 342 343 for (var key in from) { 344 if (hasOwnProperty.call(from, key)) { 345 to[key] = from[key]; 346 } 347 } 348 349 if (getOwnPropertySymbols) { 350 symbols = getOwnPropertySymbols(from); 351 for (var i = 0; i < symbols.length; i++) { 352 if (propIsEnumerable.call(from, symbols[i])) { 353 to[symbols[i]] = from[symbols[i]]; 354 } 355 } 356 } 357 } 358 359 return to; 360}; 361 362const objectAssign$1 = /*@__PURE__*/getDefaultExportFromCjs(objectAssign); 363 364var ATTRIBUTE_NAMES = { 365 BODY: "bodyAttributes", 366 HTML: "htmlAttributes", 367 TITLE: "titleAttributes" 368}; 369 370var TAG_NAMES = { 371 BASE: "base", 372 BODY: "body", 373 HEAD: "head", 374 HTML: "html", 375 LINK: "link", 376 META: "meta", 377 NOSCRIPT: "noscript", 378 SCRIPT: "script", 379 STYLE: "style", 380 TITLE: "title" 381}; 382 383Object.keys(TAG_NAMES).map(function (name) { 384 return TAG_NAMES[name]; 385}); 386 387var TAG_PROPERTIES = { 388 CHARSET: "charset", 389 CSS_TEXT: "cssText", 390 HREF: "href", 391 HTTPEQUIV: "http-equiv", 392 INNER_HTML: "innerHTML", 393 ITEM_PROP: "itemprop", 394 NAME: "name", 395 PROPERTY: "property", 396 REL: "rel", 397 SRC: "src", 398 TARGET: "target" 399}; 400 401var REACT_TAG_MAP = { 402 accesskey: "accessKey", 403 charset: "charSet", 404 class: "className", 405 contenteditable: "contentEditable", 406 contextmenu: "contextMenu", 407 "http-equiv": "httpEquiv", 408 itemprop: "itemProp", 409 tabindex: "tabIndex" 410}; 411 412var HELMET_PROPS = { 413 DEFAULT_TITLE: "defaultTitle", 414 DEFER: "defer", 415 ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters", 416 ON_CHANGE_CLIENT_STATE: "onChangeClientState", 417 TITLE_TEMPLATE: "titleTemplate" 418}; 419 420var HTML_TAG_MAP = Object.keys(REACT_TAG_MAP).reduce(function (obj, key) { 421 obj[REACT_TAG_MAP[key]] = key; 422 return obj; 423}, {}); 424 425var SELF_CLOSING_TAGS = [TAG_NAMES.NOSCRIPT, TAG_NAMES.SCRIPT, TAG_NAMES.STYLE]; 426 427var HELMET_ATTRIBUTE = "data-react-helmet"; 428 429var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { 430 return typeof obj; 431} : function (obj) { 432 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 433}; 434 435var classCallCheck = function (instance, Constructor) { 436 if (!(instance instanceof Constructor)) { 437 throw new TypeError("Cannot call a class as a function"); 438 } 439}; 440 441var createClass = function () { 442 function defineProperties(target, props) { 443 for (var i = 0; i < props.length; i++) { 444 var descriptor = props[i]; 445 descriptor.enumerable = descriptor.enumerable || false; 446 descriptor.configurable = true; 447 if ("value" in descriptor) descriptor.writable = true; 448 Object.defineProperty(target, descriptor.key, descriptor); 449 } 450 } 451 452 return function (Constructor, protoProps, staticProps) { 453 if (protoProps) defineProperties(Constructor.prototype, protoProps); 454 if (staticProps) defineProperties(Constructor, staticProps); 455 return Constructor; 456 }; 457}(); 458 459var _extends = Object.assign || function (target) { 460 for (var i = 1; i < arguments.length; i++) { 461 var source = arguments[i]; 462 463 for (var key in source) { 464 if (Object.prototype.hasOwnProperty.call(source, key)) { 465 target[key] = source[key]; 466 } 467 } 468 } 469 470 return target; 471}; 472 473var inherits = function (subClass, superClass) { 474 if (typeof superClass !== "function" && superClass !== null) { 475 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); 476 } 477 478 subClass.prototype = Object.create(superClass && superClass.prototype, { 479 constructor: { 480 value: subClass, 481 enumerable: false, 482 writable: true, 483 configurable: true 484 } 485 }); 486 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; 487}; 488 489var objectWithoutProperties = function (obj, keys) { 490 var target = {}; 491 492 for (var i in obj) { 493 if (keys.indexOf(i) >= 0) continue; 494 if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; 495 target[i] = obj[i]; 496 } 497 498 return target; 499}; 500 501var possibleConstructorReturn = function (self, call) { 502 if (!self) { 503 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 504 } 505 506 return call && (typeof call === "object" || typeof call === "function") ? call : self; 507}; 508 509var encodeSpecialCharacters = function encodeSpecialCharacters(str) { 510 var encode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 511 512 if (encode === false) { 513 return String(str); 514 } 515 516 return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); 517}; 518 519var getTitleFromPropsList = function getTitleFromPropsList(propsList) { 520 var innermostTitle = getInnermostProperty(propsList, TAG_NAMES.TITLE); 521 var innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE); 522 523 if (innermostTemplate && innermostTitle) { 524 // use function arg to avoid need to escape $ characters 525 return innermostTemplate.replace(/%s/g, function () { 526 return Array.isArray(innermostTitle) ? innermostTitle.join("") : innermostTitle; 527 }); 528 } 529 530 var innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE); 531 532 return innermostTitle || innermostDefaultTitle || undefined; 533}; 534 535var getOnChangeClientState = function getOnChangeClientState(propsList) { 536 return getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || function () {}; 537}; 538 539var getAttributesFromPropsList = function getAttributesFromPropsList(tagType, propsList) { 540 return propsList.filter(function (props) { 541 return typeof props[tagType] !== "undefined"; 542 }).map(function (props) { 543 return props[tagType]; 544 }).reduce(function (tagAttrs, current) { 545 return _extends({}, tagAttrs, current); 546 }, {}); 547}; 548 549var getBaseTagFromPropsList = function getBaseTagFromPropsList(primaryAttributes, propsList) { 550 return propsList.filter(function (props) { 551 return typeof props[TAG_NAMES.BASE] !== "undefined"; 552 }).map(function (props) { 553 return props[TAG_NAMES.BASE]; 554 }).reverse().reduce(function (innermostBaseTag, tag) { 555 if (!innermostBaseTag.length) { 556 var keys = Object.keys(tag); 557 558 for (var i = 0; i < keys.length; i++) { 559 var attributeKey = keys[i]; 560 var lowerCaseAttributeKey = attributeKey.toLowerCase(); 561 562 if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) { 563 return innermostBaseTag.concat(tag); 564 } 565 } 566 } 567 568 return innermostBaseTag; 569 }, []); 570}; 571 572var getTagsFromPropsList = function getTagsFromPropsList(tagName, primaryAttributes, propsList) { 573 // Calculate list of tags, giving priority innermost component (end of the propslist) 574 var approvedSeenTags = {}; 575 576 return propsList.filter(function (props) { 577 if (Array.isArray(props[tagName])) { 578 return true; 579 } 580 if (typeof props[tagName] !== "undefined") { 581 warn("Helmet: " + tagName + " should be of type \"Array\". Instead found type \"" + _typeof(props[tagName]) + "\""); 582 } 583 return false; 584 }).map(function (props) { 585 return props[tagName]; 586 }).reverse().reduce(function (approvedTags, instanceTags) { 587 var instanceSeenTags = {}; 588 589 instanceTags.filter(function (tag) { 590 var primaryAttributeKey = void 0; 591 var keys = Object.keys(tag); 592 for (var i = 0; i < keys.length; i++) { 593 var attributeKey = keys[i]; 594 var lowerCaseAttributeKey = attributeKey.toLowerCase(); 595 596 // Special rule with link tags, since rel and href are both primary tags, rel takes priority 597 if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === TAG_PROPERTIES.REL && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === TAG_PROPERTIES.REL && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) { 598 primaryAttributeKey = lowerCaseAttributeKey; 599 } 600 // Special case for innerHTML which doesn't work lowercased 601 if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === TAG_PROPERTIES.INNER_HTML || attributeKey === TAG_PROPERTIES.CSS_TEXT || attributeKey === TAG_PROPERTIES.ITEM_PROP)) { 602 primaryAttributeKey = attributeKey; 603 } 604 } 605 606 if (!primaryAttributeKey || !tag[primaryAttributeKey]) { 607 return false; 608 } 609 610 var value = tag[primaryAttributeKey].toLowerCase(); 611 612 if (!approvedSeenTags[primaryAttributeKey]) { 613 approvedSeenTags[primaryAttributeKey] = {}; 614 } 615 616 if (!instanceSeenTags[primaryAttributeKey]) { 617 instanceSeenTags[primaryAttributeKey] = {}; 618 } 619 620 if (!approvedSeenTags[primaryAttributeKey][value]) { 621 instanceSeenTags[primaryAttributeKey][value] = true; 622 return true; 623 } 624 625 return false; 626 }).reverse().forEach(function (tag) { 627 return approvedTags.push(tag); 628 }); 629 630 // Update seen tags with tags from this instance 631 var keys = Object.keys(instanceSeenTags); 632 for (var i = 0; i < keys.length; i++) { 633 var attributeKey = keys[i]; 634 var tagUnion = objectAssign$1({}, approvedSeenTags[attributeKey], instanceSeenTags[attributeKey]); 635 636 approvedSeenTags[attributeKey] = tagUnion; 637 } 638 639 return approvedTags; 640 }, []).reverse(); 641}; 642 643var getInnermostProperty = function getInnermostProperty(propsList, property) { 644 for (var i = propsList.length - 1; i >= 0; i--) { 645 var props = propsList[i]; 646 647 if (props.hasOwnProperty(property)) { 648 return props[property]; 649 } 650 } 651 652 return null; 653}; 654 655var reducePropsToState = function reducePropsToState(propsList) { 656 return { 657 baseTag: getBaseTagFromPropsList([TAG_PROPERTIES.HREF, TAG_PROPERTIES.TARGET], propsList), 658 bodyAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.BODY, propsList), 659 defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER), 660 encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS), 661 htmlAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.HTML, propsList), 662 linkTags: getTagsFromPropsList(TAG_NAMES.LINK, [TAG_PROPERTIES.REL, TAG_PROPERTIES.HREF], propsList), 663 metaTags: getTagsFromPropsList(TAG_NAMES.META, [TAG_PROPERTIES.NAME, TAG_PROPERTIES.CHARSET, TAG_PROPERTIES.HTTPEQUIV, TAG_PROPERTIES.PROPERTY, TAG_PROPERTIES.ITEM_PROP], propsList), 664 noscriptTags: getTagsFromPropsList(TAG_NAMES.NOSCRIPT, [TAG_PROPERTIES.INNER_HTML], propsList), 665 onChangeClientState: getOnChangeClientState(propsList), 666 scriptTags: getTagsFromPropsList(TAG_NAMES.SCRIPT, [TAG_PROPERTIES.SRC, TAG_PROPERTIES.INNER_HTML], propsList), 667 styleTags: getTagsFromPropsList(TAG_NAMES.STYLE, [TAG_PROPERTIES.CSS_TEXT], propsList), 668 title: getTitleFromPropsList(propsList), 669 titleAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.TITLE, propsList) 670 }; 671}; 672 673var rafPolyfill = function () { 674 var clock = Date.now(); 675 676 return function (callback) { 677 var currentTime = Date.now(); 678 679 if (currentTime - clock > 16) { 680 clock = currentTime; 681 callback(currentTime); 682 } else { 683 setTimeout(function () { 684 rafPolyfill(callback); 685 }, 0); 686 } 687 }; 688}(); 689 690var cafPolyfill = function cafPolyfill(id) { 691 return clearTimeout(id); 692}; 693 694var requestAnimationFrame = typeof window !== "undefined" ? window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || rafPolyfill : global.requestAnimationFrame || rafPolyfill; 695 696var cancelAnimationFrame = typeof window !== "undefined" ? window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || cafPolyfill : global.cancelAnimationFrame || cafPolyfill; 697 698var warn = function warn(msg) { 699 return console && typeof console.warn === "function" && console.warn(msg); 700}; 701 702var _helmetCallback = null; 703 704var handleClientStateChange = function handleClientStateChange(newState) { 705 if (_helmetCallback) { 706 cancelAnimationFrame(_helmetCallback); 707 } 708 709 if (newState.defer) { 710 _helmetCallback = requestAnimationFrame(function () { 711 commitTagChanges(newState, function () { 712 _helmetCallback = null; 713 }); 714 }); 715 } else { 716 commitTagChanges(newState); 717 _helmetCallback = null; 718 } 719}; 720 721var commitTagChanges = function commitTagChanges(newState, cb) { 722 var baseTag = newState.baseTag, 723 bodyAttributes = newState.bodyAttributes, 724 htmlAttributes = newState.htmlAttributes, 725 linkTags = newState.linkTags, 726 metaTags = newState.metaTags, 727 noscriptTags = newState.noscriptTags, 728 onChangeClientState = newState.onChangeClientState, 729 scriptTags = newState.scriptTags, 730 styleTags = newState.styleTags, 731 title = newState.title, 732 titleAttributes = newState.titleAttributes; 733 734 updateAttributes(TAG_NAMES.BODY, bodyAttributes); 735 updateAttributes(TAG_NAMES.HTML, htmlAttributes); 736 737 updateTitle(title, titleAttributes); 738 739 var tagUpdates = { 740 baseTag: updateTags(TAG_NAMES.BASE, baseTag), 741 linkTags: updateTags(TAG_NAMES.LINK, linkTags), 742 metaTags: updateTags(TAG_NAMES.META, metaTags), 743 noscriptTags: updateTags(TAG_NAMES.NOSCRIPT, noscriptTags), 744 scriptTags: updateTags(TAG_NAMES.SCRIPT, scriptTags), 745 styleTags: updateTags(TAG_NAMES.STYLE, styleTags) 746 }; 747 748 var addedTags = {}; 749 var removedTags = {}; 750 751 Object.keys(tagUpdates).forEach(function (tagType) { 752 var _tagUpdates$tagType = tagUpdates[tagType], 753 newTags = _tagUpdates$tagType.newTags, 754 oldTags = _tagUpdates$tagType.oldTags; 755 756 757 if (newTags.length) { 758 addedTags[tagType] = newTags; 759 } 760 if (oldTags.length) { 761 removedTags[tagType] = tagUpdates[tagType].oldTags; 762 } 763 }); 764 765 cb && cb(); 766 767 onChangeClientState(newState, addedTags, removedTags); 768}; 769 770var flattenArray = function flattenArray(possibleArray) { 771 return Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray; 772}; 773 774var updateTitle = function updateTitle(title, attributes) { 775 if (typeof title !== "undefined" && document.title !== title) { 776 document.title = flattenArray(title); 777 } 778 779 updateAttributes(TAG_NAMES.TITLE, attributes); 780}; 781 782var updateAttributes = function updateAttributes(tagName, attributes) { 783 var elementTag = document.getElementsByTagName(tagName)[0]; 784 785 if (!elementTag) { 786 return; 787 } 788 789 var helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE); 790 var helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : []; 791 var attributesToRemove = [].concat(helmetAttributes); 792 var attributeKeys = Object.keys(attributes); 793 794 for (var i = 0; i < attributeKeys.length; i++) { 795 var attribute = attributeKeys[i]; 796 var value = attributes[attribute] || ""; 797 798 if (elementTag.getAttribute(attribute) !== value) { 799 elementTag.setAttribute(attribute, value); 800 } 801 802 if (helmetAttributes.indexOf(attribute) === -1) { 803 helmetAttributes.push(attribute); 804 } 805 806 var indexToSave = attributesToRemove.indexOf(attribute); 807 if (indexToSave !== -1) { 808 attributesToRemove.splice(indexToSave, 1); 809 } 810 } 811 812 for (var _i = attributesToRemove.length - 1; _i >= 0; _i--) { 813 elementTag.removeAttribute(attributesToRemove[_i]); 814 } 815 816 if (helmetAttributes.length === attributesToRemove.length) { 817 elementTag.removeAttribute(HELMET_ATTRIBUTE); 818 } else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) { 819 elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(",")); 820 } 821}; 822 823var updateTags = function updateTags(type, tags) { 824 var headElement = document.head || document.querySelector(TAG_NAMES.HEAD); 825 var tagNodes = headElement.querySelectorAll(type + "[" + HELMET_ATTRIBUTE + "]"); 826 var oldTags = Array.prototype.slice.call(tagNodes); 827 var newTags = []; 828 var indexToDelete = void 0; 829 830 if (tags && tags.length) { 831 tags.forEach(function (tag) { 832 var newElement = document.createElement(type); 833 834 for (var attribute in tag) { 835 if (tag.hasOwnProperty(attribute)) { 836 if (attribute === TAG_PROPERTIES.INNER_HTML) { 837 newElement.innerHTML = tag.innerHTML; 838 } else if (attribute === TAG_PROPERTIES.CSS_TEXT) { 839 if (newElement.styleSheet) { 840 newElement.styleSheet.cssText = tag.cssText; 841 } else { 842 newElement.appendChild(document.createTextNode(tag.cssText)); 843 } 844 } else { 845 var value = typeof tag[attribute] === "undefined" ? "" : tag[attribute]; 846 newElement.setAttribute(attribute, value); 847 } 848 } 849 } 850 851 newElement.setAttribute(HELMET_ATTRIBUTE, "true"); 852 853 // Remove a duplicate tag from domTagstoRemove, so it isn't cleared. 854 if (oldTags.some(function (existingTag, index) { 855 indexToDelete = index; 856 return newElement.isEqualNode(existingTag); 857 })) { 858 oldTags.splice(indexToDelete, 1); 859 } else { 860 newTags.push(newElement); 861 } 862 }); 863 } 864 865 oldTags.forEach(function (tag) { 866 return tag.parentNode.removeChild(tag); 867 }); 868 newTags.forEach(function (tag) { 869 return headElement.appendChild(tag); 870 }); 871 872 return { 873 oldTags: oldTags, 874 newTags: newTags 875 }; 876}; 877 878var generateElementAttributesAsString = function generateElementAttributesAsString(attributes) { 879 return Object.keys(attributes).reduce(function (str, key) { 880 var attr = typeof attributes[key] !== "undefined" ? key + "=\"" + attributes[key] + "\"" : "" + key; 881 return str ? str + " " + attr : attr; 882 }, ""); 883}; 884 885var generateTitleAsString = function generateTitleAsString(type, title, attributes, encode) { 886 var attributeString = generateElementAttributesAsString(attributes); 887 var flattenedTitle = flattenArray(title); 888 return attributeString ? "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeString + ">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">" : "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">"; 889}; 890 891var generateTagsAsString = function generateTagsAsString(type, tags, encode) { 892 return tags.reduce(function (str, tag) { 893 var attributeHtml = Object.keys(tag).filter(function (attribute) { 894 return !(attribute === TAG_PROPERTIES.INNER_HTML || attribute === TAG_PROPERTIES.CSS_TEXT); 895 }).reduce(function (string, attribute) { 896 var attr = typeof tag[attribute] === "undefined" ? attribute : attribute + "=\"" + encodeSpecialCharacters(tag[attribute], encode) + "\""; 897 return string ? string + " " + attr : attr; 898 }, ""); 899 900 var tagContent = tag.innerHTML || tag.cssText || ""; 901 902 var isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1; 903 904 return str + "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeHtml + (isSelfClosing ? "/>" : ">" + tagContent + "</" + type + ">"); 905 }, ""); 906}; 907 908var convertElementAttributestoReactProps = function convertElementAttributestoReactProps(attributes) { 909 var initProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 910 911 return Object.keys(attributes).reduce(function (obj, key) { 912 obj[REACT_TAG_MAP[key] || key] = attributes[key]; 913 return obj; 914 }, initProps); 915}; 916 917var convertReactPropstoHtmlAttributes = function convertReactPropstoHtmlAttributes(props) { 918 var initAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 919 920 return Object.keys(props).reduce(function (obj, key) { 921 obj[HTML_TAG_MAP[key] || key] = props[key]; 922 return obj; 923 }, initAttributes); 924}; 925 926var generateTitleAsReactComponent = function generateTitleAsReactComponent(type, title, attributes) { 927 var _initProps; 928 929 // assigning into an array to define toString function on it 930 var initProps = (_initProps = { 931 key: title 932 }, _initProps[HELMET_ATTRIBUTE] = true, _initProps); 933 var props = convertElementAttributestoReactProps(attributes, initProps); 934 935 return [React$1.createElement(TAG_NAMES.TITLE, props, title)]; 936}; 937 938var generateTagsAsReactComponent = function generateTagsAsReactComponent(type, tags) { 939 return tags.map(function (tag, i) { 940 var _mappedTag; 941 942 var mappedTag = (_mappedTag = { 943 key: i 944 }, _mappedTag[HELMET_ATTRIBUTE] = true, _mappedTag); 945 946 Object.keys(tag).forEach(function (attribute) { 947 var mappedAttribute = REACT_TAG_MAP[attribute] || attribute; 948 949 if (mappedAttribute === TAG_PROPERTIES.INNER_HTML || mappedAttribute === TAG_PROPERTIES.CSS_TEXT) { 950 var content = tag.innerHTML || tag.cssText; 951 mappedTag.dangerouslySetInnerHTML = { __html: content }; 952 } else { 953 mappedTag[mappedAttribute] = tag[attribute]; 954 } 955 }); 956 957 return React$1.createElement(type, mappedTag); 958 }); 959}; 960 961var getMethodsForTag = function getMethodsForTag(type, tags, encode) { 962 switch (type) { 963 case TAG_NAMES.TITLE: 964 return { 965 toComponent: function toComponent() { 966 return generateTitleAsReactComponent(type, tags.title, tags.titleAttributes); 967 }, 968 toString: function toString() { 969 return generateTitleAsString(type, tags.title, tags.titleAttributes, encode); 970 } 971 }; 972 case ATTRIBUTE_NAMES.BODY: 973 case ATTRIBUTE_NAMES.HTML: 974 return { 975 toComponent: function toComponent() { 976 return convertElementAttributestoReactProps(tags); 977 }, 978 toString: function toString() { 979 return generateElementAttributesAsString(tags); 980 } 981 }; 982 default: 983 return { 984 toComponent: function toComponent() { 985 return generateTagsAsReactComponent(type, tags); 986 }, 987 toString: function toString() { 988 return generateTagsAsString(type, tags, encode); 989 } 990 }; 991 } 992}; 993 994var mapStateOnServer = function mapStateOnServer(_ref) { 995 var baseTag = _ref.baseTag, 996 bodyAttributes = _ref.bodyAttributes, 997 encode = _ref.encode, 998 htmlAttributes = _ref.htmlAttributes, 999 linkTags = _ref.linkTags, 1000 metaTags = _ref.metaTags, 1001 noscriptTags = _ref.noscriptTags, 1002 scriptTags = _ref.scriptTags, 1003 styleTags = _ref.styleTags, 1004 _ref$title = _ref.title, 1005 title = _ref$title === undefined ? "" : _ref$title, 1006 titleAttributes = _ref.titleAttributes; 1007 return { 1008 base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode), 1009 bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode), 1010 htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode), 1011 link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode), 1012 meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode), 1013 noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode), 1014 script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode), 1015 style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode), 1016 title: getMethodsForTag(TAG_NAMES.TITLE, { title: title, titleAttributes: titleAttributes }, encode) 1017 }; 1018}; 1019 1020var Helmet = function Helmet(Component) { 1021 var _class, _temp; 1022 1023 return _temp = _class = function (_React$Component) { 1024 inherits(HelmetWrapper, _React$Component); 1025 1026 function HelmetWrapper() { 1027 classCallCheck(this, HelmetWrapper); 1028 return possibleConstructorReturn(this, _React$Component.apply(this, arguments)); 1029 } 1030 1031 HelmetWrapper.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { 1032 return !isEqual(this.props, nextProps); 1033 }; 1034 1035 HelmetWrapper.prototype.mapNestedChildrenToProps = function mapNestedChildrenToProps(child, nestedChildren) { 1036 if (!nestedChildren) { 1037 return null; 1038 } 1039 1040 switch (child.type) { 1041 case TAG_NAMES.SCRIPT: 1042 case TAG_NAMES.NOSCRIPT: 1043 return { 1044 innerHTML: nestedChildren 1045 }; 1046 1047 case TAG_NAMES.STYLE: 1048 return { 1049 cssText: nestedChildren 1050 }; 1051 } 1052 1053 throw new Error("<" + child.type + " /> elements are self-closing and can not contain children. Refer to our API for more information."); 1054 }; 1055 1056 HelmetWrapper.prototype.flattenArrayTypeChildren = function flattenArrayTypeChildren(_ref) { 1057 var _babelHelpers$extends; 1058 1059 var child = _ref.child, 1060 arrayTypeChildren = _ref.arrayTypeChildren, 1061 newChildProps = _ref.newChildProps, 1062 nestedChildren = _ref.nestedChildren; 1063 1064 return _extends({}, arrayTypeChildren, (_babelHelpers$extends = {}, _babelHelpers$extends[child.type] = [].concat(arrayTypeChildren[child.type] || [], [_extends({}, newChildProps, this.mapNestedChildrenToProps(child, nestedChildren))]), _babelHelpers$extends)); 1065 }; 1066 1067 HelmetWrapper.prototype.mapObjectTypeChildren = function mapObjectTypeChildren(_ref2) { 1068 var _babelHelpers$extends2, _babelHelpers$extends3; 1069 1070 var child = _ref2.child, 1071 newProps = _ref2.newProps, 1072 newChildProps = _ref2.newChildProps, 1073 nestedChildren = _ref2.nestedChildren; 1074 1075 switch (child.type) { 1076 case TAG_NAMES.TITLE: 1077 return _extends({}, newProps, (_babelHelpers$extends2 = {}, _babelHelpers$extends2[child.type] = nestedChildren, _babelHelpers$extends2.titleAttributes = _extends({}, newChildProps), _babelHelpers$extends2)); 1078 1079 case TAG_NAMES.BODY: 1080 return _extends({}, newProps, { 1081 bodyAttributes: _extends({}, newChildProps) 1082 }); 1083 1084 case TAG_NAMES.HTML: 1085 return _extends({}, newProps, { 1086 htmlAttributes: _extends({}, newChildProps) 1087 }); 1088 } 1089 1090 return _extends({}, newProps, (_babelHelpers$extends3 = {}, _babelHelpers$extends3[child.type] = _extends({}, newChildProps), _babelHelpers$extends3)); 1091 }; 1092 1093 HelmetWrapper.prototype.mapArrayTypeChildrenToProps = function mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) { 1094 var newFlattenedProps = _extends({}, newProps); 1095 1096 Object.keys(arrayTypeChildren).forEach(function (arrayChildName) { 1097 var _babelHelpers$extends4; 1098 1099 newFlattenedProps = _extends({}, newFlattenedProps, (_babelHelpers$extends4 = {}, _babelHelpers$extends4[arrayChildName] = arrayTypeChildren[arrayChildName], _babelHelpers$extends4)); 1100 }); 1101 1102 return newFlattenedProps; 1103 }; 1104 1105 HelmetWrapper.prototype.warnOnInvalidChildren = function warnOnInvalidChildren(child, nestedChildren) { 1106 1107 return true; 1108 }; 1109 1110 HelmetWrapper.prototype.mapChildrenToProps = function mapChildrenToProps(children, newProps) { 1111 var _this2 = this; 1112 1113 var arrayTypeChildren = {}; 1114 1115 React$1.Children.forEach(children, function (child) { 1116 if (!child || !child.props) { 1117 return; 1118 } 1119 1120 var _child$props = child.props, 1121 nestedChildren = _child$props.children, 1122 childProps = objectWithoutProperties(_child$props, ["children"]); 1123 1124 var newChildProps = convertReactPropstoHtmlAttributes(childProps); 1125 1126 _this2.warnOnInvalidChildren(child, nestedChildren); 1127 1128 switch (child.type) { 1129 case TAG_NAMES.LINK: 1130 case TAG_NAMES.META: 1131 case TAG_NAMES.NOSCRIPT: 1132 case TAG_NAMES.SCRIPT: 1133 case TAG_NAMES.STYLE: 1134 arrayTypeChildren = _this2.flattenArrayTypeChildren({ 1135 child: child, 1136 arrayTypeChildren: arrayTypeChildren, 1137 newChildProps: newChildProps, 1138 nestedChildren: nestedChildren 1139 }); 1140 break; 1141 1142 default: 1143 newProps = _this2.mapObjectTypeChildren({ 1144 child: child, 1145 newProps: newProps, 1146 newChildProps: newChildProps, 1147 nestedChildren: nestedChildren 1148 }); 1149 break; 1150 } 1151 }); 1152 1153 newProps = this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps); 1154 return newProps; 1155 }; 1156 1157 HelmetWrapper.prototype.render = function render() { 1158 var _props = this.props, 1159 children = _props.children, 1160 props = objectWithoutProperties(_props, ["children"]); 1161 1162 var newProps = _extends({}, props); 1163 1164 if (children) { 1165 newProps = this.mapChildrenToProps(children, newProps); 1166 } 1167 1168 return React$1.createElement(Component, newProps); 1169 }; 1170 1171 createClass(HelmetWrapper, null, [{ 1172 key: "canUseDOM", 1173 1174 1175 // Component.peek comes from react-side-effect: 1176 // For testing, you may use a static peek() method available on the returned component. 1177 // It lets you get the current state without resetting the mounted instance stack. 1178 // Donât use it for anything other than testing. 1179 1180 /** 1181 * @param {Object} base: {"target": "_blank", "href": "http://mysite.com/"} 1182 * @param {Object} bodyAttributes: {"className": "root"} 1183 * @param {String} defaultTitle: "Default Title" 1184 * @param {Boolean} defer: true 1185 * @param {Boolean} encodeSpecialCharacters: true 1186 * @param {Object} htmlAttributes: {"lang": "en", "amp": undefined} 1187 * @param {Array} link: [{"rel": "canonical", "href": "http://mysite.com/example"}] 1188 * @param {Array} meta: [{"name": "description", "content": "Test description"}] 1189 * @param {Array} noscript: [{"innerHTML": "<img src='http://mysite.com/js/test.js'"}] 1190 * @param {Function} onChangeClientState: "(newState) => console.log(newState)" 1191 * @param {Array} script: [{"type": "text/javascript", "src": "http://mysite.com/js/test.js"}] 1192 * @param {Array} style: [{"type": "text/css", "cssText": "div { display: block; color: blue; }"}] 1193 * @param {String} title: "Title" 1194 * @param {Object} titleAttributes: {"itemprop": "name"} 1195 * @param {String} titleTemplate: "MySite.com - %s" 1196 */ 1197 set: function set$$1(canUseDOM) { 1198 Component.canUseDOM = canUseDOM; 1199 } 1200 }]); 1201 return HelmetWrapper; 1202 }(React$1.Component), _class.propTypes = { 1203 base: PropTypes.object, 1204 bodyAttributes: PropTypes.object, 1205 children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), 1206 defaultTitle: PropTypes.string, 1207 defer: PropTypes.bool, 1208 encodeSpecialCharacters: PropTypes.bool, 1209 htmlAttributes: PropTypes.object, 1210 link: PropTypes.arrayOf(PropTypes.object), 1211 meta: PropTypes.arrayOf(PropTypes.object), 1212 noscript: PropTypes.arrayOf(PropTypes.object), 1213 onChangeClientState: PropTypes.func, 1214 script: PropTypes.arrayOf(PropTypes.object), 1215 style: PropTypes.arrayOf(PropTypes.object), 1216 title: PropTypes.string, 1217 titleAttributes: PropTypes.object, 1218 titleTemplate: PropTypes.string 1219 }, _class.defaultProps = { 1220 defer: true, 1221 encodeSpecialCharacters: true 1222 }, _class.peek = Component.peek, _class.rewind = function () { 1223 var mappedState = Component.rewind(); 1224 if (!mappedState) { 1225 // provide fallback if mappedState is undefined 1226 mappedState = mapStateOnServer({ 1227 baseTag: [], 1228 bodyAttributes: {}, 1229 encodeSpecialCharacters: true, 1230 htmlAttributes: {}, 1231 linkTags: [], 1232 metaTags: [], 1233 noscriptTags: [], 1234 scriptTags: [], 1235 styleTags: [], 1236 title: "", 1237 titleAttributes: {} 1238 }); 1239 } 1240 1241 return mappedState; 1242 }, _temp; 1243}; 1244 1245var NullComponent = function NullComponent() { 1246 return null; 1247}; 1248 1249var HelmetSideEffects = withSideEffect$1(reducePropsToState, handleClientStateChange, mapStateOnServer)(NullComponent); 1250 1251var HelmetExport = Helmet(HelmetSideEffects); 1252HelmetExport.renderStatic = HelmetExport.rewind; 1253 1254export { HelmetExport as H }; 1255//# sourceMappingURL=Helmet-959560d8.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.