{"version":3,"file":"dimensions.mjs","names":[],"sources":["../../../../../../../../@warlock.js/seal/src/rules/file/dimensions.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Min width rule - image width validation\r\n */\r\nexport const minWidthRule: SchemaRule<{ minWidth: number }> = {\r\n  name: \"minWidth\",\r\n  defaultErrorMessage: \"The :input must be at least :minWidth pixels wide\",\r\n  async validate(value: any, context) {\r\n    const dimensions = await value.dimensions();\r\n\r\n    if (dimensions.width >= this.context.options.minWidth) {\r\n      return VALID_RULE;\r\n    }\r\n\r\n    this.context.translationParams.minWidth = this.context.options.minWidth;\r\n\r\n    return invalidRule(this, context);\r\n  },\r\n};\r\n\r\n/**\r\n * Max width rule - image width validation\r\n */\r\nexport const maxWidthRule: SchemaRule<{ maxWidth: number }> = {\r\n  name: \"maxWidth\",\r\n  defaultErrorMessage: \"The :input must be at most :maxWidth pixels wide\",\r\n  async validate(value: any, context) {\r\n    const dimensions = await value.dimensions();\r\n\r\n    if (dimensions.width <= this.context.options.maxWidth) {\r\n      return VALID_RULE;\r\n    }\r\n\r\n    this.context.translationParams.maxWidth = this.context.options.maxWidth;\r\n\r\n    return invalidRule(this, context);\r\n  },\r\n};\r\n\r\n/**\r\n * Min height rule - image height validation\r\n */\r\nexport const minHeightRule: SchemaRule<{ minHeight: number }> = {\r\n  name: \"minHeight\",\r\n  defaultErrorMessage: \"The :input must be at least :minHeight pixels tall\",\r\n  async validate(value: any, context) {\r\n    const dimensions = await value.dimensions();\r\n\r\n    if (dimensions.height >= this.context.options.minHeight) {\r\n      return VALID_RULE;\r\n    }\r\n\r\n    this.context.translationParams.minHeight = this.context.options.minHeight;\r\n\r\n    return invalidRule(this, context);\r\n  },\r\n};\r\n\r\n/**\r\n * Max height rule - image height validation\r\n */\r\nexport const maxHeightRule: SchemaRule<{ maxHeight: number }> = {\r\n  name: \"maxHeight\",\r\n  defaultErrorMessage: \"The :input must be at most :maxHeight pixels tall\",\r\n  async validate(value: any, context) {\r\n    const dimensions = await value.dimensions();\r\n\r\n    if (dimensions.height <= this.context.options.maxHeight) {\r\n      return VALID_RULE;\r\n    }\r\n\r\n    this.context.translationParams.maxHeight = this.context.options.maxHeight;\r\n\r\n    return invalidRule(this, context);\r\n  },\r\n};\r\n"],"mappings":";;;;;;;AAMA,MAAa,eAAiD;CAC5D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,EAE5B,CAAC,SAAS,KAAK,QAAQ,QAAQ,UAC3C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,WAAW,KAAK,QAAQ,QAAQ;EAE/D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAAiD;CAC5D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,EAE5B,CAAC,SAAS,KAAK,QAAQ,QAAQ,UAC3C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,WAAW,KAAK,QAAQ,QAAQ;EAE/D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,EAE5B,CAAC,UAAU,KAAK,QAAQ,QAAQ,WAC5C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,EAE5B,CAAC,UAAU,KAAK,QAAQ,QAAQ,WAC5C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}