Liferay.Loader.define("data-engine-taglib@3.3.53/data_layout_builder/js/utils/client.es",["module","exports","require","frontend-js-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=getURL,t.addItem=function addItem(t,n){return fetchItem(getURL(t),{body:JSON.stringify(n),headers:e,method:"POST"})},t.deleteItem=deleteItem,t.confirmDelete=function confirmDelete(e){return t=>new Promise(((n,o)=>{(0,r.openConfirmModal)({message:Liferay.Language.get("are-you-sure-you-want-to-delete-this"),onConfirm:r=>{r?deleteItem(e+t.id).then((()=>n(!0))).catch((e=>o(e))):n(!1)}})}))},t.request=function request(t,n="GET"){return(0,r.fetch)(getURL(t),{headers:e,method:n})},t.getItem=function getItem(t){return(0,r.fetch)(getURL(t),{headers:e,method:"GET"}).then((e=>e.json()))},t.updateItem=function updateItem(t,n,r){return fetchItem(getURL(t,r),{body:JSON.stringify(n),headers:e,method:"PUT"})};var r=n("frontend-js-web");function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e={Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"};function fetchItem(e,t){return new Promise(((n,o)=>{let c;(0,r.fetch)(e,t).then((e=>(c=e.ok,e.json()))).then((e=>{c?n(e):o(e)})).catch((e=>o(e)))}))}function getURL(e,t){t=function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({p_auth:Liferay.authToken,t:Date.now()},t);let n=themeDisplay.getPathContext();n&&"/"!==n||(n="");const r=new URL("".concat(window.location.origin).concat(n).concat(e));return Object.keys(t).forEach((e=>r.searchParams.set(e,t[e]))),r.toString()}function deleteItem(e){return(0,r.fetch)(getURL(e),{method:"DELETE"})}}}));
//# sourceMappingURL=client.es.js.map