Ezmary commited on
Commit
094fd2d
·
verified ·
1 Parent(s): 1476e59

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +322 -207
src/App.tsx CHANGED
@@ -1,8 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import React, { useEffect, useRef, useState } from "react";
2
- // import "./App.scss"; // ممکن است بخواهید این را کامنت یا حذف کنید اگر با استایل‌های جدید تداخل دارد
3
  import { LiveAPIProvider } from "./contexts/LiveAPIContext";
4
- import SidePanel from "./components/side-panel/SidePanel";
5
- import { Altair } from "./components/altair/Altair";
 
6
  import ControlTray from "./components/control-tray/ControlTray";
7
  import { IOSModal } from "./components/ios-modal/IOSModal";
8
  import { isIOS } from "./lib/platform";
@@ -13,75 +27,8 @@ import { LiveConfig } from "./multimodal-live-types";
13
  const ALLOWED_ORIGIN = "https://www.aisada.ir"; // یا "http://www.aisada.ir"; // یا "https://aisada.ir"; // یا "http://aisada.ir" اگر سایتتان http است
14
  // --- 👆 ---
15
 
16
- // Helper component for SVGs to avoid repetition (or you can use an SVG loader)
17
- const SvgIcon = ({ path, viewBox = "0 0 24 24", width = "24", height = "24", className = "" }) => (
18
- <svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox={viewBox} fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
19
- {path}
20
- </svg>
21
- );
22
-
23
-
24
- function App() {
25
- const videoRef = useRef<HTMLVideoElement>(null);
26
- const [videoStream, setVideoStream] = useState<MediaStream | null>(null);
27
- const [showIOSModal, setShowIOSModal] = useState(false);
28
- const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
29
- const [isNotificationOpen, setIsNotificationOpen] = useState(false);
30
- const notificationPopoverRef = useRef<HTMLDivElement>(null);
31
- const notificationButtonRef = useRef<HTMLButtonElement>(null);
32
-
33
-
34
- useEffect(() => {
35
- if (isIOS()) {
36
- setShowIOSModal(true);
37
- }
38
-
39
- try {
40
- if (window.self !== window.top) {
41
- if (window.location.ancestorOrigins && window.location.ancestorOrigins.length > 0) {
42
- const parentOrigin = window.location.ancestorOrigins[0];
43
- console.log("Parent Origin:", parentOrigin);
44
- if (parentOrigin === ALLOWED_ORIGIN) {
45
- setIsAllowedOrigin(true);
46
- } else {
47
- console.warn(`Blocked load from origin: ${parentOrigin}`);
48
- setIsAllowedOrigin(false);
49
- }
50
- } else {
51
- console.warn("Cannot verify parent origin (ancestorOrigins not available/empty). Blocking.");
52
- setIsAllowedOrigin(false);
53
- }
54
- } else {
55
- // اگر میخواهید مستقیما هم کار کند این خط را true کنید، برای هاگینگ فیس معمولا false بهتر است
56
- // setIsAllowedOrigin(true); // For direct loading if needed
57
- console.warn("App loaded directly, not in an iframe. Blocking.");
58
- setIsAllowedOrigin(false); // Default behavior
59
- }
60
- } catch (e) {
61
- console.error("Cross-origin access error, cannot verify parent. Blocking.", e);
62
- setIsAllowedOrigin(false);
63
- }
64
-
65
- // Click outside handler for notification
66
- const handleClickOutside = (event: MouseEvent) => {
67
- if (
68
- notificationPopoverRef.current &&
69
- !notificationPopoverRef.current.contains(event.target as Node) &&
70
- notificationButtonRef.current &&
71
- !notificationButtonRef.current.contains(event.target as Node)
72
- ) {
73
- setIsNotificationOpen(false);
74
- }
75
- };
76
-
77
- document.addEventListener('click', handleClickOutside);
78
- return () => {
79
- document.removeEventListener('click', handleClickOutside);
80
- };
81
-
82
- }, []);
83
-
84
- const myCustomInstruction = `
85
  ت1. هویت دستیار:
86
 
87
  فقط خود را به عنوان "دستیار صوتی و تصویری اپلیکیشن زبانفلای" معرفی کن.
@@ -151,86 +98,89 @@ function App() {
151
 
152
  سطح سختی واژگان و جملات را بر اساس سطح کاربر (مبتدی، متوسط، پیشرفته) تنظیم کن.".
153
  `.trim();
 
154
 
155
- const initialAppConfig: LiveConfig = {
156
- model: "models/gemini-2.0-flash-exp",
157
- systemInstruction: {
158
- parts: [{ text: myCustomInstruction }]
159
- }
160
- };
161
 
162
- const newStyles = `
163
- :root {
164
- --radius: 0.625rem; /* 10px */
165
- --radius-md: 0.5rem; /* 8px */
166
- --background: oklch(1 0 0);
167
- --foreground: oklch(0.145 0 0);
168
- --popover: oklch(1 0 0);
169
- --popover-foreground: oklch(0.145 0 0);
170
- --border: oklch(0.922 0 0);
171
- }
172
- .dark {
173
- --background: oklch(0.145 0 0);
174
- --foreground: oklch(0.985 0 0);
175
- --popover: oklch(0.205 0 0);
176
- --popover-foreground: oklch(0.985 0 0);
177
- --border: oklch(1 0 0 / 10%);
178
- }
179
- body { background-color: var(--background); color: var(--foreground); overflow-x: hidden; }
180
- * { border-color: var(--border); /* Tailwind applies border-border */ }
181
-
182
- .notification-popover-wrapper {
183
- position: fixed; top: 1rem; left: 50%;
184
- transform: translateX(-50%); z-index: 100;
185
- width: calc(100% - 2rem); max-width: 28rem;
186
- display: flex; justify-content: center; pointer-events: none;
187
- }
188
- .popover-content {
189
- width: 100%; border-radius: var(--radius-md, 0.5rem);
190
- border-width: 1px; border-color: var(--border);
191
- background-color: var(--popover); color: var(--popover-foreground);
192
- box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
193
- outline: none;
194
- transition: opacity 0.3s ease-out, transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
195
- opacity: 0; transform: translateY(-100%) scale(0.9); pointer-events: none;
196
- }
197
- .popover-content.open {
198
- opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
199
- }
200
- .notification-popover-text-content {
201
- background-color: #eff6ff; font-size: 0.875rem; line-height: 1.5rem; direction: rtl;
202
- padding: 1rem; border-radius: var(--radius-md, 0.5rem);
203
- color: oklch(0.145 0 0);
204
- }
205
- .dark .notification-popover-text-content {
206
- background-color: oklch(0.25 0.05 230); color: oklch(0.95 0.01 230);
207
- }
208
- .header-controls {
209
- display: flex; padding: 1rem; justify-content: space-between; align-items: center;
210
- width: 100%; position: absolute; top: 0; left: 0; z-index: 10;
211
  }
212
- .header-button {
213
- display: flex; align-items: center; justify-content: center;
214
- padding: 0.5rem; border-radius: var(--radius-lg, 0.625rem);
215
- background-color: #e5e7eb; /* bg-gray-200 */
216
- cursor: pointer; transition: background-color 0.2s;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
- .header-button:hover { background-color: #d1d5db; /* bg-gray-300 */ }
219
- .header-button svg { opacity: 0.7; stroke: #374151 /* gray-700 */; }
220
- .dark .header-button { background-color: oklch(0.28 0 0); }
221
- .dark .header-button:hover { background-color: oklch(0.35 0 0); }
222
- .dark .header-button svg { opacity: 0.8; stroke: oklch(0.85 0 0); }
223
-
224
- /* Styles for ControlTray will be in ControlTray.tsx or its own CSS if preferred */
225
- /* Ensure .App container itself doesn't constrain width too much if SidePanel is present */
226
- .App { display: flex; flex-direction: column; min-height: 100vh; }
227
- .streaming-console { flex-grow: 1; display: flex; } /* Assuming SidePanel and main are siblings */
228
- main { flex-grow: 1; position: relative; /* For positioning ControlTray */ }
229
- .main-app-area { position: relative; width: 100%; height: 100%; /* Or specific height like 90dvh */ }
230
-
231
- /* Hide original Altair styling if it conflicts */
232
- /* .user-query-container, .system-response-container { display: none !important; } */
233
- `;
 
 
 
 
234
 
235
  if (isAllowedOrigin === null) {
236
  return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>;
@@ -239,84 +189,249 @@ function App() {
239
  if (isAllowedOrigin === false) {
240
  return <div style={{ padding: '20px', textAlign: 'center', color: 'red' }}>دسترسی غیرمجاز! اگر چت صوتی و تصویری برای شما باز نمیشود این لینک رو با مرورگر کروم باز کنید و همچنین مرورگر کروم رو به عنوان مرورگر پیشفرض گوشی خود قرار دهید تا هر بار زدن روی دکمه شروع داخل برنامه لینک با مرورگر کروم باز بشه، برای پیشفرض قرار دادن مرورگر کروم وارد تنظیمات گوشی خود شوید قسمت برنامه ها ، مدیریت برنامه ها رو کلیک کنید بالای صفحه روی سه نقطه بزنید و تنظیمات بیشتر رو انتخاب کنید بعدا وارد قسمت برنامه های پیش فرض شوید و مرورگر کروم رو به عنوان مرورگر پیشفرض خود قرار دهید، اگر مشکلی بود حتماً به پشتیبانی برنامه پیام بفرستید</div>;
241
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
  return (
244
  <>
245
- <style>{newStyles}</style> {/* Injecting new styles */}
246
- <div className="App antialiased"> {/* Added antialiased from body */}
247
- <LiveAPIProvider initialConfig={initialAppConfig}>
248
- {/* Header Controls from new HTML */}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  <div className="header-controls">
250
- <div className="notification-trigger-container">
251
- <button
252
- ref={notificationButtonRef}
253
- id="notification-button"
254
- aria-label="Notifications"
255
- className="header-button"
256
- onClick={(e) => {
257
- e.stopPropagation();
258
- setIsNotificationOpen(!isNotificationOpen);
259
- }}
260
- >
261
- <SvgIcon path={<><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></>} />
262
- </button>
263
- </div>
264
- <div className="back-button-container">
265
- <div className="header-button" onClick={() => alert('Back clicked (ZabanFly)')}> {/* Replace alert with actual back logic */}
266
- <SvgIcon path={<path d="m15 18-6-6 6-6"></path>} width="20" height="20" />
267
- </div>
268
  </div>
269
  </div>
270
 
271
  {/* Notification Popover */}
272
- <div id="notification-popover-wrapper" className="notification-popover-wrapper">
273
  <div
274
- ref={notificationPopoverRef}
275
  id="notification-popover"
276
- className={cn("popover-content", { open: isNotificationOpen })}
277
- // Animation classes can be controlled by 'open' state via Tailwind or CSS transitions
 
 
278
  >
279
  <div className="notification-popover-text-content">
280
  مدل‌های هوش مصنوعی می‌توانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از وارد کردن اطلاعات حساس بپرهیزید.
281
  </div>
282
  </div>
283
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
- <div className="streaming-console">
286
- <SidePanel /> {/* Kept SidePanel, might need style adjustments */}
287
- <main>
288
- <div className={cn("main-app-area w-full flex flex-col items-center justify-center min-h-[90dvh] md:min-h-screen bg-background top-0 left-0 relative")}>
289
- <Altair /> {/* This is where conversation happens */}
290
- <video
291
- id="video-feed" // From new HTML
292
- className={cn(
293
- "absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]",
294
- { hidden: !videoStream } // Controlled by videoStream state
295
- )}
296
- ref={videoRef}
297
- autoPlay
298
- playsInline
299
- />
300
- {/* large-logo-container might be managed by ControlTray or here based on cam/mic state */}
301
- <div id="large-logo-container" className="hidden absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
302
- {/* Content for large logo will be dynamic based on mic state if cam is off */}
303
- </div>
304
- </div>
305
- <ControlTray
306
- videoRef={videoRef}
307
- supportsVideo={true}
308
- onVideoStreamChange={setVideoStream}
309
- // Pass any other necessary props from new HTML logic if ControlTray needs them
310
- />
311
- </main>
312
  </div>
313
- </LiveAPIProvider>
314
-
315
- <IOSModal
316
- isOpen={showIOSModal}
317
- onClose={() => setShowIOSModal(false)}
318
- />
319
  </div>
 
 
320
  </>
321
  );
322
  }
 
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"; // اگر فایل App.scss جداگانه دارید
16
  import { LiveAPIProvider } from "./contexts/LiveAPIContext";
17
+ // SidePanel و Altair دیگر مستقیما اینجا استفاده نمی‌شوند، مگر اینکه بخواهید آنها را در جای دیگری از UI جدید قرار دهید.
18
+ // import SidePanel from "./components/side-panel/SidePanel";
19
+ // import { Altair } from "./components/altair/Altair";
20
  import ControlTray from "./components/control-tray/ControlTray";
21
  import { IOSModal } from "./components/ios-modal/IOSModal";
22
  import { isIOS } from "./lib/platform";
 
27
  const ALLOWED_ORIGIN = "https://www.aisada.ir"; // یا "http://www.aisada.ir"; // یا "https://aisada.ir"; // یا "http://aisada.ir" اگر سایتتان http است
28
  // --- 👆 ---
29
 
30
+ // --- 👇 دستورالعمل شخصی‌سازی شما (بدون تغییر) 👇 ---
31
+ const myCustomInstruction = `
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ت1. هویت دستیار:
33
 
34
  فقط خود را به عنوان "دستیار صوتی و تصویری اپلیکیشن زبانفلای" معرفی کن.
 
98
 
99
  سطح سختی واژگان و جملات را بر اساس سطح کاربر (مبتدی، متوسط، پیشرفته) تنظیم کن.".
100
  `.trim();
101
+ // --- 👆 ---
102
 
103
+ const initialAppConfig: LiveConfig = {
104
+ model: "models/gemini-2.0-flash-exp",
105
+ systemInstruction: {
106
+ parts: [{ text: myCustomInstruction }],
107
+ },
108
+ };
109
 
110
+ // SVG Icons (می‌توانید این‌ها را به فایل‌های جداگانه منتقل کنید و ایمپورت کنید اگر تمایل دارید)
111
+ const SvgHumanIcon = () => (
112
+ <svg width="70" height="70" 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="#FCFCFC" 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="#FCFCFC" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
113
+ );
114
+
115
+
116
+ function App() {
117
+ const videoRef = useRef<HTMLVideoElement>(null);
118
+ const [videoStream, setVideoStream] = useState<MediaStream | null>(null); // این توسط ControlTray مدیریت می‌شود
119
+ const [showIOSModal, setShowIOSModal] = useState(false);
120
+ const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
121
+
122
+ const [isMicActive, setIsMicActive] = useState(false);
123
+ const [isCamActive, setIsCamActive] = useState(false);
124
+ const [isNotificationOpen, setIsNotificationOpen] = useState(false);
125
+
126
+ const notificationPopoverRef = useRef<HTMLDivElement>(null);
127
+ const notificationButtonRef = useRef<HTMLButtonElement>(null);
128
+
129
+
130
+ useEffect(() => {
131
+ if (isIOS()) {
132
+ setShowIOSModal(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
+ try {
135
+ if (window.self !== window.top) {
136
+ if (window.location.ancestorOrigins && window.location.ancestorOrigins.length > 0) {
137
+ const parentOrigin = window.location.ancestorOrigins[0];
138
+ console.log("Parent Origin:", parentOrigin);
139
+ if (parentOrigin === ALLOWED_ORIGIN) {
140
+ setIsAllowedOrigin(true);
141
+ } else {
142
+ console.warn(`Blocked load from origin: ${parentOrigin}`);
143
+ setIsAllowedOrigin(false);
144
+ }
145
+ } else {
146
+ console.warn("Cannot verify parent origin (ancestorOrigins not available/empty). Blocking.");
147
+ setIsAllowedOrigin(false);
148
+ }
149
+ } else {
150
+ // اگر مستقیماً بارگذاری شده و نه در یک iframe از دامنه مجاز، آن را مسدود کنید
151
+ // مگر اینکه بخواهید برای تست محلی به آن اجازه دهید
152
+ if (process.env.NODE_ENV === 'development' && window.location.hostname === 'localhost') {
153
+ console.warn("App loaded directly in development. Allowed for local testing.");
154
+ setIsAllowedOrigin(true);
155
+ } else {
156
+ console.warn("App loaded directly, not in an iframe from allowed origin. Blocking.");
157
+ setIsAllowedOrigin(false);
158
+ }
159
+ }
160
+ } catch (e) {
161
+ console.error("Cross-origin access error, cannot verify parent. Blocking.", e);
162
+ setIsAllowedOrigin(false);
163
  }
164
+ }, []);
165
+
166
+ useEffect(() => {
167
+ const handleClickOutside = (event: MouseEvent) => {
168
+ if (
169
+ isNotificationOpen &&
170
+ notificationPopoverRef.current &&
171
+ !notificationPopoverRef.current.contains(event.target as Node) &&
172
+ notificationButtonRef.current &&
173
+ !notificationButtonRef.current.contains(event.target as Node)
174
+ ) {
175
+ setIsNotificationOpen(false);
176
+ }
177
+ };
178
+ document.addEventListener("mousedown", handleClickOutside);
179
+ return () => {
180
+ document.removeEventListener("mousedown", handleClickOutside);
181
+ };
182
+ }, [isNotificationOpen]);
183
+
184
 
185
  if (isAllowedOrigin === null) {
186
  return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>;
 
189
  if (isAllowedOrigin === false) {
190
  return <div style={{ padding: '20px', textAlign: 'center', color: 'red' }}>دسترسی غیرمجاز! اگر چت صوتی و تصویری برای شما باز نمیشود این لینک رو با مرورگر کروم باز کنید و همچنین مرورگر کروم رو به عنوان مرورگر پیشفرض گوشی خود قرار دهید تا هر بار زدن روی دکمه شروع داخل برنامه لینک با مرورگر کروم باز بشه، برای پیشفرض قرار دادن مرورگر کروم وارد تنظیمات گوشی خود شوید قسمت برنامه ها ، مدیریت برنامه ها رو کلیک کنید بالای صفحه روی سه نقطه بزنید و تنظیمات بیشتر رو انتخاب کنید بعدا وارد قسمت برنامه های پیش فرض شوید و مرورگر کروم رو به عنوان مرورگر پیشفرض خود قرار دهید، اگر مشکلی بود حتماً به پشتیبانی برنامه پیام بفرستید</div>;
191
  }
192
+
193
+ // تابع برای ساخت لوگو (ساده شده)
194
+ const createLogoHTML = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human') => {
195
+ if (!isActive) return null;
196
+ const size = isMini ? 80 : 200;
197
+ const iconSize = isMini ? 35 : 70;
198
+ const insetBase = isMini
199
+ ? { ping: 10, outer: 0, mid: 5, inner: 12, icon: 22 }
200
+ : { ping: 40, outer: 0, mid: 20, inner: 50, icon: 65 };
201
+ const bgColorBase = type === 'human' ? 'blue' : 'green';
202
+
203
+ return (
204
+ <div className="relative" style={{ width: `${size}px`, height: `${size}px` }}>
205
+ <div className={`absolute rounded-full opacity-50 animate-ping bg-${bgColorBase}-200`} style={{ inset: `${insetBase.ping}px` }}></div>
206
+ <div className={`absolute inset-0 rounded-full opacity-50 bg-${bgColorBase}-200`} style={{ inset: `${insetBase.outer}px` }}></div>
207
+ <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-300`} style={{ inset: `${insetBase.mid}px` }}></div>
208
+ <div className={`absolute rounded-full opacity-50 bg-${bgColorBase}-400`} style={{ inset: `${insetBase.inner}px` }}></div>
209
+ <div className="z-10 absolute" style={{ inset: `${insetBase.icon}px`, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
210
+ {type === 'human' && <SvgHumanIcon />}
211
+ {/* Add AI icon if needed */}
212
+ </div>
213
+ </div>
214
+ );
215
+ };
216
+
217
 
218
  return (
219
  <>
220
+ {/* Global Styles from your HTML example */}
221
+ <style jsx global>{`
222
+ :root {
223
+ --radius: 0.625rem; /* 10px */
224
+ --radius-md: 0.5rem; /* 8px */
225
+ --background: oklch(1 0 0);
226
+ --foreground: oklch(0.145 0 0);
227
+ --popover: oklch(1 0 0);
228
+ --popover-foreground: oklch(0.145 0 0);
229
+ --border: oklch(0.922 0 0);
230
+ }
231
+ .dark {
232
+ --background: oklch(0.145 0 0);
233
+ --foreground: oklch(0.985 0 0);
234
+ --popover: oklch(0.205 0 0);
235
+ --popover-foreground: oklch(0.985 0 0);
236
+ --border: oklch(1 0 0 / 10%);
237
+ }
238
+ /* Tailwind base layer directives are handled by Tailwind itself if setup via CDN/build */
239
+ /* Notification Popover */
240
+ .notification-popover-wrapper {
241
+ position: fixed; top: 1rem; left: 50%;
242
+ transform: translateX(-50%); z-index: 100;
243
+ width: calc(100% - 2rem); max-width: 28rem;
244
+ display: flex; justify-content: center; pointer-events: none;
245
+ }
246
+ .popover-content {
247
+ width: 100%; border-radius: var(--radius-md, 0.5rem);
248
+ border-width: 1px; border-color: var(--border);
249
+ background-color: var(--popover); color: var(--popover-foreground);
250
+ box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
251
+ outline: none; transition: opacity 0.3s ease-out, transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
252
+ opacity: 0; transform: translateY(-100%) scale(0.9); pointer-events: none;
253
+ }
254
+ .popover-content.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
255
+ .notification-popover-text-content {
256
+ background-color: #eff6ff; /* bg-blue-50 */
257
+ font-size: 0.875rem; line-height: 1.5rem; direction: rtl;
258
+ padding: 1rem; border-radius: var(--radius-md, 0.5rem);
259
+ color: oklch(0.145 0 0);
260
+ }
261
+ .dark .notification-popover-text-content {
262
+ background-color: oklch(0.25 0.05 230); color: oklch(0.95 0.01 230);
263
+ }
264
+ /* Header controls */
265
+ .header-controls {
266
+ display: flex; padding: 1rem; justify-content: space-between;
267
+ align-items: center; width: 100%; position: absolute; top: 0; left: 0; z-index: 10;
268
+ }
269
+ .header-button {
270
+ display: flex; align-items: center; justify-content: center;
271
+ padding: 0.5rem; border-radius: var(--radius-lg, 0.625rem);
272
+ background-color: #e5e7eb; /* bg-gray-200 */
273
+ cursor: pointer; transition: background-color 0.2s;
274
+ }
275
+ .header-button:hover { background-color: #d1d5db; /* bg-gray-300 */ }
276
+ .header-button svg { opacity: 0.7; stroke: #374151 /* gray-700 */; }
277
+ .dark .header-button { background-color: oklch(0.28 0 0); }
278
+ .dark .header-button:hover { background-color: oklch(0.35 0 0); }
279
+ .dark .header-button svg { opacity: 0.8; stroke: oklch(0.85 0 0); }
280
+
281
+ /* Footer and Control Buttons */
282
+ .footer-controls {
283
+ width: 100%; display: flex; gap: 1rem; position: absolute;
284
+ bottom: 0; padding: 2rem 3rem; align-items: center;
285
+ }
286
+ .footer-controls.layout-default { justify-content: space-between; }
287
+ .footer-controls.layout-with-small-logo { justify-content: space-around; }
288
+
289
+ .control-button {
290
+ height: 80px; width: 80px; border-radius: 9999px; /* rounded-full */
291
+ padding: 0; display: flex; align-items: center; justify-content: center;
292
+ border-width: 1px; border-color: var(--border);
293
+ box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
294
+ cursor: pointer; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
295
+ }
296
+ .control-button:hover {
297
+ transform: scale(1.05);
298
+ box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
299
+ }
300
+ .cam-button-color { background-color: #E0ECFF; }
301
+ .mic-button-color { background-color: #fecdd3; }
302
+ .dark .cam-button-color { background-color: #223355; }
303
+ .dark .mic-button-color { background-color: #5C2129; }
304
+
305
+ /* Switch Camera Button */
306
+ .switch-camera-button-container {
307
+ position: absolute; bottom: calc(100% + 0.65rem); left: 50%;
308
+ z-index: 5; opacity: 0;
309
+ transform: translateY(15px) scale(0.7) translateX(-50%);
310
+ pointer-events: none;
311
+ transition: opacity 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55), transform 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55);
312
+ transform-origin: center bottom;
313
+ }
314
+ .switch-camera-button-container.visible {
315
+ opacity: 1; transform: translateY(0) scale(1) translateX(-50%); pointer-events: auto;
316
+ }
317
+ .switch-camera-button-content {
318
+ width: 48px; height: 48px; background-color: var(--background);
319
+ border: 1px solid var(--border); border-radius: 9999px;
320
+ display: flex; align-items: center; justify-content: center;
321
+ box-shadow: 0 5px 10px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
322
+ cursor: pointer; transform-origin: center;
323
+ transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
324
+ }
325
+ .switch-camera-button-content:hover {
326
+ transform: scale(1.12) rotate(-6deg);
327
+ box-shadow: 0 7px 15px rgba(0,0,0,0.18), 0 3px 6px rgba(0,0,0,0.12);
328
+ }
329
+ .switch-camera-button-content:active { transform: scale(1.03) rotate(0deg); }
330
+ .switch-camera-button-content svg {
331
+ width: 22px; height: 22px; stroke: var(--foreground);
332
+ transition: transform 0.3s ease-in-out;
333
+ }
334
+ .switch-camera-button-content:hover svg { transform: rotate(360deg); }
335
+
336
+ /* Keyframes for popover (Tailwind keyframes should be in tailwind.config.js or added via <style>) */
337
+ @keyframes popover-drop-in {
338
+ '0%': { opacity: '0', transform: 'translateY(-100%) scale(0.9)' },
339
+ '70%': { opacity: '1', transform: 'translateY(5px) scale(1.02)' },
340
+ '100%': { opacity: '1', transform: 'translateY(0) scale(1)' },
341
+ }
342
+ @keyframes popover-lift-out {
343
+ '0%': { opacity: '1', transform: 'translateY(0) scale(1)' },
344
+ '100%': { opacity: '0', transform: 'translateY(-100%) scale(0.9)' },
345
+ }
346
+ .animate-popover-open-top-center { animation: popover-drop-in 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards; }
347
+ .animate-popover-close-top-center { animation: popover-lift-out 0.3s ease-in forwards; }
348
+
349
+ /* Forcing Tailwind specific classes for logo bg as an example if not working via template literals in JS */
350
+ .bg-blue-200 { background-color: #bfdbfe !important; }
351
+ .bg-blue-300 { background-color: #93c5fd !important; }
352
+ .bg-blue-400 { background-color: #60a5fa !important; }
353
+ .bg-green-200 { background-color: #bbf7d0 !important; }
354
+ .bg-green-300 { background-color: #86efac !important; }
355
+ .bg-green-400 { background-color: #4ade80 !important; }
356
+
357
+ `}</style>
358
+
359
+ <LiveAPIProvider initialConfig={initialAppConfig}>
360
+ <div className="w-full flex flex-col items-center justify-center min-h-[90dvh] md:min-h-screen bg-background text-foreground antialiased">
361
+ <div className="max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
362
+ {/* Header */}
363
  <div className="header-controls">
364
+ <button
365
+ ref={notificationButtonRef}
366
+ id="notification-button"
367
+ aria-label="Notifications"
368
+ className="header-button"
369
+ onClick={() => setIsNotificationOpen(!isNotificationOpen)}
370
+ >
371
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
372
+ </button>
373
+ <div className="header-button" onClick={() => alert('Back clicked (implement navigation)')}>
374
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"></path></svg>
 
 
 
 
 
 
 
375
  </div>
376
  </div>
377
 
378
  {/* Notification Popover */}
379
+ <div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
380
  <div
 
381
  id="notification-popover"
382
+ className={cn("popover-content", {
383
+ "open animate-popover-open-top-center": isNotificationOpen,
384
+ "animate-popover-close-top-center": !isNotificationOpen && document.getElementById('notification-popover')?.classList.contains('open'), // برای انیمیشن بسته شدن
385
+ })}
386
  >
387
  <div className="notification-popover-text-content">
388
  مدل‌های هوش مصنوعی می‌توانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از وارد کردن اطلاعات حساس بپرهیزید.
389
  </div>
390
  </div>
391
  </div>
392
+
393
+ {/* Main Media Area */}
394
+ <div className="w-full flex flex-col items-center justify-center h-[90dvh] bg-background top-0 left-0 relative">
395
+ {/* Video Feed (controlled by ControlTray's activeVideoStream) */}
396
+ <video
397
+ id="video-feed"
398
+ ref={videoRef}
399
+ autoPlay
400
+ playsInline
401
+ className={cn("absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", {
402
+ "hidden": !isCamActive, // isCamActive از ControlTray بروزرسانی می‌شود
403
+ })}
404
+ />
405
+ {/* Large Logo Container */}
406
+ <div id="large-logo-container" className={cn("items-center justify-center w-full h-full absolute top-0 left-0", {
407
+ "flex": !isCamActive && isMicActive, // Show when mic is on and cam is off
408
+ "hidden": isCamActive || !isMicActive
409
+ })}>
410
+ {createLogoHTML(false, !isCamActive && isMicActive)}
411
+ </div>
412
 
413
+ {/* Altair Chat component - شما تصمیم می‌گیرید کجا و چگونه نمایش داده شود */}
414
+ {/* <div className="absolute bottom-24 left-4 z-20 w-1/3 max-w-md"> <Altair /> </div> */}
415
+ {/* <SidePanel /> */}
416
+
417
+
418
+ {/* Footer Controls - Passed to ControlTray */}
419
+ <ControlTray
420
+ videoRef={videoRef}
421
+ supportsVideo={true} // شما این را true گذاشته بودید
422
+ onVideoStreamChange={setVideoStream} // ControlTray این را برای بروزرسانی استریم ویدیو استفاده می‌کند
423
+ // Props جدید برای کنترل ظاهر از App.tsx
424
+ isAppMicActive={isMicActive}
425
+ onAppMicToggle={setIsMicActive}
426
+ isAppCamActive={isCamActive}
427
+ onAppCamToggle={setIsCamActive}
428
+ createLogoFunction={createLogoHTML} // تابع ساخت لوگو به ControlTray پاس داده می‌شود
429
+ />
 
 
 
 
 
 
 
 
 
 
430
  </div>
431
+ </div>
 
 
 
 
 
432
  </div>
433
+ <IOSModal isOpen={showIOSModal} onClose={() => setShowIOSModal(false)} />
434
+ </LiveAPIProvider>
435
  </>
436
  );
437
  }