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
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
<script lang="ts">

  import { onMount } from 'svelte';

  import { backendService, type CurrentRFPDocument } from '../utils/backendService';

  import { suggestionEngine } from '../utils/suggestionEngine';



  export let visible = false;



  let currentRFPs: CurrentRFPDocument[] = [];

  let selectedRFP: CurrentRFPDocument | null = null;

  let rfpContent = '';

  let insights: any = null;

  let uploading = false;

  let loading = false;



  // File upload

  let fileInput: HTMLInputElement;



  onMount(() => {

    if (visible) {

      loadCurrentRFPs();

    }

  });



  $: if (visible) {

    loadCurrentRFPs();

  }



  async function loadCurrentRFPs() {

    try {

      loading = true;

      currentRFPs = await backendService.getCurrentRFPs();

    } catch (error) {

      console.error('Failed to load current RFPs:', error);

    } finally {

      loading = false;

    }

  }



  async function handleFileUpload(event: Event) {

    const target = event.target as HTMLInputElement;

    const file = target.files?.[0];

    

    if (!file) return;



    try {

      uploading = true;

      const result = await backendService.uploadCurrentRFP(file);

      

      // Add to current RFPs list

      currentRFPs = [...currentRFPs, result.document];

      

      // Auto-select the uploaded document

      selectedRFP = result.document;

      await loadRFPContent(result.document.id);

      

      // Reset file input

      target.value = '';

    } catch (error) {

      console.error('Upload failed:', error);

      alert('Failed to upload file: ' + (error as Error).message);

    } finally {

      uploading = false;

    }

  }



  async function selectRFP(rfp: CurrentRFPDocument) {

    selectedRFP = rfp;

    await loadRFPContent(rfp.id);

  }



  async function loadRFPContent(id: string) {

    try {

      loading = true;

      const result = await backendService.getCurrentRFPContent(id);

      rfpContent = result.content;

      

      // Analyze the RFP document for insights

      insights = suggestionEngine.analyzeRFPDocument(rfpContent);

    } catch (error) {

      console.error('Failed to load RFP content:', error);

    } finally {

      loading = false;

    }

  }



  function formatDate(dateString: string) {

    return new Date(dateString).toLocaleDateString();

  }



  function getFileIcon(fileType: string) {

    switch (fileType.toLowerCase()) {

      case 'pdf': return 'πŸ“„';

      case 'docx': case 'doc': return 'πŸ“';

      case 'txt': return 'πŸ“‹';

      default: return 'πŸ“';

    }

  }

</script>

<div class="rfp-manager" class:visible>
  <div class="header">
    <h3>Current RFP Documents</h3>
    <button class="close-btn" on:click={() => visible = false}>Γ—</button>
  </div>

  <div class="content">
    <!-- Upload Section -->
    <div class="upload-section">
      <h4>Upload Current RFP</h4>
      <div class="upload-area">
        <input 

          bind:this={fileInput}

          type="file" 

          accept=".pdf,.doc,.docx,.txt" 

          on:change={handleFileUpload}

          style="display: none;"

        />
        <button 

          class="upload-btn" 

          on:click={() => fileInput.click()}
          disabled={uploading}
        >
          {uploading ? 'Uploading...' : 'Choose RFP Document'}
        </button>
        <p class="upload-help">Upload the current RFP document to analyze and get suggestions</p>
      </div>
    </div>

    <!-- Documents List -->
    <div class="documents-section">
      <h4>Uploaded RFPs ({currentRFPs.length})</h4>
      
      {#if loading && currentRFPs.length === 0}
        <div class="loading">Loading documents...</div>
      {:else if currentRFPs.length === 0}
        <div class="empty-state">
          No RFP documents uploaded yet. Upload one to get started!
        </div>
      {:else}
        <div class="documents-list">
          {#each currentRFPs as rfp (rfp.id)}
            <div 

              class="document-item" 

              class:selected={selectedRFP?.id === rfp.id}

              on:click={() => selectRFP(rfp)}
            >
              <div class="doc-icon">{getFileIcon(rfp.fileType)}</div>
              <div class="doc-info">
                <div class="doc-name">{rfp.name}</div>
                <div class="doc-meta">
                  {rfp.fileType.toUpperCase()} β€’ {formatDate(rfp.uploadDate)}
                  {#if rfp.contentLength}
                    β€’ {Math.round(rfp.contentLength / 1000)}k chars
                  {/if}
                </div>
              </div>
              <div class="doc-status">
                {#if rfp.processed}
                  <span class="status-processed">βœ“ Processed</span>
                {:else}
                  <span class="status-pending">⏳ Processing</span>
                {/if}
              </div>
            </div>
          {/each}
        </div>
      {/if}
    </div>

    <!-- RFP Analysis -->
    {#if selectedRFP && insights}
      <div class="analysis-section">
        <h4>RFP Analysis: {selectedRFP.name}</h4>
        
        <div class="insights-grid">
          <!-- Key Requirements -->
          <div class="insight-card">
            <h5>Key Requirements</h5>
            <div class="tag-list">
              {#each insights.keyRequirements.slice(0, 8) as requirement}
                <span class="tag">{requirement}</span>
              {/each}
            </div>
          </div>

          <!-- Technology Mentions -->
          {#if insights.technologyMentions.length > 0}
            <div class="insight-card">
              <h5>Technology Stack</h5>
              <div class="tag-list">
                {#each insights.technologyMentions as tech}
                  <span class="tag tech-tag">{tech}</span>
                {/each}
              </div>
            </div>
          {/if}

          <!-- Compliance Requirements -->
          {#if insights.complianceRequirements.length > 0}
            <div class="insight-card">
              <h5>Compliance & Security</h5>
              <div class="tag-list">
                {#each insights.complianceRequirements as compliance}
                  <span class="tag compliance-tag">{compliance}</span>
                {/each}
              </div>
            </div>
          {/if}

          <!-- Timeline Indicators -->
          {#if insights.timelineIndicators.length > 0}
            <div class="insight-card">
              <h5>Timeline Indicators</h5>
              <div class="tag-list">
                {#each insights.timelineIndicators as timeline}
                  <span class="tag timeline-tag">{timeline}</span>
                {/each}
              </div>
            </div>
          {/if}

          <!-- Budget Indicators -->
          {#if insights.budgetIndicators.length > 0}
            <div class="insight-card">
              <h5>Budget Indicators</h5>
              <div class="tag-list">
                {#each insights.budgetIndicators as budget}
                  <span class="tag budget-tag">{budget}</span>
                {/each}
              </div>
            </div>
          {/if}
        </div>

        <!-- Strategy Recommendations -->
        <div class="strategy-section">
          <h5>Strategic Recommendations</h5>
          <div class="recommendations">
            <div class="recommendation">
              <strong>Emphasize SEDNA's Experience:</strong> 
              Highlight 15+ years and 200+ successful projects
            </div>
            <div class="recommendation">
              <strong>Security Focus:</strong> 
              Lead with SOC 2, ISO 27001 certifications
            </div>
            <div class="recommendation">
              <strong>Methodology:</strong> 
              Detail 5-phase approach: Discovery β†’ Design β†’ Implementation β†’ Testing β†’ Deployment
            </div>
            <div class="recommendation">
              <strong>Transparency:</strong> 
              Emphasize fixed-price model with milestone billing
            </div>
          </div>
        </div>
      </div>
    {/if}
  </div>
</div>

<style>

  .rfp-manager {

    position: fixed;

    top: 0;

    right: -600px;

    width: 600px;

    height: 100vh;

    background: #1a1a1a;

    border-left: 1px solid #333;

    transition: right 0.3s ease;

    z-index: 1000;

    overflow-y: auto;

  }



  .rfp-manager.visible {

    right: 0;

  }



  .header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 1rem;

    border-bottom: 1px solid #333;

    background: #2a2a2a;

  }



  .header h3 {

    margin: 0;

    color: #e0e0e0;

    font-size: 1.2rem;

  }



  .close-btn {

    background: none;

    border: none;

    color: #888;

    font-size: 1.5rem;

    cursor: pointer;

    padding: 0.25rem;

  }



  .close-btn:hover {

    color: #e0e0e0;

  }



  .content {

    padding: 1rem;

  }



  .upload-section {

    margin-bottom: 2rem;

  }



  .upload-section h4, .documents-section h4, .analysis-section h4 {

    color: #4a9eff;

    margin: 0 0 1rem 0;

    font-size: 1rem;

  }



  .upload-area {

    text-align: center;

    padding: 1rem;

    border: 2px dashed #333;

    border-radius: 8px;

  }



  .upload-btn {

    background: #4a9eff;

    color: white;

    border: none;

    padding: 0.75rem 1.5rem;

    border-radius: 6px;

    cursor: pointer;

    font-size: 0.9rem;

    margin-bottom: 0.5rem;

  }



  .upload-btn:hover:not(:disabled) {

    background: #357abd;

  }



  .upload-btn:disabled {

    background: #666;

    cursor: not-allowed;

  }



  .upload-help {

    color: #888;

    font-size: 0.8rem;

    margin: 0;

  }



  .documents-list {

    max-height: 300px;

    overflow-y: auto;

  }



  .document-item {

    display: flex;

    align-items: center;

    padding: 0.75rem;

    border-radius: 6px;

    cursor: pointer;

    transition: background-color 0.2s;

    margin-bottom: 0.5rem;

  }



  .document-item:hover {

    background: #2a2a2a;

  }



  .document-item.selected {

    background: #1e3a5f;

    border: 1px solid #4a9eff;

  }



  .doc-icon {

    font-size: 1.5rem;

    margin-right: 0.75rem;

  }



  .doc-info {

    flex: 1;

  }



  .doc-name {

    color: #e0e0e0;

    font-weight: 500;

    margin-bottom: 0.25rem;

  }



  .doc-meta {

    color: #888;

    font-size: 0.8rem;

  }



  .doc-status {

    margin-left: 1rem;

  }



  .status-processed {

    color: #4caf50;

    font-size: 0.8rem;

  }



  .status-pending {

    color: #ff9800;

    font-size: 0.8rem;

  }



  .empty-state, .loading {

    text-align: center;

    color: #888;

    padding: 2rem;

    font-style: italic;

  }



  .analysis-section {

    margin-top: 2rem;

    padding-top: 2rem;

    border-top: 1px solid #333;

  }



  .insights-grid {

    display: grid;

    gap: 1rem;

    margin-bottom: 2rem;

  }



  .insight-card {

    background: #2a2a2a;

    padding: 1rem;

    border-radius: 6px;

    border: 1px solid #333;

  }



  .insight-card h5 {

    margin: 0 0 0.75rem 0;

    color: #4a9eff;

    font-size: 0.9rem;

  }



  .tag-list {

    display: flex;

    flex-wrap: wrap;

    gap: 0.5rem;

  }



  .tag {

    background: #333;

    color: #e0e0e0;

    padding: 0.25rem 0.5rem;

    border-radius: 4px;

    font-size: 0.8rem;

  }



  .tech-tag {

    background: #1e3a5f;

    color: #4a9eff;

  }



  .compliance-tag {

    background: #1e4a1e;

    color: #4caf50;

  }



  .timeline-tag {

    background: #4a1e4a;

    color: #e91e63;

  }



  .budget-tag {

    background: #4a4a1e;

    color: #ffeb3b;

  }



  .strategy-section {

    background: #2a2a2a;

    padding: 1rem;

    border-radius: 6px;

    border: 1px solid #333;

  }



  .strategy-section h5 {

    margin: 0 0 1rem 0;

    color: #4a9eff;

  }



  .recommendations {

    display: flex;

    flex-direction: column;

    gap: 0.75rem;

  }



  .recommendation {

    color: #e0e0e0;

    font-size: 0.9rem;

    line-height: 1.4;

  }



  .recommendation strong {

    color: #4a9eff;

  }

</style>