Opera8 commited on
Commit
41d58f8
·
verified ·
1 Parent(s): 3d31271

Create boteditor.html

Browse files
Files changed (1) hide show
  1. boteditor.html +494 -0
boteditor.html ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fa" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>AI Photoshop Pro</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
8
+ <style>
9
+ :root {
10
+ --app-font: 'Vazirmatn', sans-serif;
11
+ --app-bg: #F8F9FC;
12
+ --panel-bg: #FFFFFF;
13
+ --panel-border: #EAEFF7;
14
+ --input-bg: #F6F8FB;
15
+ --input-border: #E1E7EF;
16
+ --text-primary: #1A202C;
17
+ --text-secondary: #626F86;
18
+ --text-tertiary: #8A94A6;
19
+ --accent-primary: #4A6CFA;
20
+ --accent-primary-hover: #3553D6;
21
+ --accent-primary-glow: rgba(74, 108, 250, 0.25);
22
+ --accent-secondary: #0FD4A8;
23
+ --danger-color: #e53e3e;
24
+ --shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
25
+ --shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
26
+ --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
27
+ --radius-card: 24px;
28
+ --radius-btn: 14px;
29
+ --radius-input: 12px;
30
+ --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
31
+ }
32
+
33
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
34
+ @keyframes scaleUp { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
35
+ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
36
+ @keyframes pulse-loader { 0% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); } 50% { box-shadow: 0 0 60px rgba(56, 189, 248, 0.7); } 100% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); } }
37
+ @keyframes glow-text { 0% { opacity: 0.7; } 50% { opacity: 1; } 100% { opacity: 0.7; } }
38
+ @keyframes badge-fade-in { from { opacity: 0; transform: translateY(-10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
39
+
40
+ * { box-sizing: border-box; margin: 0; padding: 0; }
41
+
42
+ body { font-family: var(--app-font); background-color: var(--app-bg); color: var(--text-primary); display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 2.5rem 1rem; }
43
+ .container { max-width: 820px; width: 100%; display: flex; flex-direction: column; gap: 1.5rem; }
44
+
45
+ /* Header */
46
+ header { position: relative; text-align: center; margin-bottom: 1rem; padding: 2rem 0; animation: fadeIn 0.8s 0.1s ease-out backwards; overflow: hidden; }
47
+ #neural-network-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; opacity: 0.7; }
48
+ h1, .subtitle, #subscription-status-badge { position: relative; z-index: 2; }
49
+ h1 { font-size: 2.8rem; font-weight: 800; margin: 0 0 0.8rem 0; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; }
50
+ .subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.5rem; }
51
+
52
+ /* Status Badge */
53
+ #subscription-status-badge { display: none; padding: 6px 16px; border-radius: 20px; font-size: 0.85em; font-weight: 700; margin-top: 1rem; display: inline-block; animation: badge-fade-in 0.6s 0.5s ease-out backwards; position: relative; z-index: 2;}
54
+ #subscription-status-badge.free-badge { background: #64748b; color: white; box-shadow: 0 2px 8px rgba(100, 116, 139, 0.3); }
55
+ #subscription-status-badge.paid-badge { background: linear-gradient(45deg, #FFC107, #ffca2c); color: #333; box-shadow: 0 4px 10px rgba(255, 193, 7, 0.3); }
56
+
57
+ /* Panels */
58
+ main { padding: 3rem; background-color: var(--panel-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); border: 1px solid var(--panel-border); animation: fadeIn 0.8s 0.3s ease-out backwards; }
59
+ .form-group { margin-bottom: 2.5rem; }
60
+ .form-group:last-child { margin-bottom: 0; }
61
+ .form-label { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; color: var(--text-primary); font-size: 1.2em; margin-bottom: 1.2rem; }
62
+ .form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
63
+
64
+ /* Upload Area */
65
+ #upload-area { position: relative; border: 2px dashed var(--input-border); border-radius: var(--radius-input); padding: 2.5rem; text-align: center; cursor: pointer; transition: var(--transition-smooth); background-color: var(--input-bg); min-height: 200px; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; }
66
+ #upload-area.drag-over, #upload-area:hover:not(.has-file) { border-color: var(--accent-primary); background-color: #fff; box-shadow: 0 0 15px var(--accent-primary-glow); }
67
+ #upload-area.has-file { border-style: solid; border-color: var(--panel-border); padding: 0; cursor: default; }
68
+ #upload-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
69
+ #upload-icon svg { width: 48px; height: 48px; color: var(--accent-primary); stroke-width: 1.5; opacity: 0.8; }
70
+ #upload-area p { margin: 0; color: var(--text-secondary); font-weight: 500; }
71
+ #preview-image-main { display: none; width: 100%; height: 100%; object-fit: contain; position: absolute; top: 0; left: 0; }
72
+ #remove-file-btn-main { display: none; position: absolute; top: 12px; right: 12px; background-color: rgba(26, 32, 44, 0.6); color: white; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; line-height: 1; z-index: 10; transition: var(--transition-smooth); padding: 0; }
73
+ #remove-file-btn-main:hover { background-color: var(--danger-color); transform: scale(1.1); }
74
+ #upload-area.has-file #upload-content { display: none; }
75
+ #upload-area.has-file #preview-image-main, #upload-area.has-file #remove-file-btn-main { display: block; }
76
+
77
+ /* Textarea & Buttons */
78
+ textarea { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 2px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1.05rem; box-sizing: border-box; transition: var(--transition-smooth); min-height: 120px; resize: vertical; }
79
+ textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 4px var(--accent-primary-glow); background-color: #fff; }
80
+
81
+ /* پکیج طراحی شکیل اتمام اعتبار هفتگی */
82
+ .limit-warning-card {
83
+ display: none;
84
+ background: linear-gradient(135deg, #FFF5F7 0%, #FFE5EC 100%);
85
+ border: 2px solid #FFCCD5;
86
+ border-radius: 20px;
87
+ padding: 1.75rem;
88
+ margin: 1.5rem 0;
89
+ text-align: center;
90
+ box-shadow: 0 10px 25px rgba(255, 77, 109, 0.1);
91
+ animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
92
+ }
93
+ .limit-warning-card h4 {
94
+ color: #FF4D6D;
95
+ font-size: 1.25rem;
96
+ font-weight: 800;
97
+ margin-bottom: 10px;
98
+ }
99
+ .limit-warning-card p {
100
+ color: #4A5568;
101
+ font-size: 0.95rem;
102
+ line-height: 1.8;
103
+ font-weight: 600;
104
+ margin-bottom: 15px;
105
+ }
106
+ .countdown-timer-box {
107
+ font-weight: 800;
108
+ color: #FF4D6D;
109
+ background: #FFFFFF;
110
+ border: 2px dashed #FFAEC0;
111
+ padding: 10px 16px;
112
+ border-radius: 12px;
113
+ display: inline-block;
114
+ font-size: 0.95rem;
115
+ box-shadow: var(--shadow-sm);
116
+ }
117
+
118
+ .credit-info { font-size: 0.95rem; color: var(--text-tertiary); text-align: center; margin-top: 1rem; font-weight: 600; background: var(--input-bg); padding: 10px; border-radius: var(--radius-input); border: 1px solid var(--input-border); display: none; }
119
+
120
+ #submit-btn { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.2rem; font-size: 1.3rem; font-weight: 800; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 15px -3px var(--accent-primary-glow); margin-top: 1rem; }
121
+ #submit-btn svg { width: 26px; height: 26px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); }
122
+ #submit-btn:hover:not(:disabled) { transform: translateY(-4px) scale(1.01); box-shadow: 0 10px 20px -4px var(--accent-primary-glow); }
123
+ #submit-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; transform: none; }
124
+ #submit-btn .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
125
+
126
+ /* --- Result Area --- */
127
+ #image-result-container { display: flex; width: 100%; flex-direction: column; align-items: center; gap: 1rem; margin-top: 1rem; padding-top: 2rem; border-top: 1px solid var(--panel-border); animation: fadeIn 0.5s ease-out; }
128
+
129
+ .empty-placeholder { width: 400px; max-width: 100%; height: 300px; border: 2px dashed var(--input-border); border-radius: 20px; background-color: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
130
+ .empty-placeholder svg { color: var(--text-tertiary); margin-bottom: 15px; opacity: 0.5; width: 48px; height: 48px; }
131
+ .empty-placeholder p { color: var(--text-tertiary); font-size: 0.95rem; font-weight: 600; margin: 0; }
132
+
133
+ .generator-container { position: relative; width: 400px; max-width: 100%; height: 300px; border: 2px solid #38bdf8; border-radius: 20px; overflow: hidden; box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); animation: pulse-loader 5s infinite cubic-bezier(0.4, 0, 0.6, 1); background-color: #161b22; color: #f0f6fc; margin: 0 auto; }
134
+ .noise-layer, .sketch-layer, .building-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
135
+ .noise-layer { background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="none"/><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.6"/></svg>') repeat; opacity: 1; animation: fade-noise 7s infinite ease-in-out; }
136
+ @keyframes fade-noise { 0% { opacity: 1; filter: blur(5px); } 30% { opacity: 0.8; filter: blur(2px); } 100% { opacity: 0; filter: blur(0px); } }
137
+ .sketch-layer { filter: grayscale(1) contrast(1.5) blur(3px); opacity: 0; animation: reveal-sketch 7s infinite ease-in-out; }
138
+ @keyframes reveal-sketch { 0% { opacity: 0; } 20% { opacity: 1; } 60% { opacity: 0.5; } 100% { opacity: 0; } }
139
+ .building-layer { filter: blur(15px); opacity: 0; animation: denoise-color 7s infinite ease-in-out; }
140
+ @keyframes denoise-color { 0% { opacity: 0; } 40% { opacity: 0.6; filter: blur(5px); } 100% { opacity: 1; filter: blur(0px); } }
141
+ .pixel-grid { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: repeating-linear-gradient(0deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px), repeating-linear-gradient(90deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px); opacity: 1; animation: dissolve-grid 7s infinite ease-in-out; }
142
+ @keyframes dissolve-grid { 0% { opacity: 1; } 70% { opacity: 0.5; } 100% { opacity: 0; } }
143
+ .particles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle, rgba(56, 189, 248, 0.2) 0%, transparent 50%); animation: flow-particles 7s infinite cubic-bezier(0.4, 0, 0.6, 1); }
144
+ @keyframes flow-particles { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(10px, -15px) scale(1.05); } 100% { transform: translate(0, 0) scale(1); } }
145
+ .text-overlay { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); font-size: 20px; font-weight: 700; text-shadow: 0 0 20px rgba(56, 189, 248, 0.8); animation: glow-text 7s infinite ease-in-out; font-family: var(--app-font); z-index: 2; text-align: center; width: 90%; }
146
+ .progress-bar { position: absolute; bottom: 0; left: 0; width: 0%; height: 6px; background: linear-gradient(to right, #38bdf8, #bb86fc, #facc15); transition: width 0.3s linear; z-index: 2; }
147
+
148
+ @media (max-width: 650px) {
149
+ main { padding: 1.5rem; } h1 { font-size: 2.2rem; }
150
+ .generator-container { height: 250px; }
151
+ .text-overlay { font-size: 16px; }
152
+ }
153
+ </style>
154
+ </head>
155
+ <body>
156
+ <!-- کدهای متغیرهای مخفی سیستمی آپلود -->
157
+ <input type="hidden" id="file_id" value="{FILE_ID}">
158
+ <input type="hidden" id="bot_b64" value="{BOT_B64}">
159
+ <input type="hidden" id="t" value="{TIMESTAMP}">
160
+
161
+ <div class="container">
162
+ <header>
163
+ <canvas id="neural-network-canvas"></canvas>
164
+ <div style="position: relative; z-index: 2;">
165
+ <h1>فتوشاپ هوش مصنوعی ✨</h1>
166
+ <p class="subtitle">تصاویر خود را با قدرت هوش مصنوعی و به زبان ساده ویرایش کنید</p>
167
+ <div id="subscription-status-badge">درحال بررسی...</div>
168
+ </div>
169
+ </header>
170
+
171
+ <main>
172
+ <div class="form-group">
173
+ <div class="form-label">
174
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4Z"/></svg>
175
+ ۱. تصویر خود را انتخاب کنید
176
+ </div>
177
+ <label id="upload-area" for="file-input">
178
+ <div id="upload-content">
179
+ <div id="upload-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg></div>
180
+ <p>فایل تصویر را اینجا بکشید یا برای انتخاب کلیک کنید</p>
181
+ </div>
182
+ <img id="preview-image-main" src="" alt="Preview">
183
+ <button type="button" id="remove-file-btn-main" title="حذف تصویر">&times;</button>
184
+ </label>
185
+ <input type="file" id="file-input" accept="image/png, image/jpeg, image/webp" hidden>
186
+ </div>
187
+
188
+ <div class="form-group">
189
+ <label class="form-label">
190
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
191
+ ۲. دستور ویرایش را بنویسید
192
+ </label>
193
+ <textarea id="prompt-input" placeholder="مثال: پس‌زمینه را حذف کن و یک ساحل آفتابی قرار بده"></textarea>
194
+
195
+ <!-- کارت اتمام اعتبار رایگان هفتگی -->
196
+ <div id="limit-warning-card" class="limit-warning-card">
197
+ <h4>⚠️ سهمیه هفتگی شما تمام شد!</h4>
198
+ <p>اعتبار این هفته شما برای ویرایش عکس به پایان رسید. هفته آینده مجدداً شارژ خواهد شد.<br>همچنین برای استفاده کاملاً نامحدود و دسترسی بدون مرز به تمامی ابزارها، می‌توانید همین حالا از داخل ربات لایسنس ویژه تهیه فرمایید. 🌟💎</p>
199
+ <div id="countdown-timer-box" class="countdown-timer-box">در حال محاسبه زمان شارژ مجدد...</div>
200
+ </div>
201
+
202
+ <div id="credit-info" class="credit-info">درحال بررسی اعتبار...</div>
203
+
204
+ <button id="submit-btn" disabled>
205
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/></svg>
206
+ <span id="btn-text">ایجاد کن</span>
207
+ <div class="spinner"></div>
208
+ </button>
209
+ </div>
210
+
211
+ <div class="form-group">
212
+ <div class="form-label">
213
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/><path d="M21 14l-1.5 3-3-1.5 3-3 1.5 3z"/><path d="M19.5 2.5l-3 1.5 1.5 3 3-1.5-1.5-3z"/></svg>
214
+ ۳. وضعیت درخواست
215
+ </div>
216
+ <div id="image-result-container">
217
+ <div class="empty-placeholder">
218
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
219
+ <p>تصویر و دستور خود را وارد کنید.</p>
220
+ </div>
221
+ </div>
222
+ </div>
223
+ </main>
224
+ </div>
225
+
226
+ <script>
227
+ // --- مدیریت آپلود و متغیرها ---
228
+ const uploadArea = document.getElementById('upload-area');
229
+ const fileInput = document.getElementById('file-input');
230
+ const previewImage = document.getElementById('preview-image-main');
231
+ const removeFileBtn = document.getElementById('remove-file-btn-main');
232
+ const promptInput = document.getElementById('prompt-input');
233
+ const submitBtn = document.getElementById('submit-btn');
234
+ const imageResultContainer = document.getElementById('image-result-container');
235
+
236
+ let uploadedFile = null;
237
+ let fakeProgressInterval = null;
238
+ let isSubmitting = false;
239
+
240
+ // دریافت وضعیت اشتراک کاربر به صورت زنده از رانفلر
241
+ let userSubscriptionStatus = "{PREMIUM_STATUS}";
242
+ let userFingerprint = null;
243
+ let freeCreditRemaining = 5;
244
+
245
+ async function getBrowserFingerprint() {
246
+ const components = [navigator.userAgent, navigator.language, screen.width + 'x' + screen.height, new Date().getTimezoneOffset(), "canvas-test"];
247
+ const fingerprintString = components.join('---');
248
+ let hash = 0;
249
+ for (let i = 0; i < fingerprintString.length; i++) { hash = ((hash << 5) - hash) + fingerprintString.charCodeAt(i); hash |= 0; }
250
+ return 'fp_edit_' + Math.abs(hash).toString(16);
251
+ }
252
+
253
+ function updateUIForSubscriptionStatus(status) {
254
+ userSubscriptionStatus = status;
255
+ const creditInfoDiv = document.getElementById('credit-info');
256
+ const warningCard = document.getElementById('limit-warning-card');
257
+ const badge = document.getElementById('subscription-status-badge');
258
+
259
+ badge.style.display = 'inline-block';
260
+
261
+ if (status === 'paid') {
262
+ badge.textContent = 'کاربر ویژه (نامحدود)';
263
+ badge.className = 'paid-badge';
264
+ creditInfoDiv.style.display = 'none';
265
+ warningCard.style.display = 'none';
266
+ checkFormState();
267
+ } else {
268
+ badge.textContent = 'کاربر رایگان';
269
+ badge.className = 'free-badge';
270
+ checkFreeUserCredit();
271
+ }
272
+ }
273
+
274
+ async function checkFreeUserCredit() {
275
+ if (!userFingerprint || userSubscriptionStatus === 'paid') return;
276
+ const creditInfoDiv = document.getElementById('credit-info');
277
+ const warningCard = document.getElementById('limit-warning-card');
278
+ const submitBtn = document.getElementById('submit-btn');
279
+ try {
280
+ const response = await fetch('/api/check-edit-credit', {
281
+ method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ fingerprint: userFingerprint })
282
+ });
283
+ const result = await response.json();
284
+
285
+ if (result.limit_reached) {
286
+ freeCreditRemaining = 0;
287
+ submitBtn.style.display = 'none';
288
+ warningCard.style.display = 'block';
289
+ creditInfoDiv.style.display = 'none';
290
+ startWeeklyCountdown();
291
+ } else {
292
+ freeCreditRemaining = result.credits_remaining;
293
+ checkFormState();
294
+ warningCard.style.display = 'none';
295
+ creditInfoDiv.style.display = 'block';
296
+ creditInfoDiv.innerHTML = `شما <b>${result.credits_remaining}</b> اعتبار ویرایش تصویر برای این هفته دارید.`;
297
+ }
298
+ } catch (error) {
299
+ creditInfoDiv.textContent = "خطا در ارتباط با سیستم اعتبار.";
300
+ submitBtn.disabled = true;
301
+ }
302
+ }
303
+
304
+ function startWeeklyCountdown() {
305
+ const timerBox = document.getElementById('countdown-timer-box');
306
+ if (!timerBox) return;
307
+
308
+ function tick() {
309
+ const now = new Date();
310
+ const daysUntilMonday = (8 - now.getDay()) % 7 || 7;
311
+ const nextMonday = new Date(now.getFullYear(), now.getMonth(), now.getDate() + daysUntilMonday);
312
+ nextMonday.setHours(0, 0, 0, 0);
313
+ const diff = nextMonday - now;
314
+
315
+ const days = Math.floor(diff / (1000 * 60 * 60 * 24));
316
+ const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
317
+ const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
318
+ const seconds = Math.floor((diff % (1000 * 60)) / 1000);
319
+
320
+ timerBox.textContent = `⏳ ${days} روز و ${hours} ساعت و ${minutes} دقیقه و ${seconds} ثانیه تا شارژ مجدد`;
321
+ }
322
+ tick();
323
+ setInterval(tick, 1000);
324
+ }
325
+
326
+ async function handleFile(file) {
327
+ if (!file || !file.type.startsWith('image/')) return alert('لطفاً یک تصویر انتخاب کنید.');
328
+ uploadedFile = file;
329
+ const reader = new FileReader();
330
+ reader.onload = (e) => { previewImage.src = e.target.result; };
331
+ reader.readAsDataURL(file);
332
+ uploadArea.classList.add('has-file');
333
+ checkFormState();
334
+ }
335
+
336
+ removeFileBtn.onclick = async (e) => {
337
+ e.preventDefault(); e.stopPropagation();
338
+ uploadedFile = null; fileInput.value = ''; previewImage.src = '';
339
+ uploadArea.classList.remove('has-file');
340
+ checkFormState();
341
+ };
342
+
343
+ fileInput.onchange = (e) => handleFile(e.target.files[0]);
344
+ uploadArea.ondragover = (e) => { e.preventDefault(); uploadArea.classList.add('drag-over'); };
345
+ uploadArea.ondragleave = () => uploadArea.classList.remove('drag-over');
346
+ uploadArea.ondrop = (e) => { e.preventDefault(); uploadArea.classList.remove('drag-over'); handleFile(e.dataTransfer.files[0]); };
347
+
348
+ function checkFormState() {
349
+ let limitReached = (userSubscriptionStatus === 'free' && freeCreditRemaining === 0);
350
+ submitBtn.disabled = limitReached || !(uploadedFile && promptInput.value.trim() !== '');
351
+ }
352
+ promptInput.oninput = checkFormState;
353
+
354
+ // --- نوار پیشرفت ---
355
+ function startFakeProgress(targetSeconds) {
356
+ clearInterval(fakeProgressInterval);
357
+ const pb = document.getElementById('tv-progress-bar');
358
+ if (!pb) return;
359
+ let currentProg = 0;
360
+ const intervalMs = 100;
361
+ const increment = 100 / (targetSeconds * 1000 / intervalMs);
362
+
363
+ pb.style.width = '0%';
364
+ fakeProgressInterval = setInterval(() => {
365
+ currentProg += increment;
366
+ if(currentProg > 98) {
367
+ clearInterval(fakeProgressInterval);
368
+ currentProg = 98;
369
+ }
370
+ pb.style.width = `${currentProg}%`;
371
+ }, intervalMs);
372
+ }
373
+
374
+ function finishFakeProgress() {
375
+ clearInterval(fakeProgressInterval);
376
+ const pb = document.getElementById('tv-progress-bar');
377
+ if(pb) pb.style.width = '100%';
378
+ }
379
+
380
+ // --- ارسال درخواست به سرور ---
381
+ submitBtn.onclick = async () => {
382
+ if (isSubmitting) return;
383
+ if (!uploadedFile) return alert('لطفاً ابتدا تصویر خود را انتخاب کنید.');
384
+ if (promptInput.value.trim() === '') return alert('لطفاً دستور ویرایش را وارد کنید.');
385
+
386
+ isSubmitting = true;
387
+ submitBtn.disabled = true;
388
+ promptInput.disabled = true;
389
+ document.getElementById('btn-text').style.display = 'none';
390
+ document.querySelector('.spinner').style.display = 'inline-block';
391
+
392
+ const originalPrompt = promptInput.value.trim();
393
+
394
+ // ۱. نمایش لودر متحرک تلویزیون
395
+ imageResultContainer.innerHTML = `
396
+ <div class="generator-container" style="display:flex;">
397
+ <div class="noise-layer"></div><div class="sketch-layer"></div><div class="building-layer"></div><div class="pixel-grid"></div><div class="particles"></div>
398
+ <div class="text-overlay" id="loading-text">در حال ارسال درخواست...</div>
399
+ <div class="progress-bar" id="tv-progress-bar"></div>
400
+ </div>
401
+ `;
402
+
403
+ // شروع پر کردن سریع نوار پیشرفت در ۱.۵ ثانیه
404
+ startFakeProgress(1.5);
405
+
406
+ const formData = new FormData();
407
+ formData.append('file', uploadedFile);
408
+ formData.append('file_id', document.getElementById('file_id').value);
409
+ formData.append('bot_b64', document.getElementById('bot_b64').value);
410
+ formData.append('t', document.getElementById('t').value);
411
+ formData.append('prompt', originalPrompt); // ارسال دستور متنی کاربر
412
+
413
+ try {
414
+ const res = await fetch('/api/bridge/upload', {
415
+ method: 'POST',
416
+ body: formData
417
+ });
418
+
419
+ const data = await res.json();
420
+
421
+ if (data.status === 'success') {
422
+ // کاهش سهمیه وب مرکزی در صورت رایگان بودن و موفقیت آپلود
423
+ if (userSubscriptionStatus === 'free') {
424
+ try {
425
+ await fetch('/api/use-edit-credit', {
426
+ method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ fingerprint: userFingerprint })
427
+ });
428
+ checkFreeUserCredit();
429
+ } catch (e) { console.error("Error using credit", e); }
430
+ }
431
+
432
+ // ۲. به محض ارسال موفقیت آمیز، نوار پیشرفت سریعاً ۱۰۰٪ شود
433
+ finishFakeProgress();
434
+
435
+ // ۳. مکث کوتاه برای انیمیشن و سپس مخفی کردن تلویزیون و نمایش پیام موفقیت نهایی شیک
436
+ setTimeout(() => {
437
+ // مخفی کردن فرم‌ها و دکمه ویرایش برای جلوگیری از ارسال مجدد روی همان لینک منقضی شده
438
+ document.querySelectorAll('main > .form-group:not(:last-child), #submit-btn, .credit-info').forEach(el => {
439
+ el.style.display = 'none';
440
+ });
441
+
442
+ imageResultContainer.innerHTML = `
443
+ <div style="display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.5rem; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-card); animation: scaleUp 0.6s cubic-bezier(0.4, 0, 0.2, 1); max-width: 450px; margin: 1.5rem auto; box-shadow: var(--shadow-lg);">
444
+ <div style="width: 70px; height: 70px; background: #dcfce7; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 1.5rem; box-shadow: 0 4px 10px rgba(74, 222, 128, 0.2); animation: scaleUp 0.5s ease-out;">
445
+ <svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
446
+ <polyline points="20 6 9 17 4 12"></polyline>
447
+ </svg>
448
+ </div>
449
+ <h3 style="color: #15803d; font-size: 1.45rem; font-weight: 800; margin-bottom: 0.8rem; font-family: var(--app-font);">درخواست شما ثبت شد! 🎉</h3>
450
+ <p style="color: #166534; font-size: 1.05rem; line-height: 1.7; font-weight: 500; margin: 0; font-family: var(--app-font);">
451
+ تصویر با موفقیت دریافت و جهت پردازش به روبات ارسال گردید.<br>
452
+ <span style="display: block; margin-top: 0.8rem; font-size: 0.95rem; color: #15803d; opacity: 0.85; font-weight: bold;">
453
+ 👈 اکنون می‌توانید به روبیکا بازگردید. ربات به محض آماده شدن فایل، نتیجه نهایی را مستقیماً برایتان ارسال خواهد کرد.
454
+ </span>
455
+ </p>
456
+ </div>
457
+ `;
458
+
459
+ resetBtn();
460
+ }, 800);
461
+ } else {
462
+ displayError('خطا در تحویل فایل به سرور ربات: ' + data.message);
463
+ }
464
+ } catch (e) {
465
+ displayError('خطای ارتباط با سرور رانفلر!');
466
+ }
467
+ };
468
+
469
+ function displayError(msg) {
470
+ clearInterval(fakeProgressInterval);
471
+ imageResultContainer.innerHTML = `<div style="color: var(--danger-color); font-weight:bold; text-align:center; padding: 2rem;">خطا: ${msg}</div>`;
472
+ resetBtn();
473
+ }
474
+
475
+ function resetBtn() {
476
+ isSubmitting = false;
477
+ submitBtn.disabled = false;
478
+ promptInput.disabled = false;
479
+ document.getElementById('btn-text').style.display = 'inline-block';
480
+ document.getElementById('btn-text').textContent = 'ایجاد کن';
481
+ document.querySelector('.spinner').style.display = 'none';
482
+ checkFormState();
483
+ }
484
+
485
+ // انیمیشن شبکه عصبی هدر
486
+ document.addEventListener('DOMContentLoaded', async () => {
487
+ userFingerprint = await getBrowserFingerprint();
488
+ updateUIForSubscriptionStatus(userSubscriptionStatus);
489
+
490
+ const canvas = document.getElementById('neural-network-canvas'); if (!canvas) return; const header = canvas.parentElement; const ctx = canvas.getContext('2d'); let particles = []; const particleCount = 20; const maxDistance = 100; const computedStyles = getComputedStyle(document.documentElement); const particleColor = computedStyles.getPropertyValue('--accent-primary').trim(); const lineColor = computedStyles.getPropertyValue('--text-tertiary').trim(); function resizeCanvas() { canvas.width = header.clientWidth; canvas.height = header.clientHeight; init(); } class Particle { constructor() { this.x = Math.random() * canvas.width; this.y = Math.random() * canvas.height; this.vx = (Math.random() - 0.5) * 0.3; this.vy = (Math.random() - 0.5) * 0.3; this.radius = 1.2; } update() { this.x += this.vx; this.y += this.vy; if (this.x < 0 || this.x > canvas.width) this.vx *= -1; if (this.y < 0 || this.y > canvas.height) this.vy *= -1; } draw() { ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = particleColor; ctx.fill(); } } function init() { particles = []; for (let i = 0; i < particleCount; i++) { particles.push(new Particle()); } } function connectParticles() { for (let i = 0; i < particles.length; i++) { for (let j = i + 1; j < particles.length; j++) { const dx = particles[i].x - particles[j].x; const dy = particles[i].y - particles[j].y; const distance = Math.sqrt(dx * dx + dy * dy); if (distance < maxDistance) { ctx.beginPath(); ctx.moveTo(particles[i].x, particles[i].y); ctx.lineTo(particles[j].x, particles[j].y); ctx.strokeStyle = lineColor; ctx.lineWidth = 0.2; ctx.globalAlpha = 1 - distance / maxDistance; ctx.stroke(); } } } ctx.globalAlpha = 1; } function animate() { ctx.clearRect(0, 0, canvas.width, canvas.height); particles.forEach(particle => { particle.update(); particle.draw(); }); connectParticles(); requestAnimationFrame(animate); } window.addEventListener('resize', resizeCanvas); resizeCanvas(); animate();
491
+ });
492
+ </script>
493
+ </body>
494
+ </html>