diff --git a/build/content-helper/dashboard-page.asset.php b/build/content-helper/dashboard-page.asset.php index d95036f79b..ca0d7efbe5 100644 --- a/build/content-helper/dashboard-page.asset.php +++ b/build/content-helper/dashboard-page.asset.php @@ -1 +1 @@ - array('react', 'react-dom', 'wp-dom-ready', 'wp-element'), 'version' => '18278c930ac085311870'); + array('react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '801d6f5bef2f27842da3'); diff --git a/build/content-helper/dashboard-page.js b/build/content-helper/dashboard-page.js index 3ed664bade..909bda5390 100644 --- a/build/content-helper/dashboard-page.js +++ b/build/content-helper/dashboard-page.js @@ -1 +1 @@ -!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,o={},u=null,c=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:a,type:e,key:u,ref:c,props:o,_owner:l.current}}t.Fragment=o,t.jsx=u,t.jsxs=u},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t=r(848),n=window.wp.domReady,a=r.n(n),o=window.wp.element,i=r(609),l=window.ReactDOM;function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}var m;function g(e,t,r){return void 0===r&&(r="/"),function(e,t,r,n){let a=F(("string"==typeof t?v(t):t).pathname||"/",r);if(null==a)return null;let o=y(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(o);let i=null;for(let e=0;null==i&&e{let i={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};i.relativePath.startsWith("/")&&(c(i.relativePath.startsWith(n),'Absolute route path "'+i.relativePath+'" nested under path "'+n+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),i.relativePath=i.relativePath.slice(n.length));let l=T([n,i.relativePath]),s=r.concat(i);e.children&&e.children.length>0&&(c(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),y(e.children,t,s,l)),(null!=e.path||e.index)&&t.push({path:l,score:C(l,e.index),routesMeta:s})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of w(e.path))a(e,t,r);else a(e,t)})),t}function w(e){let t=e.split("/");if(0===t.length)return[];let[r,...n]=t,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===n.length)return a?[o,""]:[o];let i=w(n.join("/")),l=[];return l.push(...i.map((e=>""===e?o:[o,e].join("/")))),a&&l.push(...i),l.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(m||(m={})),new Set(["lazy","caseSensitive","path","id","index","children"]);const x=/^:[\w-]+$/,b=3,E=2,S=1,R=10,_=-2,P=e=>"*"===e;function C(e,t){let r=e.split("/"),n=r.length;return r.some(P)&&(n+=_),t&&(n+=E),r.filter((e=>!P(e))).reduce(((e,t)=>e+(x.test(t)?b:""===t?S:R)),n)}function j(e,t,r){void 0===r&&(r=!1);let{routesMeta:n}=e,a={},o="/",i=[];for(let e=0;e(n.push({paramName:t,isOptional:null!=r}),r?"/?([^\\/]+)?":"/([^\\/]+)")));return e.endsWith("*")?(n.push({paramName:"*"}),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce(((e,t,r)=>{let{paramName:n,isOptional:a}=t;if("*"===n){let e=l[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}const s=l[r];return e[n]=a&&!s?void 0:(s||"").replace(/%2F/g,"/"),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function U(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return h(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function F(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}const T=e=>e.join("/").replace(/\/\/+/g,"/"),k=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/");Error;const L=["post","put","patch","delete"],B=(new Set(L),["get",...L]);function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t0))return null;e=r.matches}}let l=e,s=null==(a=r)?void 0:a.errors;if(null!=s){let e=l.findIndex((e=>e.route.id&&void 0!==(null==s?void 0:s[e.route.id])));e>=0||c(!1),l=l.slice(0,Math.min(l.length,e+1))}let u=!1,h=-1;if(r&&n&&n.v7_partialHydration)for(let e=0;e=0?l.slice(0,h+1):[l[0]];break}}}return l.reduceRight(((e,n,a)=>{let o,c=!1,p=null,d=null;var f;r&&(o=s&&n.route.id?s[n.route.id]:void 0,p=n.route.errorElement||J,u&&(h<0&&0===a?(Q[f="route-fallback"]||(Q[f]=!0),c=!0,d=null):h===a&&(c=!0,d=n.route.hydrateFallbackElement||null)));let v=t.concat(l.slice(0,a+1)),m=()=>{let t;return t=o?p:c?d:n.route.Component?i.createElement(n.route.Component,null):n.route.element?n.route.element:e,i.createElement(G,{match:n,routeContext:{outlet:e,matches:v,isDataRoute:null!=r},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||0===a)?i.createElement(Y,{location:r.location,revalidation:r.revalidation,component:p,error:o,children:m(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):m()}),null)}(w&&w.map((e=>Object.assign({},e,{params:Object.assign({},u,e.params),pathname:T([h,o.encodeLocation?o.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?h:T([h,o.encodeLocation?o.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,n,a);return r&&x?i.createElement(W.Provider,{value:{location:D({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:e.Pop}},x):x}function q(){let e=function(){var e;let t=i.useContext(N),r=function(){let e=i.useContext(A);return e||c(!1),e}(K.UseRouteError),n=function(){let e=function(){let e=i.useContext(I);return e||c(!1),e}(),t=e.matches[e.matches.length-1];return t.route.id||c(!1),t.route.id}(K.UseRouteError);return void 0!==t?t:null==(e=r.errors)?void 0:e[n]}(),t=function(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},t),r?i.createElement("pre",{style:n},r):null,null)}const J=i.createElement(q,null);class Y extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?i.createElement(I.Provider,{value:this.props.routeContext},i.createElement(N.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function G(e){let{routeContext:t,match:r,children:n}=e,a=i.useContext($);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),i.createElement(I.Provider,{value:t},n)}var K=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(K||{});const Q={},X={},Z=(e,t,r)=>{var n;X[n="⚠️ React Router Future Flag Warning: "+t+". You can use the `"+e+"` future flag to opt-in early. For more information, see "+r+"."]||(X[n]=!0,console.warn(n))};function ee(e){c(!1)}function te(t){let{basename:r="/",children:n=null,location:a,navigationType:o=e.Pop,navigator:l,static:s=!1,future:u}=t;z()&&c(!1);let h=r.replace(/^\/*/,"/"),p=i.useMemo((()=>({basename:h,navigator:l,static:s,future:D({v7_relativeSplatPath:!1},u)})),[h,u,l,s]);"string"==typeof a&&(a=v(a));let{pathname:d="/",search:f="",hash:m="",state:g=null,key:y="default"}=a,w=i.useMemo((()=>{let e=F(d,h);return null==e?null:{location:{pathname:e,search:f,hash:m,state:g,key:y},navigationType:o}}),[h,d,f,m,g,y,o]);return null==w?null:i.createElement(M.Provider,{value:p},i.createElement(W.Provider,{children:n,value:w}))}function re(e){let{children:t,location:r}=e;return V(ne(t),r)}function ne(e,t){void 0===t&&(t=[]);let r=[];return i.Children.forEach(e,((e,n)=>{if(!i.isValidElement(e))return;let a=[...t,n];if(e.type===i.Fragment)return void r.push.apply(r,ne(e.props.children,a));e.type!==ee&&c(!1),e.props.index&&e.props.children&&c(!1);let o={id:e.props.id||a.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(o.children=ne(e.props.children,a)),r.push(o)})),r}i.startTransition,new Promise((()=>{})),i.Component,new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);try{window.__reactRouterVersion="6"}catch(e){}new Map;const ae=i.startTransition;function oe(t){let{basename:r,children:n,future:a,window:o}=t,l=i.useRef();var m;null==l.current&&(l.current=(void 0===(m={window:o,v5Compat:!0})&&(m={}),function(t,r,n,a){void 0===a&&(a={});let{window:o=document.defaultView,v5Compat:i=!1}=a,l=o.history,h=e.Pop,v=null,m=g();function g(){return(l.state||{idx:null}).idx}function y(){h=e.Pop;let t=g(),r=null==t?null:t-m;m=t,v&&v({action:h,location:x.location,delta:r})}function w(e){let t="null"!==o.location.origin?o.location.origin:o.location.href,r="string"==typeof e?e:f(e);return r=r.replace(/ $/,"%20"),c(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==m&&(m=0,l.replaceState(s({},l.state,{idx:m}),""));let x={get action(){return h},get location(){return t(o,l)},listen(e){if(v)throw new Error("A history only accepts one active listener");return o.addEventListener(u,y),v=e,()=>{o.removeEventListener(u,y),v=null}},createHref(e){return r(o,e)},createURL:w,encodeLocation(e){let t=w(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){h=e.Push;let a=d(x.location,t,r);n&&n(a,t),m=g()+1;let s=p(a,m),u=x.createHref(a);try{l.pushState(s,"",u)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;o.location.assign(u)}i&&v&&v({action:h,location:x.location,delta:1})},replace:function(t,r){h=e.Replace;let a=d(x.location,t,r);n&&n(a,t),m=g();let o=p(a,m),s=x.createHref(a);l.replaceState(o,"",s),i&&v&&v({action:h,location:x.location,delta:0})},go(e){return l.go(e)}};return x}((function(e,t){let{pathname:r="/",search:n="",hash:a=""}=v(e.location.hash.substr(1));return r.startsWith("/")||r.startsWith(".")||(r="/"+r),d("",{pathname:r,search:n,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),n="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");n=-1===r?t:t.slice(0,r)}return n+"#"+("string"==typeof t?t:f(t))}),(function(e,t){h("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),m)));let g=l.current,[y,w]=i.useState({action:g.action,location:g.location}),{v7_startTransition:x}=a||{},b=i.useCallback((e=>{x&&ae?ae((()=>w(e))):w(e)}),[w,x]);return i.useLayoutEffect((()=>g.listen(b)),[g,b]),i.useEffect((()=>{return null!=(e=a)&&e.v7_startTransition||Z("v7_startTransition","React Router will begin wrapping state updates in `React.startTransition` in v7","https://reactrouter.com/v6/upgrading/future#v7_starttransition"),null!=e&&e.v7_relativeSplatPath||t&&t.v7_relativeSplatPath||Z("v7_relativeSplatPath","Relative route resolution within Splat routes is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath"),void(t&&(t.v7_fetcherPersist||Z("v7_fetcherPersist","The persistence behavior of fetchers is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist"),t.v7_normalizeFormMethod||Z("v7_normalizeFormMethod","Casing of `formMethod` fields is being normalized to uppercase in v7","https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod"),t.v7_partialHydration||Z("v7_partialHydration","`RouterProvider` hydration behavior is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_partialhydration"),t.v7_skipActionErrorRevalidation||Z("v7_skipActionErrorRevalidation","The revalidation behavior after 4xx/5xx `action` responses is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation")));var e,t}),[a]),i.createElement(te,{basename:r,children:n,location:y.location,navigationType:y.action,navigator:g,future:a})}var ie,le,se;l.flushSync,i.useId,"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement,(se=ie||(ie={})).UseScrollRestoration="useScrollRestoration",se.UseSubmit="useSubmit",se.UseSubmitFetcher="useSubmitFetcher",se.UseFetcher="useFetcher",se.useViewTransitionState="useViewTransitionState",function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(le||(le={}));var ue=function(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h1",{children:"Parse.ly Dashboard"}),(0,t.jsx)("p",{children:"Welcome to the main Parse.ly dashboard page."})]})},ce=function(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h1",{children:"Traffic Boost"}),(0,t.jsx)("p",{children:"This is where the amazing Traffic Boost implementation will live."})]})},he=function(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h1",{children:"Parse.ly Settings"}),(0,t.jsx)("p",{children:"This is a page for settings."})]})};a()((function(){(0,o.createRoot)(document.getElementById("parsely-dashboard-page")).render((0,t.jsx)(oe,{future:{v7_relativeSplatPath:!0,v7_startTransition:!0},children:(0,t.jsx)(pe,{})}))}));var pe=function(){var e=H();return(0,o.useEffect)((function(){var e=document.querySelector("#toplevel_page_parsely-dashboard-page .wp-submenu li a.wp-first-item");e&&e.setAttribute("href",window.location.pathname+window.location.search+"#/")}),[]),(0,o.useEffect)((function(){document.querySelectorAll("#toplevel_page_parsely-dashboard-page .wp-submenu li").forEach((function(t){var r,n=t.querySelector("a");(null===(r=null==n?void 0:n.getAttribute("href"))||void 0===r?void 0:r.split("#")[1])===e.pathname?(t.classList.add("current"),null==n||n.blur()):t.classList.remove("current")}))}),[e]),(0,t.jsxs)(re,{children:[(0,t.jsx)(ee,{path:"/",element:(0,t.jsx)(ue,{})}),(0,t.jsx)(ee,{path:"/traffic-boost",element:(0,t.jsx)(ce,{})}),(0,t.jsx)(ee,{path:"/settings",element:(0,t.jsx)(he,{})})]})}}()}(); \ No newline at end of file +!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,o={},u=null,c=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:a,type:e,key:u,ref:c,props:o,_owner:l.current}}t.Fragment=o,t.jsx=u,t.jsxs=u},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t=r(848),n=r(609),a=window.ReactDOM;function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}var h;function f(e,t,r){return void 0===r&&(r="/"),function(e,t,r,n){let a=C(("string"==typeof t?d(t):t).pathname||"/",r);if(null==a)return null;let o=v(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(o);let i=null;for(let e=0;null==i&&e{let i={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};i.relativePath.startsWith("/")&&(l(i.relativePath.startsWith(n),'Absolute route path "'+i.relativePath+'" nested under path "'+n+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),i.relativePath=i.relativePath.slice(n.length));let s=O([n,i.relativePath]),u=r.concat(i);e.children&&e.children.length>0&&(l(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+s+'".'),v(e.children,t,u,s)),(null!=e.path||e.index)&&t.push({path:s,score:P(s,e.index),routesMeta:u})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of m(e.path))a(e,t,r);else a(e,t)})),t}function m(e){let t=e.split("/");if(0===t.length)return[];let[r,...n]=t,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===n.length)return a?[o,""]:[o];let i=m(n.join("/")),l=[];return l.push(...i.map((e=>""===e?o:[o,e].join("/")))),a&&l.push(...i),l.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(h||(h={})),new Set(["lazy","caseSensitive","path","id","index","children"]);const g=/^:[\w-]+$/,y=3,w=2,S=1,x=10,b=-2,E=e=>"*"===e;function P(e,t){let r=e.split("/"),n=r.length;return r.some(E)&&(n+=b),t&&(n+=w),r.filter((e=>!E(e))).reduce(((e,t)=>e+(g.test(t)?y:""===t?S:x)),n)}function _(e,t,r){void 0===r&&(r=!1);let{routesMeta:n}=e,a={},o="/",i=[];for(let e=0;e(n.push({paramName:t,isOptional:null!=r}),r?"/?([^\\/]+)?":"/([^\\/]+)")));return e.endsWith("*")?(n.push({paramName:"*"}),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce(((e,t,r)=>{let{paramName:n,isOptional:a}=t;if("*"===n){let e=l[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}const s=l[r];return e[n]=a&&!s?void 0:(s||"").replace(/%2F/g,"/"),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function j(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return s(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function C(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&"/"!==n?null:e.slice(r)||"/"}const O=e=>e.join("/").replace(/\/\/+/g,"/"),T=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/");Error;const U=["post","put","patch","delete"],F=(new Set(U),["get",...U]);function L(){return L=Object.assign?Object.assign.bind():function(e){for(var t=1;t0))return null;e=r.matches}}let s=e,u=null==(o=r)?void 0:o.errors;if(null!=u){let e=s.findIndex((e=>e.route.id&&void 0!==(null==u?void 0:u[e.route.id])));e>=0||l(!1),s=s.slice(0,Math.min(s.length,e+1))}let c=!1,p=-1;if(r&&a&&a.v7_partialHydration)for(let e=0;e=0?s.slice(0,p+1):[s[0]];break}}}return s.reduceRight(((e,a,o)=>{let i,l=!1,d=null,h=null;var f;r&&(i=u&&a.route.id?u[a.route.id]:void 0,d=a.route.errorElement||z,c&&(p<0&&0===o?(G[f="route-fallback"]||(G[f]=!0),l=!0,h=null):p===o&&(l=!0,h=a.route.hydrateFallbackElement||null)));let v=t.concat(s.slice(0,o+1)),m=()=>{let t;return t=i?d:l?h:a.route.Component?n.createElement(a.route.Component,null):a.route.element?a.route.element:e,n.createElement(V,{match:a,routeContext:{outlet:e,matches:v,isDataRoute:null!=r},children:t})};return r&&(a.route.ErrorBoundary||a.route.errorElement||0===o)?n.createElement(J,{location:r.location,revalidation:r.revalidation,component:d,error:i,children:m(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):m()}),null)}(w&&w.map((e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:O([p,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?p:O([p,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),s,a,o);return r&&S?n.createElement(I.Provider,{value:{location:L({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:e.Pop}},S):S}function H(){let e=function(){var e;let t=n.useContext(M),r=function(){let e=n.useContext(N);return e||l(!1),e}(q.UseRouteError),a=function(){let e=function(){let e=n.useContext(A);return e||l(!1),e}(),t=e.matches[e.matches.length-1];return t.route.id||l(!1),t.route.id}(q.UseRouteError);return void 0!==t?t:null==(e=r.errors)?void 0:e[a]}(),t=function(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return n.createElement(n.Fragment,null,n.createElement("h2",null,"Unexpected Application Error!"),n.createElement("h3",{style:{fontStyle:"italic"}},t),r?n.createElement("pre",{style:a},r):null,null)}const z=n.createElement(H,null);class J extends n.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?n.createElement(A.Provider,{value:this.props.routeContext},n.createElement(M.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function V(e){let{routeContext:t,match:r,children:a}=e,o=n.useContext(k);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),n.createElement(A.Provider,{value:t},a)}var q=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(q||{});const G={},Y={},K=(e,t,r)=>{var n;Y[n="⚠️ React Router Future Flag Warning: "+t+". You can use the `"+e+"` future flag to opt-in early. For more information, see "+r+"."]||(Y[n]=!0,console.warn(n))};function Q(e){l(!1)}function X(t){let{basename:r="/",children:a=null,location:o,navigationType:i=e.Pop,navigator:s,static:u=!1,future:c}=t;D()&&l(!1);let p=r.replace(/^\/*/,"/"),h=n.useMemo((()=>({basename:p,navigator:s,static:u,future:L({v7_relativeSplatPath:!1},c)})),[p,c,s,u]);"string"==typeof o&&(o=d(o));let{pathname:f="/",search:v="",hash:m="",state:g=null,key:y="default"}=o,w=n.useMemo((()=>{let e=C(f,p);return null==e?null:{location:{pathname:e,search:v,hash:m,state:g,key:y},navigationType:i}}),[p,f,v,m,g,y,i]);return null==w?null:n.createElement(B.Provider,{value:h},n.createElement(I.Provider,{children:a,value:w}))}function Z(e){let{children:t,location:r}=e;return W(ee(t),r)}function ee(e,t){void 0===t&&(t=[]);let r=[];return n.Children.forEach(e,((e,a)=>{if(!n.isValidElement(e))return;let o=[...t,a];if(e.type===n.Fragment)return void r.push.apply(r,ee(e.props.children,o));e.type!==Q&&l(!1),e.props.index&&e.props.children&&l(!1);let i={id:e.props.id||o.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(i.children=ee(e.props.children,o)),r.push(i)})),r}n.startTransition,new Promise((()=>{})),n.Component,new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);try{window.__reactRouterVersion="6"}catch(e){}new Map;const te=n.startTransition;function re(t){let{basename:r,children:a,future:h,window:f}=t,v=n.useRef();var m;null==v.current&&(v.current=(void 0===(m={window:f,v5Compat:!0})&&(m={}),function(t,r,n,a){void 0===a&&(a={});let{window:s=document.defaultView,v5Compat:d=!1}=a,h=s.history,f=e.Pop,v=null,m=g();function g(){return(h.state||{idx:null}).idx}function y(){f=e.Pop;let t=g(),r=null==t?null:t-m;m=t,v&&v({action:f,location:S.location,delta:r})}function w(e){let t="null"!==s.location.origin?s.location.origin:s.location.href,r="string"==typeof e?e:p(e);return r=r.replace(/ $/,"%20"),l(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==m&&(m=0,h.replaceState(o({},h.state,{idx:m}),""));let S={get action(){return f},get location(){return t(s,h)},listen(e){if(v)throw new Error("A history only accepts one active listener");return s.addEventListener(i,y),v=e,()=>{s.removeEventListener(i,y),v=null}},createHref(e){return r(s,e)},createURL:w,encodeLocation(e){let t=w(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){f=e.Push;let a=c(S.location,t,r);n&&n(a,t),m=g()+1;let o=u(a,m),i=S.createHref(a);try{h.pushState(o,"",i)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;s.location.assign(i)}d&&v&&v({action:f,location:S.location,delta:1})},replace:function(t,r){f=e.Replace;let a=c(S.location,t,r);n&&n(a,t),m=g();let o=u(a,m),i=S.createHref(a);h.replaceState(o,"",i),d&&v&&v({action:f,location:S.location,delta:0})},go(e){return h.go(e)}};return S}((function(e,t){let{pathname:r="/",search:n="",hash:a=""}=d(e.location.hash.substr(1));return r.startsWith("/")||r.startsWith(".")||(r="/"+r),c("",{pathname:r,search:n,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),n="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");n=-1===r?t:t.slice(0,r)}return n+"#"+("string"==typeof t?t:p(t))}),(function(e,t){s("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),m)));let g=v.current,[y,w]=n.useState({action:g.action,location:g.location}),{v7_startTransition:S}=h||{},x=n.useCallback((e=>{S&&te?te((()=>w(e))):w(e)}),[w,S]);return n.useLayoutEffect((()=>g.listen(x)),[g,x]),n.useEffect((()=>{return null!=(e=h)&&e.v7_startTransition||K("v7_startTransition","React Router will begin wrapping state updates in `React.startTransition` in v7","https://reactrouter.com/v6/upgrading/future#v7_starttransition"),null!=e&&e.v7_relativeSplatPath||t&&t.v7_relativeSplatPath||K("v7_relativeSplatPath","Relative route resolution within Splat routes is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath"),void(t&&(t.v7_fetcherPersist||K("v7_fetcherPersist","The persistence behavior of fetchers is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist"),t.v7_normalizeFormMethod||K("v7_normalizeFormMethod","Casing of `formMethod` fields is being normalized to uppercase in v7","https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod"),t.v7_partialHydration||K("v7_partialHydration","`RouterProvider` hydration behavior is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_partialhydration"),t.v7_skipActionErrorRevalidation||K("v7_skipActionErrorRevalidation","The revalidation behavior after 4xx/5xx `action` responses is changing in v7","https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation")));var e,t}),[h]),n.createElement(X,{basename:r,children:a,location:y.location,navigationType:y.action,navigator:g,future:h})}var ne,ae,oe;a.flushSync,n.useId,"undefined"!=typeof window&&void 0!==window.document&&window.document.createElement,(oe=ne||(ne={})).UseScrollRestoration="useScrollRestoration",oe.UseSubmit="useSubmit",oe.UseSubmitFetcher="useSubmitFetcher",oe.UseFetcher="useFetcher",oe.useViewTransitionState="useViewTransitionState",function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(ae||(ae={}));var ie=window.wp.domReady,le=r.n(ie),se=window.wp.element,ue=window.wp.data,ce=function(){return ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'd7059d961c9fe0a71c34'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '91832340c46f7a9be8e6'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index e822c1e8f1..17cead64ce 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,4 +1,4 @@ -!function(){"use strict";var e={20:function(e,t,n){var r=n(609),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,s={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,r)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:u,props:s,_owner:a.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,n){e.exports=n(20)},609:function(e){e.exports=window.React}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){n.d({},{w:function(){return Sr},_:function(){return jr}});var e,t,r,i,s,o,a,l,c,u,p,d,f=n(848),h=window.wp.components,v=window.wp.data,g=window.wp.domReady,y=n.n(g);void 0!==window.wp&&(p=null!==(t=null===(e=window.wp.editor)||void 0===e?void 0:e.PluginDocumentSettingPanel)&&void 0!==t?t:null!==(i=null===(r=window.wp.editPost)||void 0===r?void 0:r.PluginDocumentSettingPanel)&&void 0!==i?i:null===(s=window.wp.editSite)||void 0===s?void 0:s.PluginDocumentSettingPanel,d=null!==(a=null===(o=window.wp.editor)||void 0===o?void 0:o.PluginSidebar)&&void 0!==a?a:null!==(c=null===(l=window.wp.editPost)||void 0===l?void 0:l.PluginSidebar)&&void 0!==c?c:null===(u=window.wp.editSite)||void 0===u?void 0:u.PluginSidebar);var m,w,b,_=window.wp.element,x=window.wp.i18n,k=window.wp.primitives,S=(0,f.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,f.jsx)(k.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})}),j=window.wp.plugins,P=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,s=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=1e4&&(clearInterval(s),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),T=(P.trackEvent,function(){return(0,f.jsx)(h.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,f.jsx)(h.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),E=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,i=void 0===r?"wp-parsely-icon":r;return(0,f.jsxs)(h.SVG,{className:i,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},L=function(){return L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0?"".concat(i," ").concat(n):n)||this).hint=null,s.name=s.constructor.name,s.code=r;var o=[U.AccessToFeatureDisabled,U.ParselyApiForbidden,U.ParselyApiResponseContainsError,U.ParselyApiReturnedNoData,U.ParselyApiReturnedTooManyResults,U.PluginCredentialsNotSetMessageDetected,U.PluginSettingsApiSecretNotSet,U.PluginSettingsSiteIdNotSet,U.PostIsNotPublished,U.UnknownError,U.ParselySuggestionsApiAuthUnavailable,U.ParselySuggestionsApiNoAuthentication,U.ParselySuggestionsApiNoAuthorization,U.ParselySuggestionsApiNoData,U.ParselySuggestionsApiSchemaError];return s.retryFetch=!o.includes(s.code),Object.setPrototypeOf(s,t.prototype),s.code===U.AccessToFeatureDisabled?s.message=(0,x.__)("Access to this feature is disabled by the site's administration.","wp-parsely"):s.code===U.ParselySuggestionsApiNoAuthorization?s.message=(0,x.__)('This AI-powered feature is opt-in. To gain access, please submit a request here.',"wp-parsely"):s.code===U.ParselySuggestionsApiOpenAiError||s.code===U.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,x.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===U.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,x.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===U.ParselySuggestionsApiSchemaError?s.message=(0,x.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===U.ParselySuggestionsApiNoData?s.message=(0,x.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===U.ParselySuggestionsApiOpenAiSchema?s.message=(0,x.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===U.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,x.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return ee(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[U.PluginCredentialsNotSetMessageDetected,U.PluginSettingsSiteIdNotSet,U.PluginSettingsApiSecretNotSet].includes(this.code)?X(e):(this.code===U.FetchError&&(this.hint=this.Hint((0,x.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==U.ParselyApiForbidden&&this.code!==U.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,x.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===U.HttpRequestFailed&&(this.hint=this.Hint((0,x.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,f.jsx)(Q,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,x.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,v.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),ne=window.wp.compose,re=(0,f.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,f.jsx)(k.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),ie=(0,_.forwardRef)((function({icon:e,size:t=24,...n},r){return(0,_.cloneElement)(e,{width:t,height:t,...n,ref:r})})),se=function(){return(0,f.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:(0,f.jsx)(h.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M13.5034 7.91642L9 12.0104L4.49662 7.91642L5.25337 7.08398L8.99999 10.49L12.7466 7.08398L13.5034 7.91642Z",fill:"#1E1E1E"})})},oe={journalist:{label:(0,x.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,x.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,x.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,x.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,x.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,x.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,x.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,x.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,x.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,x.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,x.__)("Custom Persona","wp-parsely"),icon:re}},ae=Object.keys(oe),le=function(e){return"custom"===e||""===e?oe.custom.label:ce(e)?e:oe[e].label},ce=function(e){return!ae.includes(e)||"custom"===e},ue=function(e){var t=e.value,n=e.onChange,r=(0,_.useState)(""),i=r[0],s=r[1],o=(0,ne.useDebounce)(n,500);return(0,f.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,f.jsx)(h.TextControl,{value:i||t,placeholder:(0,x.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void s("");e.length>32&&(e=e.slice(0,32)),o(e),s(e)}})})},pe=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,x.__)("Select a persona…","wp-parsely"):n,i=e.label,s=void 0===i?(0,x.__)("Persona","wp-parsely"):i,o=e.onChange,a=e.onDropdownChange,l=e.disabled,c=void 0!==l&&l,u=e.allowCustom,p=void 0!==u&&u;return(0,f.jsxs)(h.Disabled,{isDisabled:c,children:[s&&(0,f.jsx)("div",{className:"wp-parsely-dropdown-label",children:s}),(0,f.jsx)(h.DropdownMenu,{label:(0,x.__)("Persona","wp-parsely"),className:"parsely-persona-selector-dropdown"+(c?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"parsely-persona-selector-label",children:ce(t)?oe.custom.label:r}),(0,f.jsx)(se,{})]})},children:function(e){var n=e.onClose;return(0,f.jsx)(h.MenuGroup,{label:(0,x.__)("Persona","wp-parsely"),children:(0,f.jsx)(f.Fragment,{children:ae.map((function(e){if(!p&&"custom"===e)return null;var r=oe[e],i=e===t||ce(t)&&"custom"===e;return(0,f.jsxs)(h.MenuItem,{isSelected:i,className:i?"is-selected":"",role:"menuitemradio",onClick:function(){null==a||a(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-persona-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,f.jsx)(ie,{icon:r.icon}),r.label]},e)}))})})}}),p&&ce(t)&&(0,f.jsx)(ue,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},de={neutral:{label:(0,x.__)("Neutral","wp-parsely")},formal:{label:(0,x.__)("Formal","wp-parsely")},humorous:{label:(0,x.__)("Humorous","wp-parsely")},confident:{label:(0,x.__)("Confident","wp-parsely")},provocative:{label:(0,x.__)("Provocative","wp-parsely")},serious:{label:(0,x.__)("Serious","wp-parsely")},inspirational:{label:(0,x.__)("Inspirational","wp-parsely")},skeptical:{label:(0,x.__)("Skeptical","wp-parsely")},conversational:{label:(0,x.__)("Conversational","wp-parsely")},analytical:{label:(0,x.__)("Analytical","wp-parsely")},custom:{label:(0,x.__)("Custom Tone","wp-parsely"),icon:re}},fe=Object.keys(de),he=function(e){return"custom"===e||""===e?de.custom.label:ve(e)?e:de[e].label},ve=function(e){return!fe.includes(e)||"custom"===e},ge=function(e){var t=e.value,n=e.onChange,r=(0,_.useState)(""),i=r[0],s=r[1],o=(0,ne.useDebounce)(n,500);return(0,f.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,f.jsx)(h.TextControl,{value:i||t,placeholder:(0,x.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void s("");e.length>32&&(e=e.slice(0,32)),o(e),s(e)}})})},ye=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,x.__)("Select a tone","wp-parsely"):n,i=e.label,s=void 0===i?(0,x.__)("Tone","wp-parsely"):i,o=e.onChange,a=e.onDropdownChange,l=e.disabled,c=void 0!==l&&l,u=e.allowCustom,p=void 0!==u&&u;return(0,f.jsxs)(h.Disabled,{isDisabled:c,children:[(0,f.jsx)("div",{className:"wp-parsely-dropdown-label",children:s}),(0,f.jsx)(h.DropdownMenu,{label:(0,x.__)("Tone","wp-parsely"),className:"parsely-tone-selector-dropdown"+(c?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"parsely-tone-selector-label",children:ve(t)?de.custom.label:r}),(0,f.jsx)(se,{})]})},children:function(e){var n=e.onClose;return(0,f.jsx)(h.MenuGroup,{label:(0,x.__)("Select a tone","wp-parsely"),children:(0,f.jsx)(f.Fragment,{children:fe.map((function(e){if(!p&&"custom"===e)return null;var r=de[e],i=e===t||ve(t)&&"custom"===e;return(0,f.jsxs)(h.MenuItem,{isSelected:i,className:i?"is-selected":"",role:"menuitemradio",onClick:function(){null==a||a(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-tone-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,f.jsx)(ie,{icon:r.icon}),r.label]},e)}))})})}}),p&&ve(t)&&(0,f.jsx)(ge,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},me=function(e){var t=e.isLoading,n=e.onPersonaChange,r=e.onToneChange,i=e.persona,s=e.tone;return(0,f.jsxs)("div",{className:"excerpt-suggestions-settings",children:[(0,f.jsx)(ye,{tone:s,value:he(s),onChange:function(e){r(e)},onDropdownChange:function(e){P.trackEvent("excerpt_generator_ai_tone_changed",{selectedTone:e})},disabled:t,allowCustom:!0}),(0,f.jsx)(pe,{persona:i,value:le(i),onChange:function(e){n(e)},onDropdownChange:function(e){P.trackEvent("excerpt_generator_ai_persona_changed",{persona:e})},disabled:t,allowCustom:!0})]})},we=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,o,a;return function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0?(0,x.sprintf)( +!function(){"use strict";var e={20:function(e,t,n){var r=n(609),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,s={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,r)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:u,props:s,_owner:a.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,n){e.exports=n(20)},609:function(e){e.exports=window.React}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){n.d({},{w:function(){return Sr},_:function(){return jr}});var e,t,r,i,s,o,a,l,c,u,p,d,f=n(848),h=window.wp.components,v=window.wp.data,g=window.wp.domReady,y=n.n(g);void 0!==window.wp&&(p=null!==(t=null===(e=window.wp.editor)||void 0===e?void 0:e.PluginDocumentSettingPanel)&&void 0!==t?t:null!==(i=null===(r=window.wp.editPost)||void 0===r?void 0:r.PluginDocumentSettingPanel)&&void 0!==i?i:null===(s=window.wp.editSite)||void 0===s?void 0:s.PluginDocumentSettingPanel,d=null!==(a=null===(o=window.wp.editor)||void 0===o?void 0:o.PluginSidebar)&&void 0!==a?a:null!==(c=null===(l=window.wp.editPost)||void 0===l?void 0:l.PluginSidebar)&&void 0!==c?c:null===(u=window.wp.editSite)||void 0===u?void 0:u.PluginSidebar);var m,w,b,_=window.wp.element,x=window.wp.i18n,k=window.wp.primitives,S=(0,f.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,f.jsx)(k.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})}),j=window.wp.plugins,P=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,s=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=1e4&&(clearInterval(s),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),T=(P.trackEvent,function(){return(0,f.jsx)(h.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,f.jsx)(h.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),E=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,i=void 0===r?"wp-parsely-icon":r;return(0,f.jsxs)(h.SVG,{className:i,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,f.jsx)(h.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},L=function(){return L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0?"".concat(i," ").concat(n):n)||this).hint=null,s.name=s.constructor.name,s.code=r;var o=[U.AccessToFeatureDisabled,U.ParselyApiForbidden,U.ParselyApiResponseContainsError,U.ParselyApiReturnedNoData,U.ParselyApiReturnedTooManyResults,U.PluginCredentialsNotSetMessageDetected,U.PluginSettingsApiSecretNotSet,U.PluginSettingsSiteIdNotSet,U.PostIsNotPublished,U.UnknownError,U.ParselySuggestionsApiAuthUnavailable,U.ParselySuggestionsApiNoAuthentication,U.ParselySuggestionsApiNoAuthorization,U.ParselySuggestionsApiNoData,U.ParselySuggestionsApiSchemaError];return s.retryFetch=!o.includes(s.code),Object.setPrototypeOf(s,t.prototype),s.code===U.AccessToFeatureDisabled?s.message=(0,x.__)("Access to this feature is disabled by the site's administration.","wp-parsely"):s.code===U.ParselySuggestionsApiNoAuthorization?s.message=(0,x.__)('This AI-powered feature is opt-in. To gain access, please submit a request here.',"wp-parsely"):s.code===U.ParselySuggestionsApiOpenAiError||s.code===U.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,x.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===U.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,x.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===U.ParselySuggestionsApiSchemaError?s.message=(0,x.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===U.ParselySuggestionsApiNoData?s.message=(0,x.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===U.ParselySuggestionsApiOpenAiSchema?s.message=(0,x.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===U.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,x.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return ee(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[U.PluginCredentialsNotSetMessageDetected,U.PluginSettingsSiteIdNotSet,U.PluginSettingsApiSecretNotSet].includes(this.code)?X(e):(this.code===U.FetchError&&(this.hint=this.Hint((0,x.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==U.ParselyApiForbidden&&this.code!==U.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,x.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===U.HttpRequestFailed&&(this.hint=this.Hint((0,x.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,f.jsx)(Q,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,x.__)("Hint:","wp-parsely")," ").concat(e,"

")},t.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,v.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),ne=window.wp.compose,re=(0,f.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,f.jsx)(k.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),ie=(0,_.forwardRef)((function({icon:e,size:t=24,...n},r){return(0,_.cloneElement)(e,{width:t,height:t,...n,ref:r})})),se=function(){return(0,f.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:(0,f.jsx)(h.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M13.5034 7.91642L9 12.0104L4.49662 7.91642L5.25337 7.08398L8.99999 10.49L12.7466 7.08398L13.5034 7.91642Z",fill:"#1E1E1E"})})},oe={journalist:{label:(0,x.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,x.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,x.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,x.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,x.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,x.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,x.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,x.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,x.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,x.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,x.__)("Custom Persona","wp-parsely"),icon:re}},ae=Object.keys(oe),le=function(e){return"custom"===e||""===e?oe.custom.label:ce(e)?e:oe[e].label},ce=function(e){return!ae.includes(e)||"custom"===e},ue=function(e){var t=e.value,n=e.onChange,r=(0,_.useState)(""),i=r[0],s=r[1],o=(0,ne.useDebounce)(n,500);return(0,f.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,f.jsx)(h.TextControl,{value:i||t,placeholder:(0,x.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void s("");e.length>32&&(e=e.slice(0,32)),o(e),s(e)}})})},pe=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,x.__)("Select a persona…","wp-parsely"):n,i=e.label,s=void 0===i?(0,x.__)("Persona","wp-parsely"):i,o=e.onChange,a=e.onDropdownChange,l=e.disabled,c=void 0!==l&&l,u=e.allowCustom,p=void 0!==u&&u;return(0,f.jsxs)(h.Disabled,{isDisabled:c,children:[s&&(0,f.jsx)("div",{className:"wp-parsely-dropdown-label",children:s}),(0,f.jsx)(h.DropdownMenu,{label:(0,x.__)("Persona","wp-parsely"),className:"parsely-persona-selector-dropdown"+(c?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"parsely-persona-selector-label",children:ce(t)?oe.custom.label:r}),(0,f.jsx)(se,{})]})},children:function(e){var n=e.onClose;return(0,f.jsx)(h.MenuGroup,{label:(0,x.__)("Persona","wp-parsely"),children:(0,f.jsx)(f.Fragment,{children:ae.map((function(e){if(!p&&"custom"===e)return null;var r=oe[e],i=e===t||ce(t)&&"custom"===e;return(0,f.jsxs)(h.MenuItem,{isSelected:i,className:i?"is-selected":"",role:"menuitemradio",onClick:function(){null==a||a(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-persona-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,f.jsx)(ie,{icon:r.icon}),r.label]},e)}))})})}}),p&&ce(t)&&(0,f.jsx)(ue,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},de={neutral:{label:(0,x.__)("Neutral","wp-parsely")},formal:{label:(0,x.__)("Formal","wp-parsely")},humorous:{label:(0,x.__)("Humorous","wp-parsely")},confident:{label:(0,x.__)("Confident","wp-parsely")},provocative:{label:(0,x.__)("Provocative","wp-parsely")},serious:{label:(0,x.__)("Serious","wp-parsely")},inspirational:{label:(0,x.__)("Inspirational","wp-parsely")},skeptical:{label:(0,x.__)("Skeptical","wp-parsely")},conversational:{label:(0,x.__)("Conversational","wp-parsely")},analytical:{label:(0,x.__)("Analytical","wp-parsely")},custom:{label:(0,x.__)("Custom Tone","wp-parsely"),icon:re}},fe=Object.keys(de),he=function(e){return"custom"===e||""===e?de.custom.label:ve(e)?e:de[e].label},ve=function(e){return!fe.includes(e)||"custom"===e},ge=function(e){var t=e.value,n=e.onChange,r=(0,_.useState)(""),i=r[0],s=r[1],o=(0,ne.useDebounce)(n,500);return(0,f.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,f.jsx)(h.TextControl,{value:i||t,placeholder:(0,x.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void s("");e.length>32&&(e=e.slice(0,32)),o(e),s(e)}})})},ye=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,x.__)("Select a tone","wp-parsely"):n,i=e.label,s=void 0===i?(0,x.__)("Tone","wp-parsely"):i,o=e.onChange,a=e.onDropdownChange,l=e.disabled,c=void 0!==l&&l,u=e.allowCustom,p=void 0!==u&&u;return(0,f.jsxs)(h.Disabled,{isDisabled:c,children:[(0,f.jsx)("div",{className:"wp-parsely-dropdown-label",children:s}),(0,f.jsx)(h.DropdownMenu,{label:(0,x.__)("Tone","wp-parsely"),className:"parsely-tone-selector-dropdown"+(c?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"parsely-tone-selector-label",children:ve(t)?de.custom.label:r}),(0,f.jsx)(se,{})]})},children:function(e){var n=e.onClose;return(0,f.jsx)(h.MenuGroup,{label:(0,x.__)("Select a tone","wp-parsely"),children:(0,f.jsx)(f.Fragment,{children:fe.map((function(e){if(!p&&"custom"===e)return null;var r=de[e],i=e===t||ve(t)&&"custom"===e;return(0,f.jsxs)(h.MenuItem,{isSelected:i,className:i?"is-selected":"",role:"menuitemradio",onClick:function(){null==a||a(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-tone-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,f.jsx)(ie,{icon:r.icon}),r.label]},e)}))})})}}),p&&ve(t)&&(0,f.jsx)(ge,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},me=function(e){var t=e.isLoading,n=e.onPersonaChange,r=e.onToneChange,i=e.persona,s=e.tone;return(0,f.jsxs)("div",{className:"excerpt-suggestions-settings",children:[(0,f.jsx)(ye,{tone:s,value:he(s),onChange:function(e){r(e)},onDropdownChange:function(e){P.trackEvent("excerpt_generator_ai_tone_changed",{selectedTone:e})},disabled:t,allowCustom:!0}),(0,f.jsx)(pe,{persona:i,value:le(i),onChange:function(e){n(e)},onDropdownChange:function(e){P.trackEvent("excerpt_generator_ai_persona_changed",{persona:e})},disabled:t,allowCustom:!0})]})},we=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,o,a;return function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0?(0,x.sprintf)( // Translators: %1$s the number of words in the excerpt. // Translators: %1$s the number of words in the excerpt. (0,x._n)("%1$s word","%1$s words",e,"wp-parsely"),e):"")}),[u.currentExcerpt,D]),(0,_.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[u.newExcerptGeneratedCount]);var G=(0,f.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,f.jsx)(E,{size:16}),(0,f.jsxs)("div",{className:"wp-parsely-excerpt-generator-header-label",children:[(0,x.__)("Generate With Parse.ly","wp-parsely"),(0,f.jsx)("span",{className:"beta-label",children:(0,x.__)("Beta","wp-parsely")})]})]}),H=n?(0,x.__)("Write an excerpt (optional)","wp-parsely"):(0,x.__)("Excerpt","wp-parsely");return(0,f.jsxs)("div",{className:"editor-post-excerpt",children:[!n&&(0,f.jsxs)("div",{className:"excerpt-suggestions-text",children:[(0,x.__)("Use Parse.ly AI to generate a concise, engaging excerpt for your post.","wp-parsely"),(0,f.jsxs)(h.Button,{href:"https://docs.wpvip.com/parse-ly/wp-parsely-features/excerpt-suggestions/",target:"_blank",variant:"link",rel:"noopener",children:[(0,x.__)("Learn more about Parse.ly AI","wp-parsely"),(0,f.jsx)(h.Icon,{icon:Y,size:18,className:"parsely-external-link-icon"})]})]}),(0,f.jsxs)("div",{style:{position:"relative"},children:[g&&(0,f.jsx)("div",{className:"editor-post-excerpt__loading_animation",children:(0,f.jsx)(Te,{})}),(0,f.jsx)(h.TextareaControl,{__nextHasNoMarginBottom:!0,label:H,className:"editor-post-excerpt__textarea",onChange:function(e){u.isUnderReview||I({excerpt:e}),p(ke(ke({},u),{currentExcerpt:e})),b(!0)},onKeyUp:function(){var e;if(w)b(!1);else{var t=document.querySelector(".editor-post-excerpt textarea"),n=null!==(e=null==t?void 0:t.textContent)&&void 0!==e?e:"";p(ke(ke({},u),{currentExcerpt:n}))}},value:g?"":u.isUnderReview?u.currentExcerpt:D,help:A||null})]}),n&&(0,f.jsxs)(h.Button,{href:(0,x.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt"),target:"_blank",variant:"link",rel:"noopener",children:[(0,x.__)("Learn more about manual excerpts","wp-parsely"),(0,f.jsx)(h.Icon,{icon:Y,size:18,className:"parsely-external-link-icon"})]}),(0,f.jsxs)("div",{className:"wp-parsely-excerpt-generator"+(n?" is-doc-set-panel":""),children:[a&&(0,f.jsx)(h.Notice,{className:"wp-parsely-excerpt-generator-error",onRemove:function(){return l(void 0)},status:"info",children:a.Message()}),u.isUnderReview?(0,f.jsxs)(f.Fragment,{children:[n&&G,(0,f.jsxs)("div",{className:"wp-parsely-excerpt-suggestions-review-controls",children:[(0,f.jsx)(h.Button,{variant:"secondary",onClick:function(){return Se(void 0,void 0,void 0,(function(){return je(this,(function(e){switch(e.label){case 0:return[4,I({excerpt:u.currentExcerpt})];case 1:return e.sent(),p(ke(ke({},u),{isUnderReview:!1})),P.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,x.__)("Accept","wp-parsely")}),(0,f.jsx)(h.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return Se(void 0,void 0,void 0,(function(){return je(this,(function(e){return I({excerpt:u.oldExcerpt}),p(ke(ke({},u),{currentExcerpt:u.oldExcerpt,isUnderReview:!1})),P.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,x.__)("Discard","wp-parsely")})]})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(me,{isLoading:g,onPersonaChange:function(e){R("Persona",e),j(e)},onSettingChange:R,onToneChange:function(e){R("Tone",e),C(e)},persona:i.ExcerptSuggestions.Persona,tone:i.ExcerptSuggestions.Tone}),n&&G,(0,f.jsx)("div",{className:"excerpt-suggestions-generate",children:(0,f.jsxs)(h.Button,{onClick:function(){return Se(void 0,void 0,void 0,(function(){var e,t;return je(this,(function(n){switch(n.label){case 0:y(!0),l(void 0),n.label=1;case 1:return n.trys.push([1,3,4,5]),P.trackEvent("excerpt_generator_pressed"),[4,xe.getInstance().generateExcerpt(V,F,S,L)];case 2:return e=n.sent(),p({currentExcerpt:e,isUnderReview:!0,newExcerptGeneratedCount:u.newExcerptGeneratedCount+1,oldExcerpt:D}),[3,5];case 3:return(t=n.sent())instanceof te?l(t):(l(new te((0,x.__)("An unknown error occurred.","wp-parsely"),U.UnknownError)),console.error(t)),[3,5];case 4:return y(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:g,disabled:g||!F,children:[g&&(0,x.__)("Generating Excerpt…","wp-parsely"),!g&&u.newExcerptGeneratedCount>0&&(0,x.__)("Regenerate Excerpt","wp-parsely"),!g&&0===u.newExcerptGeneratedCount&&(0,x.__)("Generate Excerpt","wp-parsely")]})})]}),n&&(0,f.jsxs)(h.Button,{href:"https://docs.wpvip.com/parse-ly/wp-parsely-features/excerpt-suggestions/",target:"_blank",variant:"link",rel:"noopener",children:[(0,x.__)("Learn more about Parse.ly AI","wp-parsely"),(0,f.jsx)(h.Icon,{icon:Y,size:18,className:"parsely-external-link-icon"})]})]})]})},Te=function(){return(0,f.jsx)(h.Animate,{type:"loading",children:function(e){var t=e.className;return(0,f.jsx)("span",{className:t,children:(0,x.__)("Generating…","wp-parsely")})}})},Ee=function(){return(0,f.jsx)(q.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,f.jsx)(p,{name:"parsely-post-excerpt",title:(0,x.__)("Excerpt","wp-parsely"),children:(0,f.jsx)(D,{endpoint:"editor-sidebar",defaultSettings:jr(window.wpParselyContentHelperSettings),children:(0,f.jsx)(Pe,{isDocumentSettingPanel:!0})})})})},Le=function(e,t){var n,r,i;return t!==Sr?e:H().ExcerptSuggestions?((null===(n=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===n?void 0:n.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,$.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,j.registerPlugin)("wp-parsely-excerpt-suggestions",{render:function(){return(0,f.jsx)(Ee,{})}}),(null===(r=(0,v.dispatch)("core/editor"))||void 0===r?void 0:r.removeEditorPanel)?null===(i=(0,v.dispatch)("core/editor"))||void 0===i||i.removeEditorPanel("post-excerpt"):null==Z||Z.removeEditorPanel("post-excerpt"),e):e};function Ce(){(0,$.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-suggestions",Le,1e3)}var Ne=window.wp.blockEditor;function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Oe=function(){return Oe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0)return r(e.innerBlocks,t[s].innerBlocks);if(JSON.stringify(e)!==JSON.stringify(t[s])){var o=t[s],a=i.parseFromString(e.attributes.content||"","text/html"),l=i.parseFromString((null==o?void 0:o.attributes.content)||"","text/html"),c=Array.from(a.querySelectorAll("a[data-smartlink]")),u=Array.from(l.querySelectorAll("a[data-smartlink]")),p=c.filter((function(e){return!u.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),d=u.filter((function(e){return!c.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),f=c.filter((function(e){var t=u.find((function(t){return t.dataset.smartlink===e.dataset.smartlink}));return t&&t.outerHTML!==e.outerHTML}));(p.length>0||d.length>0||f.length>0)&&n.push({block:e,prevBlock:o,addedLinks:p,removedLinks:d,changedLinks:f})}}}))};return r(e,t),n}(a,l.current);o.length>0&&(o.forEach((function(e){e.changedLinks.length>0&&n&&n(e),e.addedLinks.length>0&&i&&i(e),e.removedLinks.length>0&&r&&r(e)})),l.current=a)}),o);return e(t),function(){e.cancel()}}),[a,o,t,i,n,r]),null},Me=function(e){var t=e.value,n=e.onChange,r=e.max,i=e.min,s=e.suffix,o=e.size,a=e.label,l=e.initialPosition,c=e.disabled,u=e.className;return(0,f.jsxs)("div",{className:"parsely-inputrange-control ".concat(u||""),children:[(0,f.jsx)(h.__experimentalHeading,{className:"parsely-inputrange-control__label",level:3,children:a}),(0,f.jsxs)("div",{className:"parsely-inputrange-control__controls",children:[(0,f.jsx)(h.__experimentalNumberControl,{disabled:c,value:t,suffix:(0,f.jsx)(h.__experimentalInputControlSuffixWrapper,{children:s}),size:null!=o?o:"__unstable-large",min:i,max:r,onChange:function(e){var t=parseInt(e,10);isNaN(t)||n(t)}}),(0,f.jsx)(h.RangeControl,{disabled:c,value:t,showTooltip:!1,initialPosition:l,onChange:function(e){n(e)},withInputField:!1,min:i,max:r})]})]})},De=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((r=r.apply(e,t||[])).next())}))},Fe=function(e,t){var n,r,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]'; - - // TODO: The codeblock below is for demonstration purposes only and - // will be removed in the future. - if ( - Permissions::current_user_can_use_pch_feature( - 'traffic_boost', - $this->parsely->get_options()['content_helper'] - ) - ) { - echo 'Traffic Boost is enabled.'; - } else { - echo 'Traffic Boost is disabled.'; - } } /** @@ -168,11 +157,62 @@ public function enqueue_dashboard_page_scripts( ?string $hook_suffix ): void { true ); + // Inline scripts must be injected after enqueueing the main script. + $this->inject_content_helper_permissions(); + $this->inject_traffic_boost_settings(); + wp_enqueue_style( 'parsely-dashboard-page', $built_assets_url . 'dashboard-page.css', - $asset_info['dependencies'], + array(), $asset_info['version'] ); } + + /** + * Injects Content Helper permissions into the dashboard page. + * + * @since 3.18.0 + */ + protected function inject_content_helper_permissions(): void { + $permissions_json = Permissions::get_pch_permissions_json( + $this->parsely->get_options()['content_helper'] + ); + + wp_add_inline_script( + 'parsely-dashboard-page', + "window.wpParselyContentHelperPermissions = '$permissions_json';", + 'before' + ); + } + + /** + * Injects Traffic Boost settings into the dashboard page. + * + * @since 3.18.0 + */ + protected function inject_traffic_boost_settings(): void { + $settings = ''; + + if ( ! defined( 'INTEGRATION_TESTS_RUNNING' ) ) { + $settings = rest_do_request( + new WP_REST_Request( + 'GET', + '/wp-parsely/v2/settings/traffic-boost' + ) + )->get_data(); + } + + if ( ! is_array( $settings ) ) { + $settings = array(); + } + + $settings = wp_json_encode( $settings ); + + wp_add_inline_script( + 'parsely-dashboard-page', + "window.wpParselyContentHelperSettings = '$settings';", + 'before' + ); + } } diff --git a/src/content-helper/common/settings/types/index.ts b/src/content-helper/common/settings/types/index.ts index 1180452067..2b370621c1 100644 --- a/src/content-helper/common/settings/types/index.ts +++ b/src/content-helper/common/settings/types/index.ts @@ -10,6 +10,7 @@ import type { TitleSuggestionsSettings, } from './sidebar-settings'; import type { TopPostsSettings } from './top-posts-settings'; +import type { TrafficBoostSettings } from './traffic-boost-settings'; /** * Export the settings types. @@ -22,7 +23,8 @@ export type { SmartLinkingSettings, // Part of SidebarSettings type. TitleSuggestionsSettings, // Part of SidebarSettings type. TopPostsSettings, + TrafficBoostSettings, }; // Generic type for settings. -export type Settings = SidebarSettings | TopPostsSettings; +export type Settings = SidebarSettings | TopPostsSettings | TrafficBoostSettings; diff --git a/src/content-helper/common/settings/types/traffic-boost-settings.d.ts b/src/content-helper/common/settings/types/traffic-boost-settings.d.ts new file mode 100644 index 0000000000..f5c77516d4 --- /dev/null +++ b/src/content-helper/common/settings/types/traffic-boost-settings.d.ts @@ -0,0 +1,8 @@ +/** + * Defines the Traffic Boost settings structure. + * + * @since 3.18.0 + */ +export interface TrafficBoostSettings { + Setting1: string; +} diff --git a/src/content-helper/common/utils/permissions.ts b/src/content-helper/common/utils/permissions.ts index 1cfddbfc69..198a7a22ab 100644 --- a/src/content-helper/common/utils/permissions.ts +++ b/src/content-helper/common/utils/permissions.ts @@ -4,9 +4,10 @@ * @since 3.16.0 */ export interface ContentHelperPermissions { + ExcerptSuggestions: boolean; SmartLinking: boolean; TitleSuggestions: boolean; - ExcerptSuggestions: boolean; + TrafficBoost: boolean; } /** @@ -18,9 +19,10 @@ export interface ContentHelperPermissions { */ export function getContentHelperPermissions(): ContentHelperPermissions { const defaultPermissions: ContentHelperPermissions = { + ExcerptSuggestions: false, SmartLinking: false, TitleSuggestions: false, - ExcerptSuggestions: false, + TrafficBoost: false, }; try { diff --git a/src/content-helper/dashboard-page/dashboard-page.tsx b/src/content-helper/dashboard-page/dashboard-page.tsx index b7ef076b14..780f6e90e6 100644 --- a/src/content-helper/dashboard-page/dashboard-page.tsx +++ b/src/content-helper/dashboard-page/dashboard-page.tsx @@ -1,13 +1,18 @@ /** - * WordPress dependencies + * External dependencies */ -import domReady from '@wordpress/dom-ready'; -import { createRoot, useEffect } from '@wordpress/element'; +import { + Route, + HashRouter as Router, + Routes, + useLocation, +} from 'react-router-dom'; /** - * External dependencies + * WordPress dependencies */ -import { HashRouter as Router, Route, Routes, useLocation } from 'react-router-dom'; +import domReady from '@wordpress/dom-ready'; +import { createRoot, useEffect } from '@wordpress/element'; /** * Internal dependencies @@ -47,9 +52,13 @@ const ParselyDashboard = () => { * @since 3.18.0 */ useEffect( () => { - const firstLink = document.querySelector( '#toplevel_page_parsely-dashboard-page .wp-submenu li a.wp-first-item' ); + const firstLink = document.querySelector( + '#toplevel_page_parsely-dashboard-page .wp-submenu li a.wp-first-item' + ); if ( firstLink ) { - firstLink.setAttribute( 'href', window.location.pathname + window.location.search + '#/' ); + firstLink.setAttribute( + 'href', window.location.pathname + window.location.search + '#/' + ); } }, [] ); @@ -59,7 +68,9 @@ const ParselyDashboard = () => { * @since 3.18.0 */ useEffect( () => { - const submenuItems = document.querySelectorAll( '#toplevel_page_parsely-dashboard-page .wp-submenu li' ); + const submenuItems = document.querySelectorAll( + '#toplevel_page_parsely-dashboard-page .wp-submenu li' + ); submenuItems.forEach( ( item ) => { const link = item.querySelector( 'a' ); diff --git a/src/content-helper/dashboard-page/pages/dashboard/page-component.tsx b/src/content-helper/dashboard-page/pages/dashboard/page-component.tsx index 4f5a4ab347..eb671ebd48 100644 --- a/src/content-helper/dashboard-page/pages/dashboard/page-component.tsx +++ b/src/content-helper/dashboard-page/pages/dashboard/page-component.tsx @@ -1,3 +1,53 @@ +/** + * Internal dependencies + */ +import { SettingsProvider, TrafficBoostSettings } from '../../../common/settings'; +import { getContentHelperPermissions } from '../../../common/utils/permissions'; +import { VerifyCredentials } from '../../../common/verify-credentials'; + +/** + * Gets the settings from the passed JSON. + * + * If missing settings or invalid values are detected, they get set to their + * defaults. + * + * @since 3.18.0 + * + * @param {string} settingsJson The JSON containing the settings. + * + * @return {TrafficBoostSettings} The resulting settings object. + */ +const getSettingsFromJson = ( settingsJson: string ): TrafficBoostSettings => { + // Default settings object. + const defaultSettings: TrafficBoostSettings = { + Setting1: 'Hello World!', + }; + + // If the settings are empty, try to get them from the global variable. + if ( '' === settingsJson ) { + settingsJson = window.wpParselyContentHelperSettings; + } + + let parsedSettings: TrafficBoostSettings; + + try { + parsedSettings = JSON.parse( settingsJson ); + } catch ( e ) { + // Return defaults when parsing failed or the string is empty. + return defaultSettings; + } + + // Merge parsed settings with default settings. + const mergedSettings = { ...defaultSettings, ...parsedSettings }; + + // Fix invalid values if any are found. + if ( typeof mergedSettings.Setting1 !== 'string' ) { + mergedSettings.Setting1 = defaultSettings.Setting1; + } + + return mergedSettings; +}; + /** * The main dashboard page component. * @@ -5,9 +55,18 @@ */ export const DashboardPage = () => { return ( - <> -

Parse.ly Dashboard

-

Welcome to the main Parse.ly dashboard page.

- + + + <> +

Parse.ly

+

Welcome to the Parse.ly Dashboard page!

+

Content Helper Permissions: { JSON.stringify( getContentHelperPermissions() ) }

+

Traffic Boost Settings: { JSON.stringify( getSettingsFromJson( window.wpParselyContentHelperSettings ) ) }

+ +
+
); }; diff --git a/src/rest-api/settings/class-endpoint-traffic-boost-settings.php b/src/rest-api/settings/class-endpoint-traffic-boost-settings.php new file mode 100644 index 0000000000..e9ea6e5ff1 --- /dev/null +++ b/src/rest-api/settings/class-endpoint-traffic-boost-settings.php @@ -0,0 +1,58 @@ + + */ + protected function get_subvalues_specs(): array { + return array( + 'Setting1' => array( + 'values' => array(), + 'default' => 'Hello World!', + ), + ); + } +} diff --git a/src/rest-api/settings/class-settings-controller.php b/src/rest-api/settings/class-settings-controller.php index 930856a66f..a7a37381db 100644 --- a/src/rest-api/settings/class-settings-controller.php +++ b/src/rest-api/settings/class-settings-controller.php @@ -40,6 +40,7 @@ public function init(): void { $endpoints = array( new Endpoint_Dashboard_Widget_Settings( $this ), new Endpoint_Editor_Sidebar_Settings( $this ), + new Endpoint_Traffic_Boost_Settings( $this ), ); $this->register_endpoints( $endpoints );