PageSourceSearch

https://aimathsolver.co/build/assets/ai-chat-hdqRtwfu.js

js aimathsolver.co collected 2026-09-29 21:55:09 UTC 40,335 bytes, 161 lines download raw bytes

1import{p as i}from"./pageData-B3nQg5j2.js";import{h as Z,l as w,s as y}from"./ai-core-MTYXcks9.js";import{r as V,s as q}from"./ai-math-renderer-D_jPhNkG.js";import{r as ie}from"./ai-chat-history-CoRCWUXM.js";import{i as le}from"./ai-premium-modal-DHwfLQz5.js";const de=i("ai-chat-data","isChat",!1),R=i("ai-chat-data","markedJsUrl"),ce=i("ai-chat-data","skipTurnstile",!1),D=i("ai-chat-data","isAuthenticated",!1),U=i("ai-chat-data","cloudflareLocale","en"),pe=i("ai-chat-data","cloudflareSiteKey",""),ue=i("ai-chat-data","solveLabel","Solve"),he=i("ai-chat-data","sendIconUrl"),me=i("ai-chat-data","removeIconUrl"),K=i("ai-chat-data","downloadIconUrl"),X=i("ai-chat-data","tipRegenerateMessage","Regenerate Answer"),J=i("ai-chat-data","tipCopyMessage","Copy Answer"),G=i("ai-chat-data","tipDownMessage","Download Answer"),Y=i("ai-chat-data","tipGoodMessage","Good"),z=i("ai-chat-data","tipBadMessage","bad"),fe=i("ai-chat-data","premiumModalHtml",""),Ce=i("ai-chat-data","limitReachMessage","Your daily credit limit has been reached."),ge=i("ai-chat-data","pricingUrl"),$e=i("ai-chat-data","upgradeLabel","Upgrade"),_=i("ai-chat-data","unexpectedErrorMessage","An unexpected error occurred."),A=document.getElementById("statement");A&&A.addEventListener("input",function(){(this.innerHTML==="<br>"||this.textContent.trim()==="")&&(this.innerHTML="")});function W(e){let o="";return e.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE?o+=t.textContent:t.nodeType===Node.ELEMENT_NODE&&(t.classList.contains("txtMathField")&&window.mathFieldInstances?.[t.id]?o+=window.mathFieldInstances[t.id].latex():t.tagName==="BR"?o+=`
2`:o+=W(t)+`
3`)}),o}function Q(e){let o="";return e.childNodes.forEach(t=>{if(t.nodeType===Node.TEXT_NODE)o+=E(t.textContent);else if(t.nodeType===Node.ELEMENT_NODE)if(t.classList.contains("txtMathField")&&window.mathFieldInstances?.[t.id]){const n=window.mathFieldInstances[t.id].latex();o+=`<span class="math-tex" data-tex="${E(n)}">${E(n)}</span>`}else t.tagName==="BR"?o+="<br>":o+=Q(t)+"<br>"}),o}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function j(){var e=Date.now().toString(36),o=Math.random().toString(36).substr(2,5),t=e+o;return t}function we(e){$(`.edit-field-${e}`).removeClass("d-none"),$(`.submit-${e}, .close-edit-${e}`).removeClass("d-none"),$(`#input-search-${e}`).attr("contenteditable","true"),$("#statement, .input-search").off("keydown"),$(`#img-${e}`).attr("src")&&$(`#img-${e}`).attr("src").trim()!==""&&$(`.close-img-${e}`).hasClass("d-none")&&$(`.close-img-${e}`).removeClass("d-none")}function be(e){$(`.edit-icon-${e}`).removeClass("d-none"),$(`.submit-${e}, .close-edit-${e}`).addClass("d-none"),$(`#input-search-${e}`).attr("contenteditable","false"),$("#statement, .input-search").on("keydown",Z),$(`.close-img-${e}`).addClass("d-none")}function ve(e){$(`#img-${e}`).attr("src","").addClass("d-none"),$(`.close-img-${e}`).addClass("d-none")}document.addEventListener("DOMContentLoaded",function(){const e=document.querySelector(".arrow-down");e&&(e.addEventListener("click",function(){document.querySelector("#content-section").scrollIntoView({behavior:"smooth"})}),window.addEventListener("scroll",function(){window.scrollY===0?(e.style.opacity="1",e.style.pointerEvents="auto"):(e.style.opacity="0",e.style.pointerEvents="none")}))});document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".examples .unique_id").forEach(e=>{e.value=j()})});document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".loading").forEach(e=>{let o=e.id.split("-")[1],t=document.getElementById(`chat-response-${o}`);setTimeout(()=>{e.style.display="none",t.classList.remove("d-none")},1e3)})});document.querySelectorAll(".accordion-header").forEach(e=>{e.addEventListener("click",()=>{document.querySelectorAll(".accordion-body.active").forEach(t=>{t!==e.nextElementSibling&&(t.classList.remove("active"),t.previousElementSibling.classList.remove("collapsed"))});const o=e.nextElementSibling;e.classList.toggle("collapsed"),o.classList.toggle("active")})});de||$(".search").on("focus blur",function(e){$(".insideSearch").toggleClass("searchBorder",e.type==="focus")});$(document).ready(function(){$("#statement, .input-search").on("keydown",Z),$(".think").on("click",function(){$(".think").toggleClass("think-active")});var e=1,o=$(".authUserId").val(),t=t===0&&document.cookie.split("; ").find(p=>p.startsWith("user_id="))?parseInt(document.cookie.split("; ").find(p=>p.startsWith("user_id=")).split("=")[1]):o;const n=$("#unique_id").val()==null?j():$("#unique_id").val();$("#unique_id").val()==null||$("#unique_id").val(),$(".require-login").on("click",function(){typeof window.openLoginRequiredModal=="function"?window.openLoginRequiredModal():window.location.href="/sign-in"}),$("#historyCollapse .sidebar-header").map(function(){return $(this).text().trim()}).get().join(", "),$(".qr_scan").on("click",function(){$(".qr_code img").addClass("d-none"),$(".qr_code").removeClass("d-none"),$("#qr-loading").removeClass("d-none");let p=window.location.origin,a=j();$.ajax({method:"GET",url:p+"/qr_scan/"+a,xhr:function(){const r=new XMLHttpRequest;return r.responseType="blob",r},success:function(r){const s=new Blob([r],{type:"image/png"}),l=URL.createObjectURL(s);$("#qr-loading").addClass("d-none"),$(".qr_code img").attr("src",l),$(".qr_code img").removeClass("d-none")},error:function(r,s,l){console.error("Error:",l)}}),w("https://cdnjs.cloudflare.com/ajax/libs/pusher/5.0.3/pusher.min.js",()=>{new Pusher("00192f91488756bd52b2",{cluster:"us2",forceTLS:!0}).subscribe(`image-${a}`).bind("calculator-online",function(l){l.path?($(".previewImage").removeClass("d-none"),$("#imagePreview").attr("src",l.path),$(".drag_drop").addClass("d-none"),$("#fileName").val(l.fileName),$("#img").attr("src",l.path)):console.error("No path foun
3d in the received data")})})});let d=!1,h=window.location.href.includes("/history/");$(".send").on("click",async function(p){p.preventDefault();const a=$(this);$(`.edit-field-${e}`).addClass("d-none"),$("#route").val(),$(".send svg").addClass("fly-effect"),setTimeout(()=>$(".send svg").removeClass("fly-effect"),500),await w(R).catch(u=>console.error("Failed to load markdown renderer:",u));var r=$("#statement").text();$("#fileName").val(),$(".think").hasClass("think-active");const s=$("#imagePreview").attr("src")&&$("#imagePreview").attr("src")!=="",l=r.trim()!=="";if(a.attr("disabled",!0),!s&&!l){a.attr("disabled",!1),typeof Swal>"u"&&await w("https://cdn.jsdelivr.net/npm/sweetalert2@11"),Swal.fire({icon:"error",title:"Please enter text in the field.",toast:!0,position:"top-end",background:"var(--bg-white)",showConfirmButton:!1,timer:2e3,timerProgressBar:!0});return}if(d||h){a.attr("disabled",!1),c();return}D||ce?(a.attr("disabled",!1),c()):(document.querySelector("#cloudfare-recaptcha-container")||$(".captcha-area").append('<div id="cloudfare-recaptcha-container" style="position: absolute; right: 0; bottom: 30px;"></div>'),await w(`https://challenges.cloudflare.com/turnstile/v0/api.js?hl=${U}`),turnstile.render("#cloudfare-recaptcha-container",{sitekey:pe,language:U,callback:function(u){(!d||!h)&&(d=!0,$("#cloudfare-recaptcha-container").remove(),a.attr("disabled",!1),c(u))}}))});async function c(p){var a=document.querySelector(".ownMargin");a&&(a.style.display="none"),$("#output").css("margin-top","5rem"),$("#keyboard").addClass("latest-keyboard"),$(".footer-section").addClass("d-none"),$(".content-section-start").addClass("d-none"),$(".heading").addClass("d-none"),$(".camera").removeClass("d-none"),$(".search-box").removeClass("position-absolute bg-white shadow"),$(".search-box").addClass("afterSearch"),$(".section-main").removeClass("justify-content-center").addClass("justify-content-between"),$(".drag_drop").addClass("d-none"),$(".insideSearch").addClass("searchBorder"),$(".searchHistory").removeClass("d-none").addClass("d-flex"),$(`#loadingIndicator-${e}`).removeClass("d-none"),$(".examples").addClass("d-none"),$(".newChat").removeClass("d-none"),$("#section-search").addClass("section-search"),$(".previewImage").addClass("d-none");const r=W(document.getElementById("statement")),s=E(r).replace(/\n/g,"<br>"),l=Q(document.getElementById("statement")),f=$("#imagePreview").attr("src"),u=$("#route").val(),M=$("#fileName").val();if(!s&&(!f||f==="")){console.warn("Empty request detected. Skipping...");return}const te=`
4                <input type="hidden" name="route" id="route" value="${u}">
5                <div class="mt-md-2 gap-2 input-section d-flex align-items-center justify-content-end position-relative">
6                    <div class="py-1 px-3 flex-grow useChatColor radius-10">
7                        <img id="img-${e}" src="${f}" class="position-relative ${f?"":"d-none"}" alt="uploaded-image-preview-${e}" width="140px" height="140px" style="object-fit:contain;">
8                        <div class="edit-field-${e} d-flex justify-content-between align-items-center radius-10 py-1 px-2">
9                                <p id="input-search-${e}" contenteditable="false" class="flex-grow-1 input-search" data-placeholder="Type your problem here" style="height: auto !important;word-break: break-all; margin-bottom:0px;">
10                                ${l}
11                            </p>
12                            <div class="d-flex align-items-center gap-2">
13                                <button type="submit" class="me-2 align-items-center d-flex justify-content-center sended submit-${e} d-none update" style="margin-bottom: 1px;" aria-label="Submit form" onclick="edit(${e}, '${n}')">
14                                    <span class="text-white">
15                                        ${ue}
16                                    </span>
17                                    <img src="${he}" alt="send-btn" width="15px" height="15px">
18                                </button>
19                                <img src="${me}" alt="image" class="cursor-pointer close-edit-${e} d-none d-none" onclick="close_edit(${e})" width="20px" height="20px">
20                            </div>
21                        </div>
22                    </div>
23                    <button class="edit-icon-${e} bg-white edit-icon" onclick="edit_icon(${e})" type="button" style="border: none; border-radius: 50px; padding: 8px 10px 8px 10px;" class="edit-icon">
24                        <svg width="14" height="15" viewBox="0 0 16 17" fill="none"
25                            xmlns="http://www.w3.org/2000/svg">
26                            <g clip-path="url(#clip0_43_217)">
27                                <path
28                                    d="M15.2914 0.844073C14.8365 0.389874 14.2199 0.134766 13.5771 0.134766C12.9342 0.134766 12.3177 0.389874 11.8628 0.844073L0.980267 11.7266C0.668627 12.0365 0.421529 12.4051 0.25327 12.8111C0.0850108 13.2171 -0.00106923 13.6524 1.00242e-05 14.0919V15.4656C1.00242e-05 15.6431 0.0705062 15.8133 0.19599 15.9388C0.321474 16.0643 0.491667 16.1348 0.669128 16.1348H2.04283C2.48228 16.136 2.91761 16.0501 3.32362 15.8819C3.72963 15.7138 4.09826 15.4667 4.40816 15.1552L15.2914 4.27196C15.7454 3.81709 16.0003 3.20068 16.0003 2.55802C16.0003 1.91535 15.7454 1.29894 15.2914 0.844073ZM3.46202 14.209C3.08464 14.5839 2.57475 14.795 2.04283 14.7965H1.33825V14.0919C1.33757 13.8282 1.3892 13.567 1.49016 13.3234C1.59112 13.0798 1.73939 12.8587 1.9264 12.6727L10.1853 4.41382L11.7243 5.95279L3.46202 14.209ZM14.3446 3.32583L12.6677 5.00331L11.1288 3.46768L12.8063 1.79021C12.9073 1.68937 13.0272 1.60943 13.1592 1.55495C13.2911 1.50046 13.4325 1.4725 13.5752 1.47266C13.718 1.47281 13.8593 1.50108 13.9911 1.55585C14.123 1.61063 14.2427 1.69083 14.3436 1.79188C14.4444 1.89293 14.5243 2.01285 14.5788 2.14479C14.6333 2.27674 14.6613 2.41812 14.6611 2.56087C14.6609 2.70362 14.6327 2.84495 14.5779 2.97677C14.5231 3.1086 14.4429 3.22835 14.3419 3.32918L14.3446 3.32583Z"
29                                    fill="black" />
30                            </g>
31                            <defs>
32                                <clipPath id="clip0_43_217">
33                                    <rect width="16" height="16" fill="white" transform="translate(0 0.0761719)" />
34                                </clipPath>
35                            </defs>
36                        </svg>
37                    </button>
38                </div>
39                <div class="mt-2 output-section gap-2">
40                    <div class="result-${e} p-4 flex-grow-1 bg-white rounded" style="overflow-x:auto;" id="section-result-${e}">
41                        <div id="loadingIndicator-${e}" class="row w-50 mx-auto justify-content-center p-4">
42                            <p class="loader"></p>
43                        </div>
44                    </div>
45                </div>
46                <div class="other-buttons d-flex gap-1 mt-1 pb-2 other-btn-${e} position-relative">
47                
48                </div>
49            `;$("#output").append(te),V(document.getElementById(`input-search-${e}`)),$("#fileName").val(""),$("#imagePreview").attr("src",""),$("#statement").text("");const oe=1200*60;document.cookie=`unique_id=${n};path=/;max-age=${oe};`;const N=window.location.pathname.split("/").filter(b=>b),O=N[0],ne=/^[a-zA-Z]{2}$/.test(O);let S="",T="home";ne?(S=O,T=N[1]||"home"):(S="",T=N[0]||"home");let I="";S?I=`/${S}/${T}/history/${n}`:I=`/${T}/history/${n}`,history.pushState({},"",I);try{$("#output")[0].lastElementChild.scrollIntoView({behavior:"smooth"});let b={statement:s,route:u,captcha_token:p,unique_id:n};M&&(b.fileName=M);const k=await fetch("/mathSolver",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify(b)}),C=$(`.result-${e}`);if($(`#loadingIndicator-${e}`).addClass("d-none"),C.html('<div class="content"></div>'),k.ok){$("#output").css("margin-top","0px");
49const m=document.querySelector(".drag_drop .previewImage"),B=m?m.querySelector("#imagePreview"):null,L=B&&!m.classList.contains("d-none")?B.src:"";$(".afterChat").addClass("previewImage"),m&&m.remove(),L&&($("#imagePreview").attr("src",L),$(".previewImage").removeClass("d-none"));const v=await k.json(),x=v.message||v.content||v.result||v.candidates?.[0]?.content||"";if(!x){C.find(".content").html("<p>No response received.</p>");return}C.find(".content").html(q(x)),await V(C[0]);const F=`
50                        <div class="latex-info" style="font-size:12px;color:#666;margin-top:10px;">
51                            <strong>Tip:</strong> You can use LaTeX for math:
52                            Inline math: <code>$x^2 + y^2$</code>,
53                            Display math: <code>$$E = mc^2$$</code>.
54                        </div>
55                    `,ae=C.html();await fetch("/store",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({statement:s,fileName:M,unique_id:n,route:u,response_message:ae})}).then(H=>H.json()).then(H=>{var g=H.chat_id;if(D){const P=new Date,re={unique_id:n,message:s,page_url:u,time:P.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),full_date:P.toISOString(),diff_for_humans:"Just Now"};ChatHistory.addChat(u,re),ie(ChatHistory.get(u))}var se=`
56                            <button onclick="regenerate(${e},'${n}')" class="Regenerate other-icon" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Regenerate chat">
57                                <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${X}</span>
58                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md"><path d="M3.06957 10.8763C3.62331 6.43564 7.40967 3 12 3C14.2824 3 16.4028 3.85067 18.0118 5.25439V4C18.0118 3.44772 18.4595 3 19.0118 3C19.5641 3 20.0118 3.44772 20.0118 4V8C20.0118 8.55228 19.5641 9 19.0118 9H15C14.4477 9 14 8.55228 14 8C14 7.44772 14.4477 7 15 7H16.9571C15.6757 5.76379 13.9101 5 12 5C8.43108 5 5.48466 7.67174 5.0542 11.1237C4.98586 11.6718 4.48619 12.0607 3.93815 11.9923C3.39011 11.924 3.00123 11.4243 3.06957 10.8763ZM20.0618 12.0077C20.6099 12.076 20.9988 12.5757 20.9304 13.1237C20.3767 17.5644 16.5903 21 12 21C9.72322 21 7.60762 20.1535 5.99999 18.7559V20C5.99999 20.5523 5.55228 21 4.99999 21C4.44771 21 3.99999 20.5523 3.99999 20V16C3.99999 15.4477 4.44771 15 4.99999 15H8.99999C9.55228 15 9.99999 15.4477 9.99999 16C9.99999 16.5523 9.55228 17 8.99999 17H7.04285C8.32433 18.2362 10.0899 19 12 19C15.5689 19 18.5153 16.3283 18.9458 12.8763C19.0141 12.3282 19.5138 11.9393 20.0618 12.0077Z" fill="currentColor"></path></svg>
59                            </button>
60
61                            <button class="other-icon copy" onclick="copy(${e})" style="border: none; border-radius: 50px; padding: 8px 10px 8px 10px;background:transparent;" aria-label="Copy chat">
62                                <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${J}</span>
63                                <svg width="14" height="15" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
64                                    <path d="M12.6667 0.5H8.66667C6.82867 0.5 5.33333 1.99533 5.33333 3.83333V7.83333C5.33333 9.67133 6.82867 11.1667 8.66667 11.1667H12.6667C14.5047 11.1667 16 9.67133 16 7.83333V3.83333C16 1.99533 14.5047 0.5 12.6667 0.5ZM14.6667 7.83333C14.6667 8.936 13.7693 9.83333 12.6667 9.83333H8.66667C7.564 9.83333 6.66667 8.936 6.66667 7.83333V3.83333C6.66667 2.73067 7.564 1.83333 8.66667 1.83333H12.6667C13.7693 1.83333 14.6667 2.73067 14.6667 3.83333V7.83333ZM10.6667 13.1667C10.6667 15.0047 9.17133 16.5 7.33333 16.5H3.33333C1.49533 16.5 0 15.0047 0 13.1667V9.16667C0 7.32867 1.49533 5.83333 3.33333 5.83333C3.702 5.83333 4 6.132 4 6.5C4 6.868 3.702 7.16667 3.33333 7.16667C2.23067 7.16667 1.33333 8.064 1.33333 9.16667V13.1667C1.33333 14.2693 2.23067 15.1667 3.33333 15.1667H7.33333C8.436 15.1667 9.33333 14.2693 9.33333 13.1667C9.33333 12.7987 9.63133 12.5 10 12.5C10.3687 12.5 10.6667 12.7987 10.6667 13.1667Z" fill="currentColor" />
65                                </svg>
66                            </button>
67
68                            <button class="other-icon download" onclick="download(${e})" style="background:transparent; border: none; border-radius: 50px; padding: 8px 10px 8px 10px;">
69                                <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${G}</span>
70                                <img src="${K}" alt="download" width="14px" height="14px">
71                            </button>
72
73                            <div class="feedback-${e} d-flex gap-1">
74                                <button class="other-icon good good-response-${g}" onclick='feedback("1","${g}")' style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Good feedback">
75                                    <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${Y}</span>
76                                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md" style="cursor: pointer;">
77                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M12.1318 2.50389C12.3321 2.15338 12.7235 1.95768 13.124 2.00775L13.5778 2.06447C16.0449 2.37286 17.636 4.83353 16.9048 7.20993L16.354 8.99999H17.0722C19.7097 8.99999 21.6253 11.5079 20.9313 14.0525L19.5677 19.0525C19.0931 20.7927 17.5124 22 15.7086 22H6C4.34315 22 3 20.6568 3 19V12C3 10.3431 4.34315 8.99999 6 8.99999H8C8.25952 8.99999 8.49914 8.86094 8.6279 8.63561L12.1318 2.50389ZM10 20H15.7086C16.6105 20 17.4008 19.3964 17.6381 18.5262L19.0018 13.5262C19.3488 12.2539 18.391 11 17.0722 11H15C14.6827 11 14.3841 10.8494 14.1956 10.5941C14.0071 10.3388 13.9509 10.0092 14.0442 9.70591L14.9932 6.62175C15.3384 5.49984 14.6484 4.34036 13.5319 4.08468L10.3644 9.62789C10.0522 10.1742 9.56691 10.5859 9 10.8098V19C9 19.5523 9.44772 20 10 20ZM7 11V19C7 19.3506 7.06015 19.6872 7.17071 20H6C5.44772 20 5 19.5523 5 19V12C5 11.4477 5.44772 11 6 11H7Z" fill="currentColor"></path>
78                                    </svg>
79                                </button>
80                                <button class="other-icon fill-good-response-${g} d-none" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Good feedback fill">
81                                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md">
82                                        <path d="M12.592 2.50386C12.8047 2.13014 13.2317 1.935 13.652 2.01942C15.5627 2.40314 16.7246 4.36079 16.1516 6.23085L15.303 9L17.0142 9C19.6409 9 21.5485 11.5079 20.8574 14.0525L19.4994 19.0525C19.0267 20.7927 17.4526 22 15.6562 22H9.96721C8.869 21.9979 7.97939 21.1033 7.97939 20V9H8.31734C8.67472 9 9.0047 8.80771 9.18201 8.49613L12.592 2.50386Z" fill="currentColor"></path>
83                                        <path d="M5.98763 9C4.33761 9 3 10.3431 3 12V19C3 20.6569 4.33761 22 5.98763 22H6.52055C6.18162 21.4116 5.98763 20.7286 5.98763 20V9Z" fill="currentColor"></path>
84                                    </svg>
85                                </button>
86                            
87                                <button class="other-icon bad bad-response-${g}" onclick='feedback("0","${g}")' style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Bad feedback">
88                                    <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${z}</span>
89                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md" style="cursor: pointer;">
90                                        <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8727 21.4961C11.6725 21.8466 11.2811 22.0423 10.8805 21.9922L10.4267 21.9355C7.95958 21.6271 6.36855 19.1665 7.09975 16.7901L7.65054 15H6.93226C4.29476 15 2.37923 12.4921 3.0732 9.94753L4.43684 4.94753C4.91145 3.20728 6.49209 2 8.29589 2H18.0045C19.6614 2 21.0045 3.34315 21.0045 5V12C21.0045 13.6569 19.6614 15 18.0045 15H16.0045C15.745 15 15.5054 15.1391 15.3766 15.3644L11.8727 21.4961ZM14.0045 4H8.29589C7.39399 4 6.60367 4.60364 6.36637 5.47376L5.00273 10.4738C4.65574 11.746 5.61351 13 6.93226 13H9.00451C9.32185 13 9.62036 13.1506 9.8089 13.4059C9.99743 13.6612 10.
900536 13.9908 9.96028 14.2941L9.01131 17.3782C8.6661 18.5002 9.35608 19.6596 10.4726 19.9153L13.6401 14.3721C13.9523 13.8258 14.4376 13.4141 15.0045 13.1902V5C15.0045 4.44772 14.5568 4 14.0045 4ZM17.0045 13V5C17.0045 4.64937 16.9444 4.31278 16.8338 4H18.0045C18.5568 4 19.0045 4.44772 19.0045 5V12C19.0045 12.5523 18.5568 13 18.0045 13H17.0045Z" fill="currentColor"></path>
91                                    </svg>
92                                </button>
93
94                                <button class="other-icon fill-bad-response-${g} d-none" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Fill Bad feedback">
95                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md">
96                                        <path d="M11.4079 21.4961C11.1953 21.8698 10.7683 22.0649 10.348 21.9805C8.4373 21.5968 7.27541 19.6391 7.84844 17.7691L8.69697 14.9999L6.98577 14.9999C4.35915 14.9999 2.45151 12.492 3.14262 9.94747L4.50063 4.94747C4.97329 3.20722 6.54741 1.99994 8.34378 1.99994H14.0328C15.131 2.00207 16.0206 2.89668 16.0206 3.99994V14.9999H15.6827C15.3253 14.9999 14.9953 15.1922 14.818 15.5038L11.4079 21.4961Z" fill="currentColor"></path>
97                                        <path d="M18.0124 14.9999C19.6624 14.9999 21 13.6568 21 11.9999V4.99994C21 3.34308 19.6624 1.99994 18.0124 1.99994H17.4794C17.8184 2.58829 18.0124 3.27136 18.0124 3.99994V14.9999Z" fill="currentColor"></path>
98                                    </svg>
99                                </button>
100                            </div>
101
102                            <input type="hidden" class="chat_id chat_id-${e}" value="${g}">
103                            <input type="hidden" class="fileName fileName-${e}" value="${M||""}">
104                            <input type="hidden" class="user_id" value="">
105                        `;$(`.other-btn-${e}`).append(se)}).catch(H=>{console.error("Error:",H)}),C[0].lastElementChild.scrollIntoView({behavior:"smooth"})}else{const m=k.headers.get("Content-Type");if(m&&m.includes("application/json")){const B=await k.json();if(k.status===429){const L=document.getElementById("premiumModal");L&&L.remove();const v=fe;document.body.insertAdjacentHTML("beforeend",v),le();const x=document.getElementById("premiumModal");x.querySelectorAll(".close-modal").forEach(F=>{F.addEventListener("click",()=>{x.style.display="none"})}),x.style.display="flex",C.find(".content").html(`<strong>${Ce} <a href="${ge}" class="text-primary">${$e}</a></strong>`)}}else y(_,"danger")}}catch(b){console.error("Error during request:",b),y(_,"danger")}e++}$(".close").on("click",function(){$(".search_field").attr("placeholder","Type your Problem here").val(""),$(".close").toggleClass("d-none"),$(".qr_scan").toggleClass("d-none"),$(".hint-text").addClass("d-none")}),$(".search_field").on("focus",function(){$(".hint-text").addClass("d-none")}),$(".hint-text").on("click",function(){$(".hint-text").addClass("d-none"),$(".search_field").focus()}),$("#clickableCard").on("click",function(){$("#exampleForm").submit()}),$("#clickableCard-2").on("click",function(){$("#exampleForm-2").submit()}),$("#clickableCard-3").on("click",function(){$("#exampleForm-3").submit()}),$(".qr_scan").on("mouseleave",function(){$(".qr_code").addClass("d-none")})});async function xe(e,o){console.log("status "+e,"ID "+o);let t=e.split(",");console.log(t),t[0]==="1"?($(`.good-response-${o}`).addClass("d-none"),$(`.fill-good-response-${o}`).removeClass("d-none"),$(`.bad-response-${o}`).addClass("d-none")):t[0]=="0"&&($(`.bad-response-${o}`).addClass("d-none"),$(`.fill-bad-response-${o}`).removeClass("d-none"),$(`.good-response-${o}`).addClass("d-none"));try{const n=await fetch("/feedback",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({res:e,unique_id:o})});n.ok||console.error("Request failed:",n.statusText)}catch(n){console.error("Error:",n)}}async function ye(e,o){$(`.result-${e}`).html(""),$(`.result-${e}`).html(`<div id="loadingIndicator-${e}" class="row w-50 mx-auto justify-content-center p-4">
106                <p class="loader"></p>
107                </div>`),$(`#input-search-${e}`)[0]?.scrollIntoView({behavior:"smooth",block:"start"});let t=$(`#input-search-${e}`).text(),n=await ee(e),d=$(`.fileName-${e}`).val(),h=$("#route").val();await w(R).catch(a=>console.error("Failed to load markdown renderer:",a));try{const a=await fetch("/mathSolver",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({statement:t,fileName:d,unique_id:o,route:h})}),r=$(`.result-${e}`);if($(`#loadingIndicator-${e}`).addClass("d-none"),r.html('<div class="content"></div>'),a.ok){const s=await a.json(),l=s.message||s.content||s.result||"";if(!l){r.html("<p>No response returned.</p>");return}var c=n,p=`
108                    <button onclick="regenerate(${e},'${o}')" class="Regenerate other-icon" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Regenerate chat">
109                        <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${X}</span>
110                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md"><path d="M3.06957 10.8763C3.62331 6.43564 7.40967 3 12 3C14.2824 3 16.4028 3.85067 18.0118 5.25439V4C18.0118 3.44772 18.4595 3 19.0118 3C19.5641 3 20.0118 3.44772 20.0118 4V8C20.0118 8.55228 19.5641 9 19.0118 9H15C14.4477 9 14 8.55228 14 8C14 7.44772 14.4477 7 15 7H16.9571C15.6757 5.76379 13.9101 5 12 5C8.43108 5 5.48466 7.67174 5.0542 11.1237C4.98586 11.6718 4.48619 12.0607 3.93815 11.9923C3.39011 11.924 3.00123 11.4243 3.06957 10.8763ZM20.0618 12.0077C20.6099 12.076 20.9988 12.5757 20.9304 13.1237C20.3767 17.5644 16.5903 21 12 21C9.72322 21 7.60762 20.1535 5.99999 18.7559V20C5.99999 20.5523 5.55228 21 4.99999 21C4.44771 21 3.99999 20.5523 3.99999 20V16C3.99999 15.4477 4.44771 15 4.99999 15H8.99999C9.55228 15 9.99999 15.4477 9.99999 16C9.99999 16.5523 9.55228 17 8.99999 17H7.04285C8.32433 18.2362 10.0899 19 12 19C15.5689 19 18.5153 16.3283 18.9458 12.8763C19.0141 12.3282 19.5138 11.9393 20.0618 12.0077Z" fill="currentColor"></path></svg>
111                    </button>
112
113                    <button class="other-icon copy" onclick="copy(${e})" style="border: none; border-radius: 50px; padding: 8px 10px 8px 10px;background:transparent;" aria-label="Copy chat">
114                        <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${J}</span>
115                        <svg width="14" height="15" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
116                            <path d="M12.6667 0.5H8.66667C6.82867 0.5 5.33333 1.99533 5.33333 3.83333V7.83333C5.33333 9.67133 6.82867 11.1667 8.66667 11.1667H12.6667C14.5047 11.1667 16 9.67133 16 7.83333V3.83333C16 1.99533 14.5047 0.5 12.6667 0.5ZM14.6667 7.83333C14.6667 8.936 13.7693 9.83333 12.6667 9.83333H8.66667C7.564 9.83333 6.66667 8.936 6.66667 7.83333V3.83333C6.66667 2.73067 7.564 1.83333 8.66667 1.83333H12.6667C13.7693 1.83333 14.6667 2.73067 14.6667 3.83333V7.83333ZM10.6667 13.1667C10.6667 15.0047 9.17133 16.5 7.33333 16.5H3.33333C1.49533 16.5 0 15.0047 0 13.1667V9.16667C0 7.32867 1.49533 5.83333 3.33333 5.83333C3.702 5.83333 4 6.132 4 6.5C4 6.868 3.702 7.16667 3.33333 7.16667C2.23067 7.16667 1.33333 8.064 1.33333 9.16667V13.1667C1.33333 14.2693 2.23067 15.1667 3.33333 15.1667H7.33333C8.436 15.1667 9.33333 14.2693 9.33333 13.1667C9.33333 12.7987 9.63133 12.5 10 12.5C10.3687 12.5 10.6667 12.7987 10.6667 13.1667Z" fill="currentColor" />
117                        </svg>
118                    </button>
119
120                    <button class="other-icon download" onclick="download(${e})" style="background:transparent; border: none; border-radius: 50px; padding: 8px 10px 8px 10px;">
121                        <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${G}</span>
122                        <img src="${K}" alt="download" width="14px" height="14px">
123                    </button>
124
125                    <div class="feedback-${e} d-flex gap-1">
126                            <button class="other-icon good-response-${c}" onclick='feedback("1","${c}")' style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Good feedback">
127                                <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${Y}</span>
128                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md" style="cursor: pointer;">
129                                    <path fill-rule="evenodd" clip-rule="evenodd" d="M12.1318 2.50389C12.3321 2.15338 12.7235 1.95768 13.124 2.00775L13.5778 2.06447C16.0449 2.37286 17.636 4.83353 16.9048 7.20993L16.354 8.99999H17.0722C19.7097 8.99999 21.6253 11.5079 20.9313 14.0525L19.5677 19.0525C19.0931 20.7927 17.5124 22 15.7086 22H6C4.34315 22 3 20.6568 3 19V12C3 10.3431 4.34315 8.99999 6 8.99999H8C8.25952 8.99999 8.49914 8.86094 8.6279 8.63561L12.1318 2.50389ZM10 20H15.7086C16.6105 20 17.4008 19.3964 17.6381 18.5262L19.0018 13.5262C19.3488 12.2539 18.391 11 17.0722 11H15C14.6827 11 14.3841 10.8494 14.1956 10.5941C14.0071 10.3388 13.9509 10.0092 14.0442 9.70591L14.9932 6.62
129175C15.3384 5.49984 14.6484 4.34036 13.5319 4.08468L10.3644 9.62789C10.0522 10.1742 9.56691 10.5859 9 10.8098V19C9 19.5523 9.44772 20 10 20ZM7 11V19C7 19.3506 7.06015 19.6872 7.17071 20H6C5.44772 20 5 19.5523 5 19V12C5 11.4477 5.44772 11 6 11H7Z" fill="currentColor"></path>
130                                </svg>
131                            </button>
132                            <button class="other-icon good fill-good-response-${c} d-none" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Good feedback fill">
133                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md">
134                                    <path d="M12.592 2.50386C12.8047 2.13014 13.2317 1.935 13.652 2.01942C15.5627 2.40314 16.7246 4.36079 16.1516 6.23085L15.303 9L17.0142 9C19.6409 9 21.5485 11.5079 20.8574 14.0525L19.4994 19.0525C19.0267 20.7927 17.4526 22 15.6562 22H9.96721C8.869 21.9979 7.97939 21.1033 7.97939 20V9H8.31734C8.67472 9 9.0047 8.80771 9.18201 8.49613L12.592 2.50386Z" fill="currentColor"></path>
135                                    <path d="M5.98763 9C4.33761 9 3 10.3431 3 12V19C3 20.6569 4.33761 22 5.98763 22H6.52055C6.18162 21.4116 5.98763 20.7286 5.98763 20V9Z" fill="currentColor"></path>
136                                </svg>
137                            </button>
138                        
139                            <button class="other-icon bad bad-response-${c}" onclick='feedback("0","${c}")' style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Bad feedback">
140                                <span class="tooltip position-absolute shadow p-1 radius-5 fw-bold font-s-12 text-white">${z}</span>
141                                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md" style="cursor: pointer;">
142                                    <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8727 21.4961C11.6725 21.8466 11.2811 22.0423 10.8805 21.9922L10.4267 21.9355C7.95958 21.6271 6.36855 19.1665 7.09975 16.7901L7.65054 15H6.93226C4.29476 15 2.37923 12.4921 3.0732 9.94753L4.43684 4.94753C4.91145 3.20728 6.49209 2 8.29589 2H18.0045C19.6614 2 21.0045 3.34315 21.0045 5V12C21.0045 13.6569 19.6614 15 18.0045 15H16.0045C15.745 15 15.5054 15.1391 15.3766 15.3644L11.8727 21.4961ZM14.0045 4H8.29589C7.39399 4 6.60367 4.60364 6.36637 5.47376L5.00273 10.4738C4.65574 11.746 5.61351 13 6.93226 13H9.00451C9.32185 13 9.62036 13.1506 9.8089 13.4059C9.99743 13.6612 10.0536 13.9908 9.96028 14.2941L9.01131 17.3782C8.6661 18.5002 9.35608 19.6596 10.4726 19.9153L13.6401 14.3721C13.9523 13.8258 14.4376 13.4141 15.0045 13.1902V5C15.0045 4.44772 14.5568 4 14.0045 4ZM17.0045 13V5C17.0045 4.64937 16.9444 4.31278 16.8338 4H18.0045C18.5568 4 19.0045 4.44772 19.0045 5V12C19.0045 12.5523 18.5568 13 18.0045 13H17.0045Z" fill="currentColor"></path>
143                                </svg>
144                            </button>
145
146                            <button class="other-icon fill-bad-response-${c} d-none" style="background:transparent; border: none; border-radius: 100px; padding: 8px 10px 8px 10px;" aria-label="Fill Bad feedback">
147                                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-md">
148                                    <path d="M11.4079 21.4961C11.1953 21.8698 10.7683 22.0649 10.348 21.9805C8.4373 21.5968 7.27541 19.6391 7.84844 17.7691L8.69697 14.9999L6.98577 14.9999C4.35915 14.9999 2.45151 12.492 3.14262 9.94747L4.50063 4.94747C4.97329 3.20722 6.54741 1.99994 8.34378 1.99994H14.0328C15.131 2.00207 16.0206 2.89668 16.0206 3.99994V14.9999H15.6827C15.3253 14.9999 14.9953 15.1922 14.818 15.5038L11.4079 21.4961Z" fill="currentColor"></path>
149                                    <path d="M18.0124 14.9999C19.6624 14.9999 21 13.6568 21 11.9999V4.99994C21 3.34308 19.6624 1.99994 18.0124 1.99994H17.4794C17.8184 2.58829 18.0124 3.27136 18.0124 3.99994V14.9999Z" fill="currentColor"></path>
150                                </svg>
151                            </button>
152                    </div>
153
154                    <input type="hidden" class="chat_id chat_id-${e}" value="${n}">
155                    <input type="hidden" class="fileName fileName-${e}" value="${d||""}">
156                    <input type="hidden" class="user_id" value="">
157                `;$(`.other-btn-${e}`).html(p),r.find(".content").html(q(l)),await V(r[0]);const f=r.html(),u=await fetch(`/update/${n}`,{method:"PUT",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({statement:t,fileName:d,response_message:f})});u.ok||console.error("Failed to persist regenerated answer:",u.statusText)}else{const s=await a.json();s.status==="error"&&(y(s.message,"danger"),setTimeout(()=>{window.location.href="/"},3e3))}}catch(a){console.error("Error occurred:",a),y(_,"danger")}}async function ee(e,o=4e3,t=200){const n=Date.now()+o;let d=$(`.chat_id-${e}`).val()||$(".chat_id").val();for(;!d&&Date.now()<n;)await new Promise(h=>setTimeout(h,t)),d=$(`.chat_id-${e}`).val()||$(".chat_id").val();return d}async function ke(e,o){console.log("Editing:",e,o),$(`.edit-icon-${e}`).removeClass("d-none"),$(`.submit-${e}, .close-edit-${e}`).addClass("d-none"),$(`#input-search-${e}`).attr("contenteditable","false"),$("#statement, .input-search").on("keydown",Z),$(`.close-img-${e}`).addClass("d-none");var t=await ee(e);$(".user_id").val(),console.log(t,"chatId");const n=$(`#input-search-${e}`).text().trim(),d=$(`.fileName-${e}`).val(),h=$("#route").val();console.log(n,"statement");const c=$(`#img-${e}
157`).attr("src"),p=c&&c.trim()!==""||!!d;if(!n&&!p){typeof Swal>"u"&&await w("https://cdn.jsdelivr.net/npm/sweetalert2@11"),Swal.fire({icon:"error",title:"Please enter text in the field.",toast:!0,position:"top-end",background:"var(--main-color)",showConfirmButton:!1,timer:2e3,timerProgressBar:!0});return}$(`#section-result-${e}`).html(`
158            <div id="loadingIndicator" class="row w-50 mx-auto justify-content-center p-4">
159                <p class="loader"></p>
160            </div>
161        `),await w(R).catch(a=>console.error("Failed to load markdown renderer:",a));try{const a={statement:n,fileName:d,route:h,unique_id:o},r=await fetch("/mathSolver",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify(a)});if(console.log(r,"response",a),$("#loadingIndicator").addClass("d-none"),r.ok){const s=await r.json(),l=s.message||s.content||s.result||"";if(!l){$(`#section-result-${e}`).html("<p>No response found.</p>");return}await Le(e,l),await He(t,n,d,l,o,h)}else{const s=await r.json();s.status==="error"&&y(s.message,"danger")}}catch(a){console.error("Request failed",a),y(_,"danger")}}async function Le(e,o){const t=$(`#section-result-${e}`);t.html('<div class="content"></div>'),t.find(".content").html(q(o)),await V(t[0])}async function He(e,o,t,n,d,h){if(!e){console.warn("No chat_id available for update — falling back to /store."),await fetch("/store",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({statement:o,fileName:t,unique_id:d,route:h,response_message:n})}).catch(p=>console.error("Fallback /store also failed:",p));return}const c=await fetch(`/update/${e}`,{method:"PUT",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":$('meta[name="csrf-token"]').attr("content")},body:JSON.stringify({statement:o,fileName:t,response_message:n})});c.ok?console.log("Response updated successfully"):console.error("Failed to persist the updated response:",c.status)}window.feedback=xe;window.regenerate=ye;window.edit=ke;window.edit_icon=we;window.close_edit=be;window.close_img=ve;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.