Liferay.Loader.define("depot-web@2.0.68/js/LanguageListItemEditable.es",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/label","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/table","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/drop-down")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/label")),d=_interopRequireDefault(a("@frontend-taglib-clay$clayui/layout")),u=_interopRequireDefault(a("@frontend-taglib-clay$clayui/table")),o=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),c=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),f=a("liferay!frontend-js-react-web$react-dnd");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={BOTTOM:"BOTTOM",TOP:"TOP"},s={ITEM:"ITEM"},g=28,isValidTarget=(t,a,l)=>!(t.id===a.id||!(l===e.TOP&&(a.index<t.index||a.index>t.index+1)||l===e.BOTTOM&&(a.index>t.index||a.index<t.index-1))),getDropZone=(t,a)=>{if(!t.current)return;const l=a.getClientOffset(),r=t.current.getBoundingClientRect(),n=l.y-r.top;let i=e.BOTTOM;return n<g&&(i=e.TOP),i},noop=()=>{};var _default=({displayName:t,isDefault:a,localeId:g,onMakeDefault:y,isFirst:p=!1,isLast:m=!1,index:b,onItemDrop:O=noop,onMoveUp:T=noop,onMoveDown:v=noop})=>{const[D,w]=(0,c.useState)(!1),[E,$]=(0,c.useState)(),_=(0,c.useRef)(),[{isDragging:C},M]=(0,f.useDrag)({collect:e=>({isDragging:!!e.isDragging()}),item:{id:g,index:b,type:s.ITEM}}),[{isOver:R},j]=(0,f.useDrop)({accept:s.ITEM,canDrop(e,t){const a=getDropZone(_,t);return isValidTarget(e,{id:g,index:b},a)},collect:e=>({isOver:!!e.isOver()}),drop(t,a){if(a.canDrop()){let a=b;E===e.BOTTOM&&(a=b+1),a>t.index&&(a-=1),O(t.index,a)}},hover(e,t){let a;R&&t.canDrop()&&(a=getDropZone(_,t)),$(a)}});return(0,c.useEffect)((()=>{M(j(_))}),[M,j]),c.default.createElement(u.default.Row,{className:(0,o.default)("language-list-item",{dragging:C,"drop-bottom":R&&E===e.BOTTOM,"drop-top":R&&E===e.TOP}),ref:_},c.default.createElement(u.default.Cell,{expanded:!0},c.default.createElement(d.default.ContentRow,{verticalAlign:"center"},c.default.createElement(d.default.ContentCol,{className:"autofit-padded-no-gutters"},c.default.createElement("div",{className:"language-drag-handler"},c.default.createElement(n.default,{symbol:"drag"}))),c.default.createElement(d.default.ContentCol,{className:"align-items-center autofit-padded-no-gutters flex-row justify-content-start",expand:!0},t,a&&c.default.createElement(i.default,{className:"ml-3",displayType:"info"},Liferay.Language.get("default"))))),c.default.createElement(u.default.Cell,{align:"right"},c.default.createElement(r.default,{active:D,onActiveChange:w,trigger:c.default.createElement(l.default,{borderless:!0,displayType:"secondary",monospaced:!0,small:!0},c.default.createElement(n.default,{symbol:"ellipsis-v"}))},c.default.createElement(r.default.ItemList,null,c.default.createElement(r.default.Item,{"data-value":g,key:g,onClick:e=>{w(!1),y({localeId:g}),Liferay.fire("inputLocalized:defaultLocaleChanged",{item:e.currentTarget})}},Liferay.Language.get("make-default")),!p&&c.default.createElement(r.default.Item,{onClick:()=>{w(!1),T()}},Liferay.Language.get("move-up")),!m&&c.default.createElement(r.default.Item,{onClick:()=>{w(!1),v()}},Liferay.Language.get("move-down"))))))};t.default=_default}}));
//# sourceMappingURL=LanguageListItemEditable.es.js.map