import{regressionLoess as C,sampleCurve as U,regressionConstant as D,regressionLinear as R,regressionLog as j,regressionExp as N,regressionPow as I,regressionQuad as M,regressionPoly as P}from"/-/vega-statistics@v1.9.0-Qw8CjSQVQOg2M6VMgsme/dist=es2020,mode=imports,min/optimized/vega-statistics.js";import{Transform as w,ingest as x}from"/-/vega-dataflow@v5.7.6-WDoszrJUyhTwz7sPwzda/dist=es2020,mode=imports,min/optimized/vega-dataflow.js";import{inherits as z,accessorName as f,hasOwnProperty as Q,error as F,extent as T}from"/-/vega-util@v1.17.2-LUfkDhormMyfWqy3Ts6U/dist=es2020,mode=imports,min/optimized/vega-util.js";function L(e,r){var t=[],g=function(l){return l(i)},u,o,a,i,n,s;if(r==null)t.push(e);else for(u={},o=0,a=e.length;o{C(s,e.x,e.y,e.bandwidth||.3).forEach(l=>{const d={};for(let m=0;me==="poly"?r:e==="quad"?2:1;function O(e){w.call(this,null,e)}O.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(E)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]},z(O,w,{transform(e,r){const t=r.fork(r.NO_SOURCE|r.NO_FIELDS);if(!this.value||r.changed()||e.modified()){const g=r.materialize(r.SOURCE).source,u=L(g,e.groupby),o=(e.groupby||[]).map(f),a=e.method||"linear",i=e.order==null?3:e.order,n=V(a,i),s=e.as||[f(e.x),f(e.y)],l=E[a],d=[];let m=e.extent;Q(E,a)||F("Invalid regression method: "+a),m!=null&&(a==="log"&&m[0]<=0&&(r.dataflow.warn("Ignoring extent with values <= 0 for log regression."),m=null)),u.forEach(p=>{const k=p.length;if(k<=n){r.dataflow.warn("Skipping regression with more parameters than data points.");return}const h=l(p,e.x,e.y,i);if(e.params){d.push(x({keys:p.dims,coef:h.coef,rSquared:h.rSquared}));return}const S=m||T(p,e.x),q=c=>{const y={};for(let v=0;vq([c,h.predict(c)])):U(h.predict,S,25,200).forEach(q)}),this.value&&(t.rem=this.value),this.value=t.add=t.source=d}return t}});export{b as loess,O as regression};export default null;