SIGN IN SIGN UP

fix(paywalls): don't leave a hidden package selected by default (#3915)

### Motivation

A customer did some tricks hiding the default package. This leads to a
screen with no package selected.
The default package is annual. As you can see in the video, the left
side selects nothing and the right side (with the fix) defaults to
monthly

See
https://github.com/user-attachments/assets/22d9b52a-09e6-44f4-b3ae-4df13f9b78b0

counterpart of RevenueCat/purchases-iOS#7380 already merged

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes initial selection, tab switching, and reset behavior for
component paywalls; logic is nuanced but covered by new tests and
mirrors iOS.
> 
> **Overview**
> Fixes component paywalls where the **authored default package is
hidden** (static `visible` or variable/override rules), which previously
left **no package selected** and broke price variables on first load.
> 
> **StyleFactory** now records each package’s `visible`, visibility
overrides, and offer eligibility when building `AvailablePackages.Info`,
using the same override resolution path as rendering.
> 
> **PaywallState** uses that data to pick defaults: prefer the authored
default only if it **resolves visible** (with selection pinned
unselected so visibility rules can’t oscillate), else the first visible
package in document order, with fallbacks for hidden defaults outside
tabs, tab switches, sheet dismiss, and `resetToDefaultPackage`. Paywalls
with **no** authored default still start unselected.
> 
> Adds broad **visibility-aware package selection** tests (custom
variables, tabs, fallbacks).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
cb4b8005effaebc43cf54d39f87889cc2b66e225. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
F
Facundo Menzella committed
06101064c761ab338db94276ae3947313be601e3
Parent: 7cea7d7
Committed by GitHub <noreply@github.com> on 8/18/2026, 1:24:56 PM