@@ -342,11 +342,24 @@ var useViewState = function useViewState(state, props) {
342342
343343 if ( hasLatestRelease && ( 0 , _typeUtil . exists ) ( baseProduct ) ) {
344344 hasLatestReleaseBundle = _BundleService . default . isProductInBundle ( bundlesContext , latestReleaseObject . release , baseProduct . productCode ) ;
345+ } // Determine if the bundle product has data for the specified release.
346+
347+
348+ var isBundleProductInRelease = true ;
349+
350+ if ( hasBundleProduct && hasSpecifiedRelease && ! isAppliedReleaseLatestNonProv ) {
351+ var _bundleProduct ;
352+
353+ var bundleHasRelease = ( _bundleProduct = bundleProduct ) === null || _bundleProduct === void 0 ? void 0 : _bundleProduct . releases . find ( function ( r ) {
354+ return r . release === appliedRenderedReleaseTag ;
355+ } ) ;
356+ isBundleProductInRelease = ( 0 , _typeUtil . exists ) ( bundleHasRelease ) ;
345357 } // Determine if the citable product should be the bundle container product
346358 // or the currently specified product.
359+ // eslint-disable-next-line max-len
347360
348361
349- var citableBaseProduct = hasBundleProduct ? bundleProduct : baseProduct ; // Determine the product to use for citing within the applicable release
362+ var citableBaseProduct = hasBundleProduct && isBundleProductInRelease ? bundleProduct : baseProduct ; // Determine the product to use for citing within the applicable release
350363 // and within the context of bundles.
351364
352365 var citableReleaseProduct = null ;
@@ -357,6 +370,7 @@ var useViewState = function useViewState(state, props) {
357370 if ( ! hasSpecifiedRelease && ! hasLatestReleaseBundle ) {
358371 citableReleaseProduct = baseProduct ;
359372 } else {
373+ // Has a specified release, or if not, has latest release bundle.
360374 // When a bundled product code is available for the given release,
361375 // get the product for the parent code and release.
362376 // Otherwise, the citable product is the current product for the specified
@@ -383,7 +397,22 @@ var useViewState = function useViewState(state, props) {
383397 } // Determine if there's a valid product to generate the citation with.
384398
385399
386- var hasValidProduct = ( 0 , _typeUtil . exists ) ( citableBaseProduct ) ; // Determine the overall citation display status.
400+ var hasValidProduct = ( 0 , _typeUtil . exists ) ( citableBaseProduct ) ;
401+ var hasValidReleaseProduct = ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ; // Verify identified release product is in the applied release.
402+
403+ var isCitableReleaseProductInRelease = false ; // If looking at latest release non provisional, consider in release.
404+
405+ if ( isAppliedReleaseLatestNonProv ) {
406+ isCitableReleaseProductInRelease = true ;
407+ } else if ( hasValidReleaseProduct ) {
408+ var _citableReleaseProduc ;
409+
410+ var productHasRelease = ( _citableReleaseProduc = citableReleaseProduct ) === null || _citableReleaseProduc === void 0 ? void 0 : _citableReleaseProduc . releases . find ( function ( r ) {
411+ return r . release === appliedRenderedReleaseTag ;
412+ } ) ;
413+ isCitableReleaseProductInRelease = ( 0 , _typeUtil . exists ) ( productHasRelease ) ;
414+ } // Determine the overall citation display status.
415+
387416
388417 var appliedStatus = status ;
389418 var displayType = _ViewState . DisplayType . CONDITIONAL ;
@@ -402,8 +431,15 @@ var useViewState = function useViewState(state, props) {
402431 // not show a release citation, show not available display state.
403432 displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
404433 } else if ( hasAppliedReleaseDoi ) {
405- if ( ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ) {
406- displayType = _ViewState . DisplayType . RELEASE ;
434+ if ( hasValidReleaseProduct ) {
435+ // If the identified release product doesn't have data in the
436+ // release and we're viewing a specific release, report
437+ // as not available for that release.
438+ if ( ! isCitableReleaseProductInRelease ) {
439+ displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
440+ } else {
441+ displayType = _ViewState . DisplayType . RELEASE ;
442+ }
407443 } else {
408444 // If the component is ready and a release was specified but
409445 // failed to resolve the appropriate citable release product,
@@ -418,14 +454,18 @@ var useViewState = function useViewState(state, props) {
418454 // a special case, render as not available.
419455 displayType = _ViewState . DisplayType . NOT_AVAILABLE ;
420456 }
457+ } else if ( ! isCitableReleaseProductInRelease ) {
458+ // If the detected citable release product is not in the applied
459+ // release, then consider the display as provisional.
460+ displayType = _ViewState . DisplayType . PROVISIONAL ;
421461 } else if ( ! hasLatestRelease || hideLatestReleaseCitation || disableConditional ) {
422462 // If display is determined to be conditional, but we haven't identified
423463 // a valid latest release or it's set to hide the citation for that
424464 // release, then display as provisional.
425465 // If an override has been presented by the component, also
426466 // display as provisional.
427467 displayType = _ViewState . DisplayType . PROVISIONAL ;
428- } else if ( ! hasValidProduct || ! ( 0 , _typeUtil . exists ) ( citableReleaseProduct ) ) {
468+ } else if ( ! hasValidProduct || ! hasValidReleaseProduct ) {
429469 // If the component is ready and the display state is conditional
430470 // and a valid product and release product were not found, error state.
431471 appliedStatus = _State . ContextStatus . ERROR ;
0 commit comments