palbase 0.65.0 → 0.68.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.
Files changed (111) hide show
  1. package/README.md +3 -2
  2. package/dist/ai/index.js +2 -2
  3. package/dist/ai-sdk/index.js +4 -0
  4. package/dist/backend/engine.js +2 -2
  5. package/dist/backend/env.js +1 -1
  6. package/dist/backend/index.js +8 -8
  7. package/dist/backend/stack.js +1 -1
  8. package/dist/backend/test.js +2 -2
  9. package/dist/chunks/{YP3QTS4L.js → 22GRHCVI.js} +1 -1
  10. package/dist/chunks/{CZGZTOK7.js → 2ZHSNWVZ.js} +2 -2
  11. package/dist/chunks/3OP3YJ63.js +22 -0
  12. package/dist/chunks/{5HMDOBEH.js → 4YV35XDP.js} +2 -2
  13. package/dist/chunks/5ZXXBM6L.js +18 -0
  14. package/dist/chunks/{KZZ3Y3DC.js → 622BI7EV.js} +1 -1
  15. package/dist/chunks/65QZXK2S.js +2 -0
  16. package/dist/chunks/{ZF3WKPVM.js → 7SGTDHXJ.js} +2 -2
  17. package/dist/chunks/D6EUPFUR.js +2 -0
  18. package/dist/chunks/EGWQ3EJE.js +21 -0
  19. package/dist/chunks/{ARRJICH3.js → EJAGO6ZV.js} +2 -2
  20. package/dist/chunks/{6GRY63N6.js → F4B6ELAN.js} +2 -2
  21. package/dist/chunks/IZWB7FGX.js +6 -0
  22. package/dist/chunks/{G2JBUBZO.js → J7WJF7F4.js} +2 -2
  23. package/dist/chunks/{DFX37NU3.js → LUUXXMXH.js} +1 -1
  24. package/dist/chunks/MVY4K43S.js +13 -0
  25. package/dist/chunks/{JHM7GTPD.js → OWLXCD3D.js} +1 -1
  26. package/dist/chunks/PP7MW4OT.js +2 -0
  27. package/dist/chunks/{DLMWZYLL.js → QFZ4GCJH.js} +2 -2
  28. package/dist/chunks/QQUIM4VK.js +2 -0
  29. package/dist/chunks/UJLFALKX.js +2 -0
  30. package/dist/chunks/{TEF7WS37.js → XJLAH42O.js} +1 -1
  31. package/dist/chunks/{XSOQNHZ5.js → XU4G5W72.js} +1 -1
  32. package/dist/chunks/YCDAV3WO.js +2 -0
  33. package/dist/cli.js +351 -364
  34. package/dist/cloud/index.js +2 -2
  35. package/dist/refuse/ai-sdk.js +2 -0
  36. package/dist/refuse/ai.js +1 -1
  37. package/dist/refuse/backend.js +1 -1
  38. package/dist/refuse/cloud.js +1 -1
  39. package/dist/refuse/server.js +1 -1
  40. package/dist/server/index.js +2 -2
  41. package/dist/server/testing.js +2 -2
  42. package/dist/web/index.js +2 -2
  43. package/dist/web/message.js +2 -2
  44. package/dist/web/palbe.js +2 -2
  45. package/dist/web/payments-ui.js +264 -0
  46. package/dist/web/paywall.js +2 -2
  47. package/dist/web/push-sw.js +1 -1
  48. package/dist/web/ssr.js +2 -2
  49. package/dist/web/vite.js +4 -3
  50. package/package.json +19 -2
  51. package/types/ai/src/ai.d.ts +55 -29
  52. package/types/ai/src/chats.d.ts +163 -171
  53. package/types/ai/src/index.d.ts +5 -5
  54. package/types/ai/src/pools.d.ts +17 -7
  55. package/types/ai/src/tools.d.ts +6 -64
  56. package/types/ai-sdk/src/index.d.ts +166 -0
  57. package/types/backend/src/decorators.d.ts +3 -9
  58. package/types/backend/src/idempotency.d.ts +18 -0
  59. package/types/backend/src/index.d.ts +1 -1
  60. package/types/backend/src/services.d.ts +2 -2
  61. package/types/backend/src/stack.d.ts +2 -4
  62. package/types/backend/src/strings-files.d.ts +5 -6
  63. package/types/backend/src/upload.d.ts +2 -1
  64. package/types/cloud/src/generated/project.d.ts +3 -2
  65. package/types/cloud/src/generated/studio.d.ts +3 -3
  66. package/types/internal/src/chat.d.ts +56 -2
  67. package/types/internal/src/event.d.ts +1 -1
  68. package/types/internal/src/modules/ai.d.ts +939 -1133
  69. package/types/internal/src/modules/analytics.d.ts +1 -1
  70. package/types/internal/src/modules/events.d.ts +5 -4
  71. package/types/internal/src/modules/{purchases.d.ts → iap.d.ts} +2183 -2438
  72. package/types/internal/src/modules/index.d.ts +2 -1
  73. package/types/internal/src/modules/journeys.d.ts +1 -1
  74. package/types/internal/src/modules/notify.d.ts +3 -3
  75. package/types/internal/src/modules/payments.d.ts +3286 -0
  76. package/types/internal/src/modules/stores.d.ts +7 -7
  77. package/types/internal/src/modules/workspaces.d.ts +22 -0
  78. package/types/server/src/{purchases.d.ts → iap.d.ts} +7 -7
  79. package/types/server/src/index.d.ts +2 -1
  80. package/types/server/src/payments.d.ts +65 -0
  81. package/types/server/src/server.d.ts +4 -1
  82. package/types/web/src/chat.d.ts +30 -4
  83. package/types/web/src/client.d.ts +13 -10
  84. package/types/web/src/{purchases.d.ts → iap.d.ts} +46 -56
  85. package/types/web/src/inapp.d.ts +5 -5
  86. package/types/web/src/index.d.ts +4 -2
  87. package/types/web/src/messaging.d.ts +1 -0
  88. package/types/web/src/notify.d.ts +2 -2
  89. package/types/web/src/payments-ui/index.d.ts +7 -0
  90. package/types/web/src/payments-ui/payment-sheet.d.ts +13 -0
  91. package/types/web/src/payments-ui/qr.d.ts +9 -0
  92. package/types/web/src/payments-ui/saved-cards-view.d.ts +7 -0
  93. package/types/web/src/payments-ui/spend-qr-view.d.ts +8 -0
  94. package/types/web/src/payments-ui/theme.d.ts +16 -0
  95. package/types/web/src/payments-ui/types.d.ts +149 -0
  96. package/types/web/src/payments-ui/wallet-topup-sheet.d.ts +7 -0
  97. package/types/web/src/payments.d.ts +281 -0
  98. package/types/web/src/paywall/placement.d.ts +6 -8
  99. package/types/web/src/screen/assets.d.ts +1 -1
  100. package/types/web/src/screen/resolve.d.ts +3 -3
  101. package/types/web/src/vite.d.ts +8 -0
  102. package/dist/chunks/2HJQSGOO.js +0 -13
  103. package/dist/chunks/3TXOVBZP.js +0 -22
  104. package/dist/chunks/4NHRUBEF.js +0 -2
  105. package/dist/chunks/63TUW6P7.js +0 -18
  106. package/dist/chunks/BYXX373R.js +0 -21
  107. package/dist/chunks/CTWUVLVE.js +0 -2
  108. package/dist/chunks/GFG7WVN2.js +0 -2
  109. package/dist/chunks/KU6B2OXP.js +0 -2
  110. package/dist/chunks/X6JMSZBD.js +0 -6
  111. package/dist/chunks/ZZRRJOEP.js +0 -2
@@ -0,0 +1,264 @@
1
+ /*! palbase 0.68.0 — Palbase SDK License (see LICENSE) */
2
+ import{b as ae,d as re,f as X}from"../chunks/QQUIM4VK.js";import"../chunks/65QZXK2S.js";import"../chunks/QFZ4GCJH.js";import"../chunks/XJLAH42O.js";import"../chunks/XU4G5W72.js";var le='-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';function ce(s){if(s==="dark"||s==="light")return s;try{let r=globalThis.matchMedia;return r?.("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{return"light"}}function j(s){return s?.locale??globalThis.navigator?.language??"en-US"}function K(s){try{return new Intl.NumberFormat("en",{style:"currency",currency:s}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function O(s,r,e="en-US"){let i=K(r),t=s/10**i;try{return new Intl.NumberFormat(e,{style:"currency",currency:r}).format(t)}catch{return`${t.toFixed(i)} ${r.toUpperCase()}`}}function G(s){switch((s??"").toLowerCase()){case"visa":return"Visa";case"mastercard":return"Mastercard";case"troy":return"Troy";case"amex":return"Amex";default:return s?s.toUpperCase():"Card"}}function Q(s,r){let i=ce(r?.theme)==="dark",t=r?.primaryColor??(i?"#3B82F6":"#111827"),a=r?.surfaceColor??(i?"#18181B":"#FFFFFF"),p=r?.textColor??(i?"#F4F4F5":"#111827"),f=r?.borderRadius??"12px",l=r?.fontFamily??le;s.style.setProperty("--pb-surface",a),s.style.setProperty("--pb-surface-alt",i?"#27272A":"#F4F4F5"),s.style.setProperty("--pb-text",p),s.style.setProperty("--pb-muted",i?"#A1A1AA":"#52525B"),s.style.setProperty("--pb-border",i?"#3F3F46":"#E4E4E7"),s.style.setProperty("--pb-primary",t),s.style.setProperty("--pb-on-primary","#FFFFFF"),s.style.setProperty("--pb-danger",i?"#F87171":"#DC2626"),s.style.setProperty("--pb-danger-bg",i?"rgba(220,38,38,0.16)":"#FEF2F2"),s.style.setProperty("--pb-success",i?"#34D399":"#059669"),s.style.setProperty("--pb-success-bg",i?"rgba(5,150,105,0.16)":"#ECFDF5"),s.style.setProperty("--pb-radius",f),s.style.setProperty("--pb-font",l)}var de=`
3
+ :host {
4
+ display: block;
5
+ font-family: var(--pb-font);
6
+ color: var(--pb-text);
7
+ box-sizing: border-box;
8
+ }
9
+ *, *::before, *::after { box-sizing: border-box; }
10
+ .pb-card {
11
+ background: var(--pb-surface);
12
+ color: var(--pb-text);
13
+ border: 1px solid var(--pb-border);
14
+ border-radius: var(--pb-radius);
15
+ padding: 20px;
16
+ font-family: var(--pb-font);
17
+ line-height: 1.4;
18
+ }
19
+ .pb-header {
20
+ display: flex;
21
+ align-items: baseline;
22
+ justify-content: space-between;
23
+ gap: 12px;
24
+ margin-bottom: 16px;
25
+ }
26
+ .pb-title {
27
+ font-size: 16px;
28
+ font-weight: 600;
29
+ margin: 0;
30
+ }
31
+ .pb-amount {
32
+ font-size: 20px;
33
+ font-weight: 700;
34
+ font-variant-numeric: tabular-nums;
35
+ }
36
+ .pb-sub {
37
+ font-size: 13px;
38
+ color: var(--pb-muted);
39
+ margin: 0 0 12px;
40
+ }
41
+ .pb-split {
42
+ background: var(--pb-surface-alt);
43
+ border-radius: calc(var(--pb-radius) * 0.7);
44
+ padding: 10px 12px;
45
+ font-size: 13px;
46
+ margin-bottom: 14px;
47
+ display: flex;
48
+ flex-direction: column;
49
+ gap: 4px;
50
+ }
51
+ .pb-split-row {
52
+ display: flex;
53
+ justify-content: space-between;
54
+ }
55
+ .pb-section-label {
56
+ font-size: 12px;
57
+ font-weight: 600;
58
+ text-transform: uppercase;
59
+ letter-spacing: 0.04em;
60
+ color: var(--pb-muted);
61
+ margin: 14px 0 8px;
62
+ }
63
+ .pb-list {
64
+ display: flex;
65
+ flex-direction: column;
66
+ gap: 8px;
67
+ }
68
+ .pb-option {
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: space-between;
72
+ gap: 10px;
73
+ width: 100%;
74
+ padding: 12px 14px;
75
+ border: 1.5px solid var(--pb-border);
76
+ border-radius: calc(var(--pb-radius) * 0.75);
77
+ background: transparent;
78
+ color: var(--pb-text);
79
+ font: inherit;
80
+ font-size: 14px;
81
+ cursor: pointer;
82
+ text-align: left;
83
+ transition: border-color 0.15s ease, background-color 0.15s ease;
84
+ }
85
+ .pb-option:hover {
86
+ border-color: var(--pb-primary);
87
+ }
88
+ .pb-option[aria-checked="true"], .pb-option[data-selected="true"] {
89
+ border-color: var(--pb-primary);
90
+ background: var(--pb-surface-alt);
91
+ }
92
+ .pb-option-main {
93
+ display: flex;
94
+ align-items: center;
95
+ gap: 10px;
96
+ min-width: 0;
97
+ }
98
+ .pb-badge {
99
+ display: inline-block;
100
+ font-size: 11px;
101
+ font-weight: 600;
102
+ padding: 2px 7px;
103
+ border-radius: 999px;
104
+ background: var(--pb-surface-alt);
105
+ border: 1px solid var(--pb-border);
106
+ color: var(--pb-muted);
107
+ }
108
+ .pb-input {
109
+ width: 100%;
110
+ padding: 10px 12px;
111
+ border: 1.5px solid var(--pb-border);
112
+ border-radius: calc(var(--pb-radius) * 0.65);
113
+ background: var(--pb-surface);
114
+ color: var(--pb-text);
115
+ font: inherit;
116
+ font-size: 14px;
117
+ }
118
+ .pb-input:focus {
119
+ outline: none;
120
+ border-color: var(--pb-primary);
121
+ }
122
+ .pb-checkbox {
123
+ display: flex;
124
+ align-items: center;
125
+ gap: 8px;
126
+ font-size: 13px;
127
+ color: var(--pb-muted);
128
+ margin-top: 12px;
129
+ cursor: pointer;
130
+ }
131
+ .pb-btn {
132
+ display: inline-flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ gap: 8px;
136
+ width: 100%;
137
+ padding: 12px 16px;
138
+ border: 0;
139
+ border-radius: calc(var(--pb-radius) * 0.75);
140
+ background: var(--pb-primary);
141
+ color: var(--pb-on-primary);
142
+ font: inherit;
143
+ font-size: 14px;
144
+ font-weight: 600;
145
+ cursor: pointer;
146
+ margin-top: 16px;
147
+ transition: opacity 0.15s ease;
148
+ }
149
+ .pb-btn:disabled {
150
+ opacity: 0.55;
151
+ cursor: not-allowed;
152
+ }
153
+ .pb-btn-ghost {
154
+ background: transparent;
155
+ color: var(--pb-muted);
156
+ border: 1px solid var(--pb-border);
157
+ margin-top: 8px;
158
+ }
159
+ .pb-btn-danger-sm {
160
+ background: transparent;
161
+ color: var(--pb-danger);
162
+ border: 1px solid var(--pb-border);
163
+ border-radius: 8px;
164
+ padding: 5px 10px;
165
+ font: inherit;
166
+ font-size: 12px;
167
+ font-weight: 600;
168
+ cursor: pointer;
169
+ }
170
+ .pb-alert {
171
+ padding: 11px 13px;
172
+ border-radius: calc(var(--pb-radius) * 0.65);
173
+ font-size: 13px;
174
+ margin-top: 12px;
175
+ }
176
+ .pb-alert-error {
177
+ background: var(--pb-danger-bg);
178
+ color: var(--pb-danger);
179
+ }
180
+ .pb-alert-success {
181
+ background: var(--pb-success-bg);
182
+ color: var(--pb-success);
183
+ }
184
+ .pb-chips {
185
+ display: grid;
186
+ grid-template-columns: repeat(2, minmax(0, 1fr));
187
+ gap: 8px;
188
+ margin-bottom: 12px;
189
+ }
190
+ .pb-chip {
191
+ padding: 10px 12px;
192
+ border: 1.5px solid var(--pb-border);
193
+ border-radius: calc(var(--pb-radius) * 0.65);
194
+ background: transparent;
195
+ color: var(--pb-text);
196
+ font: inherit;
197
+ font-size: 14px;
198
+ font-weight: 600;
199
+ cursor: pointer;
200
+ }
201
+ .pb-chip[data-selected="true"] {
202
+ border-color: var(--pb-primary);
203
+ background: var(--pb-surface-alt);
204
+ }
205
+ .pb-frame-wrap {
206
+ margin-top: 12px;
207
+ border: 1px solid var(--pb-border);
208
+ border-radius: calc(var(--pb-radius) * 0.7);
209
+ overflow: hidden;
210
+ background: #ffffff;
211
+ }
212
+ .pb-qr-wrap {
213
+ display: flex;
214
+ flex-direction: column;
215
+ align-items: center;
216
+ gap: 12px;
217
+ padding: 12px 0;
218
+ }
219
+ .pb-qr-box {
220
+ background: #ffffff;
221
+ padding: 14px;
222
+ border-radius: 12px;
223
+ border: 1px solid var(--pb-border);
224
+ display: inline-flex;
225
+ }
226
+ .pb-progress {
227
+ width: 100%;
228
+ height: 6px;
229
+ border-radius: 999px;
230
+ background: var(--pb-surface-alt);
231
+ overflow: hidden;
232
+ }
233
+ .pb-progress-bar {
234
+ height: 100%;
235
+ background: var(--pb-primary);
236
+ transition: width 0.25s linear;
237
+ }
238
+ .pb-meta {
239
+ font-size: 12px;
240
+ color: var(--pb-muted);
241
+ font-variant-numeric: tabular-nums;
242
+ }
243
+ .pb-inst-grid {
244
+ display: grid;
245
+ grid-template-columns: repeat(2, minmax(0, 1fr));
246
+ gap: 6px;
247
+ margin-top: 6px;
248
+ }
249
+ .pb-inst-btn {
250
+ padding: 8px 10px;
251
+ border: 1.5px solid var(--pb-border);
252
+ border-radius: 8px;
253
+ background: transparent;
254
+ color: var(--pb-text);
255
+ font: inherit;
256
+ font-size: 12px;
257
+ cursor: pointer;
258
+ text-align: left;
259
+ }
260
+ .pb-inst-btn[data-selected="true"] {
261
+ border-color: var(--pb-primary);
262
+ background: var(--pb-surface-alt);
263
+ }
264
+ `;function q(s,r,e){let i=s.ownerDocument,t=i.createElement("div");t.setAttribute(r,""),Q(t,e);let a=t.attachShadow({mode:"open"}),p=i.createElement("style");p.textContent=de;let f=i.createElement("div");return f.className="pb-card",a.append(p,f),s.replaceChildren(t),{host:t,shadow:a,root:f}}var pe={title:"Complete payment",payButton:"Pay now",processing:"Processing payment...",savedCardsHeading:"Saved payment methods",newCardOption:"Pay with a new card",masterpassOption:"Pay with Masterpass",saveCardCheckbox:"Save card for future payments",installmentsHeading:"Installments",singlePayment:"Single payment",otpHeading:"Enter verification code",otpPlaceholder:"6-digit code",otpSubmit:"Verify & pay",retryButton:"Try again",cancelButton:"Cancel",succeededTitle:"Payment succeeded",walletApplied:"Wallet applied",cardRemaining:"Card to pay"};function Y(s,r,e){let i=e.appearance,t={...pe,...e.labels},a=s.ownerDocument,p=new AbortController,{host:f,root:l}=q(s,"data-palbase-payment-sheet",i),m=!1,o="status"in e.intent&&"amount"in e.intent?e.intent:void 0,E=e.intent.client_secret,v,B=[],c={kind:"new_card"},n=!1,g=e.masterpassPhone??"",w,h=1,k={stage:"loading"},P,A=()=>j(i),z=()=>{m||(m=!0,p.abort(new DOMException("PaymentSheet destroyed","AbortError")),P?.(),P=void 0,f.remove())},S=d=>{i=d,Q(f,i),C()},F=async d=>{if(!o||!v?.capabilities.installments||e.allowInstallments===!1){w=void 0,h=1;return}let y=o.card_amount>0?o.card_amount:o.amount;if(!(y<=0))try{let x=await r.installments({amount:y,currency:o.currency,methodId:d.id,bin:d.bin,channel:o.channel_key,signal:p.signal});if(m)return;w=x,h=x.options[0]?.count??1,C()}catch{w=void 0,h=1}},U=async()=>{try{if(o||(o=await r.getIntent(e.intent.id,{clientSecret:E,signal:p.signal})),m)return;if(ae(o.status)){V(o);return}let[d,y]=await Promise.all([r.capabilities({currency:o.currency,channel:o.channel_key,signal:p.signal}).catch(()=>{}),e.showSavedCards!==!1?r.methods.list({signal:p.signal}).catch(()=>[]):Promise.resolve([])]);if(m)return;if(v=d,B=y,B.length>0?(c={kind:"saved",methodId:B[0].id},F(B[0])):c={kind:"new_card"},o.next_action&&o.next_action.type!=="none"){T(o);return}k={stage:"select"},C()}catch(d){if(m)return;k={stage:"failed",message:d instanceof Error?d.message:"Unable to load payment details.",retryable:!0},C(),e.onError?.(d)}},V=d=>{o=d,d.status==="succeeded"||d.status==="requires_capture"?(k={stage:"succeeded",intent:d},C(),e.onSuccess?.(d)):(k={stage:"failed",intent:d,message:re(d.decline_code),retryable:d.retryable!==!1},C(),e.onFailure?.(d))},T=async d=>{k={stage:"processing"},C();try{let y=await r.present(d,{clientSecret:E,timeoutMs:e.timeoutMs,signal:p.signal,onEmbed:x=>(k={stage:"embed",action:x},C(),()=>{P?.(),P=void 0}),onOtp:x=>new Promise(L=>{k={stage:"otp",ctx:x,resolve:L},C()})});if(m)return;V(y)}catch(y){if(m)return;if(y?.code==="payment_canceled"){k={stage:"select"},C();return}k={stage:"failed",intent:d,message:y instanceof Error?y.message:"Payment could not be completed.",retryable:!0},C(),e.onError?.(y)}},M=async()=>{if(o){k={stage:"processing"},C();try{let d=await r.confirm(o.id,{clientSecret:E,buyer:e.buyer,...c.kind==="saved"?{methodId:c.methodId,...h>1?{installments:{count:h}}:{}}:c.kind==="masterpass"?{useMasterpass:!0,phone:g.trim()||void 0,saveMethod:n}:{saveMethod:n,...v?.capabilities.installments&&e.allowInstallments!==!1?{installments:{enabled:!0}}:{}},signal:p.signal});if(m)return;o=d,await T(d)}catch(d){if(m)return;k={stage:"failed",intent:o,message:d instanceof Error?d.message:"Unable to start payment.",retryable:!0},C(),e.onError?.(d)}}},C=()=>{if(m)return;P?.(),P=void 0,l.replaceChildren();let d=a.createElement("div");d.className="pb-header";let y=a.createElement("h3");if(y.className="pb-title",y.textContent=o?.description||t.title,d.append(y),o){let u=a.createElement("div");u.className="pb-amount",u.textContent=O(o.amount,o.currency,A()),d.append(u)}if(l.append(d),o&&o.wallet_amount>0&&o.card_amount>0){let u=a.createElement("div");u.className="pb-split";let b=a.createElement("div");b.className="pb-split-row";let N=a.createElement("span");N.textContent=t.walletApplied;let I=a.createElement("strong");I.textContent=`-${O(o.wallet_amount,o.currency,A())}`,b.append(N,I);let _=a.createElement("div");_.className="pb-split-row";let $=a.createElement("span");$.textContent=t.cardRemaining;let H=a.createElement("strong");H.textContent=O(o.card_amount,o.currency,A()),_.append($,H),u.append(b,_),l.append(u)}if(k.stage==="loading"||k.stage==="processing"){let u=a.createElement("p");u.className="pb-sub",u.setAttribute("role","status"),u.textContent=t.processing,l.append(u);return}if(k.stage==="succeeded"){let u=a.createElement("div");u.className="pb-alert pb-alert-success",u.setAttribute("role","status"),u.textContent=t.succeededTitle,l.append(u);return}if(k.stage==="failed"){let u=a.createElement("div");if(u.className="pb-alert pb-alert-error",u.setAttribute("role","alert"),u.textContent=k.message,l.append(u),k.retryable){let b=a.createElement("button");b.type="button",b.className="pb-btn",b.textContent=t.retryButton,b.addEventListener("click",()=>{k={stage:"select"},C()}),l.append(b)}if(e.onCancel){let b=a.createElement("button");b.type="button",b.className="pb-btn pb-btn-ghost",b.textContent=t.cancelButton,b.addEventListener("click",()=>e.onCancel?.()),l.append(b)}return}if(k.stage==="embed"){let u=a.createElement("div");if(u.className="pb-frame-wrap",l.append(u),P=X(u,k.action),e.onCancel){let b=a.createElement("button");b.type="button",b.className="pb-btn pb-btn-ghost",b.textContent=t.cancelButton,b.addEventListener("click",()=>{p.abort(new DOMException("Payment canceled","AbortError")),e.onCancel?.()}),l.append(b)}return}if(k.stage==="otp"){let{ctx:u,resolve:b}=k,N=a.createElement("p");if(N.className="pb-section-label",N.textContent=t.otpHeading,l.append(N),u.maskedPhone){let D=a.createElement("p");D.className="pb-sub",D.textContent=`Code sent to ${u.maskedPhone}`,l.append(D)}let I=a.createElement("form"),_=a.createElement("input");_.type="text",_.inputMode="numeric",_.autocomplete="one-time-code",_.className="pb-input",_.placeholder=t.otpPlaceholder,_.maxLength=12,_.setAttribute("data-pb-otp-input",""),I.append(_);let $=a.createElement("button");$.type="submit",$.className="pb-btn",$.textContent=t.otpSubmit,I.append($);let H=a.createElement("button");H.type="button",H.className="pb-btn pb-btn-ghost",H.textContent=t.cancelButton,H.addEventListener("click",()=>b(null)),I.append(H),I.addEventListener("submit",D=>{D.preventDefault();let ne=_.value.trim();ne&&b({otp:ne,saveMethod:n})}),l.append(I);return}let x=a.createElement("div");if(x.className="pb-list",x.setAttribute("role","radiogroup"),x.setAttribute("aria-label",t.savedCardsHeading),B.length>0){let u=a.createElement("div");u.className="pb-section-label",u.textContent=t.savedCardsHeading,l.append(u);for(let b of B){let N=a.createElement("button");N.type="button",N.className="pb-option",N.setAttribute("role","radio");let I=c.kind==="saved"&&c.methodId===b.id;N.setAttribute("aria-checked",String(I)),N.setAttribute("data-pb-method",b.id);let _=a.createElement("span");_.className="pb-option-main";let $=a.createElement("span");if($.textContent=`${G(b.brand)} \u2022\u2022\u2022\u2022 ${b.last4??"****"}`,_.append($),b.exp_month&&b.exp_year){let D=a.createElement("span");D.className="pb-meta",D.textContent=`${String(b.exp_month).padStart(2,"0")}/${String(b.exp_year).slice(-2)}`,_.append(D)}let H=a.createElement("span");H.className="pb-badge",H.textContent=b.card_family||b.vault,N.append(_,H),N.addEventListener("click",()=>{c={kind:"saved",methodId:b.id},w=void 0,h=1,C(),F(b)}),x.append(N)}}let L=a.createElement("button");if(L.type="button",L.className="pb-option",L.setAttribute("role","radio"),L.setAttribute("aria-checked",String(c.kind==="new_card")),L.setAttribute("data-pb-option","new_card"),L.textContent=t.newCardOption,L.addEventListener("click",()=>{c={kind:"new_card"},w=void 0,h=1,C()}),x.append(L),v?.capabilities.masterpass&&e.allowMasterpass!==!1){let u=a.createElement("button");u.type="button",u.className="pb-option",u.setAttribute("role","radio"),u.setAttribute("aria-checked",String(c.kind==="masterpass")),u.setAttribute("data-pb-option","masterpass");let b=a.createElement("span");b.textContent=t.masterpassOption;let N=a.createElement("span");N.className="pb-badge",N.textContent="OTP",u.append(b,N),u.addEventListener("click",()=>{c={kind:"masterpass"},w=void 0,h=1,C()}),x.append(u)}if(l.append(x),c.kind==="masterpass"){let u=a.createElement("div");u.className="pb-section-label",u.textContent="Mobile phone";let b=a.createElement("input");b.type="tel",b.className="pb-input",b.placeholder="+905XXXXXXXXX",b.value=g,b.setAttribute("data-pb-masterpass-phone",""),b.addEventListener("input",()=>{g=b.value}),l.append(u,b)}if(c.kind==="saved"&&w&&w.options.length>1&&o){let u=a.createElement("div");u.className="pb-section-label",u.textContent=t.installmentsHeading;let b=a.createElement("div");b.className="pb-inst-grid";for(let N of w.options){let I=a.createElement("button");I.type="button",I.className="pb-inst-btn",I.setAttribute("data-selected",String(h===N.count)),I.setAttribute("data-pb-installment",String(N.count));let _=a.createElement("div");_.style.fontWeight="600",_.textContent=N.count===1?t.singlePayment:`${N.count} \xD7 ${O(N.installment_amount,o.currency,A())}`;let $=a.createElement("div");$.className="pb-meta",$.textContent=O(N.total_amount,o.currency,A()),I.append(_,$),I.addEventListener("click",()=>{h=N.count,C()}),b.append(I)}l.append(u,b)}if(c.kind!=="saved"&&e.allowSaveCard!==!1&&(v?.capabilities.saved_cards??!0)){let u=a.createElement("label");u.className="pb-checkbox";let b=a.createElement("input");b.type="checkbox",b.checked=n,b.addEventListener("change",()=>{n=b.checked});let N=a.createElement("span");N.textContent=t.saveCardCheckbox,u.append(b,N),l.append(u)}let W=o?o.card_amount>0?o.card_amount:o.amount:0,R=a.createElement("button");if(R.type="button",R.className="pb-btn",R.setAttribute("data-pb-pay-btn",""),R.textContent=o&&W>0?`${t.payButton} \xB7 ${O(W,o.currency,A())}`:t.payButton,R.addEventListener("click",()=>{M()}),l.append(R),e.onCancel){let u=a.createElement("button");u.type="button",u.className="pb-btn pb-btn-ghost",u.textContent=t.cancelButton,u.addEventListener("click",()=>e.onCancel?.()),l.append(u)}};return C(),U(),{destroy:z,setAppearance:S}}function ue(s,r){let e=globalThis.document;return e?.body?new Promise(i=>{let t=e.createElement("div");t.setAttribute("data-palbase-payment-modal",""),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.style.position="fixed",t.style.inset="0",t.style.zIndex="2147483000",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="16px",t.style.background="rgba(0, 0, 0, 0.55)";let a=e.createElement("div");a.style.width="100%",a.style.maxWidth="440px",a.style.maxHeight="92vh",a.style.overflowY="auto",t.append(a),e.body.append(t);let p=!1,f,l=o=>{p||(p=!0,e.removeEventListener("keydown",m),f?.destroy(),t.remove(),i(o))},m=o=>{o.key==="Escape"&&l(null)};e.addEventListener("keydown",m),t.addEventListener("click",o=>{o.target===t&&l(null)}),f=Y(a,s,{...r,onSuccess:o=>l(o),onFailure:o=>l(o),onCancel:()=>l(null)})}):Promise.reject(new Error("openPaymentSheet requires a browser document"))}function me(s,r,e){let i=e.appearance,t=s.ownerDocument,a=new AbortController,{host:p,root:f}=q(s,"data-palbase-wallet-topup",i),l=K(e.currency),m=10**l,o=e.presets??[100*m,250*m,500*m,1e3*m],E=e.minAmount??1*m,v=!1,B=o[0]??E,c=String(B/m),n=!1,g,w,h,k,P=()=>j(i),A=r.wallet.onChange(V=>{v||(w=V?.find(T=>T.wallet_key===e.walletKey),h||U())}),z=()=>{v||(v=!0,a.abort(new DOMException("WalletTopUpSheet destroyed","AbortError")),A(),h?.destroy(),h=void 0,p.remove())},S=V=>{i=V,Q(p,i),h?.setAppearance(V),h||U()},F=async()=>{if(g=void 0,!Number.isFinite(B)||B<E){g=`Minimum top-up amount is ${O(E,e.currency,P())}.`,U();return}if(e.maxAmount!==void 0&&B>e.maxAmount){g=`Maximum top-up amount is ${O(e.maxAmount,e.currency,P())}.`,U();return}n=!0,U();try{let V=await r.wallet.topUp({walletKey:e.walletKey,amount:Math.round(B),channel:e.channel,returnUrl:e.returnUrl,cancelUrl:e.cancelUrl,signal:a.signal});if(v)return;n=!1,f.replaceChildren(),k=t.createElement("div"),f.append(k),h=Y(k,r,{intent:V,appearance:i,onSuccess:T=>e.onSuccess?.(T),onFailure:T=>e.onFailure?.(T),onCancel:()=>{h?.destroy(),h=void 0,k=void 0,U(),e.onCancel?.()},onError:T=>e.onError?.(T)})}catch(V){if(v)return;n=!1,g=V instanceof Error?V.message:"Unable to start wallet top-up.",U(),e.onError?.(V)}},U=()=>{if(v)return;f.replaceChildren();let V=t.createElement("div");V.className="pb-header";let T=t.createElement("h3");if(T.className="pb-title",T.textContent="Top up wallet",V.append(T),w){let x=t.createElement("span");x.className="pb-meta",x.setAttribute("data-pb-wallet-balance",""),x.textContent=`Balance: ${O(w.available,w.currency,P())}`,V.append(x)}f.append(V);let M=t.createElement("div");M.className="pb-chips";for(let x of o){let L=t.createElement("button");L.type="button",L.className="pb-chip",L.setAttribute("data-selected",String(B===x)),L.setAttribute("data-pb-preset",String(x)),L.textContent=O(x,e.currency,P()),L.addEventListener("click",()=>{B=x,c=String(x/m),g=void 0,U()}),M.append(L)}f.append(M);let C=t.createElement("div");C.className="pb-section-label",C.textContent=`Custom amount (${e.currency.toUpperCase()})`;let d=t.createElement("input");if(d.type="number",d.inputMode="decimal",d.step=l>0?String(1/m):"1",d.className="pb-input",d.value=c,d.setAttribute("data-pb-custom-amount",""),d.addEventListener("input",()=>{c=d.value;let x=Number.parseFloat(d.value);B=Number.isFinite(x)?Math.round(x*m):0}),f.append(C,d),g){let x=t.createElement("div");x.className="pb-alert pb-alert-error",x.setAttribute("role","alert"),x.textContent=g,f.append(x)}let y=t.createElement("button");if(y.type="button",y.className="pb-btn",y.disabled=n,y.setAttribute("data-pb-topup-btn",""),y.textContent=n?"Starting top-up...":`Continue \xB7 ${O(Math.max(0,B),e.currency,P())}`,y.addEventListener("click",()=>{F()}),f.append(y),e.onCancel){let x=t.createElement("button");x.type="button",x.className="pb-btn pb-btn-ghost",x.textContent="Cancel",x.addEventListener("click",()=>e.onCancel?.()),f.append(x)}};return U(),{destroy:z,setAppearance:S}}function be(s,r,e={}){let i=e.appearance,t=s.ownerDocument,a=new AbortController,{host:p,root:f}=q(s,"data-palbase-saved-cards",i),l=!1,m=!0,o=!1,E=[],v,B,c,n=()=>{l||(l=!0,a.abort(new DOMException("SavedCardsView destroyed","AbortError")),c?.(),c=void 0,p.remove())},g=A=>{i=A,Q(p,i),P()},w=async()=>{m=!0,v=void 0,P();try{if(E=await r.methods.list({signal:a.signal}),l)return;m=!1,e.onChanged?.(E),P()}catch(A){if(l)return;m=!1,v=A instanceof Error?A.message:"Unable to load saved cards.",P(),e.onError?.(A)}},h=async A=>{o=!0,v=void 0,P();try{if(await r.methods.remove(A,{signal:a.signal}),l)return;E=E.filter(z=>z.id!==A),o=!1,e.onChanged?.(E),P()}catch(z){if(l)return;o=!1,v=z instanceof Error?z.message:"Unable to remove card.",P(),e.onError?.(z)}},k=async()=>{o=!0,v=void 0,P();try{let A=await r.methods.add({channel:e.channel,vault:e.vault,returnUrl:e.returnUrl,cancelUrl:e.cancelUrl,signal:a.signal});if(l)return;if(o=!1,A.type==="redirect"&&A.url){globalThis.location?.assign(A.url);return}if(A.type==="embed"){B=A,P();return}await w()}catch(A){if(l)return;o=!1,v=A instanceof Error?A.message:"Unable to start card setup.",P(),e.onError?.(A)}},P=()=>{if(l)return;c?.(),c=void 0,f.replaceChildren();let A=t.createElement("div");A.className="pb-header";let z=t.createElement("h3");if(z.className="pb-title",z.textContent="Saved cards",A.append(z),f.append(A),B){let S=t.createElement("div");S.className="pb-frame-wrap",f.append(S),c=X(S,B);let F=t.createElement("button");F.type="button",F.className="pb-btn pb-btn-ghost",F.textContent="Done",F.addEventListener("click",()=>{B=void 0,w()}),f.append(F);return}if(m){let S=t.createElement("p");S.className="pb-sub",S.textContent="Loading saved cards...",f.append(S);return}if(E.length===0){let S=t.createElement("p");S.className="pb-sub",S.setAttribute("data-pb-empty",""),S.textContent="No saved payment methods yet.",f.append(S)}else{let S=t.createElement("div");S.className="pb-list";for(let F of E){let U=t.createElement("div");U.className="pb-option",U.setAttribute("data-pb-saved-card",F.id),U.style.cursor=e.onSelect?"pointer":"default";let V=t.createElement("span");V.className="pb-option-main";let T=t.createElement("span");if(T.textContent=`${G(F.brand)} \u2022\u2022\u2022\u2022 ${F.last4??"****"}`,V.append(T),F.exp_month&&F.exp_year){let y=t.createElement("span");y.className="pb-meta",y.textContent=`${String(F.exp_month).padStart(2,"0")}/${String(F.exp_year).slice(-2)}`,V.append(y)}let M=t.createElement("span");M.className="pb-badge",M.textContent=F.card_family||F.vault,V.append(M);let C=t.createElement("span"),d=t.createElement("button");d.type="button",d.className="pb-btn-danger-sm",d.disabled=o,d.setAttribute("data-pb-remove-card",F.id),d.textContent="Remove",d.addEventListener("click",y=>{y.stopPropagation(),h(F.id)}),C.append(d),U.append(V,C),e.onSelect&&U.addEventListener("click",()=>e.onSelect?.(F)),S.append(U)}f.append(S)}if(v){let S=t.createElement("div");S.className="pb-alert pb-alert-error",S.setAttribute("role","alert"),S.textContent=v,f.append(S)}if(e.allowAdd!==!1){let S=t.createElement("button");S.type="button",S.className="pb-btn",S.disabled=o,S.setAttribute("data-pb-add-card",""),S.textContent="Add new card",S.addEventListener("click",()=>{k()}),f.append(S)}};return P(),w(),{destroy:n,setAppearance:g}}var fe=[{version:1,size:21,dataCodewords:16,ecPerBlock:10,blocks:1,align:[]},{version:2,size:25,dataCodewords:28,ecPerBlock:16,blocks:1,align:[6,18]},{version:3,size:29,dataCodewords:44,ecPerBlock:26,blocks:1,align:[6,22]},{version:4,size:33,dataCodewords:64,ecPerBlock:18,blocks:2,align:[6,26]},{version:5,size:37,dataCodewords:86,ecPerBlock:24,blocks:2,align:[6,30]},{version:6,size:41,dataCodewords:108,ecPerBlock:16,blocks:4,align:[6,34]}],J=new Uint8Array(512),ee=new Uint8Array(256);{let s=1;for(let r=0;r<255;r++)J[r]=s,J[r+255]=s,ee[s]=r,s<<=1,s&256&&(s^=285)}function oe(s,r){return s===0||r===0?0:J[ee[s]+ee[r]]}function ge(s){let r=new Uint8Array([1]);for(let e=0;e<s;e++){let i=new Uint8Array(r.length+1),t=J[e];for(let a=0;a<r.length;a++)i[a]^=r[a],i[a+1]^=oe(r[a],t);r=i}return r}function ye(s,r){let e=ge(r),i=new Uint8Array(r);for(let t=0;t<s.length;t++){let a=s[t]^i[0];if(i.copyWithin(0,1),i[r-1]=0,a!==0)for(let p=0;p<r;p++)i[p]^=oe(e[p+1],a)}return i}function he(s){let r=Math.ceil((12+8*s)/8);for(let e of fe)if(r<=e.dataCodewords)return e;throw new RangeError(`QR payload too long (${s} bytes; max 106 bytes)`)}function xe(s,r){let e=[],i=(c,n)=>{for(let g=n-1;g>=0;g--)e.push(c>>>g&1)};i(4,4),i(s.length,8);for(let c of s)i(c,8);let t=r.dataCodewords*8,a=Math.min(4,t-e.length);for(let c=0;c<a;c++)e.push(0);for(;e.length%8!==0;)e.push(0);let p=new Uint8Array(r.dataCodewords),f=e.length/8;for(let c=0;c<f;c++){let n=0;for(let g=0;g<8;g++)n=n<<1|e[c*8+g];p[c]=n}let l=[236,17];for(let c=f;c<r.dataCodewords;c++)p[c]=l[c-f&1];let m=r.dataCodewords/r.blocks,o=[],E=[];for(let c=0;c<r.blocks;c++){let n=p.subarray(c*m,(c+1)*m);o.push(n),E.push(ye(n,r.ecPerBlock))}let v=new Uint8Array(r.dataCodewords+r.blocks*r.ecPerBlock),B=0;for(let c=0;c<m;c++)for(let n=0;n<r.blocks;n++)v[B++]=o[n][c];for(let c=0;c<r.ecPerBlock;c++)for(let n=0;n<r.blocks;n++)v[B++]=E[n][c];return v}function ve(s){let r=0|s&7,e=r<<10,i=1335;for(let t=14;t>=10;t--)e>>>t&1&&(e^=i<<t-10);return(r<<10|e)^21522}function se(s,r,e){switch(s){case 0:return(r+e)%2===0;case 1:return r%2===0;case 2:return e%3===0;case 3:return(r+e)%3===0;case 4:return(Math.floor(r/2)+Math.floor(e/3))%2===0;case 5:return r*e%2+r*e%3===0;case 6:return(r*e%2+r*e%3)%2===0;default:return((r+e)%2+r*e%3)%2===0}}function ie(s){let r=new TextEncoder().encode(s),e=he(r.length),i=xe(r,e),t=e.size,a=Array.from({length:t},()=>Array(t).fill(!1)),p=Array.from({length:t},()=>Array(t).fill(!1)),f=(n,g,w)=>{n<0||g<0||n>=t||g>=t||(a[n][g]=w,p[n][g]=!0)},l=(n,g)=>{for(let w=-1;w<=7;w++)for(let h=-1;h<=7;h++){let P=w>=0&&w<=6&&h>=0&&h<=6&&(w===0||w===6||h===0||h===6||w>=2&&w<=4&&h>=2&&h<=4);f(n+w,g+h,P)}};l(0,0),l(0,t-7),l(t-7,0);for(let n=8;n<t-8;n++)f(6,n,n%2===0),f(n,6,n%2===0);for(let n of e.align)for(let g of e.align)if(!p[n][g])for(let w=-2;w<=2;w++)for(let h=-2;h<=2;h++){let k=Math.max(Math.abs(w),Math.abs(h))!==1;f(n+w,g+h,k)}for(let n=0;n<=8;n++)p[8][n]||(p[8][n]=!0),p[n][8]||(p[n][8]=!0);for(let n=t-8;n<t;n++)p[8][n]=!0,p[n][8]=!0;f(t-8,8,!0);let m=0,o=i.length*8,E=!0;for(let n=t-1;n>0;n-=2){n===6&&n--;for(let g=0;g<t;g++){let w=E?t-1-g:g;for(let h=0;h<2;h++){let k=n-h;if(p[w][k])continue;let P=!1;m<o&&(P=(i[m>>>3]>>>7-(m&7)&1)===1,m++),a[w][k]=P}}E=!E}let v=0,B=Number.POSITIVE_INFINITY;for(let n=0;n<8;n++){let g=we(a,p,n);g<B&&(B=g,v=n)}for(let n=0;n<t;n++)for(let g=0;g<t;g++)!p[n][g]&&se(v,n,g)&&(a[n][g]=!a[n][g]);let c=ve(v);for(let n=0;n<=5;n++)f(8,n,(c>>>14-n&1)===1);f(8,7,(c>>>8&1)===1),f(8,8,(c>>>7&1)===1),f(7,8,(c>>>6&1)===1);for(let n=9;n<=14;n++)f(14-n,8,(c>>>14-n&1)===1);for(let n=0;n<=7;n++)f(t-1-n,8,(c>>>14-n&1)===1);for(let n=8;n<=14;n++)f(8,t-15+n,(c>>>14-n&1)===1);return a}function we(s,r,e){let i=s.length,t=0,a=0,p=(l,m)=>r[l][m]?s[l][m]:se(e,l,m)?!s[l][m]:s[l][m];for(let l=0;l<i;l++){let m=p(l,0),o=1;m&&t++;for(let E=1;E<i;E++){let v=p(l,E);v&&t++,v===m?o++:(o>=5&&(a+=3+(o-5)),m=v,o=1)}o>=5&&(a+=3+(o-5))}for(let l=0;l<i;l++){let m=p(0,l),o=1;for(let E=1;E<i;E++){let v=p(E,l);v===m?o++:(o>=5&&(a+=3+(o-5)),m=v,o=1)}o>=5&&(a+=3+(o-5))}let f=Math.abs(t*100/(i*i)-50);return a+=Math.floor(f/5)*10,a}function te(s,r={}){let e=ie(s),i=e.length,t=r.margin??4,a=i+t*2,p=r.size??200,f=r.fg??"#111827",l=r.bg??"#FFFFFF",m=[];for(let o=0;o<i;o++)for(let E=0;E<i;E++)e[o][E]&&m.push(`M${E+t},${o+t}h1v1h-1z`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${a}" width="${p}" height="${p}" role="img" aria-label="Payment QR code" shape-rendering="crispEdges"><rect width="${a}" height="${a}" fill="${l}"/><path d="${m.join("")}" fill="${f}"/></svg>`}function Ee(s,r,e){let i=e.appearance,t=e.ttlSeconds??60,a=e.autoRefresh!==!1,p=s.ownerDocument,f=new AbortController,{host:l,root:m}=q(s,"data-palbase-spend-qr",i),o=!1,E=!0,v,B=0,c=0,n,g,w,h=!1,k=()=>j(i),P=r.wallet.onChange(M=>{if(o)return;let C=M?.find(d=>d.wallet_key===e.walletKey);C&&(n=C,e.onBalance?.(C),T())}),A=()=>{w!==void 0&&(clearInterval(w),w=void 0)},z=()=>{o||(o=!0,A(),P(),f.abort(new DOMException("SpendQRView destroyed","AbortError")),l.remove())},S=M=>{i=M,Q(l,i),T()},F=async()=>{if(!(o||h)){h=!0,E=!v,g=void 0,T();try{let M=await r.wallet.createSpendToken({walletKey:e.walletKey,maxAmount:e.maxAmount,ttlSeconds:t,signal:f.signal});if(o)return;v=M,B=Date.now();let C=Date.parse(M.expires_at);c=Number.isFinite(C)?C:B+t*1e3,E=!1,h=!1,e.onToken?.(M),U(),T()}catch(M){if(o)return;E=!1,h=!1,g=M instanceof Error?M.message:"Unable to generate spend QR code.",T(),e.onError?.(M)}}},U=()=>{A(),w=setInterval(()=>{if(o||!v)return;let M=c-Date.now();if(a&&M<=5e3&&!h){F();return}M<=0&&A(),V()},500)},V=()=>{let M=m.querySelector("[data-pb-qr-bar]"),C=m.querySelector("[data-pb-qr-timer]");if(!M||!C||!v)return;let d=Math.max(1e3,c-B),y=Math.max(0,c-Date.now()),x=Math.max(0,Math.min(100,y/d*100));M.style.width=`${x.toFixed(1)}%`;let L=Math.ceil(y/1e3);C.textContent=L>0?`Expires in ${L}s \xB7 single-use`:"Code expired"},T=()=>{if(o)return;m.replaceChildren();let M=p.createElement("div");M.className="pb-header";let C=p.createElement("h3");if(C.className="pb-title",C.textContent="Pay with QR",M.append(C),n){let y=p.createElement("span");y.className="pb-meta",y.setAttribute("data-pb-qr-balance",""),y.textContent=O(n.available,n.currency,k()),M.append(y)}if(m.append(M),E){let y=p.createElement("p");y.className="pb-sub",y.textContent="Generating single-use QR code...",m.append(y);return}if(v){let y=p.createElement("div");y.className="pb-qr-wrap";let x=p.createElement("div");x.className="pb-qr-box",x.setAttribute("data-pb-qr-svg","");let L=te(v.spend_token,{size:200}),Z=p.defaultView?.DOMParser??globalThis.DOMParser;if(Z){let N=new Z().parseFromString(L,"image/svg+xml").documentElement;x.append(p.importNode(N,!0))}else x.textContent=v.spend_token;let W=p.createElement("div");W.className="pb-progress";let R=p.createElement("div");R.className="pb-progress-bar",R.setAttribute("data-pb-qr-bar",""),W.append(R);let u=p.createElement("div");u.className="pb-meta",u.setAttribute("data-pb-qr-timer",""),y.append(x,W,u),m.append(y),V()}if(g){let y=p.createElement("div");y.className="pb-alert pb-alert-error",y.setAttribute("role","alert"),y.textContent=g,m.append(y)}let d=p.createElement("button");d.type="button",d.className="pb-btn pb-btn-ghost",d.disabled=h,d.setAttribute("data-pb-qr-refresh",""),d.textContent=h?"Refreshing...":"Generate new QR",d.addEventListener("click",()=>{F()}),m.append(d)};return T(),F(),{destroy:z,setAppearance:S}}export{K as currencyMinorDigits,ie as encodeQrMatrix,O as formatMinorAmount,Y as mountPaymentSheet,be as mountSavedCardsView,Ee as mountSpendQRView,me as mountWalletTopUpSheet,ue as openPaymentSheet,te as renderQrSvg};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.65.0 — Palbase SDK License (see LICENSE) */
2
- import{a as f,b as d,c as m,d as u,e as A,f as c,g as R}from"../chunks/4NHRUBEF.js";import{a as e,b as a,c as t,d as l,e as r,f as o,g as p,i as y,k as s,l as P,n,o as i,s as w}from"../chunks/YP3QTS4L.js";import"../chunks/DLMWZYLL.js";import"../chunks/TEF7WS37.js";import"../chunks/XSOQNHZ5.js";export{y as PAYWALL_COMPONENTS,o as PAYWALL_ICONS,p as PAYWALL_SCHEMA,c as Paywall,a as assetId,f as attributesHeader,s as countdownValues,R as defaultPaywall,e as fontFamily,u as formatPeriod,m as formatPrice,r as htmlDocument,A as packageValues,P as packagesOf,d as parseDuration,t as prepareAssets,w as renderPaywall,n as resolvePaywall,i as resolvePaywallWithPaths,l as unzip};
1
+ /*! palbase 0.68.0 — Palbase SDK License (see LICENSE) */
2
+ import{a as f,b as d,c as m,d as u,e as A,f as c,g as R}from"../chunks/UJLFALKX.js";import{a as e,b as a,c as t,d as l,e as r,f as o,g as p,i as y,k as s,l as P,n,o as i,s as w}from"../chunks/22GRHCVI.js";import"../chunks/QFZ4GCJH.js";import"../chunks/XJLAH42O.js";import"../chunks/XU4G5W72.js";export{y as PAYWALL_COMPONENTS,o as PAYWALL_ICONS,p as PAYWALL_SCHEMA,c as Paywall,a as assetId,f as attributesHeader,s as countdownValues,R as defaultPaywall,e as fontFamily,u as formatPeriod,m as formatPrice,r as htmlDocument,A as packageValues,P as packagesOf,d as parseDuration,t as prepareAssets,w as renderPaywall,n as resolvePaywall,i as resolvePaywallWithPaths,l as unzip};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.65.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.68.0 — Palbase SDK License (see LICENSE) */
2
2
  "use strict";(()=>{function g(t,l){if(t)try{let o=new URL(t,l);if(o.protocol==="https:"||o.protocol==="http:"&&(o.hostname==="localhost"||o.hostname==="127.0.0.1"))return o.href}catch{}}function w(t){let l=new URL(t.location.href).searchParams,o=l.get("url")??"",p=l.get("key")??"",c=(e,n)=>!e||!o?Promise.resolve():t.fetch(`${o.replace(/\/$/,"")}/notify/receipts`,{method:"POST",headers:{"content-type":"application/json",apikey:p},body:JSON.stringify({receipts:[{receipt:e,status:n}]}),keepalive:!0}).catch(()=>{}),f=async(e,n)=>{for(let s of await t.clients.matchAll({type:"window",includeUncontrolled:!0}))s.postMessage({type:"palbase.push",event:e,url:n.url,data:n.data})};t.addEventListener("push",(e=>{let n={};try{n=e.data?.json()??{}}catch{}let s={url:n.url,receipt:n.receipt,data:n.data},a=n.data?.type==="messaging.message"||n.data?.pb_call==="incoming",u=async()=>a&&(await t.clients.matchAll({type:"window",includeUncontrolled:!0})).some(i=>i.focused===!0),r=async()=>{let i=n.data?.pb_call==="missed"?n.data.call_id:void 0;if(i)for(let d of await t.registration.getNotifications?.({tag:i})??[])d.close()};e.waitUntil(Promise.all([u(),r().catch(()=>{})]).then(([i])=>i?void 0:t.registration.showNotification(n.title??"",{body:n.body,image:n.image,tag:n.tag,data:s})).then(()=>Promise.all([c(n.receipt,"delivered"),f("received",s)])))})),t.addEventListener("notificationclick",(e=>{e.notification.close();let n=e.notification.data??{},s=n.data?.pb_call!==void 0,a=g(n.url,t.location.origin)??(s?g(t.registration.scope??"/",t.location.origin):void 0),u=async()=>{if(!a)return;let r=await t.clients.matchAll({type:"window",includeUncontrolled:!0}),i=r.find(d=>d.url===a)??(s&&!n.url?r.find(d=>d.focused)??r[0]:void 0);i?await i.focus():await t.clients.openWindow(a)};e.waitUntil(Promise.all([c(n.receipt,"opened"),u(),f("opened",n)]))})),t.addEventListener("notificationclose",(e=>{e.waitUntil(c(e.notification.data?.receipt,"dismissed"))}))}typeof self<"u"&&typeof self.registration=="object"&&!("document"in self)&&w(self);})();
package/dist/web/ssr.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! palbase 0.65.0 — Palbase SDK License (see LICENSE) */
2
- import{B as g}from"../chunks/3TXOVBZP.js";import"../chunks/2HJQSGOO.js";import"../chunks/GFG7WVN2.js";import"../chunks/4NHRUBEF.js";import"../chunks/ARRJICH3.js";import"../chunks/YP3QTS4L.js";import"../chunks/DFX37NU3.js";import"../chunks/KU6B2OXP.js";import"../chunks/G2JBUBZO.js";import"../chunks/DLMWZYLL.js";import"../chunks/TEF7WS37.js";import"../chunks/XSOQNHZ5.js";var A=Object.freeze({"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"}),x={path:"/",sameSite:"lax",secure:!0,httpOnly:!1,maxAge:400*24*60*60},h=3180,$=5*6e4;function b(e,t={}){let s=/^pb_([a-z0-9]+)_c/.exec(e)?.[1];if(s===void 0)throw new TypeError("publishableKey is the project publishable key (pb_<ref>_c\u2026)");let o={...x,...t};return`${o.secure===!0&&!o.domain&&(o.path??"/")==="/"?"__Host-":""}pb-${s}-session`}var v=e=>{let t=new TextEncoder().encode(JSON.stringify(e)),s="";for(let o of t)s+=String.fromCharCode(o);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},_=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),s=JSON.parse(new TextDecoder().decode(Uint8Array.from(t,o=>o.charCodeAt(0))));return typeof s.accessToken!="string"||typeof s.refreshToken!="string"||typeof s.expiresAt!="number"||typeof s.userId!="string"?null:s}catch{return null}},f="__Host-",C=!1;function w(e,t,s={},o=!1){let r={...x,...s},d=async()=>new Map((await t.getAll()).map(n=>[n.name,n.value])),m=n=>a=>a===n||a.startsWith(`${n}.`)&&/^\d+$/.test(a.slice(n.length+1)),S=m(e),k=e.startsWith(f)?e.slice(f.length):f+e,O=m(k),y=async n=>{if(!t.setAll)return;let a=n===null?[]:n.length<=h?[[e,n]]:Array.from({length:Math.ceil(n.length/h)},(i,u)=>[`${e}.${u}`,n.slice(u*h,(u+1)*h)]),l=new Set(a.map(([i])=>i)),c=a.map(([i,u])=>({name:i,value:u,options:r})),p=await d();for(let i of p.keys())S(i)&&!l.has(i)&&c.push({name:i,value:"",options:{...r,maxAge:0}});if(e.startsWith(f))for(let i of p.keys())O(i)&&c.push({name:i,value:"",options:{...r,maxAge:0}});c.length>0&&await t.setAll(c,{...A})};return{async load(){let n=await d(),a=[...n.keys()];!C&&!a.some(S)&&a.some(O)&&(C=!0,console.warn(`palbase: the request holds a session cookie named ${k}, and this client reads ${e}: no one is signed in here. The browser's client and the server's name it from the same cookieOptions \u2014 on http (localhost) the server's needs cookieOptions: { secure: false }.`));let l=n.get(e);if(l===void 0){let c="";for(let p=0;n.has(`${e}.${p}`);p++)c+=n.get(`${e}.${p}`);l=c}return l?_(l):null},save:n=>y(v(n)),clear:()=>y(null),shared:o}}function P(e){let{cookies:t,cookieOptions:s,...o}=e,r=e.refresh??(t.setAll?"before":"never");return g({...o,refresh:r,storage:w(b(e.publishableKey,s),t,s)})}function T(){let e=()=>{let t=globalThis.document;if(!t)throw new Error("documentCookies: there is no document here \u2014 a server gives its request's cookies to createServerClient");return t};return{getAll:()=>e().cookie.split(";").map(t=>t.trim()).filter(t=>t.includes("=")).map(t=>{let s=t.indexOf("=");return{name:t.slice(0,s),value:t.slice(s+1)}}),setAll(t){for(let s of t){let o=s.options,r=[`Path=${o.path??"/"}`,o.domain?`Domain=${o.domain}`:"",o.maxAge!==void 0?`Max-Age=${o.maxAge}`:"",o.expires?`Expires=${o.expires.toUTCString()}`:"",o.sameSite?`SameSite=${o.sameSite.charAt(0).toUpperCase()}${o.sameSite.slice(1)}`:"",o.secure?"Secure":""].filter(Boolean);e().cookie=[`${s.name}=${s.value}`,...r].join("; ")}}}}function M(e){let{cookieOptions:t,...s}=e,r={secure:globalThis.location?.protocol==="https:",...t};return g({...s,storage:w(b(e.publishableKey,r),T(),r,!0)})}async function N(e){let t=await e.auth.currentSession();if(!t||(t.expiresAt-Date.now()<=$&&await e.auth.refreshSession().catch(()=>{}),!await e.auth.currentSession()))return null;try{return(await e.auth.api.verifyTokenUser()).data}catch(s){if(s.status===401)return null;throw s}}export{A as NO_STORE_HEADERS,x as SESSION_COOKIE_OPTIONS,w as cookieSessionStore,M as createBrowserClient,P as createServerClient,T as documentCookies,N as keepSession,b as sessionCookieName};
1
+ /*! palbase 0.68.0 — Palbase SDK License (see LICENSE) */
2
+ import{B as g}from"../chunks/3OP3YJ63.js";import"../chunks/QQUIM4VK.js";import"../chunks/MVY4K43S.js";import"../chunks/D6EUPFUR.js";import"../chunks/UJLFALKX.js";import"../chunks/EJAGO6ZV.js";import"../chunks/22GRHCVI.js";import"../chunks/65QZXK2S.js";import"../chunks/LUUXXMXH.js";import"../chunks/J7WJF7F4.js";import"../chunks/QFZ4GCJH.js";import"../chunks/XJLAH42O.js";import"../chunks/XU4G5W72.js";var A=Object.freeze({"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"}),x={path:"/",sameSite:"lax",secure:!0,httpOnly:!1,maxAge:400*24*60*60},h=3180,$=5*6e4;function b(e,t={}){let s=/^pb_([a-z0-9]+)_c/.exec(e)?.[1];if(s===void 0)throw new TypeError("publishableKey is the project publishable key (pb_<ref>_c\u2026)");let o={...x,...t};return`${o.secure===!0&&!o.domain&&(o.path??"/")==="/"?"__Host-":""}pb-${s}-session`}var v=e=>{let t=new TextEncoder().encode(JSON.stringify(e)),s="";for(let o of t)s+=String.fromCharCode(o);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},_=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),s=JSON.parse(new TextDecoder().decode(Uint8Array.from(t,o=>o.charCodeAt(0))));return typeof s.accessToken!="string"||typeof s.refreshToken!="string"||typeof s.expiresAt!="number"||typeof s.userId!="string"?null:s}catch{return null}},f="__Host-",C=!1;function w(e,t,s={},o=!1){let r={...x,...s},d=async()=>new Map((await t.getAll()).map(n=>[n.name,n.value])),m=n=>a=>a===n||a.startsWith(`${n}.`)&&/^\d+$/.test(a.slice(n.length+1)),S=m(e),k=e.startsWith(f)?e.slice(f.length):f+e,O=m(k),y=async n=>{if(!t.setAll)return;let a=n===null?[]:n.length<=h?[[e,n]]:Array.from({length:Math.ceil(n.length/h)},(i,u)=>[`${e}.${u}`,n.slice(u*h,(u+1)*h)]),l=new Set(a.map(([i])=>i)),c=a.map(([i,u])=>({name:i,value:u,options:r})),p=await d();for(let i of p.keys())S(i)&&!l.has(i)&&c.push({name:i,value:"",options:{...r,maxAge:0}});if(e.startsWith(f))for(let i of p.keys())O(i)&&c.push({name:i,value:"",options:{...r,maxAge:0}});c.length>0&&await t.setAll(c,{...A})};return{async load(){let n=await d(),a=[...n.keys()];!C&&!a.some(S)&&a.some(O)&&(C=!0,console.warn(`palbase: the request holds a session cookie named ${k}, and this client reads ${e}: no one is signed in here. The browser's client and the server's name it from the same cookieOptions \u2014 on http (localhost) the server's needs cookieOptions: { secure: false }.`));let l=n.get(e);if(l===void 0){let c="";for(let p=0;n.has(`${e}.${p}`);p++)c+=n.get(`${e}.${p}`);l=c}return l?_(l):null},save:n=>y(v(n)),clear:()=>y(null),shared:o}}function P(e){let{cookies:t,cookieOptions:s,...o}=e,r=e.refresh??(t.setAll?"before":"never");return g({...o,refresh:r,storage:w(b(e.publishableKey,s),t,s)})}function T(){let e=()=>{let t=globalThis.document;if(!t)throw new Error("documentCookies: there is no document here \u2014 a server gives its request's cookies to createServerClient");return t};return{getAll:()=>e().cookie.split(";").map(t=>t.trim()).filter(t=>t.includes("=")).map(t=>{let s=t.indexOf("=");return{name:t.slice(0,s),value:t.slice(s+1)}}),setAll(t){for(let s of t){let o=s.options,r=[`Path=${o.path??"/"}`,o.domain?`Domain=${o.domain}`:"",o.maxAge!==void 0?`Max-Age=${o.maxAge}`:"",o.expires?`Expires=${o.expires.toUTCString()}`:"",o.sameSite?`SameSite=${o.sameSite.charAt(0).toUpperCase()}${o.sameSite.slice(1)}`:"",o.secure?"Secure":""].filter(Boolean);e().cookie=[`${s.name}=${s.value}`,...r].join("; ")}}}}function M(e){let{cookieOptions:t,...s}=e,r={secure:globalThis.location?.protocol==="https:",...t};return g({...s,storage:w(b(e.publishableKey,r),T(),r,!0)})}async function N(e){let t=await e.auth.currentSession();if(!t||(t.expiresAt-Date.now()<=$&&await e.auth.refreshSession().catch(()=>{}),!await e.auth.currentSession()))return null;try{return(await e.auth.api.verifyTokenUser()).data}catch(s){if(s.status===401)return null;throw s}}export{A as NO_STORE_HEADERS,x as SESSION_COOKIE_OPTIONS,w as cookieSessionStore,M as createBrowserClient,P as createServerClient,T as documentCookies,N as keepSession,b as sessionCookieName};
package/dist/web/vite.js CHANGED
@@ -1,3 +1,4 @@
1
- /*! palbase 0.65.0 — Palbase SDK License (see LICENSE) */
2
- import"../chunks/XSOQNHZ5.js";import{execFile as $}from"node:child_process";import{existsSync as y,mkdtempSync as k,readFileSync as S,rmSync as x,writeFileSync as P}from"node:fs";import{createRequire as O}from"node:module";import{tmpdir as W}from"node:os";import{dirname as g,join as o,relative as u,resolve as v,sep as d}from"node:path";var E=/\.(?:ts|js|mts|mjs)$/;function F(n){if(!/^[a-z][a-z0-9-]*$/.test(n.app))throw new TypeError(`palbase({ app }): ${JSON.stringify(n.app)} is an app's slug (palbase apps:list)`);let c=process.cwd(),p="",i="",f=()=>v(c,n.dir??"palbase"),m=()=>{let e=n.environments[p];if(!e)throw new Error(`palbase: the mode "${p}" is not built against any environment \u2014 say which in vite.config: palbase({ environments: { ${JSON.stringify(p)}: '<environment slug>' } })`);return e};return{name:"palbase",enforce:"pre",config(e,s){p=s.mode,i=s.command??"";let r=e.build?.rollupOptions?.onwarn;return{build:{rollupOptions:{onwarn(t,a){let l=String(t.exporter??t.id??"");if(t.code==="MISSING_EXPORT"&&l.includes(`${d}environments${d}`))throw new Error(`palbase: ${t.message} \u2014 ${m()}'s backend has no such route (palbase apps:sync brings what it has)`);r?r(t,a):a(t)}}}}},configResolved(e){c=e.root,p=e.mode,i=e.command??i},async buildStart(){i!=="build"||n.typecheck===!1||await j(c,m(),n.tsconfig)},resolveId(e,s){if(!s)return null;let r=f();if(e==="palbase"||e.startsWith("palbase/")){let w=u(r,s);return w.startsWith("..")||w===""?null:this.resolve(e,o(c,"index.html"),{skipSelf:!0})}if(!(e.startsWith(".")||e.startsWith("/")))return null;let t=v(g(s),e);if(E.test(t)||(t+=".ts"),g(t)!==r&&g(t)!==o(r,"palbe"))return null;let a=u(r,t),l=`${n.app}.ts`;if(a!==l&&!a.startsWith(`palbe${d}`))return null;let h=m(),b=o(r,"environments",h,a===l?l:o("palbe",a.slice(`palbe${d}`.length)));if(!y(b))throw new Error(`palbase: ${u(c,b)} is not there \u2014 palbase apps:sync writes it (is ${n.app} set in ${h}, and has ${h} that machine?)`);return b}}}async function j(n,c,p){let i=p?v(n,p):["tsconfig.app.json","tsconfig.json"].map(e=>o(n,e)).find(y);if(!i)return;if(!y(i))throw new Error(`palbase({ tsconfig }): ${u(n,i)} is not there`);let f;try{let e=O(o(n,"package.json")).resolve("typescript/package.json"),s=JSON.parse(S(e,"utf8")).bin?.tsc;if(!s)throw new Error("no tsc");f=o(g(e),s)}catch{throw new Error("palbase: the build type-checks the app against its environment with the app's TypeScript, and the app has none (npm i -D typescript) \u2014 or say palbase({ typecheck: false })")}let m=k(o(W(),"palbase-typecheck-"));try{let e=o(m,"tsconfig.json");P(e,JSON.stringify({extends:i,compilerOptions:{noEmit:!0,composite:!1,incremental:!1,moduleSuffixes:[`.${c}`,""]}}));let s=await new Promise(r=>$(process.execPath,[f,"-p",e,"--pretty","false"],{cwd:n,maxBuffer:16<<20},(t,a,l)=>r({code:t?typeof t.code=="number"?t.code:1:0,text:`${a}${l}`.trim()})));if(s.code!==0)throw new Error(`palbase: the app does not type-check against ${c}, the environment this build is made for \u2014 a route its backend does not have, or a call that does not fit it:
3
- ${s.text}`)}finally{x(m,{recursive:!0,force:!0})}}export{F as palbase};
1
+ /*! palbase 0.68.0 — Palbase SDK License (see LICENSE) */
2
+ import"../chunks/XU4G5W72.js";import{execFile as R}from"node:child_process";import{existsSync as A,mkdtempSync as C,readFileSync as W,rmSync as J,writeFileSync as N}from"node:fs";import{createRequire as I}from"node:module";import{tmpdir as T}from"node:os";import{dirname as v,join as f,relative as S,resolve as b,sep as k}from"node:path";var E=/\.(?:ts|js|mts|mjs)$/;function x(n){return n?Array.isArray(n)?n:Object.entries(n).map(([t,e])=>({find:t,replacement:e})):[]}function V(n,t){for(let{find:e,replacement:s}of t)if(typeof e=="string"){if(n===e)return s;if(n.startsWith(e)&&(e.endsWith("/")||n[e.length]==="/"))return`${s}${n.slice(e.length)}`}else if(e instanceof RegExp&&e.test(n))return n.replace(e,s);return null}function U(n){if(!/^[a-z][a-z0-9-]*$/.test(n.app))throw new TypeError(`palbase({ app }): ${JSON.stringify(n.app)} is an app's slug (palbase apps:list)`);let t=process.cwd(),e="",s="",r=[],h=()=>b(t,n.dir??"palbase"),l=()=>{let i=n.environments[e];if(!i)throw new Error(`palbase: the mode "${e}" is not built against any environment \u2014 say which in vite.config: palbase({ environments: { ${JSON.stringify(e)}: '<environment slug>' } })`);return i},g=(i,u)=>{let c=h(),o=E.test(i)?i.replace(E,".ts"):`${i}.ts`;if(v(o)!==c&&v(o)!==f(c,"palbe"))return null;let a=S(c,o),d=`${n.app}.ts`,y=`${n.app}.ssr.ts`;if(a!==d&&a!==y&&!a.startsWith(`palbe${k}`))return null;let m=l(),p=f(c,"environments",m,a===d||a===y?a:f("palbe",a.slice(`palbe${k}`.length)));if(!A(p))throw new Error(`palbase: ${S(t,p)} is not there \u2014 palbase apps:sync writes it (is ${n.app} set in ${m}, and has ${m} that machine?)`);return`${p}${u}`};return{name:"palbase",enforce:"pre",config(i,u){e=u.mode,s=u.command??"";let c=i.build?.rollupOptions?.onwarn;return{build:{rollupOptions:{onwarn(o,a){let d=String(o.exporter??o.id??"");if(o.code==="MISSING_EXPORT"&&d.includes(`${k}environments${k}`))throw new Error(`palbase: ${o.message} \u2014 ${l()}'s backend has no such route (palbase apps:sync brings what it has)`);c?c(o,a):a(o)}}}}},configResolved(i){t=i.root,e=i.mode,s=i.command??s,r=x(i.resolve?.alias)},async buildStart(){s!=="build"||n.typecheck===!1||await D(t,l(),n.tsconfig)},resolveId(i,u){if(!u)return null;let c=h(),o=i.search(/[?#]/),a=o>=0?i.slice(0,o):i,d=o>=0?i.slice(o):"";if(a==="palbase"||a.startsWith("palbase/")){let p=S(c,u);return p.startsWith("..")||p===""?null:this.resolve(i,f(t,"index.html"),{skipSelf:!0})}if(a.startsWith(".")||a.startsWith("/"))return g(b(v(u),a),d);let y=V(a,r);if(y!==null){let p=g(b(t,y),d);if(p!==null)return p}let m=(n.dir??"palbase").replace(/\\/g,"/").replace(/^(\.\/|\.\.\/)+/,"").replace(/\/+$/,"");return a.includes(n.app)||a.includes("/palbe/")||m!==""&&a.includes(m)?this.resolve(i,u,{skipSelf:!0}).then(p=>{let w=p?.id;if(!w)return p;let $=w.search(/[?#]/),j=$>=0?w.slice(0,$):w,P=$>=0?w.slice($):d;return g(j,P)??p}):null}}}function z(n){let t="",e=0;for(;e<n.length;){let s=n[e];if(s==='"')for(t+=s,e++;e<n.length;){let r=n[e];if(t+=r,e++,r==="\\"&&e<n.length)t+=n[e],e++;else if(r==='"')break}else if(s==="/"&&n[e+1]==="/")for(e+=2;e<n.length&&n[e]!==`
3
+ `;)e++;else if(s==="/"&&n[e+1]==="*"){for(e+=2;e<n.length&&!(n[e]==="*"&&n[e+1]==="/");)e++;if(e>=n.length)return null;e+=2,t+=" "}else t+=s,e++}return t}function F(n){let t="",e=0;for(;e<n.length;){let s=n[e];if(s==='"')for(t+=s,e++;e<n.length;){let r=n[e];if(t+=r,e++,r==="\\"&&e<n.length)t+=n[e],e++;else if(r==='"')break}else if(s===","){let r=e+1;for(;r<n.length&&/\s/.test(n[r]);)r++;n[r]!=="}"&&n[r]!=="]"&&(t+=s),e++}else t+=s,e++}return t}function q(n){try{let t=z(n);if(t===null)return null;let e=JSON.parse(F(t));return typeof e!="object"||e===null||Array.isArray(e)?null:e}catch{return null}}function O(n,t=new Set){let e=b(n);if(t.has(e)||!A(e))return!1;t.add(e);let s=q(W(e,"utf8"));if(!s||"files"in s||"include"in s||"references"in s)return!0;let r=s.extends,h=typeof r=="string"?[r]:Array.isArray(r)?r.filter(l=>typeof l=="string"):[];for(let l of h){if(!l.startsWith("."))continue;let g=b(v(e),l.endsWith(".json")?l:`${l}.json`);if(O(g,t))return!0}return!1}async function D(n,t,e){let s=e?b(n,e):["tsconfig.app.json","tsconfig.json"].map(l=>f(n,l)).find(A);if(!s)return;if(!A(s))throw new Error(`palbase({ tsconfig }): ${S(n,s)} is not there`);let r;try{let l=I(f(n,"package.json")).resolve("typescript/package.json"),g=JSON.parse(W(l,"utf8")).bin?.tsc;if(!g)throw new Error("no tsc");r=f(v(l),g)}catch{throw new Error("palbase: the build type-checks the app against its environment with the app's TypeScript, and the app has none (npm i -D typescript) \u2014 or say palbase({ typecheck: false })")}let h=C(f(T(),"palbase-typecheck-"));try{let l=f(h,"tsconfig.json"),g=O(s)?{}:{include:[f(n,"**/*")],exclude:[f(n,"node_modules"),f(n,"dist")]};N(l,JSON.stringify({extends:s,...g,compilerOptions:{noEmit:!0,composite:!1,incremental:!1,moduleSuffixes:[`.${t}`,""]}}));let i=await new Promise(u=>R(process.execPath,[r,"-p",l,"--pretty","false"],{cwd:n,maxBuffer:16<<20},(c,o,a)=>u({code:c?typeof c.code=="number"?c.code:1:0,text:`${o}${a}`.trim()})));if(i.code!==0)throw new Error(`palbase: the app does not type-check against ${t}, the environment this build is made for \u2014 a route its backend does not have, or a call that does not fit it:
4
+ ${i.text}`)}finally{J(h,{recursive:!0,force:!0})}}export{U as palbase};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palbase",
3
- "version": "0.65.0",
3
+ "version": "0.68.0",
4
4
  "description": "Palbase for JavaScript: the web client (palbase/web), the server SDK (palbase/server), an organization's management SDK (palbase/cloud), the backend framework (palbase/backend), AI (palbase/ai) and the CLI (npx palbase).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://palbase.studio",
@@ -17,6 +17,7 @@
17
17
  "realtime",
18
18
  "feature-flags",
19
19
  "push-notifications",
20
+ "payments",
20
21
  "in-app-purchases",
21
22
  "analytics",
22
23
  "ai",
@@ -39,6 +40,10 @@
39
40
  "types": "./types/web/src/index.d.ts",
40
41
  "default": "./dist/web/index.js"
41
42
  },
43
+ "./web/payments-ui": {
44
+ "types": "./types/web/src/payments-ui/index.d.ts",
45
+ "default": "./dist/web/payments-ui.js"
46
+ },
42
47
  "./web/palbe": {
43
48
  "types": "./types/web/src/palbe.d.ts",
44
49
  "default": "./dist/web/palbe.js"
@@ -96,6 +101,18 @@
96
101
  "worker": "./dist/ai/index.js",
97
102
  "default": "./dist/ai/index.js"
98
103
  },
104
+ "./ai-sdk": {
105
+ "types": "./types/ai-sdk/src/index.d.ts",
106
+ "node": "./dist/ai-sdk/index.js",
107
+ "bun": "./dist/ai-sdk/index.js",
108
+ "deno": "./dist/ai-sdk/index.js",
109
+ "workerd": "./dist/ai-sdk/index.js",
110
+ "edge-light": "./dist/ai-sdk/index.js",
111
+ "react-native": "./dist/refuse/ai-sdk.js",
112
+ "browser": "./dist/refuse/ai-sdk.js",
113
+ "worker": "./dist/ai-sdk/index.js",
114
+ "default": "./dist/ai-sdk/index.js"
115
+ },
99
116
  "./backend": {
100
117
  "types": "./types/backend/src/index.d.ts",
101
118
  "react-native": "./dist/refuse/backend.js",
@@ -150,7 +167,7 @@
150
167
  "@types/node": "26.6.4",
151
168
  "bun-types": "1.4.2",
152
169
  "livekit-client": "^2.23.0",
153
- "palgres": "0.65.0",
170
+ "palgres": "0.68.0",
154
171
  "reflect-metadata": "^0.2.2",
155
172
  "typescript": "~6.0.3",
156
173
  "zod": "^4.6.5"
@@ -3,9 +3,9 @@ import { type RetryPolicy } from '../../internal/src/retry.js';
3
3
  import * as modules from '../../internal/src/modules/index.js';
4
4
  import { type Infer, type PreparedSchema, type StandardSchema } from './schema.js';
5
5
  import type { ToolResult } from '../../internal/src/tool-output.js';
6
- import { type Agents, type Chats, type Endpoints, type Repos, type Settings } from './chats.js';
6
+ import { type Agents, type Chats, type Endpoints, type Environments, type Settings } from './chats.js';
7
7
  import { type EnvVariables, type PoolMachines, type Pools } from './pools.js';
8
- import { type AgentContext, type BackendAgent, type BackendAgentOptions, type BackendRepo, type BackendTool, type BackendToolOptions, type DeferredAnswer, type ToolReply, type WorkspaceTree, type RepoTokenContext, type RepoTokens, type ClientTool, type ClientToolOptions, type HttpsToolRef, type McpToolRef, type TurnDefinition } from './tools.js';
8
+ import { type AgentContext, type BackendAgent, type BackendAgentOptions, type BackendTool, type BackendToolOptions, type DeferredAnswer, type ToolReply, type WorkspaceTree, type ClientTool, type ClientToolOptions, type HttpsToolRef, type McpToolRef, type TurnDefinition } from './tools.js';
9
9
  type Module = ReturnType<typeof modules.ai.client>;
10
10
  export type Response = Awaited<ReturnType<Module['getResponse']>>['data'];
11
11
  export type Usage = Awaited<ReturnType<Module['listUsage']>>['data']['usage'][number];
@@ -15,10 +15,51 @@ export type Usage = Awaited<ReturnType<Module['listUsage']>>['data']['usage'][nu
15
15
  * project now — and if not, why (reason).
16
16
  */
17
17
  export type Spend = modules.ai.Spend;
18
- /** What the project may name (ai.models()): its text, embedding and image models, the default and a deprecated one marked. */
18
+ /** What the project may name (ai.models()): its text, embedding, image, video, speech-to-text and text-to-speech models, the default and a deprecated one marked. */
19
19
  export type Models = modules.ai.Models;
20
20
  /** A text model a turn may name, as the engine's catalogue says it (ai.models().chat): `name` is what a call names it by. */
21
21
  export type ChatModel = modules.ai.ChatModel;
22
+ /** Every usage modality tracked in the unified AI ledger. */
23
+ export type UsageKind = 'text' | 'embedding' | 'image' | 'video' | 'stt' | 'tts' | 'voice' | 'web_search' | 'machine';
24
+ export type VideoRequest = modules.ai.VideoRequest;
25
+ export type VideoJob = modules.ai.VideoJob;
26
+ export type VideoCancelResult = modules.ai.VideoCancelResult;
27
+ export type TranscriptionRequest = modules.ai.TranscriptionRequest;
28
+ export type TranscriptionResponse = modules.ai.TranscriptionResponse;
29
+ export type TranscriptionSegment = modules.ai.TranscriptionSegment;
30
+ export type SpeechRequest = modules.ai.SpeechRequest;
31
+ export interface SpeechAudio {
32
+ mediaType: string;
33
+ bytes: Uint8Array;
34
+ }
35
+ export interface Videos {
36
+ /** Starts a durable asynchronous video generation job (Google Veo, Kling). */
37
+ create(request: VideoRequest, options?: {
38
+ signal?: AbortSignal;
39
+ }): Promise<VideoJob>;
40
+ /** Reads a video job's status, storage location, output URL, and settled cost. */
41
+ get(id: string, options?: {
42
+ signal?: AbortSignal;
43
+ }): Promise<VideoJob>;
44
+ /** Cancels a queued or running video job. */
45
+ cancel(id: string, options?: {
46
+ signal?: AbortSignal;
47
+ }): Promise<VideoCancelResult>;
48
+ }
49
+ export interface Audio {
50
+ /** Transcribes a stored audio file via OpenAI or Deepgram with optional timestamps and diarization. */
51
+ transcribe(request: TranscriptionRequest, options?: {
52
+ signal?: AbortSignal;
53
+ }): Promise<TranscriptionResponse>;
54
+ /** Synthesizes speech via OpenAI or ElevenLabs, returning the complete audio bytes and media type. */
55
+ speak(request: SpeechRequest, options?: {
56
+ signal?: AbortSignal;
57
+ }): Promise<SpeechAudio>;
58
+ /** Synthesizes speech and returns the raw streaming HTTP Response for low-latency forwarding. */
59
+ speakStream(request: SpeechRequest, options?: {
60
+ signal?: AbortSignal;
61
+ }): Promise<globalThis.Response>;
62
+ }
22
63
  export interface AIOptions {
23
64
  /** The project's address (https://<ref>.<domain>); default PALBASE_URL. */
24
65
  url?: string;
@@ -225,10 +266,14 @@ export interface AI {
225
266
  embed(text: string, options?: Embed): Promise<number[]>;
226
267
  /** Pictures for a prompt: waits for the job (it takes the provider up to minutes). */
227
268
  image(request: ImageRequest): Promise<Images>;
269
+ /** Durable asynchronous video generation jobs (Google Veo, Kling). */
270
+ readonly videos: Videos;
271
+ /** Audio transcription (STT via OpenAI, Deepgram) and speech synthesis (TTS via OpenAI, ElevenLabs). */
272
+ readonly audio: Audio;
228
273
  /**
229
274
  * What the project may name: every text model a turn may name (chat: an agent's, a response's) with the efforts it
230
275
  * takes, its window, its token limits and its price — the default, and a deprecated one marked with what to name
231
- * instead: what a model picker offers a person —, and the embedding and picture models. unavailable: the providers
276
+ * instead: what a model picker offers a person —, and the embedding, image, video, transcription and speech models. unavailable: the providers
232
277
  * whose models could not be listed just now. Each model's `name` is what a call names it by.
233
278
  */
234
279
  models(): Promise<Models>;
@@ -239,7 +284,7 @@ export interface AI {
239
284
  * a reasoning call cut before its answer, whose hidden thinking its provider never counted.
240
285
  */
241
286
  usage(options?: {
242
- kind?: 'text' | 'embedding' | 'image';
287
+ kind?: UsageKind;
243
288
  metadata?: Record<string, string>;
244
289
  limit?: number;
245
290
  cursor?: string;
@@ -291,8 +336,8 @@ export interface AI {
291
336
  expiresInSeconds?: number;
292
337
  }): DeferredAnswer;
293
338
  /**
294
- * What a backend tool's run returns when it wrote the chat's workspace (chats.workspace.write): its output, and the
295
- * tree its writes left (what the write answered) — the session's machine takes it before the agent's next command,
339
+ * What a backend tool's run returns when it wrote the chat's workspace: its output, and the
340
+ * tree its writes left — the session's machine takes it before the agent's next command,
296
341
  * so the agent sees what the tool wrote. A tool that wrote and then failed says it with new ToolError(message, {
297
342
  * workspaceTree }).
298
343
  */
@@ -307,29 +352,10 @@ export interface AI {
307
352
  * Made once, at a module's top level.
308
353
  */
309
354
  agent(name: string, define: (ctx: AgentContext) => TurnDefinition | Promise<TurnDefinition>, options?: BackendAgentOptions): BackendAgent;
355
+ /** First-class runtime environments (`ephemeral` or `always_on`) and their pre-bake builds. */
356
+ readonly environments: Environments;
310
357
  /**
311
- * A GitHub repository a chat's workspace works in, whose tokens this
312
- * backend gives (token, asked at each clone and each push): put it with
313
- * ai.repos.put(repo). Made once, at a module's top level.
314
- */
315
- repo(options: {
316
- name: string;
317
- repository: string;
318
- defaultBranch?: string;
319
- machine?: string;
320
- token: (ctx: RepoTokenContext) => string | Promise<string>;
321
- }): BackendRepo;
322
- /**
323
- * The tokens of the repositories put by name at run time (ai.repos.put(name, { repository, backend })) — one a
324
- * product makes for itself — that no ai.repo of this backend names: each clone and push of a chat's workspace asks
325
- * this machine, and give answers with a token for that one operation, or null for one it gives none for. Given
326
- * once, at a module's top level; an ai.repo answers for its own repository first.
327
- */
328
- repoTokens(give: RepoTokens): void;
329
- /** The project's repositories a chat's workspace works in (chats.create({ workspace })). */
330
- readonly repos: Repos;
331
- /**
332
- * The project's own runner pools — machines of its own, a Mac or a Linux box, enrolled with palai and a single-use
358
+ * The project's own runner pools — machines of its own, a Mac or a Linux box, enrolled with palbase-agent and a single-use
333
359
  * key — that a chat's workspace runs on (chats.create({ pool })), read as its scaling loop reads them (state).
334
360
  */
335
361
  readonly pools: Pools;