"""Rendered local Gift Cards, Sell, Registry, and static Video placeholder pages.""" from __future__ import annotations from html import escape from typing import Any, Iterable from urllib.parse import urlencode from render import layout, money from specialty_store import ( GIFT_AMOUNTS_MINOR, GIFT_CARD_BALANCE_PATH, GIFT_CARD_PREVIEW_PATH, GIFT_CARD_REDEEM_PATH, GIFT_CARDS_PATH, GIFT_DESIGNS, PRIME_VIDEO_PATH, REGISTRY_CREATE_PATH, REGISTRY_DETAIL_PATH, REGISTRY_PATH, REGISTRY_SEARCH_PATH, REGISTRY_TYPES, SELL_CATEGORIES, SELL_CONDITIONS, SELL_DRAFT_PATH, SELL_PATH, ) CUSTOMER_SERVICE_HREF = "/gp/help/customer/display.html?nodeId=508510" def _simulation_notice(copy: str) -> str: return ( '" ) def gift_cards_page(cart_count: int, account_name: str | None = None) -> str: account_href = ( "/gp/css/homepage.html" if account_name else "/ap/signin?openid.return_to=%2Fgift-cards%2Fb%2F" ) account_action = "Go to your account" if account_name else "Sign in" design_choices = "".join( f'" for key, label in GIFT_DESIGNS.items() ) amount_choices = "".join( f'' for amount in GIFT_AMOUNTS_MINOR ) categories = ( ("Birthday", "/s?k=birthday+gifts", "Celebrate their day"), ("Books", "/s?k=books", "For every kind of reader"), ("Home & Kitchen", "/s?k=home+kitchen", "Useful picks for home"), ("Toys & Games", "/s?k=toys", "For play and discovery"), ("Beauty", "/s?k=beauty+personal+care", "Self-care favorites"), ("Deals", "/gp/goldbox/", "Browse current offers"), ) category_cards = "".join( f'{escape(title)}' f"{escape(copy)}Explore ›" for title, href, copy in categories ) body = f"""

Amazon Gift Cards

So many ways to celebrate

Choose a card face and amount, then continue to a controlled local preview. No payment information is collected.
{_simulation_notice("Gift Card previews do not create value, charge a card, send email, or connect to Amazon Gift Card services.")}

Customers love these gift card styles

Build a local Gift Card preview

1. Choose a card face
{design_choices}
2. Choose an amount
{amount_choices}
3. Who is it for?

Occasion, category, and delivery ideas

Shop gifts by department

Find a gift from the local catalog.
{category_cards}

Gift Card FAQ

Can I use a real Gift Card here?

No. Do not enter a real claim code. This clone stores only an irreversible fingerprint of a fictional test code and never changes a real balance.

Will the purchase preview charge me?

No. It does not request card details and cannot complete a financial transaction.

Where can I get account help?

Search Customer Service or {account_action}.

""" return layout( "Amazon.com Gift Cards", body, cart_count, body_class="specialty-page gift-cards-page", account_name=account_name, ) def gift_card_preview_page( preview: dict[str, Any], cart_count: int, account_name: str | None ) -> str: design = str(preview.get("design", "classic")) design_label = GIFT_DESIGNS.get(design, GIFT_DESIGNS["classic"]) recipient = "For me" if preview.get("recipient_kind") == "self" else "For someone else" amount = money(int(preview.get("amount_minor", 0)), "USD") body = f"""
{_simulation_notice("This is a saved preview in this browser session. It is not in the cart and no payment or Gift Card value exists.")}
amazon{amount}

Local Gift Card preview #{int(preview['preview_id'])}

{escape(design_label)}

Amount
{amount}
Recipient
{escape(recipient)}
Status
Preview only — not purchased
""" return layout( "Gift Card local preview", body, cart_count, body_class="specialty-page specialty-result-page", account_name=account_name, ) def gift_card_balance_page( balance: dict[str, int], cart_count: int, account_name: str | None, *, redemption_result: bool = False, ) -> str: result = ( '
No balance was applied.This local simulation returns the same result for every well-formed fictional code.
' if redemption_result else "" ) body = f"""

Local simulated balance

{money(int(balance.get('balance_minor', 0)), 'USD')}

No real Gift Card account is connected.Build a purchase preview

Redeem a fictional test code

Do not enter a real Amazon Gift Card claim code. Raw input is never stored; only an irreversible fingerprint is retained.

{result}
Local attempts in this browser session: {int(balance.get('redemption_attempts', 0))}
{_simulation_notice("Redemption never contacts Amazon and never applies monetary value. Public responses do not reveal whether any real-looking code exists.")}
""" return layout( "Gift Card balance and redemption", body, cart_count, body_class="specialty-page specialty-balance-page", account_name=account_name, ) def sell_page( drafts: Iterable[dict[str, Any]], cart_count: int, account_name: str | None ) -> str: category_options = "".join( f'' for key, label in SELL_CATEGORIES.items() ) condition_options = "".join( f'' for key, label in SELL_CONDITIONS.items() ) draft_cards = "".join( f'{escape(str(draft["title"]))}{escape(SELL_CATEGORIES.get(str(draft["category"]), str(draft["category"])))}{money(int(draft["price_minor"]), "USD")}' for draft in drafts ) or '

No listing drafts saved in this browser session yet.

' body = f"""

Sell on Amazon

Create an Amazon selling account

This clone cannot create a real seller account. You can save a server-validated listing draft locally to understand the flow.
{_simulation_notice("Nothing saved here is published, searchable by other shoppers, or sent to Amazon. No seller identity, tax, bank, or payout data is collected.")}
1

What will you sell?

Choose a supported local catalog category and write a clear title.

2

How will you offer it?

Set condition, price, and quantity. The server validates every field.

3

Ready to publish?

Review the local result. Publishing and fulfillment stay intentionally unavailable.

Getting started

Save a local listing draft

Estimate gross listing value from price × quantity without implying fees, revenue, or real sales.

Your browser session

Saved listing drafts

{draft_cards}

Why model selling?

It connects catalog information, inventory choices, validation, and a review step.

Local incentives

There are no promotional credits or seller benefits in this clone.

Next step

Use the saved result to review data before a hypothetical publish action.

""" return layout( "Sell on Amazon - local draft", body, cart_count, body_class="specialty-page specialty-sell-page", account_name=account_name, ) def seller_draft_page( draft: dict[str, Any], cart_count: int, account_name: str | None ) -> str: gross_minor = int(draft["price_minor"]) * int(draft["quantity"]) body = f"""
{_simulation_notice("This draft belongs only to this browser session and is not a public Amazon listing.")}

Local listing draft #{int(draft['draft_id'])}

{escape(str(draft['title']))}

Category
{escape(SELL_CATEGORIES.get(str(draft['category']), str(draft['category'])))}
Condition
{escape(SELL_CONDITIONS.get(str(draft['item_condition']), str(draft['item_condition'])))}
Unit price
{money(int(draft['price_minor']), 'USD')}
Quantity
{int(draft['quantity'])}
Gross listing value
{money(gross_minor, 'USD')} before any hypothetical fees
Status
Local draft — not published
{f'

{escape(str(draft["description"]))}

' if draft.get('description') else ''}Create another draft
""" return layout( "Local seller listing draft", body, cart_count, body_class="specialty-page specialty-result-page", account_name=account_name, ) def registry_page( own_registries: Iterable[dict[str, Any]], cart_count: int, account_name: str | None ) -> str: type_cards = "".join( f'{escape(label)}{escape(copy)}' for (key, label), icon, copy in zip( REGISTRY_TYPES.items(), ("💍", "🧸", "🎁"), ("Plan shared gift ideas", "Prepare for a new arrival", "Collect ideas for any occasion"), ) ) type_options = "".join( f'' for key, label in REGISTRY_TYPES.items() ) own_cards = "".join( f'{escape(str(item["registry_name"]))}{escape(REGISTRY_TYPES.get(str(item["registry_type"]), str(item["registry_type"])))}Private local draft' for item in own_registries ) or '

No registry drafts saved in this browser session.

' body = f"""

Registry & Gift List

Find a registry or create your own

Search local demo registries and your own private browser-session drafts.
{_simulation_notice("Registry drafts are private to this browser session. They are not published to Amazon and are never exposed in another visitor's search results.")}

Choose the list that fits

Baby Registry, Wedding Registry, and Gift List

{type_cards}

Create and personalize

Start a private local registry draft

After saving, build the idea list by browsing Books, Home, Toys, Beauty, or Electronics.

Reasons and benefits

One place to organize gift ideas

Personalize

Name the event and choose the kind of registry.

Build

Use the live catalog links on the saved detail page.

Keep it private

Only the creating browser session can open the draft.

{own_cards}
""" return layout( "Amazon Registry & Gift List", body, cart_count, body_class="specialty-page specialty-registry-page", account_name=account_name, ) def registry_search_page( query: str, results: Iterable[dict[str, Any]], cart_count: int, account_name: str | None, ) -> str: cards: list[str] = [] for item in results: label = REGISTRY_TYPES.get(str(item.get("registry_type")), "Gift List") if item.get("is_own"): href = REGISTRY_DETAIL_PATH + "?" + urlencode( {"registryID": int(item["registry_id"])} ) action = f'Open your private draft' else: action = "Local demo result — no personal data" cards.append( f'

{escape(label)}

{escape(str(item["registry_name"]))}

{escape(str(item["owner_name"]))}{action}
' ) result_markup = "".join(cards) or '

No local demo or private draft matched that search.

' body = f"""

Results for “{escape(query)}”

{result_markup}
{_simulation_notice("Only built-in demo entries and registries owned by this browser session are searchable here.")}
""" return layout( "Find a local registry", body, cart_count, body_class="specialty-page specialty-registry-page", account_name=account_name, ) def registry_detail_page( item: dict[str, Any], cart_count: int, account_name: str | None ) -> str: date_copy = escape(str(item.get("event_date") or "No event date selected")) body = f"""
{_simulation_notice("This registry exists only in the creating browser session and is not published or shared.")}

{escape(REGISTRY_TYPES.get(str(item['registry_type']), 'Gift List'))}

{escape(str(item['registry_name']))}

Owner
{escape(str(item['owner_name']))}
Event date
{date_copy}
Status
Private local draft

Start building your list

""" return layout( "Private local registry draft", body, cart_count, body_class="specialty-page specialty-result-page", account_name=account_name, ) def prime_video_page(cart_count: int, account_name: str | None) -> str: body = f"""

PRIME VIDEO

Video service is outside this shopping clone

This reachable placeholder does not model a catalog, subscription, stream, rental, purchase, watchlist, or viewing history.
""" return layout( "Prime Video - local placeholder", body, cart_count, body_class="specialty-video-page", account_name=account_name, )