@hidemikimura/receipt-html-to-pdf 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +20 -11
- package/dist/receipt-html-to-pdf.min.js +17 -16
- package/dist/receipt-html-to-pdf.min.js.map +4 -4
- package/examples/cdn.html +2 -2
- package/package.json +1 -1
- package/skills/receipt-html-to-pdf/SKILL.md +30 -5
- package/skills/receipt-html-to-pdf/references/receipt-format.md +3 -1
- package/src/font/gsub.js +229 -0
- package/src/index.js +26 -1
- package/src/pacer.js +50 -0
- package/src/page.js +195 -22
- package/src/paginate.js +19 -0
- package/src/pdf/content.js +44 -2
- package/src/pdf/outline.js +103 -0
- package/src/pdf/shading.js +113 -0
- package/src/walker/gradient.js +193 -0
- package/src/walker/image.js +77 -0
- package/src/walker/svg-path.js +342 -0
- package/src/walker/text.js +29 -2
- package/src/walker/walk.js +330 -24
- package/types/font/gsub.d.ts +47 -0
- package/types/index.d.ts +38 -1
- package/types/pacer.d.ts +11 -0
- package/types/page.d.ts +6 -1
- package/types/paginate.d.ts +1 -0
- package/types/pdf/content.d.ts +18 -1
- package/types/pdf/outline.d.ts +41 -0
- package/types/pdf/shading.d.ts +44 -0
- package/types/walker/gradient.d.ts +25 -0
- package/types/walker/image.d.ts +36 -0
- package/types/walker/svg-path.d.ts +31 -0
- package/types/walker/text.d.ts +4 -0
- package/types/walker/walk.d.ts +72 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
設計と経緯の詳細は docs/design.md。
|
|
4
4
|
|
|
5
|
+
## 0.4.0 — リンク注釈としおり(2026-09-20)
|
|
6
|
+
|
|
7
|
+
### 追加
|
|
8
|
+
|
|
9
|
+
- **リンク注釈に対応**。`<a href>` を PDF のリンク注釈(`/Annot /Link`)にする。既定で有効、止めるなら `links: false`(docs/design.md 26 章)
|
|
10
|
+
- 外部 URL・`mailto:` / `tel:`・文書内リンク(`href="#id"` → その要素が載るページへ `/Dest [page /XYZ]`)。`<a name>` も飛び先になる
|
|
11
|
+
- 折り返したインラインリンクは行ごとに、ページ境界を跨ぐリンクはページごとに切り取って注釈を作る
|
|
12
|
+
- ヘッダー/フッターの中のリンクも各ページに出る
|
|
13
|
+
- `javascript:` と、飛び先の無い `#id` は注釈にしない。相対 URL は `baseUrl` で解決する
|
|
14
|
+
- `transform` の中のリンクは外接矩形で近似する(PDF の注釈は軸並行の矩形しか持てないため)
|
|
15
|
+
- **`outline: true` でしおり(`/Outlines`)を作る**。`h1`〜`h6` の入れ子から目次の木を組み立て、各項目をその見出しのページへ飛ばす。既定は作らない
|
|
16
|
+
|
|
17
|
+
## 0.3.0 — 描画と大きな文書の強化(2026-09-20)
|
|
18
|
+
|
|
19
|
+
### 追加
|
|
20
|
+
|
|
21
|
+
- **`onProgress` を追加**。`render` → `walk` → `layout`(総ページ数が確定)→ `page`(1 ページずつ)→ `done` の順に進み具合を通知する(docs/design.md 25 章)
|
|
22
|
+
- **長い変換でメインスレッドを占有しなくなった**。12ms ごとにイベントループへ戻す(`scheduler.yield()` があればそれを使う)。3000 行・130 ページの文書で、走査中に描画されるフレーム数が 0 → 5、変換全体の最長フレーム間隔が 934ms → 181ms。所要時間の増加は約 9%
|
|
23
|
+
- **埋め込み後にデコード済み画像データを解放する**。以前はデコード結果(RGB・アルファ)が URL キーのキャッシュに永久に残っていた。600×600 の透過 PNG 12 枚で、変換後に残るメモリが約 17MB → 1.3MB。次の変換では読み直しになる(速度よりメモリを優先)
|
|
24
|
+
- **`background-repeat` に対応**。`repeat` / `no-repeat` / `repeat-x` / `repeat-y` / `space` / `round` と、軸ごとの 2 値指定(`repeat space` など)
|
|
25
|
+
- タイルは同じ画像 XObject を参照するので、繰り返しても画像の埋め込みは 1 回だけ
|
|
26
|
+
- `round` はタイルの大きさを調整して整数個収め、`space` は余りを隙間に等分する(CSS 仕様どおり)
|
|
27
|
+
- タイルが 4000 枚を超える場合のみ、1 枚だけ描いて警告する
|
|
28
|
+
- **GSUB の単一置換に対応**。ブラウザが `font-variant-numeric` / `-caps` / `-east-asian` / `font-feature-settings` で有効にした機能と同じグリフ置換を PDF でも行う(docs/design.md 23 章)
|
|
29
|
+
- `zero`(スラッシュ付きゼロ)、`jp78` / `jp83` / `jp90` / `jp04` / `nlck` / `trad` / `smpl`(旧字体・異体字)、`fwid` / `hwid`、`smcp` など
|
|
30
|
+
- 置換は埋め込み前に解決するので、GSUB テーブル自体は PDF に入らない。抽出テキストは元の文字のまま(ToUnicode は変えない)
|
|
31
|
+
- 合字(`liga` / `dlig`、Lookup タイプ 4)は未対応。既定で有効な機能(`ccmp` / `liga` / `calt`)は適用しない
|
|
32
|
+
- 調査の結果 `tabular-nums` は日本語フォントに `tnum` 機能が無く効かないことが分かったため、数字の桁揃えはフォント選択で解決する旨をドキュメントに明記した
|
|
33
|
+
- **インライン `<svg>` のベクター変換に対応**。ラスタライズせず PDF のパスとして出すので、拡大しても滑らかで、テキスト以外の図形はそのまま印刷品質になる(docs/design.md 22 章)
|
|
34
|
+
- `<path>` の全コマンド(`M L H V C S Q T A Z`、相対・絶対)。円弧と二次ベジェは 3 次ベジェへ変換
|
|
35
|
+
- `<rect>`(`rx` / `ry`)・`<circle>`・`<ellipse>`・`<line>`・`<polyline>`・`<polygon>`・`<g>`・入れ子の `<svg>`
|
|
36
|
+
- `fill` / `fill-rule` / `fill-opacity`、`stroke` と `-width` / `-opacity` / `-linecap` / `-linejoin` / `-miterlimit` / `-dasharray` / `-dashoffset`、`opacity`、`visibility`
|
|
37
|
+
- `viewBox` / `preserveAspectRatio` / `transform` は `getScreenCTM()` の結果をそのまま使う
|
|
38
|
+
- `<svg>` はページ境界で分割しない
|
|
39
|
+
- `<text>` / `<use>` / paint server(`fill="url(#id)"`)は警告して飛ばす。`<img src="x.svg">` は従来どおりラスタライズ
|
|
40
|
+
- **`linear-gradient` に対応**。PDF の軸シェーディング(ShadingType 2)としてベクター出力するので、拡大しても滑らかで、ファイルも軽い(docs/design.md 21 章)
|
|
41
|
+
- 角度(`<n>deg` / `to <side>` / `to <side> <side>`)、色止めの `%` / `px` / 位置省略(等間隔)/ 二重指定、単調化に対応
|
|
42
|
+
- 色止めごとにアルファが変わる場合(`transparent` → `black` など)は輝度ソフトマスクで正確に再現する
|
|
43
|
+
- `background-origin` / `background-clip` / `border-radius` を尊重する
|
|
44
|
+
- `repeating-linear-gradient` / `radial-gradient` / `conic-gradient` / 複数背景は従来どおり警告
|
|
45
|
+
- **`break-before: avoid` / `break-after: avoid`(`page-break-*: avoid`)に対応**。隣の箱との間にページ境界を置かず、置きそうなら前の箱の先頭まで境界を戻す。見出しがページ末尾に取り残されるのを防げる
|
|
46
|
+
- 兄弟が無ければ親をさかのぼるので、`<section>` の最後の見出しに書いても次の `<section>` と結びつく
|
|
47
|
+
- 境界は次の箱の上端ではなく**最初の行**まで判定する(`line-height` の半行分だけ箱の上端より下に来るため)
|
|
48
|
+
- 結んだ範囲が 1 ページに収まらない場合と、戻すとページが空になる場合は諦めて普通に分割する
|
|
49
|
+
|
|
5
50
|
## 0.2.1 — 右端が切れる不具合の修正(2026-09-20)
|
|
6
51
|
|
|
7
52
|
### 追加
|
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
**ドキュメント: https://hidemikimura.github.io/receipt-html-to-pdf/** ([デモ](https://hidemikimura.github.io/receipt-html-to-pdf/demo.html) / [API リファレンス](https://hidemikimura.github.io/receipt-html-to-pdf/api.html) / [対応 CSS 一覧](https://hidemikimura.github.io/receipt-html-to-pdf/css.html))
|
|
12
12
|
|
|
13
|
-
> **v0.
|
|
14
|
-
> Chromium / Firefox / WebKit の 3 ブラウザで Playwright
|
|
13
|
+
> **v0.4.0** — テキスト・背景・ボーダー・画像・角丸・2D transform・擬似要素・`overflow: hidden`・シャドウ DOM(Web Components)・`linear-gradient`・インライン `<svg>` のベクター変換・`background-repeat`・GSUB の単一置換・複数ページに加え、**リンク注釈**(外部 URL・`mailto:`・文書内 `#id`)と**しおり**(`outline: true`)に対応。長い文書では途中でイベントループへ戻すので画面が固まらず、`onProgress` で進捗を出せる。依存ゼロ、minify バンドルは gzip 28KB。
|
|
14
|
+
> Chromium / Firefox / WebKit の 3 ブラウザで Playwright テスト(テキスト抽出・ページ分割・画素差分・注釈)に合格。対応 CSS は [docs/css-support.md](docs/css-support.md)、設計と経緯は [docs/design.md](docs/design.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md)。
|
|
15
15
|
|
|
16
16
|
## 使い方
|
|
17
17
|
|
|
@@ -39,7 +39,15 @@ downloadPdf(pdf, 'receipt.pdf');
|
|
|
39
39
|
| `downloadPdf(pdf, filename)` | ブラウザでダウンロードさせる補助 |
|
|
40
40
|
| `listFonts()` / `version` | 登録済みフォントの一覧、ライブラリのバージョン |
|
|
41
41
|
|
|
42
|
-
主なオプション(`ConvertOptions`、型は `types/index.d.ts`): `page: { size, orientation, margin }`、`header` / `footer`(`{{pageNumber}}` `{{totalPages}}`)、`stylesheets: 'inherit' | 'none' | [url または CSS 文字列]`、`mediaPrint`、`fontFallback`、`metadata`、`compress`、`baseUrl`、`onWarning`。
|
|
42
|
+
主なオプション(`ConvertOptions`、型は `types/index.d.ts`): `page: { size, orientation, margin }`、`header` / `footer`(`{{pageNumber}}` `{{totalPages}}`)、`stylesheets: 'inherit' | 'none' | [url または CSS 文字列]`、`mediaPrint`、`fontFallback`、`metadata`、`compress`、`baseUrl`、`links`(既定 true、`<a href>` をリンク注釈にする)、`outline`(既定 false、見出しからしおりを作る)、`onWarning`、`onProgress`。
|
|
43
|
+
|
|
44
|
+
長い文書でも画面が固まらないよう、変換は途中でイベントループへ戻る。進捗表示を出すなら `onProgress` を使う。
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
onProgress: (p) => {
|
|
48
|
+
if (p.phase === 'page') setProgress(p.page / p.totalPages);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
43
51
|
|
|
44
52
|
サンプル: [`examples/cdn.html`](examples/cdn.html)(CDN から読むだけ、ビルド不要)、[`examples/vanilla.html`](examples/vanilla.html)(`npm run dev` 後に `/examples/vanilla.html`)、[`examples/react.jsx`](examples/react.jsx)、[`examples/lit.js`](examples/lit.js)(シャドウ DOM はそのまま変換できる)。
|
|
45
53
|
|
|
@@ -58,14 +66,14 @@ npm install @hidemikimura/receipt-html-to-pdf
|
|
|
58
66
|
```html
|
|
59
67
|
<script type="module">
|
|
60
68
|
import { registerFont, htmlToPdf, downloadPdf }
|
|
61
|
-
from 'https://cdn.jsdelivr.net/npm/@hidemikimura/receipt-html-to-pdf@0.
|
|
69
|
+
from 'https://cdn.jsdelivr.net/npm/@hidemikimura/receipt-html-to-pdf@0.4.0/dist/receipt-html-to-pdf.min.js';
|
|
62
70
|
|
|
63
71
|
await registerFont({ family: 'BIZ UDPGothic', src: '/fonts/BIZUDPGothic-Regular.ttf' });
|
|
64
72
|
downloadPdf(await htmlToPdf(document.querySelector('#receipt')), 'receipt.pdf');
|
|
65
73
|
</script>
|
|
66
74
|
```
|
|
67
75
|
|
|
68
|
-
バージョン(`@0.
|
|
76
|
+
バージョン(`@0.4.0`)は固定すること。unpkg でも同じ。グローバル変数を配るビルド(IIFE / UMD)は用意していないが、`import * as ReceiptHtmlToPdf` して `window` に載せれば `type="module"` でない普通のスクリプトからも呼べる。ファイル 1 つで動く一式は [`examples/cdn.html`](examples/cdn.html)。
|
|
69
77
|
|
|
70
78
|
## 開発
|
|
71
79
|
|
|
@@ -93,15 +101,16 @@ brew install qpdf # 任意: 生成 PDF の構造
|
|
|
93
101
|
|
|
94
102
|
CI(`.github/workflows/ci.yml`)は typecheck → 単体テスト → サイズ検査の後、3 ブラウザ並列でブラウザテストを流し、生成された PDF を `qpdf --check` で検証する。
|
|
95
103
|
|
|
96
|
-
## 対応範囲(v0.
|
|
104
|
+
## 対応範囲(v0.4.0)
|
|
97
105
|
|
|
98
106
|
| 対応 | 未対応(onWarning で通知) |
|
|
99
107
|
|---|---|
|
|
100
|
-
| テキスト(日本語・サブセット埋め込み・ToUnicode)、`color`、`opacity`、`text-decoration` | `box-shadow`、`text-shadow`、`filter`、`clip-path`、`outline
|
|
101
|
-
| `background-color`、`border-*`(solid / dashed / dotted、辺ごと)、`border-collapse`、`border-radius` | 非均一ボーダー +
|
|
102
|
-
| `<img>`(PNG 透過 / JPEG、`object-fit`)、`background-image: url()`(size / position)、`overflow: hidden`
|
|
108
|
+
| テキスト(日本語・サブセット埋め込み・ToUnicode)、`color`、`opacity`、`text-decoration`、GSUB の単一置換(`zero`・`jp90` などの異体字・`fwid` / `hwid`・`smcp`) | `box-shadow`、`text-shadow`、`filter`、`clip-path`、`outline`、縦書き、合字(`liga` / `dlig`) |
|
|
109
|
+
| `background-color`、`background-image: linear-gradient()`(軸シェーディングでベクター出力)、`background-repeat`(`repeat` / `-x` / `-y` / `space` / `round`)、`border-*`(solid / dashed / dotted、辺ごと)、`border-collapse`、`border-radius` | 非均一ボーダー + 角丸(直線で近似)、`repeating-` / `radial-` / `conic-gradient` |
|
|
110
|
+
| `<img>`(PNG 透過 / JPEG、`object-fit`)、`background-image: url()`(size / position)、`overflow: hidden` のクリップ、**インライン `<svg>` のベクター変換**(パス・基本図形・塗り・線・破線・変換行列) | SVG の `<text>` / `<use>` / paint server(警告)、`<img src="x.svg">` はラスタライズ |
|
|
103
111
|
| `transform`(2D、`transform-origin`)、`::before` / `::after`(文字列 content) | 3D transform、`counter()` / `url()` content |
|
|
104
|
-
| 複数ページ: 行・`tr`・`thead`・`tfoot`・`<img>`・`break-inside: avoid` を跨がない分割、`break-before/after: page`、`thead` / `tfoot` の各ページ繰り返し、`header` / `footer` テンプレート(`{{pageNumber}}` `{{totalPages}}`) | `
|
|
112
|
+
| 複数ページ: 行・`tr`・`thead`・`tfoot`・`<img>`・`break-inside: avoid` を跨がない分割、`break-before/after: page`、`break-before/after: avoid`(隣の箱と同じページに保つ)、`thead` / `tfoot` の各ページ繰り返し、`header` / `footer` テンプレート(`{{pageNumber}}` `{{totalPages}}`) | `orphans` / `widows`、ページ番号による高さ変化 |
|
|
113
|
+
| リンク注釈(`<a href>` の外部 URL・`mailto:`・文書内 `#id`、ページ跨ぎは分割)、`outline: true` で `h1`〜`h6` からしおり | `transform` 内のリンクは外接矩形で近似、`javascript:` は無視 |
|
|
105
114
|
| Web Components: シャドウ DOM のホスト要素をそのまま変換(宣言的シャドウ DOM で直列化)、`<slot>` の割り当て、`:host` / `::slotted()`、`adoptedStyleSheets`、`:defined` | `closed` なシャドウルート、`Element.getHTML()` の無いブラウザ(警告して light DOM のみ) |
|
|
106
115
|
| レイアウト全般(Flexbox / Grid / テーブル / 禁則 / letter-spacing)はブラウザ計算をそのまま利用 | |
|
|
107
116
|
|
|
@@ -141,7 +150,7 @@ npm run site:dev # 組み立てて http://localhost:5174 で表示
|
|
|
141
150
|
2. `npm run pack:check` で tarball の内容を確認する(`files` で許可リスト管理。フォント・フィクスチャ・テストは含まれない)
|
|
142
151
|
3. `npm login`(スコープ `@hidemikimura` の所有者アカウント)
|
|
143
152
|
4. `npm publish` — `prepublishOnly` が typecheck → 単体テスト → `.d.ts` 生成 → minify ビルド + サイズ検査を自動で流す。`publishConfig.access` が `public` なのでスコープ付きでも無料で公開される
|
|
144
|
-
5. `git tag v0.
|
|
153
|
+
5. `git tag v0.4.0 && git push --tags`
|
|
145
154
|
|
|
146
155
|
## ライセンス
|
|
147
156
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/* @hidemikimura/receipt-html-to-pdf v0.
|
|
2
|
-
function
|
|
1
|
+
/* @hidemikimura/receipt-html-to-pdf v0.4.0 | MIT */
|
|
2
|
+
function Xt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),s=n.getUint32(0);if(s===1330926671)throw new Error("CFF outlines (OpenType/CFF) are not supported. Use a TrueType (glyf) font.");if(s===2001684038||s===2001684018)throw new Error("WOFF/WOFF2 are not supported. Use a raw .ttf file.");if(s===1953784678)throw new Error("TrueType collections (.ttc) are not supported. Extract a single face first.");if(s!==65536&&s!==1953658213)throw new Error("Not a TrueType font (bad sfnt version)");let o=n.getUint16(4),r=new Map;for(let l=0;l<o;l++){let h=12+l*16,y=String.fromCharCode(t[h]??0,t[h+1]??0,t[h+2]??0,t[h+3]??0);r.set(y,{offset:n.getUint32(h+8),length:n.getUint32(h+12)})}if(r.has("CFF "))throw new Error("CFF outlines are not supported. Use a TrueType (glyf) font.");let i=r.has("fvar");for(let l of["head","hhea","maxp","hmtx","loca","glyf"])if(!r.has(l))throw new Error(`Font is missing required table: ${l}`);let c=l=>r.get(l),a=c("head"),u=n.getUint16(a.offset+18),m=[n.getInt16(a.offset+36),n.getInt16(a.offset+38),n.getInt16(a.offset+40),n.getInt16(a.offset+42)],f=n.getUint16(a.offset+44),b=n.getInt16(a.offset+50),g=c("hhea"),d=n.getInt16(g.offset+4),p=n.getInt16(g.offset+6),T=n.getInt16(g.offset+8),P=n.getUint16(g.offset+34),x=n.getUint16(c("maxp").offset+4),L=c("hmtx"),N=new Uint16Array(x),q=0;for(let l=0;l<x;l++)l<P&&(q=n.getUint16(L.offset+l*4)),N[l]=q;let H=c("loca"),W=new Uint32Array(x+1);for(let l=0;l<=x;l++)W[l]=b===0?n.getUint16(H.offset+l*2)*2:n.getUint32(H.offset+l*4);let J=r.get("cmap"),D=J?Le(n,J.offset):new Map,B=Math.round(d*.7),K=!1,ft=d,nt=p,st=d,at=-p,ct=(f&1)!==0,Y=(f&2)!==0,Z=r.get("OS/2");if(Z){let l=n.getUint16(Z.offset),h=n.getUint16(Z.offset+62);if(K=(h&128)!==0,ct=ct||(h&32)!==0,Y=Y||(h&1)!==0,ft=n.getInt16(Z.offset+68),nt=n.getInt16(Z.offset+70),st=n.getUint16(Z.offset+74),at=n.getUint16(Z.offset+76),l>=2&&Z.length>=90){let y=n.getInt16(Z.offset+88);y>0&&(B=y)}}let rt=0,$=r.get("post");$&&(rt=n.getInt32($.offset+4)/65536);let S=Oe(n,t,r.get("name"))??"Embedded";return{data:t,tables:r,unitsPerEm:u,indexToLocFormat:b,bbox:m,ascender:d,descender:p,lineGap:T,numGlyphs:x,advances:N,loca:W,cmap:D,capHeight:B,italicAngle:rt,useTypoMetrics:K,typoAscender:ft,typoDescender:nt,winAscent:st,winDescent:at,postScriptName:S,bold:ct,italic:Y,variable:i}}function Le(e,t){let n=e.getUint16(t+2),s=-1,o=-1;for(let c=0;c<n;c++){let a=t+4+c*8,u=e.getUint16(a),m=e.getUint16(a+2),f=e.getUint32(a+4),b=e.getUint16(t+f),g=-1;u===3&&m===10&&b===12?g=4:u===0&&(m===4||m===6)&&b===12?g=3:u===3&&m===1&&b===4?g=2:u===0&&b===4&&(g=1),g>o&&(o=g,s=t+f)}if(s<0)throw new Error("Font has no usable Unicode cmap subtable (format 4 or 12)");let r=new Map,i=e.getUint16(s);if(i===4){let c=e.getUint16(s+6),a=c/2,u=s+14,m=u+c+2,f=m+c,b=f+c;for(let g=0;g<a;g++){let d=e.getUint16(u+g*2),p=e.getUint16(m+g*2),T=e.getInt16(f+g*2),P=e.getUint16(b+g*2);if(p!==65535)for(let x=p;x<=d;x++){let L;if(P===0)L=x+T&65535;else{let N=b+g*2+P+(x-p)*2;if(N+2>e.byteLength)continue;L=e.getUint16(N),L!==0&&(L=L+T&65535)}L!==0&&r.set(x,L)}}}else if(i===12){let c=e.getUint32(s+12),a=s+16;for(let u=0;u<c;u++,a+=12){let m=e.getUint32(a),f=e.getUint32(a+4),b=e.getUint32(a+8);for(let g=m;g<=f&&g-m<65536;g++){let d=b+(g-m);d!==0&&r.set(g,d)}}}return r}function Oe(e,t,n){if(!n)return null;let s=e.getUint16(n.offset+2),o=e.getUint16(n.offset+4),r=null;for(let i=0;i<s;i++){let c=n.offset+6+i*12,a=e.getUint16(c),u=e.getUint16(c+6),m=e.getUint16(c+8),f=e.getUint16(c+10);if(u!==6)continue;let b=n.offset+o+f;if(a===1)return _t(String.fromCharCode(...t.subarray(b,b+m)));if(a===3||a===0){let g="";for(let d=0;d+1<m;d+=2)g+=String.fromCharCode(e.getUint16(b+d));r=_t(g)}}return r}function _t(e){return e.replace(/[^\x21-\x7e]/g,"").replace(/[\[\]\(\)\{\}<>\/%#]/g,"")||"Embedded"}function It(e,t){let n=e.tables.get("glyf"),s=e.loca[t]??0,o=e.loca[t+1]??s;return e.data.subarray(n.offset+s,n.offset+o)}function Yt(e){if(e.length<10)return[];let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getInt16(0)>=0)return[];let s=[],o=10;for(;;){let r=t.getUint16(o),i=t.getUint16(o+2);if(s.push(i),o+=4,o+=r&1?4:2,r&8?o+=2:r&64?o+=4:r&128&&(o+=8),!(r&32)||o>=e.length)break}return s}var Tt=class{constructor(){this.fonts=[]}async register(t){let n=await De(t.src),s=Xt(n),o={family:Rt(t.family),displayFamily:t.family,weight:t.weight??400,style:t.style??"normal",parsed:s},r=this.fonts.findIndex(i=>i.family===o.family&&i.weight===o.weight&&i.style===o.style);return r>=0?this.fonts[r]=o:this.fonts.push(o),o}hasFamily(t){let n=Rt(t);return this.fonts.some(s=>s.family===n)}match(t,n,s,o){for(let r of t){let i=Rt(r),c=this.fonts.filter(a=>a.family===i);if(o!==void 0&&(c=c.filter(a=>a.parsed.cmap.has(o))),!!c.length)return Zt(c,n,s)}return null}anyWithGlyph(t,n,s){let o=this.fonts.filter(r=>r.parsed.cmap.has(t));return o.length?Zt(o,n,s):null}};function Zt(e,t,n){let s=e.filter(u=>u.style===n),o=s.length?s:e,r=o.find(u=>u.weight===t);if(r)return r;let i=[...o].sort((u,m)=>u.weight-m.weight),c=i.filter(u=>u.weight>t),a=i.filter(u=>u.weight<t).reverse();if(t>=400&&t<=500){let u=c.find(m=>m.weight<=500);return u||(a.length?a[0]:c[0])}return t<400?a[0]??c[0]:c[0]??a[0]}function Rt(e){return e.trim().replace(/^["']|["']$/g,"").trim().toLowerCase()}function Kt(e){let t=[],n="",s="";for(let o of e)s?o===s?s="":n+=o:o==='"'||o==="'"?s=o:o===","?(n.trim()&&t.push(n.trim()),n=""):n+=o;return n.trim()&&t.push(n.trim()),t}function Qt(e){if(e==="bold")return 700;if(e==="normal")return 400;let t=parseInt(e,10);return Number.isFinite(t)?t:400}async function De(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch font ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}async function Lt(e,t){let n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText=`position:fixed;left:-100000px;top:0;width:${t.widthPx}px;height:1000px;border:0;visibility:hidden;pointer-events:none;`,document.body.appendChild(n);let s=n.contentWindow,o=n.contentDocument;if(!s||!o)throw new Error("Failed to create rendering iframe");let r=Be(e,t);o.open(),o.write(r),o.close(),Ve(o,s);let i=()=>{n.style.height=`${Math.max(o.documentElement.scrollHeight,o.body.scrollHeight,100)}px`};return i(),await Xe(o),i(),await Ye(o),await Ze(o),Ke(o,t.warn??(()=>{})),i(),o.body.offsetHeight,Ge(o,t.widthPx,t.warn??(()=>{})),{iframe:n,doc:o,win:s,root:o.body,destroy:()=>n.remove()}}function Be(e,t){let n=t.baseUrl??document.baseURI,s=`<base href="${wt(n)}">`,o="<style data-rhtp-reset>html,body{margin:0 !important;padding:0 !important;background:transparent}html{-webkit-text-size-adjust:100%}</style>";if(typeof e=="string"){if(/<html[\s>]/i.test(e)){let m=e;return m=/<head[^>]*>/i.test(m)?m.replace(/<head[^>]*>/i,f=>`${f}${s}${o}`):m.replace(/<html[^>]*>/i,f=>`${f}<head>${s}${o}</head>`),t.mediaPrint?_e(m):m}let u=Jt(t.stylesheets,t.mediaPrint);return`<!DOCTYPE html><html><head><meta charset="utf-8">${s}${o}${u}</head><body>${e}</body></html>`}let r=Jt(t.stylesheets,t.mediaPrint)+je(e,t.stylesheets,t.mediaPrint),i=vt(document.documentElement),c=vt(document.body),a=ze(e,t.warn??(()=>{}));return`<!DOCTYPE html><html${i}><head><meta charset="utf-8">${s}${o}${r}</head><body${c}>${a}</body></html>`}function Jt(e,t){if(e==="none")return"";let n=[];if(e==="inherit"){for(let o of document.querySelectorAll('style, link[rel~="stylesheet"]'))if(!o.hasAttribute("data-rhtp-reset"))if(o instanceof HTMLStyleElement){let r=o.textContent??"";n.push(`<style>${t?bt(r):r}</style>`)}else o instanceof HTMLLinkElement&&n.push(`<link rel="stylesheet" href="${wt(o.href)}"${o.media?` media="${wt(o.media)}"`:""}>`);let s=Ot(document.adoptedStyleSheets);return s&&n.push(`<style>${t?bt(s):s}</style>`),n.join("")}for(let s of e)/^(https?:)?\/\/|^\.{0,2}\/|\.css(\?|$)/i.test(s)&&!s.includes("{")?n.push(`<link rel="stylesheet" href="${wt(s)}">`):n.push(`<style>${t?bt(s):s}</style>`);return n.join("")}function je(e,t,n){if(t!=="inherit")return"";let s=[],o=e.getRootNode();for(;o&&o!==document&&"host"in o;){let r=o,i=[...r.querySelectorAll("style")].map(c=>c.textContent??"").join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`+
|
|
5
|
-
`)}function de(e,t){let n=t.customElements,s=t.HTMLElement;if(!n||!s)return;let o=new Set,r=i=>{for(let a of i.querySelectorAll("*"))a.tagName.includes("-")&&!a.hasAttribute("is")&&o.add(a.tagName.toLowerCase()),a.shadowRoot&&r(a.shadowRoot)};r(e);for(let i of o)if(!n.get(i))try{n.define(i,class extends s{})}catch{}}function ue(e){return e.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(t,n,s)=>`<style${n}>${ot(s)}</style>`)}function ot(e){let t="",n=0;for(;n<e.length;){let s=/@media\s*([^{]+)\{/g;s.lastIndex=n;let o=s.exec(e);if(!o){t+=e.slice(n);break}t+=e.slice(n,o.index);let r=1,i=s.lastIndex;for(;i<e.length&&r>0;)e[i]==="{"?r++:e[i]==="}"&&r--,i++;let a=o[1].trim(),c=e.slice(s.lastIndex,i-1);/\bprint\b/.test(a)?t+=c:/^\s*(only\s+)?screen\b/.test(a)&&!/\band\b/.test(a)?t+="":t+=e.slice(o.index,i),n=i}return t}function xt(e){let t="";for(let n of e.attributes)/^on/i.test(n.name)||(t+=` ${n.name}="${it(n.value)}"`);return t}function it(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}async function pe(e){let t=[...e.querySelectorAll('link[rel~="stylesheet"]')];await Promise.all(t.map(n=>new Promise(s=>{let o=n;if(o.sheet)return s(void 0);o.addEventListener("load",()=>s(void 0),{once:!0}),o.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}async function me(e){if(e.body.offsetHeight,e.fonts){await e.fonts.ready;let t=[...e.fonts].filter(n=>n.status==="loading").map(n=>n.loaded.catch(()=>{}));t.length&&await Promise.all(t),await e.fonts.ready}}async function ge(e){let t=[...e.images];await Promise.all(t.map(n=>n.complete?n.decode().catch(()=>{}):new Promise(s=>{n.addEventListener("load",()=>n.decode().catch(()=>{}).then(s),{once:!0}),n.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}function ye(e,t){let n=e.defaultView;if(!n)return;let s=[];for(let i of be(e.body))for(let a of["before","after"]){let c=n.getComputedStyle(i,`::${a}`),h=c.content;if(!h||h==="none"||h==="normal"||c.display==="none")continue;let p=we(h);if(p===null){t({code:"unsupported-css",message:`::${a} content "${h}" is not supported (only quoted strings are); the pseudo-element is skipped`,element:i,property:"content"});continue}let f=[];for(let d=0;d<c.length;d++){let u=c[d];u==="content"||u.startsWith("-webkit-")||u.startsWith("-moz-")||f.push([u,c.getPropertyValue(u)])}s.push({el:i,pseudo:a,text:p,styles:f})}if(!s.length)return;let o='[data-rhtp-pseudo-host~="before"]::before{content:none!important;display:none!important}[data-rhtp-pseudo-host~="after"]::after{content:none!important;display:none!important}',r=e.createElement("style");r.setAttribute("data-rhtp-pseudo",""),r.textContent=o,e.head.appendChild(r);for(let i of new Set(s.map(a=>a.el.getRootNode()).filter(a=>a!==e))){let a=e.createElement("style");a.setAttribute("data-rhtp-pseudo",""),a.textContent=o,i.appendChild(a)}for(let i of s){let a=e.createElement("span");a.setAttribute("data-rhtp-pseudo",i.pseudo);for(let[h,p]of i.styles)a.style.setProperty(h,p);a.textContent=i.text;let c=(i.el.getAttribute("data-rhtp-pseudo-host")??"").split(" ").filter(Boolean);c.push(i.pseudo),i.el.setAttribute("data-rhtp-pseudo-host",c.join(" ")),i.pseudo==="before"?i.el.insertBefore(a,i.el.firstChild):i.el.appendChild(a)}}function be(e){let t=[],n=s=>{for(let o of s.querySelectorAll("*"))t.push(o),o.shadowRoot&&n(o.shadowRoot)};return n(e),t}function we(e){let t="",n=0,s=e.trim();for(;n<s.length;){let o=s[n];if(o===" "||o===" "){n++;continue}if(o!=='"'&&o!=="'")return null;let r=o;for(n++;n<s.length&&s[n]!==r;)if(s[n]==="\\"){n++;let i=/^[0-9a-fA-F]{1,6}/.exec(s.slice(n));i?(t+=String.fromCodePoint(parseInt(i[0],16)),n+=i[0].length,s[n]===" "&&n++):(t+=s[n]??"",n++)}else t+=s[n],n++;n++}return t}var _=2.834645669291339,$t={A3:{width:297*_,height:420*_},A4:{width:210*_,height:297*_},A5:{width:148*_,height:210*_},B4:{width:257*_,height:364*_},B5:{width:182*_,height:257*_},Letter:{width:612,height:792},Legal:{width:612,height:1008}};function Y(e){if(typeof e=="number")return e*.75;let t=/^\s*(-?[\d.]+)\s*([a-z%]*)\s*$/i.exec(e);if(!t)throw new Error(`Invalid CSS length: ${e}`);let n=parseFloat(t[1]);switch((t[2]??"").toLowerCase()){case"":case"px":return n*.75;case"pt":return n;case"mm":return n*_;case"cm":return n*_*10;case"in":return n*72;case"pc":return n*12;default:throw new Error(`Unsupported CSS unit: ${e}`)}}function q(e){let t=parseFloat(e);return Number.isFinite(t)?t:0}function st(e){if(!e)return null;let t=e.trim();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(t);if(n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:tt(parseFloat(n[1])/255),g:tt(parseFloat(n[2])/255),b:tt(parseFloat(n[3])/255),a:tt(s)}}if(n=/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*(?:\/\s*([\d.]+%?)\s*)?\)$/i.exec(t),n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:tt(parseFloat(n[1])),g:tt(parseFloat(n[2])),b:tt(parseFloat(n[3])),a:tt(s)}}if(n=/^#([0-9a-f]{3,8})$/i.exec(t),n){let s=n[1];(s.length===3||s.length===4)&&(s=s.split("").map(r=>r+r).join(""));let o=parseInt(s.padEnd(8,"f"),16);return{r:(o>>>24&255)/255,g:(o>>>16&255)/255,b:(o>>>8&255)/255,a:(o&255)/255}}return null}function tt(e){return e<0?0:e>1?1:e}function U(e){if(!Number.isFinite(e))return"0";let t=e.toFixed(3),n=t.includes(".")?t.replace(/\.?0+$/,""):t;return n===""||n==="-0"||n==="-"?"0":n}var xe=new Set([32,9,10,13,12,160,12288,8194,8195,8201,8202,8239,8287]);function Ot(e,t,n){let s=e.ownerDocument,o=$e(e.data,t.textTransform),r=s.createRange(),i=Ce(s,t),a=[],c=null,h=NaN,p=new Set;for(let f=0;f<o.length;){let d=o.codePointAt(f),u=d>65535?2:1,w=f+u;r.setStart(e,f),r.setEnd(e,Math.min(w,e.data.length));let y=Se(r.getClientRects());if(f=w,!y)continue;let C=Te(d,n,p);if(!C)continue;let{font:O,gid:R,cpForUnicode:D}=C,L=y.top;(!c||c.font!==O||Math.abs(L-h)>.5)&&(c={font:O,baseline:L+i,top:L,bottom:y.bottom,glyphs:[]},h=L,a.push(c)),c.top=Math.min(c.top,L),c.bottom=Math.max(c.bottom,y.bottom);let j=(O.parsed.advances[R]??0)*n.size/O.parsed.unitsPerEm;c.glyphs.push({gid:R,cp:D,x:y.left,advance:j})}return a}function Se(e){let t=null;for(let n of e)n.width>.01&&(!t||n.width>t.width)&&(t=n);return t}function Te(e,t,n){let s=(i,a)=>{let c=i?.parsed.cmap.get(a);return i&&c?{font:i,gid:c,cpForUnicode:e}:null};if(xe.has(e))return s(t.primary,e)??s(t.primary,32)??s(t.registry.anyWithGlyph(32,t.weight,t.fstyle),32);let o=s(t.primary,e);if(o||(o=s(t.registry.match(t.families,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.match(t.fallback,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.anyWithGlyph(e,t.weight,t.fstyle),e),o))return o;n.has(e)||(n.add(e),t.warn({code:"missing-glyph",message:`No registered font has a glyph for U+${e.toString(16).toUpperCase().padStart(4,"0")} "${String.fromCodePoint(e)}"; substituted with U+25A1`,element:t.element,text:String.fromCodePoint(e)}));let r=s(t.primary,9633)??s(t.registry.anyWithGlyph(9633,t.weight,t.fstyle),9633);return r?{...r,cpForUnicode:e}:null}function $e(e,t){if(!t||t==="none")return e;let n=e;return t.includes("uppercase")?n=e.toUpperCase():t.includes("lowercase")?n=e.toLowerCase():t.includes("capitalize")&&(n=e.replace(new RegExp("(^|\\s)(\\p{L})","gu"),(s,o,r)=>o+r.toUpperCase())),n.length===e.length?n:e}var Dt=new WeakMap;function Ce(e,t){let n=[t.fontFamily,t.fontSize,t.fontWeight,t.fontStyle,t.fontStretch,t.fontVariant,t.fontFeatureSettings].join("|"),s=Dt.get(e);s||(s=new Map,Dt.set(e,s));let o=s.get(n);if(o!==void 0)return o;let r=e.createElement("div");r.setAttribute("data-rhtp-probe",""),r.style.cssText="position:absolute;left:0;top:0;visibility:hidden;white-space:pre;line-height:normal;margin:0;padding:0;border:0;letter-spacing:0;text-indent:0;",r.style.fontFamily=t.fontFamily,r.style.fontSize=t.fontSize,r.style.fontWeight=t.fontWeight,r.style.fontStyle=t.fontStyle,r.style.fontStretch=t.fontStretch,r.style.fontVariant=t.fontVariant,r.style.fontFeatureSettings=t.fontFeatureSettings;let i=e.createTextNode("Ag\u3042");r.appendChild(i);let a=e.createElement("span");a.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0;",r.appendChild(a),e.body.appendChild(r);let c=e.createRange();c.selectNodeContents(i);let h=c.getBoundingClientRect(),f=a.getBoundingClientRect().bottom-h.top;r.remove();let d=Number.isFinite(f)&&f>0?f:parseFloat(t.fontSize)*.8;return s.set(n,d),d}var vt=new Map;function Ct(e,t,n){let s=vt.get(e);return s||(s=Fe(e,t,n).catch(o=>(t({code:"image-failed",message:`Failed to load image ${e}: ${o instanceof Error?o.message:String(o)}`,element:n}),null)),vt.set(e,s)),s}async function Fe(e,t,n){let s=null;try{let y=await fetch(e,{mode:"cors",credentials:"same-origin"});y.ok&&(s=new Uint8Array(await y.arrayBuffer()))}catch{s=null}if(s&&s[0]===255&&s[1]===216){let y=Ue(s);if(y&&y.components===3)return{key:e,width:y.width,height:y.height,jpeg:s,rgb:null,alpha:null}}let o=new Image;o.crossOrigin="anonymous",o.decoding="sync";let r=new Promise((y,C)=>{o.onload=()=>y(void 0),o.onerror=()=>C(new Error("image failed to load"))});if(s){let y=URL.createObjectURL(new Blob([s]));o.src=y;try{await r}finally{URL.revokeObjectURL(y)}}else o.src=e,await r;let i=o.naturalWidth,a=o.naturalHeight;if(!i||!a)throw new Error("image has no intrinsic size");let c=document.createElement("canvas");c.width=i,c.height=a;let h=c.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("2D canvas unavailable");h.drawImage(o,0,0);let p;try{p=h.getImageData(0,0,i,a)}catch{return t({code:"image-failed",message:`Image ${e} is cross-origin without CORS headers; add crossorigin="anonymous" and Access-Control-Allow-Origin. Skipped.`,element:n}),null}let f=p.data,d=new Uint8Array(i*a*3),u=new Uint8Array(i*a),w=!0;for(let y=0,C=0,O=0;y<f.length;y+=4,C+=3,O++){let R=f[y+3];R===0?d[C]=d[C+1]=d[C+2]=255:(d[C]=f[y],d[C+1]=f[y+1],d[C+2]=f[y+2]),u[O]=R,R!==255&&(w=!1)}return{key:e,width:i,height:a,jpeg:null,rgb:d,alpha:w?null:u}}function Ue(e){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}let n=e[t+1];if(n===216||n>=208&&n<=215||n===1||n===255){t+=n===255?1:2;continue}let s=e[t+2]<<8|e[t+3];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return{height:e[t+5]<<8|e[t+6],width:e[t+7]<<8|e[t+8],components:e[t+9]};if(n===218)break;t+=2+s}return null}function Nt(e){if(!e||e==="none")return null;let t=ke(e);if(t.length!==1)return null;let n=/^url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)$/.exec(t[0].trim());return n?n[1]??n[2]??n[3]??null:null}function ke(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function ft(e,t,n,s,o){let r,i,a=s.trim();if(a==="cover"||a==="contain"){let d=a==="cover"?Math.max(e.w/t,e.h/n):Math.min(e.w/t,e.h/n);r=t*d,i=n*d}else{let[d="auto",u="auto"]=a.split(/\s+/),w=Lt(d,e.w),y=Lt(u,e.h);w===null&&y===null?(r=t,i=n):w===null?(i=y,r=t*i/n):y===null?(r=w,i=n*r/t):(r=w,i=y)}let[c="0%",h="0%"]=o.trim().split(/\s+/),p=e.x+jt(c,e.w-r),f=e.y+jt(h,e.h-i);return{x:p,y:f,w:r,h:i}}function Lt(e,t){return e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function jt(e,t){return e==="left"||e==="top"?0:e==="center"?t/2:e==="right"||e==="bottom"?t:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function zt(e){switch(e){case"contain":case"scale-down":return"contain";case"cover":return"cover";case"none":return"auto";default:return"100% 100%"}}var Ee=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","META","LINK","TITLE","BASE","IFRAME","CANVAS","VIDEO","AUDIO","SVG","OBJECT","EMBED"]);function Pe(e){let t=e.shadowRoot;if(t)return[...t.childNodes];if(e.tagName==="SLOT"){let n=e;if(typeof n.assignedNodes=="function")return n.assignedNodes({flatten:!0})}return[...e.childNodes]}var Me=[["boxShadow",e=>e!=="none"],["textShadow",e=>e!=="none"],["filter",e=>e!=="none"],["backdropFilter",e=>e!=="none"&&e!==""],["writingMode",e=>e.startsWith("vertical")],["outlineStyle",e=>e!=="none"],["clipPath",e=>e!=="none"],["mixBlendMode",e=>e!=="normal"]];async function Ft(e,t){let n=e.ownerDocument.defaultView,s=n.scrollX,o=n.scrollY,r=[],i=r,a=[],c=[],h=[],p=null,f=0,d=new Set,u=new Set;function w(l,m){d.has(l)||(d.add(l),t.warn(m))}async function y(l,m){if(Ee.has(l.tagName))return;let g=n.getComputedStyle(l);if(g.display==="none")return;let x=Ae(g.transform);if(x&&"style"in l){let S=l,F=S.getBoundingClientRect(),E=S.style.transform;S.style.transform="none",S.offsetWidth;let k=S.getBoundingClientRect(),[I,M]=Ie(g.transformOrigin),N={x:k.left+I+s,y:k.top+M+o},W=r;r=[],await O(l,n.getComputedStyle(l),m);let b=r;r=W,S.style.transform=E,S.offsetWidth,r.push({type:"group",matrix:x,origin:N,items:b,top:F.top+o,bottom:F.bottom+o,z:C(g,m.z),seq:f++});return}await O(l,g,m)}function C(l,m){if(l.position!=="static"&&l.zIndex!=="auto"){let g=parseInt(l.zIndex,10);if(Number.isFinite(g))return g}return m}async function O(l,m,g){let x=C(m,g.z),S=parseFloat(m.opacity),F=g.alpha*(Number.isFinite(S)?S:1),E=m.visibility==="visible"&&F>0;if(m.display!=="contents"&&m.display!=="inline"){let P=l.getBoundingClientRect(),H=P.top+o,K=P.bottom+o;if(P.height>0){let V=m.breakBefore||m.pageBreakBefore,ee=m.breakAfter||m.pageBreakAfter;/^(page|always|left|right|recto|verso)$/.test(V)&&c.push(H),/^(page|always|left|right|recto|verso)$/.test(ee)&&c.push(K);let kt=m.breakInside||m.pageBreakInside;(kt==="avoid"||kt==="avoid-page"||m.display==="table-row"||m.display==="table-header-group"||m.display==="table-footer-group"||l.tagName==="IMG")&&a.push({top:H,bottom:K})}}let k=null;if(m.display==="table"||m.display==="inline-table"){let P=l.getBoundingClientRect();k={top:P.top+o,bottom:P.bottom+o,headTop:0,headBottom:0,headItems:[],footTop:0,footBottom:0,footItems:[]},h.push(k)}let I=p;k&&(p=k);let M=m.display==="table-header-group"&&p&&!p.headItems.length,N=m.display==="table-footer-group"&&p&&!p.footItems.length,W=M||N?r.length:-1,b=m.overflowX!=="visible"||m.overflowY!=="visible",T=null,B=null;if(b&&m.display!=="inline"&&m.display!=="contents"&&l!==e){let P=l.getBoundingClientRect();B=z(P,m,"padding-box",Gt(m,P))}if(E&&m.display!=="contents"){R(l,m);let P=m.display==="inline"?[...l.getClientRects()]:[l.getBoundingClientRect()],H=m.borderCollapse==="collapse"&&/^table/.test(m.display)&&m.display!=="table-caption",K=P.length===1?Gt(m,P[0]):null;for(let V of P)V.width<=0&&V.height<=0||(D(V,m,F,x,K),await L(l,V,m,F,x,K),X(V,m,F,x,H,K));l.tagName==="IMG"&&P[0]&&await j(l,P[0],m,F,x,K)}let v=g.decorations,G=m.textDecorationLine;if(G&&G!=="none"){let P=st(m.textDecorationColor)??st(m.color)??{r:0,g:0,b:0,a:1};v=[...v,{line:G,color:P}]}B&&(T=r,r=[]);let Z={z:x,alpha:F,decorations:v};for(let P of Pe(l))P.nodeType===Node.TEXT_NODE?E&&et(P,l,m,Z):P.nodeType===Node.ELEMENT_NODE&&await y(P,Z);if(B&&T){let P=r.filter(H=>Re(H,B));r=T,P.length&&r.push({type:"clip",box:B,items:P,top:B.y,bottom:B.y+B.h,z:x,seq:f++})}if((M||N)&&p&&W>=0){let P=l.getBoundingClientRect(),H=r.slice(W);M?(p.headTop=P.top+o,p.headBottom=P.bottom+o,p.headItems=H):(p.footTop=P.top+o,p.footBottom=P.bottom+o,p.footItems=H)}p=I}function R(l,m){for(let[g,x]of Me){let S=String(m[g]??"");x(S)&&w(`css:${g}`,{code:"unsupported-css",message:`CSS property "${Ht(g)}" is not supported in this version and will be ignored (first seen on <${l.tagName.toLowerCase()}>: ${S})`,element:l,property:Ht(g)})}/^matrix3d/.test(m.transform)&&w("css:transform3d",{code:"unsupported-css",message:"3D transforms are not supported; the element is drawn untransformed",element:l,property:"transform"})}function D(l,m,g,x,S){let F=st(m.backgroundColor);if(!F||F.a<=0)return;let E={type:"rect",x:l.left+s,y:l.top+o,w:l.width,h:l.height,color:at(F,g),z:x,seq:f++};S&&(E.radius=S),r.push(E)}async function L(l,m,g,x,S,F){if(g.backgroundImage==="none")return;let E=Nt(g.backgroundImage);if(!E){w("css:backgroundImage",{code:"unsupported-css",message:`background-image "${g.backgroundImage}" is not supported (only a single url() is); ignored`,element:l,property:"background-image"});return}let k=await Ct(new URL(E,l.ownerDocument.baseURI).href,t.warn,l);if(!k)return;g.backgroundRepeat!=="no-repeat"&&w("css:backgroundRepeat",{code:"unsupported-css",message:`background-repeat "${g.backgroundRepeat}" is not supported; drawn once as no-repeat`,element:l,property:"background-repeat"});let I=z(m,g,g.backgroundClip||"border-box",F),M=z(m,g,g.backgroundOrigin||"padding-box",null),N=ft(M,k.width,k.height,g.backgroundSize,g.backgroundPosition);r.push({type:"image",...N,image:k,clip:I,alpha:x,z:S,seq:f++})}async function j(l,m,g,x,S,F){let E=l.currentSrc||l.src;if(!E)return;let k=await Ct(E,t.warn,l);if(!k)return;let I=z(m,g,"content-box",F),M=ft(I,k.width,k.height,zt(g.objectFit),g.objectPosition);g.objectFit==="scale-down"&&(M.w>k.width||M.h>k.height)&&Object.assign(M,ft(I,k.width,k.height,"auto",g.objectPosition)),r.push({type:"image",...M,image:k,clip:I,alpha:x,z:S,seq:f++})}function z(l,m,g,x){let S=l.left+s,F=l.top+o,E=l.width,k=l.height;if(g==="padding-box"||g==="content-box"){let M=q(m.borderTopWidth),N=q(m.borderRightWidth),W=q(m.borderBottomWidth),b=q(m.borderLeftWidth);S+=b,F+=M,E-=b+N,k-=M+W,x&&(x=x.map(T=>Math.max(0,T-Math.max(M,N,W,b))))}if(g==="content-box"){let M=q(m.paddingTop),N=q(m.paddingRight),W=q(m.paddingBottom),b=q(m.paddingLeft);S+=b,F+=M,E-=b+N,k-=M+W}let I={x:S,y:F,w:Math.max(0,E),h:Math.max(0,k)};return x&&x.some(M=>M>0)&&(I.radius=x),I}function X(l,m,g,x,S,F){let E=l.left+s,k=l.top+o,I=l.width,M=l.height,b=["Top","Right","Bottom","Left"].map(T=>({side:T,width:q(m[`border${T}Width`]),style:m[`border${T}Style`],color:st(m[`border${T}Color`])})).filter(T=>T.width>0&&T.style!=="none"&&T.style!=="hidden"&&T.color&&T.color.a>0);if(b.length){if(F&&F.some(T=>T>0)){let T=b[0];if(b.length===4&&b.every(v=>v.width===T.width&&v.style===T.style&&JSON.stringify(v.color)===JSON.stringify(T.color))){let v=T.width;r.push({type:"stroke-rrect",x:E+v/2,y:k+v/2,w:I-v,h:M-v,radius:F.map(G=>Math.max(0,G-v/2)),width:v,color:at(T.color,g),dash:Wt(T.style,v),z:x,seq:f++});return}w("css:borderRadiusNonUniform",{code:"unsupported-css",message:"border-radius with non-uniform borders is approximated with straight borders",property:"border-radius"})}for(let T of b){let B=T.width,v=at(T.color,g),G=T.side==="Top"||T.side==="Bottom",Z=T.side==="Top"||T.side==="Left"?1:-1,P=T.side==="Top"?k:T.side==="Bottom"?k+M:T.side==="Left"?E:E+I,H=Wt(T.style,B);if(H){let V=S?P:P+B/2*Z;r.push({type:"line",x1:G?E:V,y1:G?V:k,x2:G?E+I:V,y2:G?V:k+M,width:B,color:v,dash:H,z:x,seq:f++});continue}let K=S?P-B/2:Z>0?P:P-B;G?r.push({type:"rect",x:E,y:K,w:I,h:B,color:v,z:x,seq:f++}):r.push({type:"rect",x:K,y:k,w:B,h:M,color:v,z:x,seq:f++})}}}function et(l,m,g,x){let S=l.data;if(!S)return;if(!/\S/.test(S)&&!S.includes("\xA0")){let b=l.ownerDocument.createRange();if(b.selectNodeContents(l),![...b.getClientRects()].some(T=>T.width>0))return}let F=at(st(g.color)??{r:0,g:0,b:0,a:1},x.alpha),E=q(g.fontSize);if(E<=0)return;let k=It(g.fontFamily),I=Rt(g.fontWeight),M=g.fontStyle==="italic"||g.fontStyle==="oblique"?"italic":"normal",N=t.registry.match(k,I,M)??t.registry.match(t.fontFallback,I,M);if(!N){let b=k.join(",");u.has(b)||(u.add(b),t.warn({code:"missing-font",message:`No registered font matches font-family "${g.fontFamily}" and no fallback is available; text will be skipped`,element:m}));return}let W=Ot(l,g,{registry:t.registry,families:k,fallback:t.fontFallback,primary:N,weight:I,fstyle:M,size:E,textMeasure:t.textMeasure,warn:t.warn,element:m});for(let b of W)if(b.glyphs.length){a.push({top:b.top+o,bottom:b.bottom+o}),r.push({type:"text",x:b.glyphs[0]?.x??0,y:b.baseline+o,top:b.top+o,bottom:b.bottom+o,size:E,color:F,font:b.font,glyphs:b.glyphs.map(T=>({...T,x:T.x+s})),z:x.z,seq:f++});for(let T of x.decorations){let B=b.glyphs[0],v=b.glyphs[b.glyphs.length-1];if(!B||!v)continue;let G=B.x+s,Z=v.x+v.advance+s,P=Math.max(1,E/14),H=at(T.color,x.alpha);T.line.includes("underline")&&r.push({type:"rect",x:G,y:b.baseline+o+E*.08,w:Z-G,h:P,color:H,z:x.z,seq:f++}),T.line.includes("line-through")&&r.push({type:"rect",x:G,y:b.baseline+o-E*.3,w:Z-G,h:P,color:H,z:x.z,seq:f++})}}}await y(e,{z:0,alpha:1,decorations:[]}),qt(i);let $=e.getBoundingClientRect().bottom+o;for(let l of i)l.type==="rect"||l.type==="stroke-rrect"||l.type==="image"?$=Math.max($,l.y+l.h):l.type==="line"?$=Math.max($,l.y1,l.y2):(l.type==="text"||l.type==="group"||l.type==="clip")&&($=Math.max($,l.bottom));return{items:i,atoms:a,breaks:c,tables:h,height:$}}function qt(e){e.sort((t,n)=>t.z-n.z||t.seq-n.seq);for(let t of e)(t.type==="group"||t.type==="clip")&&qt(t.items)}function Wt(e,t){return e==="dashed"?[t*3,t*3]:e==="dotted"?[t,t]:null}function Gt(e,t){let n=o=>{let r=o.trim().split(/\s+/)[0]??"0px";return r.endsWith("%")?parseFloat(r)/100*t.width:q(r)},s=[n(e.borderTopLeftRadius),n(e.borderTopRightRadius),n(e.borderBottomRightRadius),n(e.borderBottomLeftRadius)];return s.some(o=>o>0)?s:null}function Ae(e){if(!e||e==="none")return null;let t=/^matrix\(([^)]+)\)$/.exec(e.trim());if(!t)return null;let n=t[1].split(",").map(h=>parseFloat(h));if(n.length!==6||n.some(h=>!Number.isFinite(h)))return null;let[s,o,r,i,a,c]=n;return s===1&&o===0&&r===0&&i===1&&a===0&&c===0?null:[s,o,r,i,a,c]}function Ie(e){let t=e.trim().split(/\s+/);return[q(t[0]??"0"),q(t[1]??"0")]}function Re(e,t){let n,s,o,r;if(e.type==="rect"||e.type==="stroke-rrect"||e.type==="image")n=e.x,s=e.y,o=e.x+e.w,r=e.y+e.h;else if(e.type==="line")n=Math.min(e.x1,e.x2)-e.width,s=Math.min(e.y1,e.y2)-e.width,o=Math.max(e.x1,e.x2)+e.width,r=Math.max(e.y1,e.y2)+e.width;else if(e.type==="text"){let i=e.glyphs[e.glyphs.length-1];n=e.x,s=e.top,o=i?i.x+i.advance:e.x,r=e.bottom}else if(e.type==="clip")n=e.box.x,s=e.box.y,o=e.box.x+e.box.w,r=e.box.y+e.box.h;else return!0;return o>t.x&&n<t.x+t.w&&r>t.y&&s<t.y+t.h}function at(e,t){return t===1?e:{...e,a:e.a*t}}function Ht(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Be(){return typeof CompressionStream=="function"}async function Xt(e){if(!Be())return null;try{let t=new CompressionStream("deflate"),n=t.writable.getWriter();n.write(e),n.close();let s=await new Response(t.readable).arrayBuffer();return new Uint8Array(s)}catch{return null}}var lt=class{constructor(t){this.id=t}toString(){return`${this.id} 0 R`}},J=class{constructor(t){this.name=t}toString(){let t="/";for(let n of this.name){let s=n.charCodeAt(0);if(s<33||s>126||"#/%()<>[]{}".includes(n))for(let o of new TextEncoder().encode(n))t+="#"+o.toString(16).padStart(2,"0");else t+=n}return t}},Q=class{constructor(t){this.text=t}toString(){return this.text}};function nt(e){if(/^[\x20-\x7e]*$/.test(e))return new Q("("+e.replace(/[\\()]/g,n=>"\\"+n)+")");let t="FEFF";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16).padStart(4,"0");return new Q("<"+t+">")}function Vt(e){let t=i=>String(i).padStart(2,"0"),n=-e.getTimezoneOffset(),s=n>=0?"+":"-",o=t(Math.floor(Math.abs(n)/60)),r=t(Math.abs(n)%60);return new Q(`(D:${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}${s}${o}'${r}')`)}function ht(e){if(e===null)return"null";if(typeof e=="number")return U(e);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return new J(e).toString();if(e instanceof lt||e instanceof J||e instanceof Q)return e.toString();if(Array.isArray(e))return"["+e.map(ht).join(" ")+"]";let t=[];for(let[n,s]of Object.entries(e))s!==void 0&&t.push(new J(n).toString()+" "+ht(s));return"<< "+t.join(" ")+" >>"}var dt=class{constructor(t={}){this.objects=[null],this.compress=t.compress??!0,this.version=t.version??"1.7"}reserve(){return this.objects.push({value:null}),new lt(this.objects.length-1)}set(t,n,s){this.objects[t.id]={value:n,stream:s}}add(t){let n=this.reserve();return this.set(n,t),n}async addStream(t,n,s={}){let o=this.reserve();return await this.setStream(o,t,n,s),o}async setStream(t,n,s,o={}){let r=s,i={...n};if((o.compress??this.compress)&&!("Filter"in i)){let c=await Xt(s);c&&c.length<s.length&&(r=c,i.Filter="FlateDecode")}i.Length=r.length,this.set(t,i,r)}build(t,n){let s=new TextEncoder,o=[],r=0,i=f=>{let d=typeof f=="string"?s.encode(f):f;o.push(d),r+=d.length};i(ut([s.encode(`%PDF-${this.version}
|
|
4
|
+
`+Ot(r.adoptedStyleSheets);i.trim()&&s.unshift(i),o=r.host.getRootNode()}return s.map(r=>`<style>${n?bt(r):r}</style>`).join("")}function Ge(e,t,n){let s=Math.max(e.documentElement.scrollWidth,e.body.scrollWidth),o=s-t;if(o<1)return;let r=i=>Math.round(i/96*25.4*10)/10;n({code:"other",message:`Content is ${Math.round(o)}px (${r(o)}mm) wider than the page content area (${Math.round(s)}px vs ${Math.round(t)}px); the right side will be clipped. Common causes: a fixed width plus padding/border without box-sizing: border-box, or a table that cannot shrink.`})}var We=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","SOURCE","TRACK","WBR"]);function ze(e,t){let n=e===document.body||e===document.documentElement,s=qe(n?document.body:e);if(!s.length)return n?document.body.innerHTML:e.outerHTML;let o=n?document.body:e;if(typeof o.getHTML!="function")return t({code:"unsupported-css",message:"This browser lacks Element.getHTML(); shadow DOM content cannot be serialized and will be missing from the PDF. Pass an element inside the shadow root instead.",element:e}),n?document.body.innerHTML:e.outerHTML;let r=He(s);try{let i={serializableShadowRoots:!0,shadowRoots:s},c=o.getHTML(i);if(n)return c;let a=e.tagName.toLowerCase();return We.has(e.tagName)?e.outerHTML:`<${a}${vt(e)}>${c}</${a}>`}finally{r()}}function qe(e){let t=[],n=s=>{s instanceof Element&&s.shadowRoot&&(t.push(s.shadowRoot),n(s.shadowRoot));for(let o of s.children)n(o)};return n(e),t}function He(e){let t=[];for(let n of e){let s=Ot(n.adoptedStyleSheets);if(!s)continue;let o=document.createElement("style");o.setAttribute("data-rhtp-adopted",""),o.textContent=s,n.insertBefore(o,n.firstChild),t.push(o)}return()=>{for(let n of t)n.remove()}}function Ot(e){if(!e||!e.length)return"";let t=[];for(let n of e)try{for(let s of n.cssRules)t.push(s.cssText)}catch{}return t.join(`
|
|
5
|
+
`)}function Ve(e,t){let n=t.customElements,s=t.HTMLElement;if(!n||!s)return;let o=new Set,r=i=>{for(let c of i.querySelectorAll("*"))c.tagName.includes("-")&&!c.hasAttribute("is")&&o.add(c.tagName.toLowerCase()),c.shadowRoot&&r(c.shadowRoot)};r(e);for(let i of o)if(!n.get(i))try{n.define(i,class extends s{})}catch{}}function _e(e){return e.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(t,n,s)=>`<style${n}>${bt(s)}</style>`)}function bt(e){let t="",n=0;for(;n<e.length;){let s=/@media\s*([^{]+)\{/g;s.lastIndex=n;let o=s.exec(e);if(!o){t+=e.slice(n);break}t+=e.slice(n,o.index);let r=1,i=s.lastIndex;for(;i<e.length&&r>0;)e[i]==="{"?r++:e[i]==="}"&&r--,i++;let c=o[1].trim(),a=e.slice(s.lastIndex,i-1);/\bprint\b/.test(c)?t+=a:/^\s*(only\s+)?screen\b/.test(c)&&!/\band\b/.test(c)?t+="":t+=e.slice(o.index,i),n=i}return t}function vt(e){let t="";for(let n of e.attributes)/^on/i.test(n.name)||(t+=` ${n.name}="${wt(n.value)}"`);return t}function wt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}async function Xe(e){let t=[...e.querySelectorAll('link[rel~="stylesheet"]')];await Promise.all(t.map(n=>new Promise(s=>{let o=n;if(o.sheet)return s(void 0);o.addEventListener("load",()=>s(void 0),{once:!0}),o.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}async function Ye(e){if(e.body.offsetHeight,e.fonts){await e.fonts.ready;let t=[...e.fonts].filter(n=>n.status==="loading").map(n=>n.loaded.catch(()=>{}));t.length&&await Promise.all(t),await e.fonts.ready}}async function Ze(e){let t=[...e.images];await Promise.all(t.map(n=>n.complete?n.decode().catch(()=>{}):new Promise(s=>{n.addEventListener("load",()=>n.decode().catch(()=>{}).then(s),{once:!0}),n.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}function Ke(e,t){let n=e.defaultView;if(!n)return;let s=[];for(let i of Qe(e.body))for(let c of["before","after"]){let a=n.getComputedStyle(i,`::${c}`),u=a.content;if(!u||u==="none"||u==="normal"||a.display==="none")continue;let m=Je(u);if(m===null){t({code:"unsupported-css",message:`::${c} content "${u}" is not supported (only quoted strings are); the pseudo-element is skipped`,element:i,property:"content"});continue}let f=[];for(let b=0;b<a.length;b++){let g=a[b];g==="content"||g.startsWith("-webkit-")||g.startsWith("-moz-")||f.push([g,a.getPropertyValue(g)])}s.push({el:i,pseudo:c,text:m,styles:f})}if(!s.length)return;let o='[data-rhtp-pseudo-host~="before"]::before{content:none!important;display:none!important}[data-rhtp-pseudo-host~="after"]::after{content:none!important;display:none!important}',r=e.createElement("style");r.setAttribute("data-rhtp-pseudo",""),r.textContent=o,e.head.appendChild(r);for(let i of new Set(s.map(c=>c.el.getRootNode()).filter(c=>c!==e))){let c=e.createElement("style");c.setAttribute("data-rhtp-pseudo",""),c.textContent=o,i.appendChild(c)}for(let i of s){let c=e.createElement("span");c.setAttribute("data-rhtp-pseudo",i.pseudo);for(let[u,m]of i.styles)c.style.setProperty(u,m);c.textContent=i.text;let a=(i.el.getAttribute("data-rhtp-pseudo-host")??"").split(" ").filter(Boolean);a.push(i.pseudo),i.el.setAttribute("data-rhtp-pseudo-host",a.join(" ")),i.pseudo==="before"?i.el.insertBefore(c,i.el.firstChild):i.el.appendChild(c)}}function Qe(e){let t=[],n=s=>{for(let o of s.querySelectorAll("*"))t.push(o),o.shadowRoot&&n(o.shadowRoot)};return n(e),t}function Je(e){let t="",n=0,s=e.trim();for(;n<s.length;){let o=s[n];if(o===" "||o===" "){n++;continue}if(o!=='"'&&o!=="'")return null;let r=o;for(n++;n<s.length&&s[n]!==r;)if(s[n]==="\\"){n++;let i=/^[0-9a-fA-F]{1,6}/.exec(s.slice(n));i?(t+=String.fromCodePoint(parseInt(i[0],16)),n+=i[0].length,s[n]===" "&&n++):(t+=s[n]??"",n++)}else t+=s[n],n++;n++}return t}var lt=2.834645669291339,Dt={A3:{width:297*lt,height:420*lt},A4:{width:210*lt,height:297*lt},A5:{width:148*lt,height:210*lt},B4:{width:257*lt,height:364*lt},B5:{width:182*lt,height:257*lt},Letter:{width:612,height:792},Legal:{width:612,height:1008}};function ut(e){if(typeof e=="number")return e*.75;let t=/^\s*(-?[\d.]+)\s*([a-z%]*)\s*$/i.exec(e);if(!t)throw new Error(`Invalid CSS length: ${e}`);let n=parseFloat(t[1]);switch((t[2]??"").toLowerCase()){case"":case"px":return n*.75;case"pt":return n;case"mm":return n*lt;case"cm":return n*lt*10;case"in":return n*72;case"pc":return n*12;default:throw new Error(`Unsupported CSS unit: ${e}`)}}function et(e){let t=parseFloat(e);return Number.isFinite(t)?t:0}function pt(e){if(!e)return null;let t=e.trim();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(t);if(n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:mt(parseFloat(n[1])/255),g:mt(parseFloat(n[2])/255),b:mt(parseFloat(n[3])/255),a:mt(s)}}if(n=/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*(?:\/\s*([\d.]+%?)\s*)?\)$/i.exec(t),n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:mt(parseFloat(n[1])),g:mt(parseFloat(n[2])),b:mt(parseFloat(n[3])),a:mt(s)}}if(n=/^#([0-9a-f]{3,8})$/i.exec(t),n){let s=n[1];(s.length===3||s.length===4)&&(s=s.split("").map(r=>r+r).join(""));let o=parseInt(s.padEnd(8,"f"),16);return{r:(o>>>24&255)/255,g:(o>>>16&255)/255,b:(o>>>8&255)/255,a:(o&255)/255}}return null}function mt(e){return e<0?0:e>1?1:e}function I(e){if(!Number.isFinite(e))return"0";let t=e.toFixed(3),n=t.includes(".")?t.replace(/\.?0+$/,""):t;return n===""||n==="-0"||n==="-"?"0":n}function tn(e){let t=e.tables.get("GSUB");if(!t||t.length<10)return null;let n=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),s=t.offset;try{let o=s+n.getUint16(s+6),r=s+n.getUint16(s+8),i=new Map,c=n.getUint16(o);for(let f=0;f<c;f++){let b=o+2+f*6,g=String.fromCharCode(n.getUint8(b),n.getUint8(b+1),n.getUint8(b+2),n.getUint8(b+3)),d=o+n.getUint16(b+4),p=n.getUint16(d+2),T=i.get(g)??[];for(let P=0;P<p;P++)T.push(n.getUint16(d+4+P*2));i.set(g,T)}let a=n.getUint16(r),u=new Map;return{features:i,lookup:f=>{if(u.has(f))return u.get(f)??null;let b=null;if(f>=0&&f<a){let g=r+n.getUint16(r+2+f*2);b=en(n,g,n.getUint16(g),n.getUint16(g+4),g+6)}return u.set(f,b),b}}}catch{return null}}function en(e,t,n,s,o){if(n!==1&&n!==7)return null;let r=new Map;for(let i=0;i<s;i++){let c=t+e.getUint16(o+i*2);if(n===7){if(e.getUint16(c)!==1||e.getUint16(c+2)!==1)continue;c+=e.getUint32(c+4)}nn(e,c,r)}return r.size?r:null}function nn(e,t,n){let s=e.getUint16(t),o=on(e,t+e.getUint16(t+2));if(s===1){let r=e.getInt16(t+4);for(let i of o)n.set(i,i+r&65535)}else if(s===2){let r=e.getUint16(t+4);for(let i=0;i<o.length&&i<r;i++)n.set(o[i],e.getUint16(t+6+i*2))}}function on(e,t){let n=e.getUint16(t),s=[];if(n===1){let o=e.getUint16(t+2);for(let r=0;r<o;r++)s.push(e.getUint16(t+4+r*2))}else if(n===2){let o=e.getUint16(t+2);for(let r=0;r<o;r++){let i=t+4+r*6,c=e.getUint16(i),a=e.getUint16(i+2),u=e.getUint16(i+4);for(let m=c;m<=a;m++)s[u+(m-c)]=m}}return s}function te(e,t){let n=tn(e);if(!n)return null;let s=[];for(let i of t)for(let c of n.features.get(i)??[])s.includes(c)||s.push(c);if(!s.length)return null;s.sort((i,c)=>i-c);let o=[];for(let i of s){let c=n.lookup(i);c&&o.push(c)}if(!o.length)return null;let r=new Map;return i=>{let c=r.get(i);if(c!==void 0)return c;let a=i;for(let u of o)a=u.get(a)??a;return r.set(i,a),a}}var sn={"lining-nums":"lnum","oldstyle-nums":"onum","proportional-nums":"pnum","tabular-nums":"tnum","diagonal-fractions":"frac","stacked-fractions":"afrc",ordinal:"ordn","slashed-zero":"zero","small-caps":"smcp","all-small-caps":"c2sc","petite-caps":"pcap","all-petite-caps":"c2pc",unicase:"unic","titling-caps":"titl",jis78:"jp78",jis83:"jp83",jis90:"jp90",jis04:"jp04",simplified:"smpl",traditional:"trad","full-width":"fwid","proportional-width":"pwid",ruby:"ruby"};function ee(e){let t=new Set,n=`${e.fontVariantNumeric??""} ${e.fontVariantCaps??""} ${e.fontVariantEastAsian??""}`.split(/\s+/);for(let o of n){let r=sn[o];r&&t.add(r)}let s=e.fontFeatureSettings??"";if(s&&s!=="normal")for(let o of s.split(",")){let r=/^\s*["']([A-Za-z0-9]{4})["']\s*(.*)$/.exec(o);if(!r)continue;let i=r[2].trim();i==="0"||i==="off"||t.add(r[1])}return[...t]}var rn=new Set([32,9,10,13,12,160,12288,8194,8195,8201,8202,8239,8287]);function se(e,t,n){let s=e.ownerDocument,o=fn(e.data,t.textTransform),r=s.createRange(),i=un(s,t),c=[],a=null,u=NaN,m=new Set;for(let f=0;f<o.length;){let b=o.codePointAt(f),g=b>65535?2:1,d=f+g;r.setStart(e,f),r.setEnd(e,Math.min(d,e.data.length));let p=cn(r.getClientRects());if(f=d,!p)continue;let T=ln(b,n,m);if(!T)continue;let{font:P,gid:x,cpForUnicode:L}=T,N=p.top;(!a||a.font!==P||Math.abs(N-u)>.5)&&(a={font:P,baseline:N+i,top:N,bottom:p.bottom,glyphs:[]},u=N,c.push(a)),a.top=Math.min(a.top,N),a.bottom=Math.max(a.bottom,p.bottom);let q=n.features.length?an(P.parsed,n.features):null,H=q?q(x):x,W=(P.parsed.advances[H]??0)*n.size/P.parsed.unitsPerEm;a.glyphs.push({gid:H,cp:L,x:p.left,advance:W})}return c}var ne=new WeakMap;function an(e,t){let n=ne.get(e);n||(n=new Map,ne.set(e,n));let s=[...t].sort().join(",");if(n.has(s))return n.get(s)??null;let o=te(e,t);return n.set(s,o),o}function cn(e){let t=null;for(let n of e)n.width>.01&&(!t||n.width>t.width)&&(t=n);return t}function ln(e,t,n){let s=(i,c)=>{let a=i?.parsed.cmap.get(c);return i&&a?{font:i,gid:a,cpForUnicode:e}:null};if(rn.has(e))return s(t.primary,e)??s(t.primary,32)??s(t.registry.anyWithGlyph(32,t.weight,t.fstyle),32);let o=s(t.primary,e);if(o||(o=s(t.registry.match(t.families,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.match(t.fallback,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.anyWithGlyph(e,t.weight,t.fstyle),e),o))return o;n.has(e)||(n.add(e),t.warn({code:"missing-glyph",message:`No registered font has a glyph for U+${e.toString(16).toUpperCase().padStart(4,"0")} "${String.fromCodePoint(e)}"; substituted with U+25A1`,element:t.element,text:String.fromCodePoint(e)}));let r=s(t.primary,9633)??s(t.registry.anyWithGlyph(9633,t.weight,t.fstyle),9633);return r?{...r,cpForUnicode:e}:null}function fn(e,t){if(!t||t==="none")return e;let n=e;return t.includes("uppercase")?n=e.toUpperCase():t.includes("lowercase")?n=e.toLowerCase():t.includes("capitalize")&&(n=e.replace(new RegExp("(^|\\s)(\\p{L})","gu"),(s,o,r)=>o+r.toUpperCase())),n.length===e.length?n:e}var oe=new WeakMap;function un(e,t){let n=[t.fontFamily,t.fontSize,t.fontWeight,t.fontStyle,t.fontStretch,t.fontVariant,t.fontFeatureSettings].join("|"),s=oe.get(e);s||(s=new Map,oe.set(e,s));let o=s.get(n);if(o!==void 0)return o;let r=e.createElement("div");r.setAttribute("data-rhtp-probe",""),r.style.cssText="position:absolute;left:0;top:0;visibility:hidden;white-space:pre;line-height:normal;margin:0;padding:0;border:0;letter-spacing:0;text-indent:0;",r.style.fontFamily=t.fontFamily,r.style.fontSize=t.fontSize,r.style.fontWeight=t.fontWeight,r.style.fontStyle=t.fontStyle,r.style.fontStretch=t.fontStretch,r.style.fontVariant=t.fontVariant,r.style.fontFeatureSettings=t.fontFeatureSettings;let i=e.createTextNode("Ag\u3042");r.appendChild(i);let c=e.createElement("span");c.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0;",r.appendChild(c),e.body.appendChild(r);let a=e.createRange();a.selectNodeContents(i);let u=a.getBoundingClientRect(),f=c.getBoundingClientRect().bottom-u.top;r.remove();let b=Number.isFinite(f)&&f>0?f:parseFloat(t.fontSize)*.8;return s.set(n,b),b}var Bt=new Map;function xt(e,t,n){let s=Bt.get(e);return s||(s=hn(e,t,n).catch(o=>(t({code:"image-failed",message:`Failed to load image ${e}: ${o instanceof Error?o.message:String(o)}`,element:n}),null)),Bt.set(e,s)),s}async function hn(e,t,n){let s=null;try{let p=await fetch(e,{mode:"cors",credentials:"same-origin"});p.ok&&(s=new Uint8Array(await p.arrayBuffer()))}catch{s=null}if(s&&s[0]===255&&s[1]===216){let p=pn(s);if(p&&p.components===3)return{key:e,width:p.width,height:p.height,jpeg:s,rgb:null,alpha:null}}let o=new Image;o.crossOrigin="anonymous",o.decoding="sync";let r=new Promise((p,T)=>{o.onload=()=>p(void 0),o.onerror=()=>T(new Error("image failed to load"))});if(s){let p=URL.createObjectURL(new Blob([s]));o.src=p;try{await r}finally{URL.revokeObjectURL(p)}}else o.src=e,await r;let i=o.naturalWidth,c=o.naturalHeight;if(!i||!c)throw new Error("image has no intrinsic size");let a=document.createElement("canvas");a.width=i,a.height=c;let u=a.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("2D canvas unavailable");u.drawImage(o,0,0);let m;try{m=u.getImageData(0,0,i,c)}catch{return t({code:"image-failed",message:`Image ${e} is cross-origin without CORS headers; add crossorigin="anonymous" and Access-Control-Allow-Origin. Skipped.`,element:n}),null}let f=m.data,b=new Uint8Array(i*c*3),g=new Uint8Array(i*c),d=!0;for(let p=0,T=0,P=0;p<f.length;p+=4,T+=3,P++){let x=f[p+3];x===0?b[T]=b[T+1]=b[T+2]=255:(b[T]=f[p],b[T+1]=f[p+1],b[T+2]=f[p+2]),g[P]=x,x!==255&&(d=!1)}return{key:e,width:i,height:c,jpeg:null,rgb:b,alpha:d?null:g}}function pn(e){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}let n=e[t+1];if(n===216||n>=208&&n<=215||n===1||n===255){t+=n===255?1:2;continue}let s=e[t+2]<<8|e[t+3];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return{height:e[t+5]<<8|e[t+6],width:e[t+7]<<8|e[t+8],components:e[t+9]};if(n===218)break;t+=2+s}return null}function ae(e){if(!e||e==="none")return null;let t=dn(e);if(t.length!==1)return null;let n=/^url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)$/.exec(t[0].trim());return n?n[1]??n[2]??n[3]??null:null}function dn(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function Ct(e,t,n,s,o){let r,i,c=s.trim();if(c==="cover"||c==="contain"){let b=c==="cover"?Math.max(e.w/t,e.h/n):Math.min(e.w/t,e.h/n);r=t*b,i=n*b}else{let[b="auto",g="auto"]=c.split(/\s+/),d=re(b,e.w),p=re(g,e.h);d===null&&p===null?(r=t,i=n):d===null?(i=p,r=t*i/n):p===null?(r=d,i=n*r/t):(r=d,i=p)}let[a="0%",u="0%"]=o.trim().split(/\s+/),m=e.x+ie(a,e.w-r),f=e.y+ie(u,e.h-i);return{x:m,y:f,w:r,h:i}}function re(e,t){return e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function ie(e,t){return e==="left"||e==="top"?0:e==="center"?t/2:e==="right"||e==="bottom"?t:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function ce(e){switch(e){case"contain":case"scale-down":return"contain";case"cover":return"cover";case"none":return"auto";default:return"100% 100%"}}function le(e){let t=(e||"repeat").trim();if(t==="repeat-x")return["repeat","no-repeat"];if(t==="repeat-y")return["no-repeat","repeat"];let n=t.split(/\s+/),s=i=>i==="repeat"||i==="no-repeat"||i==="space"||i==="round"?i:"repeat",o=s(n[0]??"repeat"),r=s(n[1]??n[0]??"repeat");return[o,r]}function jt(e,t,n,s,o){if(!(n>0))return{positions:[t],size:n};let r=o-s;if(e==="no-repeat")return{positions:[t],size:n};if(e==="round"){let a=Math.max(1,Math.round(r/n)),u=r/a;return{positions:Array.from({length:a},(m,f)=>s+f*u),size:u}}if(e==="space"){let a=Math.floor(r/n);if(a<2)return{positions:[s],size:n};let u=(r-a*n)/(a-1);return{positions:Array.from({length:a},(m,f)=>s+f*(n+u)),size:n}}let i=t-Math.ceil((t-s)/n)*n,c=[];for(let a=i;a<o&&(a+n>s&&c.push(a),!(c.length>1e4));a+=n);return{positions:c.length?c:[t],size:n}}function fe(e){e.jpeg=null,e.rgb=null,e.alpha=null,Bt.delete(e.key)}function he(e,t,n){let s=/^linear-gradient\((.*)\)$/s.exec(e.trim());if(!s)return null;let o=wn(s[1]);if(o.length<2)return null;let r=0,i=180,c=o[0].trim(),a=c.replace(/^in\s+\S+(\s+\S+\s+hue)?\s*/i,"").trim(),u=gn(a);u!==null?(i=u,r=1):/^in\s/i.test(c)&&a===""&&(r=1);let m=o.slice(r).map(N=>N.trim());if(m.length<2)return null;let f=i*Math.PI/180,b=Math.sin(f),g=Math.cos(f),d=Math.abs(t*b)+Math.abs(n*g);if(!(d>0))return null;let p=[];for(let N of m){let q=mn(N);if(!q)return null;let H=pt(q.color);if(!H)return null;if(!q.positions.length){p.push({t:NaN,color:H});continue}for(let W of q.positions){let J=bn(W,d);if(J===null)return null;p.push({t:J,color:H})}}if(p.length<2)return null;yn(p);let T=t/2,P=n/2,x=b,L=-g;return{x0:T-x*d/2,y0:P-L*d/2,x1:T+x*d/2,y1:P+L*d/2,stops:p}}function gn(e){let t=/^(-?[\d.]+)deg$/.exec(e);if(t)return(parseFloat(t[1])%360+360)%360;let n=/^to\s+(.+)$/.exec(e);if(!n)return null;let s=n[1].trim().split(/\s+/).sort().join(" ");return{top:0,right:90,bottom:180,left:270,"right top":45,"bottom right":135,"bottom left":225,"left top":315}[s]??null}function mn(e){let t=/^([a-z-]+\([^()]*\))\s*(.*)$/i.exec(e);if(t)return{color:t[1],positions:ue(t[2])};let n=/^(\S+)\s*(.*)$/.exec(e);return n?{color:n[1],positions:ue(n[2])}:null}function ue(e){let t=e.trim();return t?t.split(/\s+/):[]}function bn(e,t){let n=/^(-?[\d.]+)%$/.exec(e);if(n)return parseFloat(n[1])/100;let s=/^(-?[\d.]+)px$/.exec(e);return s?parseFloat(s[1])/t:null}function yn(e){let t=e.length-1;Number.isNaN(e[0]?.t)&&(e[0].t=0),Number.isNaN(e[t]?.t)&&(e[t].t=1);for(let n=1;n<t;n++){if(!Number.isNaN(e[n]?.t))continue;let s=n+1;for(;s<t&&Number.isNaN(e[s]?.t);)s++;let o=e[n-1]?.t,r=e[s]?.t;for(let i=n;i<s;i++)e[i].t=o+(r-o)*(i-n+1)/(s-n+1);n=s-1}for(let n=1;n<e.length;n++){let s=e[n-1]?.t;e[n]?.t<s&&(e[n].t=s)}}function wn(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function xn(e){let t=[],n=Sn(e),s=0,o=0,r=0,i=0,c=0,a=null,u=null,m="",f=()=>{let g=n[s++];return typeof g=="number"?g:NaN},b=()=>typeof n[s]=="number";for(;s<n.length;){if(typeof n[s]=="string")m=n[s++];else if(!m)break;let g=m===m.toLowerCase(),d=m.toUpperCase(),p=g?o:0,T=g?r:0;if(d==="M"){o=f()+p,r=f()+T,t.push(["M",o,r]),i=o,c=r,a=u=null,m=g?"l":"L";continue}if(d==="Z"){t.push(["Z"]),o=i,r=c,a=u=null;continue}if(d==="L")o=f()+p,r=f()+T,t.push(["L",o,r]),a=u=null;else if(d==="H")o=f()+p,t.push(["L",o,r]),a=u=null;else if(d==="V")r=f()+T,t.push(["L",o,r]),a=u=null;else if(d==="C"){let P=f()+p,x=f()+T,L=f()+p,N=f()+T;o=f()+p,r=f()+T,t.push(["C",P,x,L,N,o,r]),a=[L,N],u=null}else if(d==="S"){let P=a?2*o-a[0]:o,x=a?2*r-a[1]:r,L=f()+p,N=f()+T;o=f()+p,r=f()+T,t.push(["C",P,x,L,N,o,r]),a=[L,N],u=null}else if(d==="Q"||d==="T"){let P,x;d==="Q"?(P=f()+p,x=f()+T):(P=u?2*o-u[0]:o,x=u?2*r-u[1]:r);let L=f()+p,N=f()+T;t.push(["C",o+2/3*(P-o),r+2/3*(x-r),L+2/3*(P-L),N+2/3*(x-N),L,N]),o=L,r=N,u=[P,x],a=null}else if(d==="A"){let P=f(),x=f(),L=f(),N=f(),q=f(),H=f()+p,W=f()+T;for(let J of Tn(o,r,H,W,P,x,L,N!==0,q!==0))t.push(J);o=H,r=W,a=u=null}else break;if(!b()&&typeof n[s]!="string")break}return t}function Sn(e){let t=[],n=/([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?)/g,s;for(;s=n.exec(e);)s[1]?t.push(s[1]):t.push(parseFloat(s[2]));return t}function Tn(e,t,n,s,o,r,i,c,a){if(e===n&&t===s)return[];if(o=Math.abs(o),r=Math.abs(r),o===0||r===0)return[["L",n,s]];let u=i*Math.PI/180,m=Math.cos(u),f=Math.sin(u),b=(e-n)/2,g=(t-s)/2,d=m*b+f*g,p=-f*b+m*g,T=d*d/(o*o)+p*p/(r*r);if(T>1){let Y=Math.sqrt(T);o*=Y,r*=Y}let P=c===a?-1:1,x=o*o*r*r-o*o*p*p-r*r*d*d,L=o*o*p*p+r*r*d*d,N=P*Math.sqrt(Math.max(0,x/L)),q=N*o*p/r,H=-N*r*d/o,W=m*q-f*H+(e+n)/2,J=f*q+m*H+(t+s)/2,D=(Y,Z,rt,$)=>{let S=Y*rt+Z*$,l=Math.hypot(Y,Z)*Math.hypot(rt,$),h=Math.acos(Math.min(1,Math.max(-1,S/(l||1))));return Y*$-Z*rt<0&&(h=-h),h},B=D(1,0,(d-q)/o,(p-H)/r),K=D((d-q)/o,(p-H)/r,(-d-q)/o,(-p-H)/r);!a&&K>0&&(K-=2*Math.PI),a&&K<0&&(K+=2*Math.PI);let ft=Math.max(1,Math.ceil(Math.abs(K/(Math.PI/2)))),nt=K/ft,st=4/3*Math.tan(nt/4),at=[],ct=B;for(let Y=0;Y<ft;Y++){let Z=ct+nt,rt=Math.cos(ct),$=Math.sin(ct),S=Math.cos(Z),l=Math.sin(Z),h=(j,O)=>[m*o*j-f*r*O+W,f*o*j+m*r*O+J],[y,w]=h(rt,$),[k,M]=h(S,l),[C,F]=h(rt-st*$,$+st*rt),[z,E]=h(S+st*l,l-st*S);at.push(["C",C,F,z,E,k,M]),ct=Z}return at}function ge(e,t){let n=(s,o=0)=>{let r=parseFloat(t(s));return Number.isFinite(r)?r:o};switch(e.tagName){case"path":{let s=t("d");return s?xn(s):[]}case"rect":{let s=n("x"),o=n("y"),r=n("width"),i=n("height");if(r<=0||i<=0)return[];let c=t("rx")===""||t("rx")==="auto"?NaN:n("rx"),a=t("ry")===""||t("ry")==="auto"?NaN:n("ry");return Number.isNaN(c)&&Number.isNaN(a)||(Number.isNaN(c)&&(c=a),Number.isNaN(a)&&(a=c),c=Math.min(c,r/2),a=Math.min(a,i/2),c<=0||a<=0)?pe(s,o,r,i):Cn(s,o,r,i,c,a)}case"circle":{let s=n("r");return s<=0?[]:de(n("cx"),n("cy"),s,s)}case"ellipse":{let s=n("rx"),o=n("ry");return s<=0||o<=0?[]:de(n("cx"),n("cy"),s,o)}case"line":return[["M",n("x1"),n("y1")],["L",n("x2"),n("y2")]];case"polyline":case"polygon":{let s=t("points").split(/[\s,]+/).map(parseFloat).filter(r=>Number.isFinite(r));if(s.length<4)return[];let o=[["M",s[0],s[1]]];for(let r=2;r+1<s.length;r+=2)o.push(["L",s[r],s[r+1]]);return e.tagName==="polygon"&&o.push(["Z"]),o}default:return null}}function pe(e,t,n,s){return[["M",e,t],["L",e+n,t],["L",e+n,t+s],["L",e,t+s],["Z"]]}var kt=.5522847498307936;function Cn(e,t,n,s,o,r){let i=o*kt,c=r*kt,a=e+n,u=t+s;return[["M",e+o,t],["L",a-o,t],["C",a-o+i,t,a,t+r-c,a,t+r],["L",a,u-r],["C",a,u-r+c,a-o+i,u,a-o,u],["L",e+o,u],["C",e+o-i,u,e,u-r+c,e,u-r],["L",e,t+r],["C",e,t+r-c,e+o-i,t,e+o,t],["Z"]]}function de(e,t,n,s){let o=n*kt,r=s*kt;return[["M",e+n,t],["C",e+n,t+r,e+o,t+s,e,t+s],["C",e-o,t+s,e-n,t+r,e-n,t],["C",e-n,t-r,e-o,t-s,e,t-s],["C",e+o,t-s,e+n,t-r,e+n,t],["Z"]]}var me=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","META","LINK","TITLE","BASE","IFRAME","CANVAS","VIDEO","AUDIO","OBJECT","EMBED"]),be=4e3,ye="http://www.w3.org/2000/svg",kn=new Set(["defs","symbol","marker","clipPath","mask","pattern","filter","linearGradient","radialGradient","style","title","desc","metadata","script"]),Mn=new Set(["g","a","svg","switch"]);function $n(e){let t=e.shadowRoot;if(t)return[...t.childNodes];if(e.tagName==="SLOT"){let n=e;if(typeof n.assignedNodes=="function")return n.assignedNodes({flatten:!0})}return[...e.childNodes]}var Un=[["boxShadow",e=>e!=="none"],["textShadow",e=>e!=="none"],["filter",e=>e!=="none"],["backdropFilter",e=>e!=="none"&&e!==""],["writingMode",e=>e.startsWith("vertical")],["outlineStyle",e=>e!=="none"],["clipPath",e=>e!=="none"],["mixBlendMode",e=>e!=="normal"]];async function Gt(e,t){let n=e.ownerDocument.defaultView,s=n.scrollX,o=n.scrollY,r=[],i=r,c=[],a=[],u=[],m=[],f=new Map,b=[],g=[],d=null,p=0,T=new Set,P=new Set;function x(l,h){T.has(l)||(T.add(l),t.warn(h))}async function L(l,h){if(me.has(l.tagName))return;t.pacer&&await t.pacer();let y=n.getComputedStyle(l);if(y.display==="none")return;let w=Fn(y.transform);if(w&&"style"in l){let k=l,M=k.getBoundingClientRect(),C=k.style.transform;k.style.transform="none",k.offsetWidth;let F=k.getBoundingClientRect(),[z,E]=Pn(y.transformOrigin),j={x:F.left+z+s,y:F.top+E+o},O=r;r=[],await q(l,n.getComputedStyle(l),h);let A=r;r=O,k.style.transform=C,k.offsetWidth,r.push({type:"group",matrix:w,origin:j,items:A,top:M.top+o,bottom:M.bottom+o,z:N(y,h.z),seq:p++});return}await q(l,y,h)}function N(l,h){if(l.position!=="static"&&l.zIndex!=="auto"){let y=parseInt(l.zIndex,10);if(Number.isFinite(y))return y}return h}async function q(l,h,y){let w=N(h,y.z),k=parseFloat(h.opacity),M=y.alpha*(Number.isFinite(k)?k:1),C=h.visibility==="visible"&&M>0;if(h.display!=="contents"&&h.display!=="inline"){let v=l.getBoundingClientRect(),Q=v.top+o,ot=v.bottom+o;if(v.height>0){let tt=h.breakBefore||h.pageBreakBefore,Ht=h.breakAfter||h.pageBreakAfter;/^(page|always|left|right|recto|verso)$/.test(tt)&&a.push(Q),/^(page|always|left|right|recto|verso)$/.test(Ht)&&a.push(ot);let Vt=h.breakInside||h.pageBreakInside;if((Vt==="avoid"||Vt==="avoid-page"||h.display==="table-row"||h.display==="table-header-group"||h.display==="table-footer-group"||l.tagName==="IMG"||l.tagName==="svg")&&c.push({top:Q,bottom:ot}),/^avoid(-page)?$/.test(Ht)){let gt=rt(l);gt&&u.push({start:Math.min(ot,gt.top),end:Math.max(ot,gt.top),pullTo:Q})}if(/^avoid(-page)?$/.test(tt)){let gt=$(l);gt&&u.push({start:Math.min(gt.bottom,Q),end:Math.max(gt.bottom,Q),pullTo:gt.top})}}}Y(l,h);let F=null;if(h.display==="table"||h.display==="inline-table"){let v=l.getBoundingClientRect();F={top:v.top+o,bottom:v.bottom+o,headTop:0,headBottom:0,headItems:[],footTop:0,footBottom:0,footItems:[]},g.push(F)}let z=d;F&&(d=F);let E=h.display==="table-header-group"&&d&&!d.headItems.length,j=h.display==="table-footer-group"&&d&&!d.footItems.length,O=E||j?r.length:-1,A=h.overflowX!=="visible"||h.overflowY!=="visible",U=null,V=null;if(A&&h.display!=="inline"&&h.display!=="contents"&&l!==e){let v=l.getBoundingClientRect();V=B(v,h,"padding-box",xe(h,v))}if(C&&h.display!=="contents"){H(l,h);let v=h.display==="inline"?[...l.getClientRects()]:[l.getBoundingClientRect()],Q=h.borderCollapse==="collapse"&&/^table/.test(h.display)&&h.display!=="table-caption",ot=v.length===1?xe(h,v[0]):null;for(let tt of v)tt.width<=0&&tt.height<=0||(W(tt,h,M,w,ot),await J(l,tt,h,M,w,ot),K(tt,h,M,w,Q,ot));l.tagName==="IMG"&&v[0]&&await D(l,v[0],h,M,w,ot)}let G=y.decorations,_=h.textDecorationLine;if(_&&_!=="none"){let v=pt(h.textDecorationColor)??pt(h.color)??{r:0,g:0,b:0,a:1};G=[...G,{line:_,color:v}]}V&&(U=r,r=[]);let it={z:w,alpha:M,decorations:G};if(l.tagName==="svg"&&l.namespaceURI===ye){st(l,M,w),V&&U&&Z(V,U,w);return}for(let v of $n(l))v.nodeType===Node.TEXT_NODE?C&&ft(v,l,h,it):v.nodeType===Node.ELEMENT_NODE&&await L(v,it);if(V&&U&&Z(V,U,w),(E||j)&&d&&O>=0){let v=l.getBoundingClientRect(),Q=r.slice(O);E?(d.headTop=v.top+o,d.headBottom=v.bottom+o,d.headItems=Q):(d.footTop=v.top+o,d.footBottom=v.bottom+o,d.footItems=Q)}d=z}function H(l,h){for(let[y,w]of Un){let k=String(h[y]??"");w(k)&&x(`css:${y}`,{code:"unsupported-css",message:`CSS property "${Se(y)}" is not supported in this version and will be ignored (first seen on <${l.tagName.toLowerCase()}>: ${k})`,element:l,property:Se(y)})}/^matrix3d/.test(h.transform)&&x("css:transform3d",{code:"unsupported-css",message:"3D transforms are not supported; the element is drawn untransformed",element:l,property:"transform"})}function W(l,h,y,w,k){let M=pt(h.backgroundColor);if(!M||M.a<=0)return;let C={type:"rect",x:l.left+s,y:l.top+o,w:l.width,h:l.height,color:St(M,y),z:w,seq:p++};k&&(C.radius=k),r.push(C)}async function J(l,h,y,w,k,M){if(y.backgroundImage==="none")return;let C=B(h,y,y.backgroundClip||"border-box",M),F=B(h,y,y.backgroundOrigin||"padding-box",null),z=he(y.backgroundImage,F.w,F.h);if(z){r.push({type:"gradient",box:F,clip:C,gradient:z,alpha:w,z:k,seq:p++});return}let E=ae(y.backgroundImage);if(!E){x("css:backgroundImage",{code:"unsupported-css",message:`background-image "${y.backgroundImage}" is not supported (a single url() or linear-gradient() is); ignored`,element:l,property:"background-image"});return}let j=await xt(new URL(E,l.ownerDocument.baseURI).href,t.warn,l);if(!j)return;let O=Ct(F,j.width,j.height,y.backgroundSize,y.backgroundPosition),[A,U]=le(y.backgroundRepeat),V=jt(A,O.x,O.w,C.x,C.x+C.w),G=jt(U,O.y,O.h,C.y,C.y+C.h),_=V.positions.length*G.positions.length;if(_>be){x("css:backgroundRepeat",{code:"unsupported-css",message:`background-repeat would need ${_} tiles (limit ${be}); drawn once instead. Use a larger background-size or a pre-tiled image.`,element:l,property:"background-repeat"}),r.push({type:"image",...O,image:j,clip:C,alpha:w,z:k,seq:p++});return}for(let it of G.positions)for(let v of V.positions)r.push({type:"image",x:v,y:it,w:V.size,h:G.size,image:j,clip:C,alpha:w,z:k,seq:p++})}async function D(l,h,y,w,k,M){let C=l.currentSrc||l.src;if(!C)return;let F=await xt(C,t.warn,l);if(!F)return;let z=B(h,y,"content-box",M),E=Ct(z,F.width,F.height,ce(y.objectFit),y.objectPosition);y.objectFit==="scale-down"&&(E.w>F.width||E.h>F.height)&&Object.assign(E,Ct(z,F.width,F.height,"auto",y.objectPosition)),r.push({type:"image",...E,image:F,clip:z,alpha:w,z:k,seq:p++})}function B(l,h,y,w){let k=l.left+s,M=l.top+o,C=l.width,F=l.height;if(y==="padding-box"||y==="content-box"){let E=et(h.borderTopWidth),j=et(h.borderRightWidth),O=et(h.borderBottomWidth),A=et(h.borderLeftWidth);k+=A,M+=E,C-=A+j,F-=E+O,w&&(w=w.map(U=>Math.max(0,U-Math.max(E,j,O,A))))}if(y==="content-box"){let E=et(h.paddingTop),j=et(h.paddingRight),O=et(h.paddingBottom),A=et(h.paddingLeft);k+=A,M+=E,C-=A+j,F-=E+O}let z={x:k,y:M,w:Math.max(0,C),h:Math.max(0,F)};return w&&w.some(E=>E>0)&&(z.radius=w),z}function K(l,h,y,w,k,M){let C=l.left+s,F=l.top+o,z=l.width,E=l.height,A=["Top","Right","Bottom","Left"].map(U=>({side:U,width:et(h[`border${U}Width`]),style:h[`border${U}Style`],color:pt(h[`border${U}Color`])})).filter(U=>U.width>0&&U.style!=="none"&&U.style!=="hidden"&&U.color&&U.color.a>0);if(A.length){if(M&&M.some(U=>U>0)){let U=A[0];if(A.length===4&&A.every(G=>G.width===U.width&&G.style===U.style&&JSON.stringify(G.color)===JSON.stringify(U.color))){let G=U.width;r.push({type:"stroke-rrect",x:C+G/2,y:F+G/2,w:z-G,h:E-G,radius:M.map(_=>Math.max(0,_-G/2)),width:G,color:St(U.color,y),dash:we(U.style,G),z:w,seq:p++});return}x("css:borderRadiusNonUniform",{code:"unsupported-css",message:"border-radius with non-uniform borders is approximated with straight borders",property:"border-radius"})}for(let U of A){let V=U.width,G=St(U.color,y),_=U.side==="Top"||U.side==="Bottom",it=U.side==="Top"||U.side==="Left"?1:-1,v=U.side==="Top"?F:U.side==="Bottom"?F+E:U.side==="Left"?C:C+z,Q=we(U.style,V);if(Q){let tt=k?v:v+V/2*it;r.push({type:"line",x1:_?C:tt,y1:_?tt:F,x2:_?C+z:tt,y2:_?tt:F+E,width:V,color:G,dash:Q,z:w,seq:p++});continue}let ot=k?v-V/2:it>0?v:v-V;_?r.push({type:"rect",x:C,y:ot,w:z,h:V,color:G,z:w,seq:p++}):r.push({type:"rect",x:ot,y:F,w:V,h:E,color:G,z:w,seq:p++})}}}function ft(l,h,y,w){let k=l.data;if(!k)return;if(!/\S/.test(k)&&!k.includes("\xA0")){let A=l.ownerDocument.createRange();if(A.selectNodeContents(l),![...A.getClientRects()].some(U=>U.width>0))return}let M=St(pt(y.color)??{r:0,g:0,b:0,a:1},w.alpha),C=et(y.fontSize);if(C<=0)return;let F=Kt(y.fontFamily),z=Qt(y.fontWeight),E=y.fontStyle==="italic"||y.fontStyle==="oblique"?"italic":"normal",j=t.registry.match(F,z,E)??t.registry.match(t.fontFallback,z,E);if(!j){let A=F.join(",");P.has(A)||(P.add(A),t.warn({code:"missing-font",message:`No registered font matches font-family "${y.fontFamily}" and no fallback is available; text will be skipped`,element:h}));return}let O=se(l,y,{registry:t.registry,families:F,fallback:t.fontFallback,primary:j,weight:z,fstyle:E,size:C,textMeasure:t.textMeasure,features:ee(y),warn:t.warn,element:h});for(let A of O)if(A.glyphs.length){c.push({top:A.top+o,bottom:A.bottom+o}),r.push({type:"text",x:A.glyphs[0]?.x??0,y:A.baseline+o,top:A.top+o,bottom:A.bottom+o,size:C,color:M,font:A.font,glyphs:A.glyphs.map(U=>({...U,x:U.x+s})),z:w.z,seq:p++});for(let U of w.decorations){let V=A.glyphs[0],G=A.glyphs[A.glyphs.length-1];if(!V||!G)continue;let _=V.x+s,it=G.x+G.advance+s,v=Math.max(1,C/14),Q=St(U.color,w.alpha);U.line.includes("underline")&&r.push({type:"rect",x:_,y:A.baseline+o+C*.08,w:it-_,h:v,color:Q,z:w.z,seq:p++}),U.line.includes("line-through")&&r.push({type:"rect",x:_,y:A.baseline+o-C*.3,w:it-_,h:v,color:Q,z:w.z,seq:p++})}}}await L(e,{z:0,alpha:1,decorations:[]}),Te(i);let nt=e.getBoundingClientRect().bottom+o;for(let l of i)l.type==="rect"||l.type==="stroke-rrect"||l.type==="image"?nt=Math.max(nt,l.y+l.h):l.type==="line"?nt=Math.max(nt,l.y1,l.y2):(l.type==="text"||l.type==="group"||l.type==="clip")&&(nt=Math.max(nt,l.bottom));function st(l,h,y){for(let w of l.children){if(w.namespaceURI!==ye)continue;let k=w.tagName;if(kn.has(k))continue;let M=n.getComputedStyle(w);if(M.display==="none")continue;let C=parseFloat(M.opacity),F=h*(Number.isFinite(C)?C:1);if(F<=0)continue;if(Mn.has(k)){st(w,F,y);continue}let E=ge(w,V=>{let G=M.getPropertyValue(V);return G&&/^-?[\d.]+px$/.test(G)?String(parseFloat(G)):w.getAttribute(V)??""});if(E===null){x(`svg:${k}`,{code:"unsupported-css",message:`<${k}> inside an inline <svg> is not supported and was skipped (shapes are: path, rect, circle, ellipse, line, polyline, polygon)`,element:w});continue}if(!E.length||M.visibility!=="visible")continue;let j=w.getScreenCTM?.();if(!j)continue;let O=at(w,M.fill,M.fillOpacity,F,"fill"),A=ct(w,M,F);if(!O&&!A)continue;let U=w.getBoundingClientRect();r.push({type:"path",segs:E,matrix:[j.a,j.b,j.c,j.d,j.e+s,j.f+o],fill:O,evenOdd:M.fillRule==="evenodd",stroke:A,top:U.top+o,bottom:U.bottom+o,z:y,seq:p++})}}function at(l,h,y,w,k){if(!h||h==="none")return null;if(h.startsWith("url("))return x(`svg:${k}:url`,{code:"unsupported-css",message:`${k} with a paint server (${h}) inside an inline <svg> is not supported; the shape is skipped`,element:l,property:k}),null;let M=pt(h);if(!M)return null;let C=parseFloat(y),F=w*(Number.isFinite(C)?C:1);return F===1?M:{...M,a:M.a*F}}function ct(l,h,y){let w=at(l,h.stroke,h.strokeOpacity,y,"stroke");if(!w)return null;let k=et(h.strokeWidth);if(!(k>0))return null;let M=(h.strokeDasharray||"none").split(/[\s,]+/).map(E=>et(E)).filter(E=>Number.isFinite(E)&&E>=0),C=h.strokeLinecap==="round"?1:h.strokeLinecap==="square"?2:0,F=h.strokeLinejoin==="round"?1:h.strokeLinejoin==="bevel"?2:0,z=parseFloat(h.strokeMiterlimit);return{color:w,width:k,cap:C,join:F,miter:Number.isFinite(z)&&z>=1?z:4,dash:M.length&&M.some(E=>E>0)?M:null,dashOffset:et(h.strokeDashoffset)||0}}function Y(l,h){let y=l.id||(l.tagName==="A"?l.getAttribute("name"):null);if(y&&!f.has(y)){let C=l.getBoundingClientRect();f.set(y,C.top+o)}if(/^H[1-6]$/.test(l.tagName)){let C=(l.textContent??"").trim().replace(/\s+/g," ");C&&b.push({level:Number(l.tagName[1]),text:C,y:l.getBoundingClientRect().top+o})}if(l.tagName!=="A")return;let w=l.getAttribute("href");if(!w||h.visibility!=="visible")return;let k=w.startsWith("#")?decodeURIComponent(w.slice(1)):null,M=w;if(!k){try{M=new URL(w,l.ownerDocument.baseURI).href}catch{return}if(!/^(https?|mailto|tel|ftp|file):/i.test(M))return}for(let C of l.getClientRects())C.width<=0||C.height<=0||m.push({x:C.left+s,y:C.top+o,w:C.width,h:C.height,href:M,fragment:k})}function Z(l,h,y){let w=r.filter(k=>An(k,l));r=h,w.length&&r.push({type:"clip",box:l,items:w,top:l.y,bottom:l.y+l.h,z:y,seq:p++})}function rt(l){let h=l;for(;h&&h!==e;){for(let y=h.nextElementSibling;y;y=y.nextElementSibling){let w=S(y,"first");if(w)return w}h=h.parentElement}return null}function $(l){let h=l;for(;h&&h!==e;){for(let y=h.previousElementSibling;y;y=y.previousElementSibling){let w=S(y,"last");if(w)return w}h=h.parentElement}return null}function S(l,h){if(me.has(l.tagName))return null;let y=n.getComputedStyle(l);if(y.display==="none")return null;if(y.display!=="contents"&&y.display!=="inline"){let k=l.getBoundingClientRect();if(k.height>0)return{top:k.top+o,bottom:k.bottom+o}}let w=[...l.children];h==="last"&&w.reverse();for(let k of w){let M=S(k,h);if(M)return M}return null}return{items:i,atoms:c,breaks:a,joins:u,tables:g,links:m,anchors:f,headings:b,height:nt}}function Te(e){e.sort((t,n)=>t.z-n.z||t.seq-n.seq);for(let t of e)(t.type==="group"||t.type==="clip")&&Te(t.items)}function we(e,t){return e==="dashed"?[t*3,t*3]:e==="dotted"?[t,t]:null}function xe(e,t){let n=o=>{let r=o.trim().split(/\s+/)[0]??"0px";return r.endsWith("%")?parseFloat(r)/100*t.width:et(r)},s=[n(e.borderTopLeftRadius),n(e.borderTopRightRadius),n(e.borderBottomRightRadius),n(e.borderBottomLeftRadius)];return s.some(o=>o>0)?s:null}function Fn(e){if(!e||e==="none")return null;let t=/^matrix\(([^)]+)\)$/.exec(e.trim());if(!t)return null;let n=t[1].split(",").map(u=>parseFloat(u));if(n.length!==6||n.some(u=>!Number.isFinite(u)))return null;let[s,o,r,i,c,a]=n;return s===1&&o===0&&r===0&&i===1&&c===0&&a===0?null:[s,o,r,i,c,a]}function Pn(e){let t=e.trim().split(/\s+/);return[et(t[0]??"0"),et(t[1]??"0")]}function An(e,t){let n,s,o,r;if(e.type==="rect"||e.type==="stroke-rrect"||e.type==="image")n=e.x,s=e.y,o=e.x+e.w,r=e.y+e.h;else if(e.type==="line")n=Math.min(e.x1,e.x2)-e.width,s=Math.min(e.y1,e.y2)-e.width,o=Math.max(e.x1,e.x2)+e.width,r=Math.max(e.y1,e.y2)+e.width;else if(e.type==="text"){let i=e.glyphs[e.glyphs.length-1];n=e.x,s=e.top,o=i?i.x+i.advance:e.x,r=e.bottom}else{if(e.type==="path")return!0;if(e.type==="clip"||e.type==="gradient"){let i=e.type==="clip"?e.box:e.clip;n=i.x,s=i.y,o=i.x+i.w,r=i.y+i.h}else return!0}return o>t.x&&n<t.x+t.w&&r>t.y&&s<t.y+t.h}function St(e,t){return t===1?e:{...e,a:e.a*t}}function Se(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function En(){return typeof CompressionStream=="function"}async function Ce(e){if(!En())return null;try{let t=new CompressionStream("deflate"),n=t.writable.getWriter();n.write(e),n.close();let s=await new Response(t.readable).arrayBuffer();return new Uint8Array(s)}catch{return null}}var Mt=class{constructor(t){this.id=t}toString(){return`${this.id} 0 R`}},X=class{constructor(t){this.name=t}toString(){let t="/";for(let n of this.name){let s=n.charCodeAt(0);if(s<33||s>126||"#/%()<>[]{}".includes(n))for(let o of new TextEncoder().encode(n))t+="#"+o.toString(16).padStart(2,"0");else t+=n}return t}},dt=class{constructor(t){this.text=t}toString(){return this.text}};function ht(e){if(/^[\x20-\x7e]*$/.test(e))return new dt("("+e.replace(/[\\()]/g,n=>"\\"+n)+")");let t="FEFF";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16).padStart(4,"0");return new dt("<"+t+">")}function ke(e){let t=i=>String(i).padStart(2,"0"),n=-e.getTimezoneOffset(),s=n>=0?"+":"-",o=t(Math.floor(Math.abs(n)/60)),r=t(Math.abs(n)%60);return new dt(`(D:${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}${s}${o}'${r}')`)}function $t(e){if(e===null)return"null";if(typeof e=="number")return I(e);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return new X(e).toString();if(e instanceof Mt||e instanceof X||e instanceof dt)return e.toString();if(Array.isArray(e))return"["+e.map($t).join(" ")+"]";let t=[];for(let[n,s]of Object.entries(e))s!==void 0&&t.push(new X(n).toString()+" "+$t(s));return"<< "+t.join(" ")+" >>"}var Ut=class{constructor(t={}){this.objects=[null],this.compress=t.compress??!0,this.version=t.version??"1.7"}reserve(){return this.objects.push({value:null}),new Mt(this.objects.length-1)}set(t,n,s){this.objects[t.id]={value:n,stream:s}}add(t){let n=this.reserve();return this.set(n,t),n}async addStream(t,n,s={}){let o=this.reserve();return await this.setStream(o,t,n,s),o}async setStream(t,n,s,o={}){let r=s,i={...n};if((o.compress??this.compress)&&!("Filter"in i)){let a=await Ce(s);a&&a.length<s.length&&(r=a,i.Filter="FlateDecode")}i.Length=r.length,this.set(t,i,r)}build(t,n){let s=new TextEncoder,o=[],r=0,i=f=>{let b=typeof f=="string"?s.encode(f):f;o.push(b),r+=b.length};i(Ft([s.encode(`%PDF-${this.version}
|
|
6
6
|
%`),new Uint8Array([226,227,207,211]),s.encode(`
|
|
7
|
-
`)]));let
|
|
8
|
-
${
|
|
9
|
-
`),
|
|
10
|
-
`),i(
|
|
7
|
+
`)]));let c=[];for(let f=1;f<this.objects.length;f++){let b=this.objects[f];if(!b)throw new Error(`PDF object ${f} was reserved but never set`);c[f]=r,i(`${f} 0 obj
|
|
8
|
+
${$t(b.value)}
|
|
9
|
+
`),b.stream&&(i(`stream
|
|
10
|
+
`),i(b.stream),i(`
|
|
11
11
|
endstream
|
|
12
12
|
`)),i(`endobj
|
|
13
|
-
`)}let
|
|
13
|
+
`)}let a=r,u=`xref
|
|
14
14
|
0 ${this.objects.length}
|
|
15
15
|
0000000000 65535 f
|
|
16
|
-
`;for(let f=1;f<this.objects.length;f++)
|
|
17
|
-
`;i(
|
|
18
|
-
${
|
|
16
|
+
`;for(let f=1;f<this.objects.length;f++)u+=String(c[f]).padStart(10,"0")+` 00000 n
|
|
17
|
+
`;i(u);let m={Size:this.objects.length,Root:t};return n&&(m.Info=n),i(`trailer
|
|
18
|
+
${$t(m)}
|
|
19
19
|
startxref
|
|
20
|
-
${
|
|
20
|
+
${a}
|
|
21
21
|
%%EOF
|
|
22
|
-
`),
|
|
22
|
+
`),Ft(o)}};function Ft(e){let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),s=0;for(let o of e)n.set(o,s),s+=o.length;return n}var Pt=class{constructor(){this.ops=[],this.depth=0}save(){return this.ops.push("q"),this.depth++,this}restore(){if(this.depth<=0)throw new Error("ContentStream: unbalanced Q");return this.ops.push("Q"),this.depth--,this}transform(t,n,s,o,r,i){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} ${I(o)} ${I(r)} ${I(i)} cm`),this}setGState(t){return this.ops.push(`/${t} gs`),this}fillColor(t,n,s){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} rg`),this}strokeColor(t,n,s){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} RG`),this}lineWidth(t){return this.ops.push(`${I(t)} w`),this}dash(t,n=0){return this.ops.push(`[${t.map(I).join(" ")}] ${I(n)} d`),this}lineCap(t){return this.ops.push(`${t} J`),this}rect(t,n,s,o){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} ${I(o)} re`),this}moveTo(t,n){return this.ops.push(`${I(t)} ${I(n)} m`),this}lineTo(t,n){return this.ops.push(`${I(t)} ${I(n)} l`),this}curveTo(t,n,s,o,r,i){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} ${I(o)} ${I(r)} ${I(i)} c`),this}closePath(){return this.ops.push("h"),this}roundedRect(t,n,s,o,r){let c=Math.min(s,o)/2,a=p=>Math.max(0,Math.min(p,c)),u=a(r[0]),m=a(r[1]),f=a(r[2]),b=a(r[3]),g=n+o,d=t+s;return this.moveTo(t+u,g),this.lineTo(d-m,g),m&&this.curveTo(d-m+m*.5523,g,d,g-m+m*.5523,d,g-m),this.lineTo(d,n+f),f&&this.curveTo(d,n+f-f*.5523,d-f+f*.5523,n,d-f,n),this.lineTo(t+b,n),b&&this.curveTo(t+b-b*.5523,n,t,n+b-b*.5523,t,n+b),this.lineTo(t,g-u),u&&this.curveTo(t,g-u+u*.5523,t+u-u*.5523,g,t+u,g),this.closePath()}image(t,n,s,o,r){return this.ops.push(`q ${I(o)} 0 0 ${I(r)} ${I(n)} ${I(s)} cm /${t} Do Q`),this}lineJoin(t){return this.ops.push(`${t} j`),this}miterLimit(t){return this.ops.push(`${I(t)} M`),this}fill(t=!1){return this.ops.push(t?"f*":"f"),this}fillAndStroke(t=!1){return this.ops.push(t?"B*":"B"),this}path(t){for(let n of t)n[0]==="M"?this.moveTo(n[1],n[2]):n[0]==="L"?this.lineTo(n[1],n[2]):n[0]==="C"?this.curveTo(n[1],n[2],n[3],n[4],n[5],n[6]):this.closePath();return this}stroke(){return this.ops.push("S"),this}shading(t){return this.ops.push(`/${t} sh`),this}clip(){return this.ops.push("W n"),this}fillRect(t,n,s,o){return this.rect(t,n,s,o).fill()}text(t,n,s,o,r,i={}){let c=[];for(let a of r)typeof a=="string"?a.length&&c.push(`<${a}>`):a!==0&&c.push(I(a));return c.length?(this.ops.push("BT"),this.ops.push(`/${t} ${I(n)} Tf`),i.charSpacing&&this.ops.push(`${I(i.charSpacing)} Tc`),i.rise&&this.ops.push(`${I(i.rise)} Ts`),this.ops.push(`1 0 0 1 ${I(s)} ${I(o)} Tm`),this.ops.push(`[${c.join(" ")}] TJ`),this.ops.push("ET"),this):this}toBytes(){if(this.depth!==0)throw new Error(`ContentStream: ${this.depth} unclosed q`);return new TextEncoder().encode(this.ops.join(`
|
|
23
23
|
`)+`
|
|
24
|
-
`)}};function
|
|
24
|
+
`)}};function $e(e,t){let n=new Set([0]),s=[...t];for(;s.length;){let D=s.pop();if(!(D<0||D>=e.numGlyphs||n.has(D))){n.add(D);for(let B of Yt(It(e,D)))n.has(B)||s.push(B)}}let o=[...n].sort((D,B)=>D-B),r=new Map;o.forEach((D,B)=>r.set(D,B));let i=o.length,c=[],a=new Uint32Array(i+1),u=0;for(let D=0;D<i;D++){let B=It(e,o[D]);B.length&&new DataView(B.buffer,B.byteOffset,B.byteLength).getInt16(0)<0&&(B=Nn(B,r)),a[D]=u,c.push(B),u+=B.length;let K=(4-u%4)%4;K&&(c.push(new Uint8Array(K)),u+=K)}a[i]=u;let m=Ft(c),f=new Uint8Array(a.length*4),b=new DataView(f.buffer);a.forEach((D,B)=>b.setUint32(B*4,D));let g=e.tables.get("hmtx"),d=e.tables.get("hhea"),p=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),T=p.getUint16(d.offset+34),P=new Uint8Array(i*4),x=new DataView(P.buffer);for(let D=0;D<i;D++){let B=o[D],K=B<T?g.offset+B*4+2:g.offset+T*4+(B-T)*2;x.setUint16(D*4,e.advances[B]??0),x.setInt16(D*4+2,K+2<=e.data.byteLength?p.getInt16(K):0)}let L=At(e,"head"),N=new DataView(L.buffer);N.setUint32(8,0),N.setInt16(50,1);let q=At(e,"hhea");new DataView(q.buffer).setUint16(34,i);let H=At(e,"maxp");new DataView(H.buffer).setUint16(4,i);let W=[["glyf",m],["head",L],["hhea",q],["hmtx",P],["loca",f],["maxp",H]];for(let D of["cvt ","fpgm","prep"])e.tables.has(D)&&W.push([D,At(e,D)]);return W.sort((D,B)=>D[0]<B[0]?-1:1),{data:In(W),gidMap:r,oldGids:o}}function At(e,t){let n=e.tables.get(t);if(!n)throw new Error(`missing table ${t}`);return new Uint8Array(e.data.subarray(n.offset,n.offset+n.length))}function Nn(e,t){let n=new Uint8Array(e),s=new DataView(n.buffer),o=10;for(;;){let r=s.getUint16(o),i=s.getUint16(o+2);if(s.setUint16(o+2,t.get(i)??0),o+=4,o+=r&1?4:2,r&8?o+=2:r&64?o+=4:r&128&&(o+=8),!(r&32)||o>=n.length)break}return n}function In(e){let t=e.length,n=0;for(;1<<n+1<=t;)n++;let s=(1<<n)*16,o=t*16-s,i=12+t*16,c=[];for(let[f,b]of e)c.push({tag:f,data:b,offset:i,checksum:Me(b)}),i+=b.length+3&-4;let a=new Uint8Array(i),u=new DataView(a.buffer);u.setUint32(0,65536),u.setUint16(4,t),u.setUint16(6,s),u.setUint16(8,n),u.setUint16(10,o),c.forEach((f,b)=>{let g=12+b*16;for(let d=0;d<4;d++)a[g+d]=f.tag.charCodeAt(d);u.setUint32(g+4,f.checksum),u.setUint32(g+8,f.offset),u.setUint32(g+12,f.data.length),a.set(f.data,f.offset)});let m=c.find(f=>f.tag==="head");if(m){let f=Me(a);u.setUint32(m.offset+8,2981146554-f>>>0)}return a}function Me(e){let t=0,n=e.length;for(let s=0;s<n;s+=4){let o=e[s]??0,r=e[s+1]??0,i=e[s+2]??0,c=e[s+3]??0;t=t+((o<<24|r<<16|i<<8|c)>>>0)>>>0}return t}var Et=class{constructor(t,n){this.font=t,this.resourceName=n,this.usedGids=new Map,this.subset=null}addGlyph(t,n){this.usedGids.has(t)||this.usedGids.set(t,n)}cid(t){if(!this.subset)throw new Error("EmbeddedFont: embed() must be called before cid()");return this.subset.gidMap.get(t)??0}finalize(){return this.subset||(this.subset=$e(this.font,this.usedGids.keys())),this.subset}async embed(t){let n=this.finalize(),s=this.font,o=1e3/s.unitsPerEm,i=`${Rn(this.usedGids)}+${s.postScriptName}`,c=await t.addStream({Length1:n.data.length},n.data),a=4;s.italic&&(a|=64),s.bold&&(a|=1<<18);let u=t.add({Type:"FontDescriptor",FontName:i,Flags:a,FontBBox:s.bbox.map(p=>Math.round(p*o)),ItalicAngle:s.italicAngle,Ascent:Math.round(s.ascender*o),Descent:Math.round(s.descender*o),CapHeight:Math.round(s.capHeight*o),StemV:s.bold?120:80,FontFile2:c}),m=[],f=n.oldGids.map(p=>Math.round((s.advances[p]??0)*o)),b=0;for(;b<f.length;){let p=b;for(;p+1<f.length&&p-b<100;)p++;m.push(b,f.slice(b,p+1)),b=p+1}let g=t.add({Type:"Font",Subtype:"CIDFontType2",BaseFont:i,CIDSystemInfo:{Registry:new dt("(Adobe)"),Ordering:new dt("(Identity)"),Supplement:0},FontDescriptor:u,DW:1e3,W:m,CIDToGIDMap:"Identity"}),d=await t.addStream({},vn(n,this.usedGids));return t.add({Type:"Font",Subtype:"Type0",BaseFont:i,Encoding:"Identity-H",DescendantFonts:[g],ToUnicode:d})}};function Rn(e){let t=2166136261;for(let s of e.keys())t^=s,t=Math.imul(t,16777619)>>>0;let n="";for(let s=0;s<6;s++)n+=String.fromCharCode(65+t%26),t=Math.floor(t/26);return n}function vn(e,t){let n=[];e.oldGids.forEach((r,i)=>{let c=t.get(r);c!==void 0&&n.push(`<${yt(i)}> <${Ln(c)}>`)});let s="";for(let r=0;r<n.length;r+=100){let i=n.slice(r,r+100);s+=`${i.length} beginbfchar
|
|
25
25
|
${i.join(`
|
|
26
26
|
`)}
|
|
27
27
|
endbfchar
|
|
@@ -38,5 +38,6 @@ endcodespacerange
|
|
|
38
38
|
CMapName currentdict /CMap defineresource pop
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
`;return new TextEncoder().encode(o)}function rt(e){return e.toString(16).toUpperCase().padStart(4,"0")}function je(e){if(e<=65535)return rt(e);let t=e-65536;return rt(55296+(t>>10))+rt(56320+(t&1023))}async function Kt(e,t){let n={Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceRGB",BitsPerComponent:8};if(t.jpeg)return n.Filter="DCTDecode",e.addStream(n,t.jpeg,{compress:!1});if(!t.rgb)throw new Error("embedImage: image has no pixel data");return t.alpha&&(n.SMask=await e.addStream({Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceGray",BitsPerComponent:8},t.alpha)),e.addStream(n,t.rgb)}function Jt(e,t){let n=t,s=e.height,o=[...e.atoms].sort((f,d)=>f.top-d.top),r=[...new Set(e.breaks)].sort((f,d)=>f-d),i=.01,a=[],c=0,h=0;for(;c<s-i&&h++<1e4;){let f=[],d=0;for(let C of e.tables)C.headItems.length&&C.headBottom<=c+i&&c<C.bottom-i&&(f.push({table:C,shift:d}),d+=C.headBottom-C.headTop);let u=[],w=0,y=c;for(let C=0;C<4;C++){let O=Math.max(n-d-w,n*.25);y=p(c,O);let R=[],D=0;for(let j of e.tables)j.footItems.length&&j.top<y-i&&j.footTop>=y-i&&j.bottom>y+i&&(R.push({table:j,shift:D}),D+=j.footBottom-j.footTop);let L=R.length===u.length&&R.every((j,z)=>j.table===u[z]?.table);if(u=R,w=D,L)break}a.push({start:c,end:y,heads:f,headShift:d,feet:u,footShift:w}),c=y}return a.length||a.push({start:0,end:Math.max(s,1),heads:[],headShift:0,feet:[],footShift:0}),a;function p(f,d){let u=Math.min(f+d,s);for(let w of r)if(w>f+i&&w<u-i){u=w;break}if(u<s-i){let w=!0,y=0;for(;w&&y++<1e3;){w=!1;for(let C of o){if(C.top>=u)break;C.bottom-C.top>d||C.top<u-i&&C.bottom>u+i&&C.top>f+i&&(u=C.top,w=!0)}}u<=f+i&&(u=Math.min(f+d,s))}return u}}function Qt(e={}){let t=e.size??"A4",n,s;if(typeof t=="string"){let i=$t[t];if(!i)throw new Error(`Unknown page size "${t}". Use one of ${Object.keys($t).join(", ")} or {width, height}.`);n=i.width,s=i.height}else n=Y(t.width),s=Y(t.height);(e.orientation??"portrait")==="landscape"&&n<s&&([n,s]=[s,n]);let o=e.margin??"15mm",r=typeof o=="string"?{top:Y(o),right:Y(o),bottom:Y(o),left:Y(o)}:{top:Y(o.top),right:Y(o.right),bottom:Y(o.bottom),left:Y(o.left)};return{width:n,height:s,...r}}async function Zt(e,t,n){let s=new dt({compress:n.compress}),o=(n.header?.heightPx??0)*.75,r=(n.footer?.heightPx??0)*.75,i=t.width-t.left-t.right,a=t.height-t.top-o,c=t.height-t.top-t.bottom-o-r;if(c<=0)throw new Error("Page content area is empty: margins + header + footer exceed the page height");let h=c/.75,p=Jt(e,h),f=p.length,d=[],u=[];for(let g=0;g<f;g++)d.push(n.header?await n.header.render(g+1,f):null),u.push(n.footer?await n.footer.render(g+1,f):null);let w=new Map,y=new Map,C=g=>{for(let x of g)if(x.type==="text"){let S=w.get(x.font);S||(S=new gt(x.font.parsed,`F${w.size+1}`),w.set(x.font,S));for(let F of x.glyphs)S.addGlyph(F.gid,F.cp)}else x.type==="image"?y.has(x.image.key)||y.set(x.image.key,{name:`Im${y.size+1}`,image:x.image}):(x.type==="group"||x.type==="clip")&&C(x.items)};C(e.items);for(let g of[...d,...u])g&&C(g.items);for(let g of w.values())g.finalize();let O={};for(let g of w.values())O[g.resourceName]=await g.embed(s);let R={};for(let g of y.values())R[g.name]=await Kt(s,g.image);let D=new Map,L={},j=g=>{let x=U(g),S=D.get(x);return S||(S=`GS${D.size+1}`,D.set(x,S),L[S]=s.add({Type:"ExtGState",ca:g,CA:g})),S},z=s.reserve(),X=[];for(let g=0;g<f;g++){let x=p[g],S=new pt,F=new Ut(S,t,w,y,j),E=x.headShift*.75,k=x.footShift*.75;S.save(),S.rect(t.left,a-c+k,i,c-E-k).clip(),F.setOrigin(a-E,x.start),F.render(e.items,x),S.restore();let I=a-E-(x.end-x.start)*.75;for(let b of x.feet){let T=(b.table.footBottom-b.table.footTop)*.75,B=I-b.shift*.75-T;S.save(),S.rect(t.left,B,i,T).clip(),F.setOrigin(B+T,b.table.footTop),F.render(b.table.footItems),S.restore()}for(let b of x.heads){S.save();let T=(b.table.headBottom-b.table.headTop)*.75;S.rect(t.left,a-b.shift*.75-T,i,T).clip(),F.setOrigin(a-b.shift*.75,b.table.headTop),F.render(b.table.headItems),S.restore()}let M=d[g];M&&(S.save(),S.rect(t.left,t.height-t.top-o,i,o).clip(),F.setOrigin(t.height-t.top,0),F.render(M.items),S.restore());let N=u[g];N&&(S.save(),S.rect(t.left,t.bottom,i,r).clip(),F.setOrigin(t.bottom+r,0),F.render(N.items),S.restore());let W=await s.addStream({},S.toBytes());X.push(s.add({Type:"Page",Parent:z,MediaBox:[0,0,t.width,t.height],Resources:{Font:O,XObject:R,ExtGState:L,ProcSet:[new J("PDF"),new J("Text"),new J("ImageC")]},Contents:W}))}s.set(z,{Type:"Pages",Kids:X,Count:X.length});let et=s.add({Type:"Catalog",Pages:z}),$=n.metadata??{},l={Producer:nt("receipt-html-to-pdf"),Creator:nt($.creator??"receipt-html-to-pdf"),CreationDate:Vt($.creationDate??new Date)};$.title&&(l.Title=nt($.title)),$.author&&(l.Author=nt($.author)),$.subject&&(l.Subject=nt($.subject)),$.keywords&&(l.Keywords=nt($.keywords));let m=s.add(l);return s.build(et,m)}function Ne(e,t){if(e.type==="text"){let s=(e.top+e.bottom)/2;return s>=t.start-.01&&s<t.end-.01}return Ge(e)>t.start+.01&&We(e)<t.end-.01}var Ut=class{constructor(t,n,s,o,r){this.cs=t,this.geo=n,this.fonts=s,this.images=o,this.gsName=r,this.pdfTop=n.height-n.top,this.docTop=0,this.curAlpha=1}setOrigin(t,n){this.pdfTop=t,this.docTop=n}X(t){return this.geo.left+t*.75}Y(t){return this.pdfTop-(t-this.docTop)*.75}setAlpha(t){Math.abs(t-this.curAlpha)<.001||(this.cs.setGState(this.gsName(t)),this.curAlpha=t)}radiusPt(t){return(t??[0,0,0,0]).map(n=>n*.75)}clipBox(t){let n=this.cs;t.radius?n.roundedRect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75,this.radiusPt(t.radius)):n.rect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75),n.clip()}render(t,n){let s=this.cs;for(let o of t)if(!(n&&!Ne(o,n)))if(o.type==="rect"){if(o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),o.radius?s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).fill():s.fillRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="line")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.moveTo(this.X(o.x1),this.Y(o.y1)).lineTo(this.X(o.x2),this.Y(o.y2)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="stroke-rrect")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="image"){let r=this.images.get(o.image.key);if(!r||o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.alpha),o.clip&&this.clipBox(o.clip),s.image(r.name,this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="text"){let r=this.fonts.get(o.font),i=ze(o,r);s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),s.text(r.resourceName,o.size*.75,this.X(o.x),this.Y(o.y),i),s.restore(),this.curAlpha=1}else if(o.type==="group"){let[r,i,a,c]=o.matrix,h=this.X(o.origin.x),p=this.Y(o.origin.y),f=r,d=-i,u=-a,w=c,y=h-(f*h+u*p)+o.matrix[4]*.75,C=p-(d*h+w*p)-o.matrix[5]*.75;s.save(),s.transform(f,d,u,w,y,C),this.render(o.items,n),s.restore()}else o.type==="clip"&&(s.save(),this.clipBox(o.box),this.render(o.items,n),s.restore())}};function ze(e,t){let n=[],s="";for(let o=0;o<e.glyphs.length;o++){let r=e.glyphs[o];s+=rt(t.cid(r.gid));let i=e.glyphs[o+1];if(!i)break;let a=r.x+r.advance,h=-(i.x-a)/e.size*1e3;Math.abs(h)>=.5&&(n.push(s,Math.round(h*10)/10),s="")}return s&&n.push(s),n}function We(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y:e.type==="line"?Math.min(e.y1,e.y2)-e.width/2:(e.type==="group"||e.type==="clip",e.top)}function Ge(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y+e.h:e.type==="line"?Math.max(e.y1,e.y2)+e.width/2:(e.type==="group"||e.type==="clip",e.bottom)}var Mn="0.2.1",yt=new ct;async function An(e){if(!e||!e.family||!e.src)throw new TypeError("registerFont: { family, src } are required");(await yt.register(e)).parsed.variable&&console.warn(`[receipt-html-to-pdf] "${e.family}" is a variable font; only the default instance outlines are embedded. Use static TTF instances for other weights.`)}function In(){return yt.fonts.map(e=>({family:e.displayFamily,weight:e.weight,style:e.style,glyphs:e.parsed.numGlyphs}))}async function Rn(e,t={}){if(typeof document>"u")throw new Error("htmlToPdf must run in a browser (needs DOM layout)");if(yt.fonts.length===0)throw new Error("htmlToPdf: no fonts registered. Call registerFont() with at least one TrueType font first.");let n=t.onWarning??(()=>{}),s=Qt(t.page),o=(s.width-s.left-s.right)/.75,r=await St(e,{widthPx:o,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n}),i={registry:yt,fontFallback:t.fontFallback??[],warn:n,textMeasure:t.textMeasure??"auto"},a={widthPx:o,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n};try{let c=await Ft(r.root,i),h=t.header?await te(t.header,a,i):null,p=t.footer?await te(t.footer,a,i):null,f=await Zt(c,s,{compress:t.compress??!0,metadata:t.metadata,header:h,footer:p});return He(f,t.output??"blob")}finally{r.destroy()}}async function te(e,t,n){let s=async(i,a)=>{let c=e.replace(/\{\{\s*pageNumber\s*\}\}/g,String(i)).replace(/\{\{\s*totalPages\s*\}\}/g,String(a)),h=await St(c,t);try{return await Ft(h.root,n)}finally{h.destroy()}},o=await s(1,1),r=new Map([["1/1",o]]);return{heightPx:o.height,render:async(i,a)=>{let c=`${i}/${a}`,h=r.get(c);return h||(h=await s(i,a),r.set(c,h)),h}}}function He(e,t){if(t==="uint8array")return e;if(t==="dataurl"){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,s+32768));return"data:application/pdf;base64,"+btoa(n)}return new Blob([e],{type:"application/pdf"})}function Bn(e,t){let n=e instanceof Blob?e:new Blob([e],{type:"application/pdf"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}export{Bn as downloadPdf,ot as expandPrintMediaCss,Rn as htmlToPdf,In as listFonts,An as registerFont,Mn as version};
|
|
41
|
+
`;return new TextEncoder().encode(o)}function yt(e){return e.toString(16).toUpperCase().padStart(4,"0")}function Ln(e){if(e<=65535)return yt(e);let t=e-65536;return yt(55296+(t>>10))+yt(56320+(t&1023))}async function Ue(e,t){let n={Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceRGB",BitsPerComponent:8};if(t.jpeg)return n.Filter="DCTDecode",e.addStream(n,t.jpeg,{compress:!1});if(!t.rgb)throw new Error("embedImage: image has no pixel data");return t.alpha&&(n.SMask=await e.addStream({Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceGray",BitsPerComponent:8},t.alpha)),e.addStream(n,t.rgb)}function Fe(e,t){let s=t,o=e.height,r=[...e.atoms].sort((g,d)=>g.top-d.top),i=[...new Set(e.breaks)].sort((g,d)=>g-d),c=(e.joins??[]).map(g=>{let d=r.find(p=>p.top>=g.end-.01);return{start:g.start,limit:d?Math.max(d.top,g.end):g.end,pullTo:g.pullTo}}),a=.01,u=[],m=0,f=0;for(;m<o-a&&f++<1e4;){let g=[],d=0;for(let x of e.tables)x.headItems.length&&x.headBottom<=m+a&&m<x.bottom-a&&(g.push({table:x,shift:d}),d+=x.headBottom-x.headTop);let p=[],T=0,P=m;for(let x=0;x<4;x++){let L=Math.max(s-d-T,s*.25);P=b(m,L);let N=[],q=0;for(let W of e.tables)W.footItems.length&&W.top<P-a&&W.footTop>=P-a&&W.bottom>P+a&&(N.push({table:W,shift:q}),q+=W.footBottom-W.footTop);let H=N.length===p.length&&N.every((W,J)=>W.table===p[J]?.table);if(p=N,T=q,H)break}u.push({start:m,end:P,heads:g,headShift:d,feet:p,footShift:T}),m=P}return u.length||u.push({start:0,end:Math.max(o,1),heads:[],headShift:0,feet:[],footShift:0}),u;function b(g,d){let p=Math.min(g+d,o);for(let T of i)if(T>g+a&&T<p-a){p=T;break}if(p<o-a){let T=!0,P=0;for(;T&&P++<1e3;){T=!1;for(let x of r){if(x.top>=p)break;x.bottom-x.top>d||x.top<p-a&&x.bottom>p+a&&x.top>g+a&&(p=x.top,T=!0)}for(let x of c)x.limit-x.pullTo>d||x.pullTo<=g+a||p>=x.start-a&&p<=x.limit+a&&p>x.pullTo+a&&(p=x.pullTo,T=!0)}p<=g+a&&(p=Math.min(g+d,o))}return p}}function On(e,t,n){let s=t[0],o=t[t.length-1],r=o.t-s.t;if(!(r>0))return e.add({FunctionType:2,Domain:[0,1],C0:n(s.color),C1:n(o.color),N:1});if(t.length===2)return e.add({FunctionType:2,Domain:[0,1],C0:n(s.color),C1:n(o.color),N:1});let i=[],c=[],a=[];for(let u=0;u<t.length-1;u++){let m=t[u],f=t[u+1];i.push(e.add({FunctionType:2,Domain:[0,1],C0:n(m.color),C1:n(f.color),N:1})),a.push(0,1),u>0&&c.push((m.t-s.t)/r)}return e.add({FunctionType:3,Domain:[0,1],Functions:i,Bounds:c,Encode:a})}function Wt(e,t,n,s){let o=s==="rgb"?r=>[r.r,r.g,r.b]:r=>[r.a];return e.add({ShadingType:2,ColorSpace:new X(s==="rgb"?"DeviceRGB":"DeviceGray"),Coords:[t.x0,t.y0,t.x1,t.y1],Function:On(e,n,o),Extend:[!0,!0]})}function Pe(e){let t=e[0].color.a;return e.every(n=>Math.abs(n.color.a-t)<.002)?t:null}async function Ae(e,t,n,s,o){let r=o===1?n:n.map(u=>({t:u.t,color:{...u.color,a:u.color.a*o}})),i=Wt(e,t,r,"gray"),c=new TextEncoder().encode(`q ${s.x} ${s.y} ${s.w} ${s.h} re W n /Sh0 sh Q
|
|
42
|
+
`),a=await e.addStream({Type:new X("XObject"),Subtype:new X("Form"),BBox:[s.x,s.y,s.x+s.w,s.y+s.h],Group:{Type:new X("Group"),S:new X("Transparency"),CS:new X("DeviceGray")},Resources:{Shading:{Sh0:i}}},c);return e.add({Type:new X("ExtGState"),SMask:{Type:new X("Mask"),S:new X("Luminosity"),G:a,BC:[0]},ca:1,CA:1})}function zt(e,t,n){let s={Type:new X("Annot"),Subtype:new X("Link"),Rect:[t.x,t.y,t.x+t.w,t.y+t.h],Border:[0,0,0],F:4};return"uri"in n?s.A={S:new X("URI"),URI:ht(n.uri)}:s.Dest=n.dest,e.add(s)}function Ee(e,t){let n=t.filter(a=>a.dest!==null);if(!n.length)return null;let s=[],o=[];for(let a of n){let u={level:a.level,text:a.text,dest:a.dest,children:[],ref:e.reserve()};for(;o.length&&o[o.length-1].level>=u.level;)o.pop();let m=o[o.length-1];m?m.children.push(u):s.push(u),o.push(u)}let r=e.reserve(),i=(a,u)=>{let m=0;return a.forEach((f,b)=>{let g=i(f.children,f.ref),d={Title:ht(f.text),Parent:u,Dest:f.dest},p=a[b-1],T=a[b+1];p&&(d.Prev=p.ref),T&&(d.Next=T.ref),f.children.length&&(d.First=f.children[0].ref,d.Last=f.children[f.children.length-1].ref,d.Count=g),e.set(f.ref,d),m+=1+g}),m},c=i(s,r);return e.set(r,{Type:new X("Outlines"),First:s[0].ref,Last:s[s.length-1].ref,Count:c}),r}function Ne(e={}){let t=e.size??"A4",n,s;if(typeof t=="string"){let i=Dt[t];if(!i)throw new Error(`Unknown page size "${t}". Use one of ${Object.keys(Dt).join(", ")} or {width, height}.`);n=i.width,s=i.height}else n=ut(t.width),s=ut(t.height);(e.orientation??"portrait")==="landscape"&&n<s&&([n,s]=[s,n]);let o=e.margin??"15mm",r=typeof o=="string"?{top:ut(o),right:ut(o),bottom:ut(o),left:ut(o)}:{top:ut(o.top),right:ut(o.right),bottom:ut(o.bottom),left:ut(o.left)};return{width:n,height:s,...r}}async function Ie(e,t,n){let s=new Ut({compress:n.compress}),o=(n.header?.heightPx??0)*.75,r=(n.footer?.heightPx??0)*.75,i=t.width-t.left-t.right,c=t.height-t.top-o,a=t.height-t.top-t.bottom-o-r;if(a<=0)throw new Error("Page content area is empty: margins + header + footer exceed the page height");let u=a/.75,m=Fe(e,u),f=m.length,b=[],g=[];for(let $=0;$<f;$++)b.push(n.header?await n.header.render($+1,f):null),g.push(n.footer?await n.footer.render($+1,f):null);let d=new Map,p=new Map,T=$=>{for(let S of $)if(S.type==="text"){let l=d.get(S.font);l||(l=new Et(S.font.parsed,`F${d.size+1}`),d.set(S.font,l));for(let h of S.glyphs)l.addGlyph(h.gid,h.cp)}else S.type==="image"?p.has(S.image.key)||p.set(S.image.key,{name:`Im${p.size+1}`,image:S.image}):(S.type==="group"||S.type==="clip")&&T(S.items)};T(e.items);for(let $ of[...b,...g])$&&T($.items);for(let $ of d.values())$.finalize();let P={};for(let $ of d.values())P[$.resourceName]=await $.embed(s);let x={};for(let $ of p.values()){let S=$.image;if(!S.jpeg&&!S.rgb){let l=await xt(S.key,n.warn??(()=>{}));if(!l)continue;S=l}x[$.name]=await Ue(s,S),fe(S),n.pacer&&await n.pacer()}let L=new Map,N={},q=($,S=$)=>{let l=`${I($)}/${I(S)}`,h=L.get(l);return h||(h=`GS${L.size+1}`,L.set(l,h),N[h]=s.add({Type:"ExtGState",ca:$,CA:S})),h},H={},W=new Map,J=async $=>{for(let S of $)if(S.type==="gradient"){let l=`Sh${Object.keys(H).length+1}`;H[l]=Wt(s,S.gradient,S.gradient.stops,"rgb");let h=Pe(S.gradient.stops),y=null;if(h===null){let w=await Ae(s,S.gradient,S.gradient.stops,{x:0,y:0,w:S.box.w,h:S.box.h},S.alpha);y=`GM${W.size+1}`,N[y]=w}W.set(S,{sh:l,gs:y})}else(S.type==="group"||S.type==="clip")&&await J(S.items)};await J(e.items);for(let $ of[...b,...g])$&&await J($.items);let D=s.reserve(),B=[],K=Array.from({length:f},()=>s.reserve()),ft=$=>K[$],nt=$=>{for(let S=0;S<f;S++){let l=m[S];if($>=l.start-.01&&($<l.end-.01||S===f-1)){let h=c-l.headShift*.75;return{page:S,x:t.left,y:h-($-l.start)*.75}}}return null};n.progress?.({phase:"layout",totalPages:f});for(let $=0;$<f;$++){n.pacer&&await n.pacer(),n.progress?.({phase:"page",page:$+1,totalPages:f});let S=m[$],l=new Pt,h=new qt(l,t,d,p,q,W),y=S.headShift*.75,w=S.footShift*.75;l.save(),l.rect(t.left,c-a+w,i,a-y-w).clip(),h.setOrigin(c-y,S.start),h.render(e.items,S),l.restore();let k=c-y-(S.end-S.start)*.75;for(let O of S.feet){let A=(O.table.footBottom-O.table.footTop)*.75,U=k-O.shift*.75-A;l.save(),l.rect(t.left,U,i,A).clip(),h.setOrigin(U+A,O.table.footTop),h.render(O.table.footItems),l.restore()}for(let O of S.heads){l.save();let A=(O.table.headBottom-O.table.headTop)*.75;l.rect(t.left,c-O.shift*.75-A,i,A).clip(),h.setOrigin(c-O.shift*.75,O.table.headTop),h.render(O.table.headItems),l.restore()}let M=b[$];M&&(l.save(),l.rect(t.left,t.height-t.top-o,i,o).clip(),h.setOrigin(t.height-t.top,0),h.render(M.items),l.restore());let C=g[$];C&&(l.save(),l.rect(t.left,t.bottom,i,r).clip(),h.setOrigin(t.bottom+r,0),h.render(C.items),l.restore());let F=[];if(n.links!==!1){let O=(A,U,V,G)=>{for(let _ of A){let it=Math.max(_.y,V),v=Math.min(_.y+_.h,G);if(v-it<=.01)continue;let Q={x:t.left+_.x*.75,y:U-(v-V)*.75,w:_.w*.75,h:(v-it)*.75};if(_.fragment===null){F.push(zt(s,Q,{uri:_.href}));continue}let ot=e.anchors?.get(_.fragment);if(ot===void 0)continue;let tt=nt(ot);tt&&F.push(zt(s,Q,{dest:[ft(tt.page),new X("XYZ"),tt.x,tt.y,null]}))}};O(e.links??[],c-y,S.start,S.end),M&&O(M.links??[],t.height-t.top,0,o/.75),C&&O(C.links??[],t.bottom+r,0,r/.75)}let z=await s.addStream({},l.toBytes()),E={Type:"Page",Parent:D,MediaBox:[0,0,t.width,t.height],Resources:{Font:P,XObject:x,ExtGState:N,Shading:H,ProcSet:[new X("PDF"),new X("Text"),new X("ImageC")]},Contents:z};F.length&&(E.Annots=F);let j=ft($);s.set(j,E),B.push(j)}s.set(D,{Type:"Pages",Kids:B,Count:B.length});let st=null;n.outline&&(st=Ee(s,(e.headings??[]).map($=>{let S=nt($.y);return{level:$.level,text:$.text,dest:S?[ft(S.page),new X("XYZ"),S.x,S.y,null]:null}})));let at={Type:"Catalog",Pages:D};st&&(at.Outlines=st,at.PageMode=new X("UseOutlines"));let ct=s.add(at),Y=n.metadata??{},Z={Producer:ht("receipt-html-to-pdf"),Creator:ht(Y.creator??"receipt-html-to-pdf"),CreationDate:ke(Y.creationDate??new Date)};Y.title&&(Z.Title=ht(Y.title)),Y.author&&(Z.Author=ht(Y.author)),Y.subject&&(Z.Subject=ht(Y.subject)),Y.keywords&&(Z.Keywords=ht(Y.keywords));let rt=s.add(Z);return s.build(ct,rt)}function Dn(e,t){if(e.type==="text"){let s=(e.top+e.bottom)/2;return s>=t.start-.01&&s<t.end-.01}return Gn(e)>t.start+.01&&jn(e)<t.end-.01}var qt=class{constructor(t,n,s,o,r,i){this.cs=t,this.geo=n,this.fonts=s,this.images=o,this.gsName=r,this.gradients=i,this.pdfTop=n.height-n.top,this.docTop=0,this.curAlpha=1}setOrigin(t,n){this.pdfTop=t,this.docTop=n}X(t){return this.geo.left+t*.75}Y(t){return this.pdfTop-(t-this.docTop)*.75}setAlpha(t){Math.abs(t-this.curAlpha)<.001||(this.cs.setGState(this.gsName(t)),this.curAlpha=t)}radiusPt(t){return(t??[0,0,0,0]).map(n=>n*.75)}clipBox(t){let n=this.cs;t.radius?n.roundedRect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75,this.radiusPt(t.radius)):n.rect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75),n.clip()}render(t,n){let s=this.cs;for(let o of t)if(!(n&&!Dn(o,n)))if(o.type==="rect"){if(o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),o.radius?s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).fill():s.fillRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="line")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.moveTo(this.X(o.x1),this.Y(o.y1)).lineTo(this.X(o.x2),this.Y(o.y2)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="stroke-rrect")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="path"){if(!o.segs.length)continue;let[r,i,c,a,u,m]=o.matrix,f=.75,b=this.geo.left,g=this.pdfTop+this.docTop*f;s.save(),s.transform(f*r,-f*i,f*c,-f*a,f*u+b,-f*m+g),o.fill&&s.fillColor(o.fill.r,o.fill.g,o.fill.b),o.stroke&&(s.strokeColor(o.stroke.color.r,o.stroke.color.g,o.stroke.color.b),s.lineWidth(o.stroke.width),s.lineCap(o.stroke.cap),s.lineJoin(o.stroke.join),o.stroke.join===0&&s.miterLimit(o.stroke.miter),o.stroke.dash&&s.dash(o.stroke.dash,o.stroke.dashOffset));let d=o.fill?o.fill.a:1,p=o.stroke?o.stroke.color.a:1;(d!==1||p!==1)&&s.setGState(this.gsName(d,p)),s.path(o.segs),o.fill&&o.stroke?s.fillAndStroke(o.evenOdd):o.fill?s.fill(o.evenOdd):s.stroke(),s.restore(),this.curAlpha=1}else if(o.type==="gradient"){let r=this.gradients.get(o);if(!r||o.box.w<=0||o.box.h<=0)continue;s.save(),this.clipBox(o.clip),s.transform(.75,0,0,-.75,this.X(o.box.x),this.Y(o.box.y)),r.gs?s.setGState(r.gs):this.setAlpha(o.alpha),s.shading(r.sh),s.restore(),this.curAlpha=1}else if(o.type==="image"){let r=this.images.get(o.image.key);if(!r||o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.alpha),o.clip&&this.clipBox(o.clip),s.image(r.name,this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="text"){let r=this.fonts.get(o.font),i=Bn(o,r);s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),s.text(r.resourceName,o.size*.75,this.X(o.x),this.Y(o.y),i),s.restore(),this.curAlpha=1}else if(o.type==="group"){let[r,i,c,a]=o.matrix,u=this.X(o.origin.x),m=this.Y(o.origin.y),f=r,b=-i,g=-c,d=a,p=u-(f*u+g*m)+o.matrix[4]*.75,T=m-(b*u+d*m)-o.matrix[5]*.75;s.save(),s.transform(f,b,g,d,p,T),this.render(o.items,n),s.restore()}else o.type==="clip"&&(s.save(),this.clipBox(o.box),this.render(o.items,n),s.restore())}};function Bn(e,t){let n=[],s="";for(let o=0;o<e.glyphs.length;o++){let r=e.glyphs[o];s+=yt(t.cid(r.gid));let i=e.glyphs[o+1];if(!i)break;let c=r.x+r.advance,u=-(i.x-c)/e.size*1e3;Math.abs(u)>=.5&&(n.push(s,Math.round(u*10)/10),s="")}return s&&n.push(s),n}function jn(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y:e.type==="gradient"?e.clip.y:e.type==="path"?e.top:e.type==="line"?Math.min(e.y1,e.y2)-e.width/2:(e.type==="group"||e.type==="clip",e.top)}function Gn(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y+e.h:e.type==="gradient"?e.clip.y+e.clip.h:e.type==="path"?e.bottom:e.type==="line"?Math.max(e.y1,e.y2)+e.width/2:(e.type==="group"||e.type==="clip",e.bottom)}function Wn(){let e=globalThis.scheduler;return e&&typeof e.yield=="function"?e.yield():new Promise(t=>{if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)})}function Re(e=12){let t=()=>typeof performance<"u"?performance.now():Date.now(),n=t();return async()=>{t()-n<e||(await Wn(),n=t())}}var Vo="0.4.0",Nt=new Tt;async function _o(e){if(!e||!e.family||!e.src)throw new TypeError("registerFont: { family, src } are required");(await Nt.register(e)).parsed.variable&&console.warn(`[receipt-html-to-pdf] "${e.family}" is a variable font; only the default instance outlines are embedded. Use static TTF instances for other weights.`)}function Xo(){return Nt.fonts.map(e=>({family:e.displayFamily,weight:e.weight,style:e.style,glyphs:e.parsed.numGlyphs}))}async function Yo(e,t={}){if(typeof document>"u")throw new Error("htmlToPdf must run in a browser (needs DOM layout)");if(Nt.fonts.length===0)throw new Error("htmlToPdf: no fonts registered. Call registerFont() with at least one TrueType font first.");let n=t.onWarning??(()=>{}),s=t.onProgress??(()=>{}),o=Re(),r=Ne(t.page),i=(r.width-r.left-r.right)/.75;s({phase:"render"});let c=await Lt(e,{widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n}),a={registry:Nt,fontFallback:t.fontFallback??[],warn:n,textMeasure:t.textMeasure??"auto",pacer:o},u={widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n};try{s({phase:"walk"});let m=await Gt(c.root,a),f=t.header?await ve(t.header,u,a):null,b=t.footer?await ve(t.footer,u,a):null,g=await Ie(m,r,{compress:t.compress??!0,metadata:t.metadata,header:f,footer:b,links:t.links??!0,outline:t.outline??!1,pacer:o,progress:s,warn:n});return s({phase:"done"}),zn(g,t.output??"blob")}finally{c.destroy()}}async function ve(e,t,n){let s=async(i,c)=>{let a=e.replace(/\{\{\s*pageNumber\s*\}\}/g,String(i)).replace(/\{\{\s*totalPages\s*\}\}/g,String(c)),u=await Lt(a,t);try{return await Gt(u.root,n)}finally{u.destroy()}},o=await s(1,1),r=new Map([["1/1",o]]);return{heightPx:o.height,render:async(i,c)=>{let a=`${i}/${c}`,u=r.get(a);return u||(u=await s(i,c),r.set(a,u)),u}}}function zn(e,t){if(t==="uint8array")return e;if(t==="dataurl"){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,s+32768));return"data:application/pdf;base64,"+btoa(n)}return new Blob([e],{type:"application/pdf"})}function Zo(e,t){let n=e instanceof Blob?e:new Blob([e],{type:"application/pdf"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}export{Zo as downloadPdf,bt as expandPrintMediaCss,Yo as htmlToPdf,Xo as listFonts,_o as registerFont,Vo as version};
|
|
42
43
|
//# sourceMappingURL=receipt-html-to-pdf.min.js.map
|