PageSourceSearch

https://delphi.tools/assets/sci-calc-B-xNGTP-.js

js delphi.tools collected 2026-09-26 02:22:30 UTC 11,497 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-DBScgg2x.js","assets/rolldown-runtime-Bv92FReW.js","assets/__vite-browser-external-DwCaj-fe.js"])))=>i.map(i=>d[i]);
2import{At as t,Yt as s,f as e,g as n,t as i}from"./dist-DbesxMH9.js";import{a as o,r}from"./template-only-OXqhdPeE.js";import{n as a}from"./dist-DAI4kugB.js";import{t as l}from"./preload-helper-g33OWdIx.js";import"./dist-DMqe6bAt.js";import{t as c}from"./icon-CP7IfZdC.js";import{r as u}from"./helper-VI-zKrdX.js";import{t as p}from"./eq-CywQK-u3.js";import{E as h,T as d,d as m,f as y,w as x}from"./main-CwcQVUEc.js";import{a as g,i as f,n as b,o as k,r as v,t as C}from"./command-CIn1PIyn.js";var M=[["1","2","3","."],["0","±","EE","mod"]],w=[...[["C","(",")","%","⌫"],["sin","cos","tan","π","÷"],["asin","acos","atan","e","×"],["x²","√","xʸ","ʸ√x","−"],["log","ln","!","|x|","+"],["7","8","9","10ˣ","eˣ"],["4","5","6","Const","Ans"]].flat(),...M[0]??[],"=",...M[1]??[]],O=["+","−","×","÷","%"],E=/^[0-9.]$/;function $(t){return"="===t?"is-equals":"C"===t||"⌫"===t?"is-clear":O.includes(t)?"is-operator":E.test(t)?"is-digit":"Const"===t?"is-const":"is-default"}function A(t,s){return t.replace(/×/g,"*").replace(/÷/g,"/").replace(/−/g,"-").replace(/π/g,`(${Math.PI})`).replace(/(\d\.?\d*)[eE]([+-]?\d)/g,"$1e$2").replace(/(^|[^0-9])e(?!x|[0-9])/g,`$1(${Math.E})`).replace(/Ans/g,`(${s})`).replace(/(\d+)!/g,"factorial($1)").replace(/\|([^|]+)\|/g,"abs($1)")}function I(t){return"rad"===t?{}:{sin:t=>Math.sin(t*Math.PI/180),cos:t=>Math.cos(t*Math.PI/180),tan:t=>Math.tan(t*Math.PI/180),asin:t=>180*Math.asin(t)/Math.PI,acos:t=>180*Math.acos(t)/Math.PI,atan:t=>180*Math.atan(t)/Math.PI}}function P(t){return"number"==typeof t?y(t):String(t)}var T=null,j=class extends i{static{r(this.prototype,"expression",[e],function(){return""})}#t=void o(this,"expression");static{r(this.prototype,"result",[e],function(){return null})}#s=void o(this,"result");static{r(this.prototype,"error",[e],function(){return null})}#e=void o(this,"error");static{r(this.prototype,"angleMode",[e],function(){return"deg"})}#n=void o(this,"angleMode");static{r(this.prototype,"history",[e],function(){return[]})}#i=void o(this,"history");static{r(this.prototype,"historyOpen",[e],function(){return!1})}#o=void o(this,"historyOpen");static{r(this.prototype,"lastAnswer",[e],function(){return 0})}#r=void o(this,"lastAnswer");static{r(this.prototype,"copied",[e],function(){return!1})}#a=void o(this,"copied");static{r(this.prototype,"constantsOpen",[e],function(){return!1})}#l=void o(this,"constantsOpen");#c=0;#u;willDestroy(){super.willDestroy(),clearTimeout(this.#u)}get buttons(){return w.map(t=>({key:t,label:t,variant:$(t),isConst:"Const"===t}))}get display(){return this.expression||"0"}get readout(){return this.error??this.result??"0"}get showCopy(){return null!==this.result&&null===this.error}get constantGroups(){return[{key:"mathematical",heading:"Mathematical"},{key:"physical",heading:"Physical"},{key:"chemical",heading:"Chemical"}].map(t=>({...t,constants:m.filter(s=>s.category===t.key).map(t=>({name:t.name,symbol:t.symbol,value:t.value,search:`${t.name} ${t.symbol}`}))}))}
2shortcuts=a(t=>{const s=t=>{if(t.target instanceof HTMLInputElement)return;const s=t.key;if(/^[0-9.+\-*/()%^]$/.test(s)){t.preventDefault();const e="*"===s?"×":"/"===s?"÷":"-"===s?"−":s;this.press(e)}else"Enter"===s?(t.preventDefault(),this.calculate()):"Backspace"===s?(t.preventDefault(),this.press("⌫")):"Escape"===s&&(t.preventDefault(),this.press("C"))};return t.ownerDocument.addEventListener("keydown",s),()=>t.ownerDocument.removeEventListener("keydown",s)});calculate=async()=>{if(this.expression.trim())try{const{evaluate:t}=await async function(){return T??=await l(()=>import("./esm-DBScgg2x.js"),__vite__mapDeps([0,1,2])),T}(),s=t(A(this.expression,this.lastAnswer),I(this.angleMode)),e=P(s);this.result=e,this.error=null,this.lastAnswer="number"==typeof s?s:0,this.history=[{id:this.#c++,expression:this.expression,result:e},...this.history.slice(0,19)]}catch{this.error="Error",this.result=null}};press=t=>{switch(this.error=null,t){case"C":this.expression="",this.result=null;break;case"⌫":this.expression=this.expression.slice(0,-1);break;case"=":this.calculate();break;case"±":if(null!==this.result){const t=Number.parseFloat(this.result.replace(/[^\d.-]/g,""));Number.isNaN(t)||(this.expression=String(-t),this.result=null)}else this.expression&&(this.expression=this.expression.startsWith("-")?this.expression.slice(1):`-${this.expression}`);break;case"x²":this.expression=`(${this.expression||"0"})^2`;break;case"√":this.expression=`sqrt(${this.expression})`;break;case"xʸ":this.expression+="^";break;case"ʸ√x":this.expression+="nthRoot(";break;case"10ˣ":this.expression=`10^(${this.expression})`;break;case"eˣ":this.expression=`exp(${this.expression})`;break;case"log":this.expression+="log10(";break;case"ln":this.expression+="log(";break;case"!":this.expression+="!";break;case"|x|":this.expression=`|${this.expression}|`;break;case"sin":case"cos":case"tan":case"asin":case"acos":case"atan":this.expression+=`${t}(`;break;case"EE":this.expression+="e";break;case"mod":this.expression+=" mod ";break;case"Ans":this.expression+="Ans";break;default:null!==this.result&&E.test(t)?(this.expression=t,this.result=null):this.expression+=t}};setAngleMode=t=>{this.angleMode=t};toggleHistory=()=>{this.historyOpen=!this.historyOpen};setConstantsOpen=t=>{this.constantsOpen=t};chooseConstant=t=>{this.expression+=y(t),this.constantsOpen=!1};loadFromHistory=t=>{this.expression=t.expression,this.result=t.result,this.historyOpen=!1};copyResult=async()=>{this.result&&(await navigator.clipboard.writeText(this.result),this.copied=!0,clearTimeout(this.#u),this.#u=setTimeout(()=>this.copied=!1,1500))};copy=()=>{this.copyResult()};static{s(t({id:null,block:'[[[11,0],[24,0,"dt-sci"],[4,[30,0,["shortcuts"]],null,null],[12],[1,"\\n\\t"],[10,0],[14,0,"dt-sci-frame"],[12],[1,"\\n\\t\\t"],[10,0],[14,0,"dt-sci-head"],[12],[1,"\\n\\t\\t\\t"],[11,"button"],[16,0,[29,["dt-sci-mode\\n\\t\\t\\t\\t\\t",[52,[28,[32,0],[[30,0,["angleMode"]],"deg"],null],"is-active"]]]],[24,4,"button"],[4,[32,1],["click",[28,[32,2],[[30,0,["setAngleMode"]],"deg"],null]],null],[12],[1,"DEG"],[13],[1,"\\n\\t\\t\\t"],[11,"button"],[16,0,[29,["dt-sci-mode\\n\\t\\t\\t\\t\\t",[52,[28,[32,0],[[30,0,["angleMode"]],"rad"],null],"is-active"]]]],[24,4,"button"],[4,[32,1],["click",[28,[32,2],[[30,0,["setAngleMode"]],"rad"],null]],null],[12],[1,"RAD"],[13],[1,"\\n\\t\\t\\t"],[11,"button"],[24,0,"dt-sci-history-toggle"],[16,"aria-expanded",[52,[30,0,["historyOpen"]],"true","false"]],[24,4,"button"],[4,[32,1],["click",[30,0,["toggleHistory"]]],null],[12],[1,"\\n\\t\\t\\t\\t"],[8,[32,3],null,[["@name"],["clock"]],null],[1,"\\n"],[1,"\\t\\t\\t\\tHistory\\n\\t\\t\\t\\t"],[8,[32,3],[[16,0,[29,["dt-sci-chevron\\n\\t\\t\\t\\t\\t\\t",[52,[30,0,["historyOpen"]],"is-open"]]]]],[["@name"],["chevron-down"]],null],[1,"\\n\\t\\t\\t"],[13],[1,"\\n\\t\\t"],[13],[1,"\\n\\n\\t\\t"],[10,0],[14,0,"dt-sci-display"],[12],[1,"\\n\\t\\t\\t"],[10,0],[14,0,"dt-sci-expression"],[12],[1,[30,0,["display"]]],[13],[1,"\\n\\t\\t\\t"],[10,0],[14,0,"dt-sci-readout"],[12],[1,"\\n\\t\\t\\t\\t"],[10,0],[15,0,[29,["dt-sci-value\\n\\t\\t\\t\\t\\t\\t",[52,[30,0,["error"]],"is-error"]]]],[12],[1,[30,0,["readout"]]],[13],[1,"\\n"],[41,[30,0,["showCopy"]],[[[1,"\\t\\t\\t\\t\\t"],[11,"button"],[24,0,"dt-sci-copy"],[24,"aria-label","Copy result"],[24,4,"button"],[4,[32,1],["click",[30,0,["copy"]]],null],[12],[1,"\\n\\t\\t\\t\\t\\t\\t"],[8,[32,3],[[16,0,[52,[30,0,["copied"]],"is-copied"]]],[["@name"],[[52,[30,0,["copied"]],"check","copy"]]],null],[1,"\\n\\t\\t\\t\\t\\t"],[13],[1,"\\n"]],[]],null],[1,"\\t\\t\\t"],[13],[1,"\\n\\t\\t"],[13],[1,"\\n\\n"],[41,[30,0,["historyOpen"]],[[[1,"\\t\\t\\t"],[10,0],[14,0,"dt-sci-history"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["history"]]],null]],null],"id",[[[1,"\\t\\t\\t\\t\\t"],[11,"button"],[24,0,"dt-sci-history-item"],[24,4,"button"],[4,[32,1],["click",[28,[32,2],[[30,0,["loadFromHistory"]],[30,1]],null]],null],[12],[1,"\\n\\t\\t\\t\\t\\t\\t"],[10,0],[14,0,"dt-sci-history-expression"],[12],[1,[30,1,["expression"]]],[13],[1,"\\n\\t\\t\\t\\t\\t\\t"],[10,0],[14,0,"dt-sci-history-result"],[12],[1,[30,1,["result"]]],[13],[1,"\\n\\t\\t\\t\\t\\t"],[13],[1,"\\n"]],[1]],[[[1,"\\t\\t\\t\\t\\t"],[10,2],[14,0,"dt-sci-history-empty"],[12],[1,"No history yet"],[13],[1,"\\n"]],[]]],[1,"\\t\\t\\t"],[13],[1,"\\n"]],[]],null],[1,"\\n\\t\\t"],[10,0],[14,0,"dt-sci-keypad segmented"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["buttons"]]],null]],null],"key",[[[41,[30,2,["isConst"]],[[[1,"\\t\\t\\t\\t\\t"],[8,[32,4],null,[["@open","@onOpenChange"],[[30,0,["constantsOpen"]],[30,0,["setConstantsOpen"]]]],[["default"],[[[[1,"\\n\\t\\t\\t\\t\\t\\t"],[8,[32,5],null,[["@asChild"],[true]],[["default"],[[[[1,"\\n"],[1,"\\t\\t\\t\\t\\t\\t\\t"],[11,"button"],[24,0,"dt-sci-key is-const"],[24,4,"button"],[4,[30,3,["modifiers"]],null,null],[12],[1,"Const"],[13],[1,"\\n\\t\\t\\t\\t\\t\\t"]],[3]]]]],[1,"\\n\\t\\t\\t\\t\\t\\t"],[8,[32,6],[[24,0,"dt-sci-constants"]],[["@align"],["start"]],[["default"],[[[[1,"\\n\\t\\t\\t\\t\\t\\t\\t"],[8,[32,7],null,null,[["default"],[[[[1,"\\n"],[1,"\\t\\t\\t\\t\\t\\t\\t\\t"],[8,[32,8],null,[["@placeholder"],["Search constants..."]],null],[1,"\\n\\t\\t\\t\\t\\t\\t\\t\\t"],[8,[32,9],null,null,[["default"],[[[[1,"\\n"],[1,"\\t\\t\\t\\t\\t\\t\\t\\t\\t"],[8,[32,10],null,null,[["default"],[[[[1,"No\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tconstant\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tfound."]],[]]]]],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["constantGroups"]]],null]],null],"key",[[[1,"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"],[8,[32,11],null,[["@heading"],[[30,4,["heading"]]]],[["default"],[[[[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,4,["constants"]]],null]],null],"name",[[[1,"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"],[8,[32,12],null,[["@value","@onSelect"],[[30,5,["search"]],[28,[32,2],[[30,0,["chooseConstant"]],[30,5,["value"]]],null]]],[["default"],[[[[1,"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"],[10,1],[14,0,"dt-sci-constant-symbol"],[12],[1,[30,5,["symbol"]]],[13],[1,"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"],[10,1],[14,0,"dt-sci-constant-name"],[12],[1,[30,5,["name"]]],[13],[1,"\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n"]],[5]],null],[1,"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n"]],[4]],null],[1,"\\t\\t\\t\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n\\t\\t\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n\\t\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n\\t\\t\\t\\t\\t"]],[]]]]],[1,"\\n"]],[]],[[[1,"\\t\\t\\t\\t\\t"],[11,"button"],[16,0,[29,["dt-sci-key\\n\\t\\t\\t\\t\\t\\t\\t",[30,2,["variant"]]]]],[24,4,"button"],[4,[32,1],["click",[28,[32,2],[[30,0,["press"]],[30,2,["key"]]],null]],null],[12],[1,[30,2,["label"]]],[13],[1,"\\n"]],[]]]],[2]],null],[1,"\\t\\t"],[13],[1,"\\n\\t"],[13],[1,"\\n\\n"],[1,"\\t"],[10,2],[14,0,"dt-sci-hint"],[12],[1,"Keyboard supported: numbers,\\n\\t\\toperators, Enter to calculate, Escape to clear"],[13],[1,"\\n"],[13]],["item","btn","trigger","group","constant"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({eq:p,on:n,fn:u,Icon:c,Popover:x,PopoverTrigger:h,PopoverContent:d,Command:C,CommandInput:f,CommandList:k,CommandEmpty:b,CommandGroup:v,CommandItem:g}),isStrictMode:!0}),this)}};export{w as KEYPAD,I as angleScope,j as default,$ as keyVariant,A as prepareExpression,P as resultText};

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.