@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow/data/pending-insights.jsonl +43 -0
- package/.claude-flow/sessions/session-1794323376548.json +14 -0
- package/CHANGELOG.md +41 -0
- package/jest.config.cjs +22 -0
- package/lib/assets/home/loop-day.jpg +0 -0
- package/lib/assets/home/loop-day.mp4 +0 -0
- package/lib/assets/home/loop-time-back.jpg +0 -0
- package/lib/assets/home/loop-time-back.mp4 +0 -0
- package/lib/assets/home/loop-where.jpg +0 -0
- package/lib/assets/home/loop-where.mp4 +0 -0
- package/lib/assets/home/reel-gym.jpg +0 -0
- package/lib/assets/home/reel-gym.mp4 +0 -0
- package/lib/assets/home/reel-internet.jpg +0 -0
- package/lib/assets/home/reel-internet.mp4 +0 -0
- package/lib/assets/icon.png +0 -0
- package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/lib/assets/lottie/lucy-mark-call.json +1470 -0
- package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
- package/lib/assets/lottie/lucy-mark-details.json +1735 -0
- package/lib/assets/lottie/lucy-mark-email.json +1363 -0
- package/lib/assets/lottie/lucy-mark-message.json +1154 -0
- package/lib/assets/lottie/lucy-mark-search.json +1067 -0
- package/lib/assets/lottie/lucy-mark-think.json +1253 -0
- package/lib/assets/lottie/lucy-mark-write.json +1532 -0
- package/lib/assets/lottie/time-back.json +16458 -0
- package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/lib/assets/sounds/hours-back.m4a +0 -0
- package/lib/assets/sounds/meet-lucy.m4a +0 -0
- package/lib/assets/sounds/power-on.m4a +0 -0
- package/lib/assets/sounds/wind-back.m4a +0 -0
- package/lib/assets/sounds/youre-in.m4a +0 -0
- package/lib/chat/agent.js +358 -0
- package/lib/chat/agent.js.map +1 -0
- package/lib/chat/appFront.js +32 -0
- package/lib/chat/appFront.js.map +1 -0
- package/lib/chat/auth.js +370 -0
- package/lib/chat/auth.js.map +1 -0
- package/lib/chat/chores.js +360 -0
- package/lib/chat/chores.js.map +1 -0
- package/lib/chat/connectors.js +45 -0
- package/lib/chat/connectors.js.map +1 -0
- package/lib/chat/jobs.js +223 -0
- package/lib/chat/jobs.js.map +1 -0
- package/lib/chat/lucyMotion.js +6 -0
- package/lib/chat/lucyMotion.js.map +1 -0
- package/lib/chat/protocol.js +111 -0
- package/lib/chat/protocol.js.map +1 -0
- package/lib/chat/results.js +133 -0
- package/lib/chat/results.js.map +1 -0
- package/lib/chat/store.js +81 -0
- package/lib/chat/store.js.map +1 -0
- package/lib/chat/useDictation.js +168 -0
- package/lib/chat/useDictation.js.map +1 -0
- package/lib/chat/useLucyChat.js +451 -0
- package/lib/chat/useLucyChat.js.map +1 -0
- package/lib/chat/useMyComputer.js +32 -0
- package/lib/chat/useMyComputer.js.map +1 -0
- package/lib/chat/whereLucyWorks.js +52 -0
- package/lib/chat/whereLucyWorks.js.map +1 -0
- package/lib/chat/workspace.js +124 -0
- package/lib/chat/workspace.js.map +1 -0
- package/lib/components/AreaShot.js +289 -0
- package/lib/components/AreaShot.js.map +1 -0
- package/lib/components/Backdrops.js +262 -0
- package/lib/components/Backdrops.js.map +1 -0
- package/lib/components/BottomSheet.js +61 -0
- package/lib/components/BottomSheet.js.map +1 -0
- package/lib/components/ChatSheets.js +429 -0
- package/lib/components/ChatSheets.js.map +1 -0
- package/lib/components/ConnectorLogo.js +91 -0
- package/lib/components/ConnectorLogo.js.map +1 -0
- package/lib/components/CustomDrawer.js +534 -0
- package/lib/components/CustomDrawer.js.map +1 -0
- package/lib/components/IdeasPane.js +394 -0
- package/lib/components/IdeasPane.js.map +1 -0
- package/lib/components/ImessageSheet.js +261 -0
- package/lib/components/ImessageSheet.js.map +1 -0
- package/lib/components/KeyboardAvoider.js +29 -0
- package/lib/components/KeyboardAvoider.js.map +1 -0
- package/lib/components/Logo.js +81 -0
- package/lib/components/Logo.js.map +1 -0
- package/lib/components/LucyWorking.js +67 -0
- package/lib/components/LucyWorking.js.map +1 -0
- package/lib/components/Markdown.js +260 -0
- package/lib/components/Markdown.js.map +1 -0
- package/lib/components/Media.js +93 -0
- package/lib/components/Media.js.map +1 -0
- package/lib/components/MessagesAppIcon.js +23 -0
- package/lib/components/MessagesAppIcon.js.map +1 -0
- package/lib/components/MicButton.js +71 -0
- package/lib/components/MicButton.js.map +1 -0
- package/lib/components/ResultCards.js +974 -0
- package/lib/components/ResultCards.js.map +1 -0
- package/lib/components/SignInPrompt.js +148 -0
- package/lib/components/SignInPrompt.js.map +1 -0
- package/lib/components/SignedOut.js +38 -0
- package/lib/components/SignedOut.js.map +1 -0
- package/lib/components/TalkToLucyHero.js +487 -0
- package/lib/components/TalkToLucyHero.js.map +1 -0
- package/lib/components/TalkToLucySheet.js +182 -0
- package/lib/components/TalkToLucySheet.js.map +1 -0
- package/lib/components/WhereLucyWorks.js +277 -0
- package/lib/components/WhereLucyWorks.js.map +1 -0
- package/lib/components/WorkspaceSection.js +271 -0
- package/lib/components/WorkspaceSection.js.map +1 -0
- package/lib/components/YantraMark.js +13 -0
- package/lib/components/YantraMark.js.map +1 -0
- package/lib/components/drawerHeader.js +38 -0
- package/lib/components/drawerHeader.js.map +1 -0
- package/lib/components/lottieInstalled.js +6 -0
- package/lib/components/lottieInstalled.js.map +1 -0
- package/lib/components/ui.js +550 -0
- package/lib/components/ui.js.map +1 -0
- package/lib/components/useSignOut.js +7 -0
- package/lib/components/useSignOut.js.map +1 -0
- package/lib/components/viewport.js +121 -0
- package/lib/components/viewport.js.map +1 -0
- package/lib/components/voiceDial.js +10 -0
- package/lib/components/voiceDial.js.map +1 -0
- package/lib/compute.js +157 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.js +27 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/routes.js +15 -0
- package/lib/config/routes.js.map +1 -0
- package/lib/content.js +25 -0
- package/lib/content.js.map +1 -0
- package/lib/hooks/keyboardCover.js +39 -0
- package/lib/hooks/keyboardCover.js.map +1 -0
- package/lib/hooks/useKeyboard.js +121 -0
- package/lib/hooks/useKeyboard.js.map +1 -0
- package/lib/hooks/useReducedMotion.js +13 -0
- package/lib/hooks/useReducedMotion.js.map +1 -0
- package/lib/imessage/openMessages.js +25 -0
- package/lib/imessage/openMessages.js.map +1 -0
- package/lib/imessage/platform.js +12 -0
- package/lib/imessage/platform.js.map +1 -0
- package/lib/imessage/textLink.js +262 -0
- package/lib/imessage/textLink.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/live/card.js +28 -0
- package/lib/live/card.js.map +1 -0
- package/lib/live/liveActivity.js +144 -0
- package/lib/live/liveActivity.js.map +1 -0
- package/lib/module.js +3 -0
- package/lib/module.js.map +1 -0
- package/lib/offer/BlackFridayOffer.js +378 -0
- package/lib/offer/BlackFridayOffer.js.map +1 -0
- package/lib/offer/blackFriday.js +78 -0
- package/lib/offer/blackFriday.js.map +1 -0
- package/lib/offer/parts.js +624 -0
- package/lib/offer/parts.js.map +1 -0
- package/lib/offer/state.js +63 -0
- package/lib/offer/state.js.map +1 -0
- package/lib/push/push.js +142 -0
- package/lib/push/push.js.map +1 -0
- package/lib/push/usePushNotifications.js +39 -0
- package/lib/push/usePushNotifications.js.map +1 -0
- package/lib/routes.json +175 -0
- package/lib/screens/Account/index.js +209 -0
- package/lib/screens/Account/index.js.map +1 -0
- package/lib/screens/Chat/index.js +710 -0
- package/lib/screens/Chat/index.js.map +1 -0
- package/lib/screens/Chores/index.js +18 -0
- package/lib/screens/Chores/index.js.map +1 -0
- package/lib/screens/Connectors/index.js +17 -0
- package/lib/screens/Connectors/index.js.map +1 -0
- package/lib/screens/History/index.js +380 -0
- package/lib/screens/History/index.js.map +1 -0
- package/lib/screens/Home/index.js +2715 -0
- package/lib/screens/Home/index.js.map +1 -0
- package/lib/screens/Home/media.js +25 -0
- package/lib/screens/Home/media.js.map +1 -0
- package/lib/screens/Welcome/index.js +1066 -0
- package/lib/screens/Welcome/index.js.map +1 -0
- package/lib/talk/talkToLucy.js +139 -0
- package/lib/talk/talkToLucy.js.map +1 -0
- package/lib/theme/colors.js +29 -0
- package/lib/theme/colors.js.map +1 -0
- package/lib/theme/fonts.js +17 -0
- package/lib/theme/fonts.js.map +1 -0
- package/lib/theme/muse.js +134 -0
- package/lib/theme/muse.js.map +1 -0
- package/lib/utils/links.js +54 -0
- package/lib/utils/links.js.map +1 -0
- package/lib/utils/yantraLinks.js +68 -0
- package/lib/utils/yantraLinks.js.map +1 -0
- package/lib/welcome/flow.js +375 -0
- package/lib/welcome/flow.js.map +1 -0
- package/lib/welcome/haptics.js +125 -0
- package/lib/welcome/haptics.js.map +1 -0
- package/lib/welcome/parts.js +1996 -0
- package/lib/welcome/parts.js.map +1 -0
- package/lib/welcome/powerOn.js +29 -0
- package/lib/welcome/powerOn.js.map +1 -0
- package/lib/welcome/seen.js +41 -0
- package/lib/welcome/seen.js.map +1 -0
- package/lib/welcome/sound.js +110 -0
- package/lib/welcome/sound.js.map +1 -0
- package/package.json +66 -5
- package/rollup.config.mjs +42 -0
- package/src/.claude-flow/data/pending-insights.jsonl +19 -0
- package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
- package/src/__tests__/auth.test.ts +94 -0
- package/src/__tests__/blackFriday.test.ts +75 -0
- package/src/__tests__/cardTokens.test.ts +77 -0
- package/src/__tests__/chores.test.ts +188 -0
- package/src/__tests__/choresList.test.ts +100 -0
- package/src/__tests__/connectLink.test.ts +21 -0
- package/src/__tests__/content.test.ts +54 -0
- package/src/__tests__/dictation.test.ts +186 -0
- package/src/__tests__/envConfig.test.ts +14 -0
- package/src/__tests__/haptics.test.ts +202 -0
- package/src/__tests__/jobs.test.ts +130 -0
- package/src/__tests__/keyboardCover.test.ts +84 -0
- package/src/__tests__/liveCard.test.ts +39 -0
- package/src/__tests__/lockedPhone.test.ts +355 -0
- package/src/__tests__/lucyMotion.test.ts +34 -0
- package/src/__tests__/platform.test.ts +32 -0
- package/src/__tests__/powerOn.test.ts +62 -0
- package/src/__tests__/protocol.test.ts +125 -0
- package/src/__tests__/push.test.ts +111 -0
- package/src/__tests__/results.test.ts +256 -0
- package/src/__tests__/sound.test.ts +248 -0
- package/src/__tests__/talkToLucy.test.ts +205 -0
- package/src/__tests__/textLink.test.ts +91 -0
- package/src/__tests__/voiceDial.test.ts +53 -0
- package/src/__tests__/welcomeFlow.test.ts +157 -0
- package/src/__tests__/whereLucyWorks.test.ts +81 -0
- package/src/__tests__/yantraLinks.test.ts +96 -0
- package/src/assets/home/loop-day.jpg +0 -0
- package/src/assets/home/loop-day.mp4 +0 -0
- package/src/assets/home/loop-time-back.jpg +0 -0
- package/src/assets/home/loop-time-back.mp4 +0 -0
- package/src/assets/home/loop-where.jpg +0 -0
- package/src/assets/home/loop-where.mp4 +0 -0
- package/src/assets/home/reel-gym.jpg +0 -0
- package/src/assets/home/reel-gym.mp4 +0 -0
- package/src/assets/home/reel-internet.jpg +0 -0
- package/src/assets/home/reel-internet.mp4 +0 -0
- package/src/assets/icon.png +0 -0
- package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/src/assets/lottie/lucy-mark-call.json +1470 -0
- package/src/assets/lottie/lucy-mark-connect.json +2552 -0
- package/src/assets/lottie/lucy-mark-details.json +1735 -0
- package/src/assets/lottie/lucy-mark-email.json +1363 -0
- package/src/assets/lottie/lucy-mark-message.json +1154 -0
- package/src/assets/lottie/lucy-mark-search.json +1067 -0
- package/src/assets/lottie/lucy-mark-think.json +1253 -0
- package/src/assets/lottie/lucy-mark-write.json +1532 -0
- package/src/assets/lottie/time-back.json +16458 -0
- package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/src/assets/sounds/hours-back.m4a +0 -0
- package/src/assets/sounds/meet-lucy.m4a +0 -0
- package/src/assets/sounds/power-on.m4a +0 -0
- package/src/assets/sounds/wind-back.m4a +0 -0
- package/src/assets/sounds/youre-in.m4a +0 -0
- package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/chat/agent.ts +376 -0
- package/src/chat/appFront.ts +39 -0
- package/src/chat/auth.ts +433 -0
- package/src/chat/chores.ts +394 -0
- package/src/chat/connectors.ts +75 -0
- package/src/chat/jobs.ts +228 -0
- package/src/chat/lucyMotion.ts +33 -0
- package/src/chat/protocol.ts +192 -0
- package/src/chat/results.ts +224 -0
- package/src/chat/store.ts +87 -0
- package/src/chat/useDictation.ts +201 -0
- package/src/chat/useLucyChat.ts +458 -0
- package/src/chat/useMyComputer.ts +41 -0
- package/src/chat/whereLucyWorks.ts +97 -0
- package/src/chat/workspace.ts +127 -0
- package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
- package/src/components/AreaShot.tsx +239 -0
- package/src/components/Backdrops.tsx +323 -0
- package/src/components/BottomSheet.tsx +96 -0
- package/src/components/ChatSheets.tsx +565 -0
- package/src/components/ConnectorLogo.tsx +116 -0
- package/src/components/CustomDrawer.tsx +526 -0
- package/src/components/IdeasPane.tsx +318 -0
- package/src/components/ImessageSheet.tsx +280 -0
- package/src/components/KeyboardAvoider.tsx +45 -0
- package/src/components/Logo.tsx +97 -0
- package/src/components/LucyWorking.tsx +122 -0
- package/src/components/Markdown.tsx +219 -0
- package/src/components/Media.tsx +173 -0
- package/src/components/MessagesAppIcon.tsx +51 -0
- package/src/components/MicButton.tsx +92 -0
- package/src/components/ResultCards.tsx +1067 -0
- package/src/components/SignInPrompt.tsx +182 -0
- package/src/components/SignedOut.tsx +47 -0
- package/src/components/TalkToLucyHero.tsx +540 -0
- package/src/components/TalkToLucySheet.tsx +208 -0
- package/src/components/VoiceOrb.tsx +364 -0
- package/src/components/WhereLucyWorks.tsx +261 -0
- package/src/components/WorkspaceSection.tsx +307 -0
- package/src/components/YantraMark.tsx +30 -0
- package/src/components/drawerHeader.tsx +46 -0
- package/src/components/kit.tsx +309 -0
- package/src/components/lottieInstalled.ts +7 -0
- package/src/components/ui.tsx +700 -0
- package/src/components/useSignOut.ts +21 -0
- package/src/components/viewport.tsx +166 -0
- package/src/components/voiceDial.ts +45 -0
- package/src/compute.ts +168 -0
- package/src/config/env-config.ts +50 -0
- package/src/config/routes.ts +28 -0
- package/src/content.ts +217 -0
- package/src/hooks/keyboardCover.ts +70 -0
- package/src/hooks/useKeyboard.ts +135 -0
- package/src/hooks/useReducedMotion.ts +19 -0
- package/src/imessage/openMessages.ts +53 -0
- package/src/imessage/platform.ts +32 -0
- package/src/imessage/textLink.ts +307 -0
- package/src/index.ts +24 -0
- package/src/live/card.ts +62 -0
- package/src/live/liveActivity.ts +192 -0
- package/src/module.ts +8 -0
- package/src/offer/BlackFridayOffer.tsx +394 -0
- package/src/offer/blackFriday.ts +109 -0
- package/src/offer/parts.tsx +650 -0
- package/src/offer/state.ts +78 -0
- package/src/push/push.ts +171 -0
- package/src/push/usePushNotifications.ts +47 -0
- package/src/screens/Account/index.tsx +310 -0
- package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
- package/src/screens/Chat/index.tsx +891 -0
- package/src/screens/Chores/index.tsx +35 -0
- package/src/screens/Connectors/index.tsx +35 -0
- package/src/screens/History/index.tsx +346 -0
- package/src/screens/Home/index.tsx +2776 -0
- package/src/screens/Home/media.ts +31 -0
- package/src/screens/Welcome/index.tsx +1182 -0
- package/src/talk/talkToLucy.ts +187 -0
- package/src/theme/colors.ts +38 -0
- package/src/theme/fonts.ts +30 -0
- package/src/theme/muse.ts +86 -0
- package/src/utils/links.ts +84 -0
- package/src/utils/yantraLinks.ts +94 -0
- package/src/welcome/flow.ts +418 -0
- package/src/welcome/haptics.ts +179 -0
- package/src/welcome/parts.tsx +2160 -0
- package/src/welcome/powerOn.ts +84 -0
- package/src/welcome/seen.ts +68 -0
- package/src/welcome/sound.ts +173 -0
- package/tools/lottie/chat.motion +0 -0
- package/tools/lottie/cloud.motion +0 -0
- package/tools/lottie/generate.mjs +1209 -0
- package/tools/lottie/inter-glyphs.json +4416 -0
- package/tools/lottie/lucy-mark-calendar.motion +0 -0
- package/tools/lottie/lucy-mark-call.motion +0 -0
- package/tools/lottie/lucy-mark-connect.motion +0 -0
- package/tools/lottie/lucy-mark-details.motion +0 -0
- package/tools/lottie/lucy-mark-email.motion +0 -0
- package/tools/lottie/lucy-mark-message.motion +0 -0
- package/tools/lottie/lucy-mark-search.motion +0 -0
- package/tools/lottie/lucy-mark-think.motion +0 -0
- package/tools/lottie/lucy-mark-write.motion +0 -0
- package/tools/lottie/mark.json +1 -0
- package/tools/lottie/mine-none.motion +0 -0
- package/tools/lottie/mine-offline.motion +0 -0
- package/tools/lottie/mine-online.motion +0 -0
- package/tools/lottie/time-back.mjs +604 -0
- package/tools/sounds/render.mjs +730 -0
- package/tsconfig.json +17 -0
- package/README.md +0 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import AsyncStorage from'@react-native-async-storage/async-storage';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const MAX_CHATS = 30;
|
|
21
|
+
const threadKey = (account) => `clockbook.lucy.thread:v1:${account}`;
|
|
22
|
+
const historyKey = (account) => `clockbook.lucy.history:v1:${account}`;
|
|
23
|
+
async function read(key, fallback) {
|
|
24
|
+
try {
|
|
25
|
+
const raw = await AsyncStorage.getItem(key);
|
|
26
|
+
return raw ? JSON.parse(raw) : fallback;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return fallback;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function write(key, value) {
|
|
32
|
+
try {
|
|
33
|
+
await AsyncStorage.setItem(key, JSON.stringify(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const emptyThread = () => ({
|
|
38
|
+
sessionId: null,
|
|
39
|
+
messages: []
|
|
40
|
+
});
|
|
41
|
+
function loadThread(account) {
|
|
42
|
+
return read(threadKey(account), emptyThread());
|
|
43
|
+
}
|
|
44
|
+
function saveThread(account, thread) {
|
|
45
|
+
return write(threadKey(account), __spreadProps(__spreadValues({}, thread), {
|
|
46
|
+
messages: thread.messages.slice(-200)
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
function loadHistory(account) {
|
|
50
|
+
return read(historyKey(account), {
|
|
51
|
+
chats: []
|
|
52
|
+
}).then((h) => {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = h.chats) != null ? _a : [];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function archiveThread(account, thread, title) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!thread.messages.some((m) => m.role === "user"))
|
|
60
|
+
return loadHistory(account);
|
|
61
|
+
const chats = await loadHistory(account);
|
|
62
|
+
const id = (_a = thread.sessionId) != null ? _a : `local-${Date.now()}`;
|
|
63
|
+
const next = [{
|
|
64
|
+
id,
|
|
65
|
+
title,
|
|
66
|
+
at: Date.now(),
|
|
67
|
+
sessionId: thread.sessionId,
|
|
68
|
+
messages: thread.messages.slice(-200)
|
|
69
|
+
}, ...chats.filter((c) => c.id !== id)].slice(0, MAX_CHATS);
|
|
70
|
+
await write(historyKey(account), {
|
|
71
|
+
chats: next
|
|
72
|
+
});
|
|
73
|
+
return next;
|
|
74
|
+
}
|
|
75
|
+
async function removePastChat(account, id) {
|
|
76
|
+
const next = (await loadHistory(account)).filter((c) => c.id !== id);
|
|
77
|
+
await write(historyKey(account), {
|
|
78
|
+
chats: next
|
|
79
|
+
});
|
|
80
|
+
return next;
|
|
81
|
+
}export{archiveThread,emptyThread,loadHistory,loadThread,removePastChat,saveThread};//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sources":["../../src/chat/store.ts"],"sourcesContent":["/**\n * The chat on this phone, per account: the open thread and past chats, as the web chat keeps them in localStorage\n * (chat/thread.ts `cbh-chat:v1:<sub>`, chat/history.ts `cbh-history:v1:<sub>`). The agent holds each session's\n * transcript too, so reopening a past chat and sending carries it on. Nothing here syncs with the web.\n */\nimport AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport interface ChatMessage {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n createdAt: number;\n /** A reply that failed: what went wrong, and whether sending again could fix it. */\n error?: string;\n /** The chore record this reply is (chat/jobs.ts): how it is read back when its stream did not finish here. */\n jobId?: string;\n /** The chore this reply is a turn of: its own id for a new one, the asking reply's chore for an answer. */\n chore?: string;\n /** Lucy is still on it, with nothing here streaming it (the screen left, the app reloaded): read from the record. */\n pending?: boolean;\n}\n\nexport interface Thread {\n sessionId: string | null;\n messages: ChatMessage[];\n}\n\nexport interface PastChat extends Thread {\n id: string;\n title: string;\n at: number;\n}\n\nconst MAX_MESSAGES = 200;\nconst MAX_CHATS = 30;\nconst threadKey = (account: string) => `clockbook.lucy.thread:v1:${account}`;\nconst historyKey = (account: string) => `clockbook.lucy.history:v1:${account}`;\n\nasync function read<T>(key: string, fallback: T): Promise<T> {\n try {\n const raw = await AsyncStorage.getItem(key);\n return raw ? (JSON.parse(raw) as T) : fallback;\n } catch {\n return fallback;\n }\n}\n\nasync function write(key: string, value: unknown): Promise<void> {\n try {\n await AsyncStorage.setItem(key, JSON.stringify(value));\n } catch {\n // storage full or unavailable: the chat still works, it just is not kept\n }\n}\n\nexport const emptyThread = (): Thread => ({ sessionId: null, messages: [] });\n\nexport function loadThread(account: string): Promise<Thread> {\n return read<Thread>(threadKey(account), emptyThread());\n}\n\nexport function saveThread(account: string, thread: Thread): Promise<void> {\n return write(threadKey(account), { ...thread, messages: thread.messages.slice(-MAX_MESSAGES) });\n}\n\nexport function loadHistory(account: string): Promise<PastChat[]> {\n return read<{ chats: PastChat[] }>(historyKey(account), { chats: [] }).then((h) => h.chats ?? []);\n}\n\n/** Files the thread under History (newest first), replacing an earlier copy of the same session. */\nexport async function archiveThread(account: string, thread: Thread, title: string): Promise<PastChat[]> {\n if (!thread.messages.some((m) => m.role === 'user')) return loadHistory(account);\n const chats = await loadHistory(account);\n const id = thread.sessionId ?? `local-${Date.now()}`;\n const next = [\n { id, title, at: Date.now(), sessionId: thread.sessionId, messages: thread.messages.slice(-MAX_MESSAGES) },\n ...chats.filter((c) => c.id !== id),\n ].slice(0, MAX_CHATS);\n await write(historyKey(account), { chats: next });\n return next;\n}\n\nexport async function removePastChat(account: string, id: string): Promise<PastChat[]> {\n const next = (await loadHistory(account)).filter((c) => c.id !== id);\n await write(historyKey(account), { chats: next });\n return next;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,MAAM,SAAY,GAAA,EAAA;AAClB,MAAM,SAAA,GAAY,CAAC,OAAA,KAAoB,CAA4B,yBAAA,EAAA,OAAA,CAAA,CAAA;AACnE,MAAM,UAAA,GAAa,CAAC,OAAA,KAAoB,CAA6B,0BAAA,EAAA,OAAA,CAAA,CAAA;AACrE,eAAe,IAAA,CAAQ,KAAa,QAAyB,EAAA;AAC3D,EAAI,IAAA;AACF,IAAA,MAAM,GAAM,GAAA,MAAM,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AAC1C,IAAA,OAAO,GAAM,GAAA,IAAA,CAAK,KAAM,CAAA,GAAG,CAAS,GAAA,QAAA;AAAA,WAC9B,CAAN,EAAA;AACA,IAAO,OAAA,QAAA;AAAA;AAEX;AACA,eAAe,KAAA,CAAM,KAAa,KAA+B,EAAA;AAC/D,EAAI,IAAA;AACF,IAAA,MAAM,aAAa,OAAQ,CAAA,GAAA,EAAK,IAAK,CAAA,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,WAC/C,CAAN,EAAA;AAAA;AAGJ;AACO,MAAM,cAAc,OAAe;AAAA,EACxC,SAAW,EAAA,IAAA;AAAA,EACX,UAAU;AACZ,CAAA;AACO,SAAS,WAAW,OAAkC,EAAA;AAC3D,EAAA,OAAO,IAAa,CAAA,SAAA,CAAU,OAAO,CAAA,EAAG,aAAa,CAAA;AACvD;AACgB,SAAA,UAAA,CAAW,SAAiB,MAA+B,EAAA;AACzE,EAAA,OAAO,KAAM,CAAA,SAAA,CAAU,OAAO,CAAA,EAAG,iCAC5B,MAD4B,CAAA,EAAA;AAAA,IAE/B,QAAU,EAAA,MAAA,CAAO,QAAS,CAAA,KAAA,CAAM,IAAa;AAAA,GAC9C,CAAA,CAAA;AACH;AACO,SAAS,YAAY,OAAsC,EAAA;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AA,IAAA,GAAA,CAAQ,MAAM,WAAY,CAAA,OAAO,GAAG,MAAO,CAAA,CAAA,CAAA,KAAK,CAAE,CAAA,EAAA,KAAO,EAAE,CAAA;AACjE,EAAM,MAAA,KAAA,CAAM,UAAW,CAAA,OAAO,CAAG,EAAA;AAAA,IAC/B,KAAO,EAAA;AAAA,GACR,CAAA;AACD,EAAO,OAAA,IAAA;AACT"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {useState,useRef,useCallback,useEffect}from'react';import {requireOptionalNativeModule}from'expo-modules-core';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
function speechModule() {
|
|
18
|
+
try {
|
|
19
|
+
return requireOptionalNativeModule("ExpoSpeechRecognition");
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function dictationAvailable() {
|
|
25
|
+
const mod = speechModule();
|
|
26
|
+
if (!mod)
|
|
27
|
+
return false;
|
|
28
|
+
try {
|
|
29
|
+
return typeof mod.isRecognitionAvailable === "function" ? mod.isRecognitionAvailable() : true;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function joinSaid(...parts) {
|
|
35
|
+
return parts.map((p) => (p != null ? p : "").trim()).filter(Boolean).join(" ");
|
|
36
|
+
}
|
|
37
|
+
function levelOf(value) {
|
|
38
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
39
|
+
return 0;
|
|
40
|
+
return Math.min(1, Math.max(0, (value - 0.5) / 7.5));
|
|
41
|
+
}
|
|
42
|
+
function useDictation({
|
|
43
|
+
onText,
|
|
44
|
+
onProblem,
|
|
45
|
+
onLevel
|
|
46
|
+
}) {
|
|
47
|
+
const [listening, setListening] = useState(false);
|
|
48
|
+
const subs = useRef([]);
|
|
49
|
+
const base = useRef("");
|
|
50
|
+
const kept = useRef("");
|
|
51
|
+
const live = useRef("");
|
|
52
|
+
const handlers = useRef({
|
|
53
|
+
onText,
|
|
54
|
+
onProblem,
|
|
55
|
+
onLevel
|
|
56
|
+
});
|
|
57
|
+
handlers.current = {
|
|
58
|
+
onText,
|
|
59
|
+
onProblem,
|
|
60
|
+
onLevel
|
|
61
|
+
};
|
|
62
|
+
const detach = useCallback(() => {
|
|
63
|
+
subs.current.forEach((s) => s.remove());
|
|
64
|
+
subs.current = [];
|
|
65
|
+
}, []);
|
|
66
|
+
const finish = useCallback(() => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
detach();
|
|
69
|
+
setListening(false);
|
|
70
|
+
(_b = (_a = handlers.current).onLevel) == null ? void 0 : _b.call(_a, 0);
|
|
71
|
+
}, [detach]);
|
|
72
|
+
const stop = useCallback(() => {
|
|
73
|
+
const mod = speechModule();
|
|
74
|
+
try {
|
|
75
|
+
mod == null ? void 0 : mod.stop();
|
|
76
|
+
} catch (e) {
|
|
77
|
+
finish();
|
|
78
|
+
}
|
|
79
|
+
}, [finish]);
|
|
80
|
+
const cancel = useCallback(() => {
|
|
81
|
+
var _a;
|
|
82
|
+
finish();
|
|
83
|
+
try {
|
|
84
|
+
(_a = speechModule()) == null ? void 0 : _a.abort();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
}
|
|
87
|
+
}, [finish]);
|
|
88
|
+
const start = useCallback(async (current) => {
|
|
89
|
+
const mod = speechModule();
|
|
90
|
+
if (!mod || !dictationAvailable()) {
|
|
91
|
+
handlers.current.onProblem("unavailable");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const perm = await mod.requestPermissionsAsync();
|
|
96
|
+
if (!perm.granted) {
|
|
97
|
+
handlers.current.onProblem("denied");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
handlers.current.onProblem("failed", err.message);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
base.current = current.trim();
|
|
105
|
+
kept.current = "";
|
|
106
|
+
live.current = "";
|
|
107
|
+
detach();
|
|
108
|
+
subs.current = [
|
|
109
|
+
mod.addListener("result", (e) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
const heard = (_b = (_a = e.results) == null ? void 0 : _a[0]) == null ? void 0 : _b.transcript;
|
|
112
|
+
if (e.isFinal) {
|
|
113
|
+
kept.current = joinSaid(kept.current, heard || live.current);
|
|
114
|
+
live.current = "";
|
|
115
|
+
} else if (heard !== void 0) {
|
|
116
|
+
live.current = heard;
|
|
117
|
+
}
|
|
118
|
+
handlers.current.onText(joinSaid(base.current, kept.current, live.current));
|
|
119
|
+
}),
|
|
120
|
+
mod.addListener("error", (e) => {
|
|
121
|
+
if (e.error !== "no-speech" && e.error !== "aborted" && e.error !== "speech-timeout") {
|
|
122
|
+
handlers.current.onProblem("failed", e.message || e.error);
|
|
123
|
+
}
|
|
124
|
+
finish();
|
|
125
|
+
}),
|
|
126
|
+
mod.addListener("end", finish)
|
|
127
|
+
];
|
|
128
|
+
const loudness = Boolean(handlers.current.onLevel);
|
|
129
|
+
if (loudness) {
|
|
130
|
+
subs.current.push(mod.addListener("volumechange", (e) => {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
return (_b = (_a = handlers.current).onLevel) == null ? void 0 : _b.call(_a, levelOf(e.value));
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
mod.start(__spreadValues({
|
|
137
|
+
lang: "en-US",
|
|
138
|
+
interimResults: true,
|
|
139
|
+
continuous: true,
|
|
140
|
+
addsPunctuation: true,
|
|
141
|
+
requiresOnDeviceRecognition: false
|
|
142
|
+
}, loudness ? {
|
|
143
|
+
volumeChangeEventOptions: {
|
|
144
|
+
enabled: true,
|
|
145
|
+
intervalMillis: 100
|
|
146
|
+
}
|
|
147
|
+
} : {}));
|
|
148
|
+
setListening(true);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
finish();
|
|
151
|
+
handlers.current.onProblem("failed", err.message);
|
|
152
|
+
}
|
|
153
|
+
}, [detach, finish]);
|
|
154
|
+
useEffect(() => () => {
|
|
155
|
+
var _a;
|
|
156
|
+
detach();
|
|
157
|
+
try {
|
|
158
|
+
(_a = speechModule()) == null ? void 0 : _a.abort();
|
|
159
|
+
} catch (e) {
|
|
160
|
+
}
|
|
161
|
+
}, [detach]);
|
|
162
|
+
return {
|
|
163
|
+
listening,
|
|
164
|
+
start,
|
|
165
|
+
stop,
|
|
166
|
+
cancel
|
|
167
|
+
};
|
|
168
|
+
}export{dictationAvailable,levelOf,useDictation};//# sourceMappingURL=useDictation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictation.js","sources":["../../src/chat/useDictation.ts"],"sourcesContent":["/**\n * Speak instead of typing, as Yantra's chat does: the phone's own speech recognition (expo-speech-recognition:\n * SFSpeechRecognizer on iOS, SpeechRecognizer on Android), words arriving live as you talk.\n *\n * The native module is read with requireOptionalNativeModule rather than by importing `expo-speech-recognition`,\n * whose import throws on a binary built before the module was linked; such a binary answers \"unavailable\" instead\n * of crashing.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { requireOptionalNativeModule } from 'expo-modules-core';\n\ntype SpeechEvent = {\n results?: { transcript?: string }[];\n isFinal?: boolean;\n error?: string;\n message?: string;\n /** volumechange: how loud, from -2 (silence) up to 10. */\n value?: number;\n};\ntype SpeechModule = {\n start: (options: Record<string, unknown>) => void;\n stop: () => void;\n abort: () => void;\n requestPermissionsAsync: () => Promise<{ granted: boolean; canAskAgain?: boolean }>;\n isRecognitionAvailable?: () => boolean;\n addListener: (event: string, listener: (e: SpeechEvent) => void) => { remove: () => void };\n};\n\nfunction speechModule(): SpeechModule | null {\n try {\n return requireOptionalNativeModule<SpeechModule>('ExpoSpeechRecognition');\n } catch {\n return null;\n }\n}\n\n/** This binary can do speech recognition (the module is linked and the phone has a recogniser). */\nexport function dictationAvailable(): boolean {\n const mod = speechModule();\n if (!mod) return false;\n try {\n return typeof mod.isRecognitionAvailable === 'function' ? mod.isRecognitionAvailable() : true;\n } catch {\n return false;\n }\n}\n\nexport type DictationProblem = 'unavailable' | 'denied' | 'failed';\n\n/** Pieces of text one after the other, a single space between them; empty pieces drop out. */\nfunction joinSaid(...parts: (string | undefined)[]): string {\n return parts\n .map((p) => (p ?? '').trim())\n .filter(Boolean)\n .join(' ');\n}\n\n/** The recogniser's loudness (-2 for silence up to 10) as 0 to 1: silence 0, ordinary speech about half, a shout 1. */\nexport function levelOf(value: number | undefined): number {\n if (typeof value !== 'number' || !Number.isFinite(value)) return 0;\n return Math.min(1, Math.max(0, (value - 0.5) / 7.5));\n}\n\n/**\n * `start(base)` listens and reports `base` plus what has been said so far through `onText`, live; `stop()` ends it\n * and keeps the words; `cancel()` ends it and drops anything still to come (the message was sent: a late final result\n * must not put the words back in the box). Listening also ends on its own after a silence. Given `onLevel`, it also\n * hears how loud the voice is (0 to 1, about ten times a second) for a mic that moves with it, and 0 once it ends.\n */\nexport function useDictation({\n onText,\n onProblem,\n onLevel,\n}: {\n onText: (text: string) => void;\n onProblem: (problem: DictationProblem, detail?: string) => void;\n onLevel?: (level: number) => void;\n}) {\n const [listening, setListening] = useState(false);\n const subs = useRef<{ remove: () => void }[]>([]);\n const base = useRef('');\n // The parts already finished, and the one still being heard.\n const kept = useRef('');\n const live = useRef('');\n // The latest callbacks, so a listener added at start never calls a stale one.\n const handlers = useRef({ onText, onProblem, onLevel });\n handlers.current = { onText, onProblem, onLevel };\n\n const detach = useCallback(() => {\n subs.current.forEach((s) => s.remove());\n subs.current = [];\n }, []);\n\n const finish = useCallback(() => {\n detach();\n setListening(false);\n handlers.current.onLevel?.(0);\n }, [detach]);\n\n const stop = useCallback(() => {\n const mod = speechModule();\n try {\n mod?.stop();\n } catch {\n finish();\n }\n }, [finish]);\n\n const cancel = useCallback(() => {\n // Listeners off first: the recogniser's final result, still on its way, then lands nowhere.\n finish();\n try {\n speechModule()?.abort();\n } catch {\n // not listening\n }\n }, [finish]);\n\n const start = useCallback(\n async (current: string) => {\n const mod = speechModule();\n if (!mod || !dictationAvailable()) {\n handlers.current.onProblem('unavailable');\n return;\n }\n try {\n const perm = await mod.requestPermissionsAsync();\n if (!perm.granted) {\n handlers.current.onProblem('denied');\n return;\n }\n } catch (err) {\n handlers.current.onProblem('failed', (err as Error).message);\n return;\n }\n base.current = current.trim();\n kept.current = '';\n live.current = '';\n detach();\n subs.current = [\n // Listening runs in parts: after each pause a final result closes the part, and what comes next\n // covers only the words after it (Android 13+; iOS 18 the same, its part starting with a space).\n // Earlier iOS sends one growing transcript and a single final one. Finished parts are kept, so a\n // long message is all there, not just its last sentence.\n mod.addListener('result', (e) => {\n const heard = e.results?.[0]?.transcript;\n if (e.isFinal) {\n kept.current = joinSaid(kept.current, heard || live.current);\n live.current = '';\n } else if (heard !== undefined) {\n live.current = heard;\n }\n handlers.current.onText(joinSaid(base.current, kept.current, live.current));\n }),\n mod.addListener('error', (e) => {\n // Silence or nothing heard is not a failure: it just ends.\n if (e.error !== 'no-speech' && e.error !== 'aborted' && e.error !== 'speech-timeout') {\n handlers.current.onProblem('failed', e.message || e.error);\n }\n finish();\n }),\n mod.addListener('end', finish),\n ];\n // How loud, for a mic that moves with the voice: asked for only when someone is listening for it.\n const loudness = Boolean(handlers.current.onLevel);\n if (loudness) {\n subs.current.push(mod.addListener('volumechange', (e) => handlers.current.onLevel?.(levelOf(e.value))));\n }\n try {\n mod.start({\n lang: 'en-US',\n interimResults: true,\n continuous: true,\n addsPunctuation: true,\n requiresOnDeviceRecognition: false,\n ...(loudness ? { volumeChangeEventOptions: { enabled: true, intervalMillis: 100 } } : {}),\n });\n setListening(true);\n } catch (err) {\n finish();\n handlers.current.onProblem('failed', (err as Error).message);\n }\n },\n [detach, finish],\n );\n\n // Leaving the screen stops listening.\n useEffect(\n () => () => {\n detach();\n try {\n speechModule()?.abort();\n } catch {\n // not listening\n }\n },\n [detach],\n );\n\n return { listening, start, stop, cancel };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAS,YAAoC,GAAA;AAC3C,EAAI,IAAA;AACF,IAAA,OAAO,4BAA0C,uBAAuB,CAAA;AAAA,WAClE,CAAN,EAAA;AACA,IAAO,OAAA,IAAA;AAAA;AAEX;AAGO,SAAS,kBAA8B,GAAA;AAC5C,EAAA,MAAM,MAAM,YAAa,EAAA;AACzB,EAAA,IAAI,CAAC,GAAA;AAAK,IAAO,OAAA,KAAA;AACjB,EAAI,IAAA;AACF,IAAA,OAAO,OAAO,GAAI,CAAA,sBAAA,KAA2B,UAAa,GAAA,GAAA,CAAI,wBAA2B,GAAA,IAAA;AAAA,WACnF,CAAN,EAAA;AACA,IAAO,OAAA,KAAA;AAAA;AAEX;AAIA,SAAS,YAAY,KAAuC,EAAA;AAC1D,EAAA,OAAO,KAAM,CAAA,GAAA,CAAI,CAAM,CAAA,KAAA,CAAA,CAAA,IAAA,IAAA,GAAA,CAAA,GAAK,EAAI,EAAA,IAAA,EAAM,CAAA,CAAE,MAAO,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,GAAG,CAAA;AAClE;AAGO,SAAS,QAAQ,KAAmC,EAAA;AACzD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