import { d as Invoice } from "./types-3EaBC58c.js"; import { t as PdfRenderer } from "./pdf-renderer-B-BQphqe.js"; import handlebars from "handlebars"; //#region src/templates/invoice-template.d.ts declare const subscriptionInvoiceTemplate = "\n\n\n \n \n فاتورة اشتراك\n\n \n \n \n\n \n\n\n\n
\n
\n
\n {{#if platform.logo}}\n \"{{platform.name}}\"\n {{/if}}\n
\n

بيان اشتراك

\n

{{#if platform.name}}{{platform.name}}{{else}}منصة اشتراكات{{/if}}

\n
\n
\n\n
\n

فاتورة اشتراك

\n
رقم الفاتورة: {{#if invoice.id}}{{invoice.id}}{{else}}—{{/if}}
\n
{{translateInvoiceStatus invoice.status}}
\n
\n
\n\n
\n
\n تاريخ الإصدار\n {{#if invoice.createdAt}}{{formatDate invoice.createdAt locale=locale}}{{else}}—{{/if}}\n
\n
\n تاريخ الاستحقاق\n {{#if invoice.dueDate}}{{formatDate invoice.dueDate locale=locale}}{{else}}—{{/if}}\n
\n
\n تاريخ السداد\n {{#if invoice.paidAt}}{{formatDate invoice.paidAt locale=locale}}{{else}}—{{/if}}\n
\n
\n حالة الاشتراك\n {{translateSubscriptionStatus subscription.status}}\n
\n
\n\n
\n
\n

بيانات المشترك

\n
\n {{#if subscriber.name}}\n
الاسم
\n
{{subscriber.name}}
\n {{/if}}\n {{#if subscriber.email}}\n
البريد الإلكتروني
\n
{{subscriber.email}}
\n {{/if}}\n {{#if subscriber.phone}}\n
الهاتف
\n
{{subscriber.phone}}
\n {{/if}}\n {{#if subscriber.address}}\n
العنوان
\n
{{subscriber.address}}
\n {{/if}}\n
معرّف المشترك
\n
{{subscription.subscriberId}}
\n
\n
\n\n
\n

معلومات المنصة

\n
\n {{#if platform.name}}\n
الاسم
\n
{{platform.name}}
\n {{/if}}\n {{#if platform.website}}\n
الموقع
\n
{{platform.website}}
\n {{/if}}\n {{#if platform.supportEmail}}\n
الدعم
\n
{{platform.supportEmail}}
\n {{/if}}\n {{#if platform.address}}\n
العنوان
\n
{{platform.address}}
\n {{/if}}\n
\n
\n
\n\n
\n
\n
\n
الخطة
\n

{{plan.name}}

\n {{#if plan.description}}\n

{{plan.description}}

\n {{/if}}\n
\n\n
\n {{formatCurrency plan.price plan.currency locale=locale}}\n {{translateBillingInterval plan.interval plan.intervalCount}}\n
\n
\n\n
\n فترة الاشتراك:\n من {{formatDate subscription.currentPeriodStart locale=locale}}\n إلى {{formatDate subscription.currentPeriodEnd locale=locale}}\n
\n
\n\n {{#if invoice.lineItems.length}}\n
\n

تفاصيل الفاتورة

\n \n \n \n \n \n \n \n \n \n \n {{#each invoice.lineItems}}\n \n \n \n \n \n \n {{/each}}\n \n
البندالكميةسعر الوحدةالإجمالي
\n
{{this.description}}
\n
{{this.quantity}}{{formatCurrency this.unitPrice ../invoice.currency locale=../locale}}{{formatCurrency this.amount ../invoice.currency locale=../locale}}
\n
\n {{/if}}\n\n
\n \n\n \n
\n\n \n
\n\n\n\n"; //#endregion //#region src/templates/invoice-utils.d.ts /** * Format a date for display in the invoice */ declare const formatDate: (dateInput: Date | string | null | undefined, format?: Intl.DateTimeFormatOptions, locale?: string) => string; /** * Format a monetary amount with the specified currency and locale. */ declare function formatCurrency(amount: number | string | null, currencyCode?: string, locale?: string): string; /** * Get currency display info for templates. */ declare function getCurrencyInfo(currencyCode?: string): { symbol: string; locale: string; nameAr: string; }; /** * Invoice data structure for template rendering */ interface SubscriptionInvoiceData { invoice: Invoice; subscription: { id: string; status: string; currentPeriodStart: Date; currentPeriodEnd: Date; subscriberId: string; }; plan: { name: string; description: string | null; price: number; currency: string; interval: string; intervalCount: number; }; platform: { name: string; logo?: string; website?: string; supportEmail?: string; address?: string; }; subscriber?: { name?: string; email?: string; phone?: string; address?: string; } | undefined; locale?: string; } /** * How to resolve the Handlebars template used for invoice rendering. * Provide either `templatePath` (Node.js filesystem) or an inline * `templateSource` string (works in every runtime). When neither is given, * the built-in {@link subscriptionInvoiceTemplate} is used. */ interface RenderSubscriptionInvoiceOptions { /** Path to a `.hbs` template file (requires a filesystem; Node.js only). */ templatePath?: string; /** Inline Handlebars template source (universal, no filesystem). */ templateSource?: string; } /** * Render the subscription invoice HTML. * * Backward compatible: the first argument may still be a template path * string. Prefer the options form — with `templateSource` or no arguments at * all the built-in template is used and no filesystem is touched. */ declare function renderSubscriptionInvoice(templatePath: string, data: SubscriptionInvoiceData): Promise; declare function renderSubscriptionInvoice(options: RenderSubscriptionInvoiceOptions | undefined, data: SubscriptionInvoiceData): Promise; declare function renderSubscriptionInvoice(data: SubscriptionInvoiceData): Promise; /** * Generate PDF bytes from rendered HTML using the given renderer. */ declare function generatePdfWith(renderer: PdfRenderer, html: string): Promise; /** * Options for {@link wrapInvoiceForPrint}. */ interface PrintWrapOptions { /** * Automatically open the browser print dialog once the page loads. * The user can then print or "Save as PDF" client-side — no server-side * Chromium needed. * @default false */ autoPrint?: boolean; /** * Show a small floating "Print / Save as PDF" toolbar on screen. * The toolbar is hidden when printing (`@media print`). * @default true */ toolbar?: boolean; } /** * Wrap a rendered invoice HTML document for client-side printing. * * Injects print-friendly CSS (`@page` margins, screen-only toolbar hiding) * and, optionally, an auto-print script so the browser's print dialog opens * on load. This is the zero-cost alternative to server-side PDF generation: * return the HTML and let the client print or "Save as PDF". * * Pure string manipulation — works in every runtime (Node, Bun, Deno, * Cloudflare Workers). */ declare function wrapInvoiceForPrint(html: string, options?: PrintWrapOptions): string; /** * Generate a PDF buffer from invoice data. * * Backward compatible: still accepts a template path and renders with * puppeteer under Node.js by default. Pass `options.renderer` to use any * {@link PdfRenderer} (e.g. Cloudflare Browser Rendering in Workers), and/or * the options form of the first argument to render without a filesystem. */ declare function generateSubscriptionInvoicePdf(templatePath: string, data: SubscriptionInvoiceData, options?: GenerateSubscriptionInvoicePdfOptions): Promise; declare function generateSubscriptionInvoicePdf(templateOptions: RenderSubscriptionInvoiceOptions | undefined, data: SubscriptionInvoiceData, options?: GenerateSubscriptionInvoicePdfOptions): Promise; /** * Options for {@link generateSubscriptionInvoicePdf}. */ interface GenerateSubscriptionInvoicePdfOptions { /** * Path to the Chromium/Chrome executable (Node.js default renderer only). */ chromiumPath?: string; /** * PDF renderer to use. Defaults to the Node.js puppeteer renderer. */ renderer?: PdfRenderer; } //#endregion export { formatCurrency as a, generateSubscriptionInvoicePdf as c, renderSubscriptionInvoice as d, wrapInvoiceForPrint as f, SubscriptionInvoiceData as i, getCurrencyInfo as l, PrintWrapOptions as n, formatDate as o, subscriptionInvoiceTemplate as p, RenderSubscriptionInvoiceOptions as r, generatePdfWith as s, GenerateSubscriptionInvoicePdfOptions as t, handlebars as u }; //# sourceMappingURL=invoice-utils-5kEz_8RQ.d.ts.map