Files
tysweld.com/wp-content/plugins/polylang-pro/js/build/sidebar.min.js
2025-02-24 22:33:42 +01:00

1 line
40 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(()=>{var t={20:(t,e,n)=>{"use strict";var s=n(677),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(t,e,n){var s,o={},c=null,d=null;for(s in void 0!==n&&(c=""+n),void 0!==e.key&&(c=""+e.key),void 0!==e.ref&&(d=e.ref),e)a.call(e,s)&&!i.hasOwnProperty(s)&&(o[s]=e[s]);if(t&&t.defaultProps)for(s in e=t.defaultProps)void 0===o[s]&&(o[s]=e[s]);return{$$typeof:r,type:t,key:c,ref:d,props:o,_owner:l.current}}e.Fragment=o,e.jsx=c,e.jsxs=c},848:(t,e,n)=>{"use strict";t.exports=n(20)},677:t=>{t.exports=function(){return this.React}()},419:t=>{t.exports=function(){return this.lodash}()},631:t=>{t.exports=function(){return this.wp.apiFetch}()},959:t=>{t.exports=function(){return this.wp.components}()},897:t=>{t.exports=function(){return this.wp.compose}()},488:t=>{t.exports=function(){return this.wp.coreData}()},987:t=>{t.exports=function(){return this.wp.data}()},53:t=>{t.exports=function(){return this.wp.editPost}()},324:t=>{t.exports=function(){return this.wp.editSite}()},601:t=>{t.exports=function(){return this.wp.element}()},75:t=>{t.exports=function(){return this.wp.i18n}()},860:t=>{t.exports=function(){return this.wp.keycodes}()},672:t=>{t.exports=function(){return this.wp.notices}()},125:t=>{t.exports=function(){return this.wp.plugins}()},933:t=>{t.exports=function(){return this.wp.primitives}()},172:t=>{t.exports=function(){return this.wp.url}()},942:(t,e)=>{var n;!function(){"use strict";var s={}.hasOwnProperty;function r(){for(var t="",e=0;e<arguments.length;e++){var n=arguments[e];n&&(t=a(t,o(n)))}return t}function o(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return r.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var e="";for(var n in t)s.call(t,n)&&t[n]&&(e=a(e,n));return e}function a(t,e){return e?t?t+" "+e:t+e:t}t.exports?(r.default=r,t.exports=r):void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n)}()}},e={};function n(s){var r=e[s];if(void 0!==r)return r.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);(()=>{"use strict";var t=n(601),e=n(53),s=n(324),r=n(125),o=n(933),a=n(419),l=n(848);const i=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M6 15v-13h10v13h-10zM5 16h8v2h-10v-13h2v11z"})}):"admin-page",c=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M13.89 3.39l2.71 2.72c0.46 0.46 0.42 1.24 0.030 1.64l-8.010 8.020-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.030c0.39-0.39 1.22-0.39 1.68 0.070zM11.16 6.18l-5.59 5.61 1.11 1.11 5.54-5.65zM8.19 14.41l5.58-5.6-1.070-1.080-5.59 5.6z"})}):"edit",d=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M17 7v3h-5v5h-3v-5h-5v-3h5v-5h3v5h5z"})}):"plus",p=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M5 7v3l-2 1.5v-6.5h11v-2l4 3.010-4 2.99v-2h-9zM15 13v-3l2-1.5v6.5h-11v2l-4-3.010 4-2.99v2h9z"})}):"controls-repeat",u=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M11 7H9.49c-.63 0-1.25.3-1.59.7L7 5H4.13l-2.39 7h1.69l.74-2H7v4H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h7c1.1 0 2 .9 2 2v2zM6.51 9H4.49l1-2.93zM10 8h7c1.1 0 2 .9 2 2v7c0 1.1-.9 2-2 2h-7c-1.1 0-2-.9-2-2v-7c0-1.1.9-2 2-2zm7.25 5v-1.08h-3.17V9.75h-1.16v2.17H9.75V13h1.28c.11.85.56 1.85 1.28 2.62-.87.36-1.89.62-2.31.62-.01.02.22.97.2 1.46.84 0 2.21-.5 3.28-1.15 1.09.65 2.48 1.15 3.34 1.15-.02-.49.2-1.44.2-1.46-.43 0-1.49-.27-2.38-.63.7-.77 1.14-1.77 1.25-2.61h1.36zm-3.81 1.93c-.5-.46-.85-1.13-1.01-1.93h2.09c-.17.8-.51 1.47-1 1.93l-.04.03s-.03-.02-.04-.03z"})}):"translation",g=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"M12 4h3c.6 0 1 .4 1 1v1H3V5c0-.6.5-1 1-1h3c.2-1.1 1.3-2 2.5-2s2.3.9 2.5 2zM8 4h3c-.2-.6-.9-1-1.5-1S8.2 3.4 8 4zM4 7h11l-.9 10.1c0 .5-.5.9-1 .9H5.9c-.5 0-.9-.4-1-.9L4 7z"})}):"trash",h=!(0,a.isUndefined)(wp.primitives)?(0,l.jsx)(o.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,l.jsx)(o.Path,{d:"m10 1 3 6 6 .75-4.12 4.62L16 19l-6-3-6 3 1.13-6.63L1 7.75 7 7z"})}):"star-filled",f=((0,a.isUndefined)(wp.primitives),({sidebar:t,sidebarName:e,onPromise:n,children:s})=>(n().then((n=>{(0,r.registerPlugin)(e,{icon:u,render:t})}),(t=>{console.info(t)})),(0,l.jsx)(l.Fragment,{children:s})));var m=n(987),y=n(172);const _="pll/metabox",x="core/editor",b="core/edit-site",w="core",v={languages:[],selectedLanguage:{},translatedPosts:{},fromPost:null,currentTemplatePart:{}},j=["wp_template","wp_global_styles"],P=["page"];function S(t){const e={};return t.forEach((function(t,e,n){this[e]=(0,a.isBoolean)(t)?t.toString():t}),e),e}function T(){return!(!document.getElementById("site-editor")&&!document.getElementById("edit-site-editor"))}function C(t){return(0,m.select)(_).getLanguages().get(t)}function E(t,e,n){const s=L(e),r=(0,m.select)(_).getFromPost();let o=new Map(Object.entries([]));return(0,a.isUndefined)(t)||(o=new Map(Object.entries(t))),(0,a.isNil)(r)||(0,a.isNil)(r.id)||s.forEach(((t,e)=>{(0,a.isNil)(t.translated_post)||(0,a.isNil)(t.translated_post.id)||o.set(e,t.translated_post.id)})),o}function N(t){let e=new Map(Object.entries([]));return(0,a.isUndefined)(t)||(e=new Map(Object.entries(t))),e}function L(t){let e=new Map(Object.entries([]));return(0,a.isUndefined)(t)||(e=new Map(Object.entries(t))),e}const k=()=>{if((0,a.isNil)((0,m.select)(x)))return Promise.reject("Polylang languages panel can't be initialized because block editor isn't fully initialized.");D();(0,m.select)(_).getCurrentUser();const t=new Promise((function(t){let e=(0,m.subscribe)((function(){const n=(0,m.select)(x).getCurrentPost();(0,a.isEmpty)(n)||(e(),t())}))}));return Promise.all([t,O()]).then((function(){const t=(0,m.select)(_).getFromPost();if(!(0,a.isNil)(t)&&!(0,a.isNil)(t.id)){(0,m.select)(x).getEditedPostAttribute("lang");const t=E((0,m.select)(x).getEditedPostAttribute("translations"),(0,m.select)(x).getEditedPostAttribute("translations_table"));(0,m.dispatch)(x).editPost({translations:S(t)})}}))},A=()=>{D();(0,m.select)(_).getCurrentUser();const t=new Promise((function(t){let e=(0,m.subscribe)((function(){(0,m.select)(b)&&(e(),t())}))}));return Promise.all([t,O()])},O=()=>new Promise((function(t){let e=(0,m.subscribe)((function(){const n=(0,m.select)(_)?.getLanguages();n?.size>0&&(e(),t())}))}));function D(){const t=(0,a.isEmpty)(window.location.search)?null:new URLSearchParams(window.location.search);null!==t&&(0,m.dispatch)(_).setFromPost({id:wp.sanitize.stripTagsAndEncodeText(t.get("from_post")),postType:wp.sanitize.stripTagsAndEncodeText(t.get("post_type")),newLanguage:wp.sanitize.stripTagsAndEncodeText(t.get("new_lang"))})}const R=()=>{const t=(()=>{const t=(0,m.select)(b);if(!t)return null;const e={postId:t.getEditedPostId(),postType:t.getEditedPostType()};if(t.hasOwnProperty("getEditedPostContext")){const n=t.getEditedPostContext();return n?.postType&&n?.postId?n:e}return e})();return null===t?null:(0,m.select)(w).getEntityRecord("postType",t.postType,t.postId)},U=({onPromise:e})=>{const n=(0,t.useRef)({}),s=()=>{var t;const e=R();return null!==(t=C(e?.lang))&&void 0!==t?t:"default"},r=t=>{if(n.current=s(),n?.current.is_default||"default"===n?.current)return;const e=new URL(document.location.href).searchParams,r=new URL(t).searchParams;e.get("postId")!==r.get("postId")&&dispatch(MODULE_CORE_KEY).invalidateResolutionForStore()};return(0,t.useEffect)((()=>{e().then((()=>{n.current=s()})),(t=>{const e=t.pushState,n=t.replaceState;t.pushState=(n,s,o)=>(r(o),e.apply(t,[n,s,o])),t.replaceState=(e,s,o)=>(r(o),n.apply(t,[e,s,o]))})(window.history)}),[]),null};var M=n(672);const{stripTags:z}=wp.sanitize,F=({notices:t})=>{if(!t)return null;const{createErrorNotice:e,createInfoNotice:n,createSuccessNotice:s,createWarningNotice:r}=(0,m.useDispatch)(M.store);return t.forEach((t=>{const o={type:"snackbar",explicitDismiss:!0},a=z(t.message);switch(t.type){case"error":e(a,o);break;case"info":n(a,o);break;case"success":s(a,o);break;case"warning":r(a,o)}})),null};var I=n(75);const B=({PluginSidebarSlot:t,sidebarName:e,children:n})=>(0,l.jsx)(t,{name:e,title:(0,I.__)("Languages","polylang-pro"),children:n}),V=({PluginSidebarMoreMenuItemSlot:t,sidebarName:e})=>(0,l.jsx)(t,{target:e,children:(0,I.__)("Languages","polylang-pro")});const W=function({language:t}){return(0,a.isNil)(t)?(0,l.jsx)("span",{className:"pll-translation-icon",children:u}):(0,a.isEmpty)(t.flag_url)?(0,l.jsxs)("abbr",{children:[t.slug,(0,l.jsx)("span",{className:"screen-reader-text",children:t.name})]}):(0,l.jsx)("span",{className:"pll-select-flag",children:(0,l.jsx)("img",{src:t.flag_url,alt:t.name,title:t.name,className:"flag"})})};var $=n(959);const H=()=>(0,l.jsxs)(t.Fragment,{children:[(0,l.jsx)($.Icon,{icon:h,className:"pll-defaut-lang-icon"}),(0,l.jsx)("span",{className:"screen-reader-text",children:(0,I.__)("Default language.","polylang-pro")})]}),G=({language:t,currentPost:e})=>{var n;const s=(0,m.useSelect)((t=>t(w).getPostType(e.type)),[]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{children:(0,l.jsx)("strong",{children:(0,I.__)("Language","polylang-pro")})}),(0,l.jsxs)("div",{className:"pll-language-item",children:[(0,l.jsx)(W,{language:t}),(0,l.jsx)("span",{className:"pll-language-name",children:(0,I.__)(t.name,"polylang-pro")}),t.is_default&&(0,l.jsx)(H,{})]}),t.is_default&&(0,l.jsx)("div",{children:(0,l.jsx)("span",{className:"pll-metabox-info",children:null!==(n="wp_template_part"===s?.slug)&&void 0!==n?n:(0,I.__)("This template part is used for languages that have not yet been translated.","polylang-pro")})})]})},K=({children:t})=>(0,l.jsx)("div",{className:"components-panel__body is-opened",children:(0,l.jsx)("div",{className:"pll-metabox-location",children:t})}),q=({postType:t})=>"wp_template"===t?(0,l.jsx)("div",{className:"pll-metabox-error components-notice is-warning",children:(0,I.__)("Templates are not translatable, only template parts are.","polylang-pro")}):(0,l.jsx)("div",{className:"pll-metabox-error components-notice is-warning",children:(0,I.__)("This entity is not translatable.","polylang-pro")}),Q=({isError:t,isAllowedPostType:e,postType:n,children:s})=>e?t?(0,l.jsx)(K,{children:(0,l.jsx)("div",{className:"pll-metabox-error components-notice is-error",children:(0,I.__)("Unable to retrieve the content language","polylang-pro")})}):(0,l.jsx)(K,{children:s}):(0,l.jsx)(K,{children:(0,l.jsx)(q,{postType:n})}),Y=({children:t})=>(0,l.jsx)("td",{className:"pll-edit-column pll-column-icon",children:t}),X=({isDefault:t})=>(0,l.jsx)("td",{className:"pll-default-lang-column pll-column-icon",children:t&&(0,l.jsx)(H,{})}),J=({children:t})=>(0,l.jsx)("td",{className:"pll-delete-column pll-column-icon",children:t}),Z=({language:t})=>(0,l.jsx)("th",{className:"pll-language-column",children:(0,a.isEmpty)(t.flag)?(0,l.jsxs)("abbr",{children:[t.slug,(0,l.jsx)("span",{className:"screen-reader-text",children:t.name})]}):(0,l.jsx)("span",{className:"pll-select-flag flag",children:(0,l.jsx)("img",{src:t.flag_url,alt:t.name,title:t.name})})}),tt=({children:t})=>(0,l.jsx)("td",{className:"pll-sync-column pll-column-icon",children:t}),et=({children:t})=>(0,l.jsx)("td",{className:"pll-translation-column",children:t}),nt=({language:t,href:e,handleAddClick:n=null})=>{const s=(0,I.sprintf)((0,I.__)("Add a translation in %s","polylang-pro"),t.name);return(0,l.jsx)($.Button,{href:e,icon:d,label:s,className:"pll-button",onClick:n,"data-target-language":t.slug,children:(0,l.jsx)("span",{className:"screen-reader-text",children:s})})},st=({language:t,disabled:e,onClick:n})=>{const s=(0,I.sprintf)((0,I.__)("Delete the translation in %s","polylang-pro"),t.name);return(0,l.jsx)($.Button,{icon:g,label:s,disabled:e,className:"pll-button",onClick:n,children:(0,l.jsx)("span",{className:"screen-reader-text",children:s})})},rt=({id:e,postType:n,userPreferenceName:s,activeLabel:r,inactiveLabel:o,icon:a})=>{const i=(0,m.useSelect)((t=>t(_).getCurrentUser()),[]),[c,d]=(0,t.useState)((()=>void 0!==i&&void 0!==i[s]&&void 0!==i[s][n]&&i[s][n])),p=c?r:o;return(0,l.jsx)($.Button,{id:e,className:`pll-button pll-before-post-translations-button ${c&&"wp-ui-text-highlight"}`,onClick:()=>{(void 0===i[s]||Array.isArray(i[s])&&0===i[s].length)&&(i[s]={}),i[s][n]=!c;const t={};t[s]=i[s],(0,m.dispatch)(_).setCurrentUser(t,!0),d((t=>!t))},icon:a,label:p,children:(0,l.jsx)("span",{className:"screen-reader-text",children:p})})},ot=t=>{const{path_d:e,...n}=t.icon,s={type:"svg",props:{...n,children:(0,l.jsx)(o.Path,{d:e})}},r={...t,id:"pll-machine-translation",userPreferenceName:`pll_machine_translation_${t.slug}`,activeLabel:(0,I.sprintf)((0,I.__)("Deactivate %s machine translation","polylang-pro"),t.name),inactiveLabel:(0,I.sprintf)((0,I.__)("Activate %s machine translation","polylang-pro"),t.name),icon:s};return(0,l.jsx)(rt,{...r})},at=t=>{const e={...t,id:"pll-duplicate",userPreferenceName:"pll_duplicate_content",activeLabel:(0,I.__)("Deactivate the content duplication","polylang-pro"),inactiveLabel:(0,I.__)("Activate the content duplication","polylang-pro"),icon:i};return(0,l.jsx)(rt,{...e})},lt=({language:t,href:e,handleEditClick:n=null})=>{const s=(0,I.sprintf)((0,I.__)("Edit the translation in %s","polylang-pro"),t.name);return(0,l.jsx)($.Button,{href:e,icon:c,label:s,className:"pll-button",onClick:n,"data-target-language":t.slug,children:(0,l.jsx)("span",{className:"screen-reader-text",children:s})})};var it=n(897);class ct extends t.Component{constructor(){super(...arguments),this.confirmButton=(0,t.createRef)()}componentDidMount(){this.confirmButton.current.focus()}render(){const{idPrefix:t,title:e,updateState:n,handleChange:s,children:r}=this.props;return(0,l.jsxs)($.Modal,{title:e,className:"confirmBox",onRequestClose:n,shouldCloseOnEsc:!1,shouldCloseOnClickOutside:!1,focusOnMount:!1,children:[r,(0,l.jsxs)($.ButtonGroup,{className:"buttons",children:[(0,l.jsx)($.Button,{id:`${t}_confirm`,ref:this.confirmButton,isPrimary:!0,onClick:t=>{s(t),n()},children:(0,I.__)("OK","polylang-pro")}),(0,l.jsx)($.Button,{id:`${t}_cancel`,isSecondary:!0,onClick:()=>n(),children:(0,I.__)("Cancel","polylang-pro")})]})]})}}const dt=function(e,n,s){return(0,it.createHigherOrderComponent)((r=>{class o extends t.Component{constructor(){super(...arguments),this.state={isOpen:!1,changeValue:null},this.handleChange=this.handleChange.bind(this)}handleChange(t){let e=r.getChangeValue(t);const n=this.props.currentPost;(0,a.isNil)(n)||(e={templateId:e,currentPost:n}),!(0,a.isUndefined)(r.bypassConfirmation)&&r.bypassConfirmation(this.props.translationData)?s(e):this.setState({isOpen:!0,changeValue:e})}render(){const o=this.props.translationData?.lang.is_default,i=this.props,c=Object.assign({},{...i},{handleChange:this.handleChange});return(0,l.jsxs)(t.Fragment,{children:[(0,l.jsx)(r,{...c}),this.state.isOpen&&(0,l.jsx)(ct,{title:r.labelConfirmationModal,idPrefix:e,handleChange:()=>s(this.state.changeValue),updateState:()=>this.setState({isOpen:!1,changeValue:null}),children:(0,l.jsx)(n,{...(0,a.isNil)(o)?{}:{isDefaultLang:o}})})]})}}return o.bypassConfirmation=r.bypassConfirmation,o.getChangeValue=r.getChangeValue,o}),"withConfirmation")};class pt extends t.Component{constructor(){super(...arguments)}static handleSynchronizationChange(t){const e=N((0,m.select)(x).getEditedPostAttribute("pll_sync_post"));e.has(t)?e.delete(t):e.set(t,!0),(0,m.dispatch)(x).editPost({pll_sync_post:S(e)}),(0,m.dispatch)(x).editPost({title:(0,m.select)(x).getEditedPostAttribute("title")})}static bypassConfirmation(t){const e=N((0,m.select)(x).getEditedPostAttribute("pll_sync_post")),n=!(0,a.isEmpty)(e)&&e.has(t.lang.slug),s=!(0,a.isUndefined)(t.translated_post)&&!(0,a.isNil)(t.translated_post.id);return n||!s}static getChangeValue(t){return t.currentTarget.id.match(/\[(.[^[]+)\]/i)[1]}render(){const t=N((0,m.select)(x).getEditedPostAttribute("pll_sync_post")),e=this.props.translationData,n=!(0,a.isEmpty)(t)&&t.has(e.lang.slug),s=n&&"wp-ui-text-highlight",r=n?(0,I.__)("Don't synchronize this post","polylang-pro"):(0,I.__)("Synchronize this post","polylang-pro");return(0,l.jsx)($.Button,{icon:p,label:r,id:`pll_sync_post[${e.lang.slug}]`,className:`pll-button ${s}`,onClick:t=>{this.props.handleChange(t)},children:(0,l.jsx)("span",{className:"screen-reader-text",children:r})})}}pt.labelConfirmationModal=(0,I.__)("Synchronize this post","polylang-pro");const ut=dt("pll_sync_post",(function(){return(0,l.jsx)("p",{children:(0,I.__)("You are about to overwrite an existing translation. Are you sure you want to proceed?","polylang-pro")})}),pt.handleSynchronizationChange)(pt);var gt=n(942),ht=n.n(gt);function ft(t){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ft(t)}function mt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,s)}return n}function _t(t,e){var n=t["page".concat(e?"Y":"X","Offset")],s="scroll".concat(e?"Top":"Left");if("number"!=typeof n){var r=t.document;"number"!=typeof(n=r.documentElement[s])&&(n=r.body[s])}return n}function xt(t){return _t(t)}function bt(t){return _t(t,!0)}function wt(t){var e=function(t){var e,n,s,r=t.ownerDocument,o=r.body,a=r&&r.documentElement;return n=(e=t.getBoundingClientRect()).left,s=e.top,{left:n-=a.clientLeft||o.clientLeft||0,top:s-=a.clientTop||o.clientTop||0}}(t),n=t.ownerDocument,s=n.defaultView||n.parentWindow;return e.left+=xt(s),e.top+=bt(s),e}var vt,jt=new RegExp("^(".concat(/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,")(?!px)[a-z%]+$"),"i"),Pt=/^(top|right|bottom|left)$/,St="currentStyle",Tt="runtimeStyle",Ct="left";function Et(t,e){for(var n=0;n<t.length;n++)e(t[n])}function Nt(t){return"border-box"===vt(t,"boxSizing")}"undefined"!=typeof window&&(vt=window.getComputedStyle?function(t,e,n){var s="",r=t.ownerDocument,o=n||r.defaultView.getComputedStyle(t,null);return o&&(s=o.getPropertyValue(e)||o[e]),s}:function(t,e){var n=t[St]&&t[St][e];if(jt.test(n)&&!Pt.test(e)){var s=t.style,r=s[Ct],o=t[Tt][Ct];t[Tt][Ct]=t[St][Ct],s[Ct]="fontSize"===e?"1em":n||0,n=s.pixelLeft+"px",s[Ct]=r,t[Tt][Ct]=o}return""===n?"auto":n});var Lt=["margin","border","padding"];function kt(t,e,n){var s,r,o,a=0;for(r=0;r<e.length;r++)if(s=e[r])for(o=0;o<n.length;o++){var l=void 0;l="border"===s?"".concat(s+n[o],"Width"):s+n[o],a+=parseFloat(vt(t,l))||0}return a}function At(t){return null!=t&&t==t.window}var Ot={};function Dt(t,e,n){if(At(t))return"width"===e?Ot.viewportWidth(t):Ot.viewportHeight(t);if(9===t.nodeType)return"width"===e?Ot.docWidth(t):Ot.docHeight(t);var s="width"===e?["Left","Right"]:["Top","Bottom"],r="width"===e?t.offsetWidth:t.offsetHeight,o=(vt(t),Nt(t)),a=0;(null==r||r<=0)&&(r=void 0,(null==(a=vt(t,e))||Number(a)<0)&&(a=t.style[e]||0),a=parseFloat(a)||0),void 0===n&&(n=o?1:-1);var l=void 0!==r||o,i=r||a;if(-1===n)return l?i-kt(t,["border","padding"],s):a;if(l){var c=2===n?-kt(t,["border"],s):kt(t,["margin"],s);return i+(1===n?0:c)}return a+kt(t,Lt.slice(n),s)}Et(["Width","Height"],(function(t){Ot["doc".concat(t)]=function(e){var n=e.document;return Math.max(n.documentElement["scroll".concat(t)],n.body["scroll".concat(t)],Ot["viewport".concat(t)](n))},Ot["viewport".concat(t)]=function(e){var n="client".concat(t),s=e.document,r=s.body,o=s.documentElement[n];return"CSS1Compat"===s.compatMode&&o||r&&r[n]||o}}));var Rt={position:"absolute",visibility:"hidden",display:"block"};function Ut(t){var e,n=arguments;return 0!==t.offsetWidth?e=Dt.apply(void 0,n):function(t,e,n){var s,r={},o=t.style;for(s in e)e.hasOwnProperty(s)&&(r[s]=o[s],o[s]=e[s]);for(s in n.call(t),e)e.hasOwnProperty(s)&&(o[s]=r[s])}(t,Rt,(function(){e=Dt.apply(void 0,n)})),e}function Mt(t,e,n){var s=n;if("object"!==ft(e))return void 0!==s?("number"==typeof s&&(s+="px"),void(t.style[e]=s)):vt(t,e);for(var r in e)e.hasOwnProperty(r)&&Mt(t,r,e[r])}Et(["width","height"],(function(t){var e=t.charAt(0).toUpperCase()+t.slice(1);Ot["outer".concat(e)]=function(e,n){return e&&Ut(e,t,n?0:1)};var n="width"===t?["Left","Right"]:["Top","Bottom"];Ot[t]=function(e,s){if(void 0===s)return e&&Ut(e,t,-1);if(e){vt(e);return Nt(e)&&(s+=kt(e,["padding","border"],n)),Mt(e,t,s)}}}));var zt=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?yt(n,!0).forEach((function(e){mt(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yt(n).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({getWindow:function(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow},offset:function(t,e){if(void 0===e)return wt(t);!function(t,e){"static"===Mt(t,"position")&&(t.style.position="relative");var n,s,r=wt(t),o={};for(s in e)e.hasOwnProperty(s)&&(n=parseFloat(Mt(t,s))||0,o[s]=n+e[s]-r[s]);Mt(t,o)}(t,e)},isWindow:At,each:Et,css:Mt,clone:function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);if(t.overflow)for(var s in t)t.hasOwnProperty(s)&&(e.overflow[s]=t.overflow[s]);return e},scrollLeft:function(t,e){if(At(t)){if(void 0===e)return xt(t);window.scrollTo(e,bt(t))}else{if(void 0===e)return t.scrollLeft;t.scrollLeft=e}},scrollTop:function(t,e){if(At(t)){if(void 0===e)return bt(t);window.scrollTo(xt(t),e)}else{if(void 0===e)return t.scrollTop;t.scrollTop=e}},viewportWidth:0,viewportHeight:0},Ot);const Ft=function(t,e,n){n=n||{},9===e.nodeType&&(e=zt.getWindow(e));var s=n.allowHorizontalScroll,r=n.onlyScrollIfNeeded,o=n.alignWithTop,a=n.alignWithLeft,l=n.offsetTop||0,i=n.offsetLeft||0,c=n.offsetBottom||0,d=n.offsetRight||0;s=void 0===s||s;var p,u,g,h,f,m,y,_,x,b,w=zt.isWindow(e),v=zt.offset(t),j=zt.outerHeight(t),P=zt.outerWidth(t);w?(y=e,b=zt.height(y),x=zt.width(y),_={left:zt.scrollLeft(y),top:zt.scrollTop(y)},f={left:v.left-_.left-i,top:v.top-_.top-l},m={left:v.left+P-(_.left+x)+d,top:v.top+j-(_.top+b)+c},h=_):(p=zt.offset(e),u=e.clientHeight,g=e.clientWidth,h={left:e.scrollLeft,top:e.scrollTop},f={left:v.left-(p.left+(parseFloat(zt.css(e,"borderLeftWidth"))||0))-i,top:v.top-(p.top+(parseFloat(zt.css(e,"borderTopWidth"))||0))-l},m={left:v.left+P-(p.left+g+(parseFloat(zt.css(e,"borderRightWidth"))||0))+d,top:v.top+j-(p.top+u+(parseFloat(zt.css(e,"borderBottomWidth"))||0))+c}),f.top<0||m.top>0?!0===o?zt.scrollTop(e,h.top+f.top):!1===o?zt.scrollTop(e,h.top+m.top):f.top<0?zt.scrollTop(e,h.top+f.top):zt.scrollTop(e,h.top+m.top):r||((o=void 0===o||!!o)?zt.scrollTop(e,h.top+f.top):zt.scrollTop(e,h.top+m.top)),s&&(f.left<0||m.left>0?!0===a?zt.scrollLeft(e,h.left+f.left):!1===a?zt.scrollLeft(e,h.left+m.left):f.left<0?zt.scrollLeft(e,h.left+f.left):zt.scrollLeft(e,h.left+m.left):r||((a=void 0===a||!!a)?zt.scrollLeft(e,h.left+f.left):zt.scrollLeft(e,h.left+m.left)))};var It=n(860),Bt=n(631),Vt=n.n(Bt);const Wt=({value:t,post:e=null,translatedPosts:n,translationData:s,language:r})=>{(0,a.isEmpty)(e)?(s.translated_post={id:null,title:t},s.links={add_link:s.links.add_link},n.delete(r.slug)):(n.set(r.slug,e.id),s.translated_post={id:e.id,title:e.title.raw},s.block_editor={edit_link:e.block_editor.edit_link},s.caps=e.caps),(0,m.dispatch)(x).editPost({translations:S(n)}),(0,m.dispatch)(x).editPost({title:(0,m.select)(x).getEditedPostAttribute("title")})},$t=t=>t.stopPropagation();class Ht extends t.Component{constructor(){super(...arguments),this.onChange=this.onChange.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.bindListNode=this.bindListNode.bind(this),this.updateSuggestions=(0,a.debounce)(this.updateSuggestions.bind(this),500),this.suggestionNodes=[],this.state={posts:[],showSuggestions:!1,selectedSuggestion:null}}componentDidUpdate(){const{showSuggestions:t,selectedSuggestion:e}=this.state;t&&null!==e&&!this.scrollingIntoView&&(this.scrollingIntoView=!0,Ft(this.suggestionNodes[e],this.listNode,{onlyScrollIfNeeded:!0}),setTimeout((()=>{this.scrollingIntoView=!1}),100))}componentWillUnmount(){delete this.suggestionsRequest}bindListNode(t){this.listNode=t}bindSuggestionNode(t){return e=>{this.suggestionNodes[t]=e}}updateSuggestions(t,e=!1){if(t.length<2&&!e)return void this.setState({showSuggestions:!1,selectedSuggestion:null,loading:!1});this.setState({selectedSuggestion:null,loading:!0});const n=(0,m.select)(x).getCurrentPostId(),s=(0,m.select)(x).getCurrentPostType(),r=(0,m.select)(x).getEditedPostAttribute("lang"),o=this.props.translationData.lang.slug,a=Vt()({path:(0,y.addQueryArgs)("/pll/v1/untranslated-posts",{search:t,include:n,untranslated_in:r,lang:o,type:s,context:"edit"})});a.then((t=>{this.suggestionsRequest===a&&(this.setState({posts:t,showSuggestions:!0,loading:!1}),t.length?this.props.debouncedSpeak((0,I.sprintf)((0,I._n)("%d result found, use up and down arrow keys to navigate.","%d results found, use up and down arrow keys to navigate.",t.length,"polylang-pro"),t.length),"assertive"):this.props.debouncedSpeak((0,I.__)("No results.","polylang-pro"),"assertive"))})).catch((()=>{this.suggestionsRequest===a&&this.setState({loading:!1})})),this.suggestionsRequest=a}onChange(t){const e=t.target.value,n=this.props.translatedPosts,s=this.props.translationData,r=this.props.translationData.lang;Wt({value:e,translatedPosts:n,translationData:s,language:r}),this.updateSuggestions(e)}onKeyDown(t){const{showSuggestions:e,selectedSuggestion:n,posts:s,loading:r}=this.state;let o=t.target.value,l=!1;if(e&&s.length&&!r)switch(t.keyCode){case It.UP:{t.stopPropagation(),t.preventDefault();const e=n?n-1:s.length-1;this.setState({selectedSuggestion:e});break}case It.DOWN:{t.stopPropagation(),t.preventDefault();const e=null===n||n===s.length-1?0:n+1;this.setState({selectedSuggestion:e});break}case It.ENTER:if(null!==this.state.selectedSuggestion){t.stopPropagation();const e=this.state.posts[this.state.selectedSuggestion];this.selectLink(e)}break;case It.ESCAPE:t.stopPropagation(),this.setState({selectedSuggestion:null,showSuggestions:!1})}else{switch(t.keyCode){case It.SPACE:const{ctrlKey:e,shiftKey:n,altKey:s,metaKey:r}=t;e&&!(n||s||r)&&(o="",l=!0);break;case It.BACKSPACE:(0,a.isEmpty)(o)&&(l=!0)}l&&this.updateSuggestions(o,!0)}}selectLink(t){const e=this.props.translationData,n=this.props.translatedPosts,s=this.props.translationData.lang;Wt({value:t.title.raw,post:t,translatedPosts:n,translationData:e,language:s}),this.setState({selectedSuggestion:null,showSuggestions:!1})}render(){const{value:t="",autoFocus:e=!0,instanceId:n,translationData:s}=this.props,r=s.lang,{showSuggestions:o,posts:a,selectedSuggestion:i,loading:c}=this.state,d=s.caps.edit||s.caps.add;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("label",{className:"screen-reader-text",htmlFor:`tr_lang_${s.lang.slug}`,children:(0,I.__)("Translation","polylang-pro")}),(0,l.jsxs)("div",{className:"translation-input",children:[(0,l.jsx)("input",{lang:r.w3c,dir:r.is_rtl?"rtl":"ltr",style:{direction:r.is_rtl?"rtl":"ltr"},autoFocus:e,disabled:!d,type:"text","aria-label":(0,I.__)("URL","polylang-pro"),required:!0,value:t,onChange:this.onChange,onInput:$t,placeholder:(0,I.__)("Start typing the post title","polylang-pro"),onKeyDown:this.onKeyDown,role:"combobox","aria-expanded":o,"aria-autocomplete":"list","aria-owns":`translation-input-suggestions-${n}`,"aria-activedescendant":null!==i?`translation-input-suggestion-${n}-${i}`:void 0}),c&&(0,l.jsx)($.Spinner,{})]}),o&&!!a.length&&(0,l.jsx)($.Popover,{position:"bottom",noArrow:!0,focusOnMount:!1,children:(0,l.jsx)("div",{className:"translation-input__suggestions",id:`translation-input-suggestions-${n}`,ref:this.bindListNode,role:"listbox",children:a.map(((t,e)=>(0,l.jsx)("button",{role:"option",tabIndex:"-1",id:`translation-input-suggestion-${n}-${e}`,ref:this.bindSuggestionNode(e),className:ht()("translation-input__suggestion",{"is-selected":e===i}),onClick:()=>this.selectLink(t),"aria-selected":e===i,children:t.title.raw||(0,I.__)("(no title)","polylang-pro")},t.id)))})})]})}}const Gt=(0,$.withSpokenMessages)((0,it.withInstanceId)(Ht)),Kt=({language:t,children:e})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Z,{language:t}),e]}),qt=({selectedLanguage:t,translationsTable:e})=>{const n=E((0,m.select)(x).getEditedPostAttribute("translations"),e,t.slug);return Array.from(e.values()).map((e=>{if(t.slug===e.lang.slug)return;const s=null!=e.translated_post?.id,r=e.caps.edit,o=e.caps.add;return(0,l.jsx)("tr",{children:(0,l.jsxs)(Kt,{language:e.lang,children:[(0,l.jsx)(Y,{children:s&&r?(0,l.jsx)(lt,{href:decodeURI(e.block_editor.edit_link),language:e.lang}):o?(0,l.jsx)(nt,{href:decodeURI(e.links.add_link),language:e.lang}):null}),(0,l.jsx)(tt,{children:e.can_synchronize&&(0,l.jsx)(ut,{translationData:e})}),(0,l.jsx)(et,{children:(0,l.jsx)(Gt,{id:`htr_lang_${e.lang.slug}`,autoFocus:!1,translatedPosts:n,translationData:e,value:void 0!==e.translated_post?.title?e.translated_post?.title:""})})]})},e.lang.slug)}))},Qt=({isDefaultLang:t})=>(0,l.jsxs)(l.Fragment,{children:[t?(0,l.jsxs)("p",{children:[(0,I.__)("You are about to delete an entity in the default language.","polylang-pro"),(0,l.jsx)("br",{}),(0,I.__)("This will delete its customizations and all its corresponding translations.","polylang-pro")]}):null,(0,l.jsx)("p",{children:(0,I.__)("Are you sure you want to delete this translation?","polylang-pro")})]});var Yt=n(488);const Xt=()=>{const{deleteEntityRecord:t}=(0,m.useDispatch)(Yt.store),{createSuccessNotice:e,createErrorNotice:n}=(0,m.useDispatch)(M.store);return{handleDelete:async(s,r)=>{try{const n=!P.includes(r);await t("postType",r,s,{force:n},{throwOnError:!0}),e((0,I.__)("The translation has been deleted.","polylang-pro"),{type:"snackbar"})}catch(t){n((0,I.sprintf)((0,I.__)("Unable to delete the translation. %s","polylang-pro"),t?.message),{type:"snackbar"})}}}},Jt=(t,e)=>{if(!t.is_default||"page"===e)return;const n=window.location.origin+wp.sanitize.stripTags(window.location.pathname),s={};switch(e){case"wp_navigation":s.path="/navigation";break;case"wp_block":s.path="/patterns",s.categoryType=e;break;case"wp_template_part":s.path="/"+e+"/all"}location.href=(0,y.addQueryArgs)(n,s)},Zt=({translationData:e,postType:n,onDeleteSuccess:s})=>{const[r,o]=(0,t.useState)(!1),a=()=>o(!1),i=null!=e.translated_post?.id,c=e.caps.delete,{handleDelete:d}=Xt();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(st,{onClick:()=>o(!0),language:e.lang,disabled:!i||!c}),r&&(0,l.jsxs)($.Modal,{title:"Delete",onRequestClose:a,children:[(0,l.jsx)(Qt,{isDefaultLang:e.lang.is_default&&"page"!==n}),(0,l.jsxs)("div",{role:"group",className:"components-button-group buttons",children:[(0,l.jsx)($.Button,{variant:"tertiary",onClick:a,type:"button",children:(0,I.__)("Cancel","polylang-pro")}),(0,l.jsx)("span",{children:" "}),(0,l.jsx)($.Button,{variant:"primary",onClick:()=>{const t="wp_template_part"===n&&void 0!==e.template?e.template.id:e.translated_post.id;d(t,n).then((()=>s())),a(),Jt(e.lang,n)},type:"submit",children:(0,I.__)("Delete","polylang-pro")})]})]})]})},te=()=>{const{saveEntityRecord:t}=(0,m.useDispatch)(Yt.store),{createSuccessNotice:e,createErrorNotice:n}=(0,m.useDispatch)(M.store);return{handleCreateTranslation:async(s,r)=>{const o={title:r.title.raw,content:r.content.raw,lang:s,from_post:r.id,translations:r.translations,status:r.status};if("wp_template_part"===r.type){const t=function(){let t="[a-z_-]+";const e=(0,m.select)(_).getLanguages(),n=Array.from(e.keys());return(0,a.isEmpty)(n)||(t=n.join("|")),new RegExp(`___(?:${t})$`)}(),e=r.slug.replace(t,""),n={[r.lang]:r.wp_id};o.slug=e,o.area=r.area,o.from_post=r.wp_id,o.translations=n}try{const n=await t("postType",r.type,o,{throwOnError:!0});e((0,I.__)("The translation is created, you will be redirected.","polylang-pro"),{type:"snackbar"});const a=n.translations_table[s]?.site_editor.edit_link;void 0!==a&&(location.href=a)}catch(t){const e=t.message&&"unknown_error"!==t.code?t.message:(0,I.__)("An error occurred while creating the translation.","polylang-pro");n(e,{type:"snackbar"})}}}},ee=({translationsTable:t,currentPost:e,translationsTabeDispatch:n})=>{const{handleCreateTranslation:s}=te();return Array.from(t.values()).map((t=>{if(e?.lang===t.lang.slug)return;const r=null!=t.translated_post?.id,o=t.caps.edit,a="wp_template_part"===e.type&&!e.wp_id||t.caps.add;return(0,l.jsx)("tr",{children:(0,l.jsxs)(Kt,{language:t.lang,children:[(0,l.jsx)(et,{children:(0,l.jsx)("span",{className:"pll-translation-language",children:t.lang.name})}),(0,l.jsx)(Y,{children:(()=>{if(r&&o)return(0,l.jsx)(lt,{href:decodeURI(t.site_editor.edit_link),language:t.lang});if(a){const n=()=>{s(t.lang.slug,e)};return(0,l.jsx)(nt,{href:"#",language:t.lang,handleAddClick:n})}return null})()}),(0,l.jsx)(J,{children:(0,l.jsx)(Zt,{translationData:t,postType:e.type,onDeleteSuccess:function(){n({type:"remove_translation",lang:t.lang.slug})}})}),(0,l.jsx)(X,{isDefault:t.lang.is_default})]})},t.lang.slug)}))},ne=({children:t})=>(0,l.jsxs)("div",{id:"post-translations",className:"translations",children:[(0,l.jsx)("p",{children:(0,l.jsx)("strong",{children:(0,I.__)("Translations","polylang-pro")})}),(0,l.jsx)("table",{children:(0,l.jsx)("tbody",{children:t})})]}),se=(t,e)=>{switch(e.type){case"remove_translation":return delete t.get(e.lang).translated_post,new Map(t);case"set_table":return e.table;default:return t}},re=()=>{const[e,n]=(0,t.useReducer)(se,new Map),[s,r]=(0,t.useState)({}),[o,a]=(0,t.useState)({}),[i,c]=(0,t.useState)("");return(0,t.useEffect)((()=>{let t;if("/wp_global_styles"===wp.sanitize.stripTagsAndEncodeText((0,y.getQueryArg)(window.location.href,"path"))&&(t="wp_global_styles"),"wp_template"===wp.sanitize.stripTagsAndEncodeText((0,y.getQueryArg)(window.location.href,"postType"))&&(t="wp_template"),t)return void c(t);const e=R();r(e),c(e?.type);const s=C(e?.lang);a(s),n({type:"set_table",table:L(e?.translations_table)})}),[r,c,a,n]),(0,l.jsxs)(Q,{isError:!o,isAllowedPostType:!j.includes(i),postType:i,children:[(0,l.jsx)(G,{language:o,currentPost:s}),(0,l.jsx)(ne,{children:(0,l.jsx)(ee,{translationsTable:e,currentPost:s,translationsTabeDispatch:n})})]})};function oe({handleChange:t,children:e,selectedLanguage:n=null,defaultValue:s=""}){const r=n?.slug?n.slug:s;return(0,l.jsxs)("div",{id:"select-post-language",children:[(0,l.jsx)(W,{language:n}),e&&(0,l.jsx)("select",{value:r,onChange:e=>t(e),id:"pll_post_lang_choice",name:"pll_post_lang_choice",className:"post_lang_choice",children:e})]})}function ae({languages:t}){return Array.from(t.values()).map((({slug:t,name:e,w3c:n})=>(0,l.jsx)("option",{value:t,lang:n,children:e},t)))}class le extends t.Component{static bypassConfirmation(){const t=(0,m.select)(x);return!t.getEditedPostAttribute("title")?.trim()&&!t.getEditedPostContent()&&!t.getEditedPostAttribute("excerpt")?.trim()}static getChangeValue(t){return t.target.value}static handleLanguageChange(t){const e=(0,m.select)(x).getEditedPostAttribute("lang"),n=(0,m.select)(x).getCurrentPostId(),s=(0,m.select)(_).getLanguages().get(t),r=C(e),o=N((0,m.select)(x).getEditedPostAttribute("pll_sync_post")),a=(0,m.select)(x).getEditedPostAttribute("translations_table"),l=E((0,m.select)(x).getEditedPostAttribute("translations"),a,r.slug),i=L(a,r.slug);l.delete(r.slug),l.set(s.slug,n),o.delete(r.slug);const c=i.get(r.slug);i.set(r.slug,{can_synchronize:c.can_synchronize,lang:c.lang,links:{add_link:c.links.add_link},caps:c.caps,site_editor:c.site_editor,block_editor:c.block_editor});const d=i.get(s.slug);i.set(s.slug,{can_synchronize:d.can_synchronize,lang:d.lang,links:d.links,translated_post:c.translated_post,caps:d.caps,site_editor:d.site_editor,block_editor:d.block_editor}),pll_block_editor_plugin_settings.lang=s;const p={lang:s.slug,pll_sync_post:S(o),translations:S(l),translations_table:S(i)};(0,m.dispatch)(x).editPost(p),(0,m.dispatch)(x).savePost(),le.forceLanguageSave(s.slug),(0,m.dispatch)(w).invalidateResolutionForStore()}static forceLanguageSave(t){const e=(0,m.select)(x);e.getEditedPostAttribute("title")||e.getEditedPostContent()||e.getEditedPostAttribute("excerpt")||Vt()({path:(0,y.addQueryArgs)(`wp/v2/posts/${e.getCurrentPostId()}`,{lang:t}),method:"POST"})}render(){const e=(0,m.select)(_).getLanguages(),n=C((0,m.select)(x).getEditedPostAttribute("lang"));return(0,l.jsxs)(t.Fragment,{children:[(0,l.jsx)("p",{children:(0,l.jsx)("strong",{children:(0,I.__)("Language","polylang-pro")})}),(0,l.jsx)("label",{className:"screen-reader-text",htmlFor:"pll_post_lang_choice",children:(0,I.__)("Language","polylang-pro")}),(0,l.jsx)(oe,{selectedLanguage:n,handleChange:this.props.handleChange,children:(0,l.jsx)(ae,{languages:e})})]})}}le.labelConfirmationModal=(0,I.__)("Change language","polylang-pro");const ie=dt("pll_change_lang",(function(){return(0,l.jsx)("p",{children:(0,I.__)("Are you sure you want to change the language of the current content?","polylang-pro")})}),le.handleLanguageChange)(le),ce=()=>{const{currentPost:t,currentPostType:e,selectedLanguage:n,translationsTable:s,isAllowedPostType:r}=(0,m.useSelect)((t=>{const e=t(x).getCurrentPost(),n=t(x).getCurrentPostType(),s=t(x).getEditedPostAttribute("lang"),r=t(x).getEditedPostAttribute("translations_table"),o=!j.includes(e?.type);return{currentPost:e,currentPostType:n,selectedLanguage:C(s),translationsTable:L(r),isAllowedPostType:o}}),[]),o=pll_block_editor_plugin_settings.machine_translation;return(0,l.jsxs)(Q,{isError:!n,isAllowedPostType:r,postType:t?.type,children:[(0,l.jsx)(ie,{selectedLanguage:n}),(0,l.jsx)(at,{postType:e}),o?.isActive&&(0,l.jsx)(ot,{postType:e,slug:o.slug,name:o.name,icon:o.icon}),(0,l.jsx)(ne,{children:(0,l.jsx)(qt,{translationsTable:s,selectedLanguage:n})})]})},de={setLanguages:t=>({type:"SET_LANGUAGES",languages:t}),setCurrentUser:(t,e=!1)=>({type:"SET_CURRENT_USER",currentUser:t,save:e}),setFromPost:t=>({type:"SET_FROM_POST",fromPost:t}),fetchFromAPI:t=>({type:"FETCH_FROM_API",options:t})},pe=(0,m.createReduxStore)(_,{reducer(t=v,e){switch(e.type){case"SET_LANGUAGES":return{...t,languages:e.languages};case"SET_CURRENT_USER":if(!e.save)return{...t,currentUser:e.currentUser};(n=e.currentUser,Promise.resolve(Vt()({path:"/wp/v2/users/me",data:n,method:"POST"}))).then((n=>(e.currentUser=n,{...t,currentUser:e.currentUser})));case"SET_FROM_POST":return{...t,fromPost:e.fromPost};case"SET_CURRENT_TEMPLATE_PART":return{...t,currentTemplatePart:e.currentTemplatePart};default:return t}var n},selectors:{getLanguages:t=>t.languages,getCurrentUser:t=>t.currentUser,getFromPost:t=>t.fromPost},actions:de,controls:{FETCH_FROM_API:t=>Vt()({...t.options})},resolvers:{*getLanguages(){const t=yield de.fetchFromAPI({path:"/pll/v1/languages",filterLang:!1});return de.setLanguages(function(t,e){const n=new Map;return t.reduce((function(t,n){return t.set(n[e],n),t}),n),n}(t,"slug"))},*getCurrentUser(){const t=yield de.fetchFromAPI({path:"/wp/v2/users/me",filterLang:!0});return de.setCurrentUser(t)}}});(0,m.register)(pe);const ue=document.createElement("div");ue.id="pll-root";const ge=document.body.appendChild(ue),he="polylang-sidebar",fe=pll_block_editor_plugin_settings?.machine_translation?.errors,me=(e,n)=>{t.createRoot?(0,t.createRoot)(n).render(e):(0,t.render)(e,n)};if(T()){const t=()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B,{PluginSidebarSlot:s.PluginSidebar,sidebarName:he,children:(0,l.jsx)(re,{})}),(0,l.jsx)(V,{PluginSidebarMoreMenuItemSlot:s.PluginSidebarMoreMenuItem,sidebarName:he})]});me((0,l.jsx)(f,{sidebar:t,sidebarName:he,onPromise:A,children:(0,l.jsx)(U,{onPromise:A})}),ge)}else{const t=()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B,{PluginSidebarSlot:e.PluginSidebar,sidebarName:he,children:(0,l.jsx)(ce,{})}),(0,l.jsx)(V,{PluginSidebarMoreMenuItemSlot:e.PluginSidebarMoreMenuItem,sidebarName:he})]});me((0,l.jsx)(f,{sidebar:t,sidebarName:he,onPromise:k,children:void 0!==fe&&(0,l.jsx)(F,{notices:fe})}),ge)}})(),this["polylang-pro"]={}})();