dsh-cost-meter 1.8.36 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.openrouter.js",factory:z=>{const B=z("react"),{createElement:s,useState:w,useEffect:F,useRef:G}=B;function L(r){if(!r||typeof r.fetchedAt!="string"||typeof r.stale!="boolean"||typeof r.error!="string"||!Array.isArray(r.models))throw new Error("Invalid OpenRouter catalog");const o=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0;for(const a of r.models)if(!a||typeof a.id!="string"||typeof a.name!="string"||!o(a.input)||!o(a.output)||!["cachedInput","cacheWrite"].every(i=>a[i]===null||o(a[i]))||!(a.contextLength===null||Number.isSafeInteger(a.contextLength)&&a.contextLength>=0))throw new Error("Invalid OpenRouter model price");return r}const D={parse:L},W={package:"dsh-cost-meter-openrouter",face:"host",descriptors:[{id:"dsh-cost-meter#costMeter/getOpenRouterCatalog",service:"costMeter",namespace:"costMeter",method:"getOpenRouterCatalog",invocation:{kind:"direct"},parameters:[],result:{mode:"strict",typeSymbol:"dsh-cost-meter#OpenRouterCatalog",schema:D,create:()=>D}}]},q=r=>"https://openrouter.ai/"+r.split("/").map(encodeURIComponent).join("/"),x=r=>r===null?"—":"$"+String(r),U=(r,o)=>{const a=new Map((r?.models??[]).map(i=>[i.id,i]));return new Set(o.models.filter(i=>a.has(i.id)&&["input","output","cachedInput","cacheWrite"].some(e=>a.get(i.id)[e]!==i[e])).map(i=>i.id))},M=new WeakMap,K=r=>(M.has(r)||M.set(r,{value:null,error:"",checkedAt:0,pending:null,changed:new Set,query:"",sort:"name",page:0}),M.get(r)),Q=(r,o)=>(o.pending||(o.pending=Promise.resolve().then(()=>r.getOpenRouterCatalog()).then(a=>{const i=L(a);return!i.stale&&i.fetchedAt!==o.value?.fetchedAt&&(o.changed=U(o.value,i)),o.value=i.error&&!i.models.length&&o.value?.models.length?{...o.value,stale:!0,error:i.error}:i,o.error=i.error,o.value}).catch(a=>{throw o.error=String(a?.message??a),a}).finally(()=>{o.checkedAt=Date.now(),o.pending=null})),o.pending);function T({api:r,state:o,resolveLocale:a}){const i=a(o.config)==="en",e=(n,u)=>i?u:n,t=K(r),[l,c]=w(()=>t.value),[g,f]=w(()=>t.error),[v,S]=w(!1),[y,P]=w(()=>t.query),[R,C]=w(()=>t.sort),[N,O]=w(()=>t.page),[E,d]=w(()=>t.changed),p=G(()=>{});F(()=>{let n=!0,u=!1;const A=async(J=!1)=>{if(!(!n||u||document.hidden)&&!(!J&&!t.pending&&t.value&&Date.now()-t.checkedAt<6e4)){u=!0,S(!0);try{const k=await Q(r,t);if(!n)return;d(t.changed),c(k),f(k.error)}catch(k){n&&f(String(k?.message??k))}finally{u=!1,n&&S(!1)}}},I=()=>A(!0);p.current=I,A();const H=setInterval(I,6e4);return document.addEventListener("visibilitychange",I),()=>{n=!1,clearInterval(H),document.removeEventListener("visibilitychange",I)}},[r]);const h=(l?.models??[]).filter(n=>(n.id+" "+n.name).toLowerCase().includes(y.trim().toLowerCase())).sort((n,u)=>(R==="name"?0:n[R]-u[R])||n.id.localeCompare(u.id)),m=Math.min(N,Math.max(0,Math.ceil(h.length/50)-1)),b=(n,u,A=!1)=>s("button",{type:"button",className:"cm-btn small",onClick:u,disabled:A},n);return s("section",{className:"cm-price-card","aria-label":e("OpenRouter 模型价格","OpenRouter model prices")},s("div",{className:"cm-price-head",style:{flexWrap:"wrap"}},s("h3",{className:"cm-h"},e("OpenRouter 模型价格","OpenRouter model prices")),b(v?e("刷新中…","Refreshing…"):e("刷新价格","Refresh prices"),()=>p.current(),v)),s("p",{className:"cm-note"},e("公开目录 · 美元 / 百万 tokens · 无需 API Key,不产生模型调用费用。优先显示上次价格,前台每分钟更新,也可手动刷新。","Public catalog · USD / million tokens · No API key or inference charges. Previous prices appear immediately; updates every minute while visible or on manual refresh.")),s("div",{className:"cm-buttons"},s("input",{className:"cm-input",type:"search",value:y,autoComplete:"off","aria-label":e("搜索 OpenRouter 模型","Search OpenRouter models"),placeholder:e("搜索模型,例如 flash","Search models, e.g. flash"),style:{flex:"1 1 180px",minWidth:0,maxWidth:"100%"},onChange:n=>{t.query=n.target.value,t.page=0,P(t.query),O(0)}}),s("select",{className:"cm-input",value:R,"aria-label":e("价格排序","Price order"),onChange:n=>{t.sort=n.target.value,t.page=0,C(t.sort),O(0)}},...[["name",e("按模型名称","Model name")],["input",e("输入价格从低到高","Input price: low to high")],["output",e("输出价格从低到高","Output price: low to high")]].map(([n,u])=>s("option",{key:n,value:n},u)))),s("p",{className:"cm-note",role:"status"},l?.fetchedAt?e("最近更新:","Last updated: ")+new Date(l.fetchedAt).toLocaleString(i?"en-US":"zh-CN"):e("尚未取得价格","Prices not loaded yet")),g?s("p",{className:"cm-msg err",role:"alert"},(l?.models.length?e("刷新失败,以下保留上次价格:","Refresh failed; previous prices are retained: "):e("价格查询失败:","Price lookup failed: "))+g):null,h.length?s("div",{className:"cm-scroll",tabIndex:0,"aria-label":e("OpenRouter 价格表","OpenRouter price table")},s("table",{className:"cm-table"},s("thead",null,s("tr",null,...[e("模型","Model"),e("输入","Input"),e("输出","Output"),e("缓存读取","Cache read"),e("缓存写入","Cache write"),e("上下文 tokens","Context tokens")].map((n,u)=>s("th",{key:n,scope:"col",className:u?"num":void 0},n)))),s("tbody",null,h.slice(m*50,m*50+50).map(n=>s("tr",{key:n.id},s("td",{style:{whiteSpace:"normal",minWidth:180,maxWidth:300,overflowWrap:"anywhere"}},s("a",{href:q(n.id),target:"_blank",rel:"noopener noreferrer",style:{color:"var(--dsw-alias-brand-primary)"}},n.name),s("div",{className:"cm-sess-id"},n.id),E.has(n.id)?s("span",{className:"cm-price-legacy"},e("价格已变动","Price changed")):null),...["input","output","cachedInput","cacheWrite"].map(u=>s("td",{key:u,className:"num"},x(n[u]))),s("td",{className:"num"},n.contextLength===null?"—":n.contextLength.toLocaleString())))))):s("p",{className:"cm-empty"},v&&!l?e("正在查询公开目录…","Loading public catalog…"):e("没有匹配的模型。","No matching models.")),s("div",{className:"cm-buttons"},s("span",{className:"cm-note"},h.length?`${m*50+1}–${Math.min((m+1)*50,h.length)} / ${h.length}`:"0"),b(e("上一页","Previous"),()=>{t.page=m-1,O(t.page)},m===0),b(e("下一页","Next"),()=>{t.page=m+1,O(t.page)},(m+1)*50>=h.length)),s("p",{className:"cm-note"},e("显示当前公开 token 参考价;— 表示目录未提供。具体路由、阶梯价格和图片、搜索等附加费用请点模型查看。优惠与实际结算以 OpenRouter 为准。","Current public token reference rates; — means unavailable. Open a model for routing, price tiers and extra image/search fees. Promotions and final charges are determined by OpenRouter.")))}function _(r,o){const a=r.querySelector('span[class$="_modelName"]')?.textContent,i=r.closest('section[role="group"][aria-labelledby]'),e=i&&document.getElementById(i.getAttribute("aria-labelledby"));if(!a||!e||!i.contains(e))return null;const t=o.filter(c=>c.name===e.textContent);if(t.length!==1||!["openrouter","llm-openrouter"].includes(t[0].id))return null;const l=t[0].models.filter(c=>c.name===a);return l.length===1?l[0]:null}function $(r,o,a,i=""){const e=a==="en",t=(g,f)=>e?f:g,l=o?.models.find(g=>g.id===r.id),c=[r.name,"OpenRouter · "+r.id];if(l){c.push(t("美元 / 百万 tokens","USD / million tokens"));for(const[g,f,v]of[["input","输入","Input"],["output","输出","Output"],["cachedInput","缓存读取","Cache read"],["cacheWrite","缓存写入","Cache write"]])c.push(t(f,v)+": "+x(l[g]));l.contextLength!==null&&c.push(t("上下文","Context")+": "+l.contextLength.toLocaleString()+" tokens")}else c.push(o?t("公开目录未提供此模型的 token 单价","Token price unavailable for this model in the public catalog"):i?t("价格查询失败","Price lookup failed"):t("正在查询公开价格…","Loading public prices…"));return o?.fetchedAt&&c.push(t("最近更新: ","Updated: ")+new Date(o.fetchedAt).toLocaleString(e?"en-US":"zh-CN")),(i||o?.stale)&&c.push(t("刷新失败,价格未更新","Refresh failed; prices have not been updated")),c.push(t("公开参考价;优惠与结算以 OpenRouter 为准","Public reference rates; promotions and billing follow OpenRouter")),c.join(`
2
- `)}function j({api:r,getGroups:o,getLocale:a,subscribeGroups:i}){if(typeof MutationObserver!="function"||!document.body)return()=>{};const e='button[role="menuitemradio"]',t=new Map;let l=!0,c=!1,g=null,f="",v=-1/0;const S=(d,p)=>{d.getAttribute("title")===p.written&&(p.original===null?d.removeAttribute("title"):d.setAttribute("title",p.original)),t.delete(d)},y=(d=!0)=>{if(!l)return;const p=o(),h=new Map;for(const m of document.querySelectorAll(e)){const b=_(m,p);b&&h.set(m,b)}for(const[m,b]of t)h.has(m)||S(m,b);for(const[m,b]of h){let n=t.get(m);const u=m.getAttribute("title");(!n||u!==n.written)&&(n={original:u,written:null}),n.written=$(b,g,a(),f),t.set(m,n),u!==n.written&&m.setAttribute("title",n.written)}d&&h.size&&!document.hidden&&Date.now()-v>=15e3&&P()},P=async()=>{if(!(!l||c)){c=!0,v=Date.now();try{const d=await r.getOpenRouterCatalog();l&&(g=d,f=d.error)}catch(d){l&&(f=String(d?.message??d))}finally{c=!1,l&&y(!1)}}},R=new MutationObserver(d=>{d.some(p=>p.type==="attributes"?p.target.matches(e)&&p.target.getAttribute("title")!==t.get(p.target)?.written:p.type==="characterData"?p.target.parentElement?.closest(e):[...p.addedNodes,...p.removedNodes].some(h=>h.nodeType===1&&(h.matches(e)||h.querySelector(e))))&&y()});R.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["title"]});const C=()=>{document.hidden||y()},N=d=>{d.target?.closest?.(e)&&y()};document.addEventListener("visibilitychange",C),document.addEventListener("pointerover",N),document.addEventListener("focusin",N);const O=setInterval(C,6e4),E=i?.(()=>y());return y(),()=>{l=!1,R.disconnect(),clearInterval(O),E?.(),document.removeEventListener("visibilitychange",C),document.removeEventListener("pointerover",N),document.removeEventListener("focusin",N);for(const[d,p]of t)S(d,p)}}async function V(r,o,a){const i=typeof o=="function"?o:()=>o&&a?a(o.getSnapshot().state?.config??{activeLocale:o.getSnapshot().locale}):r.get("locale")?.getSnapshot?.().active??"en",e=await r.get("remote").$mount(W);r.effect(()=>()=>e(),"cost-meter: OpenRouter catalog contribution");const t=r.get("remote.costMeter"),l={getOpenRouterCatalog:async()=>{const c=await t.getOpenRouterCatalog();if(!c?.ok)throw new Error(c?.error?.message||"OpenRouter price lookup failed");return L(c.value)}};return typeof r.inject=="function"&&r.inject(["modelDirectories"],c=>{const g=c.get("modelDirectories")?.catalog?.store;g?.getSnapshot&&c.effect(()=>j({api:l,getGroups:()=>g.getSnapshot()?.value?.groups??[],getLocale:i,subscribeGroups:f=>g.subscribe?.(f)}),"cost-meter: model price tooltips")}),c=>s(T,{...c,api:l})}return{mount:V,PriceBrowser:T,CONTRIBUTION:W,parseCatalog:L,changedRates:U,priceText:x,modelUrl:q,pickerModel:_,priceTooltip:$,installPickerPrices:j}}});
1
+ window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.openrouter.js",factory:z=>{const B=z("react"),{createElement:s,useState:w,useEffect:F,useRef:G}=B;function x(r){if(!r||typeof r.fetchedAt!="string"||typeof r.stale!="boolean"||typeof r.error!="string"||!Array.isArray(r.models))throw new Error("Invalid OpenRouter catalog");const o=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0;for(const a of r.models)if(!a||typeof a.id!="string"||typeof a.name!="string"||!o(a.input)||!o(a.output)||!["cachedInput","cacheWrite"].every(i=>a[i]===null||o(a[i]))||!(a.contextLength===null||Number.isSafeInteger(a.contextLength)&&a.contextLength>=0))throw new Error("Invalid OpenRouter model price");return r}const D={parse:x},W={package:"dsh-cost-meter-openrouter",face:"host",descriptors:[{id:"dsh-cost-meter#costMeter/getOpenRouterCatalog",service:"costMeter",namespace:"costMeter",method:"getOpenRouterCatalog",invocation:{kind:"direct"},parameters:[],result:{mode:"strict",typeSymbol:"dsh-cost-meter#OpenRouterCatalog",schema:D,create:()=>D}}]},q=r=>"https://openrouter.ai/"+r.split("/").map(encodeURIComponent).join("/"),I=r=>r===null?"—":"$"+String(r),U=(r,o)=>{const a=new Map((r?.models??[]).map(i=>[i.id,i]));return new Set(o.models.filter(i=>a.has(i.id)&&["input","output","cachedInput","cacheWrite"].some(e=>a.get(i.id)[e]!==i[e])).map(i=>i.id))},M=new WeakMap,K=r=>(M.has(r)||M.set(r,{value:null,error:"",checkedAt:0,pending:null,changed:new Set,query:"",sort:"name",page:0}),M.get(r)),Q=(r,o)=>(o.pending||(o.pending=Promise.resolve().then(()=>r.getOpenRouterCatalog()).then(a=>{const i=x(a);return!i.stale&&i.fetchedAt!==o.value?.fetchedAt&&(o.changed=U(o.value,i)),o.value=i.error&&!i.models.length&&o.value?.models.length?{...o.value,stale:!0,error:i.error}:i,o.error=i.error,o.value}).catch(a=>{throw o.error=String(a?.message??a),a}).finally(()=>{o.checkedAt=Date.now(),o.pending=null})),o.pending);function T({api:r,state:o,resolveLocale:a}){const i=a(o.config)==="en",e=(n,u)=>i?u:n,t=K(r),[c,l]=w(()=>t.value),[p,g]=w(()=>t.error),[b,S]=w(!1),[v,P]=w(()=>t.query),[R,C]=w(()=>t.sort),[N,O]=w(()=>t.page),[E,d]=w(()=>t.changed),m=G(()=>{});F(()=>{let n=!0,u=!1;const L=async(J=!1)=>{if(!(!n||u||document.hidden)&&!(!J&&!t.pending&&t.value&&Date.now()-t.checkedAt<6e4)){u=!0,S(!0);try{const k=await Q(r,t);if(!n)return;d(t.changed),l(k),g(k.error)}catch(k){n&&g(String(k?.message??k))}finally{u=!1,n&&S(!1)}}},A=()=>L(!0);m.current=A,L();const H=setInterval(A,6e4);return document.addEventListener("visibilitychange",A),()=>{n=!1,clearInterval(H),document.removeEventListener("visibilitychange",A)}},[r]);const f=(c?.models??[]).filter(n=>(n.id+" "+n.name).toLowerCase().includes(v.trim().toLowerCase())).sort((n,u)=>(R==="name"?0:n[R]-u[R])||n.id.localeCompare(u.id)),h=Math.min(N,Math.max(0,Math.ceil(f.length/50)-1)),y=(n,u,L=!1)=>s("button",{type:"button",className:"cm-btn small",onClick:u,disabled:L},n);return s("section",{className:"cm-price-card","aria-label":e("OpenRouter 模型价格","OpenRouter model prices")},s("div",{className:"cm-price-head",style:{flexWrap:"wrap"}},s("h3",{className:"cm-h"},e("OpenRouter 模型价格","OpenRouter model prices")),y(b?e("刷新中…","Refreshing…"):e("刷新价格","Refresh prices"),()=>m.current(),b)),s("p",{className:"cm-note"},e("公开目录 · 美元 / 百万 tokens · 无需 API Key,不产生模型调用费用。优先显示上次价格,前台每分钟更新,也可手动刷新。","Public catalog · USD / million tokens · No API key or inference charges. Previous prices appear immediately; updates every minute while visible or on manual refresh.")),s("div",{className:"cm-buttons"},s("input",{className:"cm-input",type:"search",value:v,autoComplete:"off","aria-label":e("搜索 OpenRouter 模型","Search OpenRouter models"),placeholder:e("搜索模型,例如 flash","Search models, e.g. flash"),style:{flex:"1 1 180px",minWidth:0,maxWidth:"100%"},onChange:n=>{t.query=n.target.value,t.page=0,P(t.query),O(0)}}),s("select",{className:"cm-input",value:R,"aria-label":e("价格排序","Price order"),onChange:n=>{t.sort=n.target.value,t.page=0,C(t.sort),O(0)}},...[["name",e("按模型名称","Model name")],["input",e("输入价格从低到高","Input price: low to high")],["output",e("输出价格从低到高","Output price: low to high")]].map(([n,u])=>s("option",{key:n,value:n},u)))),s("p",{className:"cm-note",role:"status"},c?.fetchedAt?e("最近更新:","Last updated: ")+new Date(c.fetchedAt).toLocaleString(i?"en-US":"zh-CN"):e("尚未取得价格","Prices not loaded yet")),p?s("p",{className:"cm-msg err",role:"alert"},(c?.models.length?e("刷新失败,以下保留上次价格:","Refresh failed; previous prices are retained: "):e("价格查询失败:","Price lookup failed: "))+p):null,f.length?s("div",{className:"cm-scroll",tabIndex:0,"aria-label":e("OpenRouter 价格表","OpenRouter price table")},s("table",{className:"cm-table"},s("thead",null,s("tr",null,...[e("模型","Model"),e("输入","Input"),e("输出","Output"),e("缓存读取","Cache read"),e("缓存写入","Cache write"),e("上下文 tokens","Context tokens")].map((n,u)=>s("th",{key:n,scope:"col",className:u?"num":void 0},n)))),s("tbody",null,f.slice(h*50,h*50+50).map(n=>s("tr",{key:n.id},s("td",{style:{whiteSpace:"normal",minWidth:180,maxWidth:300,overflowWrap:"anywhere"}},s("a",{href:q(n.id),target:"_blank",rel:"noopener noreferrer",style:{color:"var(--dsw-alias-brand-primary)"}},n.name),s("div",{className:"cm-sess-id"},n.id),E.has(n.id)?s("span",{className:"cm-price-legacy"},e("价格已变动","Price changed")):null),...["input","output","cachedInput","cacheWrite"].map(u=>s("td",{key:u,className:"num"},I(n[u]))),s("td",{className:"num"},n.contextLength===null?"—":n.contextLength.toLocaleString())))))):s("p",{className:"cm-empty"},b&&!c?e("正在查询公开目录…","Loading public catalog…"):e("没有匹配的模型。","No matching models.")),s("div",{className:"cm-buttons"},s("span",{className:"cm-note"},f.length?`${h*50+1}–${Math.min((h+1)*50,f.length)} / ${f.length}`:"0"),y(e("上一页","Previous"),()=>{t.page=h-1,O(t.page)},h===0),y(e("下一页","Next"),()=>{t.page=h+1,O(t.page)},(h+1)*50>=f.length)),s("p",{className:"cm-note"},e("显示当前公开 token 参考价;— 表示目录未提供。具体路由、阶梯价格和图片、搜索等附加费用请点模型查看。优惠与实际结算以 OpenRouter 为准。","Current public token reference rates; — means unavailable. Open a model for routing, price tiers and extra image/search fees. Promotions and final charges are determined by OpenRouter.")))}function _(r,o){const a=r.querySelector('span[class$="_modelName"]')?.textContent,i=r.closest('section[role="group"][aria-labelledby]'),e=i&&document.getElementById(i.getAttribute("aria-labelledby"));if(!a||!e||!i.contains(e))return null;const t=o.filter(l=>l.name===e.textContent);if(t.length!==1||!["openrouter","llm-openrouter"].includes(t[0].id))return null;const c=t[0].models.filter(l=>l.name===a);return c.length===1?c[0]:null}function $(r,o,a,i=""){const e=a==="en",t=(p,g)=>e?g:p,c=o?.models.find(p=>p.id===r.id),l=[r.name,"OpenRouter · "+r.id];if(c){l.push(t("美元 / 百万 tokens","USD / million tokens"));for(const[p,g,b]of[["input","输入","Input"],["output","输出","Output"],["cachedInput","缓存读取","Cache read"],["cacheWrite","缓存写入","Cache write"]])l.push(t(g,b)+": "+I(c[p]));c.contextLength!==null&&l.push(t("上下文","Context")+": "+c.contextLength.toLocaleString()+" tokens")}else l.push(o?t("公开目录未提供此模型的 token 单价","Token price unavailable for this model in the public catalog"):i?t("价格查询失败","Price lookup failed"):t("正在查询公开价格…","Loading public prices…"));return o?.fetchedAt&&l.push(t("最近更新: ","Updated: ")+new Date(o.fetchedAt).toLocaleString(e?"en-US":"zh-CN")),(i||o?.stale)&&l.push(t("刷新失败,价格未更新","Refresh failed; prices have not been updated")),l.push(t("公开参考价;优惠与结算以 OpenRouter 为准","Public reference rates; promotions and billing follow OpenRouter")),l.join(`
2
+ `)}function j({api:r,getGroups:o,getLocale:a,subscribeGroups:i}){if(typeof MutationObserver!="function"||!document.body)return()=>{};const e='button[role="menuitemradio"]',t=new Map;let c=!0,l=!1,p=null,g="",b=-1/0;const S=(d,m)=>{d.getAttribute("title")===m.written&&(m.original===null?d.removeAttribute("title"):d.setAttribute("title",m.original)),t.delete(d)},v=(d=!0)=>{if(!c)return;const m=o(),f=new Map;for(const h of document.querySelectorAll(e)){const y=_(h,m);y&&f.set(h,y)}for(const[h,y]of t)f.has(h)||S(h,y);for(const[h,y]of f){let n=t.get(h);const u=h.getAttribute("title");(!n||u!==n.written)&&(n={original:u,written:null}),n.written=$(y,p,a(),g),t.set(h,n),u!==n.written&&h.setAttribute("title",n.written)}d&&f.size&&!document.hidden&&Date.now()-b>=15e3&&P()},P=async()=>{if(!(!c||l)){l=!0,b=Date.now();try{const d=await r.getOpenRouterCatalog();c&&(p=d,g=d.error)}catch(d){c&&(g=String(d?.message??d))}finally{l=!1,c&&v(!1)}}},R=new MutationObserver(d=>{d.some(m=>m.type==="attributes"?m.target.matches(e)&&m.target.getAttribute("title")!==t.get(m.target)?.written:m.type==="characterData"?m.target.parentElement?.closest(e):[...m.addedNodes,...m.removedNodes].some(f=>f.nodeType===1&&(f.matches(e)||f.querySelector(e))))&&v()});R.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["title"]});const C=()=>{document.hidden||v()},N=d=>{d.target?.closest?.(e)&&v()};document.addEventListener("visibilitychange",C),document.addEventListener("pointerover",N),document.addEventListener("focusin",N);const O=setInterval(C,6e4),E=i?.(()=>v());return v(),()=>{c=!1,R.disconnect(),clearInterval(O),E?.(),document.removeEventListener("visibilitychange",C),document.removeEventListener("pointerover",N),document.removeEventListener("focusin",N);for(const[d,m]of t)S(d,m)}}async function V(r,o,a){const i=typeof o=="function"?o:()=>o&&a?a(o.getSnapshot().state?.config??{activeLocale:o.getSnapshot().locale}):r.get("locale")?.getSnapshot?.().active??"en",e=await r.get("remote").$mount(W);r.effect(()=>()=>e(),"cost-meter: OpenRouter catalog contribution");const t=document.createElement("style");t.textContent='@media (max-width:1023px){.cm-price-head{flex-wrap:wrap;gap:6px}.cm-scroll>.cm-table{min-width:520px}.cm-price-card{padding:10px 12px}}body[data-dsh-pocket-layout="mobile"] .cm-price-head{flex-wrap:wrap}',document.head.appendChild(t),r.effect(()=>()=>t.remove(),"cost-meter: OpenRouter responsive styles");const c=r.get("remote.costMeter"),l={getOpenRouterCatalog:async()=>{const p=await c.getOpenRouterCatalog();if(!p?.ok)throw new Error(p?.error?.message||"OpenRouter price lookup failed");return x(p.value)}};return typeof r.inject=="function"&&r.inject(["modelDirectories"],p=>{const g=p.get("modelDirectories")?.catalog?.store;g?.getSnapshot&&p.effect(()=>j({api:l,getGroups:()=>g.getSnapshot()?.value?.groups??[],getLocale:i,subscribeGroups:b=>g.subscribe?.(b)}),"cost-meter: model price tooltips")}),p=>s(T,{...p,api:l})}return{mount:V,PriceBrowser:T,CONTRIBUTION:W,parseCatalog:x,changedRates:U,priceText:I,modelUrl:q,pickerModel:_,priceTooltip:$,installPickerPrices:j}}});
@@ -24,4 +24,4 @@ window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.pricing.js",fact
24
24
  @container cm-price-list (max-width:560px){.cm-catalog-columns{display:none}.cm-catalog-model{grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.cm-catalog-model-name{grid-column:1/-1;padding-inline-end:20px}.cm-catalog-model .cm-rate-item>span{display:block}.cm-catalog-edit-caret{position:absolute;inset-inline-end:16px;top:12px}.cm-catalog-unit{font-size:10px}.cm-catalog-editor{padding:0 10px 10px}}
25
25
  @container cm-price-editor (max-width:520px){.cm-price-row.cm-price-columns{display:none}.cm-price-row:not(.cm-price-columns){grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px}.cm-price-row>span:first-child{grid-column:1/-1;font-weight:600;color:var(--dsw-alias-label-secondary)}.cm-price-cell>.cm-price-cell-label{display:block;font-size:11px;line-height:1.5}}
26
26
  @media(max-width:480px){.cm-source-choices{grid-template-columns:repeat(2,minmax(0,1fr))}.cm-catalog-toolbar>select{flex:1 1 140px}}
27
- `,h.textContent+=[".cm-price-search{display:block;min-width:0}",".cm-combo-control{position:relative;display:flex;align-items:center;min-width:0}",".cm-combo .cm-input{width:100%;min-width:0;padding-right:46px;text-overflow:ellipsis}",".cm-combo .cm-combo-input::-webkit-search-cancel-button{display:none}",".cm-combo-clear,.cm-combo-caret{position:absolute;display:flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);line-height:1;cursor:pointer}",".cm-combo-clear{right:26px;border-radius:50%;font-size:14px}",".cm-combo-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary)}",".cm-combo-caret{right:6px;font-size:10px}",".cm-combo-panel{position:fixed;z-index:10000;display:flex;flex-direction:column;gap:2px;box-sizing:border-box;padding:4px;border-radius:12px;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base));box-shadow:var(--dsw-elevation-panel,0 3px 8px rgba(0,0,0,.06),0 0 16px rgba(0,0,0,.04))}",".cm-combo-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}",".cm-combo-option{flex:none;font:inherit;font-size:12px;line-height:1.5;text-align:left;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",".cm-combo-option.active{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}",'.cm-combo-option[aria-selected="true"]{color:var(--dsw-alias-state-business-primary);font-weight:600}',".cm-combo-note{margin:0;padding:4px 8px;font-size:10px;color:var(--dsw-alias-label-tertiary)}",".cm-match-row .cm-combo{flex:1;min-width:160px}",".cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}"].join(""),t.effect(()=>()=>h.remove(),"cost-meter: pricing settings styles"),d=>d.mode==="matching"?e(Ne,d):e(d.mode==="catalog"?Ce:d.mode==="restore"?ue:Me,{...d,rpc:u})}return{mount:ke,CONTRIBUTION:pe}}});
27
+ `,h.textContent+=[".cm-price-search{display:block;min-width:0}",".cm-combo-control{position:relative;display:flex;align-items:center;min-width:0}",".cm-combo .cm-input{width:100%;min-width:0;padding-right:46px;text-overflow:ellipsis}",".cm-combo .cm-combo-input::-webkit-search-cancel-button{display:none}",".cm-combo-clear,.cm-combo-caret{position:absolute;display:flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);line-height:1;cursor:pointer}",".cm-combo-clear{right:26px;border-radius:50%;font-size:14px}",".cm-combo-clear:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary)}",".cm-combo-caret{right:6px;font-size:10px}",".cm-combo-panel{position:fixed;z-index:10000;display:flex;flex-direction:column;gap:2px;box-sizing:border-box;padding:4px;border-radius:12px;background:var(--cm-opaque-base,#fff);background:rgb(from var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff)) r g b / 1);box-shadow:var(--dsw-elevation-panel,0 3px 8px rgba(0,0,0,.06),0 0 16px rgba(0,0,0,.04))}",".cm-combo-list{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}",".cm-combo-option{flex:none;font:inherit;font-size:12px;line-height:1.5;text-align:left;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",".cm-combo-option.active{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}",'.cm-combo-option[aria-selected="true"]{color:var(--dsw-alias-state-business-primary);font-weight:600}',".cm-combo-note{margin:0;padding:4px 8px;font-size:10px;color:var(--dsw-alias-label-tertiary)}",".cm-match-row .cm-combo{flex:1;min-width:160px}",".cm-repricing-warning{padding:12px;border:1px solid var(--dsw-alias-state-warn-primary,#c58a25);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}.cm-repricing-warning p{margin:8px 0 12px;line-height:1.6}.cm-repricing-history{margin-top:12px}.cm-repricing-history table{width:100%;text-align:left;font-variant-numeric:tabular-nums}.cm-repricing-history td,.cm-repricing-history th{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l1)}",'@media (max-width:1023px){.cm-custom-grid,.cm-effective-grid,.cm-rate-summary{grid-template-columns:1fr}.cm-model-toolbar,.cm-custom-head,.cm-catalog-toolbar{flex-wrap:wrap}.cm-repricing-history table{min-width:480px}.cm-model-matching .cm-match-row{padding:12px}}body[data-dsh-pocket-layout="mobile"] .cm-custom-grid{grid-template-columns:1fr}body[data-dsh-pocket-layout="mobile"] .cm-rate-summary{grid-template-columns:1fr}'].join(""),t.effect(()=>()=>h.remove(),"cost-meter: pricing settings styles"),d=>d.mode==="matching"?e(Ne,d):e(d.mode==="catalog"?Ce:d.mode==="restore"?ue:Me,{...d,rpc:u})}return{mount:ke,CONTRIBUTION:pe}}});