(function(){"use strict";u8.Crm.Sales=function(e){$.extend(this,e);this.id="sales"};$.extend(u8.Crm.Sales.prototype,{dispose:function(){if(this._isDisposed){return}this._isDisposed=true},queryStateCopyOfferToOrder:function(e){var r="__queryStateCanCopyOfferToOrder";var n=e&&e.source;if(!n){return t({error:"missing source widget"})}function i(e){return u8.isValidRecordUid(e)&&e.infoAreaId=="PR"}function t(e){return{visible:e.error||e.canCopyOfferToOrder,disabled:!!e.error,done:true}}if(n[r]===undefined){n[r]=null;var u=e&&e.uid;if(!i(u)&&typeof n.bubble=="function"){n.bubble("Action.onPreExecute",{arguments:e,__sales__:true});u=e.uid;if(!i(u)){u=e.link}}if(!i(u)){return t({error:"missing offer uid"})}this.canCopyOfferToOrder(u,function(e,i){n[r]=t(i)})}return n[r]||{visible:true,disabled:true,done:false}},canCopyOfferToOrder:function(e,r){if(!u8.isValidRecordUid(e)){return r&&r({error:"missing uid"})}this._readCanCopyOfferToOrder(e,function(e,n){return r&&r(e,n)})},readParticipantSuggestionTypes:function(e,r){e=e||"Y1";var n=e.startsWith("M_")?e:"M_BuyingCenterParticipantSuggestions"+e;u8.services.menus.load({menuName:n},function(e,n){var i=n.menu&&n.menu.rootItem||[];var t=[];i.each(function(e){if(e.children){return}t.push({key:e.name,text:e.label||e.name})},true);r(e,{types:t})})},readParticipantSuggestions:function(e,r,n){var i=this;if(arguments.length==2){var t=e;n=r;var u=t.endPoint;var s=$.extend({},t);delete s.endPoint;u8.request(u,{options:s},function(e,r){var t=r.response&&r.response.suggestions||[];n(i,{suggestions:t})})}else{var o=r.key;u8.services.actions.execute(o,{arguments:{uid:e}},function(e,r){var t=r.output&&r.output.suggestions||[];n(i,{uids:t.map(function(e){return e.uid})})})}},_readCanCopyOfferToOrder:function(e,r){var n=this;u8.services.crud.readLink({uid:e,linkName:"$Link[FI]"},function(e,i){if(i.error){return r&&r(n,{error:i.error})}return r&&r(n,{canCopyOfferToOrder:u8.isValidRecordUid(i.uid)})})}});u8.services.add("sales",u8.Crm.Sales);u8.services.menus.registerMenuItem("D_CopyOfferToOrder",{create:function(e,r){var n=$.Deferred();var i=e.executeOptions&&e.executeOptions.arguments&&e.executeOptions.arguments.uid;u8.services.sales.canCopyOfferToOrder(i,function(e,i){var t=r.menuItem;var u=i.canCopyOfferToOrder;if(u!=t.visible){t.visible=u;t.update()}n.resolve()});return n}});var e={create:function(e,r){if(!e||!e.executeOptions||!e.executeOptions.arguments||!e.executeOptions.arguments.uids||e.executeOptions.arguments.uids.length!=2){r.menuItem.disabled=true}}};u8.services.menus.registerMenuItem("D_WebMerge_Multiple_Properties",e)})();