import { C as error } from '../../../chunks/utils.js-mIi_c4Oz.js';
import { a as hasRole } from '../../../chunks/auth.js-D502gejJ.js';
import { g as getSetting } from '../../../chunks/db.js-le-jjQPv.js';
import { l as listCategories, a as listDevices } from '../../../chunks/queries.js-BUUEc74j.js';
import { L as LABEL_PRESETS } from '../../../chunks/labels-presets.js-DFpXmbAX.js';

const load = async ({ url, locals }) => {
  if (!hasRole(locals.user, "gestor")) throw error(403, "Sin permisos para generar etiquetas.");
  const preCode = url.searchParams.get("code")?.toUpperCase() || null;
  return {
    devices: listDevices(),
    categories: listCategories(),
    presets: LABEL_PRESETS,
    preCode,
    offsets: {
      x: Number(getSetting("label_offset_x_mm", "0")),
      y: Number(getSetting("label_offset_y_mm", "0"))
    }
  };
};

var _page_server_ts = /*#__PURE__*/Object.freeze({
  __proto__: null,
  load: load
});

export { _page_server_ts as _ };
//# sourceMappingURL=_page.server.ts.js-DDZz-wHe.js.map
