import{s as qe,a as be,g as Ee,c as Ke}from"./mem0_proxy-D5oyS3vJ.js";import{M as _e}from"./api-D2MZ7O5A.js";import{S as Le}from"./messages-CjQo1qp0.js";import{S as s}from"./storage-pXeRtiJs.js";import{c as Ue,C as z,S as m,a as Se}from"./util_positioning-Cx352_Ay.js";qe();async function Fe(){try{const e=await Ke();chrome.runtime.sendMessage({action:Le.OPEN_DASHBOARD,url:e})}catch(e){console.warn("Unable to open Memory Platform dashboard",e)}}let X=!1,$=[];const V=new Set;let G=null,de=null,ie=!1,J={top:null,left:null},pe=!1;const Be=Ue({fetch:async function(e,t){const n=await new Promise(c=>{chrome.storage.sync.get([s.API_KEY,s.USER_ID_CAMEL,s.ACCESS_TOKEN,s.SELECTED_ORG,s.SELECTED_PROJECT,s.USER_ID,s.SIMILARITY_THRESHOLD,s.TOP_K],function(g){c(g)})}),o=n[s.API_KEY],r=n[s.ACCESS_TOKEN];if(!o&&!r)return[];const u=r?`Bearer ${r}`:`Token ${o}`,d=n[s.USER_ID_CAMEL]||n[s.USER_ID]||"chrome-extension-user",f=n[s.SIMILARITY_THRESHOLD]!==void 0?n[s.SIMILARITY_THRESHOLD]:.1,w=n[s.TOP_K]!==void 0?n[s.TOP_K]:10,h={};n[s.SELECTED_ORG]&&(h.org_id=n[s.SELECTED_ORG]),n[s.SELECTED_PROJECT]&&(h.project_id=n[s.SELECTED_PROJECT]);const i={query:e,filters:{user_id:d},rerank:!0,threshold:f,top_k:w,filter_memories:!1,source:"COGNIZ_CHROME_EXTENSION",...h},l=await fetch("https://api.mem0.ai/v2/memories/search/",{method:"POST",headers:{"Content-Type":"application/json",Authorization:u},body:JSON.stringify(i),signal:t&&t.signal});if(!l.ok)throw new Error(`API request failed with status ${l.status}`);return await l.json()},onSuccess:function(e,t){if(!X)return;const n=(t||[]).map(o=>({id:String(o.id),text:o.memory,categories:o.categories||[]}));ve(n,!1)},onError:function(){X&&ve([],!1)},minLength:3,debounceMs:75,cacheTTL:6e4});let ue=null;function ze(){const e=j();e&&(e.dataset.perplexityBackgroundHooked||(e.dataset.perplexityBackgroundHooked="true",ue||(ue=function(){const t=C(e).trim();Be.setText(t)}),e.addEventListener("input",ue),e.addEventListener("keyup",ue)))}function j(){return document.querySelector('textarea[id="ask-input"]')||document.querySelector('textarea[placeholder="Ask a follow-up…"]')||document.querySelector('div[contenteditable="true"][id="ask-input"]')||document.querySelector('div[contenteditable="true"][aria-placeholder="Ask anything…"]')||document.querySelector('textarea[placeholder="Ask anything…"]')}function C(e){if(!e)return"";if(e.tagName==="TEXTAREA")return e.value||"";if(e.contentEditable==="true"){const t=e.querySelector('p[dir="ltr"]');if(t){let n="";const o=t.childNodes;for(let r=0;r<o.length;r++){const u=o[r];u.nodeType===Node.TEXT_NODE||u.tagName==="SPAN"&&u.getAttribute("data-lexical-text")==="true"?n+=u.textContent||"":u.tagName==="BR"&&(n+=`
`)}return n}return e.textContent||""}return""}function Ye(e,t){if(console.log("setInputText called with text:",t),console.log("inputElement:",e),!e){console.log("No input element, returning");return}e.tagName==="TEXTAREA"?(console.log("Using textarea approach"),e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))):e.contentEditable==="true"&&(console.log("Using contenteditable approach for Lexical editor"),console.log("Attempting clipboard-based approach"),e.focus(),document.execCommand("selectAll",!1,""),navigator.clipboard&&navigator.clipboard.writeText?(console.log("Using modern Clipboard API"),navigator.clipboard.writeText(t).then(()=>{console.log("Text written to clipboard successfully"),setTimeout(()=>{const n=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});n.clipboardData&&n.clipboardData.setData("text/plain",t),console.log("Dispatching paste event");const o=e.dispatchEvent(n);console.log("Paste event result:",o),setTimeout(()=>{if(console.log("Content after paste event:",C(e)),!C(e).includes(t.substring(0,10))){console.log("Paste event failed, trying execCommand paste");const r=document.execCommand("paste");console.log("execCommand paste result:",r),setTimeout(()=>{console.log("Content after execCommand paste:",C(e)),C(e).includes(t.substring(0,10))||(console.log("All clipboard approaches failed, trying typing simulation"),xe(e,t))},100)}},100)},100)}).catch(n=>{console.log("Clipboard write failed:",n),xe(e,t)})):(console.log("Clipboard API not available, falling back to typing simulation"),xe(e,t)))}function xe(e,t){console.log("simulateTyping called with text:",t),console.log("inputElement:",e),e.focus(),console.log("Input element focused");const n=window.getSelection();if(n){n.selectAllChildren(e),console.log("Selected all children"),n.deleteFromDocument(),console.log("Deleted existing content"),console.log("Attempting Method 1: Selection API insertText");try{if(!n)throw new Error("No selection");const o=n.getRangeAt(0);if(o.deleteContents(),o.insertNode(document.createTextNode(t)),console.log("Method 1 succeeded - inserted text node"),console.log("Content after Method 1:",C(e)),C(e).includes(t.substring(0,10))){console.log("Method 1 worked! Content updated successfully");return}}catch(o){console.log("Method 1 failed:",o)}console.log("Attempting Method 2: execCommand with composition");try{const o=new CompositionEvent("compositionstart",{bubbles:!0,cancelable:!0,data:""});e.dispatchEvent(o);const r=new CompositionEvent("compositionupdate",{bubbles:!0,cancelable:!0,data:t});e.dispatchEvent(r);const u=new CompositionEvent("compositionend",{bubbles:!0,cancelable:!0,data:t});if(e.dispatchEvent(u),console.log("Method 2 composition events dispatched"),console.log("Content after Method 2:",C(e)),C(e).includes(t.substring(0,10))){console.log("Method 2 worked! Content updated successfully");return}}catch(o){console.log("Method 2 failed:",o)}console.log("Attempting Method 3: Direct DOM manipulation");try{let o=e.querySelector('p[dir="ltr"]');o||(o=document.createElement("p"),o.setAttribute("dir","ltr"),e.appendChild(o));const r=document.createElement("span");if(r.setAttribute("data-lexical-text","true"),r.textContent=t,o.innerHTML="",o.appendChild(r),console.log("Method 3 DOM manipulation completed"),console.log("Content after Method 3:",C(e)),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),C(e).includes(t.substring(0,10))){console.log("Method 3 worked! Content updated successfully");return}}catch(o){console.log("Method 3 failed:",o)}console.log("Attempting Method 4: Keyboard simulation");try{e.dispatchEvent(new KeyboardEvent("keydown",{key:"a",ctrlKey:!0,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keydown",{key:"Delete",bubbles:!0}));for(let o=0;o<t.length;o++){const r=t.charAt(o);e.dispatchEvent(new KeyboardEvent("keydown",{key:r,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keypress",{key:r,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{key:r,bubbles:!0}))}console.log("Method 4 keyboard simulation completed"),console.log("Content after Method 4:",C(e))}catch(o){console.log("Method 4 failed:",o)}console.log("All methods attempted. Final content:",C(e))}}async function me(){if(!await Oe()){const i=document.querySelector(".mem0-button-wrapper");i&&i.remove();return}if(z&&z.mountOnEditorFocus){try{document.getElementById("mem0-icon-button")||z.resolveCachedAnchor({learnKey:location.host+":"+location.pathname},null,1440*60*1e3).then(function(i){if(!i||!i.el)return;let l=z.createShadowRootHost("mem0-root"),c=l.host,g=l.shadow;c.id="mem0-icon-button";const E=typeof m<"u"&&m.perplexity?m.perplexity:null;let P=i.placement||E&&E.placement||{strategy:"inline",where:"beforeend",inlineAlign:"end"};z.applyPlacement({container:c,anchor:i.el,placement:P});let A=document.createElement("style");A.textContent=`
              :host { position: relative; }
              .mem0-btn { all: initial; cursor: pointer; display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; border-radius:50%; }
              .mem0-btn img { width:18px; height:18px; border-radius:50%; }
              .dot { position:absolute; top:-2px; right:-2px; width:8px; height:8px; background:#80DDA2; border-radius:50%; border:2px solid #1C1C1E; display:none; }
              :host([data-has-text="1"]) .dot { display:block; }
            `;let k=document.createElement("button");k.className="mem0-btn";let q=document.createElement("img");q.src=chrome.runtime.getURL("icons/icon48.png");let B=document.createElement("div");B.className="dot",k.appendChild(q),g.append(A,k,B),k.addEventListener("click",function(){re()}),typeof Y=="function"&&setTimeout(Y,0);try{const _=typeof m<"u"&&m.perplexity?m.perplexity:null;let y=_&&_.modelButtonSelector,x=_&&_.sendButtonSelector,O=y?document.querySelector(y):null,R=O||(x?document.querySelector(x):null);if(R){let v=R.parentElement||R,L=v,Q=0;for(;L&&Q<5;){let U=getComputedStyle(L);if(U.display==="flex"&&U.flexDirection!=="column"){v=L;break}L=L.parentElement,Q++}if(O?v.insertBefore(c,R.nextSibling):(c.parentElement!==v||c!==v.firstElementChild)&&v.insertBefore(c,v.firstElementChild||R),c.style.marginLeft="0",c.style.marginRight="0",z&&z.saveAnchorHint)try{z.saveAnchorHint({learnKey:location.host+":"+location.pathname},v,{strategy:"inline",where:"beforeend",inlineAlign:"end"},!0)}catch{}}}catch{}})}catch{}z.mountOnEditorFocus({existingHostSelector:"#mem0-icon-button, .mem0-root",editorSelector:typeof m<"u"&&m.perplexity&&m.perplexity.editorSelector?m.perplexity.editorSelector:'textarea, [contenteditable], input[type="text"]',deriveAnchor:typeof m<"u"&&m.perplexity&&typeof m.perplexity.deriveAnchor=="function"?m.perplexity.deriveAnchor:function(i){return i.closest("form")||i.parentElement},placement:typeof m<"u"&&m.perplexity&&m.perplexity.placement?m.perplexity.placement:{strategy:"inline",where:"beforeend",inlineAlign:"end"},render:function(i,l){l.id="mem0-icon-button";let c=document.createElement("style");c.textContent=`
          :host { position: relative; }
          .mem0-btn { all: initial; cursor: pointer; display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; border-radius:50%; }
          .mem0-btn img { width:18px; height:18px; border-radius:50%; }
          .dot { position:absolute; top:-2px; right:-2px; width:8px; height:8px; background:#80DDA2; border-radius:50%; border:2px solid #1C1C1E; display:none; }
          :host([data-has-text="1"]) .dot { display:block; }
        `;let g=document.createElement("button");g.className="mem0-btn";let E=document.createElement("img");E.src=chrome.runtime.getURL("icons/icon48.png");let P=document.createElement("div");P.className="dot",g.appendChild(E),i.append(c,g,P),g.addEventListener("click",function(){re()}),typeof Y=="function"&&setTimeout(Y,0);try{Array.from(document.querySelectorAll("#mem0-icon-button, .mem0-root")).filter(function(y){return y!==l}).forEach(function(y){try{y.remove()}catch{}});let A=typeof m<"u"&&m.perplexity?m.perplexity:null,k=A&&A.modelButtonSelector,q=A&&A.sendButtonSelector,_=(k?document.querySelector(k):null)||(q?document.querySelector(q):null);if(_){let y=_.parentElement||_,x=y,O=0;for(;x&&O<5;){let L=getComputedStyle(x);if(L.display==="flex"&&L.flexDirection!=="column"){y=x;break}x=x.parentElement,O++}let R=y.firstElementChild||_;(l.parentElement!==y||l!==R)&&y.insertBefore(l,R);let v=getComputedStyle(y).gap;(!v||v==="normal")&&(v="8px"),l.style.marginLeft=v,l.style.marginRight="0"}}catch{}},fallback:function(){let i=typeof m<"u"&&m.perplexity?m.perplexity:null;return z.mountResilient({anchors:[{find:function(){let l=i&&i.editorSelector||'textarea, [contenteditable], input[type="text"]',c=document.querySelector(l);if(!c)return null;try{return i&&typeof i.deriveAnchor=="function"?i.deriveAnchor(c):c.closest("form")||c.parentElement}catch{return c.closest("form")||c.parentElement}}}],placement:i&&i.placement||{strategy:"inline",where:"beforeend",inlineAlign:"end"},enableFloatingFallback:!0,render:function(l,c){c.id="mem0-icon-button";let g=document.createElement("style");g.textContent=`
              :host { position: relative; }
              .mem0-btn { all: initial; cursor: pointer; display:inline-flex; align-items:center; justify-content:center; width:32px; height:32px; border-radius:50%; }
              .mem0-btn img { width:18px; height:18px; border-radius:50%; }
              .dot { position:absolute; top:-2px; right:-2px; width:8px; height:8px; background:#80DDA2; border-radius:50%; border:2px solid #1C1C1E; display:none; }
              :host([data-has-text="1"]) .dot { display:block; }
            `;let E=document.createElement("button");E.className="mem0-btn";let P=document.createElement("img");P.src=chrome.runtime.getURL("icons/icon48.png");let A=document.createElement("div");A.className="dot",E.appendChild(P),l.append(g,E,A),E.addEventListener("click",function(){re()}),typeof Y=="function"&&setTimeout(Y,0);try{Array.from(document.querySelectorAll("#mem0-icon-button, .mem0-root")).filter(function(x){return x!==c}).forEach(function(x){try{x.remove()}catch{}});let k=typeof m<"u"&&m.perplexity?m.perplexity:null,q=k&&k.modelButtonSelector,B=k&&k.sendButtonSelector,_=q?document.querySelector(q):null,y=_||(B?document.querySelector(B):null);if(y){let x=y.parentElement||y,O=x,R=0;for(;O&&R<5;){let L=getComputedStyle(O);if(L.display==="flex"&&L.flexDirection!=="column"){x=O;break}O=O.parentElement,R++}_?x.insertBefore(c,y.nextSibling):(c.parentElement!==x||c.nextSibling!==y)&&x.insertBefore(c,y);let v=getComputedStyle(x).gap;(!v||v==="normal")&&(v="8px"),c.style.marginLeft=v,c.style.marginRight="0"}}catch{}}})}});return}const t=document.createElement("div");t.className="mem0-button-wrapper",t.style.cssText=`
    position: relative;
    display: inline-block;
  `;const n=document.createElement("div");n.className="mem0-tooltip",n.style.cssText=`
    visibility: hidden;
    background-color: #27272A;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 6px 10px;
    position: absolute;
    z-index: 10000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid #3B3B3F;
  `,n.textContent="Add memories to your prompt";const o=document.createElement("div");o.style.cssText=`
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #27272A transparent transparent transparent;
  `,n.appendChild(o),t.appendChild(n);const r=document.createElement("button");r.className="mem0-claude-btn focus-visible:bg-offsetPlus dark:focus-visible:bg-offsetPlusDark hover:bg-offsetPlus text-textOff dark:text-textOffDark hover:text-textMain dark:hover:bg-offsetPlusDark dark:hover:text-textMainDark font-sans focus:outline-none outline-none outline-transparent transition duration-300 ease-out font-sans select-none items-center relative group/button justify-center text-center items-center rounded-lg cursor-pointer active:scale-[0.97] active:duration-150 active:ease-outExpo origin-center whitespace-nowrap inline-flex text-sm h-8 aspect-[9/8]",r.setAttribute("aria-label","Mem0 AI"),r.setAttribute("type","button"),r.style.position="relative";const u=document.createElement("div");if(u.id="mem0-notification-dot",u.style.cssText=`
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background-color: rgb(128, 221, 162);
    border-radius: 50%;
    border: 2px solid #18181B;
    display: none;
    z-index: 1001;
    pointer-events: none;
  `,!document.getElementById("notification-dot-animation")){const i=document.createElement("style");i.id="notification-dot-animation",i.innerHTML=`
      @keyframes popIn {
        0% { transform: scale(0); }
        50% { transform: scale(1.2); }
        100% { transform: scale(1); }
      }
      
      #mem0-notification-dot.active {
        display: block !important;
        animation: popIn 0.3s ease-out forwards;
      }
    `,document.head.appendChild(i)}r.innerHTML=`
    <div class="flex items-center min-w-0 font-medium gap-1.5 justify-center">
      <div class="flex shrink-0 items-center justify-center size-4">
        <img src="${chrome.runtime.getURL("icons/icon48.png")}" alt="Mem0 AI" width="14" height="14" />
      </div>
    </div>
  `,r.appendChild(u);let d=null,f=null;try{try{let i=typeof m<"u"&&m.perplexity?m.perplexity:null,l=i&&i.modelButtonSelector;l&&(f=document.querySelector(l))}catch{}if(d=document.querySelector("div.bg-raised.dark\\:bg-offset.flex.items-center.justify-self-end.rounded-full"),d||(d=document.querySelector("div.bg-raised.flex.items-center.rounded-full")),d||(d=document.querySelector('div[class*="bg-raised"][class*="items-center"][class*="rounded-full"]')),!d){const i=document.querySelector('button[aria-label="Submit"]');if(i&&i.parentElement){const l=i.parentElement.previousElementSibling;if(l&&l.querySelectorAll("button").length>0&&(d=l),!d){const c=i.parentElement.querySelectorAll("div");for(const g of Array.from(c))if(g.querySelectorAll("button").length>=2){d=g;break}}}}}catch{}if(f&&f.parentElement){let i=f.parentElement;try{let l=i,c=0;for(;l&&c<5;){let g=getComputedStyle(l);if(g.display==="flex"&&g.flexDirection!=="column"){i=l;break}l=l.parentElement,c++}}catch{}i.insertBefore(t,i.firstElementChild)}else d&&d.insertBefore(t,d.firstChild);t.appendChild(r);let w=null;const h=j();if(h){let i=h;for(;i&&i!==document.body;){if(window.getComputedStyle(i).display==="flex"&&i.contains(h)){w=i;break}i=i.parentElement}w||(w=h.parentElement)}if(!w){setTimeout(me,500);return}w.insertBefore(t,w.firstChild),r.style.width="32px",r.style.height="32px",r.style.borderRadius="8px",r.style.background="transparent",r.style.display="inline-flex",r.style.alignItems="center",r.style.justifyContent="center",r.style.marginRight="8px",t.style.display="inline-flex",t.style.alignItems="center",t.style.justifyContent="center",t.addEventListener("mouseenter",()=>{n.style.visibility="visible",n.style.opacity="1"}),t.addEventListener("mouseleave",()=>{n.style.visibility="hidden",n.style.opacity="0"}),r.addEventListener("click",()=>{const i=j();i&&C(i).trim()?re("mem0-icon-button"):chrome.storage.sync.get([s.API_KEY,s.USER_ID_CAMEL,s.ACCESS_TOKEN],function(l){if(!l.apiKey&&!l.access_token)Ie();else{const c=n.textContent;n.textContent="Add some text to find memories",n.style.visibility="visible",n.style.opacity="1",setTimeout(()=>{n.textContent=c,t.matches(":hover")||(n.style.visibility="hidden",n.style.opacity="0")},1500)}})}),Y()}function Y(){const e=j(),t=document.getElementById("mem0-icon-button");if(!e||!t){setTimeout(Y,500);return}const n=()=>{const r=(C(e)||"").trim()!=="";try{t.setAttribute("data-has-text",r?"1":"0")}catch{}};try{new MutationObserver(n).observe(e,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}catch{}e.dataset.perplexityApplyStateHooked||(e.dataset.perplexityApplyStateHooked="true",e.addEventListener("input",n),e.addEventListener("keyup",n),e.addEventListener("focus",n)),n(),setTimeout(n,300)}function ve(e,t=!1,n=null){X&&G&&document.body.removeChild(G),X=!0;let o=0;const r=447;let u=400,d=3,f,w;if(J.top!==null&&J.left!==null)f=J.top,w=J.left;else if(n==="mem0-icon-button"){const a=document.querySelector("#mem0-icon-button")||document.querySelector(".mem0-claude-btn");if(a){const p=a.getBoundingClientRect(),T=window.innerHeight;w=Math.max(10,p.left-r-10),f=p.top+p.height/2-u/2,f=Math.max(10,Math.min(f,T-u-10))}else h()}else h();function h(){let a=document.querySelector("#mem0-icon-button")||document.querySelector(".mem0-claude-btn");if(!a)try{if(a=document.querySelector("div.bg-raised.dark\\:bg-offset.flex.items-center.justify-self-end.rounded-full")||document.querySelector("div.bg-raised.flex.items-center.rounded-full")||document.querySelector('div[class*="bg-raised"][class*="items-center"][class*="rounded-full"]'),!a){const M=document.querySelector('button[aria-label="Submit"]');if(M&&M.parentElement){const S=M.parentElement.previousElementSibling;S&&S.querySelectorAll("button").length>0&&(a=S)}}}catch{}if(!a){console.error("Mem0 anchor not found for positioning"),w=Math.max(10,(window.innerWidth-r)/2),f=Math.max(10,(window.innerHeight-u)/2);return}const p=a.getBoundingClientRect(),T=window.innerHeight;w=Math.max(10,p.left-r-10),f=p.top+p.height/2-u/2,f=Math.max(10,Math.min(f,T-u-10))}const i=document.createElement("div");i.id="mem0-modal-overlay",i.style.cssText=`
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: flex;
    z-index: 10000;
    pointer-events: auto;
  `,G=i,i.addEventListener("click",a=>{a.target===i&&he()});const l=document.createElement("div");l.style.cssText=`
    background-color: #1C1C1E;
    border-radius: 12px;
    width: ${r}px;
    height: ${u}px;
    display: flex;
    flex-direction: column;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: absolute;
    top: ${f}px;
    left: ${w}px;
    pointer-events: auto;
    border: 1px solid #27272A;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
  `;const c=document.createElement("div");c.style.cssText=`
    display: flex;
    align-items: center;
    padding: 10px 16px;
    justify-content: space-between;
    background-color: #232325;
    flex-shrink: 0;
    cursor: move;
    user-select: none;
  `;const g=document.createElement("div");g.style.cssText=`
    display: flex;
    flex-direction: row;
    align-items: center;
  `;const E=document.createElement("img");E.src=chrome.runtime.getURL("icons/icon48.png"),E.style.cssText=`
    width: 26px;
    height: 26px;
    border-radius: 50%;
  `;const P=document.createElement("div");P.textContent="Cogniz Memory",P.style.cssText=`
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
    margin-left: 8px;
  `;const A=document.createElement("div");A.style.cssText=`
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  `;const k=document.createElement("button");k.style.cssText=`
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 5px 16px;
    gap: 8px;
    background-color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: black;
  `,k.textContent="Add to Prompt";const q=document.createElement("span");q.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
    <path d="M5 12h14M12 5l7 7-7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>
`,k.appendChild(q),k.addEventListener("click",()=>{const a=e.filter(p=>!V.has(String(p.id))).map(p=>(V.add(String(p.id)),String(p.text||"")));be("memory_injection",{provider:"perplexity",source:"COGNIZ_CHROME_EXTENSION",browser:Ee(),injected_all:!0,memory_count:a.length}),$.push(...a),$.length>0?(Te(),he()):V.size>0&&he();for(let p=e.length-1;p>=0;p--)V.has(String(e[p]?.id))&&e.splice(p,1)});const B=document.createElement("button");B.style.cssText=`
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
  `,B.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" xmlns="http://www.w3.org/2000/svg">
    <path d="M12 15a3 3 0 100-6 3 3 0 000 6z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
    <path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>`,B.addEventListener("click",()=>{G&&document.body.contains(G)&&(document.body.removeChild(G),X=!1,G=null),chrome.runtime.sendMessage({action:Le.SIDEBAR_SETTINGS})}),B.addEventListener("mouseenter",()=>{B.style.opacity="1"}),B.addEventListener("mouseleave",()=>{B.style.opacity="0.6"}),g.appendChild(E),g.appendChild(P),A.appendChild(k),A.appendChild(B),c.appendChild(g),c.appendChild(A);let _=0,y=0,x=0,O=0;c.addEventListener("mousedown",a=>{const p=a.target;if(p&&(p===c||c.contains(p))){if(p.tagName==="BUTTON"||p.closest("button"))return;pe=!0,_=a.clientX,y=a.clientY;const T=l.getBoundingClientRect();x=T.left,O=T.top,l.style.transition="none",l.style.opacity="1",document.addEventListener("mousemove",R),document.addEventListener("mouseup",v),a.preventDefault()}});function R(a){if(!pe)return;const p=a.clientX-_,T=a.clientY-y;let M=x+p,S=O+T;const N=window.innerWidth-r,b=window.innerHeight-u;M=Math.max(0,Math.min(M,N)),S=Math.max(0,Math.min(S,b)),l.style.left=M+"px",l.style.top=S+"px",J.left=M,J.top=S}function v(){pe&&(pe=!1,l.style.transition="",l.style.opacity="1",document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",v))}const L=document.createElement("div"),Q=u-130;L.style.cssText=`
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    gap: 12px;
    overflow: hidden;
    flex: 1;
    height: ${Q}px;
  `;const U=document.createElement("div");U.style.cssText=`
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
    margin-top: 16px;
    flex-shrink: 0;
  `,t?U.textContent="Loading Relevant Memories...":U.textContent=`${e.length} Relevant Memories`;const Ne=Q-40,K=document.createElement("div");K.style.cssText=`
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    max-height: ${Ne}px;
    padding-right: 8px;
    margin-right: -8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  `,K.style.cssText+="::-webkit-scrollbar { display: none; }";let ee=null;const Pe=document.createElement("div");Pe.style.cssText=`
    display: flex;
    gap: 8px;
    padding: 0 8px;
  `;function He(){K.innerHTML="";for(let a=0;a<d;a++){const p=document.createElement("div");p.style.cssText=`
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        padding: 12px;
        background-color: #27272A;
        border-radius: 8px;
        height: 72px;
        flex-shrink: 0;
        animation: pulse 1.5s infinite ease-in-out;
      `;const T=document.createElement("div");T.style.cssText=`
        background-color: #383838;
        border-radius: 4px;
        height: 14px;
        width: 85%;
        margin-bottom: 8px;
      `;const M=document.createElement("div");M.style.cssText=`
        background-color: #383838;
        border-radius: 4px;
        height: 14px;
        width: 65%;
      `;const S=document.createElement("div");S.style.cssText=`
        display: flex;
        gap: 4px;
        margin-left: 10px;
      `;const N=document.createElement("div");N.style.cssText=`
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #383838;
      `;const b=document.createElement("div");b.style.cssText=`
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #383838;
      `,S.appendChild(N),S.appendChild(b);const H=document.createElement("div");H.style.cssText=`
        display: flex;
        flex-direction: column;
        flex-grow: 1;
      `,H.appendChild(T),H.appendChild(M),p.appendChild(H),p.appendChild(S),K.appendChild(p)}if(!document.getElementById("skeleton-animation")){const a=document.createElement("style");a.id="skeleton-animation",a.innerHTML=`
        @keyframes pulse {
          0% { opacity: 0.6; }
          50% { opacity: 0.8; }
          100% { opacity: 0.6; }
        }
      `,document.head.appendChild(a)}}function W(){if(K.innerHTML="",t){He();return}if(e.length===0){Ce(),ge(0,0);return}const a=Math.min(d,e.length),p=Math.ceil(e.length/a),T=Math.floor(o/a)+1;o>=e.length&&(o=0),ge(T,p);let M=0,S=o;for(;M<a&&S<e.length;){const N=e[S];if(!V.has(String(N.id))){N.id||(N.id=`memory-${Date.now()}-${S}`);const b=document.createElement("div");b.style.cssText=`
          display: flex;
          flex-direction: row;
          align-items: flex-start;
          justify-content: space-between;
          padding: 12px; 
          background-color: #27272A;
          border-radius: 8px;
          cursor: pointer;
          transition: all 0.2s ease;
          min-height: 72px; 
          max-height: 72px; 
          overflow: hidden;
          flex-shrink: 0;
        `;const H=document.createElement("div");H.style.cssText=`
          font-size: 14px;
          line-height: 1.5;
          color: #D4D4D8;
          flex-grow: 1;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          transition: all 0.2s ease;
          height: 42px; /* Height for 2 lines of text */
        `,H.textContent=String(N.text||"");const se=document.createElement("div");se.style.cssText=`
          display: flex;
          gap: 4px;
          margin-left: 10px;
          flex-shrink: 0;
        `;const ae=document.createElement("button");ae.style.cssText=`
          border: none;
          cursor: pointer;
          padding: 4px;
          background:rgb(66, 66, 69);
          color:rgb(199, 199, 201);
          border-radius: 100%;
          transition: all 0.2s ease;
        `,ae.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M12 5v14M5 12h14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
        </svg>`,ae.addEventListener("click",ne=>{ne.stopPropagation(),be("memory_injection",{provider:"perplexity",source:"COGNIZ_CHROME_EXTENSION",browser:Ee(),injected_all:!1,memory_id:N.id}),V.add(String(N.id)),$.push(String(N.text||"")),Te();const oe=e.findIndex(ye=>ye.id===N.id);oe!==-1&&(e.splice(oe,1),o>0&&o>=e.length&&(o=Math.max(0,o-d)),U.textContent=`${e.length} Relevant Memories`,W())});const ce=document.createElement("button");ce.style.cssText=`
          background: none;
          border: none;
          cursor: pointer;
          padding: 4px;
          color: #A1A1AA;
        `,ce.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
          <circle cx="12" cy="12" r="2"/>
          <circle cx="12" cy="5" r="2"/>
          <circle cx="12" cy="19" r="2"/>
        </svg>`;let te=!1;const Z=document.createElement("button");Z.style.cssText=`
          display: none;
          align-items: center;
          gap: 6px;
          background:rgb(66, 66, 69);
          color:rgb(199, 199, 201);
          border-radius: 8px;
          padding: 2px 4px;
          border: none;
          cursor: pointer;
          font-size: 13px;
          margin-top: 12px;
          width: fit-content;
        `,Z.innerHTML=`
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
          Remove
        `;const F=document.createElement("div");F.style.cssText=`
          display: flex;
          flex-direction: column;
          flex-grow: 1;
        `,F.appendChild(H),F.appendChild(Z);const je=()=>{ee&&ee!==b&&ee.dispatchEvent(new Event("collapse")),te=!0,H.style.webkitLineClamp="unset",H.style.height="auto",F.style.overflowY="auto",F.style.maxHeight="240px",F.style.scrollbarWidth="none",F.style.msOverflowStyle="none",F.style.cssText+="::-webkit-scrollbar { display: none; }",b.style.backgroundColor="#1C1C1E",b.style.maxHeight="300px",b.style.overflow="hidden",Z.style.display="flex",ee=b,K.scrollTop=b.offsetTop-K.offsetTop},ke=()=>{te=!1,H.style.webkitLineClamp="2",H.style.height="42px",F.style.overflowY="visible",b.style.backgroundColor="#27272A",b.style.maxHeight="72px",b.style.overflow="hidden",Z.style.display="none",ee=null};b.addEventListener("collapse",ke),ce.addEventListener("click",ne=>{ne.stopPropagation(),te?ke():je()}),Z.addEventListener("click",ne=>{ne.stopPropagation();const oe=e.findIndex(ye=>ye.id===N.id);oe!==-1&&(e.splice(oe,1),o>0&&o>=e.length&&(o=Math.max(0,o-d)),U.textContent=`${e.length} Relevant Memories`,W())}),se.appendChild(ae),se.appendChild(ce),b.appendChild(F),b.appendChild(se),K.appendChild(b),b.addEventListener("mouseenter",()=>{b.style.backgroundColor=te?"#18181B":"#323232"}),b.addEventListener("mouseleave",()=>{b.style.backgroundColor=te?"#1C1C1E":"#27272A"}),M++}S++}M===0&&e.length>0?(o=0,W()):M===0&&Ce()}function Ce(){K.innerHTML="";const a=document.createElement("div");a.style.cssText=`
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 32px 16px;
      text-align: center;
      flex: 1;
      min-height: 200px;
    `;const p=document.createElement("div");p.innerHTML=`<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="#71717A" xmlns="http://www.w3.org/2000/svg">
      <path d="M9 3H5a2 2 0 00-2 2v4m6-6h10a2 2 0 012 2v10a2 2 0 01-2 2h-4M3 21h4a2 2 0 002-2v-4m-6 6V9m18 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
    </svg>`,p.style.marginBottom="16px";const T=document.createElement("div");T.textContent="No relevant memories found",T.style.cssText=`
      color: #71717A;
      font-size: 14px;
      font-weight: 500;
    `,a.appendChild(p),a.appendChild(T),K.appendChild(a)}const le=document.createElement("div");le.style.cssText=`
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 10px;
    border-top: none;
    flex-shrink: 0;
  `;const D=document.createElement("button");D.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M15 19l-7-7 7-7" stroke="#A1A1AA" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>`,D.style.cssText=`
    background: #27272A;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
  `;const I=document.createElement("button");I.innerHTML=`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M9 5l7 7-7 7" stroke="#A1A1AA" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>`,I.style.cssText=D.style.cssText;function ge(a,p){if(e.length===0||p===0){D.disabled=!0,D.style.opacity="0.5",D.style.cursor="not-allowed",I.disabled=!0,I.style.opacity="0.5",I.style.cursor="not-allowed";return}t||a<=1?(D.disabled=!0,D.style.opacity="0.5",D.style.cursor="not-allowed"):(D.disabled=!1,D.style.opacity="1",D.style.cursor="pointer"),t||a>=p?(I.disabled=!0,I.style.opacity="0.5",I.style.cursor="not-allowed"):(I.disabled=!1,I.style.opacity="1",I.style.cursor="pointer")}D.addEventListener("click",()=>{!t&&o>0&&(o-=d,W())}),I.addEventListener("click",()=>{!t&&o<e.length-d&&(o+=d,W())}),[D,I].forEach(a=>{a.addEventListener("mouseenter",()=>{a.disabled||(a.style.backgroundColor="#323232")}),a.addEventListener("mouseleave",()=>{a.disabled||(a.style.backgroundColor="#27272A")})}),L.appendChild(U),L.appendChild(K),l.appendChild(c),l.appendChild(L),t||(l.appendChild(le),le.appendChild(D),le.appendChild(I)),i.appendChild(l),document.body.appendChild(i),W(),ge(1,Math.ceil(e.length/d))}function Te(){const e=j();if(!e||$.length===0)return;let t=C(e);const n=`

`+Se.memory_marker_prefix;t.includes(n)&&(t=t.substring(0,t.indexOf(n)).trim());let o=`

`+Se.memory_header_text+`
`;$.forEach((r,u)=>{o+=`- ${r}`,u<$.length-1&&(o+=`
`)}),we(e,t+o)}function Oe(){return new Promise(e=>{chrome.storage.sync.get([s.MEMORY_ENABLED],function(t){e(t.memory_enabled!==!1)})})}function Me(){const e=j();if(!e)return;let t=C(e);!t||t.trim()===""||((t||"").includes("Here is some of my memories to help")&&(t=((t||"").split("Here is some of my memories to help")[0]||"").trim()),!(!t||t.trim()==="")&&chrome.storage.sync.get([s.API_KEY,s.USER_ID_CAMEL,s.ACCESS_TOKEN,s.MEMORY_ENABLED,s.SELECTED_ORG,s.SELECTED_PROJECT,s.USER_ID],function(n){if(n.memory_enabled===!1||!n.apiKey&&!n.access_token)return;const o=n.access_token?`Bearer ${n.access_token}`:`Token ${n.apiKey}`,r=n.userId||n.user_id||"chrome-extension-user",u={};n.selected_org&&(u.org_id=n.selected_org),n.selected_project&&(u.project_id=n.selected_project),fetch("https://api.mem0.ai/v1/memories/",{method:"POST",headers:{"Content-Type":"application/json",Authorization:o},body:JSON.stringify({messages:[{role:_e.User,content:t}],user_id:r,infer:!0,metadata:{provider:"Perplexity"},source:"COGNIZ_CHROME_EXTENSION",...u})}).catch(d=>{console.error("Error saving memory:",d)})}))}function fe(){const e=document.querySelector('button[aria-label="Submit"]');if(!e){setTimeout(fe,500);return}if(e.dataset.mem0Listener)return;e.dataset.mem0Listener="true",e.addEventListener("click",()=>{Me(),setTimeout(()=>{$=[],console.log("Message sent, memories cleared")},100)});const t=j();t&&!t.dataset.mem0EnterListener&&(t.dataset.mem0EnterListener="true",t.addEventListener("keydown",n=>{n.key==="Enter"&&!n.shiftKey&&(Me(),setTimeout(()=>{$=[],console.log("Message sent via Enter key, memories cleared")},100))})),De()}function De(){de&&de.disconnect();const e=document.querySelector("main");if(!e){setTimeout(De,1e3);return}de=new MutationObserver(t=>{for(const n of t)n.type==="childList"&&n.addedNodes.length>0&&Array.from(n.addedNodes).some(r=>r.nodeType===Node.ELEMENT_NODE?r.classList.contains("answer-container"):!1)&&($=[],console.log("New answer detected, memories cleared"))}),de.observe(e,{childList:!0,subtree:!0})}function Re(){if(!j()){setTimeout(Re,500);return}}async function $e(e,t=!1,n=null){const o=j();if(!o){console.error("No input textarea found");return}const r=e||C(o).trim(),u=r;if(!r){console.error("No input message found");return}if(!ie){ie=!0;try{const d=await new Promise(E=>{chrome.storage.sync.get([s.API_KEY,s.USER_ID_CAMEL,s.ACCESS_TOKEN,s.MEMORY_ENABLED,s.SELECTED_ORG,s.SELECTED_PROJECT,s.USER_ID,s.SIMILARITY_THRESHOLD,s.TOP_K],function(P){E(P)})}),f=d[s.API_KEY],w=d[s.USER_ID_CAMEL]||d[s.USER_ID]||"chrome-extension-user",h=d[s.ACCESS_TOKEN],i=d[s.MEMORY_ENABLED]!==!1,l={};if(d[s.SELECTED_ORG]&&(l.org_id=d[s.SELECTED_ORG]),d[s.SELECTED_PROJECT]&&(l.project_id=d[s.SELECTED_PROJECT]),!f&&!h){console.error("No API Key or Access Token found"),ie=!1,Ie();return}if(!i){console.log("Memory is disabled. Skipping API calls."),t&&Ae(),ie=!1;return}ve([],!0,n),be("modal_clicked",{provider:"perplexity",source:"COGNIZ_CHROME_EXTENSION",browser:Ee()});const c=h?`Bearer ${h}`:`Token ${f}`,g=[{role:_e.User,content:r}];Be.runImmediate(r),t&&!X&&Ae(),we(o,u),fetch("https://api.mem0.ai/v1/memories/",{method:"POST",headers:{"Content-Type":"application/json",Authorization:c},body:JSON.stringify({messages:g,user_id:w,infer:!0,source:"COGNIZ_CHROME_EXTENSION",metadata:{provider:"Perplexity"},...l})}).then(E=>{E.ok||console.error(`Failed to add memory: ${E.status}`)}).catch(E=>{console.error("Error adding memory:",E)})}catch(d){console.error("Error:",d);const f=j();f&&u&&we(f,u),he()}finally{ie=!1}}}function re(e=null){try{const t=j(),n=t?(C(t)||"").trim():"";$e(n,!1,e)}catch{}}function we(e,t){e&&Ye(e,t)}function Ae(){setTimeout(()=>{const e=document.querySelector('button[aria-label="Submit"]');e?(e.click(),setTimeout(()=>{$=[],console.log("Message sent via clickSendButtonWithDelay, memories cleared")},100)):console.error("Send button not found")},0)}function Ge(){Oe().then(e=>{if(!e){const n=document.querySelector(".mem0-button-wrapper");n&&n.remove();return}Re();try{ze()}catch{}me(),fe(),new MutationObserver(()=>{me(),fe(),Y()}).observe(document.body,{childList:!0,subtree:!0}),setInterval(()=>{me(),fe(),Y()},3e3),document.addEventListener("keydown",function(n){if(n.ctrlKey&&n.key==="m"){n.preventDefault();const o=j();o&&C(o).trim()&&re("mem0-icon-button")}})})}Ge();function Ie(){const e=document.querySelector("#mem0-login-popup");e&&e.remove();const t=document.createElement("div");t.id="mem0-login-popup",t.style.cssText=`
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
  `;const n=document.createElement("div");n.style.cssText=`
    background-color: #1C1C1E;
    border-radius: 12px;
    width: 320px;
    padding: 24px;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
  `;const o=document.createElement("button");o.style.cssText=`
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #A1A1AA;
    font-size: 16px;
    cursor: pointer;
  `,o.innerHTML="&times;",o.addEventListener("click",()=>{document.body.removeChild(t)});const r=document.createElement("div");r.style.cssText=`
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
  `;const u=document.createElement("img");u.src=chrome.runtime.getURL("icons/icon48.png"),u.style.cssText=`
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 12px;
  `;const d=document.createElement("img");d.src=chrome.runtime.getURL("icons/icon128.png"),d.style.cssText=`
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 12px;
  `;const f=document.createElement("h2");f.textContent="Sign in to Cogniz",f.style.cssText=`
    margin: 0;
    font-size: 18px;
    font-weight: 600;
  `,r.appendChild(f);const w=document.createElement("p");w.textContent="Please sign in to access your memories and enhance your conversations!",w.style.cssText=`
    margin-bottom: 24px;
    color: #D4D4D8;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
  `;const h=document.createElement("button");h.style.cssText=`
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background-color: white;
    color: black;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
  `;const i=document.createElement("span");i.textContent="Sign in with Cogniz",h.appendChild(d),h.appendChild(i),h.addEventListener("mouseenter",()=>{h.style.backgroundColor="#f5f5f5"}),h.addEventListener("mouseleave",()=>{h.style.backgroundColor="white"}),h.addEventListener("click",()=>{Fe(),document.body.removeChild(t)}),n.appendChild(o),n.appendChild(r),n.appendChild(w),n.appendChild(h),t.appendChild(n),t.addEventListener("click",l=>{l.target===t&&document.body.removeChild(t)}),document.body.appendChild(t)}function he(){X&&G&&(document.body.removeChild(G),X=!1,J={top:null,left:null})}
