@livetiles/reach-components-react 0.4.0-preview.313 → 0.4.0-preview.324

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm2.js CHANGED
@@ -87849,9 +87849,9 @@ var AuthenticationContextProvider = function AuthenticationContextProvider(_a) {
87849
87849
  }), void 0);
87850
87850
  };
87851
87851
 
87852
- var version$1 = "0.4.0-preview.313";
87853
- var buildId = "100376";
87854
- var commitId = "916b802c1949cb2127b24368855e41b9dc4fafc1";
87852
+ var version$1 = "0.4.0-preview.324";
87853
+ var buildId = "100453";
87854
+ var commitId = "783194e07bc96fdd227c6b070f903fff897fab14";
87855
87855
  var isCustomerBuild = false;
87856
87856
  var buildInfo = {
87857
87857
  version: version$1,
@@ -131936,7 +131936,7 @@ if(nativeRevokeObjectURL)redefine$3(URLConstructor,'revokeObjectURL',function re
131936
131936
  var MDN_POLYFILL_BUG$1=!CORRECT_IS_REGEXP_LOGIC$1&&!!function(){var descriptor=getOwnPropertyDescriptor$2(String.prototype,'startsWith');return descriptor&&!descriptor.writable;}();// `String.prototype.startsWith` method
131937
131937
  // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
131938
131938
  $$a({target:'String',proto:true,forced:!MDN_POLYFILL_BUG$1&&!CORRECT_IS_REGEXP_LOGIC$1},{startsWith:function startsWith(searchString/* , position = 0 */){var that=String(requireObjectCoercible$4(this));notARegExp$1(searchString);var index=toLength$6(min$3(arguments.length>1?arguments[1]:undefined,that.length));var search=String(searchString);return nativeStartsWith?nativeStartsWith.call(that,search,index):that.slice(index,index+search.length)===search;}});var mentionRegex=/[@#](\[(.+?)]\((.+?)\))/gi;var CommentInput=/*#__PURE__*/forwardRef(function(_a,ref){var disabled=_a.disabled,onEnter=_a.onEnter,onCtrlEnter=_a.onCtrlEnter,buttons=_a.buttons,content=_a.content,onChange=_a.onChange,onFocus=_a.onFocus,autoFocus=_a.autoFocus,className=_a.className,mentionSearchHandler=_a.mentionSearchHandler,placeHolderStringResourceKey=_a.placeHolderStringResourceKey,placeHolderStringResourceValues=_a.placeHolderStringResourceValues,disableBoxShadow=_a.disableBoxShadow,ariaLabel=_a.ariaLabel,additionalInputControl=_a.additionalInputControl;var formatMessage=useIntl().formatMessage;var handleSearch=useMentionsSearch(mentionSearchHandler,handleSearchComplete);var inputRef=useRef$1(null);var hostRef=useRef$1(null);// exists only for e2e tests, so we know when the focus has been set
131939
- var _b=useState$2(false),didInitialFocus=_b[0],setDidInitialFocus=_b[1];var showEmojiButton=!env.isNativeMobileApp;var screenSize=useWindowSize$2();var inputPlaceholder=screenSize.width>maxScreenSize.medium?'PostMessage.inputPlaceholder':'PostMessage.inputPlaceholder.mobile';useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);useEffect$1(function(){if(autoFocus&&inputRef.current&&!didInitialFocus&&!disabled){// HACK: it seems as the react-mentions input does not like setting the focus
131939
+ var _b=useState$2(false),didInitialFocus=_b[0],setDidInitialFocus=_b[1];var showEmojiButton=!env.isNativeMobileApp;useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);useEffect$1(function(){if(autoFocus&&inputRef.current&&!didInitialFocus&&!disabled){// HACK: it seems as the react-mentions input does not like setting the focus
131940
131940
  // right away. Postpone it for a couple of ms
131941
131941
  // Unfortunately autoFocus={true} is not supported
131942
131942
  setTimeout(function(){focusOnEnd(inputRef.current);setDidInitialFocus(true);});}},[inputRef,autoFocus,didInitialFocus,disabled]);return jsxs(Host$W,__assign({ref:hostRef,className:classNames('comment-input__host',className),"data-comment-input":true,"data-did-initial-focus":didInitialFocus,disableBoxShadow:disableBoxShadow},{children:[jsxs(InputContainer,{children:[jsx$1(MentionsInput$1,__assign({className:"comment-input",value:content,singleLine:false,allowSpaceInQuery:true,onKeyDown:handleKeyDown,onChange:function(event){return onChange(event.target.value);},placeholder:getPlaceholder(),disabled:disabled,inputRef:inputRef,allowSuggestionsAboveCursor:true,onFocus:onFocus,"aria-label":ariaLabel},{children:jsx$1(Mention$1,{trigger:"@",data:handleSearch,appendSpaceOnAdd:true,renderSuggestion:function(s){var userSuggestion=s;return jsx$1(Avatar,{upn:userSuggestion.upn,text:userSuggestion.displayName,secondaryText:userSuggestion.upn},s.id);}},void 0)}),void 0),additionalInputControl]},void 0),jsxs(Buttons$4,{children:[((buttons===null||buttons===void 0?void 0:buttons.leftSide)||showEmojiButton)&&jsx$1(Fragment,{children:jsxs(LeftSide,{children:[buttons===null||buttons===void 0?void 0:buttons.leftSide,jsx$1(EmojiButton,{onEmojiSelected:handleAddEmoji,disabled:disabled},void 0)]},void 0)},void 0),(buttons===null||buttons===void 0?void 0:buttons.rightSide)&&jsx$1(RightSide,{children:buttons.rightSide},void 0)]},void 0)]}),void 0);function handleAddEmoji(emoji){var mentionMatches=__spreadArray([],Array.from(getAllMatches(content,mentionRegex)));var cursorPosition=getCorrectCursorPosition(inputRef.current.selectionStart,mentionMatches);var end=getCorrectCursorPosition(inputRef.current.selectionEnd,mentionMatches);var before=content.substring(0,cursorPosition);var after=content.substring(end);onChange(before+emoji+after);setTimeout(function(){inputRef.current.focus();inputRef.current.setSelectionRange(cursorPosition+2,cursorPosition+2);},0);}function getCorrectCursorPosition(cursorPosition,matches){// this method is required because for the user visible content in the textbox will look like this:
@@ -131958,7 +131958,7 @@ suggestionsContainer.style.maxWidth=hostRect.width-4+"px";// this block fixes th
131958
131958
  // probably because we have a "custom" input box, the calculation of the
131959
131959
  // the mention library is not entirely correct, therefore we add our own
131960
131960
  // top / bottom values
131961
- if(inputBox.top<500){suggestionsContainer.style.top=inputBox.height-10+"px";}else {suggestionsContainer.style.bottom=inputBox.height+"px";suggestionsContainer.style.top='unset';}}function getPlaceholder(){var placeholder=formatMessage({id:placeHolderStringResourceKey||inputPlaceholder},placeHolderStringResourceValues);if(!onCtrlEnter){return placeholder;}var browserHint=formatMessage({id:'PostMessage.inputPlaceholderHint'},{keyName:'CTRL'});return placeholder+" "+browserHint;}});function useMentionsSearch(mentionSearchHandler,handleSearchComplete){var _this=this;var searchSubject=useRef$1(new Subject());useEffect$1(function(){var subscription=searchSubject.current.pipe(debounceTime(500),switchMap(function(args){return __awaiter(_this,void 0,void 0,function(){var users;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,mentionSearchHandler(args.searchText)];case 1:users=_a.sent();args.updateSuggestions(users.map(function(u){return {id:u.id,upn:u.userPrincipalName,displayName:u.displayName,display:'@'+u.displayName};}));return [2/*return*/,users];}});});})).subscribe(function(){return handleSearchComplete();});return function(){subscription&&subscription.unsubscribe();};// eslint-disable-next-line react-hooks/exhaustive-deps
131961
+ if(inputBox.top<500){suggestionsContainer.style.top=inputBox.height-10+"px";}else {suggestionsContainer.style.bottom=inputBox.height+"px";suggestionsContainer.style.top='unset';}}function getPlaceholder(){var placeholder=formatMessage({id:placeHolderStringResourceKey||'CommentInput.placeholder'},placeHolderStringResourceValues);if(!onCtrlEnter){return placeholder;}var browserHint=formatMessage({id:'CommentInput.placeholderHint'},{keyName:'CTRL'});return placeholder+" "+browserHint;}});function useMentionsSearch(mentionSearchHandler,handleSearchComplete){var _this=this;var searchSubject=useRef$1(new Subject());useEffect$1(function(){var subscription=searchSubject.current.pipe(debounceTime(500),switchMap(function(args){return __awaiter(_this,void 0,void 0,function(){var users;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,mentionSearchHandler(args.searchText)];case 1:users=_a.sent();args.updateSuggestions(users.map(function(u){return {id:u.id,upn:u.userPrincipalName,displayName:u.displayName,display:'@'+u.displayName};}));return [2/*return*/,users];}});});})).subscribe(function(){return handleSearchComplete();});return function(){subscription&&subscription.unsubscribe();};// eslint-disable-next-line react-hooks/exhaustive-deps
131962
131962
  },[]);return function(searchText,updateSuggestions){searchSubject.current.next({searchText:searchText,updateSuggestions:updateSuggestions});};}var Host$W=_styled.div.withConfig({displayName:"CommentInput__Host",componentId:"sc-777bqz-0"})(templateObject_2$1y||(templateObject_2$1y=__makeTemplateObject(["\n display: flex;\n flex-direction: column;\n position: relative;\n ","\n\n textarea {\n font-family: 'Roboto', sans-serif !important;\n font-size: 14px;\n line-height: ","px;\n }\n\n .comment-input__suggestions {\n @media (max-width: ","px) {\n max-height: 300px;\n overflow-y: auto;\n padding-right: ","px;\n }\n\n &__list {\n background-color: white;\n border: 1px solid rgba(0, 0, 0, 0.15);\n width: 100%;\n }\n &__item {\n padding: 5px 15px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n &:last-of-type {\n border-bottom: none;\n }\n\n &--focused {\n background-color: ",";\n }\n }\n }\n"],["\n display: flex;\n flex-direction: column;\n position: relative;\n ","\n\n textarea {\n font-family: 'Roboto', sans-serif !important;\n font-size: 14px;\n line-height: ","px;\n }\n\n .comment-input__suggestions {\n @media (max-width: ","px) {\n max-height: 300px;\n overflow-y: auto;\n padding-right: ","px;\n }\n\n &__list {\n background-color: white;\n border: 1px solid rgba(0, 0, 0, 0.15);\n width: 100%;\n }\n &__item {\n padding: 5px 15px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n\n &:last-of-type {\n border-bottom: none;\n }\n\n &--focused {\n background-color: ",";\n }\n }\n }\n"])),function(p){return p.disableBoxShadow?css$2(templateObject_1$2l||(templateObject_1$2l=__makeTemplateObject(["\n border: 1px solid ",";\n "],["\n border: 1px solid ",";\n "])),function(p){return p.theme.palette.neutralTertiaryAlt;}):CardBorderInline(2,2);},spacingM,maxScreenSize.medium,spacingXxs,defaultPageBackgroundColor);var Buttons$4=_styled.div.withConfig({displayName:"CommentInput__Buttons",componentId:"sc-777bqz-1"})(templateObject_3$11||(templateObject_3$11=__makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n box-sizing: border-box;\n padding: ","px ","px;\n background-color: ",";\n\n && button {\n background-color: transparent;\n\n i {\n font-size: 22px;\n }\n }\n"],["\n display: flex;\n justify-content: space-between;\n box-sizing: border-box;\n padding: ","px ","px;\n background-color: ",";\n\n && button {\n background-color: transparent;\n\n i {\n font-size: 22px;\n }\n }\n"])),spacingXxs,spacingS+5,function(p){return p.theme.palette.neutralLighter;});var LeftSide=_styled.div.withConfig({displayName:"CommentInput__LeftSide",componentId:"sc-777bqz-2"})(templateObject_4$J||(templateObject_4$J=__makeTemplateObject(["\n display: flex;\n gap: ","px;\n\n @media (min-width: ","px) {\n gap: ","px;\n }\n"],["\n display: flex;\n gap: ","px;\n\n @media (min-width: ","px) {\n gap: ","px;\n }\n"])),spacingM+5,minScreenSize.medium,spacingS+5);var RightSide=_styled.div.withConfig({displayName:"CommentInput__RightSide",componentId:"sc-777bqz-3"})(templateObject_5$C||(templateObject_5$C=__makeTemplateObject(["\n display: flex;\n gap: ","px;\n margin-left: auto;\n"],["\n display: flex;\n gap: ","px;\n margin-left: auto;\n"])),spacingS);var InputContainer=_styled.div.withConfig({displayName:"CommentInput__InputContainer",componentId:"sc-777bqz-4"})(templateObject_6$s||(templateObject_6$s=__makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding: ","px ","px;\n background-color: ",";\n\n .comment-input {\n &__control {\n background-color: transparent;\n font-size: 14px;\n font-weight: normal;\n border: none;\n }\n &__input {\n /*\n * on small screens the MentionsInput renders a margin-left: -3px directly on the element\n * Use !important to remove the minus margin to match our layout.\n */\n margin: 0 !important;\n padding: 0;\n outline: 0;\n border: 0;\n }\n &__highlighter {\n padding: 0;\n border: 0;\n font-family: 'Roboto', sans-serif !important;\n font-size: 14px;\n line-height: ","px;\n\n strong {\n ","\n }\n }\n }\n"],["\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding: ","px ","px;\n background-color: ",";\n\n .comment-input {\n &__control {\n background-color: transparent;\n font-size: 14px;\n font-weight: normal;\n border: none;\n }\n &__input {\n /*\n * on small screens the MentionsInput renders a margin-left: -3px directly on the element\n * Use !important to remove the minus margin to match our layout.\n */\n margin: 0 !important;\n padding: 0;\n outline: 0;\n border: 0;\n }\n &__highlighter {\n padding: 0;\n border: 0;\n font-family: 'Roboto', sans-serif !important;\n font-size: 14px;\n line-height: ","px;\n\n strong {\n ","\n }\n }\n }\n"])),spacingS,spacingS+5,function(p){return p.theme.palette.white;},spacingM,"background-color: "+defaultPageBackgroundColor+";");var templateObject_1$2l,templateObject_2$1y,templateObject_3$11,templateObject_4$J,templateObject_5$C,templateObject_6$s;var DropTarget=_styled.div.withConfig({displayName:"DropInfo__DropTarget",componentId:"sc-1ky6ew9-0"})(templateObject_1$2k||(templateObject_1$2k=__makeTemplateObject(["\n position: ",";\n top: ",";\n left: 0;\n right: 0;\n bottom: 0;\n z-index: ",";\n\n background-color: ",";\n\n display: flex;\n justify-content: center;\n"],["\n position: ",";\n top: ",";\n left: 0;\n right: 0;\n bottom: 0;\n z-index: ",";\n\n background-color: ",";\n\n display: flex;\n justify-content: center;\n"])),function(_a){var isLarge=_a.isLarge,isActive=_a.isActive;return isLarge&&isActive?'fixed':'absolute';},function(_a){var isLarge=_a.isLarge;return isLarge?headerHeight+"px":'0';},function(_a){var isActive=_a.isActive;return isActive?300:0;},function(_a){var isActive=_a.isActive;return isActive?'rgba(253, 253, 253, 0.95)':'transparent';});var DropInfo=function DropInfo(_a){var isLarge=_a.isLarge;return jsx$1(Host$V,__assign({isLarge:isLarge},{children:jsxs(CenteredContainer,__assign({isLarge:isLarge},{children:[jsx$1(StyledIcon$8,{isLarge:isLarge,iconName:"bulkUpload",className:"ms-fontColor-accent"},void 0),jsx$1(FormattedMessage$1,{id:"Generic.dragToUploadTitle",tagName:"h2"},void 0),jsx$1(FormattedMessage$1,{id:"Generic.dragToUploadDescription",tagName:"p"},void 0)]}),void 0)}),void 0);};var Host$V=_styled.div.withConfig({displayName:"DropInfo__Host",componentId:"sc-1ky6ew9-1"})(templateObject_2$1x||(templateObject_2$1x=__makeTemplateObject(["\n ",";\n ",";\n"],["\n ",";\n ",";\n"])),function(_a){var isLarge=_a.isLarge;return !isLarge&&'display: flex';},function(_a){var isLarge=_a.isLarge;return !isLarge&&'align-items: center';});var CenteredContainer=_styled.div.withConfig({displayName:"DropInfo__CenteredContainer",componentId:"sc-1ky6ew9-2"})(templateObject_3$10||(templateObject_3$10=__makeTemplateObject(["\n position: relative;\n top: ",";\n\n display: flex;\n flex-direction: column;\n align-items: center;\n\n h2 {\n margin-bottom: 0;\n }\n p {\n margin-top: 3px;\n }\n"],["\n position: relative;\n top: ",";\n\n display: flex;\n flex-direction: column;\n align-items: center;\n\n h2 {\n margin-bottom: 0;\n }\n p {\n margin-top: 3px;\n }\n"])),function(_a){var isLarge=_a.isLarge;return isLarge?'20%':0;});var StyledIcon$8=_styled(Icon).withConfig({displayName:"DropInfo__StyledIcon",componentId:"sc-1ky6ew9-3"})(templateObject_4$I||(templateObject_4$I=__makeTemplateObject(["\n font-size: ",";\n"],["\n font-size: ",";\n"])),function(p){return p.isLarge?'100px':'50px';});var templateObject_1$2k,templateObject_2$1x,templateObject_3$10,templateObject_4$I;var hasValidGenericUrlVideoSourcePrefix=function hasValidGenericUrlVideoSourcePrefix(url){return url&&getAdditionalVideoSources().filter(function(s){return url.startsWith(s.prefix);}).length>0;};var VideoUrlParser=/** @class */function(){function VideoUrlParser(url){this.url=url;this.source=null;this.id=null;this.isDirectVideoUrl=false;this.videoProperties=null;this.thumbnailUrl=null;if(hasValidGenericUrlVideoSourcePrefix(this.url)){this.source=VideoSource.GenericUrl;this.id=url;}else if(VideoUrlParser.microsoftStreamRegex.test(this.url)){this.source=VideoSource.MicrosoftStream;this.id=VideoUrlParser.microsoftStreamRegex.exec(this.url)[1];}else if(VideoUrlParser.ytRegex.test(this.url)){this.source=VideoSource.YouTube;this.id=VideoUrlParser.ytRegex.exec(this.url)[1];}else if(VideoUrlParser.vimeoRegex.test(this.url)){this.source=VideoSource.Vimeo;this.id=VideoUrlParser.vimeoRegex.exec(this.url)[1];}else if(VideoUrlParser.vimeoDirectLinkRegex.test(this.url)){this.source=VideoSource.Vimeo;this.id=VideoUrlParser.vimeoDirectLinkRegex.exec(this.url)[1];this.isDirectVideoUrl=true;}else if(VideoUrlParser.vimeoRedirectLinkRegex.test(this.url)){this.source=VideoSource.Vimeo;this.id=VideoUrlParser.vimeoRedirectLinkRegex.exec(this.url)[1];}else if(VideoUrlParser.kalturaRegex.test(this.url)){var regexMatches=VideoUrlParser.kalturaRegex.exec(this.url);this.source=VideoSource.Kaltura;this.id=regexMatches[1];this.videoProperties={sp:regexMatches[2],uiconfId:regexMatches[3],partnerId:regexMatches[4],entryId:regexMatches[5]};this.thumbnailUrl="https://cdnsecakmi.kaltura.com/p/"+this.id+"/thumbnail/entry_id/"+this.videoProperties.entryId+"/width/1000";}}//TODO handle the different error messages for cloud and onprem versions, i.e. what sources are permitted (see task 23570)
131963
131963
  VideoUrlParser.prototype.isValid=function(features){var _this=this;if(this.source==null||this.id==null){return false;}if(features){var sources=getVideoSources(features);return sources.findIndex(function(s){return s.type===_this.source;})>=0;}return true;};VideoUrlParser.ytRegex=/^.*(?:(?:youtu.be\/)|(?:v\/)|(?:\/u\/\w\/)|(?:embed\/)|(?:watch\?))\??v?=?([^#&?]*).*$/;VideoUrlParser.vimeoRegex=/.*?(?:vimeo.com\/){1}(?:video\/)?(\d+)/;// match first GUID after domain
131964
131964
  VideoUrlParser.microsoftStreamRegex=/.*web\.microsoftstream\.com.+?([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/i;VideoUrlParser.vimeoDirectLinkRegex=/.*?(?:player\.vimeo\.com\/external\/){1}(\d+)/;VideoUrlParser.vimeoRedirectLinkRegex=/.*?(?:player\.vimeo\.com\/progressive_redirect\/playback\/){1}(\d+)(?:\/.*)/;VideoUrlParser.kalturaRegex=/.+cdnapisec\.kaltura\.com\/p\/([0-9]+)\/sp\/([0-9]+)\/embedIframeJs\/uiconf_id\/([0-9]+)\/partner_id\/([0-9]+)(?:.*entry_id=(.+?(?=&|$)))/;return VideoUrlParser;}();function getVideoSources(features){var sources=[];if(features.editorYouTubeVideos){sources.push({type:VideoSource.YouTube,name:'YouTube'});}if(features.editorVimeoVideos){sources.push({type:VideoSource.Vimeo,name:'Vimeo'});}if(features.editorMicrosoftVideos){sources.push({type:VideoSource.MicrosoftStream,name:'Microsoft Stream'});}if(features.editorKalturaVideos){sources.push({type:VideoSource.Kaltura,name:'Kaltura'});}return sources;}// this is wrapped, because the "appconfig" does not exist in the component library
@@ -132070,7 +132070,7 @@ storage.set(cacheKey,apiPage_1).then(function(){return null;});if(!cachedPage){o
132070
132070
  apiItem.fileAccessToken=cachedItem.fileAccessToken;}});observer.next(apiPage_1);observer.complete();return [3/*break*/,4];case 3:err_1=_a.sent();observer.error(err_1);return [3/*break*/,4];case 4:return [2/*return*/];}});});})();});}function validateFileAccessTokens(page,modifyFunc){if(!page||!page.items){return;}page.items.forEach(function(item){var isTokenValid=isTokenStillValid(item.fileAccessToken);modifyFunc(isTokenValid,item);});}var NewsApiService=/** @class */function(){function NewsApiService(factory,subscriptionId,storage){var _this=this;this.factory=factory;this.storage=storage;this.trackExternalItem=function(itemId,itemType){return _this.api.custom(itemType+"/"+encodeURIComponent(itemId)+"/external_url/track").get().then(function(result){return result.body().data();});};this.getAllNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{includePromoted:true}));};this.getAllUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{unreadOnly:true,pageSize:0}));};this.getMyNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news',NewsApiService.newsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition);};this.getMyUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news/unread',NewsApiService.myUnreadNewsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition,true);};this.getBookmarks=function(filterDefinition){return fetchNewsItems('users/current/bookmarks',NewsApiService.bookmarksCacheKey,_this.api,_this.storage,null,filterDefinition,true);};this.getNewsFromCache=function(){return __awaiter(_this,void 0,void 0,function(){var _a;return __generator(this,function(_b){switch(_b.label){case 0:return [4/*yield*/,this.storage.getObject(NewsApiService.newsItemsCacheKey)];case 1:return [2/*return*/,(_a=_b.sent())!==null&&_a!==void 0?_a:[]];}});});};this.get=function(newsId){var getFromCache=function getFromCache(id){return __awaiter(_this,void 0,void 0,function(){var cache,hits;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:cache=_a.sent();hits=cache.filter(function(i){return i.id===id;});return [2/*return*/,hits.length>0?hits[0]:null];}});});};var getFromApi=function getFromApi(id){return from(_this.api.all('news').get(id)).pipe(mergeMap(function(res){return updateItemCache(res.body().data());}));};var updateItemCache=function updateItemCache(item){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,cacheItem,clonedCachedItem,clonedNewItem;return __generator(this,function(_a){switch(_a.label){case 0:if(item.statistics){itemStatisticsCache[item.id]=Promise.resolve(__assign({},item.statistics));}return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===item.id;});if(index>-1){cacheItem=fromCache[index];if(isTokenStillValid(cacheItem.fileAccessToken)){clonedCachedItem=__assign({},cacheItem);delete clonedCachedItem.fileAccessToken;clonedNewItem=__assign({},item);delete clonedNewItem.fileAccessToken;if(JSON.stringify(clonedCachedItem)===JSON.stringify(clonedNewItem)){return [2/*return*/,null];}}fromCache.splice(index,1,item);}else {fromCache.push(item);}return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/,item];}});});};return concat(getFromCache(newsId),getFromApi(newsId)).pipe(filter(function(i){return i!=null;}),catchError(function(err){if(err.response&&err.response.statusCode===404){return of(null);}else {return throwError(err);}}));};this.getImageUrlWithToken=function(token,itemId,subscriptionId,resourceType,imageIdentifier,width,height){if(imageIdentifier===void 0){imageIdentifier='banner';}return _this.factory.createApiUrl("/"+resourceType+"/"+itemId+"/images/"+imageIdentifier+"/"+width+"/"+(height||''),{access_token:token,subscriptionId:subscriptionId});};this.getStatistics=function(newsId){if(!itemStatisticsCache[newsId]){itemStatisticsCache[newsId]=_this.api.custom("news/"+newsId+"/statistics").get().then(function(result){return result.body().data();}).then(function(result){var feedbackCountsKeys=Object.keys(result.feedbackCounts);return {bookmarkCount:result.bookmarkCount,likeCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='like';})],commentCount:result.commentCount,confirmationCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='confirm';})],readCount:result.readCount};});}return itemStatisticsCache[newsId];};this.refreshStatistics=function(itemId,delta){return __awaiter(_this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:// update statistics cache with new delta
132071
132071
  if(!itemStatisticsCache[itemId]){return [2/*return*/];}return [4/*yield*/,itemStatisticsCache[itemId].then(function(statistics){var updatedStatistics=NewsApiService.getUpdatedStatistics(statistics,delta);_this.tryUpdateStatisticsInCache(itemId,updatedStatistics).then(null,null);itemStatisticsCache[itemId]=Promise.resolve(updatedStatistics);onStatisticsUpdated.next(updatedStatistics);})];case 1:_a.sent();return [2/*return*/];}});});};this.tryUpdateStatisticsInCache=function(newsId,statistics){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,item;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===newsId;});item=fromCache[index];if(!item||!item.statistics){return [2/*return*/];}item.statistics=statistics;fromCache.splice(index,1,item);return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/];}});});};this.getExternalItemRoute=function(resourceType,itemId,accessToken){return _this.factory.createApiUrl("/"+resourceType+"/"+encodeURIComponent(itemId)+"/external_url",{access_token:accessToken});};this.api=factory.createApi(false,subscriptionId);}NewsApiService.getUpdatedStatistics=function(curr,delta){var _a,_b,_c,_d,_e,_f;return {bookmarkCount:curr.bookmarkCount+((_a=delta.bookmarkCount)!==null&&_a!==void 0?_a:0),commentCount:curr.commentCount+((_b=delta.commentCount)!==null&&_b!==void 0?_b:0),likeCount:curr.likeCount+((_c=delta.likeCount)!==null&&_c!==void 0?_c:0),confirmationCount:curr.confirmationCount+((_d=delta.confirmationCount)!==null&&_d!==void 0?_d:0),readCount:curr.readCount+((_e=delta.readCount)!==null&&_e!==void 0?_e:0),participantsCount:curr.participantsCount+((_f=delta.participantsCount)!==null&&_f!==void 0?_f:0)};};NewsApiService.bookmarksCacheKey='NewsService::BookmarksV2';NewsApiService.newsItemsCacheKey='NewsService::NewsItems';NewsApiService.newsCacheKey='NewsService::News';NewsApiService.allNewsCacheKey='NewsService::AllNews';NewsApiService.myUnreadNewsCacheKey='NewsService::MyUnreadNews';return NewsApiService;}();function useNewsApi(){var storage=useStorage();var factory=useApiFactory();var identifier=useContext(SubscriptionIdContext).identifier;return useMemo(function(){return new NewsApiService(factory,identifier===null||identifier===void 0?void 0:identifier.id,storage);},[factory,identifier,storage]);}function usePagesApi(){var api=useApi();var createApiUrl=useApiFactory().createApiUrl;return useMemo(function(){return {loadPage:loadPage,loadPageChildren:loadPageChildren,getRootPagesNavigation:getRootPagesNavigation,getPublishedRootPages:getPublishedRootPages,searchPublishedPages:searchPublishedPages,getSubpages:getSubpages,searchPages:searchPages,getDocumentFileUrl:getDocumentFileUrl,searchToc:searchToc};function loadPage(id){return api.all('pages').get(id,{includeNavigationContext:true}).then(function(response){var page=response.body().data();itemStatisticsCache[page.id]=Promise.resolve(__assign({},page.statistics));return page;});}function loadPageChildren(id){return api.all("pages/"+id+"/navigation/children").getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getRootPagesNavigation(){return api.all('pages').getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getPublishedRootPages(filter){var rootPagesFilter=__assign(__assign({},filter),{rootPagesOnly:true});return searchPages('pages',rootPagesFilter);}function searchPublishedPages(filter){return searchPages('pages',filter);}function getSubpages(parentId,filter){var subPagesFilter=__assign(__assign({},filter),{parentId:parentId});if(!subPagesFilter.pageSize){// return all subpages & documents
132072
132072
  subPagesFilter.pageSize=0;}return searchPages('pages',subPagesFilter);}function searchToc(basePath,searchValue){return searchPages(basePath,{pageSize:100,search:searchValue,searchInTitlesOnly:true});}function searchPages(basePath,filter){if(filter){filter=__assign({},filter);if(!filter.restrictToPageContext){delete filter.pageContextId;}// we never need / want to send this param to the API, only used for the UI
132073
- delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}var params=__assign(__assign(__assign({},filter),{groupId:groupIds}),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.custom("posts?"+queryString.stringify(params)).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","disableAddGif","disableAddFiles"]);var onDrop=useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=useRef$1(null);var formatMessage=useIntl().formatMessage;useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsx$1(CommentInput,__assign({ref:inputRef,className:className,buttons:buttons},props),void 0);}return jsxs("div",__assign({className:className},{children:[jsx$1("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsx$1(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsx$1(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsx$1(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:{leftSide:jsxs(Fragment,{children:[jsx$1(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsx$1(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons.leftSide]},void 0),rightSide:buttons.rightSide}}),void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
132073
+ delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}var params=__assign(__assign(__assign({},filter),{groupId:groupIds}),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.custom("posts?"+queryString.stringify(params)).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","disableAddGif","disableAddFiles"]);var onDrop=useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=useRef$1(null);var formatMessage=useIntl().formatMessage;useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsx$1(CommentInput,__assign({ref:inputRef,className:className,buttons:{leftSide:jsxs(Fragment,{children:[jsx$1(GifButton,{disabled:props.disabled,onGifClick:handleGifClick},'gifButton'),allowAttachments&&jsx$1(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:props.disabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'),buttons.leftSide]},void 0),rightSide:buttons.rightSide}},props),void 0);}return jsxs("div",__assign({className:className},{children:[jsx$1("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsx$1(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsx$1(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsx$1(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:{leftSide:jsxs(Fragment,{children:[jsx$1(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsx$1(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons.leftSide]},void 0),rightSide:buttons.rightSide}}),void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
132074
132074
  // src="https://www.youtube.com/embed/{videoId}?ecver=1" frameborder="0" allowfullscreen>
132075
132075
  // </iframe>
132076
132076
  var iframe=document.createElement('iframe');iframe.setAttribute('aria-label',this.iframeAreaLabel);iframe.setAttribute('src',"https://www.youtube.com/embed/"+this.videoInfo.id+"?rel=0&autoplay="+(this.autoplay?'1':'0'));iframe.setAttribute('frameborder','0');iframe.setAttribute('allowfullscreen','');return iframe;};VideoElementGenerator.prototype.getVimeoVideoElement=function(){// <iframe src="https://player.vimeo.com/video/{videoId}"