"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(e,t,o,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===o||__defProp(e,n,{get:()=>t[n],enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),edit_exports={};__export(edit_exports,{Edit:()=>Edit}),module.exports=__toCommonJS(edit_exports);var import_i18n=require("@wordpress/i18n"),import_block_templates=require("@woocommerce/block-templates"),import_components=require("@woocommerce/components"),import_element=require("@wordpress/element"),import_settings=require("@woocommerce/settings"),import_compose=require("@wordpress/compose"),import_components2=require("@wordpress/components"),import_core_data=require("@wordpress/core-data"),import_validation_context=require("../../../contexts/validation-context");function Edit({attributes:e,clientId:t}){const o=(0,import_block_templates.useWooBlockProps)(e),r=(0,import_settings.getSetting)("notifyLowStockAmount",2),[n,m]=(0,import_core_data.useEntityProp)("postType","product","low_stock_amount"),i=(0,import_compose.useInstanceId)(import_components2.BaseControl,"low_stock_amount"),{ref:p,error:s,validate:_}=(0,import_validation_context.useValidation)(`low_stock_amount-${t}`,async function(){if(n&&n<0)return{message:(0,import_i18n.__)("This field must be a positive number.","woocommerce")}},[n]);return(0,import_element.createElement)(import_element.Fragment,null,(0,import_element.createElement)("div",{...o},(0,import_element.createElement)("div",{className:"wp-block-columns"},(0,import_element.createElement)("div",{className:"wp-block-column"},(0,import_element.createElement)(import_components2.BaseControl,{id:i,label:(0,import_i18n.__)("Email me when stock reaches","woocommerce"),help:s||(0,import_element.createInterpolateElement)((0,import_i18n.__)("Make sure to enable notifications in <link>store settings.</link>","woocommerce"),{link:(0,import_element.createElement)(import_components.Link,{href:`${(0,import_settings.getSetting)("adminUrl")}admin.php?page=wc-settings&tab=products&section=inventory`,target:"_blank",type:"external"})}),className:s&&"has-error"},(0,import_element.createElement)(import_components2.__experimentalInputControl,{id:i,ref:p,name:"low_stock_amount",placeholder:(0,import_i18n.sprintf)((0,import_i18n.__)("%d (store default)","woocommerce"),r),onChange:e=>{m(parseInt(e??"",10))},onBlur:async()=>await _(),value:n?.toString(),type:"number",min:0}))),(0,import_element.createElement)("div",{className:"wp-block-column"}))))}