Spaces:
Sleeping
Sleeping
File size: 82,880 Bytes
c300883 c1ceb60 c300883 adda1ae c300883 d330331 c300883 de71b62 c300883 d330331 adda1ae c300883 de71b62 9a6952b 33233d1 c300883 40d94c5 c300883 c1ceb60 c300883 c1ceb60 c300883 adda1ae c300883 33233d1 c300883 adda1ae c300883 adda1ae de71b62 adda1ae 33233d1 c300883 33233d1 c300883 adda1ae c300883 40d94c5 c300883 de71b62 40d94c5 c300883 de71b62 c300883 d7bf755 d330331 d7bf755 c300883 40d94c5 c300883 adda1ae c300883 40d94c5 de71b62 adda1ae 33233d1 c300883 40d94c5 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 c300883 c1ceb60 3a79ec0 c1ceb60 c300883 33233d1 c300883 33233d1 c300883 d7bf755 c300883 d330331 d7bf755 c300883 33233d1 c300883 33233d1 c300883 adda1ae c300883 33233d1 c300883 adda1ae c300883 33233d1 c300883 d330331 c300883 c1ceb60 c300883 adda1ae c300883 c1ceb60 c300883 c1ceb60 c300883 adda1ae c300883 c1ceb60 c300883 c1ceb60 c300883 adda1ae c300883 adda1ae c300883 c1ceb60 c300883 adda1ae c300883 adda1ae c300883 33233d1 c300883 adda1ae c300883 adda1ae c300883 adda1ae c300883 adda1ae c300883 adda1ae c300883 adda1ae de71b62 adda1ae c300883 d7bf755 c300883 adda1ae de71b62 adda1ae c300883 d330331 c300883 adda1ae d7bf755 adda1ae c300883 d330331 c300883 adda1ae de71b62 c300883 adda1ae 33233d1 c1ceb60 33233d1 c300883 adda1ae de71b62 adda1ae c300883 adda1ae c300883 adda1ae de71b62 c300883 adda1ae c300883 de71b62 adda1ae c300883 adda1ae 33233d1 c300883 adda1ae 33233d1 c300883 33233d1 c300883 adda1ae c300883 40d94c5 c300883 40d94c5 c300883 d7bf755 c300883 d7bf755 c300883 d330331 c300883 d7bf755 c300883 d330331 c300883 40d94c5 c300883 40d94c5 c300883 40d94c5 c300883 40d94c5 de71b62 9a6952b de71b62 9a6952b de71b62 9a6952b de71b62 9a6952b 33233d1 40d94c5 adda1ae 40d94c5 33233d1 40d94c5 adda1ae 40d94c5 de71b62 40d94c5 c300883 | 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 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eddison Intelligence β Patent Assistant</title>
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:wght@300;400;500&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #07090F;
--surface: #0E1118;
--surface2: #141821;
--border: rgba(255,255,255,0.07);
--border-active: rgba(200,241,53,0.4);
--accent: #C8F135;
--accent-dim: rgba(200,241,53,0.15);
--red: #FF4757;
--blue: #3B82F6;
--text: #EDF0FF;
--muted: rgba(237,240,255,0.45);
--mono: 'DM Mono', monospace;
--sans: 'DM Sans', sans-serif;
--display: 'Bebas Neue', sans-serif;
}
html, body {
height: 100%;
background: var(--bg);
color: var(--text);
font-family: var(--sans);
overflow-x: hidden;
}
/* βββ NOISE OVERLAY βββ */
body::after {
content: '';
position: fixed; inset: 0;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
pointer-events: none; z-index: 9999; opacity: 0.4;
}
/* βββ LAYOUT βββ */
.app {
display: grid;
grid-template-rows: auto 1fr;
min-height: 100vh;
}
/* βββ HEADER βββ */
header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 40px;
border-bottom: 1px solid var(--border);
background: rgba(7,9,15,0.9);
backdrop-filter: blur(12px);
position: sticky; top: 0; z-index: 100;
}
.logo {
font-family: var(--display);
font-size: 22px;
letter-spacing: 0.15em;
color: var(--text);
}
.logo span { color: var(--accent); }
.steps-nav {
display: flex;
align-items: center;
gap: 4px;
}
.step-btn {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 16px;
border-radius: 8px;
border: none;
background: transparent;
cursor: pointer;
font-family: var(--sans);
font-size: 12px;
font-weight: 500;
letter-spacing: 0.04em;
color: var(--muted);
transition: all 0.2s;
position: relative;
}
.step-btn .num {
width: 20px; height: 20px;
border-radius: 50%;
background: var(--surface2);
border: 1px solid var(--border);
display: flex; align-items: center; justify-content: center;
font-family: var(--mono);
font-size: 10px;
transition: all 0.2s;
}
.step-btn.active { color: var(--accent); }
.step-btn.active .num {
background: var(--accent-dim);
border-color: var(--accent);
color: var(--accent);
}
.step-btn.done { color: var(--muted); }
.step-btn.done .num {
background: rgba(200,241,53,0.08);
border-color: rgba(200,241,53,0.3);
color: rgba(200,241,53,0.6);
}
.step-divider {
width: 28px; height: 1px;
background: var(--border);
}
/* βββ MAIN CONTENT βββ */
main {
display: grid;
place-items: start center;
padding: 48px 24px 80px;
}
.panel {
width: 100%;
max-width: 820px;
animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp {
from { opacity: 0; transform: translateY(16px); }
to { opacity: 1; transform: translateY(0); }
}
.panel-header {
margin-bottom: 32px;
}
.panel-tag {
font-size: 10px;
letter-spacing: 0.2em;
text-transform: uppercase;
color: var(--accent);
font-weight: 500;
margin-bottom: 10px;
}
.panel-title {
font-family: var(--display);
font-size: 48px;
letter-spacing: 0.02em;
line-height: 0.95;
color: var(--text);
}
.panel-sub {
font-size: 14px;
color: var(--muted);
margin-top: 10px;
font-weight: 300;
}
/* βββ CARDS / BOXES βββ */
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 28px;
margin-bottom: 16px;
transition: border-color 0.2s;
}
.card:focus-within { border-color: var(--border-active); }
.card-label {
font-size: 11px;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 14px;
font-weight: 500;
}
textarea {
width: 100%;
background: transparent;
border: none;
outline: none;
font-family: var(--sans);
font-size: 14px;
color: var(--text);
resize: none;
line-height: 1.6;
font-weight: 300;
}
textarea::placeholder { color: rgba(237,240,255,0.2); }
/* βββ FILE UPLOAD βββ */
.upload-zone {
border: 1px dashed rgba(255,255,255,0.12);
border-radius: 10px;
padding: 24px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
background: rgba(255,255,255,0.02);
}
.upload-zone:hover, .upload-zone.dragover {
border-color: rgba(200,241,53,0.4);
background: var(--accent-dim);
}
.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--muted); font-weight: 300; }
.upload-text strong { color: var(--accent); font-weight: 500; }
#fileInput { display: none; }
.file-attached {
display: flex; align-items: center; gap: 10px;
font-size: 13px; color: var(--accent);
background: var(--accent-dim);
border-radius: 8px; padding: 10px 14px;
margin-top: 12px;
}
/* βββ OR DIVIDER βββ */
.or-row {
display: flex; align-items: center; gap: 16px;
margin: 16px 0; color: var(--muted); font-size: 12px;
}
.or-row::before, .or-row::after {
content: ''; flex: 1; height: 1px; background: var(--border);
}
/* βββ TAGS (keywords / kind codes) βββ */
.tags-area {
display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.tag {
display: flex; align-items: center; gap: 6px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 6px;
padding: 5px 10px;
font-size: 12px;
font-family: var(--mono);
color: var(--text);
cursor: pointer;
transition: all 0.15s;
user-select: none;
}
.tag:hover { border-color: rgba(200,241,53,0.3); }
.tag.selected {
background: var(--accent-dim);
border-color: var(--accent);
color: var(--accent);
}
.tag.kind-code {
background: rgba(59,130,246,0.1);
border-color: rgba(59,130,246,0.3);
color: #93C5FD;
}
.tag.kind-code.selected {
background: rgba(59,130,246,0.2);
border-color: #3B82F6;
color: #60A5FA;
}
.tag.cpc-code {
background: rgba(168,85,247,0.1);
border-color: rgba(168,85,247,0.3);
color: #C084FC;
}
.tag.cpc-code.selected {
background: rgba(168,85,247,0.2);
border-color: #A855F7;
color: #D8B4FE;
}
.tag-remove {
width: 14px; height: 14px;
display: flex; align-items: center; justify-content: center;
opacity: 0.5; transition: opacity 0.15s;
font-size: 14px; line-height: 1;
}
.tag-remove:hover { opacity: 1; }
.tag-input-row {
display: flex; gap: 8px; margin-top: 12px;
}
.tag-input {
flex: 1;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px 14px;
font-family: var(--mono);
font-size: 12px;
color: var(--text);
outline: none;
transition: border-color 0.2s;
}
.tag-input:focus { border-color: var(--border-active); }
.tag-input::placeholder { color: rgba(237,240,255,0.2); }
/* βββ BUTTONS βββ */
.btn {
display: inline-flex; align-items: center; gap: 8px;
padding: 11px 24px;
border-radius: 9px;
border: none;
font-family: var(--sans);
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
letter-spacing: 0.02em;
}
.btn-primary {
background: var(--accent);
color: #07090F;
}
.btn-primary:hover { background: #d4f54a; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(200,241,53,0.3); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
background: var(--surface2);
border: 1px solid var(--border);
color: var(--text);
}
.btn-secondary:hover { border-color: rgba(255,255,255,0.2); }
.btn-ghost {
background: transparent;
border: 1px solid var(--border);
color: var(--muted);
padding: 8px 14px;
font-size: 12px;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.btn-row {
display: flex; align-items: center; gap: 12px;
margin-top: 24px;
}
/* βββ LOADING SPINNER βββ */
.spinner {
width: 16px; height: 16px;
border: 2px solid rgba(7,9,15,0.3);
border-top-color: #07090F;
border-radius: 50%;
animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-accent {
border-color: rgba(200,241,53,0.2);
border-top-color: var(--accent);
}
/* βββ PRIOR ART RESULTS βββ */
.prior-art-list { display: flex; flex-direction: column; gap: 12px; }
.prior-art-item {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px 22px;
cursor: pointer;
transition: all 0.2s;
position: relative;
}
.prior-art-item:hover { border-color: rgba(255,255,255,0.15); }
.prior-art-item.approved {
border-color: var(--accent);
background: rgba(200,241,53,0.04);
}
.prior-art-item.rejected {
border-color: rgba(255,71,87,0.3);
background: rgba(255,71,87,0.03);
opacity: 0.5;
}
.pa-header {
display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
margin-bottom: 8px;
}
.pa-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.3; }
.pa-num {
font-family: var(--mono);
font-size: 11px;
color: var(--accent);
background: var(--accent-dim);
padding: 3px 8px;
border-radius: 4px;
white-space: nowrap;
flex-shrink: 0;
text-decoration: none;
transition: filter 0.15s, text-decoration 0.15s;
}
a.pa-num:hover {
text-decoration: underline;
filter: brightness(1.2);
}
.pa-relevance {
display: inline-block;
font-family: var(--mono);
font-size: 11px;
font-weight: 600;
padding: 2px 8px;
border-radius: 4px;
margin-bottom: 6px;
}
.pa-relevance.high { color: #4ade80; background: rgba(74,222,128,0.12); }
.pa-relevance.medium { color: #facc15; background: rgba(250,204,21,0.12); }
.pa-relevance.low { color: var(--muted); background: rgba(237,240,255,0.06); }
.pa-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 300; }
.pa-abstract { font-size: 13px; color: rgba(237,240,255,0.6); line-height: 1.55; font-weight: 300; }
.pa-actions {
display: flex; gap: 8px; margin-top: 14px;
}
.approve-btn {
padding: 6px 14px; font-size: 12px; border-radius: 6px; border: none; cursor: pointer;
background: var(--accent-dim); border: 1px solid rgba(200,241,53,0.3);
color: var(--accent); font-family: var(--sans); font-weight: 500;
transition: all 0.15s;
}
.approve-btn:hover { background: rgba(200,241,53,0.25); }
.approve-btn.active { background: var(--accent); color: #07090F; }
.reject-btn {
padding: 6px 14px; font-size: 12px; border-radius: 6px; border: 1px solid rgba(255,71,87,0.2);
color: rgba(255,71,87,0.6); background: transparent; cursor: pointer; font-family: var(--sans);
transition: all 0.15s;
}
.reject-btn:hover { border-color: var(--red); color: var(--red); }
.reject-btn.active { background: rgba(255,71,87,0.1); border-color: var(--red); color: var(--red); }
.approved-count {
font-size: 12px; color: var(--muted); margin-top: 6px;
}
.approved-count strong { color: var(--accent); }
/* βββ CLAIM DRAFT βββ */
.claim-output {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
overflow: hidden;
}
.claim-toolbar {
display: flex; align-items: center; justify-content: space-between;
padding: 14px 20px;
border-bottom: 1px solid var(--border);
background: var(--surface2);
}
.claim-toolbar-left {
font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
color: var(--muted); font-weight: 500;
}
.claim-content {
padding: 28px;
font-size: 14px; line-height: 1.8;
color: rgba(237,240,255,0.85);
font-weight: 300;
white-space: pre-wrap;
font-family: var(--sans);
min-height: 300px;
}
.claim-content[contenteditable="true"] { outline: none; }
.claim-content[contenteditable="true"]:focus {
background: rgba(255,255,255,0.01);
}
.claim-num {
font-family: var(--mono);
font-size: 12px;
color: var(--accent);
font-weight: 400;
}
/* βββ STATUS BADGE βββ */
.status-badge {
display: inline-flex; align-items: center; gap: 6px;
font-size: 11px; font-weight: 500;
padding: 4px 10px; border-radius: 20px;
}
.status-badge.generating {
background: rgba(59,130,246,0.15);
color: #93C5FD;
border: 1px solid rgba(59,130,246,0.3);
}
.status-badge.done {
background: var(--accent-dim);
color: var(--accent);
border: 1px solid rgba(200,241,53,0.3);
}
/* βββ SECTION DIVIDERS βββ */
.section-gap { margin-top: 24px; }
/* βββ EMPTY STATE βββ */
.empty-state {
text-align: center; padding: 60px 40px;
color: var(--muted); font-size: 14px; font-weight: 300;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
/* βββ ERROR CARD βββ */
.error-card {
background: rgba(255,71,87,0.06);
border: 1px solid rgba(255,71,87,0.3);
border-radius: 12px;
padding: 24px 28px;
margin-top: 16px;
}
.error-card-header {
display: flex; align-items: center; gap: 10px;
font-size: 14px; font-weight: 500; color: var(--red);
margin-bottom: 10px;
}
.error-card-detail {
font-size: 13px; color: rgba(255,71,87,0.7);
font-weight: 300; line-height: 1.5;
margin-bottom: 16px;
font-family: var(--mono);
word-break: break-word;
}
.error-card .btn-ghost {
border-color: rgba(255,71,87,0.3);
color: var(--red);
}
.error-card .btn-ghost:hover {
border-color: var(--red);
}
/* βββ KEYWORD HIGHLIGHT βββ */
.pa-highlight {
background: var(--accent-dim);
border-radius: 2px;
padding: 0 2px;
}
/* βββ COPY BUTTON FEEDBACK βββ */
.copied { color: var(--accent) !important; }
/* βββ CLAIM ANALYSIS βββ */
.analysis-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-top: 16px;
}
@media (max-width: 768px) {
.analysis-grid { grid-template-columns: 1fr; }
}
.analysis-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 24px;
transition: border-color 0.2s;
}
.analysis-card:hover { border-color: rgba(255,255,255,0.15); }
.analysis-card-icon { font-size: 24px; margin-bottom: 12px; }
.analysis-card-title {
font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
color: var(--muted); font-weight: 500; margin-bottom: 10px;
}
.analysis-rating {
display: inline-flex; align-items: center;
font-size: 12px; font-weight: 600; font-family: var(--mono);
padding: 4px 12px; border-radius: 20px; margin-bottom: 12px;
}
.analysis-rating.green {
background: rgba(74,222,128,0.12); color: #4ade80; border: 1px solid rgba(74,222,128,0.3);
}
.analysis-rating.yellow {
background: rgba(250,204,21,0.12); color: #facc15; border: 1px solid rgba(250,204,21,0.3);
}
.analysis-rating.red {
background: rgba(255,71,87,0.12); color: var(--red); border: 1px solid rgba(255,71,87,0.3);
}
.analysis-summary {
font-size: 13px; color: rgba(237,240,255,0.85); line-height: 1.5;
font-weight: 400; margin-bottom: 14px;
}
.analysis-bullets { list-style: none; padding: 0; margin: 0; }
.analysis-bullets li {
font-size: 12px; color: rgba(237,240,255,0.6); line-height: 1.55;
font-weight: 300; padding: 4px 0 4px 16px; position: relative;
}
.analysis-bullets li::before {
content: '\2014'; position: absolute; left: 0; color: var(--muted);
}
.analysis-improve-btn {
margin-top: 16px; padding: 6px 14px; font-size: 11px; font-weight: 500;
font-family: var(--sans); border-radius: 6px; cursor: pointer;
background: transparent; color: var(--accent);
border: 1px solid rgba(200,241,53,0.3);
transition: all 0.15s;
}
.analysis-improve-btn:hover {
background: var(--accent-dim); border-color: var(--accent);
}
/* βββ COLLAPSIBLE SECTIONS βββ */
.collapsible-header {
display: flex; align-items: center; justify-content: space-between;
cursor: pointer; user-select: none;
}
.collapsible-header:hover { color: var(--text); }
.collapse-icon { font-size: 10px; color: var(--muted); transition: transform 0.2s; }
/* βββ DECOMPOSITION GRID βββ */
.decomp-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px;
}
@media (max-width: 600px) { .decomp-grid { grid-template-columns: 1fr; } }
.decomp-label {
font-size: 11px; font-weight: 500; color: var(--accent);
letter-spacing: 0.05em; margin-bottom: 8px;
}
.decomp-list { list-style: none; padding: 0; margin: 0; }
.decomp-list li {
font-size: 13px; color: rgba(237,240,255,0.75); line-height: 1.55;
padding: 3px 0 3px 14px; position: relative; font-weight: 300;
}
.decomp-list li::before { content: '\203A'; position: absolute; left: 0; color: var(--accent); }
/* βββ SYNONYM EXPANSION βββ */
.synonym-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.synonym-row:last-child { border-bottom: none; }
.synonym-feature { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.synonym-tags { display: flex; flex-wrap: wrap; gap: 6px; }
/* βββ BOOLEAN QUERIES βββ */
.boolean-query-item {
background: var(--surface2); border: 1px solid var(--border);
border-radius: 10px; padding: 16px; margin-bottom: 10px;
}
.boolean-query-label {
font-size: 11px; font-weight: 500; color: var(--accent);
letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px;
}
.boolean-query-text {
font-family: var(--mono); font-size: 12px; color: rgba(237,240,255,0.7);
line-height: 1.6; background: rgba(0,0,0,0.2); border-radius: 6px;
padding: 10px 12px; margin-bottom: 10px; word-break: break-word;
}
.boolean-query-actions { display: flex; gap: 8px; }
/* βββ SEED PATENT βββ */
.seed-patent-summary {
background: var(--surface2); border: 1px solid var(--border);
border-radius: 10px; padding: 16px;
}
/* βββ SATURATION BAR βββ */
.saturation-bar {
background: var(--surface); border: 1px solid var(--border);
border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.saturation-header {
display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.saturation-pct { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--accent); }
.saturation-track {
width: 100%; height: 6px; background: var(--surface2);
border-radius: 3px; overflow: hidden; margin-bottom: 8px;
}
.saturation-fill {
height: 100%; background: var(--accent); border-radius: 3px;
transition: width 0.4s ease; width: 0%;
}
.saturation-hint { font-size: 12px; color: var(--muted); font-weight: 300; }
/* βββ EVALUATION TABLE βββ */
.pa-evaluation table { font-family: var(--sans); }
.pa-evaluation th {
font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500;
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="logo"><span>EDDISON</span> INTELLIGENCE</div>
<nav class="steps-nav">
<button class="step-btn active" id="nav1" onclick="goToStep(1)">
<span class="num">1</span> Idea & Codes
</button>
<div class="step-divider"></div>
<button class="step-btn" id="nav2" onclick="goToStep(2)">
<span class="num">2</span> Prior Art Search
</button>
<div class="step-divider"></div>
<button class="step-btn" id="nav3" onclick="goToStep(3)">
<span class="num">3</span> Draft Claim
</button>
</nav>
<button class="btn btn-ghost" onclick="if(confirm('Clear all progress and start over?')) clearState()" style="font-size:11px;opacity:0.6">βΊ Start Over</button>
</header>
<main>
<!-- ββββββββββββββ STEP 1 ββββββββββββββ -->
<div class="panel" id="step1">
<div class="panel-header">
<div class="panel-tag">Step 01 / 03</div>
<div class="panel-title">Describe Your<br>Invention</div>
<div class="panel-sub">Type a description or upload notes β we'll extract keywords and suggest USPTO Kind Codes.</div>
</div>
<div class="card">
<div class="card-label">Describe your invention</div>
<textarea id="ideaText" rows="5" placeholder="e.g. A machine learning system that automatically classifies patent applications and routes them to the correct examiner based on technical field..."></textarea>
</div>
<div class="or-row">or</div>
<div class="card" style="padding:20px">
<div class="card-label">Upload notes or documents</div>
<div class="upload-zone" id="uploadZone" onclick="document.getElementById('fileInput').click()">
<div class="upload-icon">π</div>
<div class="upload-text"><strong>Click to upload</strong> or drag & drop a .txt, .pdf, or .docx file</div>
</div>
<input type="file" id="fileInput" accept=".txt,.pdf,.docx" onchange="handleFile(event)">
<div id="fileAttached" style="display:none"></div>
</div>
<div class="btn-row">
<button class="btn btn-primary" id="analyzeBtn" onclick="analyzeIdea()">
β¦ Analyze & Extract Keywords
</button>
</div>
<div id="extractedSection" style="display:none" class="section-gap">
<div class="card">
<div class="card-label">Extracted Keywords β click to toggle selection</div>
<div class="tags-area" id="keywordTags"></div>
<div class="tag-input-row">
<input class="tag-input" id="kwInput" placeholder="+ Add keyword..." onkeydown="addTagOnEnter(event,'keyword')">
<button class="btn btn-ghost" onclick="addTag('keyword')">Add</button>
</div>
</div>
<div class="card section-gap">
<div class="card-label">Suggested CPC Codes
<span style="font-size:10px;color:var(--muted);margin-left:8px;text-transform:none;letter-spacing:0">
(Cooperative Patent Classification β e.g. G06F40/30)
</span>
</div>
<div class="tags-area" id="cpcCodeTags"></div>
<div class="tag-input-row">
<input class="tag-input" id="cpcInput" placeholder="+ Add CPC code..." onkeydown="addTagOnEnter(event,'cpc')">
<button class="btn btn-ghost" onclick="addTag('cpc')">Add</button>
</div>
</div>
<div class="card section-gap">
<div class="card-label">Suggested USPTO Kind Codes
<span style="font-size:10px;color:var(--muted);margin-left:8px;text-transform:none;letter-spacing:0">
(e.g. A1=Published App, B1=Granted Patent, B2=Reissue...)
</span>
</div>
<div class="tags-area" id="kindCodeTags"></div>
<div class="tag-input-row">
<input class="tag-input" id="kcInput" placeholder="+ Add kind code..." onkeydown="addTagOnEnter(event,'kindcode')">
<button class="btn btn-ghost" onclick="addTag('kindcode')">Add</button>
</div>
</div>
<!-- Invention Decomposition (collapsible) -->
<div class="card section-gap" id="decompositionCard" style="display:none">
<div class="card-label collapsible-header" onclick="toggleSection('decomposition')">
<span>Invention Decomposition</span>
<span class="collapse-icon" id="decomposition-icon">▼</span>
</div>
<div class="collapsible-body" id="decomposition-body">
<div class="decomp-grid">
<div class="decomp-col">
<div class="decomp-label">Core Technical Features</div>
<ul class="decomp-list" id="coreFeatures"></ul>
</div>
<div class="decomp-col">
<div class="decomp-label">Supporting Features</div>
<ul class="decomp-list" id="supportingFeatures"></ul>
</div>
<div class="decomp-col">
<div class="decomp-label">Claimed Improvements</div>
<ul class="decomp-list" id="claimedImprovements"></ul>
</div>
<div class="decomp-col">
<div class="decomp-label">HW/SW Components</div>
<ul class="decomp-list" id="hwswComponents"></ul>
</div>
</div>
</div>
</div>
<!-- Synonym Expansion (collapsible) -->
<div class="card section-gap" id="synonymCard" style="display:none">
<div class="card-label collapsible-header" onclick="toggleSection('synonym')">
<span>Synonym Expansion</span>
<span class="collapse-icon" id="synonym-icon">▼</span>
</div>
<div class="collapsible-body" id="synonym-body">
<div id="synonymGrid"></div>
</div>
</div>
<div class="btn-row">
<button class="btn btn-primary" onclick="goToStep(2)">Continue to Prior Art Search β</button>
</div>
</div>
</div>
<!-- ββββββββββββββ STEP 2 ββββββββββββββ -->
<div class="panel" id="step2" style="display:none">
<div class="panel-header">
<div class="panel-tag">Step 02 / 03</div>
<div class="panel-title">Prior Art<br>Search</div>
<div class="panel-sub">Review your search parameters, then approve or reject results to inform your claim.</div>
</div>
<div class="card">
<div class="card-label">Search Keywords</div>
<div class="tags-area" id="searchKeywords"></div>
<div class="tag-input-row">
<input class="tag-input" id="skInput" placeholder="+ Add keyword..." onkeydown="addSearchTagOnEnter(event,'kw')">
<button class="btn btn-ghost" onclick="addSearchTag('kw')">Add</button>
</div>
</div>
<div class="card">
<div class="card-label">CPC Codes to Include</div>
<div class="tags-area" id="searchCpcCodes"></div>
</div>
<div class="card">
<div class="card-label">Kind Codes to Include</div>
<div class="tags-area" id="searchKindCodes"></div>
</div>
<div class="card">
<div class="card-label">Sort by</div>
<select id="sortSelect" style="background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:8px 14px;font-family:var(--sans);font-size:13px;color:var(--text);">
<option value="relevance">Most relevant</option>
<option value="date">Newest first</option>
<option value="citations">Most cited first</option>
</select>
</div>
<!-- Boolean Search Strings (collapsible) -->
<div class="card section-gap" id="booleanQueriesCard" style="display:none">
<div class="card-label collapsible-header" onclick="toggleSection('boolean')">
<span>Boolean Search Strings</span>
<span class="collapse-icon" id="boolean-icon">▼</span>
</div>
<div class="collapsible-body" id="boolean-body">
<div class="panel-sub" style="margin-bottom:16px;font-size:12px">
Reference queries for USPTO Full-Text search. Click "Run in App" to search with extracted keywords.
</div>
<div id="booleanQueryList"></div>
</div>
</div>
<!-- Seed Patent Strategy (collapsible) -->
<div class="card section-gap" id="seedPatentCard" style="display:none">
<div class="card-label collapsible-header" onclick="toggleSection('seed')">
<span>Seed Patent Strategy</span>
<span class="collapse-icon" id="seed-icon">▼</span>
</div>
<div class="collapsible-body" id="seed-body">
<div class="panel-sub" style="margin-bottom:12px;font-size:12px">
Mark a result as your "seed patent" to mine its citations and CPC codes for expanded search.
</div>
<div id="seedPatentInfo" style="display:none"></div>
<div id="seedPatentEmpty" style="font-size:12px;color:var(--muted)">
No seed patent selected. After searching, click "Use as Seed" on a result to begin citation mining.
</div>
</div>
</div>
<div class="btn-row">
<button class="btn btn-primary" id="searchBtn" onclick="runPriorArtSearch()">
β Search Prior Art
</button>
<button class="btn btn-secondary" onclick="goToStep(1)">β Back</button>
</div>
<div id="priorArtResults" class="section-gap" style="display:none">
<!-- Saturation Tracker -->
<div class="saturation-bar" id="saturationBar" style="display:none">
<div class="saturation-header">
<span class="card-label" style="margin:0">Search Saturation</span>
<span class="saturation-pct" id="saturationPct">0%</span>
</div>
<div class="saturation-track">
<div class="saturation-fill" id="saturationFill"></div>
</div>
<div class="saturation-hint" id="saturationHint"></div>
</div>
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:16px">
<div style="font-family:var(--display);font-size:22px;letter-spacing:0.05em">Results</div>
<div class="approved-count" id="approvedCount"></div>
</div>
<div class="prior-art-list" id="paList"></div>
<div id="loadMoreWrap" style="margin-top:16px;display:none">
<button class="btn btn-secondary" id="loadMoreBtn" onclick="loadMorePriorArt()">Load more</button>
</div>
<div class="btn-row" style="margin-top:24px">
<button class="btn btn-primary" id="proceedBtn" onclick="goToStep(3)">
Draft Claim from Approved Art β
</button>
<button class="btn btn-secondary" onclick="runPriorArtSearch()">Re-search</button>
</div>
</div>
</div>
<!-- ββββββββββββββ STEP 3 ββββββββββββββ -->
<div class="panel" id="step3" style="display:none">
<div class="panel-header">
<div class="panel-tag">Step 03 / 03</div>
<div class="panel-title">First Claim<br>Draft</div>
<div class="panel-sub">AI-drafted independent and dependent claims based on your invention and approved prior art. Edit inline.</div>
</div>
<div id="claimLoading" class="card" style="text-align:center;padding:60px">
<div style="display:flex;justify-content:center;margin-bottom:16px">
<div class="spinner spinner-accent" style="width:28px;height:28px;border-width:3px"></div>
</div>
<div style="color:var(--muted);font-size:13px">Drafting patent claims...</div>
</div>
<div id="claimOutputWrap" style="display:none">
<div class="claim-output">
<div class="claim-toolbar">
<div class="claim-toolbar-left">Patent Claims Draft</div>
<div style="display:flex;gap:8px;align-items:center">
<span class="status-badge done" id="claimStatus">β Draft Ready</span>
<button class="btn btn-ghost" onclick="copyClaim(event)">Copy</button>
</div>
</div>
<div class="claim-content" id="claimContent" contenteditable="true"></div>
</div>
<!-- Claim Analysis -->
<div id="claimAnalysisWrap" style="display:none">
<div style="margin-top:28px;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between">
<div style="font-family:var(--display);font-size:22px;letter-spacing:0.05em">Claim Analysis</div>
<span class="status-badge done" id="analysisStatus" style="display:none">✓ Analysis Complete</span>
</div>
<div id="analysisGrid" class="analysis-grid"></div>
</div>
<div id="claimAnalysisLoading" style="display:none;text-align:center;padding:40px;margin-top:20px" class="card">
<div style="display:flex;justify-content:center;margin-bottom:16px">
<div class="spinner spinner-accent" style="width:28px;height:28px;border-width:3px"></div>
</div>
<div style="color:var(--muted);font-size:13px">Analyzing claim specificity, protection scope, and infringement potential...</div>
</div>
<div id="claimAnalysisError" style="display:none"></div>
<div style="margin-top:20px">
<button class="btn btn-secondary" id="analyzeClaimBtn" onclick="analyzeClaimDraft()">⚖ Analyze Claims</button>
</div>
<div class="btn-row" style="margin-top:12px">
<button class="btn btn-primary" onclick="copyClaim(event)">Copy to Clipboard</button>
<button class="btn btn-secondary" onclick="regenerateClaim()">Regenerate</button>
<button class="btn btn-ghost" onclick="goToStep(2)">← Back to Prior Art</button>
</div>
</div>
</div>
</main>
</div>
<script>
// βββ CONFIG ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const API_BASE = window.location.origin;
function renderError(container, message, detail, retryFn) {
container.innerHTML = `
<div class="error-card">
<div class="error-card-header">β ${message}</div>
${detail ? `<div class="error-card-detail">${detail}</div>` : ''}
${retryFn ? `<button class="btn btn-ghost" id="_retryBtn">Try Again</button>` : ''}
</div>`;
if (retryFn) {
container.querySelector('#_retryBtn').onclick = retryFn;
}
container.style.display = 'block';
}
// βββ STATE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const STORAGE_KEY = 'eddison_state';
const state = {
ideaText: '',
keywords: [],
selectedKeywords: [],
kindCodes: [],
selectedKindCodes: [],
cpcCodes: [],
selectedCpcCodes: [],
priorArt: [],
approvedArt: [],
claimDraft: '',
claimAnalysis: null,
currentStep: 1,
searchAfter: null,
searchTotal: 0,
searchKeywords: [],
// USPTO 7-Step Methodology fields
decomposition: null,
synonyms: null,
booleanQueries: null,
seedPatent: null,
evaluations: {},
saturation: { searchesRun: 0, queriesExhausted: [] }
};
function saveState() {
try { localStorage.setItem(STORAGE_KEY, JSON.stringify(state)); } catch(e) {}
}
function loadState() {
try {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved) Object.assign(state, JSON.parse(saved));
} catch(e) {}
}
function clearState() {
localStorage.removeItem(STORAGE_KEY);
location.reload();
}
// βββ NAVIGATION ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function goToStep(n, opts = {}) {
[1,2,3].forEach(i => {
document.getElementById(`step${i}`).style.display = 'none';
document.getElementById(`nav${i}`).className = 'step-btn';
});
document.getElementById(`step${n}`).style.display = 'block';
document.getElementById(`nav${n}`).className = 'step-btn active';
for(let i = 1; i < n; i++) document.getElementById(`nav${i}`).className = 'step-btn done';
window.scrollTo({ top: 0, behavior: 'smooth' });
state.currentStep = n;
saveState();
if (n === 2) populateSearchPanel();
if (n === 3 && !opts.skipGenerate) generateClaim();
}
// βββ STEP 1: FILE HANDLING βββββββββββββββββββββββββββββββββββββββββββββββββββ
const uploadZone = document.getElementById('uploadZone');
uploadZone.addEventListener('dragover', e => { e.preventDefault(); uploadZone.classList.add('dragover'); });
uploadZone.addEventListener('dragleave', () => uploadZone.classList.remove('dragover'));
uploadZone.addEventListener('drop', e => {
e.preventDefault(); uploadZone.classList.remove('dragover');
const file = e.dataTransfer.files[0];
if (file) processFile(file);
});
function handleFile(e) { processFile(e.target.files[0]); }
function processFile(file) {
const div = document.getElementById('fileAttached');
div.style.display = 'flex';
div.innerHTML = `<span>π</span><span>${file.name} β extracting text...</span>`;
const ext = file.name.split('.').pop().toLowerCase();
if (file.type === 'text/plain' || ext === 'txt') {
const reader = new FileReader();
reader.onload = e => {
setExtractedText(file.name, e.target.result);
};
reader.readAsText(file);
} else if (ext === 'pdf') {
const reader = new FileReader();
reader.onload = async e => {
try {
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js';
const pdf = await pdfjsLib.getDocument({ data: new Uint8Array(e.target.result) }).promise;
let text = '';
for (let i = 1; i <= pdf.numPages; i++) {
const page = await pdf.getPage(i);
const content = await page.getTextContent();
text += content.items.map(item => item.str).join(' ') + '\n';
}
setExtractedText(file.name, text);
} catch (err) {
div.innerHTML = `<span>β οΈ</span><span>${file.name} β PDF extraction failed</span>`;
document.getElementById('ideaText').value = '';
}
};
reader.readAsArrayBuffer(file);
} else if (ext === 'docx') {
const reader = new FileReader();
reader.onload = async e => {
try {
const result = await mammoth.extractRawText({ arrayBuffer: e.target.result });
setExtractedText(file.name, result.value);
} catch (err) {
div.innerHTML = `<span>β οΈ</span><span>${file.name} β DOCX extraction failed</span>`;
document.getElementById('ideaText').value = '';
}
};
reader.readAsArrayBuffer(file);
} else {
div.innerHTML = `<span>β οΈ</span><span>${file.name} β unsupported format (use .txt, .pdf, or .docx)</span>`;
}
}
function setExtractedText(filename, text) {
const cleaned = text.trim();
document.getElementById('ideaText').value = cleaned;
const div = document.getElementById('fileAttached');
const charCount = cleaned.length;
div.innerHTML = `<span>π</span><span>${filename} β ${charCount.toLocaleString()} characters extracted</span>`;
}
// βββ STEP 1: ANALYZE βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function analyzeIdea() {
const text = document.getElementById('ideaText').value.trim();
if (!text) { document.getElementById('ideaText').focus(); return; }
state.ideaText = text;
const btn = document.getElementById('analyzeBtn');
btn.disabled = true;
btn.innerHTML = '<div class="spinner"></div> Analyzing (decomposing invention)...';
try {
const response = await fetch(`${API_BASE}/api/analyze-deep`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text })
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || `Server error (HTTP ${response.status})`);
}
const parsed = await response.json();
// Existing fields
state.keywords = parsed.keywords || [];
state.kindCodes = parsed.kindCodes || [];
state.cpcCodes = (parsed.cpcCodes || []).map(c => ({
code: c.code, reason: c.reason || '', type: c.type || 'primary'
}));
state.selectedKeywords = [...state.keywords];
state.selectedKindCodes = state.kindCodes.map(k => k.code);
state.selectedCpcCodes = state.cpcCodes.map(c => c.code);
// New 7-step methodology fields
state.decomposition = parsed.decomposition || null;
state.synonyms = parsed.synonyms || null;
state.booleanQueries = parsed.booleanQueries || null;
// Clear evaluations and saturation when re-analyzing
state.evaluations = {};
state.saturation = { searchesRun: 0, queriesExhausted: [] };
// Render existing sections
renderKeywords();
renderCpcCodes();
renderKindCodes();
// Render new methodology sections
if (state.decomposition) renderDecomposition();
if (state.synonyms) renderSynonyms();
document.getElementById('extractedSection').style.display = 'block';
document.getElementById('extractedSection').scrollIntoView({ behavior: 'smooth', block: 'start' });
} catch (err) {
const section = document.getElementById('extractedSection');
renderError(section, 'Analysis failed', err.message, analyzeIdea);
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
saveState();
btn.disabled = false;
btn.innerHTML = 'β¦ Re-analyze';
}
function renderKeywords() {
const container = document.getElementById('keywordTags');
container.innerHTML = '';
state.keywords.forEach((kw, i) => {
const tag = document.createElement('div');
tag.className = 'tag' + (state.selectedKeywords.includes(kw) ? ' selected' : '');
tag.innerHTML = `${kw}<span class="tag-remove" onclick="removeTag(event,'keyword',${i})">Γ</span>`;
tag.onclick = (e) => { if (!e.target.classList.contains('tag-remove')) toggleKeyword(kw, tag); };
container.appendChild(tag);
});
}
function renderCpcCodes() {
const container = document.getElementById('cpcCodeTags');
if (!container) return;
container.innerHTML = '';
state.cpcCodes.forEach((cc, i) => {
const tag = document.createElement('div');
const selected = state.selectedCpcCodes.includes(cc.code);
tag.className = 'tag cpc-code' + (selected ? ' selected' : '');
tag.title = cc.reason || '';
tag.innerHTML = `${cc.code}<span class="tag-remove" onclick="removeCpcCode(event,${i})">Γ</span>`;
tag.onclick = (e) => { if (!e.target.classList.contains('tag-remove')) toggleCpcCode(cc.code, tag); };
container.appendChild(tag);
});
}
function renderKindCodes() {
const container = document.getElementById('kindCodeTags');
container.innerHTML = '';
state.kindCodes.forEach((kc, i) => {
const tag = document.createElement('div');
const selected = state.selectedKindCodes.includes(kc.code);
tag.className = 'tag kind-code' + (selected ? ' selected' : '');
tag.title = kc.reason || '';
tag.innerHTML = `<strong>${kc.code}</strong> β ${kc.label}<span class="tag-remove" onclick="removeKindCode(event,${i})">Γ</span>`;
tag.onclick = (e) => { if (!e.target.classList.contains('tag-remove')) toggleKindCode(kc.code, tag); };
container.appendChild(tag);
});
}
function toggleKeyword(kw, el) {
const idx = state.selectedKeywords.indexOf(kw);
if (idx > -1) { state.selectedKeywords.splice(idx, 1); el.classList.remove('selected'); }
else { state.selectedKeywords.push(kw); el.classList.add('selected'); }
saveState();
}
function toggleKindCode(code, el) {
const idx = state.selectedKindCodes.indexOf(code);
if (idx > -1) { state.selectedKindCodes.splice(idx, 1); el.classList.remove('selected'); }
else { state.selectedKindCodes.push(code); el.classList.add('selected'); }
saveState();
}
function toggleCpcCode(code, el) {
const idx = state.selectedCpcCodes.indexOf(code);
if (idx > -1) { state.selectedCpcCodes.splice(idx, 1); el.classList.remove('selected'); }
else { state.selectedCpcCodes.push(code); el.classList.add('selected'); }
saveState();
}
function removeCpcCode(e, i) {
e.stopPropagation();
const code = state.cpcCodes[i].code;
state.cpcCodes.splice(i, 1);
state.selectedCpcCodes = state.selectedCpcCodes.filter(c => c !== code);
renderCpcCodes();
saveState();
}
function removeTag(e, type, i) {
e.stopPropagation();
state.keywords.splice(i, 1);
state.selectedKeywords = state.selectedKeywords.filter(k => state.keywords.includes(k));
renderKeywords();
saveState();
}
function removeKindCode(e, i) {
e.stopPropagation();
const code = state.kindCodes[i].code;
state.kindCodes.splice(i, 1);
state.selectedKindCodes = state.selectedKindCodes.filter(c => c !== code);
renderKindCodes();
saveState();
}
function addTagOnEnter(e, type) { if (e.key === 'Enter') { e.preventDefault(); addTag(type); } }
function addTag(type) {
if (type === 'keyword') {
const val = document.getElementById('kwInput').value.trim();
if (val && !state.keywords.includes(val)) { state.keywords.push(val); state.selectedKeywords.push(val); renderKeywords(); }
document.getElementById('kwInput').value = '';
} else if (type === 'cpc') {
const val = document.getElementById('cpcInput').value.trim();
if (val && !state.cpcCodes.find(c => c.code === val)) {
state.cpcCodes.push({ code: val, reason: '' });
state.selectedCpcCodes.push(val);
renderCpcCodes();
}
document.getElementById('cpcInput').value = '';
} else {
const val = document.getElementById('kcInput').value.trim().toUpperCase();
if (val && !state.kindCodes.find(k => k.code === val)) {
state.kindCodes.push({ code: val, label: val, reason: '' });
state.selectedKindCodes.push(val);
renderKindCodes();
}
document.getElementById('kcInput').value = '';
}
saveState();
}
// βββ STEP 2: POPULATE SEARCH PANEL βββββββββββββββββββββββββββββββββββββββββββ
function populateSearchPanel() {
const kwContainer = document.getElementById('searchKeywords');
kwContainer.innerHTML = '';
state.selectedKeywords.forEach((kw, i) => {
const tag = document.createElement('div');
tag.className = 'tag selected';
tag.dataset.kw = kw;
tag.innerHTML = `${escapeHtml(kw)}<span class="tag-remove" onclick="removeSearchKw(event, this)">Γ</span>`;
kwContainer.appendChild(tag);
});
const cpcContainer = document.getElementById('searchCpcCodes');
if (cpcContainer) {
cpcContainer.innerHTML = '';
state.selectedCpcCodes.forEach(code => {
const tag = document.createElement('div');
tag.className = 'tag cpc-code selected';
tag.innerHTML = code;
cpcContainer.appendChild(tag);
});
}
const kcContainer = document.getElementById('searchKindCodes');
kcContainer.innerHTML = '';
state.selectedKindCodes.forEach(code => {
const tag = document.createElement('div');
const kc = state.kindCodes.find(k => k.code === code);
tag.className = 'tag kind-code selected';
tag.innerHTML = `<strong>${code}</strong>${kc ? ' β ' + kc.label : ''}`;
kcContainer.appendChild(tag);
});
// Render 7-step methodology panels
renderBooleanQueries();
if (state.seedPatent !== null) {
document.getElementById('seedPatentCard').style.display = 'block';
document.getElementById('seedPatentEmpty').style.display = 'none';
} else {
document.getElementById('seedPatentCard').style.display = 'block';
}
updateSaturation();
}
function removeSearchKw(e, btn) {
e.stopPropagation();
(btn || e.target).closest('.tag').remove();
}
function addSearchTagOnEnter(e, type) { if (e.key === 'Enter') addSearchTag(type); }
function addSearchTag(type) {
const val = document.getElementById('skInput').value.trim();
if (!val) return;
const kwContainer = document.getElementById('searchKeywords');
const tag = document.createElement('div');
tag.className = 'tag selected';
tag.dataset.kw = val;
tag.innerHTML = `${escapeHtml(val)}<span class="tag-remove" onclick="this.closest('.tag').remove()">Γ</span>`;
kwContainer.appendChild(tag);
document.getElementById('skInput').value = '';
}
function getSearchKeywords() {
return [...document.querySelectorAll('#searchKeywords .tag')].map(t => t.dataset.kw || t.textContent.replace('Γ','').trim());
}
// βββ STEP 2: SEARCH βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function runPriorArtSearch(append) {
const btn = document.getElementById('searchBtn');
btn.disabled = true;
btn.innerHTML = '<div class="spinner"></div> Searching...';
if (!append) document.getElementById('priorArtResults').style.display = 'none';
const keywords = getSearchKeywords();
const codes = state.selectedKindCodes;
const cpcCodes = state.selectedCpcCodes || [];
const sortBy = document.getElementById('sortSelect')?.value || 'relevance';
const apiSortBy = sortBy === 'relevance' ? 'date' : sortBy;
const after = append ? state.searchAfter : null;
try {
const response = await fetch(`${API_BASE}/api/search`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keywords,
kind_codes: codes,
cpc_codes: cpcCodes,
sort_by: apiSortBy,
after
})
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || `Server error (HTTP ${response.status})`);
}
const data = await response.json();
const results = data.results || [];
if (append) {
state.priorArt = state.priorArt.concat(results);
} else {
state.priorArt = results;
state.approvedArt = [];
}
state.searchAfter = data.after || null;
state.searchTotal = data.total || 0;
state.searchKeywords = [...keywords];
} catch(err) {
state.priorArt = [];
const resultsDiv = document.getElementById('priorArtResults');
const listDiv = document.getElementById('paList');
renderError(listDiv, 'Prior art search failed', err.message, runPriorArtSearch);
resultsDiv.style.display = 'block';
resultsDiv.scrollIntoView({ behavior: 'smooth' });
btn.disabled = false;
btn.innerHTML = 'β Re-Search';
return;
}
if (!append) state.approvedArt = [];
if (sortBy === 'relevance') {
const kw = state.searchKeywords || keywords;
state.priorArt.sort((a, b) =>
computeRelevanceScore(b, kw, cpcCodes) - computeRelevanceScore(a, kw, cpcCodes)
);
}
renderPriorArt();
document.getElementById('priorArtResults').style.display = 'block';
if (!append) document.getElementById('priorArtResults').scrollIntoView({ behavior: 'smooth' });
const loadMoreWrap = document.getElementById('loadMoreWrap');
const hasMore = state.searchAfter && state.priorArt.length < state.searchTotal;
if (loadMoreWrap) loadMoreWrap.style.display = hasMore ? 'block' : 'none';
// Track saturation
if (!append) state.saturation.searchesRun++;
saveState();
updateSaturation();
btn.disabled = false;
btn.innerHTML = 'β Re-Search';
}
function loadMorePriorArt() {
runPriorArtSearch(true);
}
function escapeHtml(s) {
if (!s) return '';
const div = document.createElement('div');
div.textContent = s;
return div.innerHTML;
}
function computeRelevanceScore(patent, keywords, cpcCodes) {
if (!keywords || keywords.length === 0) return 0;
let score = 0;
const title = (patent.title || '').toLowerCase();
const abstract = (patent.abstract || '').toLowerCase();
const seen = new Set();
keywords.forEach(kw => {
if (!kw) return;
const lower = kw.toLowerCase();
if (seen.has(lower)) return;
seen.add(lower);
if (title.includes(lower)) score += 15;
if (abstract.includes(lower)) score += 5;
});
if (cpcCodes && cpcCodes.length > 0 && patent.cpc) {
const patentCpc = patent.cpc.toLowerCase();
if (cpcCodes.some(c => patentCpc.startsWith(c.toLowerCase()))) score += 15;
}
return Math.min(100, score);
}
function highlightKeywords(text, keywords) {
if (!text || !keywords || keywords.length === 0) return escapeHtml(text);
let out = escapeHtml(text);
const seen = new Set();
keywords.forEach(kw => {
if (!kw || seen.has(kw.toLowerCase())) return;
seen.add(kw.toLowerCase());
const re = new RegExp(`(${kw.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi');
out = out.replace(re, '<mark class="pa-highlight">$1</mark>');
});
return out;
}
function renderPriorArt() {
const list = document.getElementById('paList');
list.innerHTML = '';
const keywords = state.searchKeywords || [];
state.priorArt.forEach((pa, i) => {
const div = document.createElement('div');
div.className = 'prior-art-item';
div.id = `pa-${i}`;
const titleHtml = highlightKeywords(pa.title, keywords);
const abstractHtml = highlightKeywords(pa.abstract, keywords);
const patentId = (pa.patentNumber || '').replace(/[,\s\/]/g, '');
const score = computeRelevanceScore(pa, keywords, state.selectedCpcCodes || []);
const scoreTier = score >= 70 ? 'high' : score >= 40 ? 'medium' : 'low';
div.innerHTML = `
<div class="pa-header">
<div class="pa-title">${titleHtml}</div>
<a class="pa-num" href="https://patents.google.com/patent/${patentId}" target="_blank" rel="noopener" onclick="event.stopPropagation()">${escapeHtml(pa.patentNumber || '')}</a>
</div>
<div class="pa-relevance ${scoreTier}">Relevance: ${score}%</div>
<div class="pa-meta">${escapeHtml(pa.assignee || '')} Β· ${escapeHtml(String(pa.year || ''))} Β· Kind Code: <strong>${escapeHtml(pa.kindCode || '')}</strong></div>
<div class="pa-abstract">${abstractHtml}</div>
<div class="pa-actions">
<button class="approve-btn" id="approve-${i}" onclick="approvePA(${i})">β Approve</button>
<button class="reject-btn" id="reject-${i}" onclick="rejectPA(${i})">β Reject</button>
<button class="btn btn-ghost" style="font-size:11px;padding:4px 10px" onclick="event.stopPropagation();toggleCitations(${i})">Related patents</button>
<button class="btn btn-ghost" style="font-size:11px;padding:4px 10px" onclick="event.stopPropagation();evaluatePatent(${i})">⚖ Evaluate</button>
<button class="btn btn-ghost" style="font-size:11px;padding:4px 10px" onclick="event.stopPropagation();setSeedPatent(${i})">★ Use as Seed</button>
</div>
<div id="citations-${i}" class="pa-citations" style="display:none;margin-top:12px;padding-top:12px;border-top:1px solid var(--border);font-size:12px;color:var(--muted)"></div>
<div id="eval-${i}" style="display:none"></div>
`;
list.appendChild(div);
});
updateApprovedCount();
// Re-render any cached evaluations
Object.keys(state.evaluations).forEach(idx => {
const i = parseInt(idx);
if (state.evaluations[i]) renderEvaluation(i, state.evaluations[i]);
});
}
async function toggleCitations(i) {
const el = document.getElementById(`citations-${i}`);
if (!el) return;
if (el.style.display === 'block') {
el.style.display = 'none';
return;
}
const pa = state.priorArt[i];
if (!pa) return;
const pid = (pa.patentNumber || '').replace(/[,\s\/]/g, '').replace(/^US/i, '');
if (!pid) return;
el.innerHTML = '<span>Loading...</span>';
el.style.display = 'block';
try {
const resp = await fetch(`${API_BASE}/api/patent/${pid}/citations`);
if (!resp.ok) throw new Error('Failed to load');
const data = await resp.json();
const citing = (data.citing || []).map(p => `US${p.patent_id}`).filter(Boolean);
const cited = (data.cited || []).map(p => `US${p.patent_id}`).filter(Boolean);
let html = '';
if (citing.length) {
html += '<div style="margin-bottom:8px"><strong>Citing this patent:</strong> ';
html += citing.map(id => `<a href="https://patents.google.com/patent/${id.replace(/[,\s]/g,'')}" target="_blank" rel="noopener" style="color:var(--accent);margin-right:8px">${id}</a>`).join('');
html += '</div>';
}
if (cited.length) {
html += '<div><strong>Cited by this patent:</strong> ';
html += cited.map(id => `<a href="https://patents.google.com/patent/${id.replace(/[,\s]/g,'')}" target="_blank" rel="noopener" style="color:var(--accent);margin-right:8px">${id}</a>`).join('');
html += '</div>';
}
if (!html) html = 'No citation data found.';
el.innerHTML = html;
} catch (e) {
el.innerHTML = 'Could not load citations.';
}
}
function approvePA(i) {
const item = document.getElementById(`pa-${i}`);
const approveBtn = document.getElementById(`approve-${i}`);
const rejectBtn = document.getElementById(`reject-${i}`);
item.classList.remove('rejected');
item.classList.toggle('approved');
approveBtn.classList.toggle('active');
rejectBtn.classList.remove('active');
if (state.approvedArt.includes(i)) {
state.approvedArt = state.approvedArt.filter(x => x !== i);
} else {
state.approvedArt.push(i);
}
updateApprovedCount();
saveState();
}
function rejectPA(i) {
const item = document.getElementById(`pa-${i}`);
const approveBtn = document.getElementById(`approve-${i}`);
const rejectBtn = document.getElementById(`reject-${i}`);
item.classList.remove('approved');
item.classList.toggle('rejected');
rejectBtn.classList.toggle('active');
approveBtn.classList.remove('active');
state.approvedArt = state.approvedArt.filter(x => x !== i);
updateApprovedCount();
saveState();
}
function updateApprovedCount() {
const n = state.approvedArt.length;
document.getElementById('approvedCount').innerHTML = n > 0
? `<strong>${n}</strong> approved for claim drafting`
: 'Approve at least 1 result to proceed';
document.getElementById('proceedBtn').disabled = n === 0;
document.getElementById('proceedBtn').style.opacity = n === 0 ? '0.4' : '1';
}
// βββ STEP 3: CLAIM GENERATION βββββββββββββββββββββββββββββββββββββββββββββββββ
async function generateClaim() {
document.getElementById('claimLoading').style.display = 'block';
document.getElementById('claimOutputWrap').style.display = 'none';
const approvedPatents = state.approvedArt.map(i => state.priorArt[i]);
const priorArtSummary = approvedPatents.map(p =>
`- ${p.patentNumber}: "${p.title}" (${p.assignee}, ${p.year}): ${p.abstract}`
).join('\n');
try {
const response = await fetch(`${API_BASE}/api/generate-claim`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
invention_text: state.ideaText,
prior_art: approvedPatents
})
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || `Server error (HTTP ${response.status})`);
}
const data = await response.json();
state.claimDraft = data.claims || '';
} catch(err) {
document.getElementById('claimLoading').style.display = 'none';
const wrap = document.getElementById('claimOutputWrap');
renderError(wrap, 'Claim generation failed', err.message, regenerateClaim);
return;
}
document.getElementById('claimContent').innerText = state.claimDraft;
document.getElementById('claimLoading').style.display = 'none';
document.getElementById('claimOutputWrap').style.display = 'block';
saveState();
}
async function regenerateClaim() {
document.getElementById('claimOutputWrap').style.display = 'none';
await generateClaim();
}
function copyClaim(e) {
const text = document.getElementById('claimContent').innerText;
navigator.clipboard.writeText(text).then(() => {
const btn = e ? e.target : document.activeElement;
const orig = btn.textContent;
btn.textContent = 'β Copied!';
btn.classList.add('copied');
setTimeout(() => { btn.textContent = orig; btn.classList.remove('copied'); }, 2000);
});
}
// βββ STEP 3: CLAIM ANALYSIS βββββββββββββββββββββββββββββββββββββββββββββββββ
async function analyzeClaimDraft() {
const claims = document.getElementById('claimContent').innerText.trim();
if (!claims) return;
const btn = document.getElementById('analyzeClaimBtn');
btn.disabled = true;
btn.innerHTML = '<div class="spinner"></div> Analyzing...';
document.getElementById('claimAnalysisWrap').style.display = 'none';
document.getElementById('claimAnalysisError').style.display = 'none';
document.getElementById('claimAnalysisLoading').style.display = 'block';
const approvedPatents = state.approvedArt.map(i => state.priorArt[i]);
try {
const response = await fetch(`${API_BASE}/api/analyze-claim`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
claims: claims,
invention_text: state.ideaText,
prior_art: approvedPatents
})
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || `Server error (HTTP ${response.status})`);
}
const data = await response.json();
state.claimAnalysis = data;
} catch(err) {
document.getElementById('claimAnalysisLoading').style.display = 'none';
const errorWrap = document.getElementById('claimAnalysisError');
renderError(errorWrap, 'Claim analysis failed', err.message, analyzeClaimDraft);
btn.disabled = false;
btn.innerHTML = '⚖ Analyze Claims';
return;
}
document.getElementById('claimAnalysisLoading').style.display = 'none';
renderClaimAnalysis();
saveState();
btn.disabled = false;
btn.innerHTML = '⚖ Re-Analyze Claims';
}
function ratingColor(section, rating) {
const r = (rating || '').toLowerCase();
if (section === 'specificity') return r === 'high' ? 'green' : r === 'medium' ? 'yellow' : 'red';
if (section === 'protection') return r === 'broad' ? 'green' : r === 'moderate' ? 'yellow' : 'red';
if (section === 'infringements') return r === 'high' ? 'green' : r === 'medium' ? 'yellow' : 'red';
return 'yellow';
}
function renderClaimAnalysis() {
if (!state.claimAnalysis) return;
const grid = document.getElementById('analysisGrid');
const data = state.claimAnalysis;
const sections = [
{ key: 'specificity', icon: '\uD83D\uDD0D', title: 'Specificity' },
{ key: 'protection', icon: '\uD83D\uDEE1\uFE0F', title: 'Protection Scope' },
{ key: 'infringements', icon: '\u26A0\uFE0F', title: 'Potential Infringements' }
];
const bestRating = { specificity: 'high', protection: 'broad', infringements: 'high' };
grid.innerHTML = sections.map(s => {
const section = data[s.key];
if (!section) return '';
const color = ratingColor(s.key, section.rating);
const bullets = (section.bullets || []).map(b => `<li>${escapeHtml(b)}</li>`).join('');
const isBest = (section.rating || '').toLowerCase() === bestRating[s.key];
const improveBtn = isBest ? '' :
`<button class="analysis-improve-btn" onclick="improveClaimDimension('${s.key}')">↻ Improve ${escapeHtml(s.title)}</button>`;
return `
<div class="analysis-card">
<div class="analysis-card-icon">${s.icon}</div>
<div class="analysis-card-title">${s.title}</div>
<div class="analysis-rating ${color}">${escapeHtml(section.rating)}</div>
<div class="analysis-summary">${escapeHtml(section.summary)}</div>
<ul class="analysis-bullets">${bullets}</ul>
${improveBtn}
</div>`;
}).join('');
document.getElementById('claimAnalysisWrap').style.display = 'block';
document.getElementById('analysisStatus').style.display = 'inline-flex';
}
async function improveClaimDimension(dimension) {
const claims = document.getElementById('claimContent').innerText.trim();
if (!claims || !state.claimAnalysis || !state.claimAnalysis[dimension]) return;
const feedback = state.claimAnalysis[dimension];
// Show loading state β reuse claim loading spinner
document.getElementById('claimAnalysisWrap').style.display = 'none';
document.getElementById('claimAnalysisLoading').style.display = 'none';
document.getElementById('claimLoading').style.display = 'block';
document.getElementById('claimOutputWrap').style.display = 'none';
const approvedPatents = state.approvedArt.map(i => state.priorArt[i]);
try {
const response = await fetch(`${API_BASE}/api/generate-claim`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
invention_text: state.ideaText,
prior_art: approvedPatents,
improvement_focus: dimension,
previous_claims: claims,
analysis_feedback: feedback
})
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || `Server error (HTTP ${response.status})`);
}
const data = await response.json();
state.claimDraft = data.claims || '';
} catch(err) {
document.getElementById('claimLoading').style.display = 'none';
const wrap = document.getElementById('claimOutputWrap');
renderError(wrap, 'Claim improvement failed', err.message, () => improveClaimDimension(dimension));
return;
}
// Clear old analysis so user re-analyzes the improved version
state.claimAnalysis = null;
document.getElementById('claimContent').innerText = state.claimDraft;
document.getElementById('claimLoading').style.display = 'none';
document.getElementById('claimOutputWrap').style.display = 'block';
document.getElementById('claimAnalysisWrap').style.display = 'none';
document.getElementById('analysisStatus').style.display = 'none';
document.getElementById('analyzeClaimBtn').innerHTML = '⚖ Analyze Claims';
saveState();
document.getElementById('claimContent').scrollIntoView({ behavior: 'smooth' });
}
// βββ USPTO 7-STEP: COLLAPSIBLE SECTIONS ββββββββββββββββββββββββββββββββββββββ
function toggleSection(name) {
const body = document.getElementById(`${name}-body`);
const icon = document.getElementById(`${name}-icon`);
if (!body) return;
if (body.style.display === 'none') {
body.style.display = 'block';
if (icon) icon.innerHTML = '▲';
} else {
body.style.display = 'none';
if (icon) icon.innerHTML = '▼';
}
}
// βββ USPTO STEP 1: RENDER DECOMPOSITION ββββββββββββββββββββββββββββββββββββββ
function renderDecomposition() {
const d = state.decomposition;
if (!d) return;
document.getElementById('decompositionCard').style.display = 'block';
const render = (id, items) => {
const ul = document.getElementById(id);
if (ul) ul.innerHTML = (items || []).map(f => `<li>${escapeHtml(f)}</li>`).join('');
};
render('coreFeatures', d.core_features);
render('supportingFeatures', d.supporting_features);
render('claimedImprovements', d.claimed_improvements);
render('hwswComponents', d.components);
}
// βββ USPTO STEP 2: RENDER SYNONYMS ββββββββββββββββββββββββββββββββββββββββββ
function renderSynonyms() {
const s = state.synonyms;
if (!s || typeof s !== 'object') return;
document.getElementById('synonymCard').style.display = 'block';
const grid = document.getElementById('synonymGrid');
grid.innerHTML = Object.entries(s).map(([feature, data]) => `
<div class="synonym-row">
<div class="synonym-feature">${escapeHtml(feature)}</div>
<div class="synonym-tags">
${(data.technical_synonyms || []).map(t => `<span class="tag">${escapeHtml(t)}</span>`).join('')}
${(data.industry_terms || []).map(t => `<span class="tag kind-code">${escapeHtml(t)}</span>`).join('')}
${data.broader ? `<span class="tag cpc-code" title="Broader term">${escapeHtml(data.broader)}</span>` : ''}
${data.narrower ? `<span class="tag" style="background:rgba(74,222,128,0.1);border-color:rgba(74,222,128,0.3);color:#4ade80" title="Narrower term">${escapeHtml(data.narrower)}</span>` : ''}
</div>
</div>
`).join('');
}
// βββ USPTO STEP 4: BOOLEAN QUERIES ββββββββββββββββββββββββββββββββββββββββββ
function renderBooleanQueries() {
const queries = state.booleanQueries;
if (!queries || queries.length === 0) {
document.getElementById('booleanQueriesCard').style.display = 'none';
return;
}
document.getElementById('booleanQueriesCard').style.display = 'block';
const list = document.getElementById('booleanQueryList');
list.innerHTML = queries.map((q, i) => `
<div class="boolean-query-item">
<div class="boolean-query-label">${escapeHtml(q.label || q.level)}</div>
<div class="boolean-query-text">${escapeHtml(q.query)}</div>
<div class="boolean-query-actions">
<button class="btn btn-ghost" style="font-size:11px" onclick="copyBooleanQuery(${i})">Copy for USPTO</button>
<button class="btn btn-ghost" style="font-size:11px;color:var(--accent);border-color:rgba(200,241,53,0.3)" onclick="runBooleanQuery(${i})">Run in App</button>
</div>
</div>
`).join('');
}
function copyBooleanQuery(index) {
const q = state.booleanQueries[index];
if (!q) return;
navigator.clipboard.writeText(q.query).then(() => {
const items = document.querySelectorAll('.boolean-query-item');
if (items[index]) {
const btn = items[index].querySelector('.btn-ghost');
if (btn) { const orig = btn.textContent; btn.textContent = 'β Copied!'; setTimeout(() => btn.textContent = orig, 1500); }
}
});
}
function runBooleanQuery(index) {
const q = state.booleanQueries[index];
if (!q || !q.keyword_sets || q.keyword_sets.length === 0) return;
const kwContainer = document.getElementById('searchKeywords');
kwContainer.innerHTML = '';
q.keyword_sets.forEach(kw => {
const tag = document.createElement('div');
tag.className = 'tag selected';
tag.dataset.kw = kw;
tag.innerHTML = `${escapeHtml(kw)}<span class="tag-remove" onclick="this.closest('.tag').remove()">Γ</span>`;
kwContainer.appendChild(tag);
});
if (!state.saturation.queriesExhausted.includes(q.level)) {
state.saturation.queriesExhausted.push(q.level);
}
state.saturation.searchesRun++;
saveState();
runPriorArtSearch();
}
// βββ USPTO STEP 5: SEED PATENT STRATEGY βββββββββββββββββββββββββββββββββββββ
function setSeedPatent(index) {
state.seedPatent = index;
saveState();
document.getElementById('seedPatentCard').style.display = 'block';
document.getElementById('seedPatentEmpty').style.display = 'none';
loadSeedCitations(index);
}
async function loadSeedCitations(index) {
const pa = state.priorArt[index];
if (!pa) return;
const pid = (pa.patentNumber || '').replace(/[,\s\/]/g, '').replace(/^US/i, '');
const infoDiv = document.getElementById('seedPatentInfo');
infoDiv.style.display = 'block';
infoDiv.innerHTML = '<div style="font-size:13px;color:var(--muted)"><div class="spinner spinner-accent" style="display:inline-block;vertical-align:middle;margin-right:8px;width:14px;height:14px;border-width:2px"></div>Loading citations...</div>';
try {
const resp = await fetch(`${API_BASE}/api/patent/${pid}/citations`);
if (!resp.ok) throw new Error('Failed');
const data = await resp.json();
const citing = (data.citing || []).map(p => `US${p.patent_id}`);
const cited = (data.cited || []).map(p => `US${p.patent_id}`);
const seedCpc = pa.cpc ? [pa.cpc] : [];
infoDiv.innerHTML = `
<div class="seed-patent-summary">
<div style="font-size:14px;font-weight:500;margin-bottom:8px">${escapeHtml(pa.patentNumber)}: ${escapeHtml(pa.title)}</div>
<div style="font-size:12px;color:var(--muted);margin-bottom:12px">
CPC: ${escapeHtml(pa.cpc || 'N/A')} | ${citing.length} patents cite this | Cites ${cited.length} patents
</div>
<div style="font-size:12px;margin-bottom:8px;color:rgba(237,240,255,0.8)">
<strong>Strategy:</strong> Search within this patent's CPC subclass and citation network for comprehensive coverage.
</div>
<div style="display:flex;gap:8px;flex-wrap:wrap">
${seedCpc.length ? `<button class="btn btn-ghost" style="font-size:11px" onclick="searchSeedCpc('${escapeHtml(seedCpc[0])}')">Search CPC ${escapeHtml(seedCpc[0])}</button>` : ''}
${citing.length ? `<span style="font-size:11px;color:var(--muted)">Citing: ${citing.slice(0,5).map(id => `<a href="https://patents.google.com/patent/${id.replace(/[,\s]/g,'')}" target="_blank" rel="noopener" style="color:var(--accent);margin-right:4px">${id}</a>`).join('')}${citing.length > 5 ? ` +${citing.length-5} more` : ''}</span>` : ''}
</div>
${cited.length ? `<div style="margin-top:8px;font-size:11px;color:var(--muted)">Cited: ${cited.slice(0,5).map(id => `<a href="https://patents.google.com/patent/${id.replace(/[,\s]/g,'')}" target="_blank" rel="noopener" style="color:var(--accent);margin-right:4px">${id}</a>`).join('')}${cited.length > 5 ? ` +${cited.length-5} more` : ''}</div>` : ''}
</div>
`;
} catch(e) {
infoDiv.innerHTML = '<div style="color:var(--red);font-size:12px">Could not load seed patent data.</div>';
}
}
function searchSeedCpc(cpcCode) {
// Add the seed CPC code to search CPC codes and re-search
if (!state.selectedCpcCodes.includes(cpcCode)) {
state.selectedCpcCodes.push(cpcCode);
}
state.saturation.searchesRun++;
saveState();
populateSearchPanel();
runPriorArtSearch();
}
// βββ USPTO STEP 6: EXAMINER COMPARISON FRAMEWORK ββββββββββββββββββββββββββββ
async function evaluatePatent(index) {
if (state.evaluations[index]) {
toggleEvaluation(index);
return;
}
const evalDiv = document.getElementById(`eval-${index}`);
if (!evalDiv) return;
const pa = state.priorArt[index];
if (!pa || !state.decomposition) {
evalDiv.innerHTML = '<div style="color:var(--muted);font-size:12px;padding:12px 0">Run analysis in Step 1 first to enable evaluation.</div>';
evalDiv.style.display = 'block';
return;
}
evalDiv.innerHTML = '<div style="padding:12px 0;font-size:12px;color:var(--muted)"><div class="spinner spinner-accent" style="display:inline-block;vertical-align:middle;margin-right:8px;width:14px;height:14px;border-width:2px"></div>Evaluating against invention features...</div>';
evalDiv.style.display = 'block';
try {
const response = await fetch(`${API_BASE}/api/evaluate-patent`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
invention_text: state.ideaText,
patent: pa,
decomposition: state.decomposition
})
});
if (!response.ok) {
const err = await response.json().catch(() => ({}));
throw new Error(err.detail || 'Evaluation failed');
}
const data = await response.json();
state.evaluations[index] = data;
saveState();
renderEvaluation(index, data);
} catch(err) {
evalDiv.innerHTML = `<div style="color:var(--red);font-size:12px;padding:12px 0">${escapeHtml(err.message)}</div>`;
}
}
function statusIcon(val) {
if (val === 'yes') return '<span style="color:#4ade80">✓</span>';
if (val === 'partial') return '<span style="color:#facc15">~</span>';
return '<span style="color:var(--muted)">✗</span>';
}
function renderEvaluation(index, data) {
const evalDiv = document.getElementById(`eval-${index}`);
if (!evalDiv) return;
const threatColors = { high: 'red', medium: 'yellow', low: 'green' };
const threatColor = threatColors[data.threat_level] || 'yellow';
const comparisonRows = (data.feature_comparison || []).map(fc => `
<tr>
<td style="padding:6px 8px;font-size:12px;border-bottom:1px solid var(--border)">${escapeHtml(fc.feature)}</td>
<td style="padding:6px 8px;text-align:center;border-bottom:1px solid var(--border)">${statusIcon(fc.disclosed)}</td>
<td style="padding:6px 8px;text-align:center;border-bottom:1px solid var(--border)">${statusIcon(fc.equivalent)}</td>
<td style="padding:6px 8px;text-align:center;border-bottom:1px solid var(--border)">${statusIcon(fc.same_solution)}</td>
<td style="padding:6px 8px;text-align:center;border-bottom:1px solid var(--border)">${statusIcon(fc.problem_only)}</td>
</tr>
`).join('');
evalDiv.innerHTML = `
<div class="pa-evaluation" style="padding:16px 0;border-top:1px solid var(--border);margin-top:12px">
<div style="display:flex;align-items:center;gap:12px;margin-bottom:12px">
<span style="font-size:11px;letter-spacing:0.12em;text-transform:uppercase;color:var(--muted);font-weight:500">Examiner Comparison</span>
<span class="analysis-rating ${threatColor}">${escapeHtml(data.threat_level || 'unknown')} threat</span>
</div>
<div style="font-size:13px;color:rgba(237,240,255,0.8);margin-bottom:12px">${escapeHtml(data.overlap_summary || '')}</div>
<table style="width:100%;border-collapse:collapse;font-size:12px;color:var(--text)">
<thead>
<tr style="color:var(--muted)">
<th style="text-align:left;padding:6px 8px;border-bottom:1px solid var(--border)">Feature</th>
<th style="padding:6px 8px;border-bottom:1px solid var(--border)">Disclosed</th>
<th style="padding:6px 8px;border-bottom:1px solid var(--border)">Equivalent</th>
<th style="padding:6px 8px;border-bottom:1px solid var(--border)">Same Sol.</th>
<th style="padding:6px 8px;border-bottom:1px solid var(--border)">Prob. Only</th>
</tr>
</thead>
<tbody>${comparisonRows}</tbody>
</table>
${data.distinguishing_features && data.distinguishing_features.length ? `
<div style="margin-top:12px;font-size:12px">
<strong style="color:var(--accent)">Distinguishing features:</strong>
${data.distinguishing_features.map(f => `<span class="tag" style="margin:4px 4px 0 0">${escapeHtml(f)}</span>`).join('')}
</div>
` : ''}
</div>
`;
evalDiv.style.display = 'block';
}
function toggleEvaluation(index) {
const el = document.getElementById(`eval-${index}`);
if (!el) return;
el.style.display = el.style.display === 'none' ? 'block' : 'none';
}
// βββ USPTO STEP 7: SATURATION TRACKING ββββββββββββββββββββββββββββββββββββββ
function updateSaturation() {
const s = state.saturation;
if (s.searchesRun === 0) {
document.getElementById('saturationBar').style.display = 'none';
return;
}
document.getElementById('saturationBar').style.display = 'block';
let score = 0;
// Factor 1: Number of distinct searches run (max 30 points for 3+ searches)
score += Math.min(30, s.searchesRun * 10);
// Factor 2: How many boolean query levels exhausted (max 30 points)
const uniqueExhausted = [...new Set(s.queriesExhausted)];
score += Math.min(30, uniqueExhausted.length * 10);
// Factor 3: Review coverage (max 20 points)
const totalReviewed = Object.keys(state.evaluations).length + state.approvedArt.length;
const totalResults = state.priorArt.length;
if (totalResults > 0) score += Math.min(20, Math.round((totalReviewed / totalResults) * 20));
// Factor 4: Having a seed patent (max 20 points)
if (state.seedPatent !== null) score += 20;
score = Math.min(100, score);
document.getElementById('saturationPct').textContent = `${score}%`;
document.getElementById('saturationFill').style.width = `${score}%`;
let hint = '';
if (score < 30) hint = 'Early stage \u2014 run broad and intermediate queries to establish baseline.';
else if (score < 60) hint = 'Developing \u2014 try examiner-level queries and evaluate key results.';
else if (score < 85) hint = 'Good coverage \u2014 use seed patent strategy and check diminishing returns.';
else hint = 'Near saturation \u2014 search is likely comprehensive for this invention scope.';
document.getElementById('saturationHint').textContent = hint;
}
// βββ RESTORE SESSION ON LOAD βββββββββββββββββββββββββββββββββββββββββββββββββ
function restoreSession() {
loadState();
if (!state.ideaText && state.keywords.length === 0) return;
document.getElementById('ideaText').value = state.ideaText;
if (state.keywords.length > 0) {
renderKeywords();
if (state.cpcCodes && state.cpcCodes.length) renderCpcCodes();
renderKindCodes();
// Restore 7-step methodology sections
if (state.decomposition) renderDecomposition();
if (state.synonyms) renderSynonyms();
document.getElementById('extractedSection').style.display = 'block';
document.getElementById('analyzeBtn').innerHTML = 'β¦ Re-analyze';
}
if (state.priorArt.length > 0) {
renderPriorArt();
const loadMoreWrap = document.getElementById('loadMoreWrap');
if (loadMoreWrap) loadMoreWrap.style.display = (state.searchAfter && state.priorArt.length < state.searchTotal) ? 'block' : 'none';
state.approvedArt.forEach(i => {
const item = document.getElementById(`pa-${i}`);
const btn = document.getElementById(`approve-${i}`);
if (item) { item.classList.add('approved'); }
if (btn) { btn.classList.add('active'); }
});
document.getElementById('priorArtResults').style.display = 'block';
document.getElementById('searchBtn').innerHTML = 'β Re-Search';
}
if (state.claimDraft) {
document.getElementById('claimContent').innerText = state.claimDraft;
document.getElementById('claimLoading').style.display = 'none';
document.getElementById('claimOutputWrap').style.display = 'block';
}
if (state.claimAnalysis) {
renderClaimAnalysis();
document.getElementById('analyzeClaimBtn').innerHTML = '⚖ Re-Analyze Claims';
}
if (state.currentStep > 1) {
goToStep(state.currentStep, { skipGenerate: true });
}
}
restoreSession();
</script>
</body>
</html>
|