(()=>{"use strict";const e=window.wp.plugins,t=window.wp.element,r=window.wp.data,o=window.wp.editPost,d=window.wp.i18n,s=window.wp.components,i=window.ReactJSXRuntime;(0,e.registerPlugin)("pressforward-block-editor-feeds-infobox",{render:({})=>{const{editPost:e}=(0,r.useDispatch)("core/editor"),{feedPostType:t}=pfBlockEditorFeeds,{doImportTags:n,errorMessage:a,feedAuthor:l,feedUrl:c,postType:p}=(0,r.useSelect)((e=>{const t=e("core/editor").getCurrentPostId(),r=e("core/editor").getEditedPostAttribute("meta"),o=e("core/editor").getEditedPostAttribute("alert_message"),d=e("core/editor").getEditedPostAttribute("feed_author");return{doImportTags:e("core/editor").getEditedPostAttribute("do_import_tags"),errorMessage:o,feedAuthor:d,feedUrl:r?.feed_url||"",postId:t,postType:e("core/editor").getEditedPostAttribute("type")}}));return t===p?(0,i.jsxs)(o.PluginDocumentSettingPanel,{icon:"controls-forward",name:"pressforward-block-editor-feeds-infobox",title:(0,d.__)("Feed Information","pressforward"),children:[(0,i.jsx)(s.TextControl,{label:(0,d.__)("Feed URL","pressforward"),value:c,onChange:t=>{e({meta:{feed_url:t}})}}),(0,i.jsx)(s.TextControl,{label:(0,d.__)("Feed Author","pressforward"),value:l,onChange:t=>{e({feed_author:t})},help:(0,d.__)("Incoming items without an author name will use this value.","pressforward")}),(0,i.jsx)("hr",{}),(0,i.jsx)(s.ToggleControl,{label:(0,d.__)("Import Tags","pressforward"),checked:n,onChange:t=>{e({do_import_tags:t})},help:(0,d.__)("Import source tags with feed items?","pressforward")}),a&&(0,i.jsx)("p",{className:"pf-error-message",children:(0,i.jsx)("strong",{children:(0,d.sprintf)("Error: %s",a)})})]}):null}}),(0,e.registerPlugin)("pressforward-block-editor-feed-retrieval-infobox",{render:({})=>{const{feedPostType:e}=pfBlockEditorFeeds,[n,a]=(0,t.useState)(!1),{lastChecked:l,lastRetrieved:c,nextCheck:p,postId:f,postType:w}=(0,r.useSelect)((e=>({lastChecked:e("core/editor").getEditedPostAttribute("last_checked"),lastRetrieved:e("core/editor").getEditedPostAttribute("last_retrieved"),nextCheck:e("core/editor").getEditedPostAttribute("next_check"),postId:e("core/editor").getCurrentPostId(),postType:e("core/editor").getEditedPostAttribute("type")})));return e===w?(0,i.jsxs)(o.PluginDocumentSettingPanel,{icon:"controls-forward",name:"pressforward-block-editor-feed-retrieval-infobox",title:(0,d.__)("Retrieval","pressforward"),children:[(0,i.jsxs)("dl",{className:"pf-feed-retrieval-info",children:[(0,i.jsx)("dt",{children:(0,d.__)("This feed was last checked on:","pressforward")}),(0,i.jsx)("dd",{children:l||(0,d.__)("Never","pressforward")}),(0,i.jsx)("dt",{children:(0,d.__)("A new item was last fetched from the feed on:","pressforward")}),(0,i.jsx)("dd",{children:c||(0,d.__)("Never","pressforward")}),(0,i.jsx)("dt",{children:(0,d.__)("The next scheduled check of this feed will be on:","pressforward")}),(0,i.jsx)("dd",{children:p||(0,d.__)("None","pressforward")})]}),f&&(0,i.jsxs)("p",{children:[(0,i.jsx)(s.Button,{isSecondary:!0,disabled:n,onClick:()=>{const t=`${ajaxurl}?action=ajax_update_feed_handler&feed_id=${f}`,r=new URLSearchParams;r.append("feed_id",f),a(!0);const o={method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()};fetch(t,o).then((e=>e.json())).then((()=>{wp.data.dispatch("core").invalidateResolution("getEntityRecord",["postType",e,f]),wp.data.select("core").getEntityRecord("postType",e,f),a(!1)}))},children:(0,d.__)("Refresh Feed Now","pressforward")}),n&&(0,i.jsx)(s.Spinner,{isBusy:n})]})]}):null}})})();