{#if showQuotesSubTab} {/if} {#if canFetchDownloads} {/if}
{#if viewMode === "list"}
Committed Quotes {#if canCommitQuote} {/if}
{#if quotesLoading}
Loading quotes...
{:else if quotesError}
{quotesError}
{:else if quotes.length === 0}
No quotes yet. {#if canCommitQuote} {/if}
{:else}
{#each quotes as quote (quote.id)} {/each}
{/if}
{#if selectedQuoteDetail}

{shortFileName(selectedQuoteDetail.quoteFileName)}

{formatDate(selectedQuoteDetail.createdAt)}
{#if detailLoading}
Loading details...
{:else if selectedQuoteDetail.quoteRegenData?.options}
Line pricing Quote narrative Item narratives
{/if}
{#if !detailLoading && allProducts.length > 0}
Items {totalItems}
Revenue {formatCurrency(totalRevenue)}
Cost {formatCurrency(totalCost)}
Margin = 0} class:negative={totalMargin < 0} > {formatCurrency(totalMargin)}
{/if}
# Description Qty Revenue
{#if detailLoading}
Loading line items...
{:else if activeProducts.length > 0} {#each activeProducts as product, i}
{i + 1} {product.productDescription ?? "—"} {#if product.productClass} {product.productClass} {/if} {#if product.cancellationType === "partial"} {product.quantityCancelled ?? 0} cancelled {/if} {product.effectiveQuantity ?? product.quantity ?? 0} {formatCurrency(product.revenue)}
{/each} {:else if allProducts.length === 0}
No line items
{:else}
All items cancelled
{/if} {#if cancelledProducts.length > 0}
(cancelledExpanded = !cancelledExpanded)} on:keydown={(e) => { if (e.key === "Enter" || e.key === " ") cancelledExpanded = !cancelledExpanded; }} role="button" tabindex="0" > Cancelled ({cancelledProducts.length})
{#if cancelledExpanded} {#each cancelledProducts as product, i}
{activeProducts.length + i + 1} {product.productDescription ?? "—"} {#if product.productClass} {product.productClass} {/if} {product.quantity ?? 0} {formatCurrency(product.revenue)}
{/each} {/if} {/if}
{#if quotePreviewLoading}

Loading preview...

{:else if quotePreviewError}

{quotePreviewError}

{:else if quotePreviewObjectUrl}
{:else}

No preview available

{/if}
{:else}

Select a quote from the list to view details.

{/if}
{:else if viewMode === "preview"}
Live Preview
Generation options
{#if commitError}
{commitError}
{/if} {#if commitSuccess}
{commitSuccess}
{/if} {#if quotes.length > 0}
{/if}
{#if effectivePdfUrl} {:else}

Quote PDF Preview

{#if connectionError} Live preview error: {connectionError} {:else if !accessToken || !opportunityId} Missing authentication or opportunity id for live preview. {:else if !isConnected} Connecting to live preview channel... {:else} Connected. Waiting for live quote preview PDF payload. {/if}

{/if}
{:else if viewMode === "logs"}
Download & Print History
{#if logsLoading}

Loading logs...

{:else if logsError}

{logsError}

{:else if downloadLogs.length === 0}

No download or print activity yet.

{:else}
{#each downloadLogs as log}
{log.quoteFileName.replace(/\.pdf$/i, "")} {#if log.downloads.length > 0} {log.downloads.length} {log.downloads.length === 1 ? "entry" : "entries"} {:else} Created {formatDate(log.createdAt)} {/if}
{#if log.downloads.length > 0}
{#each log.downloads as dl}
{#if dl.fetchAction === "download"} {:else} {/if} {dl.fetchAction} {dl.userName} {formatDate(dl.downloadedAt)}
{/each}
{:else}
No downloads yet
{/if}
{/each}
{/if}
{/if}