| 10275 | ); |
| 10276 | } |
| 10277 | static makeFromEncoding(e, n) { |
| 10278 | const i = n.stack, |
| 10279 | { encoding: r } = n; |
| 10280 | if (!i) return null; |
| 10281 | const { groupbyChannels: o, fieldChannel: a, offset: s, impute: l } = i, |
| 10282 | c = o.map((e) => wa(r[e])).filter((e) => !!e), |
| 10283 | u = (function (e) { |
| 10284 | return e.stack.stackBy.reduce((e, t) => { |
| 10285 | const n = ma(t.fieldDef); |
| 10286 | return (n && e.push(n), e); |
| 10287 | }, []); |
| 10288 | })(n), |
| 10289 | f = n.encoding.order; |
| 10290 | let d; |
| 10291 | if (t.isArray(f) || Zo(f)) d = qn(f); |
| 10292 | else { |
| 10293 | const e = Xo(f) ? f.sort : "y" === a ? "descending" : "ascending"; |
| 10294 | d = u.reduce( |
| 10295 | (t, n) => ( |
| 10296 | t.field.includes(n) || (t.field.push(n), t.order.push(e)), |
| 10297 | t |
| 10298 | ), |
| 10299 | { field: [], order: [] }, |
| 10300 | ); |
| 10301 | } |
| 10302 | return new Kd(e, { |
| 10303 | dimensionFieldDefs: c, |
| 10304 | stackField: n.vgField(a), |
| 10305 | facetby: [], |
| 10306 | stackby: u, |
| 10307 | sort: d, |
| 10308 | offset: s, |
| 10309 | impute: l, |
| 10310 | as: [ |
| 10311 | n.vgField(a, { suffix: "start", forAs: !0 }), |
| 10312 | n.vgField(a, { suffix: "end", forAs: !0 }), |
| 10313 | ], |
| 10314 | }); |
| 10315 | } |
| 10316 | get stack() { |
| 10317 | return this._stack; |
| 10318 | } |