1import{j as w,e as u,r as v,v as G,F as k}from"./index-bc02e1d4.js";import{a as R,C as W,D as j,b as H,c as I,s as L,t as M,d as T,S as E}from"./PlotUtils-82439016.js";import{w as V,c as y,a as U,x as z,y as B,b as O,l as F}from"./line-61ec9873.js";function q(o,s,r){var f=null,h=y(!0),c=null,d=U,l=null,a=V(e);o=typeof o=="function"?o:o===void 0?z:y(+o),s=typeof s=="function"?s:s===void 0?y(0):y(+s),r=typeof r=="function"?r:r===void 0?B:y(+r);function e(n){var i,g,x,m=(n=O(n)).length,p,N=!1,A,P=new Array(m),b=new Array(m);for(c==null&&(l=d(A=a())),i=0;i<=m;++i){if(!(i<m&&h(p=n[i],i,n))===N)if(N=!N)g=i,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=i-1;x>=g;--x)l.point(P[x],b[x]);l.lineEnd(),l.areaEnd()}N&&(P[i]=+o(p,i,n),b[i]=+s(p,i,n),l.point(f?+f(p,i,n):P[i],r?+r(p,i,n):b[i]))}if(A)return l=null,A+""||null}function t(){return F().defined(h).curve(d).context(c)}return e.x=function(n){return arguments.length?(o=typeof n=="function"?n:y(+n),f=null,e):o},e.x0=function(n){return arguments.length?(o=typeof n=="function"?n:y(+n),e):o},e.x1=function(n){return arguments.length?(f=n==null?null:typeof n=="function"?n:y(+n),e):f},e.y=function(n){return arguments.length?(s=typeof n=="function"?n:y(+n),r=null,e):s},e.y0=function(n){return arguments.length?(s=typeof n=="function"?n:y(+n),e):s},e.y1=function(n){return arguments.length?(r=n==null?null:typeof n=="function"?n:y(+n),e):r},e.lineX0=e.lineY0=function(){return t().x(o).y(s)},e.lineY1=function(){return t().x(o).y(r)},e.lineX1=function(){return t().x(f).y(s)},e.defined=function(n){return arguments.length?(h=typeof n=="function"?n:y(!!n),e):h},e.curve=function(n){return arguments.length?(d=n,c!=null&&(l=d(c)),e):d},e.context=function(n){return arguments.length?(n==null?c=l=null:l=d(c=n),e):c},e}const J=[{fn:"f(x) = x^3",id:"tan",color:"red",samples:170,domain:[-10,10],range:[-10,10],integrate:{bounds:[-3,2],color:"gold"}}];function ln({functions:o=J,domain:s=[-10,10],range:r=[-10,10],ticks:f=10,width:h=j,height:c=H,margins:d=I,samples:l=170}){const[a,e]=L(h,c,d);return w(R,{width:h,height:c,margins:d,children:[u(W,{id:"plot2d",width:a,height:e}),w(_,{range:r,domain:s,width:a,height:e,children:[u(Z,{ticks:f}),u($,{ticks:f}),u("g",{clipPath:"url(#plot2d)",children:o.map(t=>w(Q,{fn:t.fn,children:[u(C,{color:t.color,children:u(en,{samples:t.samples||l,range:t.range,domain:t.domain})}),t.riemann&&!isNaN(t.riemann.domain[0])&&!isNaN(t.riemann.domain[1])&&u(C,{color:t.riemann.color,children:u(nn,{...t.riemann})}),t.integrate&&!isNaN(t.integrate.bounds[0])&&!isNaN(t.integrate.bounds[1])&&u(C,{fill:t.integrate.color,children:u(K,{samples:t.samples,bounds:t.integrate.bounds,max:t.domain[1]})})]},t.fn+t.id))})]})]})}function K({bounds:o,samples:s,max:r}){const[f,h]=o,{fx:c}=D(),{scaleX:d,scaleY:l}=S(),a=Math.abs(s),e=[],t=v.useMemo(()=>{for(let n=-a;n<a;n++){const i=n/a*r,g=i,x=i,m=c(g),p=0;f<i&&i<h&&e.push({x0:g,x1:x,y0:m,y1:p})}return q().defined(n=>!isNaN(n.y0)&&!isNaN(n.y1)).x0(n=>d(n.x0)).y0(n=>l(n.y0)).x1(n=>d(n.x1)).y1(n=>l(n.y1))(e)??""},[c,f,h]);return u("path",{d:t,opacity:.4,strokeWidth:1})}function C({color:o="",fill:s="",children:r}){return u("g",{stroke:o,fill:s,children:r})}const X=v.createContext({}),Q=({fn:o,children:s})=>{const r=G(o);return typeof r=="string"?null:u(X.Provider,{value:{fx:r},children:s})},D=()=>v.useContext(X);function Z({ticks:o}){const{scaleY:s,scaleX:r}=S();return u("g",{transform:M(r(0),0),children:u(T,{scale:s,ticks:o,direction:"y"})})}function $({ticks:o}){const{scaleY:s,scaleX:r}=S();return u("g",{transform:M(0,s(0)),children:u(T,{scale:r,ticks:o,direction:"x"})})}const Y=v.createContext({});function _({width:o,height:s,domain:r,range:f,children:h}){const c={scaleX:E.linear.x(r,o),scaleY:E.linear.y(f,s),domain:r,range:f};return u(Y.Provider,{value:c,children:h})}const S=()=>v.useContext(Y);function nn({domain:o,dx:s,method:r}){const{fx:f}=D(),h=o[0],c=o[1];if(h>c)return null;const{scaleX:d,scaleY:l}=S(),e=tn(o,d,l,f,s,r==="left"?t=>t/2:r==="right"?t=>-t/2:t=>t);return u(k,{children:e.map((t,n)=>w("g",{transform:M(t.xTranslate,0),children:[u("line",{strokeWidth:t.width,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,strokeOpacity:.1}),u("line",{strokeWidth:t.width-1,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,strokeOpacity:.4})]},"i"+t.x1+t.y2))})}function tn(o,s,r,f,h,c){const d=o[0],l=o[1],a=[];if(d>l)return a;for(let n=d;n<l;n+=h){const i=n,g=s(i),x=s(i),m=r(f(i)),p=r(0);a.push({x1:g,x2:x,y1:m,y2:p,width:0,xTranslate:0})}let e=0;if(!a.length)return a;let t=null;do{if(t===null)t=a[0];else{t=a[e];const n=a[e-1],i=a[e+1]||a[e],g=t.x1-n.x1;n.width=g,i.width=g,n.xTranslate=c(g),i.xTranslate=c(g)}e++}while(e<a.length);return a}function en({range:o,domain:s,samples:r}){const{scaleX:f,scaleY:h}=S(),{fx:c}=D(),d=v.useMemo(()=>{const l=[],a=o[0]*2,e=o[1]*2,t=s[0],n=s[1],i=Math.floor(Math.abs(r));for(let x=-i;x<i;x++){let m=x/r*n,p=c(m);const N=[m,p];(isNaN(p)||p<a||p>=e)&&(N[1]=NaN),!(m<t||n<m)&&l.push(N)}return F().y(x=>h(x[1])).defined(x=>!isNaN(x[1])).x(x=>f(x[0]))(l)??""},[s,o,r]);return u("path",{d,shapeRendering:"geometricPrecision",fill:"none"})}export{ln as default,J as defaults};
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.