var i=new Set(["the","a","an","to","in","of","and","as","is","are","for","this","after","over","amid","from","on","at","new"]),c=null,a=null;async function l(){return await tf.setBackend("cpu"),await tf.ready(),c=await(await fetch(chrome.runtime.getURL("model/headline/vocab.json"))).json(),tf.loadLayersModel(chrome.runtime.getURL("model/headline/model.json"))}function s(){return a||(a=l().catch(e=>{throw a=null,e})),a}function d(e){return e.toLowerCase().replace(/[^a-z\s-]/g," ").split(/\s+/).filter(t=>t&&!i.has(t))}function f(e){let t=Object.keys(c).length,n=new Float32Array(t);for(let r of d(e))r in c&&(n[c[r]]=1);return n}async function u(e){let t=await s();return tf.tidy(()=>t.predict(tf.tensor2d([Array.from(f(e))])).dataSync()[0])}chrome.runtime.onMessage.addListener((e,t,n)=>{if(e?.type!=="TF_CLASSIFY")return;let r=typeof e.threshold=="number"?e.threshold:.5;return u(e.text||"").then(o=>n({ok:!0,score:o,negative:o>=r})).catch(o=>n({ok:!1,error:String(o)})),!0});
