Liferay.Loader.define("@liferay/frontend-taglib@8.0.4/diff_version_comparator/index",["module","exports","require","@frontend-taglib-clay$clayui/card","@frontend-taglib-clay$clayui/form","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$react","./components/Diff","./components/Filter","./components/List","./components/LocaleSelector","./components/Selector","./utils/sub"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=p(a("@frontend-taglib-clay$clayui/card")),n=a("@frontend-taglib-clay$clayui/form"),l=a("@liferay/frontend-js-react-web"),o=a("frontend-js-web"),s=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=g();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),c=p(a("./components/Diff")),u=p(a("./components/Filter")),i=p(a("./components/List")),f=p(a("./components/LocaleSelector")),d=p(a("./components/Selector")),m=p(a("./utils/sub"));function g(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return g=function(){return e},e}function p(e){return e&&e.__esModule?e:{default:e}}var y=function({availableLocales:e,diffHtmlResults:t,diffVersions:a,languageId:g,nextVersion:p,portletNamespace:y,portletURL:v,previousVersion:b,resourceURL:L,sourceVersion:h,targetVersion:w}){const E=(0,l.useIsMounted)(),S=(0,s.useMemo)((()=>a.filter((e=>h!==e.version&&w!==e.version))),[a,h,w]),V=(0,s.useMemo)((()=>S.filter((e=>e.inRange))),[S]),j=(0,s.useCallback)((e=>{const t=new URL(L);return t.searchParams.append("".concat(y,"filterSourceVersion"),h),t.searchParams.append("".concat(y,"filterTargetVersion"),e),t.toString()}),[y,L,h]),[C,R]=(0,s.useState)(t),[N,O]=(0,s.useState)(j(w)),[x,M]=(0,s.useState)(""),[P,_]=(0,s.useState)(g),[$,k]=(0,s.useState)(null),[q,D]=(0,s.useState)(V),I=(0,s.useCallback)((e=>{const t=e.target.value.toLowerCase(),a=V.filter((({label:e,userName:a})=>e.toLowerCase().includes(t)||a.toLowerCase().includes(t)));M(t),D(a)}),[V]),U=(0,s.useRef)({[N]:C}),F=(0,s.useRef)(),T=(0,s.useCallback)((e=>{const t=e.target.closest("[data-version]"),a=t?t.dataset.version:null,r=V.find((e=>e.version===a));O(j(a||w)),k(r)}),[j,V,w]);return(0,s.useEffect)((()=>{const e=U.current[N];e?R(e):(0,o.fetch)(N).then((e=>e.text())).then((e=>{U.current[N]=e})).catch((()=>{U.current[N]=Liferay.Language.get("an-error-occurred-while-processing-the-requested-resource")})).finally((()=>{E()&&R(U.current[N])}))}),[N,E]),s.default.createElement("form",{action:v,className:"container-fluid container-fluid-max-xl container-view diff-version-comparator",method:"post",name:"".concat(y,"diffVersionFm"),ref:F},s.default.createElement(n.ClayInput,{name:"".concat(y,"sourceVersion"),type:"hidden",value:h}),s.default.createElement(n.ClayInput,{name:"".concat(y,"targetVersion"),type:"hidden",value:w}),s.default.createElement(r.default,{horizontal:!0},s.default.createElement(r.default.Body,null,s.default.createElement(r.default.Description,{displayType:"title"},Liferay.Language.get("you-are-comparing-these-versions")),s.default.createElement(r.default.Row,null,s.default.createElement("div",{className:"col-md-4"},s.default.createElement("div",{className:"float-right"},s.default.createElement(d.default,{label:(0,m.default)(Liferay.Language.get("version-x"),[h]),selectedVersion:b,uniqueVersionLabel:Liferay.Language.get("first-version"),urlSelector:"sourceURL",versions:S}))),s.default.createElement("div",{className:"col-md-8 diff-target-selector"},s.default.createElement(d.default,{label:(0,m.default)(Liferay.Language.get("version-x"),[w]),selectedVersion:p,uniqueVersionLabel:Liferay.Language.get("last-version"),urlSelector:"targetURL",versions:S}))),s.default.createElement("div",{className:"divider row"}),s.default.createElement(r.default.Row,null,s.default.createElement("div",{className:"col-md-4"},V.length>=5&&s.default.createElement(u.default,{onChange:I,query:x}),e&&e.length>1&&s.default.createElement(f.default,{locales:e,onChange:e=>{_(e.target.value),submitForm(F.current)},portletNamespace:y,selectedLanguageId:P}),s.default.createElement(i.default,{onChange:T,selected:$,versions:q})),s.default.createElement("div",{className:"col-md-8"},s.default.createElement(c.default,{diff:C,onClose:T,version:$}))))))};t.default=y}}));
//# sourceMappingURL=index.js.map