laipower/wp-content/plugins/gp-premium/dist/site-library.js

6 lines
27 KiB
JavaScript
Raw Normal View History

(()=>{var e={703:(e,t,r)=>{"use strict";var n=r(414);function a(){}function s(){}s.resetWarningCache=a,e.exports=function(){function e(e,t,r,a,s,i){if(i!==n){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:a};return r.PropTypes=r,r}},697:(e,t,r)=>{e.exports=r(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},216:(e,t,r)=>{"use strict";t.be=void 0;var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(196),s=m(a),i=m(r(697)),l=r(81),o=m(r(315)),p=m(r(282)),c=m(r(821));function m(e){return e&&e.__esModule?e:{default:e}}var u="data-lazyload-listened",d=[],g=[],h=!1;try{var f=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("test",null,f)}catch(e){}var b=!!h&&{capture:!1,passive:!0},v=function(e){var t=e.ref;if(t instanceof HTMLElement){var r=(0,o.default)(t),n=e.props.overflow&&r!==t.ownerDocument&&r!==document&&r!==document.documentElement?function(e,t){var r=e.ref,n=void 0,a=void 0,s=void 0,i=void 0;try{var l=t.getBoundingClientRect();n=l.top,a=l.left,s=l.height,i=l.width}catch(e){n=0,a=0,s=0,i=0}var o=window.innerHeight||document.documentElement.clientHeight,p=window.innerWidth||document.documentElement.clientWidth,c=Math.max(n,0),m=Math.max(a,0),u=Math.min(o,n+s)-c,d=Math.min(p,a+i)-m,g=void 0,h=void 0,f=void 0,b=void 0;try{var v=r.getBoundingClientRect();g=v.top,h=v.left,f=v.height,b=v.width}catch(e){g=0,h=0,f=0,b=0}var y=g-c,_=h-m,E=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return y-E[0]<=u&&y+f+E[1]>=0&&_-E[0]<=d&&_+b+E[1]>=0}(e,r):function(e){var t=e.ref;if(!(t.offsetWidth||t.offsetHeight||t.getClientRects().length))return!1;var r=void 0,n=void 0;try{var a=t.getBoundingClientRect();r=a.top,n=a.height}catch(e){r=0,n=0}var s=window.innerHeight||document.documentElement.clientHeight,i=Array.isArray(e.props.offset)?e.props.offset:[e.props.offset,e.props.offset];return r-i[0]<=s&&r+n+i[1]>=0}(e);n?e.visible||(e.props.once&&g.push(e),e.visible=!0,e.forceUpdate()):e.props.once&&e.visible||(e.visible=!1,e.props.unmountIfInvisible&&e.forceUpdate())}},y=function(){for(var e=0;e<d.length;++e){var t=d[e];v(t)}g.forEach((function(e){var t=d.indexOf(e);-1!==t&&d.splice(t,1)})),g=[]},_=void 0,E=null,w=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.visible=!1,r.setRef=r.setRef.bind(r),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"componentDidMount",value:function(){var e=window,t=this.props.scrollContainer;t&&"string"==typeof t&&(e=e.document.querySelector(t));var r=void 0!==this.props.debounce&&"throttle"===_||"debounce"===_&&void 0===this.props.debounce;if(r&&((0,l.off)(e,"scroll",E,b),(0,l.off)(window,"resize",E,b),E=null),E||(void 0!==this.props.debounce?(E=(0,p.default)(y,"number"==typeof this.props.debounce?this.props.debounce:300),_="debounce"):void 0!==this.props.throttle?(E=(0,c.default)(y,"numbe
(0,t.__)("Requires GP Premium %s.","gp-premium"),p)),!!y&&m(g,u)>0&&(0,e.createElement)("span",{className:"generatepress-site-library-required-version"},(0,t.sprintf)(/* translators: Version number */
(0,t.__)("Requires GeneratePress %s.","gp-premium"),g)),!!y&&d&&m(h,d)>0&&(0,e.createElement)("span",{className:"generatepress-site-library-required-version"},(0,t.sprintf)(/* translators: Version number */
(0,t.__)("Requires GenerateBlocks %s.","gp-premium"),h)))))}))),(0,e.createElement)("div",{className:"generatepress-site-library-refresh"},(0,e.createElement)(a.Button,{variant:"primary",onClick:()=>{z(!0),p()({path:"/generatepress-site-library/v1/get_sites",method:"POST",data:{forceRefresh:!0}}).then((e=>{i(!0),o(e.response),z(!1)}))}},U&&(0,e.createElement)(a.Spinner,null),!U&&(0,t.__)("Refresh sites","gp-premium")))),b&&(0,e.createElement)("div",{className:"generatepress-site-library-opened"},(0,e.createElement)("div",{className:"generatepress-site-library-iframe"},(0,e.createElement)(g,{url:y.preview_url,previewWidth:X})),(0,e.createElement)("div",{className:"generatepress-site-library-info"},(0,e.createElement)("div",{className:"generatepress-site-library-header"},(0,e.createElement)("div",{className:"generatepress-site-library-header__title"},(0,e.createElement)("h2",{className:ee?"has-author":""},(0,s.decodeEntities)(y.name)),ee&&(0,e.createElement)("span",{className:"site-library-author"},/* translators: Site library site built by "author name" */
(0,t.__)("Built by","gp-premium")+" ",(0,e.createElement)("a",{href:y.author_url,target:"_blank",rel:"noreferrer noopener"},y.author_name))),(0,e.createElement)(a.Button,{onClick:()=>{f(!1),v(!1),_({}),w({}),k({}),O(!1),x(!0),L(!0),R(!1),B(!1),D([]),M([]),F([])}},(0,e.createElement)("svg",{width:"35",height:"35",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",role:"img","aria-hidden":"true",focusable:"false"},(0,e.createElement)("path",{d:"M13 11.9l3.3-3.4-1.1-1-3.2 3.3-3.2-3.3-1.1 1 3.3 3.4-3.5 3.6 1 1L12 13l3.5 3.5 1-1z"})))),(0,e.createElement)("div",{className:"generatepress-site-library-content"},!!y.description&&(0,e.createElement)("p",null,(0,s.decodeEntities)(y.description)),!j&&(0,e.createElement)(n.Fragment,null,0===Object.keys(C).length&&(0,e.createElement)(n.Fragment,null,gppSiteLibrary.isDebugEnabled&&(0,e.createElement)(a.PanelBody,{className:"gpp-debug-panel",title:(0,t.__)("Debug Mode Enabled","gp-premium"),initialOpen:!1},(0,e.createElement)("p",null,(0,t.__)("WordPress debug mode is currently enabled. With this, any errors from third-party plugins might affect the import process.","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("To disable it, find WP_DEBUG in your wp-config.php file and set it to false like the below.","gp-premium")),(0,e.createElement)("code",null,"define( 'WP_DEBUG', false );"),(0,e.createElement)("p",null,(0,e.createElement)("a",{href:"https://docs.generatepress.com/article/debug-mode-enabled/",target:"_blank",rel:"noreferrer noopener"},(0,t.__)("Learn more here","gp-premium")))),Object.keys(E).length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Plugins","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("This site uses the following plugins.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},Object.entries(E).map((([t])=>(0,e.createElement)("li",{key:t},t))))),(0,e.createElement)("div",{className:"gpp-library-action-button"},(0,e.createElement)(a.Button,{variant:"primary",disabled:h,onClick:e=>{f(!0);const r=e.target.nextElementSibling;r.textContent=(0,t.__)("Gathering information","gp-premium"),p()({path:"/generatepress-site-library/v1/get_site_data",method:"POST",data:{siteData:y}}).then((e=>{const t=[],n=[],a=[];Object.entries(e.response.plugin_data).forEach((([r])=>{const s=e.response.plugin_data[r];s.repo&&!s.installed?t.push(s.name):s.installed||s.active?n.push(s.name):a.push(s.name)})),f(!1),k(e.response),w(e.response.plugins),O(e.response.widgets),D(t),M(n),F(a),r.classList.add("gpp-library-action-message--show"),r.textContent=e.response,e.success&&e.response?setTimeout((function(){r.classList.remove("gpp-library-action-message--show")}),3e3):r.classList.add("gpp-library-action-message--error")}))}},h&&(0,e.createElement)(a.Spinner,null),!h&&(0,t.__)("Get Started","gp-premium")),(0,e.createElement)("span",{className:"gpp-library-action-message"}))),Object.keys(C).length>0&&Object.keys(E).length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Plugins","gp-premium")),I.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",null,(0,t.__)("These plugins can be installed automatically.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},I.map((t=>(0,e.createElement)("li",{key:t},t))))),A.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",null,(0,t.__)("These plugins are already installed.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},A.map((t=>(0,e.createElement)("li",{key:t},t))))),W.length>0&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("p",{style:{fontWeight:"bold"}},(0,t.__)("These plugins need to be installed manually.","gp-premium")),(0,e.createElement)("ul",{className:"generatepress-site-library-plugins"},W.map((t=>"GenerateBlocks Pro"===t?(0,e.createElement)("li",{key:t},(0,e.createElement)(a.ExternalLink,{href:"https://generatepress.com/blocks/#pricing"},t)):(0,e.createElement)("li",{key:t},t)))))),Object.keys(C).length>0&&(0,e.
(0,t.__)("Installing %s","gp-premium"),s),wp.updates.installPlugin({slug:a,success:t=>{console.log(t),delete C.plugin_data[r],0===Object.keys(C.plugin_data).length&&K(e)},error:t=>{console.log(t),delete C.plugin_data[r],0===Object.keys(C.plugin_data).length&&K(e)}}))}))}(r):Q(r):(r.textContent=(0,t.__)("Import Complete","gp-premium"),f(!1),B(!0),V(!0))}),2e3)}))}(e)}},h&&(0,e.createElement)(a.Spinner,null),!h&&(0,t.__)("Begin Import","gp-premium")),(0,e.createElement)("span",{className:"gpp-library-action-message"})))),!!j&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Import Complete","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Check out your new site and start making it yours!","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Note: We do our best to ensure all imported images are licensed for open use. However, image licenses can change, so we strongly advise that you replace all imported images with your own.","gp-premium")),(0,e.createElement)("a",{className:"components-button is-primary",href:gppSiteLibrary.homeUrl},(0,t.__)("View Site","gp-premium")),y.uploads_url&&Object.values(E).includes("elementor/elementor.php")&&(0,e.createElement)(n.Fragment,null,(0,e.createElement)("h3",null,(0,t.__)("Additional Cleanup","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("This site is using Elementor which means you will want to replace the imported image URLs.","gp-premium")),(0,e.createElement)("p",null,(0,t.__)("Take note of the old and new URLs below, then head over to the Elementor Tools area to replace them.","gp-premium")),(0,e.createElement)(a.TextControl,{label:(0,t.__)("Old URL","gp-premium"),readOnly:!0,value:y.uploads_url}),(0,e.createElement)(a.TextControl,{label:(0,t.__)("New URL","gp-premium"),readOnly:!0,value:gppSiteLibrary.uploadsUrl}),(0,e.createElement)("a",{href:gppSiteLibrary.elementorReplaceUrls,className:"components-button is-primary",target:"_blank",rel:"noopener noreferrer"},(0,t.__)("Elementor Tools","gp-premium")))),(0,e.createElement)("div",{className:"generatepress-site-library-footer"},(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview desktop","gp-premium")},(0,e.createElement)(a.Button,{variant:"desktop"===J?"primary":"",onClick:()=>{Y("desktop")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M21 14H3V4h18m0-2H3c-1.11 0-2 .89-2 2v12a2 2 0 002 2h7l-2 3v1h8v-1l-2-3h7a2 2 0 002-2V4a2 2 0 00-2-2z",fill:"currentColor"})))),(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview tablet","gp-premium")},(0,e.createElement)(a.Button,{variant:"tablet"===J?"primary":"",onClick:()=>{Y("tablet")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M19 19H4V3h15m-7.5 20a1.5 1.5 0 01-1.5-1.5 1.5 1.5 0 011.5-1.5 1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m7-23h-14A2.5 2.5 0 002 2.5v19A2.5 2.5 0 004.5 24h14a2.5 2.5 0 002.5-2.5v-19A2.5 2.5 0 0018.5 0z",fill:"currentColor"})))),(0,e.createElement)(a.Tooltip,{text:(0,t.__)("Preview mobile","gp-premium")},(0,e.createElement)(a.Button,{variant:"mobile"===J?"primary":"",onClick:()=>{Y("mobile")}},(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M17 19H7V5h10m0-4H7c-1.11 0-2 .89-2 2v18a2 2 0 002 2h10a2 2 0 002-2V3a2 2 0 00-2-2z",fill:"currentColor"}))))))))))}),null),o=document.getElementById("gpp-site-library"),void 0!==n.createRoot?(0,n.createRoot)(o).render(l):(0,n.render)(l,o)})()})();