(()=>{"use strict";const e=window.React,t=window.wp.components,o=window.wp.data,r=window.wp.element,a=window.wp.i18n,n=()=>{const n="presto_player_instant_video_pages_enabled",{editPost:l}=(0,o.useDispatch)("core/editor"),s=(0,o.useSelect)(e=>e("core/editor").getEditedPostAttribute("meta"));let i=!(!s||!s[n])&&s[n];const[c,d]=(0,r.useState)(!1),p=(0,r.useRef)(null),u=()=>{d(e=>!e)};return(0,e.createElement)("div",null,(0,e.createElement)(t.Button,{variant:"tertiary",onClick:u,className:"presto-toolbar__button"},(0,e.createElement)("div",{className:"presto-toolbar__badge "+(i?"is-active":"")}),(0,a.__)("Instant Video Page","presto-player"),(0,e.createElement)("div",{className:"presto-toolbar__icon"},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6"},(0,e.createElement)("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"})))),c&&(0,e.createElement)(t.Popover,{placement:"bottom-end",shift:!0,anchor:p.current,resize:!1,onFocusOutside:u,className:"pp-instant-video-dropdown"},(0,e.createElement)("div",{className:"presto-toolbar__popover-content"},(0,e.createElement)(t.RadioControl,{label:(0,a.__)("Visibility","presto-player"),selected:i?"public":"private",options:[{label:(0,a.__)("Published","presto-player"),value:"public"},{label:(0,a.__)("Unpublished","presto-player"),value:"private"}],onChange:e=>{l({meta:{...s,[n]:"public"===e}})},className:"presto-toolbar__radio"}),(0,e.createElement)("p",{className:"presto-toolbar__description"},(0,a.__)("An instant video page gives you an instant shareable page for your media.","presto-player")))))};!function(t,o){const a=document.createElement("div");a.classList.add("presto-player-edit-root");const l=document.getElementById("editor");if(!l)return;const s=o.data.subscribe(function(){setTimeout(function(){if((0,r.render)((0,e.createElement)(n,null),a),!document.querySelector(".presto-player-edit-root")){const e=l.querySelector(".edit-post-header__settings")||l.querySelector(".editor-header__settings");e instanceof HTMLElement&&e.prepend(a)}},1)});document.querySelector(".presto-player-edit-root")&&s()}(window,wp)})();