@kapybara/zerosub 1.0.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.
@@ -0,0 +1,592 @@
1
+ import { useHosts, useSettings, type PluginSurfaceProps } from "@getpaseo/plugin/client";
2
+ import { Icon, Modal, TextInput, useToast } from "@getpaseo/plugin/client/react-native";
3
+ import { SettingsCard, SettingsSwitch } from "@getpaseo/plugin/client/ui";
4
+ import { useCallback, useEffect, useMemo, useState } from "react";
5
+ import { ScrollView, Text, View } from "react-native";
6
+ import { accountSubtitle, formatAge, formatPlan, usageSummary } from "../shared/format";
7
+ import { FAMILY_LABEL, type AccountView, type Family } from "../shared/model";
8
+ import { preferences } from "../shared/preferences";
9
+ import {
10
+ clearAccountLimit,
11
+ removeAccount,
12
+ renameAccount,
13
+ setDefaultAccount,
14
+ type ReopenSummary,
15
+ } from "../shared/rpc";
16
+ import { AddAccountModal } from "./add-account";
17
+ import { ResetConfirm, redeemToast, resetBadge } from "./reset-confirm";
18
+ import { describe, useStore, VISIBLE_POLL_MS, type ZeroSubStore } from "./store";
19
+ import { Badge, Button, Card, IconButton, UsageBar, useText } from "./ui";
20
+
21
+ type Theme = PluginSurfaceProps["theme"];
22
+
23
+ export function AccountsSurface(props: PluginSurfaceProps & { store: ZeroSubStore }) {
24
+ const { theme, layout, host, store } = props;
25
+ const { state, error } = useStore(store);
26
+ const text = useText(theme);
27
+ const [adding, setAdding] = useState<{ family: Family; accountId?: string } | null>(null);
28
+ const [refreshing, setRefreshing] = useState(false);
29
+ const refreshUsage = useCallback(async () => {
30
+ setRefreshing(true);
31
+ try {
32
+ await store.refresh({ refreshUsage: true });
33
+ } finally {
34
+ setRefreshing(false);
35
+ }
36
+ }, [store]);
37
+ // Each host runs its own copy of the plugin with its own accounts; Paseo's host picker switches.
38
+ const hosts = useHosts();
39
+ const multiHost = hosts.length > 1;
40
+ const hostStatus = hosts.find((entry) => entry.serverId === host.id)?.status;
41
+ const offline = hostStatus !== undefined && hostStatus !== "online";
42
+ // Keep usage moving while the screen is open.
43
+ useEffect(() => store.watch(VISIBLE_POLL_MS), [store]);
44
+
45
+ const families: Family[] = ["claude", "codex"];
46
+ return (
47
+ <View style={{ flex: 1, backgroundColor: theme.colors.surface0 }}>
48
+ <ScrollView
49
+ contentContainerStyle={{
50
+ padding: layout.compact ? 16 : 28,
51
+ gap: layout.compact ? 20 : 28,
52
+ maxWidth: 820,
53
+ width: "100%",
54
+ alignSelf: "center",
55
+ }}
56
+ >
57
+ <View style={{ gap: 6 }}>
58
+ <Text style={[text.small, { fontWeight: "600", letterSpacing: 0.4 }]}>ZeroSub</Text>
59
+ <View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 8 }}>
60
+ <Text style={text.title} accessibilityRole="header">
61
+ Subscription accounts
62
+ </Text>
63
+ {state ? (
64
+ <IconButton theme={theme} icon="RefreshCw" label="Refresh usage" busy={refreshing} onPress={() => void refreshUsage()} />
65
+ ) : null}
66
+ </View>
67
+ <Text style={text.muted}>
68
+ Keep several Claude and ChatGPT accounts signed in. Each agent uses one; when an account
69
+ hits its limit, agents move to another and keep going.
70
+ </Text>
71
+ </View>
72
+
73
+ {multiHost ? <HostScope theme={theme} label={host.label} /> : null}
74
+
75
+ {error && (offline || !state) ? (
76
+ <Card theme={theme}>
77
+ <Text style={text.danger}>
78
+ {offline
79
+ ? `Can't reach ${host.label}. Its accounts are saved on that machine${
80
+ state ? "; this is how they looked last." : " and show up here once it reconnects."
81
+ }`
82
+ : `Could not reach the daemon: ${error}`}
83
+ </Text>
84
+ <Button theme={theme} label="Try again" icon="RefreshCw" onPress={() => void store.refresh()} />
85
+ </Card>
86
+ ) : null}
87
+
88
+ {state?.warnings.map((warning) => (
89
+ <Card theme={theme} key={warning}>
90
+ <Text style={text.warning}>{warning}</Text>
91
+ </Card>
92
+ ))}
93
+
94
+ {!state && !error ? <Text style={text.muted}>Loading accounts…</Text> : null}
95
+
96
+ {state
97
+ ? families.map((family) => (
98
+ <FamilySection
99
+ key={family}
100
+ family={family}
101
+ accounts={state.accounts.filter((account) => account.family === family)}
102
+ theme={theme}
103
+ compact={layout.compact}
104
+ store={store}
105
+ onAdd={() => setAdding({ family })}
106
+ onSignIn={(account) => setAdding({ family, accountId: account.id })}
107
+ />
108
+ ))
109
+ : null}
110
+
111
+ <AutomationSettings theme={theme} />
112
+ </ScrollView>
113
+
114
+ {adding ? (
115
+ <AddAccountModal
116
+ theme={theme}
117
+ layout={layout}
118
+ host={host}
119
+ multiHost={multiHost}
120
+ store={store}
121
+ family={adding.family}
122
+ accountId={adding.accountId}
123
+ onClose={() => setAdding(null)}
124
+ />
125
+ ) : null}
126
+ </View>
127
+ );
128
+ }
129
+
130
+ /** Says whose accounts these are when the app knows several hosts. */
131
+ function HostScope({ theme, label }: { theme: Theme; label: string }) {
132
+ const text = useText(theme);
133
+ return (
134
+ <View
135
+ style={{
136
+ flexDirection: "row",
137
+ alignItems: "flex-start",
138
+ gap: 10,
139
+ padding: 12,
140
+ borderRadius: 10,
141
+ borderWidth: 1,
142
+ borderColor: theme.colors.border,
143
+ backgroundColor: theme.colors.surface1,
144
+ }}
145
+ >
146
+ <Icon name="Server" size={16} color={theme.colors.foregroundMuted} />
147
+ <View style={{ flex: 1, gap: 2 }}>
148
+ <Text style={text.strong}>Accounts on {label}</Text>
149
+ <Text style={text.small}>
150
+ Only agents on this host use them. Each host keeps its own accounts and settings, so sign in on
151
+ each host you use. Switch hosts with the host picker at the top; a host shows up there once ZeroSub
152
+ is installed on it.
153
+ </Text>
154
+ </View>
155
+ </View>
156
+ );
157
+ }
158
+
159
+ function FamilySection({
160
+ family,
161
+ accounts,
162
+ theme,
163
+ compact,
164
+ store,
165
+ onAdd,
166
+ onSignIn,
167
+ }: {
168
+ family: Family;
169
+ accounts: AccountView[];
170
+ theme: Theme;
171
+ compact: boolean;
172
+ store: ZeroSubStore;
173
+ onAdd(): void;
174
+ onSignIn(account: AccountView): void;
175
+ }) {
176
+ const text = useText(theme);
177
+ return (
178
+ <View style={{ gap: 10 }}>
179
+ <View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between" }}>
180
+ <Text style={text.heading} accessibilityRole="header">
181
+ {family === "claude" ? "Claude" : "ChatGPT (Codex)"}
182
+ </Text>
183
+ <Button
184
+ theme={theme}
185
+ icon="Plus"
186
+ label={compact ? "Add" : "Add account"}
187
+ accessibilityLabel={`Add ${FAMILY_LABEL[family]} account`}
188
+ onPress={onAdd}
189
+ />
190
+ </View>
191
+ {accounts.length === 0 ? (
192
+ <Text style={text.muted}>No {FAMILY_LABEL[family]} accounts yet.</Text>
193
+ ) : null}
194
+ {chunk(accounts, compact ? 1 : 2).map((row) => (
195
+ <View key={row.map((account) => account.id).join()} style={{ flexDirection: "row", gap: 10 }}>
196
+ {row.map((account) => (
197
+ <AccountCard
198
+ key={account.id}
199
+ account={account}
200
+ theme={theme}
201
+ store={store}
202
+ onSignIn={() => onSignIn(account)}
203
+ />
204
+ ))}
205
+ {!compact && row.length === 1 ? <View style={{ flex: 1 }} /> : null}
206
+ </View>
207
+ ))}
208
+ </View>
209
+ );
210
+ }
211
+
212
+ function AccountCard({
213
+ account,
214
+ theme,
215
+ store,
216
+ onSignIn,
217
+ }: {
218
+ account: AccountView;
219
+ theme: Theme;
220
+ store: ZeroSubStore;
221
+ onSignIn(): void;
222
+ }) {
223
+ const text = useText(theme);
224
+ const toast = useToast();
225
+ const [busy, setBusy] = useState<"default" | "remove" | "clear" | null>(null);
226
+ const [renaming, setRenaming] = useState(false);
227
+ const [confirmRemove, setConfirmRemove] = useState(false);
228
+ const [confirmReset, setConfirmReset] = useState(false);
229
+ const resets = account.usage?.resets ?? null;
230
+ const plan = formatPlan(account.plan);
231
+ const summary = usageSummary(account);
232
+ const subtitle = accountSubtitle(account);
233
+ const signedOut = account.status === "signed_out";
234
+ const windows = account.usage?.windows ?? [];
235
+ const agents = account.agentCount === 0 ? "No agents" : `${account.agentCount} agent${account.agentCount === 1 ? "" : "s"}`;
236
+ const freshness = !signedOut && account.usage && windows.length > 0 ? `updated ${formatAge(account.usage.fetchedAt)}` : null;
237
+
238
+ const makeDefault = useCallback(async () => {
239
+ setBusy("default");
240
+ try {
241
+ const summary = await store.rpc(setDefaultAccount, { accountId: account.id });
242
+ toast.show(describeReopen(`${account.label} is now the default`, summary), { variant: "success" });
243
+ await store.refresh();
244
+ } catch (error) {
245
+ toast.error(describe(error));
246
+ } finally {
247
+ setBusy(null);
248
+ }
249
+ }, [account, store, toast]);
250
+
251
+ // For when the user knows better, e.g. after upgrading the plan or buying credits.
252
+ const markAvailable = useCallback(async () => {
253
+ setBusy("clear");
254
+ try {
255
+ await store.rpc(clearAccountLimit, { accountId: account.id });
256
+ toast.show(`${account.label} is available again`, { variant: "success" });
257
+ } catch (error) {
258
+ toast.error(describe(error));
259
+ } finally {
260
+ setBusy(null);
261
+ }
262
+ }, [account, store, toast]);
263
+
264
+ const remove = useCallback(async () => {
265
+ setBusy("remove");
266
+ try {
267
+ const result = await store.rpc(removeAccount, { accountId: account.id });
268
+ toast.show(
269
+ result.movedAgents > 0
270
+ ? `Removed ${account.label}; ${result.movedAgents} agent(s) moved to the default account`
271
+ : `Removed ${account.label}`,
272
+ { variant: "success" },
273
+ );
274
+ await store.refresh();
275
+ } catch (error) {
276
+ toast.error(describe(error));
277
+ } finally {
278
+ setBusy(null);
279
+ setConfirmRemove(false);
280
+ }
281
+ }, [account, store, toast]);
282
+
283
+ return (
284
+ <Card theme={theme} fill>
285
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 12 }}>
286
+ <Avatar theme={theme} label={account.label} />
287
+ <View style={{ flex: 1, minWidth: 0, gap: 3 }}>
288
+ <Text style={text.strong} numberOfLines={1}>
289
+ {account.label}
290
+ </Text>
291
+ {subtitle ? (
292
+ <Text style={text.small} numberOfLines={1}>
293
+ {subtitle}
294
+ </Text>
295
+ ) : null}
296
+ </View>
297
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 2, marginTop: -4, marginRight: -6 }}>
298
+ {account.status === "limited" ? (
299
+ <IconButton
300
+ theme={theme}
301
+ icon="CircleCheck"
302
+ label="Mark as available again (it has room)"
303
+ busy={busy === "clear"}
304
+ onPress={() => void markAvailable()}
305
+ />
306
+ ) : null}
307
+ {!account.isDefault && account.status !== "signed_out" ? (
308
+ <IconButton
309
+ theme={theme}
310
+ icon="Star"
311
+ label="Make default"
312
+ busy={busy === "default"}
313
+ onPress={() => void makeDefault()}
314
+ />
315
+ ) : null}
316
+ <IconButton theme={theme} icon="Pencil" label="Rename" onPress={() => setRenaming(true)} />
317
+ {account.kind !== "main" ? (
318
+ <IconButton
319
+ theme={theme}
320
+ icon="Trash2"
321
+ label="Remove"
322
+ tone="danger"
323
+ busy={busy === "remove"}
324
+ onPress={() => setConfirmRemove(true)}
325
+ />
326
+ ) : null}
327
+ </View>
328
+ </View>
329
+
330
+ <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 6 }}>
331
+ {account.isDefault ? <Badge theme={theme} label="Default" tone="accent" /> : null}
332
+ {plan ? <Badge theme={theme} label={plan} /> : null}
333
+ {account.kind === "main" ? <Badge theme={theme} label="CLI login" /> : null}
334
+ {account.status === "limited" ? <Badge theme={theme} label="Limit reached" tone="danger" /> : null}
335
+ {account.status === "signed_out" ? <Badge theme={theme} label="Signed out" tone="warning" /> : null}
336
+ {resets && !signedOut ? <Badge theme={theme} label={resetBadge(resets)} tone="accent" /> : null}
337
+ </View>
338
+
339
+ <View style={{ gap: 10 }}>
340
+ {signedOut ? (
341
+ <Text style={text.small}>Sign in again to use this account.</Text>
342
+ ) : windows.length > 0 ? (
343
+ windows.map((limit) => <UsageBar key={limit.id} theme={theme} limit={limit} />)
344
+ ) : (
345
+ <Text style={text.small}>{account.usage?.error ?? summary ?? "Checking usage…"}</Text>
346
+ )}
347
+ {!signedOut && windows.length > 0 && account.usage?.error ? <Text style={text.small}>{account.usage.error}</Text> : null}
348
+ {!signedOut && resets?.blockedReason ? <Text style={text.small}>{resets.blockedReason}</Text> : null}
349
+ </View>
350
+
351
+ {/* Pinned to the bottom, so cards side by side line up however much each one shows. */}
352
+ <View
353
+ style={{
354
+ marginTop: "auto",
355
+ minHeight: 38,
356
+ paddingTop: 10,
357
+ borderTopWidth: 1,
358
+ borderTopColor: theme.colors.border,
359
+ flexDirection: "row",
360
+ flexWrap: "wrap",
361
+ alignItems: "center",
362
+ justifyContent: "space-between",
363
+ columnGap: 8,
364
+ rowGap: 8,
365
+ }}
366
+ >
367
+ <Text style={[text.small, { flexShrink: 1 }]} numberOfLines={1}>
368
+ {freshness ? `${agents} · ${freshness}` : agents}
369
+ </Text>
370
+ {signedOut ? (
371
+ <Button theme={theme} size="small" tone="primary" icon="LogIn" label="Sign in" onPress={onSignIn} />
372
+ ) : resets ? (
373
+ <Button
374
+ theme={theme}
375
+ size="small"
376
+ tone={account.status === "limited" ? "primary" : "secondary"}
377
+ icon="TimerReset"
378
+ label="Use reset"
379
+ accessibilityLabel="Use a banked reset"
380
+ disabled={!resets.usableNow}
381
+ onPress={() => setConfirmReset(true)}
382
+ />
383
+ ) : null}
384
+ </View>
385
+ <Modal title="Use a banked reset?" open={confirmReset} onOpenChange={setConfirmReset}>
386
+ <Modal.Content>
387
+ <ResetConfirm
388
+ theme={theme}
389
+ store={store}
390
+ account={account}
391
+ onCancel={() => setConfirmReset(false)}
392
+ onFinished={(result) => {
393
+ setConfirmReset(false);
394
+ const { message, variant } = redeemToast(account.label, result);
395
+ if (variant === "error") toast.error(message);
396
+ else toast.show(message, { variant, durationMs: 5_000 });
397
+ }}
398
+ />
399
+ </Modal.Content>
400
+ </Modal>
401
+
402
+ {renaming ? (
403
+ <RenameModal theme={theme} account={account} store={store} onClose={() => setRenaming(false)} />
404
+ ) : null}
405
+ <Modal title={`Remove ${account.label}?`} open={confirmRemove} onOpenChange={setConfirmRemove}>
406
+ <Modal.Content>
407
+ <Text style={text.body}>
408
+ {account.family === "claude"
409
+ ? "This signs the account out on this machine and deletes its saved login. Agents using it move to the default account; their conversations are kept."
410
+ : "This signs the account out on this machine and deletes its saved login. New agents use the default account. Existing ChatGPT conversations on it can't move, so start new agents for them."}
411
+ </Text>
412
+ <View style={{ flexDirection: "row", gap: 8, justifyContent: "flex-end" }}>
413
+ <Button theme={theme} label="Cancel" onPress={() => setConfirmRemove(false)} />
414
+ <Button
415
+ theme={theme}
416
+ tone="danger"
417
+ icon="Trash2"
418
+ label="Remove"
419
+ busy={busy === "remove"}
420
+ onPress={() => void remove()}
421
+ />
422
+ </View>
423
+ </Modal.Content>
424
+ </Modal>
425
+ </Card>
426
+ );
427
+ }
428
+
429
+ function RenameModal({
430
+ theme,
431
+ account,
432
+ store,
433
+ onClose,
434
+ }: {
435
+ theme: Theme;
436
+ account: AccountView;
437
+ store: ZeroSubStore;
438
+ onClose(): void;
439
+ }) {
440
+ const text = useText(theme);
441
+ const toast = useToast();
442
+ const [label, setLabel] = useState(account.label);
443
+ const [saving, setSaving] = useState(false);
444
+ const save = useCallback(async () => {
445
+ const next = label.trim();
446
+ if (!next) return;
447
+ setSaving(true);
448
+ try {
449
+ await store.rpc(renameAccount, { accountId: account.id, label: next });
450
+ await store.refresh();
451
+ onClose();
452
+ } catch (error) {
453
+ toast.error(describe(error));
454
+ } finally {
455
+ setSaving(false);
456
+ }
457
+ }, [label, account.id, store, onClose, toast]);
458
+ const inputStyle = useMemo(
459
+ () => ({
460
+ color: theme.colors.foreground,
461
+ backgroundColor: theme.colors.surface2,
462
+ borderColor: theme.colors.border,
463
+ borderWidth: 1,
464
+ borderRadius: 8,
465
+ paddingHorizontal: 12,
466
+ paddingVertical: 10,
467
+ fontSize: 15,
468
+ }),
469
+ [theme],
470
+ );
471
+ return (
472
+ <Modal title="Rename account" open onOpenChange={(open) => (open ? undefined : onClose())}>
473
+ <Modal.Content>
474
+ <Text style={text.muted}>A short name you'll recognise in the composer, like "Work" or "Personal".</Text>
475
+ <TextInput
476
+ value={label}
477
+ onChangeText={setLabel}
478
+ autoFocus
479
+ maxLength={40}
480
+ placeholder="Account name"
481
+ placeholderTextColor={theme.colors.foregroundMuted}
482
+ onSubmitEditing={() => void save()}
483
+ style={inputStyle}
484
+ accessibilityLabel="Account name"
485
+ />
486
+ <View style={{ flexDirection: "row", gap: 8, justifyContent: "flex-end" }}>
487
+ <Button theme={theme} label="Cancel" onPress={onClose} />
488
+ <Button
489
+ theme={theme}
490
+ tone="primary"
491
+ label="Save"
492
+ busy={saving}
493
+ disabled={!label.trim()}
494
+ onPress={() => void save()}
495
+ />
496
+ </View>
497
+ </Modal.Content>
498
+ </Modal>
499
+ );
500
+ }
501
+
502
+ function Avatar({ theme, label }: { theme: Theme; label: string }) {
503
+ const initial = label.trim().charAt(0).toUpperCase() || "?";
504
+ return (
505
+ <View
506
+ style={{
507
+ width: 36,
508
+ height: 36,
509
+ borderRadius: 18,
510
+ alignItems: "center",
511
+ justifyContent: "center",
512
+ backgroundColor: theme.colors.surface2,
513
+ borderWidth: 1,
514
+ borderColor: theme.colors.border,
515
+ }}
516
+ >
517
+ <Text style={{ color: theme.colors.foreground, fontSize: 15, fontWeight: "700" }}>{initial}</Text>
518
+ </View>
519
+ );
520
+ }
521
+
522
+ function AutomationSettings({ theme }: { theme: Theme }) {
523
+ const settings = useSettings(preferences);
524
+ const text = useText(theme);
525
+ if (settings.status === "loading") return null;
526
+ if (settings.status !== "ready") {
527
+ return <Text style={text.danger}>Preferences unavailable: {settings.error}</Text>;
528
+ }
529
+ const save = (patch: Partial<typeof settings.values>) =>
530
+ void settings.save({ ...settings.values, ...patch }, settings.revision);
531
+ return (
532
+ <View style={{ gap: 10 }}>
533
+ <Text style={text.heading} accessibilityRole="header">
534
+ Automatic switching
535
+ </Text>
536
+ <SettingsCard>
537
+ <SettingsSwitch
538
+ label="Switch accounts when one hits its limit"
539
+ hint="Agents move to the account with the most room left."
540
+ value={settings.values.autoSwitch}
541
+ disabled={settings.saving}
542
+ onValueChange={(autoSwitch) => save({ autoSwitch })}
543
+ />
544
+ <SettingsSwitch
545
+ label="Keep going after a switch"
546
+ hint="Sends a short follow-up so the interrupted task continues."
547
+ value={settings.values.autoContinue}
548
+ disabled={settings.saving || !settings.values.autoSwitch}
549
+ onValueChange={(autoContinue) => save({ autoContinue })}
550
+ />
551
+ <SettingsSwitch
552
+ label="Spread new agents across accounts"
553
+ hint="New agents start on the account with the most room instead of the default."
554
+ value={settings.values.balanceNewAgents}
555
+ disabled={settings.saving}
556
+ onValueChange={(balanceNewAgents) => save({ balanceNewAgents })}
557
+ />
558
+ <SettingsSwitch
559
+ label="Use banked resets when every account is out"
560
+ hint="Spends one of the account's banked resets instead of stopping. Resets are scarce, so this is off unless you turn it on."
561
+ value={settings.values.autoRedeem}
562
+ disabled={settings.saving || !settings.values.autoSwitch}
563
+ onValueChange={(autoRedeem) => save({ autoRedeem })}
564
+ />
565
+ <SettingsSwitch
566
+ label="When every account is out, fork the chat to the other provider"
567
+ hint="A stopped Claude chat carries on in a new ChatGPT agent, or the other way round, with the conversation so far. The new agent gets no more permissions than the original; the original stays as it was."
568
+ value={settings.values.forkOtherProvider}
569
+ disabled={settings.saving || !settings.values.autoSwitch}
570
+ onValueChange={(forkOtherProvider) => save({ forkOtherProvider })}
571
+ />
572
+ </SettingsCard>
573
+ {settings.saveError ? <Text style={text.danger}>{settings.saveError}</Text> : null}
574
+ </View>
575
+ );
576
+ }
577
+
578
+ export function describeReopen(prefix: string, summary: ReopenSummary): string {
579
+ const parts = [prefix];
580
+ if (summary.continuedIn) parts.push(`continuing in “${summary.continuedIn.title}”`);
581
+ if (summary.reopened.length > 0) parts.push(`${summary.reopened.length} agent(s) switched`);
582
+ if (summary.deferred.length > 0) parts.push(`${summary.deferred.length} will switch after their current turn`);
583
+ if (summary.failed.length > 0) parts.push(`${summary.failed.length} will switch on their next restart`);
584
+ return parts.join(" · ");
585
+ }
586
+
587
+ function chunk<T>(items: T[], size: number): T[][] {
588
+ const rows: T[][] = [];
589
+ for (let i = 0; i < items.length; i += size) rows.push(items.slice(i, i + size));
590
+ return rows;
591
+ }
592
+