Ezmary commited on
Commit
4ad9b66
·
verified ·
1 Parent(s): 2d9a144

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +49 -136
src/App.tsx CHANGED
@@ -1,100 +1,19 @@
1
  /**
2
  Copyright 2024 Google LLC
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
12
  */
13
 
14
  import React, { useEffect, useRef, useState } from "react";
15
  import './App.scss';
16
- import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext"; // اطمینان از ایمپورت صحیح
17
- import ControlTray from "./components/control-tray/ControlTray"; // اطمینان از ایمپورت صحیح
18
- import { IOSModal } from "./components/ios-modal/IOSModal"; // اطمینان از ایمپورت صحیح
19
  import { isIOS } from "./lib/platform";
20
  import cn from "classnames";
21
  import { LiveConfig } from "./multimodal-live-types";
22
 
23
  const myCustomInstruction = `
24
- ت1. هویت دستیار:
25
-
26
- فقط خود را به عنوان "دستیار صوتی و تصویری اپلیکیشن زبانفلای" معرفی کن.
27
-
28
- هرگز خود را محصول یا زیرمجموعه گوگل، اپل یا هیچ شرکت دیگری معرفی نکن.
29
-
30
- در پاسخ به سؤال کاربر درباره هویت، دقیقاً بگو:
31
- "من دستیار صوتی و تصویری اپلیکیشن زبانفلای هستم. چگونه می‌توانم به شما کمک کنم؟"
32
-
33
- مدیریت زبان گفتگو:
34
-
35
- به طور پیش‌فرض، مکالمه را به زبان انگلیسی آغاز کن.
36
-
37
- اگر کاربر با زبانی غیر از انگلیسی صحبت کرد، گفتگو را به همان زبان ادامه بده.
38
-
39
- زبان پاسخ را همیشه مطابق زبان کاربر تنظیم کن. تغییر زبان به صورت خودکار انجام شود.
40
-
41
- بیان اعداد:
42
-
43
- هنگام مکالمه به انگلیسی، اعداد را به صورت کامل به انگلیسی بیان کن (مثلاً: twenty-five).
44
-
45
- هنگام مکالمه به زبانی دیگر، اعداد را به همان زبان بیان کن (مثلاً: بیست و پنج).
46
-
47
- تنظیم صدا و لحن:
48
-
49
- با صدای مایل به بلند و شفاف صحبت کن.
50
-
51
- در صورت درخواست کاربر، صدای خود را بلندتر، آرام‌تر یا به تقلید از صدای خواسته‌شده تغییر بده.
52
-
53
- بدون استثنا، هرگونه تغییر صدای درخواستی کاربر را اجرا کن.
54
-
55
- تعهد به پاسخگویی:
56
-
57
- تحت هیچ شرایطی به کاربر نگو که "نمی‌توانم پاسخ دهم" یا "نمی‌توانم کمک کنم".
58
-
59
- همیشه در تمام زمینه‌ها تلاش کن بهترین پاسخ ممکن را به کاربر ارائه بدهی.
60
-
61
- رفتار در شروع گفتگو:
62
-
63
- اگر پیام ورودی "START_GREETING" دریافت شد، تنها با یکی از جملات کوتاه زیر پاسخ بده:
64
-
65
- "Hello, how can I help you?"
66
-
67
- یا "Hey, what's up?"
68
-
69
- اطلاع‌رسانی درباره اپلیکیشن زبانفلای:
70
-
71
- در صورت نیاز کاربر، توضیح بده که اپلیکیشن زبانفلای در گوگل پلی و کافه بازار قابل دانلود است.
72
-
73
- راهنمایی کن که کاربران می‌توانند با جستجو در این فروشگاه‌ها، اپلیکیشن را نصب کنند.
74
-
75
- پشتیبانی از یادگیری زبان:
76
-
77
- هنگام پاسخگویی، در صورت مرتبط بودن، مثال‌های جمله‌سازی، کاربرد واژگان و اصطلاحات ارائه بده.
78
-
79
- در صورت درخواست کاربر، معانی واژگان، هم‌معنی‌ها، متضادها، و نمونه جمله‌ها را هم ارائه بده.
80
-
81
- تمرین شنیداری و گفتاری:
82
-
83
- اگر کاربر بخواهد، جمله‌ای را بخوان و از او بخواه آن را تکرار کند (تمرین shadowing).
84
-
85
- فرصت کامل برای تکرار بده و کاربر را با بازخورد مثبت تشویق کن.
86
-
87
- شخصی‌سازی تجربه یادگیری:
88
-
89
- در صورت درخواست کاربر، سرعت مکالمه را کند یا تند کن.
90
-
91
- سطح سختی واژگان و جملات را بر اساس سطح کاربر (مبتدی، متوسط، پیشرفته) تنظیم کن.
92
-
93
- **تعامل تصویری:**
94
- - به تصویر زنده‌ای که از کاربر دریافت می‌کنی توجه کن.
95
- - اگر در تصویر نکته قابل توجهی وجود دارد (مانند حالت چهره، اشیاء خاص، یا محیط اطراف کاربر)، می‌توانی به آن در مکالمه اشاره کنی، البته فقط اگر مرتبط با موضوع صحبت باشد یا کاربر از تو بخواهد.
96
- - اگر کاربر سوالی در مورد چیزی که در تصویر می‌بیند پرسید، سعی کن بر اساس تصویر پاسخ دهی.
97
- - هدف اصلی، کمک به یادگیری زبان است، پس تعامل تصویری باید در خدمت این هدف باشد.
98
  `.trim();
99
 
100
  const initialAppConfig: LiveConfig = {
@@ -106,17 +25,24 @@ const initialAppConfig: LiveConfig = {
106
 
107
  // آیکون انسان
108
  const SvgHumanIcon = () => (
109
- <svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/><path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
 
 
 
 
 
110
  );
111
 
112
  // SVG آیکون میکروفون از HTML مرجع (با سه خط افقی)
 
113
  const SvgReferenceMicrophoneIcon = () => (
114
- <svg width="38" height="38" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg" transform="scale(0.55)">
115
  <path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
116
  <path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
117
  </svg>
118
  );
119
 
 
120
  const AppInternalLogic: React.FC<{
121
  isMicActive: boolean;
122
  isCamActive: boolean;
@@ -129,6 +55,7 @@ const AppInternalLogic: React.FC<{
129
  isNotificationOpen: boolean;
130
  setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
131
  }> = ({
 
132
  isMicActive,
133
  isCamActive,
134
  setIsMicActive,
@@ -140,6 +67,7 @@ const AppInternalLogic: React.FC<{
140
  isNotificationOpen,
141
  setIsNotificationOpen
142
  }) => {
 
143
  const { connected, disconnect } = useLiveAPIContext();
144
 
145
  useEffect(() => {
@@ -151,6 +79,7 @@ const AppInternalLogic: React.FC<{
151
  return (
152
  <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
153
  <div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
 
154
  <div className="header-controls">
155
  <div id="notification-trigger-container">
156
  <button
@@ -191,7 +120,6 @@ const AppInternalLogic: React.FC<{
191
  </div>
192
  </div>
193
  </div>
194
-
195
  <div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
196
  <video
197
  id="video-feed"
@@ -203,6 +131,7 @@ const AppInternalLogic: React.FC<{
203
  { "hidden": !isCamActive }
204
  )}
205
  />
 
206
  {isMicActive && !isCamActive && (
207
  <div
208
  id="large-logo-container"
@@ -230,69 +159,40 @@ const AppInternalLogic: React.FC<{
230
  }
231
 
232
  const logoColorConfig = {
233
- blue: {
234
- ping: "bg-blue-200 dark:bg-blue-700",
235
- outer: "bg-blue-200 dark:bg-blue-700",
236
- mid: "bg-blue-300 dark:bg-blue-600",
237
- inner: "bg-blue-400 dark:bg-blue-500",
238
- },
239
- green: {
240
- ping: "bg-green-200 dark:bg-green-700",
241
- outer: "bg-green-200 dark:bg-green-700",
242
- mid: "bg-green-300 dark:bg-green-600",
243
- inner: "bg-green-400 dark:bg-green-500",
244
- },
245
- gray: {
246
- ping: "bg-gray-200 dark:bg-gray-700",
247
- outer: "bg-gray-200 dark:bg-gray-700",
248
- mid: "bg-gray-300 dark:bg-gray-600",
249
- inner: "bg-gray-400 dark:bg-gray-500",
250
- }
251
  };
252
 
253
  function App() {
 
254
  const videoRef = useRef<HTMLVideoElement>(null);
255
  const [showIOSModal, setShowIOSModal] = useState(false);
256
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
257
-
258
  const [isMicActive, setIsMicActive] = useState(false);
259
  const [isCamActive, setIsCamActive] = useState(false);
260
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
261
-
262
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
263
  const notificationButtonRef = useRef<HTMLButtonElement>(null);
264
 
265
  useEffect(() => {
266
- if (isIOS()) {
267
- setShowIOSModal(true);
268
- }
269
- const timer = setTimeout(() => {
270
- setIsAllowedOrigin(true);
271
- }, 100);
272
  return () => clearTimeout(timer);
273
  }, []);
274
 
275
  useEffect(() => {
276
  const handleClickOutside = (event: MouseEvent) => {
277
- if (
278
- isNotificationOpen &&
279
- notificationPopoverRef.current &&
280
- !notificationPopoverRef.current.contains(event.target as Node) &&
281
- notificationButtonRef.current &&
282
- !notificationButtonRef.current.contains(event.target as Node)
283
- ) {
284
  setIsNotificationOpen(false);
285
  }
286
  };
287
  document.addEventListener("mousedown", handleClickOutside);
288
- return () => {
289
- document.removeEventListener("mousedown", handleClickOutside);
290
- };
291
  }, [isNotificationOpen]);
292
 
293
- if (isAllowedOrigin === null) {
294
- return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>;
295
- }
296
 
297
  const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
298
  if (!isActive) return null;
@@ -300,34 +200,47 @@ function App() {
300
  const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
301
  const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
302
 
303
- const size = isMini ? 80 : 200;
304
- const iconDisplaySize = isMini ? 35 : 70; // Size for the SvgHumanIcon's visual container
 
 
 
 
305
 
306
  const insetBase = {
307
  ping: isMini ? 10 : 40,
308
- outer: 0,
309
  mid: isMini ? 5 : 20,
310
  inner: isMini ? 12 : 50,
311
- // icon inset calculation to center it based on its display size and overall logo size
312
- icon: (size - iconDisplaySize) / 2
313
  };
314
 
315
  const IconComponent = type === 'human' ? SvgHumanIcon : null;
316
 
317
  return (
318
- <div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
 
319
  <div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${insetBase.ping}px` }}></div>
320
  <div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
321
  <div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
322
  <div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
323
- <div className="z-10 absolute flex items-center justify-center" style={{ inset: `${insetBase.icon}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
 
 
 
 
 
 
 
 
 
 
324
  {IconComponent && <IconComponent />}
325
  </div>
326
  </div>
327
  );
328
  };
329
 
330
-
331
  return (
332
  <LiveAPIProvider initialConfig={initialAppConfig}>
333
  <AppInternalLogic
 
1
  /**
2
  Copyright 2024 Google LLC
3
+ ... (لایسنس و توضیحات دیگر مثل قبل) ...
 
 
 
 
 
 
 
 
4
  */
5
 
6
  import React, { useEffect, useRef, useState } from "react";
7
  import './App.scss';
8
+ import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
9
+ import ControlTray from "./components/control-tray/ControlTray";
10
+ import { IOSModal } from "./components/ios-modal/IOSModal";
11
  import { isIOS } from "./lib/platform";
12
  import cn from "classnames";
13
  import { LiveConfig } from "./multimodal-live-types";
14
 
15
  const myCustomInstruction = `
16
+ ... (دستورالعمل سفارشی شما بدون تغییر) ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  `.trim();
18
 
19
  const initialAppConfig: LiveConfig = {
 
25
 
26
  // آیکون انسان
27
  const SvgHumanIcon = () => (
28
+ // viewBox="0 0 88 89" یعنی اندازه ذاتی آیکون 88x89 است
29
+ // width و height روی 100% تنظیم می‌شوند تا با کانتینر خود مقیاس شوند
30
+ <svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
31
+ <path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/>
32
+ <path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/>
33
+ </svg>
34
  );
35
 
36
  // SVG آیکون میکروفون از HTML مرجع (با سه خط افقی)
37
+ // *** حذف transform="scale(0.55)" از اینجا ***
38
  const SvgReferenceMicrophoneIcon = () => (
39
+ <svg width="38" height="38" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg">
40
  <path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
41
  <path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
42
  </svg>
43
  );
44
 
45
+
46
  const AppInternalLogic: React.FC<{
47
  isMicActive: boolean;
48
  isCamActive: boolean;
 
55
  isNotificationOpen: boolean;
56
  setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
57
  }> = ({
58
+ // ... (props مثل قبل) ...
59
  isMicActive,
60
  isCamActive,
61
  setIsMicActive,
 
67
  isNotificationOpen,
68
  setIsNotificationOpen
69
  }) => {
70
+ // ... (useEffect و disconnect مثل قبل) ...
71
  const { connected, disconnect } = useLiveAPIContext();
72
 
73
  useEffect(() => {
 
79
  return (
80
  <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
81
  <div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
82
+ {/* ... (Header and Notification Popover without change) ... */}
83
  <div className="header-controls">
84
  <div id="notification-trigger-container">
85
  <button
 
120
  </div>
121
  </div>
122
  </div>
 
123
  <div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
124
  <video
125
  id="video-feed"
 
131
  { "hidden": !isCamActive }
132
  )}
133
  />
134
+ {/* انیمیشن لوگوی بزرگ: فقط وقتی میکروفون فعال و دوربین غیرفعال است */}
135
  {isMicActive && !isCamActive && (
136
  <div
137
  id="large-logo-container"
 
159
  }
160
 
161
  const logoColorConfig = {
162
+ // ... (بدون تغییر) ...
163
+ blue: {ping: "bg-blue-200 dark:bg-blue-700", outer: "bg-blue-200 dark:bg-blue-700", mid: "bg-blue-300 dark:bg-blue-600", inner: "bg-blue-400 dark:bg-blue-500"},
164
+ green: {ping: "bg-green-200 dark:bg-green-700", outer: "bg-green-200 dark:bg-green-700", mid: "bg-green-300 dark:bg-green-600", inner: "bg-green-400 dark:bg-green-500"},
165
+ gray: {ping: "bg-gray-200 dark:bg-gray-700", outer: "bg-gray-200 dark:bg-gray-700", mid: "bg-gray-300 dark:bg-gray-600", inner: "bg-gray-400 dark:bg-gray-500"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  };
167
 
168
  function App() {
169
+ // ... (state ها و useEffect ها مثل قبل) ...
170
  const videoRef = useRef<HTMLVideoElement>(null);
171
  const [showIOSModal, setShowIOSModal] = useState(false);
172
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
 
173
  const [isMicActive, setIsMicActive] = useState(false);
174
  const [isCamActive, setIsCamActive] = useState(false);
175
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
 
176
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
177
  const notificationButtonRef = useRef<HTMLButtonElement>(null);
178
 
179
  useEffect(() => {
180
+ if (isIOS()) setShowIOSModal(true);
181
+ const timer = setTimeout(() => setIsAllowedOrigin(true), 100);
 
 
 
 
182
  return () => clearTimeout(timer);
183
  }, []);
184
 
185
  useEffect(() => {
186
  const handleClickOutside = (event: MouseEvent) => {
187
+ if (isNotificationOpen && notificationPopoverRef.current && !notificationPopoverRef.current.contains(event.target as Node) && notificationButtonRef.current && !notificationButtonRef.current.contains(event.target as Node)) {
 
 
 
 
 
 
188
  setIsNotificationOpen(false);
189
  }
190
  };
191
  document.addEventListener("mousedown", handleClickOutside);
192
+ return () => document.removeEventListener("mousedown", handleClickOutside);
 
 
193
  }, [isNotificationOpen]);
194
 
195
+ if (isAllowedOrigin === null) return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>;
 
 
196
 
197
  const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
198
  if (!isActive) return null;
 
200
  const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
201
  const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
202
 
203
+ const overallSize = isMini ? 80 : 200; // اندازه کلی انیمیشن لوگو
204
+ const iconContainerSize = isMini ? 35 : 70; // اندازه کانتینر نمایش آیکون آدمک
205
+
206
+ // محاسبه دقیق inset برای مرکز کردن آیکون آدمک درون حلقه‌ها
207
+ // این مقدار باید فاصله از لبه کانتینر overallSize تا لبه کانتینر iconContainerSize باشد
208
+ const iconInsetCalculated = (overallSize - iconContainerSize) / 2;
209
 
210
  const insetBase = {
211
  ping: isMini ? 10 : 40,
212
+ outer: 0, // حلقه بیرونی باید از لبه شروع شود
213
  mid: isMini ? 5 : 20,
214
  inner: isMini ? 12 : 50,
215
+ icon: iconInsetCalculated // استفاده از مقدار محاسبه شده
 
216
  };
217
 
218
  const IconComponent = type === 'human' ? SvgHumanIcon : null;
219
 
220
  return (
221
+ <div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${overallSize}px`, height: `${overallSize}px` }}>
222
+ {/* حلقه‌های انیمیشن */}
223
  <div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${insetBase.ping}px` }}></div>
224
  <div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
225
  <div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
226
  <div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
227
+ {/* کانتینر آیکون آدمک */}
228
+ <div className="z-10 absolute flex items-center justify-center"
229
+ style={{
230
+ width: `${iconContainerSize}px`,
231
+ height: `${iconContainerSize}px`,
232
+ top: `${insetBase.icon}px`, // فاصله از بالا
233
+ left: `${insetBase.icon}px`, // فاصله از چپ
234
+ // right و bottom هم برای اطمینان (اگرچه با top/left و width/height کافی است)
235
+ right: `${insetBase.icon}px`,
236
+ bottom: `${insetBase.icon}px`,
237
+ }}>
238
  {IconComponent && <IconComponent />}
239
  </div>
240
  </div>
241
  );
242
  };
243
 
 
244
  return (
245
  <LiveAPIProvider initialConfig={initialAppConfig}>
246
  <AppInternalLogic