import { f as a, c as i } from "../../webgpu_util-DuofJBMo.js";
import { b as h, e as d, c as n } from "../../webgpu_program-CbjdYLYk.js";
function p(r) {
  const e = r.length;
  if (e > 6)
    throw Error(`Transpose for rank ${e} is not yet supported`);
  const o = new Array(e);
  for (let t = 0; t < r.length; t++)
    o[r[t]] = `coords.${n(t)}`;
  return o.join();
}
class l {
  variableNames = ["A"];
  shaderKey;
  outputShape;
  dispatchLayout;
  dispatch;
  workPerThread = 1;
  workgroupSize = [64, 1, 1];
  newDim;
  size = !0;
  constructor(e, o) {
    const t = new Array(e.length);
    for (let s = 0; s < t.length; s++)
      t[s] = e[o[s]];
    this.outputShape = t, this.dispatchLayout = a(this.outputShape), this.dispatch = i(this.dispatchLayout, this.outputShape, this.workgroupSize, [
      this.workPerThread,
      1,
      1
    ]), this.newDim = o, this.shaderKey = `transpose16_${o}`;
  }
  getUserCode() {
    const e = h(this.outputShape.length), o = p(this.newDim);
    return `
      ${d("index")} {
        for(var i = 0; i < ${this.workPerThread}; i = i + 1) {
          let flatIndex = index * ${this.workPerThread} + i;
          if(flatIndex < uniforms.size) {
            let coords = getCoordsFromIndex(flatIndex);
            result[flatIndex] = A[getIndexFromCoords${this.outputShape.length}D(
              ${e}(${o}), uniforms.aShape)];
          }
        }
      }
    `;
  }
}
export {
  l as default
};
