"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummaryBlockEdit=void 0;const i18n_1=require("@wordpress/i18n"),block_templates_1=require("@woocommerce/block-templates"),element_1=require("@wordpress/element"),components_1=require("@wordpress/components"),data_1=require("@wordpress/data"),core_data_1=require("@wordpress/core-data"),compose_1=require("@wordpress/compose"),classnames_1=__importDefault(require("classnames")),block_editor_1=require("@wordpress/block-editor"),paragraph_rtl_control_1=require("./paragraph-rtl-control"),constants_1=require("./constants");function SummaryBlockEdit({attributes:e,setAttributes:t,context:o}){const{align:r,allowedFormats:l,direction:a,label:n,helpText:c}=e,s=(0,block_templates_1.useWooBlockProps)(e,{style:{direction:a}}),i=(0,compose_1.useInstanceId)(SummaryBlockEdit,"wp-block-woocommerce-product-summary-field__content"),[m,_]=(0,core_data_1.useEntityProp)("postType",o.postType||"product",e.property),{clearSelectedBlock:p}=(0,data_1.useDispatch)(block_editor_1.store);return(0,element_1.createElement)("div",{className:"wp-block wp-block-woocommerce-product-summary-field-wrapper"},(0,element_1.createElement)(block_editor_1.BlockControls,{group:"block"},(0,element_1.createElement)(block_editor_1.AlignmentControl,{alignmentControls:constants_1.ALIGNMENT_CONTROLS,value:r,onChange:function(e){t({align:e})}}),(0,element_1.createElement)(paragraph_rtl_control_1.ParagraphRTLControl,{direction:a,onChange:function(e){t({direction:e})}})),(0,element_1.createElement)(components_1.BaseControl,{id:i.toString(),label:void 0===n?(0,element_1.createInterpolateElement)((0,i18n_1.__)("Summary","woocommerce"),{optional:(0,element_1.createElement)("span",{className:"woocommerce-product-form__optional-input"},(0,i18n_1.__)("(OPTIONAL)","woocommerce"))}):n,help:void 0===c?(0,i18n_1.__)("Summarize this product in 1-2 short sentences. We'll show it at the top of the page.","woocommerce"):c},(0,element_1.createElement)("div",{...s},(0,element_1.createElement)(block_editor_1.RichText,{id:i.toString(),identifier:"content",tagName:"p",value:m,onChange:_,"data-empty":Boolean(m),className:(0,classnames_1.default)("components-summary-control",{[`has-text-align-${r}`]:r}),dir:a,allowedFormats:l,onBlur:function(e){var t;(null===(t=e.relatedTarget)||void 0===t?void 0:t.closest(".block-editor-block-contextual-toolbar"))||p()}}))))}exports.SummaryBlockEdit=SummaryBlockEdit;