@appsupportkit/support-sdk 0.1.1 → 0.2.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 (110) hide show
  1. package/lib/commonjs/api.js +29 -0
  2. package/lib/commonjs/api.js.map +1 -1
  3. package/lib/commonjs/components/BottomSheet.js +67 -47
  4. package/lib/commonjs/components/BottomSheet.js.map +1 -1
  5. package/lib/commonjs/components/LauncherButton.js +177 -0
  6. package/lib/commonjs/components/LauncherButton.js.map +1 -0
  7. package/lib/commonjs/components/SupportButton.js +76 -146
  8. package/lib/commonjs/components/SupportButton.js.map +1 -1
  9. package/lib/commonjs/components/icons.js +74 -23
  10. package/lib/commonjs/components/icons.js.map +1 -1
  11. package/lib/commonjs/components/primitives.js +183 -38
  12. package/lib/commonjs/components/primitives.js.map +1 -1
  13. package/lib/commonjs/components/screens/ComposeScreen.js +115 -58
  14. package/lib/commonjs/components/screens/ComposeScreen.js.map +1 -1
  15. package/lib/commonjs/components/screens/HomeScreen.js +170 -115
  16. package/lib/commonjs/components/screens/HomeScreen.js.map +1 -1
  17. package/lib/commonjs/components/screens/ThreadScreen.js +222 -108
  18. package/lib/commonjs/components/screens/ThreadScreen.js.map +1 -1
  19. package/lib/commonjs/index.js +7 -0
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/push.js +103 -0
  22. package/lib/commonjs/push.js.map +1 -0
  23. package/lib/commonjs/theme.js +136 -17
  24. package/lib/commonjs/theme.js.map +1 -1
  25. package/lib/commonjs/types.js +7 -0
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/commonjs/unread.js +92 -0
  28. package/lib/commonjs/unread.js.map +1 -0
  29. package/lib/commonjs/useSupportThreads.js +286 -0
  30. package/lib/commonjs/useSupportThreads.js.map +1 -0
  31. package/lib/commonjs/utils.js +33 -0
  32. package/lib/commonjs/utils.js.map +1 -1
  33. package/lib/module/api.js +27 -0
  34. package/lib/module/api.js.map +1 -1
  35. package/lib/module/components/BottomSheet.js +68 -48
  36. package/lib/module/components/BottomSheet.js.map +1 -1
  37. package/lib/module/components/LauncherButton.js +172 -0
  38. package/lib/module/components/LauncherButton.js.map +1 -0
  39. package/lib/module/components/SupportButton.js +79 -149
  40. package/lib/module/components/SupportButton.js.map +1 -1
  41. package/lib/module/components/icons.js +72 -22
  42. package/lib/module/components/icons.js.map +1 -1
  43. package/lib/module/components/primitives.js +179 -39
  44. package/lib/module/components/primitives.js.map +1 -1
  45. package/lib/module/components/screens/ComposeScreen.js +118 -61
  46. package/lib/module/components/screens/ComposeScreen.js.map +1 -1
  47. package/lib/module/components/screens/HomeScreen.js +172 -117
  48. package/lib/module/components/screens/HomeScreen.js.map +1 -1
  49. package/lib/module/components/screens/ThreadScreen.js +228 -112
  50. package/lib/module/components/screens/ThreadScreen.js.map +1 -1
  51. package/lib/module/index.js +1 -0
  52. package/lib/module/index.js.map +1 -1
  53. package/lib/module/push.js +98 -0
  54. package/lib/module/push.js.map +1 -0
  55. package/lib/module/theme.js +135 -16
  56. package/lib/module/theme.js.map +1 -1
  57. package/lib/module/types.js +7 -0
  58. package/lib/module/types.js.map +1 -1
  59. package/lib/module/unread.js +83 -0
  60. package/lib/module/unread.js.map +1 -0
  61. package/lib/module/useSupportThreads.js +281 -0
  62. package/lib/module/useSupportThreads.js.map +1 -0
  63. package/lib/module/utils.js +30 -0
  64. package/lib/module/utils.js.map +1 -1
  65. package/lib/typescript/api.d.ts +17 -1
  66. package/lib/typescript/api.d.ts.map +1 -1
  67. package/lib/typescript/components/BottomSheet.d.ts.map +1 -1
  68. package/lib/typescript/components/LauncherButton.d.ts +14 -0
  69. package/lib/typescript/components/LauncherButton.d.ts.map +1 -0
  70. package/lib/typescript/components/SupportButton.d.ts +3 -3
  71. package/lib/typescript/components/SupportButton.d.ts.map +1 -1
  72. package/lib/typescript/components/icons.d.ts +13 -2
  73. package/lib/typescript/components/icons.d.ts.map +1 -1
  74. package/lib/typescript/components/primitives.d.ts +35 -4
  75. package/lib/typescript/components/primitives.d.ts.map +1 -1
  76. package/lib/typescript/components/screens/ComposeScreen.d.ts.map +1 -1
  77. package/lib/typescript/components/screens/HomeScreen.d.ts +3 -2
  78. package/lib/typescript/components/screens/HomeScreen.d.ts.map +1 -1
  79. package/lib/typescript/components/screens/ThreadScreen.d.ts.map +1 -1
  80. package/lib/typescript/index.d.ts +2 -1
  81. package/lib/typescript/index.d.ts.map +1 -1
  82. package/lib/typescript/push.d.ts +18 -0
  83. package/lib/typescript/push.d.ts.map +1 -0
  84. package/lib/typescript/theme.d.ts +44 -3
  85. package/lib/typescript/theme.d.ts.map +1 -1
  86. package/lib/typescript/types.d.ts +37 -4
  87. package/lib/typescript/types.d.ts.map +1 -1
  88. package/lib/typescript/unread.d.ts +22 -0
  89. package/lib/typescript/unread.d.ts.map +1 -0
  90. package/lib/typescript/useSupportThreads.d.ts +28 -0
  91. package/lib/typescript/useSupportThreads.d.ts.map +1 -0
  92. package/lib/typescript/utils.d.ts +5 -0
  93. package/lib/typescript/utils.d.ts.map +1 -1
  94. package/package.json +8 -2
  95. package/src/api.ts +41 -1
  96. package/src/components/BottomSheet.tsx +61 -43
  97. package/src/components/LauncherButton.tsx +217 -0
  98. package/src/components/SupportButton.tsx +81 -162
  99. package/src/components/icons.tsx +77 -19
  100. package/src/components/primitives.tsx +217 -36
  101. package/src/components/screens/ComposeScreen.tsx +131 -61
  102. package/src/components/screens/HomeScreen.tsx +168 -117
  103. package/src/components/screens/ThreadScreen.tsx +289 -119
  104. package/src/index.tsx +3 -0
  105. package/src/push.ts +97 -0
  106. package/src/theme.ts +165 -18
  107. package/src/types.ts +39 -4
  108. package/src/unread.ts +91 -0
  109. package/src/useSupportThreads.ts +372 -0
  110. package/src/utils.ts +33 -0
@@ -1,23 +1,142 @@
1
1
  "use strict";
2
2
 
3
3
  // The SDK consumes the same design tokens as the admin dashboard, so both
4
- // surfaces look like one product.
4
+ // surfaces look like one product. On top of those it adds the few values
5
+ // that only exist on mobile: sheet/bubble radii and the elevation used by
6
+ // the launcher and the sheet (the web side gets those from CSS).
5
7
  import { darkColors, lightColors, motion, radii, spacing } from '@appsupportkit/design-tokens';
6
- export const supportDarkTheme = {
7
- name: 'dark',
8
- colors: darkColors,
9
- spacing,
10
- radii,
11
- motion
8
+ /** Rounder than the dashboard: touch targets read better with more radius. */
9
+ export const supportRadii = {
10
+ ...radii,
11
+ control: 10,
12
+ card: 14,
13
+ cardLg: 18,
14
+ /** Message bubbles. */
15
+ bubble: 18,
16
+ /** The tight corner on a bubble's sender side. */
17
+ bubbleTail: 6,
18
+ sheet: 24,
19
+ pill: 999
12
20
  };
13
- export const supportLightTheme = {
14
- name: 'light',
15
- colors: lightColors,
16
- spacing,
17
- radii,
18
- motion
19
- };
20
- export function resolveTheme(name) {
21
- return name === 'light' ? supportLightTheme : supportDarkTheme;
21
+
22
+ /**
23
+ * The launcher sits on the host app's own background rather than on an SDK
24
+ * surface, so the two themes need different treatment: on near-black a
25
+ * solid fill needs a hairline to separate from the background and a black
26
+ * shadow, while on white the accent-tinted shadow does that work and a
27
+ * borderless mark has to be darkened to stay legible.
28
+ */
29
+
30
+ // Color helpers come first: the themes below are built at module load, so
31
+ // anything they reach for has to already be initialized. (A `const` used
32
+ // before its definition survives tsc but lands as `undefined` on Hermes.)
33
+ const HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
34
+ function parseHex(color) {
35
+ const match = HEX.exec(color.trim());
36
+ const digits = match?.[1];
37
+ if (digits === undefined) return null;
38
+ const hex = digits.length === 3 ? digits.split('').map(c => c + c).join('') : digits;
39
+ return [parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16)];
40
+ }
41
+ function mix([r, g, b], target, amount) {
42
+ const channel = c => Math.round(c + (target - c) * amount);
43
+ return `rgb(${channel(r)}, ${channel(g)}, ${channel(b)})`;
44
+ }
45
+ function shadowsFor(name, accent) {
46
+ const dark = name === 'dark';
47
+ return {
48
+ launcher: {
49
+ // Tinting the launcher's shadow with the accent is what makes it read
50
+ // as lifted rather than pasted on.
51
+ shadowColor: dark ? '#000000' : accent,
52
+ shadowOpacity: dark ? 0.45 : 0.3,
53
+ shadowRadius: 14,
54
+ shadowOffset: {
55
+ width: 0,
56
+ height: 6
57
+ },
58
+ elevation: 8
59
+ },
60
+ sheet: {
61
+ shadowColor: '#000000',
62
+ shadowOpacity: dark ? 0.5 : 0.16,
63
+ shadowRadius: 24,
64
+ shadowOffset: {
65
+ width: 0,
66
+ height: -6
67
+ },
68
+ elevation: 24
69
+ },
70
+ badge: {
71
+ shadowColor: '#000000',
72
+ shadowOpacity: 0.25,
73
+ shadowRadius: 3,
74
+ shadowOffset: {
75
+ width: 0,
76
+ height: 1
77
+ },
78
+ elevation: 3
79
+ }
80
+ };
81
+ }
82
+ function launcherFor(name, accent) {
83
+ const rgb = parseHex(accent);
84
+ return {
85
+ solidRing: name === 'dark' ? 'rgba(255, 255, 255, 0.14)' : 'rgba(0, 0, 0, 0.06)',
86
+ // On a dark app background the raw accent is too close to the surface
87
+ // to read as a glyph; lift it toward white.
88
+ minimalMark: name === 'dark' && rgb !== null ? mix(rgb, 255, 0.35) : accent
89
+ };
90
+ }
91
+ function buildTheme(name, colors) {
92
+ return {
93
+ name,
94
+ colors,
95
+ spacing,
96
+ radii: supportRadii,
97
+ motion,
98
+ shadows: shadowsFor(name, colors.accent),
99
+ launcher: launcherFor(name, colors.accent)
100
+ };
101
+ }
102
+ export const supportDarkTheme = buildTheme('dark', darkColors);
103
+ export const supportLightTheme = buildTheme('light', lightColors);
104
+
105
+ /**
106
+ * Derives the accent family from a single brand color: a pressed shade, the
107
+ * 12% wash used behind chips and own-message bubbles, and a foreground that
108
+ * stays legible on top (dark text on light brands, white on dark ones).
109
+ */
110
+ function withAccent(theme, accent) {
111
+ const rgb = parseHex(accent);
112
+ if (!rgb) return theme;
113
+ const [r, g, b] = rgb;
114
+ // Relative luminance, sRGB coefficients — good enough to pick a foreground.
115
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
116
+ const colors = {
117
+ ...theme.colors,
118
+ accent,
119
+ accentHover: mix(rgb, theme.name === 'dark' ? 255 : 0, 0.12),
120
+ accentMuted: `rgba(${r}, ${g}, ${b}, 0.12)`,
121
+ accentForeground: luminance > 0.62 ? '#111113' : '#FFFFFF',
122
+ statusOpen: accent,
123
+ statusOpenBg: `rgba(${r}, ${g}, ${b}, 0.10)`,
124
+ focusRing: accent
125
+ };
126
+ return {
127
+ ...theme,
128
+ colors,
129
+ shadows: shadowsFor(theme.name, accent),
130
+ launcher: launcherFor(theme.name, accent)
131
+ };
132
+ }
133
+
134
+ /**
135
+ * @param name "light" | "dark" (default dark).
136
+ * @param accentColor Optional brand color (hex) replacing the default accent.
137
+ */
138
+ export function resolveTheme(name, accentColor) {
139
+ const base = name === 'light' ? supportLightTheme : supportDarkTheme;
140
+ return accentColor ? withAccent(base, accentColor) : base;
22
141
  }
23
142
  //# sourceMappingURL=theme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["darkColors","lightColors","motion","radii","spacing","supportDarkTheme","name","colors","supportLightTheme","resolveTheme"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;AAAA;AACA;AACA,SACEA,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,KAAK,EACLC,OAAO,QAEF,8BAA8B;AAWrC,OAAO,MAAMC,gBAA8B,GAAG;EAC5CC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAEP,UAAU;EAClBI,OAAO;EACPD,KAAK;EACLD;AACF,CAAC;AAED,OAAO,MAAMM,iBAA+B,GAAG;EAC7CF,IAAI,EAAE,OAAO;EACbC,MAAM,EAAEN,WAAW;EACnBG,OAAO;EACPD,KAAK;EACLD;AACF,CAAC;AAED,OAAO,SAASO,YAAYA,CAACH,IAA2B,EAAgB;EACtE,OAAOA,IAAI,KAAK,OAAO,GAAGE,iBAAiB,GAAGH,gBAAgB;AAChE","ignoreList":[]}
1
+ {"version":3,"names":["darkColors","lightColors","motion","radii","spacing","supportRadii","control","card","cardLg","bubble","bubbleTail","sheet","pill","HEX","parseHex","color","match","exec","trim","digits","undefined","hex","length","split","map","c","join","parseInt","slice","mix","r","g","b","target","amount","channel","Math","round","shadowsFor","name","accent","dark","launcher","shadowColor","shadowOpacity","shadowRadius","shadowOffset","width","height","elevation","badge","launcherFor","rgb","solidRing","minimalMark","buildTheme","colors","shadows","supportDarkTheme","supportLightTheme","withAccent","theme","luminance","accentHover","accentMuted","accentForeground","statusOpen","statusOpenBg","focusRing","resolveTheme","accentColor","base"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,SACEA,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,KAAK,EACLC,OAAO,QAEF,8BAA8B;AAIrC;AACA,OAAO,MAAMC,YAAY,GAAG;EAC1B,GAAGF,KAAK;EACRG,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACV;EACAC,MAAM,EAAE,EAAE;EACV;EACAC,UAAU,EAAE,CAAC;EACbC,KAAK,EAAE,EAAE;EACTC,IAAI,EAAE;AACR,CAAU;;AAWV;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA,MAAMC,GAAG,GAAG,gCAAgC;AAE5C,SAASC,QAAQA,CAACC,KAAa,EAAmC;EAChE,MAAMC,KAAK,GAAGH,GAAG,CAACI,IAAI,CAACF,KAAK,CAACG,IAAI,CAAC,CAAC,CAAC;EACpC,MAAMC,MAAM,GAAGH,KAAK,GAAG,CAAC,CAAC;EACzB,IAAIG,MAAM,KAAKC,SAAS,EAAE,OAAO,IAAI;EACrC,MAAMC,GAAG,GACPF,MAAM,CAACG,MAAM,KAAK,CAAC,GACfH,MAAM,CACHI,KAAK,CAAC,EAAE,CAAC,CACTC,GAAG,CAAEC,CAAC,IAAKA,CAAC,GAAGA,CAAC,CAAC,CACjBC,IAAI,CAAC,EAAE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AAC,EAAEC,CAAC,EAAEC,CAAC,CAAC,GAAGoB,GAAG;EACrB;EACA,MAAMU,SAAS,GAAG,CAAC,KAAK,GAAGhC,CAAC,GAAG,KAAK,GAAGC,CAAC,GAAG,KAAK,GAAGC,CAAC,IAAI,GAAG;EAC3D,MAAMwB,MAAmB,GAAG;IAC1B,GAAGK,KAAK,CAACL,MAAM;IACfhB,MAAM;IACNuB,WAAW,EAAElC,GAAG,CAACuB,GAAG,EAAES,KAAK,CAACtB,IAAI,KAAK,MAAM,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC;IAC5DyB,WAAW,EAAE,QAAQlC,CAAC,KAAKC,CAAC,KAAKC,CAAC,SAAS;IAC3CiC,gBAAgB,EAAEH,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS;IAC1DI,UAAU,EAAE1B,MAAM;IAClB2B,YAAY,EAAE,QAAQrC,CAAC,KAAKC,CAAC,KAAKC,CAAC,SAAS;IAC5CoC,SAAS,EAAE5B;EACb,CAAC;EACD,OAAO;IACL,GAAGqB,KAAK;IACRL,MAAM;IACNC,OAAO,EAAEnB,UAAU,CAACuB,KAAK,CAACtB,IAAI,EAAEC,MAAM,CAAC;IACvCE,QAAQ,EAAES,WAAW,CAACU,KAAK,CAACtB,IAAI,EAAEC,MAAM;EAC1C,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAAS6B,YAAYA,CAC1B9B,IAA2B,EAC3B+B,WAAoB,EACN;EACd,MAAMC,IAAI,GAAGhC,IAAI,KAAK,OAAO,GAAGoB,iBAAiB,GAAGD,gBAAgB;EACpE,OAAOY,WAAW,GAAGV,UAAU,CAACW,IAAI,EAAED,WAAW,CAAC,GAAGC,IAAI;AAC3D","ignoreList":[]}
@@ -1,5 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * How the launcher renders:
5
+ * solid — accent fill, elevated. The floating action button.
6
+ * soft — app surface + hairline border. Sits in a header or toolbar.
7
+ * minimal — bare mark, no fill or border. Sits in a nav bar.
8
+ */
9
+
3
10
  export const QUERY_TYPE_LABEL = {
4
11
  feedback: 'Feedback',
5
12
  feature_request: 'Feature request',
@@ -1 +1 @@
1
- {"version":3,"names":["QUERY_TYPE_LABEL","feedback","feature_request","bug_report","USER_MESSAGE_MIN","USER_MESSAGE_MAX"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAsEA,OAAO,MAAMA,gBAA2C,GAAG;EACzDC,QAAQ,EAAE,UAAU;EACpBC,eAAe,EAAE,iBAAiB;EAClCC,UAAU,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG,EAAE;AAClC,OAAO,MAAMC,gBAAgB,GAAG,GAAG","ignoreList":[]}
1
+ {"version":3,"names":["QUERY_TYPE_LABEL","feedback","feature_request","bug_report","USER_MESSAGE_MIN","USER_MESSAGE_MAX"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AAQA;AACA;AACA;AACA;AACA;AACA;;AA4FA,OAAO,MAAMA,gBAA2C,GAAG;EACzDC,QAAQ,EAAE,UAAU;EACpBC,eAAe,EAAE,iBAAiB;EAClCC,UAAU,EAAE;AACd,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG,EAAE;AAClC,OAAO,MAAMC,gBAAgB,GAAG,GAAG","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ // Unread accounting.
4
+ //
5
+ // The server counts a thread's unread as "admin messages newer than the
6
+ // user's read receipt". That number is authoritative, but it is always a
7
+ // little behind the device: between the moment the user opens a thread and
8
+ // the moment `mark-read` lands, every already-in-flight poll still reports
9
+ // the old count — which is what made the badge flicker back on after being
10
+ // cleared, and what made a thread the user was actively reading accumulate
11
+ // unread replies.
12
+ //
13
+ // So the client keeps its own watermark per thread: the `created_at` of the
14
+ // newest admin message the user has actually seen. Those are *server*
15
+ // timestamps, so nothing here compares against the device clock.
16
+ //
17
+ // Displayed unread is then the stricter of the two counts, which is correct
18
+ // in both directions:
19
+ //
20
+ // read here, receipt not written yet → local watermark wins (0)
21
+ // read on another device → server count wins (0)
22
+
23
+ /** Watermark map: thread id → `created_at` (ms) of the newest seen reply. */
24
+
25
+ /** `created_at` (ms) of the newest admin message, or 0 if there are none. */
26
+ export function latestAdminMessageAt(thread) {
27
+ let latest = 0;
28
+ for (const message of thread.messages) {
29
+ if (message.sender !== 'admin') continue;
30
+ const at = Date.parse(message.created_at);
31
+ if (Number.isFinite(at) && at > latest) latest = at;
32
+ }
33
+ return latest;
34
+ }
35
+
36
+ /** Admin messages in `thread` newer than `watermark`. */
37
+ export function unreadSince(thread, watermark) {
38
+ let count = 0;
39
+ for (const message of thread.messages) {
40
+ if (message.sender !== 'admin') continue;
41
+ const at = Date.parse(message.created_at);
42
+ if (Number.isFinite(at) && at > watermark) count += 1;
43
+ }
44
+ return count;
45
+ }
46
+
47
+ /**
48
+ * Returns `thread` with `unread_count` narrowed by what this device knows
49
+ * the user has read. Identity is preserved when nothing changes so lists
50
+ * stay referentially stable between polls.
51
+ */
52
+ export function reconcileThread(thread, watermarks) {
53
+ const watermark = watermarks.get(thread.id);
54
+ if (watermark === undefined || thread.unread_count === 0) return thread;
55
+ const unread = Math.min(thread.unread_count, unreadSince(thread, watermark));
56
+ return unread === thread.unread_count ? thread : {
57
+ ...thread,
58
+ unread_count: unread
59
+ };
60
+ }
61
+ export function reconcileThreads(threads, watermarks) {
62
+ return threads.map(thread => reconcileThread(thread, watermarks));
63
+ }
64
+ export function sumUnread(threads) {
65
+ return threads.reduce((total, thread) => total + thread.unread_count, 0);
66
+ }
67
+
68
+ /**
69
+ * Drops watermarks the server has caught up on (its own count is already 0)
70
+ * and ones for threads that no longer exist, so the map can't grow without
71
+ * bound over a long session.
72
+ */
73
+ export function pruneWatermarks(watermarks, serverThreads) {
74
+ const keep = new Map();
75
+ for (const thread of serverThreads) {
76
+ const watermark = watermarks.get(thread.id);
77
+ if (watermark !== undefined && thread.unread_count > 0) {
78
+ keep.set(thread.id, watermark);
79
+ }
80
+ }
81
+ return keep;
82
+ }
83
+ //# sourceMappingURL=unread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["latestAdminMessageAt","thread","latest","message","messages","sender","at","Date","parse","created_at","Number","isFinite","unreadSince","watermark","count","reconcileThread","watermarks","get","id","undefined","unread_count","unread","Math","min","reconcileThreads","threads","map","sumUnread","reduce","total","pruneWatermarks","serverThreads","keep","Map","set"],"sourceRoot":"../../src","sources":["unread.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAGA;AACA,OAAO,SAASA,oBAAoBA,CAACC,MAAc,EAAU;EAC3D,IAAIC,MAAM,GAAG,CAAC;EACd,KAAK,MAAMC,OAAO,IAAIF,MAAM,CAACG,QAAQ,EAAE;IACrC,IAAID,OAAO,CAACE,MAAM,KAAK,OAAO,EAAE;IAChC,MAAMC,EAAE,GAAGC,IAAI,CAACC,KAAK,CAACL,OAAO,CAACM,UAAU,CAAC;IACzC,IAAIC,MAAM,CAACC,QAAQ,CAACL,EAAE,CAAC,IAAIA,EAAE,GAAGJ,MAAM,EAAEA,MAAM,GAAGI,EAAE;EACrD;EACA,OAAOJ,MAAM;AACf;;AAEA;AACA,OAAO,SAASU,WAAWA,CAACX,MAAc,EAAEY,SAAiB,EAAU;EACrE,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,MAAMX,OAAO,IAAIF,MAAM,CAACG,QAAQ,EAAE;IACrC,IAAID,OAAO,CAACE,MAAM,KAAK,OAAO,EAAE;IAChC,MAAMC,EAAE,GAAGC,IAAI,CAACC,KAAK,CAACL,OAAO,CAACM,UAAU,CAAC;IACzC,IAAIC,MAAM,CAACC,QAAQ,CAACL,EAAE,CAAC,IAAIA,EAAE,GAAGO,SAAS,EAAEC,KAAK,IAAI,CAAC;EACvD;EACA,OAAOA,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,O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EACF;EACA,OAAOmB,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+
3
+ // Threads + unread state for the SDK: fetching, poll cadence, and read
4
+ // tracking. Kept out of SupportButton so the rules below live in one place.
5
+ //
6
+ // Three invariants make the badge trustworthy:
7
+ //
8
+ // 1. Responses are applied in issue order (`appliedSeq`), so a slow poll
9
+ // can never overwrite a newer one.
10
+ // 2. The badge-only endpoint returns a bare number that cannot be
11
+ // reconciled against local reads, so its answer is dropped when a read
12
+ // happened while it was in flight (`readEpoch`), and it isn't used at
13
+ // all while any `mark-read` is still unconfirmed — the full endpoint is
14
+ // polled instead, since that payload *can* be reconciled.
15
+ // 3. `mark-read` failures are retried instead of swallowed, and the local
16
+ // watermark holds the UI correct in the meantime.
17
+ import { useCallback, useEffect, useRef, useState } from 'react';
18
+ import { AppState } from 'react-native';
19
+ import { getThreads, getUnreadCount, markRead, SupportApiError } from './api';
20
+ import { latestAdminMessageAt, pruneWatermarks, reconcileThreads, sumUnread } from './unread';
21
+
22
+ // Poll cadence by context: fast where latency is felt (staring at a thread
23
+ // waiting for a reply), slow when the sheet is closed — and the idle tick
24
+ // uses the count-only endpoint, so it costs ~18 bytes instead of the full
25
+ // thread list.
26
+ const THREAD_POLL_MS = 5_000;
27
+ const SHEET_POLL_MS = 15_000;
28
+ export const IDLE_POLL_MS = 60_000;
29
+ const MIN_POLL_MS = 3_000;
30
+
31
+ // A failed mark-read used to be dropped on the floor, which resurrected the
32
+ // badge on the next poll. Retry a few times with backoff; anything still
33
+ // unconfirmed after that is picked up by the next poll tick or foreground.
34
+ const MARK_READ_MAX_ATTEMPTS = 4;
35
+ const MARK_READ_BACKOFF_MS = 1_500;
36
+
37
+ /**
38
+ * Load failures the user can act on say so; the rest stay neutral. A 401 is
39
+ * an integration mistake — the end user retrying forever won't fix a key
40
+ * that doesn't match the app — so the real cause is logged for whoever is
41
+ * running the build instead of hidden behind "couldn't load".
42
+ */
43
+ function loadErrorMessage(e) {
44
+ if (e instanceof SupportApiError) {
45
+ if (e.offline) return "You're offline — check your connection";
46
+ if (e.status === 401 || e.status === 403) {
47
+ if (__DEV__) {
48
+ console.error('SupportButton: the support API rejected this app (401). Check that ' + '`apiKey` is the key shown when the app was registered and that ' + '`appName` matches that app exactly.');
49
+ }
50
+ return 'Support is unavailable right now';
51
+ }
52
+ if (e.status === 429) return 'Too many requests — try again in a bit';
53
+ }
54
+ return "Couldn't load your conversations";
55
+ }
56
+ export function useSupportThreads({
57
+ config,
58
+ revenuecatId,
59
+ enabled,
60
+ sheetOpen,
61
+ activeThreadId,
62
+ idlePollMs
63
+ }) {
64
+ const [threads, setThreads] = useState(null);
65
+ const [totalUnread, setTotalUnread] = useState(0);
66
+ const [loading, setLoading] = useState(false);
67
+ const [refreshing, setRefreshing] = useState(false);
68
+ const [error, setError] = useState(null);
69
+ const mounted = useRef(true);
70
+ /** Last server payload, before local read reconciliation. */
71
+ const rawThreads = useRef(null);
72
+ const watermarks = useRef(new Map());
73
+ const reads = useRef(new Map());
74
+ const requestSeq = useRef(0);
75
+ const appliedSeq = useRef(0);
76
+ const readEpoch = useRef(0);
77
+ const activeThreadIdRef = useRef(activeThreadId);
78
+ useEffect(() => {
79
+ activeThreadIdRef.current = activeThreadId;
80
+ }, [activeThreadId]);
81
+ useEffect(() => {
82
+ mounted.current = true;
83
+ const timers = reads.current;
84
+ return () => {
85
+ mounted.current = false;
86
+ for (const attempt of timers.values()) {
87
+ if (attempt.timer !== null) clearTimeout(attempt.timer);
88
+ }
89
+ timers.clear();
90
+ };
91
+ }, []);
92
+ const publish = useCallback(() => {
93
+ const raw = rawThreads.current;
94
+ if (raw === null) return;
95
+ const reconciled = reconcileThreads(raw, watermarks.current);
96
+ setThreads(reconciled);
97
+ setTotalUnread(sumUnread(reconciled));
98
+ }, []);
99
+
100
+ /** POSTs the receipt, retrying transient failures with backoff. */
101
+ const sendRead = useCallback(threadId => {
102
+ const attempt = reads.current.get(threadId);
103
+ if (!attempt || attempt.inFlight !== null) return;
104
+ const covers = attempt.target;
105
+ attempt.inFlight = covers;
106
+ attempt.timer = null;
107
+ markRead(config, {
108
+ queryId: threadId,
109
+ revenuecatId
110
+ }).then(() => {
111
+ if (!mounted.current) return;
112
+ const current = reads.current.get(threadId);
113
+ if (!current) return;
114
+ current.inFlight = null;
115
+ // A reply that landed while this request was in flight isn't
116
+ // covered by the receipt it just wrote — send one more.
117
+ if (current.target > covers) {
118
+ current.attempts = 0;
119
+ sendRead(threadId);
120
+ return;
121
+ }
122
+ reads.current.delete(threadId);
123
+ // The receipt now exists server-side, so any response still in
124
+ // flight predates it and must not be trusted for unread counts.
125
+ readEpoch.current += 1;
126
+ }).catch(() => {
127
+ if (!mounted.current) return;
128
+ const current = reads.current.get(threadId);
129
+ if (!current) return;
130
+ current.inFlight = null;
131
+ current.attempts += 1;
132
+ if (current.attempts >= MARK_READ_MAX_ATTEMPTS) return;
133
+ current.timer = setTimeout(() => sendRead(threadId), MARK_READ_BACKOFF_MS * 2 ** (current.attempts - 1));
134
+ });
135
+ }, [config, revenuecatId]);
136
+
137
+ /** Re-drives receipts that gave up earlier (next poll tick / foreground). */
138
+ const flushReads = useCallback(() => {
139
+ for (const [threadId, attempt] of reads.current) {
140
+ if (attempt.inFlight !== null || attempt.timer !== null) continue;
141
+ attempt.attempts = 0;
142
+ sendRead(threadId);
143
+ }
144
+ }, [sendRead]);
145
+
146
+ /**
147
+ * Records that the user has seen every reply currently in `threadId` and
148
+ * persists it. Idempotent: re-marking a thread with nothing new is a
149
+ * no-op, so the 5s in-thread poll doesn't spam the endpoint.
150
+ */
151
+ const markThreadRead = useCallback(threadId => {
152
+ const thread = rawThreads.current?.find(t => t.id === threadId);
153
+ if (!thread) return;
154
+ const latest = latestAdminMessageAt(thread);
155
+ if (latest === 0) return;
156
+ if (latest <= (watermarks.current.get(threadId) ?? 0)) return;
157
+ watermarks.current.set(threadId, latest);
158
+ // Invalidate the bare counts of any request already in flight.
159
+ readEpoch.current += 1;
160
+ publish();
161
+ const attempt = reads.current.get(threadId);
162
+ if (attempt) attempt.target = latest;else {
163
+ reads.current.set(threadId, {
164
+ target: latest,
165
+ inFlight: null,
166
+ attempts: 0,
167
+ timer: null
168
+ });
169
+ }
170
+ sendRead(threadId);
171
+ }, [publish, sendRead]);
172
+ const fetchThreads = useCallback(async mode => {
173
+ if (!enabled) return;
174
+ const seq = requestSeq.current += 1;
175
+ // With nothing cached there is no list to pull down, so a retry shows
176
+ // the skeleton rather than a spinner nobody can see.
177
+ const blank = rawThreads.current === null;
178
+ const spinner = mode === 'user' && !blank;
179
+ const skeleton = mode !== 'background' && blank;
180
+ if (spinner) setRefreshing(true);
181
+ if (skeleton) setLoading(true);
182
+ try {
183
+ const data = await getThreads(config, revenuecatId);
184
+ if (!mounted.current) return;
185
+ // A slower earlier request must never clobber a newer answer.
186
+ if (seq <= appliedSeq.current) return;
187
+ appliedSeq.current = seq;
188
+ rawThreads.current = data.threads;
189
+ watermarks.current = pruneWatermarks(watermarks.current, data.threads);
190
+ setError(null);
191
+ publish();
192
+
193
+ // Replies that arrived while the user is sitting in the thread are
194
+ // read on arrival — otherwise the badge climbed while they read.
195
+ const active = activeThreadIdRef.current;
196
+ if (active !== null) markThreadRead(active);
197
+ flushReads();
198
+ } catch (e) {
199
+ if (!mounted.current) return;
200
+ // A failed background poll must not blow away cached threads.
201
+ if (rawThreads.current === null) setError(loadErrorMessage(e));
202
+ } finally {
203
+ if (mounted.current) {
204
+ if (spinner) setRefreshing(false);
205
+ if (skeleton) setLoading(false);
206
+ }
207
+ }
208
+ }, [config, enabled, revenuecatId, publish, markThreadRead, flushReads]);
209
+
210
+ /** Badge-only refresh — the cheap endpoint, used while idle. */
211
+ const fetchCount = useCallback(async () => {
212
+ if (!enabled) return;
213
+ const seq = requestSeq.current += 1;
214
+ const epoch = readEpoch.current;
215
+ try {
216
+ const data = await getUnreadCount(config, revenuecatId);
217
+ if (!mounted.current) return;
218
+ // This payload is just a number: there is no way to subtract reads
219
+ // that happened while it was in flight, so discard it instead.
220
+ if (readEpoch.current !== epoch) return;
221
+ if (seq <= appliedSeq.current) return;
222
+ appliedSeq.current = seq;
223
+ setTotalUnread(data.total_unread);
224
+ } catch {
225
+ // Best effort: the next tick or the next sheet open reconciles.
226
+ }
227
+ }, [config, enabled, revenuecatId]);
228
+
229
+ // Initial load.
230
+ useEffect(() => {
231
+ void fetchThreads('initial');
232
+ }, [fetchThreads]);
233
+
234
+ // Opening the sheet always shows fresh data.
235
+ useEffect(() => {
236
+ if (sheetOpen) void fetchThreads('background');
237
+ }, [sheetOpen, fetchThreads]);
238
+
239
+ // Opening a thread marks it read immediately, before the next poll.
240
+ useEffect(() => {
241
+ if (activeThreadId !== null) markThreadRead(activeThreadId);
242
+ }, [activeThreadId, markThreadRead]);
243
+
244
+ // Cadence follows what the user is looking at; the app returning to the
245
+ // foreground always ticks.
246
+ useEffect(() => {
247
+ if (!enabled) return;
248
+ const idle = !sheetOpen;
249
+ const intervalMs = idle ? idlePollMs : activeThreadId !== null ? THREAD_POLL_MS : SHEET_POLL_MS;
250
+ const tick = () => {
251
+ // While a receipt is unconfirmed the count-only endpoint would report
252
+ // replies the user has already read, so pay for the full payload.
253
+ if (idle && reads.current.size === 0) void fetchCount();else void fetchThreads('background');
254
+ };
255
+
256
+ // Clamped so a typo like `pollIntervalMs={30}` can't hammer the API;
257
+ // 0 (or negative) disables idle polling entirely.
258
+ const timer = intervalMs > 0 ? setInterval(tick, Math.max(intervalMs, MIN_POLL_MS)) : null;
259
+ const appStateSub = AppState.addEventListener('change', state => {
260
+ if (state === 'active') tick();
261
+ });
262
+ return () => {
263
+ if (timer !== null) clearInterval(timer);
264
+ appStateSub.remove();
265
+ };
266
+ }, [enabled, sheetOpen, activeThreadId, idlePollMs, fetchThreads, fetchCount]);
267
+ const refresh = useCallback(() => {
268
+ void fetchThreads('user');
269
+ }, [fetchThreads]);
270
+ const reload = useCallback(() => fetchThreads('background'), [fetchThreads]);
271
+ return {
272
+ threads,
273
+ totalUnread,
274
+ loading,
275
+ refreshing,
276
+ error,
277
+ refresh,
278
+ reload
279
+ };
280
+ }
281
+ //# sourceMappingURL=useSupportThreads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useRef","useState","AppState","getThreads","getUnreadCount","markRead","SupportApiError","latestAdminMessageAt","pruneWatermarks","reconcileThreads","sumUnread","THREAD_POLL_MS","SHEET_POLL_MS","IDLE_POLL_MS","MIN_POLL_MS","MARK_READ_MAX_ATTEMPTS","MARK_READ_BACKOFF_MS","loadErrorMessage","e","offline","status","__DEV__","console","error","useSupportThreads","config","revenuecatId","enabled","sheetOpen","activeThreadId","idlePollMs","threads","setThreads","totalUnread","setTotalUnread","loading","setLoading","refreshing","setRefreshing","setError","mounted","rawThreads","watermarks","Map","reads","requestSeq","appliedSeq","readEpoch","activeThreadIdRef","current","timers","attempt","values","timer","clearTimeout","clear","publish","raw","reconciled","sendRead","threadId","get","inFlight","covers","target","queryId","then","attempts","delete","catch","setTimeout","flushReads","markThreadRead","thread","find","t","id","latest","set","fetchThreads","mode","seq","blank","spinner","skeleton","data","active","fetchCount","epoch","total_unread","idle","intervalMs","tick","size","setInterval","Math","max","appStateSub","addEventListener","state","clearInterval","remove","refresh","reload"],"sourceRoot":"../../src","sources":["useSupportThreads.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChE,SAASC,QAAQ,QAAQ,cAAc;AACvC,SACEC,UAAU,EACVC,cAAc,EACdC,QAAQ,EACRC,eAAe,QAEV,OAAO;AAEd,SACEC,oBAAoB,EACpBC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,QAEJ,UAAU;;AAEjB;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,KAAK;AAC5B,MAAMC,aAAa,GAAG,MAAM;AAC5B,O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,MAAM,CAAC,CAAC;IACtB,CAAC;EACH,CAAC,EAAE,CACD1E,OAAO,EACPC,SAAS,EACTC,cAAc,EACdC,UAAU,EACViD,YAAY,EACZQ,UAAU,CACX,CAAC;EAEF,MAAMe,OAAO,GAAGxG,WAAW,CAAC,MAAM;IAChC,KAAKiF,YAAY,CAAC,MAAM,CAAC;EAC3B,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;EAElB,MAAMwB,MAAM,GAAGzG,WAAW,CAAC,MAAMiF,YAAY,CAAC,YAAY,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;EAE5E,OAAO;IACLhD,OAAO;IACPE,WAAW;IACXE,OAAO;IACPE,UAAU;IACVd,KAAK;IACL+E,OAAO;IACPC;EACF,CAAC;AACH","ignoreList":[]}
@@ -25,6 +25,36 @@ export function formatDate(iso) {
25
25
  });
26
26
  }
27
27
 
28
+ /** "14:32" in the device's locale — shown under a group of messages. */
29
+ export function formatTime(iso) {
30
+ return new Date(iso).toLocaleTimeString(undefined, {
31
+ hour: 'numeric',
32
+ minute: '2-digit'
33
+ });
34
+ }
35
+ export function isSameDay(a, b) {
36
+ const first = new Date(a);
37
+ const second = new Date(b);
38
+ return first.getFullYear() === second.getFullYear() && first.getMonth() === second.getMonth() && first.getDate() === second.getDate();
39
+ }
40
+
41
+ /** Date separator label: Today / Yesterday / "Mon, 5 Jan". */
42
+ export function dayLabel(iso) {
43
+ const now = new Date();
44
+ if (isSameDay(iso, now.toISOString())) return 'Today';
45
+ const yesterday = new Date(now.getTime() - 86_400_000);
46
+ if (isSameDay(iso, yesterday.toISOString())) return 'Yesterday';
47
+ const date = new Date(iso);
48
+ return date.toLocaleDateString(undefined, {
49
+ weekday: 'short',
50
+ month: 'short',
51
+ day: 'numeric',
52
+ ...(date.getFullYear() === now.getFullYear() ? {} : {
53
+ year: 'numeric'
54
+ })
55
+ });
56
+ }
57
+
28
58
  /** Dev-mode prop validation with actionable messages. */
29
59
  export function validateProps(props) {
30
60
  if (typeof props.appName !== 'string' || props.appName.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"names":["relativeTime","iso","then","Date","getTime","seconds","Math","max","floor","now","minutes","hours","days","weeks","months","formatDate","toLocaleDateString","undefined","year","month","day","validateProps","props","appName","length","apiKey","supabaseUrl","test","user","name","isPaid","revenuecatId","appVersion"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA;AACA,OAAO,SAASA,YAAYA,CAACC,GAAW,EAAU;EAChD,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAAC,CAAC;EACpC,MAAMC,OAAO,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAAC,CAACL,IAAI,CAACM,GAAG,CAAC,CAAC,GAAGP,IAAI,IAAI,IAAI,CAAC,CAAC;EACnE,IAAIG,OAAO,GAAG,EAAE,EAAE,OAAO,UAAU;EACnC,MAAMK,OAAO,GAAGJ,IAAI,CAACE,KAAK,CAACH,OAAO,GAAG,EAAE,CAAC;EACxC,IAAIK,OAAO,GAAG,EAAE,EAAE,OAAO,GAAGA,OAAO,OAAO;EAC1C,MAAMC,KAAK,GAAGL,IAAI,CAACE,KAAK,CAACE,OAAO,GAAG,EAAE,CAAC;EACtC,IAAIC,KAAK,GAAG,EAAE,EAAE,OAAO,GAAGA,KAAK,OAAO;EACtC,MAAMC,IAAI,GAAGN,IAAI,CAACE,KAAK,CAACG,KAAK,GAAG,EAAE,CAAC;EACnC,IAAIC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAGA,IAAI,OAAO;EACnC,MAAMC,KAAK,GAAGP,IAAI,CAACE,KAAK,CAACI,IAAI,GAAG,CAAC,CAAC;EAClC,IAAIC,KAAK,GAAG,CAAC,EAAE,OAAO,GAAGA,KAAK,OAAO;EACrC,MAAMC,MAAM,GAAGR,IAAI,CAACE,KAAK,CAACI,IAAI,GAAG,EAAE,CAAC;EACpC,IAAIE,MAAM,GAAG,EA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;IAC3E,OAAO,uFAAuF;EAChG;EACA,IAAI,OAAOI,IAAI,CAACI,UAAU,KAAK,QAAQ,IAAIJ,IAAI,CAACI,UAAU,CAACR,MAAM,KAAK,CAAC,EAAE;IACvE,OAAO,sEAAsE;EAC/E;EACA,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"names":["relativeTime","iso","then","Date","getTime","seconds","Math","max","floor","now","minutes","hours","days","weeks","months","formatDate","toLocaleDateString","undefined","year","month","day","formatTime","toLocaleTimeString","hour","minute","isSameDay","a","b","first","second","getFullYear","getMonth","getDate","dayLabel","toISOString","yesterday","date","weekday","validateProps","props","appName","length","apiKey","supabaseUrl","test","user","name","isPaid","revenuecatId","appVersion"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA;AACA,OAAO,SAASA,YAAYA,CAACC,GAAW,EAAU;EAChD,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAAC,CAAC;EACpC,MAAMC,OAAO,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAAC,CAACL,IAAI,CAACM,GAAG,CAAC,CAAC,GAAGP,IAAI,IAAI,IAAI,CAAC,CAAC;EACnE,IAAIG,OAAO,GAAG,EAAE,EAAE,OAAO,UAAU;EACnC,MAAMK,OAAO,GAAGJ,IAAI,CAACE,KAAK,CAACH,OAAO,GAAG,EAAE,CAAC;EACxC,IAAIK,OAAO,GAAG,EAAE,EAAE,OAAO,GAAGA,OAAO,OAAO;EAC1C,MAAMC,KAAK,GAAGL,IAAI,CAACE,KAAK,CAACE,OAAO,GAAG,EAAE,CAAC;EACtC,IAAIC,KAAK,GAAG,EAAE,EAAE,OAAO,GAAGA,KAAK,OAAO;EACtC,MAAMC,IAAI,GAAGN,IAAI,CAACE,KAAK,CAACG,KAAK,GAAG,EAAE,CAAC;EACnC,IAAIC,IAAI,GAAG,CAAC,EAAE,OAAO,GAAGA,IAAI,OAAO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