"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Edit=void 0;const element_1=require("@wordpress/element"),block_templates_1=require("@woocommerce/block-templates"),i18n_1=require("@wordpress/i18n"),use_product_entity_prop_1=__importDefault(require("../../../hooks/use-product-entity-prop")),validation_context_1=require("../../../contexts/validation-context"),number_control_1=require("../../../components/number-control");function Edit({attributes:e,context:{postType:t}}){const o=(0,block_templates_1.useWooBlockProps)(e),{label:r,property:n,suffix:l,placeholder:i,help:u,min:a,max:_}=e,[s,p]=(0,use_product_entity_prop_1.default)(n,{postType:t,fallbackValue:""}),{error:c,validate:m}=(0,validation_context_1.useValidation)(n,(async function(){return"number"==typeof a&&s&&parseFloat(s)<a?(0,i18n_1.sprintf)((0,i18n_1.__)("Value must be greater than or equal to %d","woocommerce"),a):"number"==typeof _&&s&&parseFloat(s)>_?(0,i18n_1.sprintf)((0,i18n_1.__)("Value must be less than or equal to %d","woocommerce"),_):void 0}),[s]);return(0,element_1.createElement)("div",{...o},(0,element_1.createElement)(number_control_1.NumberControl,{label:r,onChange:p,value:s||"",help:u,suffix:l,placeholder:i,error:c,onBlur:m}))}exports.Edit=Edit;