@tnf-dev/react 1.0.1-14 → 1.0.1-5

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 (186) hide show
  1. package/README.md +4 -3
  2. package/dist/cjs/components/icons/archive-box-icon.cjs +50 -1
  3. package/dist/cjs/components/icons/archive-box-icon.cjs.map +1 -0
  4. package/dist/cjs/components/icons/bell-icon.cjs +50 -1
  5. package/dist/cjs/components/icons/bell-icon.cjs.map +1 -0
  6. package/dist/cjs/components/icons/check-circle-icon.cjs +50 -1
  7. package/dist/cjs/components/icons/check-circle-icon.cjs.map +1 -0
  8. package/dist/cjs/components/icons/index.cjs +112 -1
  9. package/dist/cjs/components/icons/index.cjs.map +1 -0
  10. package/dist/cjs/components/inbox/bell.cjs +4714 -12
  11. package/dist/cjs/components/inbox/bell.cjs.map +1 -0
  12. package/dist/cjs/components/inbox/button.cjs +4654 -12
  13. package/dist/cjs/components/inbox/button.cjs.map +1 -0
  14. package/dist/cjs/components/inbox/empty.cjs +4635 -12
  15. package/dist/cjs/components/inbox/empty.cjs.map +1 -0
  16. package/dist/cjs/components/inbox/inbox.cjs +5291 -12
  17. package/dist/cjs/components/inbox/inbox.cjs.map +1 -0
  18. package/dist/cjs/components/inbox/index.cjs +5309 -12
  19. package/dist/cjs/components/inbox/index.cjs.map +1 -0
  20. package/dist/cjs/components/inbox/index.d.cts +1 -1
  21. package/dist/cjs/components/inbox/loader.cjs +4629 -12
  22. package/dist/cjs/components/inbox/loader.cjs.map +1 -0
  23. package/dist/cjs/components/inbox/notification-header.cjs +4649 -12
  24. package/dist/cjs/components/inbox/notification-header.cjs.map +1 -0
  25. package/dist/cjs/components/inbox/notification-item/actions.cjs +4738 -12
  26. package/dist/cjs/components/inbox/notification-item/actions.cjs.map +1 -0
  27. package/dist/cjs/components/inbox/notification-item/index.cjs +4865 -12
  28. package/dist/cjs/components/inbox/notification-item/index.cjs.map +1 -0
  29. package/dist/cjs/components/inbox/popover.cjs +4711 -12
  30. package/dist/cjs/components/inbox/popover.cjs.map +1 -0
  31. package/dist/cjs/components/index.cjs +5309 -12
  32. package/dist/cjs/components/index.cjs.map +1 -0
  33. package/dist/cjs/components/index.d.cts +1 -1
  34. package/dist/cjs/contexts/StyleProvider.cjs +4645 -12
  35. package/dist/cjs/contexts/StyleProvider.cjs.map +1 -0
  36. package/dist/cjs/contexts/TeknifyProvider.cjs +4674 -12
  37. package/dist/cjs/contexts/TeknifyProvider.cjs.map +1 -0
  38. package/dist/cjs/contexts/TeknifyProvider.d.cts +0 -6
  39. package/dist/cjs/contexts/index.cjs +4677 -12
  40. package/dist/cjs/contexts/index.cjs.map +1 -0
  41. package/dist/cjs/contexts/index.d.cts +0 -1
  42. package/dist/cjs/dto/index.cjs +19 -1
  43. package/dist/cjs/dto/index.cjs.map +1 -0
  44. package/dist/cjs/dto/notifications/index.cjs +19 -1
  45. package/dist/cjs/dto/notifications/index.cjs.map +1 -0
  46. package/dist/cjs/dto/notifications/notification.interface.cjs +19 -1
  47. package/dist/cjs/dto/notifications/notification.interface.cjs.map +1 -0
  48. package/dist/cjs/hooks/index.cjs +145 -1
  49. package/dist/cjs/hooks/index.cjs.map +1 -0
  50. package/dist/cjs/hooks/useNotifications.cjs +143 -1
  51. package/dist/cjs/hooks/useNotifications.cjs.map +1 -0
  52. package/dist/cjs/index.cjs +5362 -12
  53. package/dist/cjs/index.cjs.map +1 -0
  54. package/dist/cjs/index.d.cts +1 -2
  55. package/dist/cjs/utils/const.cjs +31 -1
  56. package/dist/cjs/utils/const.cjs.map +1 -0
  57. package/dist/cjs/utils/index.cjs +33 -1
  58. package/dist/cjs/utils/index.cjs.map +1 -0
  59. package/dist/esm/chunk-57PGXW3M.js +2 -0
  60. package/dist/esm/chunk-57PGXW3M.js.map +1 -0
  61. package/dist/esm/chunk-5ZHARJ3G.js +4446 -0
  62. package/dist/esm/chunk-5ZHARJ3G.js.map +1 -0
  63. package/dist/esm/chunk-6FGP2HJW.js +9 -0
  64. package/dist/esm/chunk-6FGP2HJW.js.map +1 -0
  65. package/dist/esm/chunk-ATNNGNAM.js +2 -0
  66. package/dist/esm/chunk-ATNNGNAM.js.map +1 -0
  67. package/dist/esm/chunk-B5I3IFK2.js +113 -0
  68. package/dist/esm/chunk-B5I3IFK2.js.map +1 -0
  69. package/dist/esm/chunk-DC2MKTMP.js +2 -0
  70. package/dist/esm/chunk-DC2MKTMP.js.map +1 -0
  71. package/dist/esm/chunk-EBHNXTGY.js +2 -0
  72. package/dist/esm/chunk-EBHNXTGY.js.map +1 -0
  73. package/dist/esm/chunk-ET4RPLX7.js +32 -0
  74. package/dist/esm/chunk-ET4RPLX7.js.map +1 -0
  75. package/dist/esm/chunk-H3IWAKC5.js +34 -0
  76. package/dist/esm/chunk-H3IWAKC5.js.map +1 -0
  77. package/dist/esm/chunk-H3RCKWE3.js +2 -0
  78. package/dist/esm/chunk-H3RCKWE3.js.map +1 -0
  79. package/dist/esm/chunk-HDKTD2IK.js +49 -0
  80. package/dist/esm/chunk-HDKTD2IK.js.map +1 -0
  81. package/dist/esm/chunk-IXQPSHNR.js +32 -0
  82. package/dist/esm/chunk-IXQPSHNR.js.map +1 -0
  83. package/dist/esm/chunk-MNBHQJKW.js +2 -0
  84. package/dist/esm/chunk-MNBHQJKW.js.map +1 -0
  85. package/dist/esm/chunk-NDUFFQA7.js +24 -0
  86. package/dist/esm/chunk-NDUFFQA7.js.map +1 -0
  87. package/dist/esm/chunk-NQ3CC7OA.js +84 -0
  88. package/dist/esm/chunk-NQ3CC7OA.js.map +1 -0
  89. package/dist/esm/chunk-QILM4R2Q.js +54 -0
  90. package/dist/esm/chunk-QILM4R2Q.js.map +1 -0
  91. package/dist/esm/chunk-RCHW4I55.js +2 -0
  92. package/dist/esm/chunk-RCHW4I55.js.map +1 -0
  93. package/dist/esm/chunk-RLFVKZHT.js +30 -0
  94. package/dist/esm/chunk-RLFVKZHT.js.map +1 -0
  95. package/dist/esm/chunk-S6WUE45S.js +32 -0
  96. package/dist/esm/chunk-S6WUE45S.js.map +1 -0
  97. package/dist/esm/chunk-SSLZWOID.js +97 -0
  98. package/dist/esm/chunk-SSLZWOID.js.map +1 -0
  99. package/dist/esm/chunk-VWQT7XSQ.js +2 -0
  100. package/dist/esm/chunk-VWQT7XSQ.js.map +1 -0
  101. package/dist/esm/chunk-WN4NSHNE.js +32 -0
  102. package/dist/esm/chunk-WN4NSHNE.js.map +1 -0
  103. package/dist/esm/chunk-XVCHU66N.js +40 -0
  104. package/dist/esm/chunk-XVCHU66N.js.map +1 -0
  105. package/dist/esm/chunk-YKV4YNJ4.js +44 -0
  106. package/dist/esm/chunk-YKV4YNJ4.js.map +1 -0
  107. package/dist/esm/chunk-YY3MZBYQ.js +2 -0
  108. package/dist/esm/chunk-YY3MZBYQ.js.map +1 -0
  109. package/dist/esm/chunk-Z4Q2SGNX.js +144 -0
  110. package/dist/esm/chunk-Z4Q2SGNX.js.map +1 -0
  111. package/dist/esm/chunk-ZBV5DZZB.js +104 -0
  112. package/dist/esm/chunk-ZBV5DZZB.js.map +1 -0
  113. package/dist/esm/components/icons/archive-box-icon.js +8 -1
  114. package/dist/esm/components/icons/archive-box-icon.js.map +1 -0
  115. package/dist/esm/components/icons/bell-icon.js +8 -1
  116. package/dist/esm/components/icons/bell-icon.js.map +1 -0
  117. package/dist/esm/components/icons/check-circle-icon.js +8 -1
  118. package/dist/esm/components/icons/check-circle-icon.js.map +1 -0
  119. package/dist/esm/components/icons/index.js +17 -1
  120. package/dist/esm/components/icons/index.js.map +1 -0
  121. package/dist/esm/components/inbox/bell.js +15 -29
  122. package/dist/esm/components/inbox/bell.js.map +1 -0
  123. package/dist/esm/components/inbox/button.js +11 -29
  124. package/dist/esm/components/inbox/button.js.map +1 -0
  125. package/dist/esm/components/inbox/empty.js +11 -29
  126. package/dist/esm/components/inbox/empty.js.map +1 -0
  127. package/dist/esm/components/inbox/inbox.js +28 -29
  128. package/dist/esm/components/inbox/inbox.js.map +1 -0
  129. package/dist/esm/components/inbox/index.d.ts +1 -1
  130. package/dist/esm/components/inbox/index.js +50 -29
  131. package/dist/esm/components/inbox/index.js.map +1 -0
  132. package/dist/esm/components/inbox/loader.js +9 -29
  133. package/dist/esm/components/inbox/loader.js.map +1 -0
  134. package/dist/esm/components/inbox/notification-header.js +11 -29
  135. package/dist/esm/components/inbox/notification-header.js.map +1 -0
  136. package/dist/esm/components/inbox/notification-item/actions.js +16 -29
  137. package/dist/esm/components/inbox/notification-item/actions.js.map +1 -0
  138. package/dist/esm/components/inbox/notification-item/index.js +17 -29
  139. package/dist/esm/components/inbox/notification-item/index.js.map +1 -0
  140. package/dist/esm/components/inbox/popover.js +11 -29
  141. package/dist/esm/components/inbox/popover.js.map +1 -0
  142. package/dist/esm/components/index.d.ts +1 -1
  143. package/dist/esm/components/index.js +51 -29
  144. package/dist/esm/components/index.js.map +1 -0
  145. package/dist/esm/contexts/StyleProvider.js +9 -29
  146. package/dist/esm/contexts/StyleProvider.js.map +1 -0
  147. package/dist/esm/contexts/TeknifyProvider.d.ts +0 -6
  148. package/dist/esm/contexts/TeknifyProvider.js +12 -29
  149. package/dist/esm/contexts/TeknifyProvider.js.map +1 -0
  150. package/dist/esm/contexts/index.d.ts +0 -1
  151. package/dist/esm/contexts/index.js +13 -29
  152. package/dist/esm/contexts/index.js.map +1 -0
  153. package/dist/esm/dto/index.js +4 -0
  154. package/dist/esm/dto/index.js.map +1 -0
  155. package/dist/esm/dto/notifications/index.js +3 -0
  156. package/dist/esm/dto/notifications/index.js.map +1 -0
  157. package/dist/esm/dto/notifications/notification.interface.js +2 -0
  158. package/dist/esm/dto/notifications/notification.interface.js.map +1 -0
  159. package/dist/esm/hooks/index.js +13 -1
  160. package/dist/esm/hooks/index.js.map +1 -0
  161. package/dist/esm/hooks/useNotifications.js +12 -1
  162. package/dist/esm/hooks/useNotifications.js.map +1 -0
  163. package/dist/esm/index.d.ts +1 -2
  164. package/dist/esm/index.js +62 -29
  165. package/dist/esm/index.js.map +1 -0
  166. package/dist/esm/utils/const.js +8 -1
  167. package/dist/esm/utils/const.js.map +1 -0
  168. package/dist/esm/utils/index.js +9 -1
  169. package/dist/esm/utils/index.js.map +1 -0
  170. package/package.json +5 -4
  171. package/dist/cjs/locale/default.cjs +0 -2
  172. package/dist/cjs/locale/default.d.cts +0 -5
  173. package/dist/cjs/locale/index.cjs +0 -2
  174. package/dist/cjs/locale/index.d.cts +0 -2
  175. package/dist/cjs/types/index.cjs +0 -2
  176. package/dist/cjs/types/index.d.cts +0 -1
  177. package/dist/cjs/types/locale.cjs +0 -2
  178. package/dist/cjs/types/locale.d.cts +0 -15
  179. package/dist/esm/locale/default.d.ts +0 -5
  180. package/dist/esm/locale/default.js +0 -2
  181. package/dist/esm/locale/index.d.ts +0 -2
  182. package/dist/esm/locale/index.js +0 -2
  183. package/dist/esm/types/index.d.ts +0 -1
  184. package/dist/esm/types/index.js +0 -1
  185. package/dist/esm/types/locale.d.ts +0 -15
  186. package/dist/esm/types/locale.js +0 -1
@@ -1,4 +1,3 @@
1
1
  export { TeknifyContext, default as TeknifyProvider } from './TeknifyProvider.cjs';
2
2
  import 'react';
3
3
  import '@tnf-dev/js';
4
- import '../types/locale.cjs';
@@ -1,2 +1,20 @@
1
1
  "use client"
2
- "use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/dto/index.ts
18
+ var dto_exports = {};
19
+ module.exports = __toCommonJS(dto_exports);
20
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/dto/index.ts"],"sourcesContent":["export * from './notifications';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,2 +1,20 @@
1
1
  "use client"
2
- "use strict";var m=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,p,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of x(o))!a.call(r,e)&&e!==p&&m(r,e,{get:()=>o[e],enumerable:!(f=t(o,e))||f.enumerable});return r};var c=r=>b(m({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/dto/notifications/index.ts
18
+ var notifications_exports = {};
19
+ module.exports = __toCommonJS(notifications_exports);
20
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/dto/notifications/index.ts"],"sourcesContent":["export * from './notification.interface';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,2 +1,20 @@
1
1
  "use client"
2
- "use strict";var e=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var c=(o,i,f,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of r(i))!s.call(o,t)&&t!==f&&e(o,t,{get:()=>i[t],enumerable:!(a=n(i,t))||a.enumerable});return o};var m=o=>c(e({},"__esModule",{value:!0}),o);var N={};module.exports=m(N);
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/dto/notifications/notification.interface.ts
18
+ var notification_interface_exports = {};
19
+ module.exports = __toCommonJS(notification_interface_exports);
20
+ //# sourceMappingURL=notification.interface.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/dto/notifications/notification.interface.ts"],"sourcesContent":["import { Notification as BaseNotification } from '@tnf-dev/core';\n\nexport interface Notification extends BaseNotification {\n markAsRead: () => Promise<void>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,2 +1,146 @@
1
1
  "use client"
2
- "use strict";var k=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(t,n)=>{for(var i in n)k(t,i,{get:n[i],enumerable:!0})},S=(t,n,i,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of w(n))!M.call(t,a)&&a!==i&&k(t,a,{get:()=>n[a],enumerable:!(f=F(n,a))||f.enumerable});return t};var U=t=>S(k({},"__esModule",{value:!0}),t);var H={};b(H,{useNotifications:()=>D});module.exports=U(H);var r=require("react");var V=require("@tnf-dev/js"),C=require("react");var W=require("react/jsx-runtime"),P=(0,C.createContext)({applicationId:"",subscriberId:""});var D=()=>{let{client:t}=(0,r.useContext)(P),[n,i]=(0,r.useState)([]),[f,a]=(0,r.useState)(!1),[h,y]=(0,r.useState)(null),[l,x]=(0,r.useState)(!1),[_,E]=(0,r.useState)(!0),[L,T]=(0,r.useState)(!0),[m,I]=(0,r.useState)(),[A,g]=(0,r.useState)(0),d=(0,r.useCallback)(async e=>{try{i(c=>c.map(o=>o._id===e?{...o,isRead:!0}:o)),await t.notification.markAsRead(e)}catch{i(o=>o.map(s=>s._id===e?{...s,isRead:!1}:s))}},[]),p=(0,r.useCallback)(async()=>{if(!(l||f))try{x(!0);let e=await t.notification.getNotifications({...m?{cursor:m}:{}});i(c=>[...c,...e.data.filter(o=>!c.find(s=>s._id===o._id)).map(o=>({...o,markAsRead:()=>d(o._id)}))]),T(!!e.pagination.continueCursor),I(e.pagination.continueCursor),g(e.unread)}catch(e){a(!0),e instanceof Error?y(e):y(new Error("Unknown error"))}finally{x(!1),E(!1)}},[l,m,d,f]);(0,r.useEffect)(()=>{p()},[]),(0,r.useEffect)(()=>{let e=(c,{counts:o})=>{g(o.unread),i(s=>[...c.filter(u=>{let N=s.findIndex(v=>v._id===u._id);return N!==-1?(s[N]={...u,markAsRead:()=>d(u._id)},!1):!0}).map(u=>({...u,markAsRead:()=>d(u._id)})),...s])};return t.notification.on(e),()=>{t.notification.off(e)}},[d]);let R=(0,r.useCallback)(()=>{p()},[p]);return{notifications:n,isLoading:l,isFirstLoad:_,isError:f,error:h,hasMore:L,unread:A,fetchMore:R}};0&&(module.exports={useNotifications});
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/hooks/index.ts
22
+ var hooks_exports = {};
23
+ __export(hooks_exports, {
24
+ useNotifications: () => useNotifications
25
+ });
26
+ module.exports = __toCommonJS(hooks_exports);
27
+
28
+ // src/hooks/useNotifications.ts
29
+ var import_react2 = require("react");
30
+
31
+ // src/contexts/TeknifyProvider.tsx
32
+ var import_js = require("@tnf-dev/js");
33
+ var import_react = require("react");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var TeknifyContext = (0, import_react.createContext)({
36
+ applicationId: "",
37
+ subscriberId: ""
38
+ });
39
+
40
+ // src/hooks/useNotifications.ts
41
+ var useNotifications = () => {
42
+ const { client } = (0, import_react2.useContext)(TeknifyContext);
43
+ const [notifications, setNotifications] = (0, import_react2.useState)([]);
44
+ const [isError, setIsError] = (0, import_react2.useState)(false);
45
+ const [error, setError] = (0, import_react2.useState)(null);
46
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(false);
47
+ const [isFirstLoad, setIsFirstLoad] = (0, import_react2.useState)(true);
48
+ const [hasMore, setHasMore] = (0, import_react2.useState)(true);
49
+ const [nextCursor, setNextCursor] = (0, import_react2.useState)();
50
+ const [unread, setUnread] = (0, import_react2.useState)(0);
51
+ const handleMarkAsRead = (0, import_react2.useCallback)(async (id) => {
52
+ try {
53
+ await client.notification.markAsRead(id);
54
+ setNotifications((prev) => {
55
+ return prev.map((notification) => {
56
+ if (notification._id === id) {
57
+ return {
58
+ ...notification,
59
+ isRead: true
60
+ };
61
+ }
62
+ return notification;
63
+ });
64
+ });
65
+ } catch (error2) {
66
+ }
67
+ }, []);
68
+ const fetchNotifications = (0, import_react2.useCallback)(async () => {
69
+ if (isLoading) return;
70
+ try {
71
+ setIsLoading(true);
72
+ const res = await client.notification.getNotifications({
73
+ ...nextCursor ? { cursor: nextCursor } : {}
74
+ });
75
+ setNotifications((prev) => {
76
+ return [
77
+ ...prev,
78
+ ...res.data.filter((notification) => !prev.find((n) => n._id === notification._id)).map((notification) => ({
79
+ ...notification,
80
+ markAsRead: () => handleMarkAsRead(notification._id)
81
+ }))
82
+ ];
83
+ });
84
+ setHasMore(!!res.pagination.continueCursor);
85
+ setNextCursor(res.pagination.continueCursor);
86
+ setUnread(res.unread);
87
+ } catch (error2) {
88
+ setIsError(true);
89
+ if (error2 instanceof Error) {
90
+ setError(error2);
91
+ } else {
92
+ setError(new Error("Unknown error"));
93
+ }
94
+ } finally {
95
+ setIsLoading(false);
96
+ setIsFirstLoad(false);
97
+ }
98
+ }, [isLoading, nextCursor, handleMarkAsRead]);
99
+ (0, import_react2.useEffect)(() => {
100
+ fetchNotifications();
101
+ }, []);
102
+ (0, import_react2.useEffect)(() => {
103
+ const handler = (notifications2) => {
104
+ setNotifications((prev) => {
105
+ return [
106
+ ...notifications2.filter((notification) => {
107
+ const foundIndex = prev.findIndex((n) => n._id === notification._id);
108
+ if (foundIndex) {
109
+ prev[foundIndex] = {
110
+ ...notification,
111
+ markAsRead: () => handleMarkAsRead(notification._id)
112
+ };
113
+ }
114
+ return foundIndex === -1;
115
+ }).map((notification) => ({
116
+ ...notification,
117
+ markAsRead: () => handleMarkAsRead(notification._id)
118
+ })),
119
+ ...prev
120
+ ];
121
+ });
122
+ };
123
+ client.notification.on(handler);
124
+ return () => {
125
+ client.notification.off(handler);
126
+ };
127
+ }, [handleMarkAsRead]);
128
+ const fetchMore = (0, import_react2.useCallback)(() => {
129
+ fetchNotifications();
130
+ }, [fetchNotifications]);
131
+ return {
132
+ notifications,
133
+ isLoading,
134
+ isFirstLoad,
135
+ isError,
136
+ error,
137
+ hasMore,
138
+ unread,
139
+ fetchMore
140
+ };
141
+ };
142
+ // Annotate the CommonJS export names for ESM import in node:
143
+ 0 && (module.exports = {
144
+ useNotifications
145
+ });
146
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/index.ts","../../../src/hooks/useNotifications.ts","../../../src/contexts/TeknifyProvider.tsx"],"sourcesContent":["export * from './useNotifications';\n","import { useCallback, useContext, useEffect, useState } from 'react';\nimport { TeknifyContext } from '../contexts';\nimport { Notification } from '../dto';\n\nexport const useNotifications = () => {\n const { client } = useContext(TeknifyContext);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [isError, setIsError] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [isFirstLoad, setIsFirstLoad] = useState(true);\n const [hasMore, setHasMore] = useState(true);\n const [nextCursor, setNextCursor] = useState<string | undefined>();\n const [unread, setUnread] = useState(0);\n\n const handleMarkAsRead = useCallback(async (id: string) => {\n try {\n await client.notification.markAsRead(id);\n setNotifications((prev) => {\n return prev.map((notification) => {\n if (notification._id === id) {\n return {\n ...notification,\n isRead: true,\n };\n }\n return notification;\n });\n });\n } catch (error) {}\n }, []);\n\n const fetchNotifications = useCallback(async () => {\n if (isLoading) return;\n try {\n setIsLoading(true);\n const res = await client.notification.getNotifications({\n ...(nextCursor ? { cursor: nextCursor } : {}),\n });\n\n setNotifications((prev) => {\n return [\n ...prev,\n ...res.data\n .filter((notification) => !prev.find((n) => n._id === notification._id))\n .map((notification) => ({\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n })),\n ];\n });\n setHasMore(!!res.pagination.continueCursor);\n setNextCursor(res.pagination.continueCursor);\n setUnread(res.unread);\n } catch (error) {\n setIsError(true);\n if (error instanceof Error) {\n setError(error);\n } else {\n setError(new Error('Unknown error'));\n }\n } finally {\n setIsLoading(false);\n setIsFirstLoad(false);\n }\n }, [isLoading, nextCursor, handleMarkAsRead]);\n\n useEffect(() => {\n fetchNotifications();\n }, []);\n\n useEffect(() => {\n const handler = (notifications: Array<Omit<Notification, 'markAsRead'>>) => {\n setNotifications((prev) => {\n return [\n ...notifications\n .filter((notification) => {\n const foundIndex = prev.findIndex((n) => n._id === notification._id);\n if (foundIndex) {\n prev[foundIndex] = {\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n };\n }\n return foundIndex === -1;\n })\n .map((notification) => ({\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n })),\n ...prev,\n ];\n });\n };\n client.notification.on(handler);\n return () => {\n client.notification.off(handler);\n };\n }, [handleMarkAsRead]);\n\n const fetchMore = useCallback(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n return {\n notifications,\n isLoading,\n isFirstLoad,\n isError,\n error,\n hasMore,\n unread,\n fetchMore,\n };\n};\n","import { TeknifyClient } from '@tnf-dev/js';\nimport { createContext, FC, PropsWithChildren, useMemo } from 'react';\nimport StyleProvider from './StyleProvider';\ninterface NotekProviderProps extends PropsWithChildren {\n applicationId: string;\n subscriberId: string;\n}\n\ninterface NotekContextValues {\n applicationId: string;\n subscriberId: string;\n client: TeknifyClient;\n}\n\nexport const TeknifyContext = createContext<NotekContextValues>({\n applicationId: '',\n subscriberId: '',\n} as any);\n\nconst NotekProvider: FC<NotekProviderProps> = ({ applicationId, subscriberId, children, ...props }) => {\n const values: NotekContextValues = useMemo(\n () => ({\n applicationId,\n subscriberId,\n client: new TeknifyClient({\n applicationId,\n subscriberId,\n }),\n }),\n [applicationId, subscriberId],\n );\n\n return (\n <TeknifyContext.Provider value={values}>\n <StyleProvider>{children}</StyleProvider>\n </TeknifyContext.Provider>\n );\n};\n\nexport default NotekProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA6D;;;ACA7D,gBAA8B;AAC9B,mBAA8D;AAiCxD;AApBC,IAAM,qBAAiB,4BAAkC;AAAA,EAC9D,eAAe;AAAA,EACf,cAAc;AAChB,CAAQ;;;ADbD,IAAM,mBAAmB,MAAM;AACpC,QAAM,EAAE,OAAO,QAAI,0BAAW,cAAc;AAC5C,QAAM,CAAC,eAAe,gBAAgB,QAAI,wBAAyB,CAAC,CAAC;AACrE,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAS,KAAK;AAC5C,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AACrD,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAS,IAAI;AACnD,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAS,IAAI;AAC3C,QAAM,CAAC,YAAY,aAAa,QAAI,wBAA6B;AACjE,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAAS,CAAC;AAEtC,QAAM,uBAAmB,2BAAY,OAAO,OAAe;AACzD,QAAI;AACF,YAAM,OAAO,aAAa,WAAW,EAAE;AACvC,uBAAiB,CAAC,SAAS;AACzB,eAAO,KAAK,IAAI,CAAC,iBAAiB;AAChC,cAAI,aAAa,QAAQ,IAAI;AAC3B,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,QAAQ;AAAA,YACV;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH,CAAC;AAAA,IACH,SAASC,QAAO;AAAA,IAAC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AA,gBACH,YAAY,MAAM,iBAAiB,aAAa,GAAG;AAAA,cACrD;AAAA,YACF;AACA,mBAAO,eAAe;AAAA,UACxB,CAAC,EACA,IAAI,CAAC,kBAAkB;AAAA,YACtB,GAAG;AAAA,YACH,YAAY,MAAM,iBAAiB,aAAa,GAAG;AAAA,UACrD,EAAE;AAAA,UACJ,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,aAAa,GAAG,OAAO;AAC9B,WAAO,MAAM;AACX,aAAO,aAAa,IAAI,OAAO;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,gBAAgB,CAAC;AAErB,QAAM,gBAAY,2BAAY,MAAM;AAClC,uBAAmB;AAAA,EACrB,GAAG,CAAC,kBAAkB,CAAC;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_react","error","notifications"]}
@@ -1,2 +1,144 @@
1
1
  "use client"
2
- "use strict";var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(t,n)=>{for(var i in n)p(t,i,{get:n[i],enumerable:!0})},S=(t,n,i,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of w(n))!M.call(t,a)&&a!==i&&p(t,a,{get:()=>n[a],enumerable:!(f=F(n,a))||f.enumerable});return t};var U=t=>S(p({},"__esModule",{value:!0}),t);var H={};b(H,{useNotifications:()=>D});module.exports=U(H);var r=require("react");var V=require("@tnf-dev/js"),C=require("react");var W=require("react/jsx-runtime"),P=(0,C.createContext)({applicationId:"",subscriberId:""});var D=()=>{let{client:t}=(0,r.useContext)(P),[n,i]=(0,r.useState)([]),[f,a]=(0,r.useState)(!1),[h,y]=(0,r.useState)(null),[l,x]=(0,r.useState)(!1),[_,E]=(0,r.useState)(!0),[L,T]=(0,r.useState)(!0),[m,I]=(0,r.useState)(),[A,g]=(0,r.useState)(0),d=(0,r.useCallback)(async e=>{try{i(c=>c.map(o=>o._id===e?{...o,isRead:!0}:o)),await t.notification.markAsRead(e)}catch{i(o=>o.map(s=>s._id===e?{...s,isRead:!1}:s))}},[]),k=(0,r.useCallback)(async()=>{if(!(l||f))try{x(!0);let e=await t.notification.getNotifications({...m?{cursor:m}:{}});i(c=>[...c,...e.data.filter(o=>!c.find(s=>s._id===o._id)).map(o=>({...o,markAsRead:()=>d(o._id)}))]),T(!!e.pagination.continueCursor),I(e.pagination.continueCursor),g(e.unread)}catch(e){a(!0),e instanceof Error?y(e):y(new Error("Unknown error"))}finally{x(!1),E(!1)}},[l,m,d,f]);(0,r.useEffect)(()=>{k()},[]),(0,r.useEffect)(()=>{let e=(c,{counts:o})=>{g(o.unread),i(s=>[...c.filter(u=>{let N=s.findIndex(v=>v._id===u._id);return N!==-1?(s[N]={...u,markAsRead:()=>d(u._id)},!1):!0}).map(u=>({...u,markAsRead:()=>d(u._id)})),...s])};return t.notification.on(e),()=>{t.notification.off(e)}},[d]);let R=(0,r.useCallback)(()=>{k()},[k]);return{notifications:n,isLoading:l,isFirstLoad:_,isError:f,error:h,hasMore:L,unread:A,fetchMore:R}};0&&(module.exports={useNotifications});
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/hooks/useNotifications.ts
22
+ var useNotifications_exports = {};
23
+ __export(useNotifications_exports, {
24
+ useNotifications: () => useNotifications
25
+ });
26
+ module.exports = __toCommonJS(useNotifications_exports);
27
+ var import_react2 = require("react");
28
+
29
+ // src/contexts/TeknifyProvider.tsx
30
+ var import_js = require("@tnf-dev/js");
31
+ var import_react = require("react");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var TeknifyContext = (0, import_react.createContext)({
34
+ applicationId: "",
35
+ subscriberId: ""
36
+ });
37
+
38
+ // src/hooks/useNotifications.ts
39
+ var useNotifications = () => {
40
+ const { client } = (0, import_react2.useContext)(TeknifyContext);
41
+ const [notifications, setNotifications] = (0, import_react2.useState)([]);
42
+ const [isError, setIsError] = (0, import_react2.useState)(false);
43
+ const [error, setError] = (0, import_react2.useState)(null);
44
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(false);
45
+ const [isFirstLoad, setIsFirstLoad] = (0, import_react2.useState)(true);
46
+ const [hasMore, setHasMore] = (0, import_react2.useState)(true);
47
+ const [nextCursor, setNextCursor] = (0, import_react2.useState)();
48
+ const [unread, setUnread] = (0, import_react2.useState)(0);
49
+ const handleMarkAsRead = (0, import_react2.useCallback)(async (id) => {
50
+ try {
51
+ await client.notification.markAsRead(id);
52
+ setNotifications((prev) => {
53
+ return prev.map((notification) => {
54
+ if (notification._id === id) {
55
+ return {
56
+ ...notification,
57
+ isRead: true
58
+ };
59
+ }
60
+ return notification;
61
+ });
62
+ });
63
+ } catch (error2) {
64
+ }
65
+ }, []);
66
+ const fetchNotifications = (0, import_react2.useCallback)(async () => {
67
+ if (isLoading) return;
68
+ try {
69
+ setIsLoading(true);
70
+ const res = await client.notification.getNotifications({
71
+ ...nextCursor ? { cursor: nextCursor } : {}
72
+ });
73
+ setNotifications((prev) => {
74
+ return [
75
+ ...prev,
76
+ ...res.data.filter((notification) => !prev.find((n) => n._id === notification._id)).map((notification) => ({
77
+ ...notification,
78
+ markAsRead: () => handleMarkAsRead(notification._id)
79
+ }))
80
+ ];
81
+ });
82
+ setHasMore(!!res.pagination.continueCursor);
83
+ setNextCursor(res.pagination.continueCursor);
84
+ setUnread(res.unread);
85
+ } catch (error2) {
86
+ setIsError(true);
87
+ if (error2 instanceof Error) {
88
+ setError(error2);
89
+ } else {
90
+ setError(new Error("Unknown error"));
91
+ }
92
+ } finally {
93
+ setIsLoading(false);
94
+ setIsFirstLoad(false);
95
+ }
96
+ }, [isLoading, nextCursor, handleMarkAsRead]);
97
+ (0, import_react2.useEffect)(() => {
98
+ fetchNotifications();
99
+ }, []);
100
+ (0, import_react2.useEffect)(() => {
101
+ const handler = (notifications2) => {
102
+ setNotifications((prev) => {
103
+ return [
104
+ ...notifications2.filter((notification) => {
105
+ const foundIndex = prev.findIndex((n) => n._id === notification._id);
106
+ if (foundIndex) {
107
+ prev[foundIndex] = {
108
+ ...notification,
109
+ markAsRead: () => handleMarkAsRead(notification._id)
110
+ };
111
+ }
112
+ return foundIndex === -1;
113
+ }).map((notification) => ({
114
+ ...notification,
115
+ markAsRead: () => handleMarkAsRead(notification._id)
116
+ })),
117
+ ...prev
118
+ ];
119
+ });
120
+ };
121
+ client.notification.on(handler);
122
+ return () => {
123
+ client.notification.off(handler);
124
+ };
125
+ }, [handleMarkAsRead]);
126
+ const fetchMore = (0, import_react2.useCallback)(() => {
127
+ fetchNotifications();
128
+ }, [fetchNotifications]);
129
+ return {
130
+ notifications,
131
+ isLoading,
132
+ isFirstLoad,
133
+ isError,
134
+ error,
135
+ hasMore,
136
+ unread,
137
+ fetchMore
138
+ };
139
+ };
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ useNotifications
143
+ });
144
+ //# sourceMappingURL=useNotifications.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useNotifications.ts","../../../src/contexts/TeknifyProvider.tsx"],"sourcesContent":["import { useCallback, useContext, useEffect, useState } from 'react';\nimport { TeknifyContext } from '../contexts';\nimport { Notification } from '../dto';\n\nexport const useNotifications = () => {\n const { client } = useContext(TeknifyContext);\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [isError, setIsError] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [isFirstLoad, setIsFirstLoad] = useState(true);\n const [hasMore, setHasMore] = useState(true);\n const [nextCursor, setNextCursor] = useState<string | undefined>();\n const [unread, setUnread] = useState(0);\n\n const handleMarkAsRead = useCallback(async (id: string) => {\n try {\n await client.notification.markAsRead(id);\n setNotifications((prev) => {\n return prev.map((notification) => {\n if (notification._id === id) {\n return {\n ...notification,\n isRead: true,\n };\n }\n return notification;\n });\n });\n } catch (error) {}\n }, []);\n\n const fetchNotifications = useCallback(async () => {\n if (isLoading) return;\n try {\n setIsLoading(true);\n const res = await client.notification.getNotifications({\n ...(nextCursor ? { cursor: nextCursor } : {}),\n });\n\n setNotifications((prev) => {\n return [\n ...prev,\n ...res.data\n .filter((notification) => !prev.find((n) => n._id === notification._id))\n .map((notification) => ({\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n })),\n ];\n });\n setHasMore(!!res.pagination.continueCursor);\n setNextCursor(res.pagination.continueCursor);\n setUnread(res.unread);\n } catch (error) {\n setIsError(true);\n if (error instanceof Error) {\n setError(error);\n } else {\n setError(new Error('Unknown error'));\n }\n } finally {\n setIsLoading(false);\n setIsFirstLoad(false);\n }\n }, [isLoading, nextCursor, handleMarkAsRead]);\n\n useEffect(() => {\n fetchNotifications();\n }, []);\n\n useEffect(() => {\n const handler = (notifications: Array<Omit<Notification, 'markAsRead'>>) => {\n setNotifications((prev) => {\n return [\n ...notifications\n .filter((notification) => {\n const foundIndex = prev.findIndex((n) => n._id === notification._id);\n if (foundIndex) {\n prev[foundIndex] = {\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n };\n }\n return foundIndex === -1;\n })\n .map((notification) => ({\n ...notification,\n markAsRead: () => handleMarkAsRead(notification._id),\n })),\n ...prev,\n ];\n });\n };\n client.notification.on(handler);\n return () => {\n client.notification.off(handler);\n };\n }, [handleMarkAsRead]);\n\n const fetchMore = useCallback(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n return {\n notifications,\n isLoading,\n isFirstLoad,\n isError,\n error,\n hasMore,\n unread,\n fetchMore,\n };\n};\n","import { TeknifyClient } from '@tnf-dev/js';\nimport { createContext, FC, PropsWithChildren, useMemo } from 'react';\nimport StyleProvider from './StyleProvider';\ninterface NotekProviderProps extends PropsWithChildren {\n applicationId: string;\n subscriberId: string;\n}\n\ninterface NotekContextValues {\n applicationId: string;\n subscriberId: string;\n client: TeknifyClient;\n}\n\nexport const TeknifyContext = createContext<NotekContextValues>({\n applicationId: '',\n subscriberId: '',\n} as any);\n\nconst NotekProvider: FC<NotekProviderProps> = ({ applicationId, subscriberId, children, ...props }) => {\n const values: NotekContextValues = useMemo(\n () => ({\n applicationId,\n subscriberId,\n client: new TeknifyClient({\n applicationId,\n subscriberId,\n }),\n }),\n [applicationId, subscriberId],\n );\n\n return (\n <TeknifyContext.Provider value={values}>\n <StyleProvider>{children}</StyleProvider>\n </TeknifyContext.Provider>\n );\n};\n\nexport default NotekProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA6D;;;ACA7D,gBAA8B;AAC9B,mBAA8D;AAiCxD;AApBC,IAAM,qBAAiB,4BAAkC;AAAA,EAC9D,eAAe;AAAA,EACf,cAAc;AAChB,CAAQ;;;ADbD,IAAM,mBAAmB,MAAM;AACpC,QAAM,EAAE,OAAO,QAAI,0BAAW,cAAc;AAC5C,QAAM,CAAC,eAAe,gBAAgB,QAAI,wBAAyB,CAAC,CAAC;AACrE,QAAM,CAAC,SAAS,UAAU,QAAI,wBAAS,KAAK;AAC5C,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AAC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