Comparing version 0.4.1 to 0.4.2
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=e(require("@rgrove/parse-xml")),a=e(require("dayjs")),i=require("@braintree/sanitize-url"),o=e(require("react-markdown")),l=require("linkifyjs"),c=e(require("ical-expander")),s=require("react-virtuoso"),u=e(require("dayjs/plugin/isBetween"));function m(e,t,r,n,a,i,o){try{var l=e[i](o),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}function d(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){m(i,n,a,o,l,"next",e)}function l(e){m(i,n,a,o,l,"throw",e)}o(void 0)}))}}function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var v,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof m?t:m).prototype),i=new k(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var l=E(o,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function m(){}function d(){}function f(){}var v={};v[a]=function(){return this};var h=Object.getPrototypeOf,p=h&&h(h(N([])));p&&p!==t&&r.call(p,a)&&(v=p);var g=f.prototype=m.prototype=Object.create(v);function y(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,l){var c=s(e[a],e,i);if("throw"!==c.type){var u=c.arg,m=u.value;return m&&"object"==typeof m&&r.call(m,"__await")?t.resolve(m.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(m).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,l)}))}l(c.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function E(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return d.prototype=g.constructor=f,f.constructor=d,d.displayName=l(f,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(b.prototype),b.prototype[i]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new b(c(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},y(g),l(g,o,"Generator"),g[a]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;w(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(v={exports:{}}),v.exports),p=function(){function e(e,t,r){this.name=e,this.node=t,this.attributes=this.node.attributes||{},this.children=r}var t=e.prototype;return t.getText=function(){return"text"===this.node.type?this.node.text:this.node.children&&this.node.children.length?this.node.children[0].text:""},t.initialState=function(){var e,t=this.attributes,r=t.name;return r?((e={})[r]=t.value,e):{}},e}(),g=function(e){var t=e.className;return r.createElement("div",{className:"mml-card "+(void 0===t?"":t)},e.children)},y=function(e){return r.createElement("i",{className:"mml-icon material-icons"},e.name)},b=function(e){var t=e.text,n=e.icon,a=void 0===n?"":n,i=e.className;return r.createElement("div",{className:"mml-card-header "+(void 0===i?"":i)},a&&r.createElement(y,{name:a}),r.createElement("span",{className:"mml-card-header__text"},t))},E=function(e){var t=e.className;return r.createElement("div",{className:"mml-card-body "+(void 0===t?"":t)},e.children)},x=function(e){var t=e.variant;return r.createElement("div",{className:"mml-btnlist "+("floating"===(void 0===t?"":t)?" mml-btnlist--floating":"mml-btnlist--grounded")},e.children)},w=function(e){return r.createElement("i",{className:"mml-icon"},r.createElement("svg",{className:"mml-icon__svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},r.createElement("path",{d:e.path})))},k=r.createElement(w,{path:"M21.35 11.1h-9.17v2.73h6.5c-.33 3.8-3.5 5.44-6.5 5.44C8.36 19.27 5 16.25 5 12c0-4.1 3.2-7.27 7.2-7.27 3.1 0 4.9 1.97 4.9 1.97L19 4.72S16.56 2 12.1 2C6.42 2 2.03 6.8 2.03 12c0 5.05 4.13 10 10.22 10 5.35 0 9.25-3.67 9.25-9.1 0-1.15-.15-1.8-.15-1.8h0z"}),N=r.createElement(w,{path:"M3 12V6.75l6-1.32v6.48L3 12m17-9v8.75l-10 .15V5.2L20 3M3 13l6 .1v6.8l-6-1.15V13m17 .25V22l-10-1.9v-7l10 .15z"});function _(){var e="undefined"!=typeof navigator?navigator.userAgent:"";return!!e&&(!!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(e)||"undefined"!=typeof navigator&&navigator.maxTouchPoints>1&&-1!==e.indexOf("Macintosh")&&-1!==e.indexOf("Safari"))}var O="undefined"!=typeof window&&window.navigator.msSaveOrOpenBlob&&window.Blob,L=[{id:"google",label:"Google",Icon:k},{id:"apple",label:"Apple Calendar",Icon:r.createElement(w,{path:"M18.7 19.5c-.83 1.24-1.7 2.45-3.05 2.47-1.34.03-1.77-.8-3.3-.8-1.53 0-2 .77-3.27.82-1.3.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.4c.87-1.52 2.43-2.48 4.12-2.5 1.28-.02 2.5.87 3.3.87.78 0 2.26-1.07 3.8-.9.65.03 2.47.26 3.64 1.98-.1.06-2.17 1.28-2.15 3.8.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.2-.7.85-1.83 1.5-2.95 1.42-.15-1.15.4-2.35 1.05-3.1z"})},{id:"outlook",label:"Outlook",Icon:N},{id:"outlookcom",label:"Outlook.com",Icon:N}];function I(e,t){return a(e).format("outlookcom"===t?"YYYY-MM-DDTHH:mm:ss":"YYYYMMDDTHHmmss")+"Z"}function C(e){return void 0===e&&(e={}),Object.keys(e).reduce((function(t,r){var n=e[r];return n&&(t+="&"+r+"="+encodeURIComponent(n)),t}),"")}function S(e,t){var r=e.end,n=e.title,a=e.location,i=e.description,o=I(e.start,t),l=I(r,t);if("google"===t)return"https://calendar.google.com/calendar/render?action=TEMPLATE&dates="+o+"/"+l+C({location:a,text:n,details:i});if("outlookcom"===t)return"https://outlook.live.com/owa/?rru=addevent"+C({startdt:o,enddt:l,subject:n,location:a,body:i,allday:"false"})+"&path=/calendar/view/Month";var c=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT","URL:"+("undefined"!=typeof window?window.location.href:""),"DTSTART:"+o,"DTEND:"+l,"SUMMARY:"+n,"DESCRIPTION:"+i,"LOCATION:"+a,"END:VEVENT","END:VCALENDAR"].join("\n");return!O&&_()&&(c=encodeURI("data:text/calendar;charset=utf8,"+c)),c}var j=function(e){var t=e.className,n=e.location,a=e.description,i={start:e.start,end:e.end,title:e.title,location:void 0===n?"":n,description:void 0===a?"":a};function o(e){e.preventDefault();var t=e.currentTarget.getAttribute("href");if(_()||!t.startsWith("data")&&!t.startsWith("BEGIN"))window.open(t,"_blank");else{var r=new Blob([t],{type:"text/calendar;charset=utf-8"});if(O)window.navigator.msSaveOrOpenBlob(r,"download.ics");else{var n=document.createElement("a");n.href=window.URL.createObjectURL(r),n.setAttribute("download","download.ics"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}}}return r.createElement(g,{className:"mml-add-to-calendar "+(void 0===t?"":t)},r.createElement(b,{icon:"date_range",text:"Add to My Calendar"}),r.createElement(E,null,r.createElement(x,null,L.map((function(e){var t=e.id,n=e.label,a=e.Icon;return r.createElement("a",{key:t,className:"mml-btn "+(a?"mml-btn--with-icon":""),onClick:o,href:S(i,t),target:"_blank",rel:"nofollow noreferrer noopener"},a," ",n)})))))},T=function(e){var t=e.className,n=void 0===t?"":t,a=e.text,o=e.name,l=e.value,c=e.url,s=void 0===c?"":c,u=e.icon;return n+=u?a?" mml-btn--with-icon":" mml-btn--icon":" mml-btn--text",n+="floating"===e.variant?" mml-btn--floating":" mml-btn--grounded",s?r.createElement("a",{className:"mml-btn "+n,href:i.sanitizeUrl(s),target:"_blank",rel:"nofollow noreferrer noopener"},u&&r.createElement(y,{name:u}),a):r.createElement("button",{className:"mml-btn "+n,type:"submit",name:o,value:l,onClick:function(e){var t,r,n=document.createElement("input");n.type="hidden",n.name=o||"",n.value=l||"",null==(t=e.currentTarget)||null==(r=t.closest("form"))||r.appendChild(n)}},u&&r.createElement(y,{name:u}),a)},M=function(e){var n=e.slideWidth,a=void 0===n?"120px":n,i=e.className;return r.createElement("div",{className:"mml-carousel "+(void 0===i?"":i)},r.createElement("div",{className:"mml-carousel__track"},r.createElement("div",{className:"mml-carousel__slides"},t.Children.map(e.children,(function(e){return t.cloneElement(e,{className:"mml-carousel__slide",slideWidth:a})})))))},D=function(e){var t=e.width,n=e.className,a=(void 0===t?"":t)||e.slideWidth;return r.createElement("div",{className:"mml-carousel-item "+(void 0===n?"":n),style:{flex:"0 0 "+a,minWidth:a}},e.children)},F=function(e){var t=e.width,n=e.offset,a=void 0===n?0:n,i=e.align,o="mml-col-"+(void 0===t?12:t);return a&&(o=o+" mml-offset-"+a),r.createElement("div",{className:o=o+" mml-align-"+(void 0===i?"left":i)},e.children)},A=function(e){var t=e.error,n=void 0===t?"":t;return n?r.createElement("span",{className:"mml-error"},n):null},R=function(e){var t=e.src,n=e.alt,a=void 0===n?"":n,i=e.title,o=void 0===i?"":i,l=e.className;return r.createElement("img",{className:("mml-image "+(void 0===l?"":l)).trim(),src:t,alt:a,title:o})},P=function(e){var n=e.name,a=e.label,i=e.value,o=e.type,l=void 0===o?"text":o,c=e.placeholder,s=void 0===c?"":c,u=t.useState(void 0===i?"":i),m=u[0],d=u[1],f="mml-"+n;return r.createElement(r.Fragment,null,a&&r.createElement("label",{className:"mml-card-header",htmlFor:f},r.createElement("span",{className:"mml-card-header__text"},a)),r.createElement("input",{id:f,className:"mml-input",name:n,value:m,type:l,placeholder:s,onChange:function(e){return d(e.target.value)}}))},V=function(e){var t=e.size,n=e.thickness,a=void 0===n?3.6:n,i=e.color;return a="string"==typeof a?parseFloat(a):a,t="string"==typeof t&&/^\d+$/.test(t)||"number"==typeof t?t+"px":t,r.createElement("span",{className:"mml-progress",role:"progressbar",style:{width:t,height:t,color:i}},r.createElement("svg",{className:"mml-progress__svg",viewBox:"22 22 44 44"},r.createElement("circle",{className:"mml-progress__circle",cx:44,cy:44,r:(44-a)/2,fill:"none",strokeWidth:a})))},B=function(e){var t=e.className,n=e.loading,a=e.text;return void 0!==n&&n?r.createElement("div",{className:"mml-loading "+(void 0===t?"":t)},r.createElement(V,Object.assign({},{size:e.size,thickness:e.thickness,color:e.color})),a&&r.createElement("div",{className:"mml-loading__text"},a)):null},G=function(e,t,r){return void 0===r&&(r="..."),e.length>t?""+e.substring(0,t-r.length)+r:e},W={link:function(e){return e.href&&(e.href.startsWith("http")||e.href.startsWith("mailto:"))?r.createElement("a",{href:e.href,target:"_blank",rel:"nofollow noreferrer noopener"},e.children):e.children}},q=["html","root","text","break","paragraph","emphasis","strong","link","list","listItem","code","inlineCode","blockquote"],Y=function(e){var t=e.text;if(!t)return null;var n,a,i=t,c=(n=i.match(/\[([^[]+)\](\(.*\))/gm),a=/\[([^[]+)\]\((.*)\)/,n?n.map((function(e){var t=a.exec(e);return t&&t[2]})):[]);return l.find(i).forEach((function(e){var t=e.type,r=e.href,n=e.value;if(!((c&&c.filter((function(e){return-1!==(null==e?void 0:e.indexOf(r))}))).length>0)){var a="email"===t?n:G(n.replace(/(http(s?):\/\/)?(www\.)?/,""),20);i=i.replace(n,"["+a+"]("+encodeURI(r)+")")}})),r.createElement("div",{className:"mml-md"},r.createElement(o,{allowedTypes:q,renderers:W,source:i,escapeHtml:!0,unwrapDisallowed:!0,transformLinkUri:function(e){return e.startsWith("app://")?e:o.uriTransformer(e)}}))},z=function(e){var n=e.name,a=t.useState(parseInt(""+e.value,10)||0),i=a[0],o=a[1];return r.createElement("div",{className:"mml-number"},r.createElement("input",{name:n,value:i,type:"hidden"}),r.createElement("span",{className:"mml-btn mml-btn--floating mml-btn--icon mml-number__dec",onClick:function(){return o(i-1)}},r.createElement(y,{name:"remove"})),r.createElement("span",{className:"mml-number__count"},i),r.createElement("span",{className:"mml-btn mml-btn--floating mml-btn--icon mml-number__inc",onClick:function(){return o(i+1)}},r.createElement(y,{name:"add"})))},U=function(e){return r.createElement("div",{className:"mml-row"},e.children)},H=function(e){var n=e.onChange,a=e.icalFilter,i=e.getItemData,o=e.itemClassName,l=e.interval,c=e.format,u=e.value,m=t.useCallback((function(e,t){return Array(e).fill(!0).map((function(e,r){return i({interval:l,format:c,value:u,idx:t+r})})).filter((function(e){return!a||a&&a(e.value)}))}),[l,c,u,a,i]),d=t.useState(m(80,-40)),f=d[0],v=d[1],h=t.useState(1e4),p=h[0],g=h[1],y=t.useRef(40),b=t.useState(null),E=b[0],x=b[1],w=t.useCallback((function(e){n(e.value);var t=y.current||0,r=t-40-40,a=r-e.idx+3;a>=0&&(r-=a,y.current-=t-a,v((function(e){return[].concat(m(a,r),e)}))),x(e.idx)}),[v,m,y,n]),k=t.useCallback((function(e){v((function(t){return[].concat(t,m(40,e))}))}),[v,m]),N=t.useCallback((function(){var e=y.current||0,t=e-40-40;return y&&(y.current-=40),v((function(e){return[].concat(m(40,t),e)})),g(e-40),!1}),[v,m,y]);return t.useEffect((function(){if(u){for(var e=null,t=0;t<f.length;t++)if(f[t].isSelected(u)){e=f[t].idx;break}x(e)}}),[]),r.createElement(s.Virtuoso,{data:f,firstItemIndex:p,itemContent:function(e,t){return r.createElement("div",{className:o+" mml-datepicker__item "+(t.idx===E?"mml-datepicker__item--selected":""),onClick:function(){return w(t)}},t.displayValue)},endReached:k,startReached:N})},X=function(e){var t=e.idx,r=e.interval,n=e.value,i=e.format,o=t>=0?a(n).add(t*(24*r),"hour"):a(n).subtract(t*(24*r)*-1,"hour");return{idx:t,value:o,displayValue:a(o).format(i),isSelected:function(e){return a(o).isSame(1===r?a(e):a(e).add(r,"day"),"date")}}},Z=function(e){return r.createElement("div",{className:"mml-datepicker__select mml-datepicker__date"},r.createElement(H,Object.assign({},e,{itemClassName:"mml-datepicker__item--day",getItemData:X})))};a.extend(u);var $=function(e){var t=e.idx,r=e.interval,n=e.value,i=e.format,o=t>=0?a(n).add(t*r,"minute"):a(n).subtract(-1*t*r,"minute");return{idx:t,value:o,displayValue:a(o).format(i),isSelected:function(e){return a(o).isBetween(e,a(e).add(r-1,"minute"),"minute","[]")}}},J=function(e){return r.createElement("div",{className:"mml-datepicker__select mml-datepicker__time"},r.createElement(H,Object.assign({},e,{itemClassName:"mml-datepicker__item--time",getItemData:$})))},K=function(e){var n=e.name,a=e.dateInterval,i=e.timeInterval,o=e.dateFormat,l=e.timeFormat,c=e.fullDay,s=e.icalFilter,u=t.useState(e.selected),m=u[0],d=u[1];return r.createElement("div",{className:"mml-datepicker mml-datepicker--"+(c?"single":"double")},r.createElement("input",{name:n,value:m.toISOString(),type:"hidden"}),r.createElement(Z,{icalFilter:s,format:o,value:m,onChange:function(e){d((function(t){return t.set("date",e.get("date")).set("month",e.get("month")).set("year",e.get("year"))}))},interval:a}),!c&&r.createElement(J,{icalFilter:s,format:l,value:m,onChange:function(e){d((function(t){return t.set("minute",e.get("minute")).set("hour",e.get("hour"))}))},interval:i}))},Q=function(){var e=d(h.mark((function e(t,r){var n,a,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"GET",redirect:"follow",credentials:"same-origin"});case 2:return n=e.sent,e.next=5,n.text();case 5:if(a=e.sent,n.ok){e.next=8;break}throw new Error(a);case 8:return i=new c({ics:a,maxIterations:10}),e.abrupt("return",(function(){return function(e){return!e||!i.between(e.toDate(),e.add(r,"minute").toDate()).events.length}}));case 10:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),ee=function(e){var n=e.name,i=e.selected,o=e.icalAvailability,l=e.duration,c=void 0===l?30:l,s=e.dateInterval,u=void 0===s?1:s,m=e.timeInterval,d=void 0===m?30:m,f=e.dateFormat,v=void 0===f?"ddd MMM DD":f,h=e.timeFormat,p=void 0===h?"hh:mm A":h,y=e.fullDay,x=void 0!==y&&y,w=t.useState(!1),k=w[0],N=w[1],_=t.useState(""),O=_[0],L=_[1],I=t.useState((function(){return function(){return!0}})),C=I[0],S=I[1];return t.useEffect((function(){o&&(N(!0),Q(o,c).then(S).catch((function(e){console.warn("loading ical failed",{icalAvailability:o,err:e}),L("iCal availability could not be loaded")})).finally((function(){return N(!1)})))}),[o,c]),r.createElement(g,{className:"mml-scheduler"},r.createElement(b,{icon:"date_range",text:"Scheduler"}),r.createElement(E,null,O&&!k&&r.createElement(A,{error:"Failed, error: "+O}),!O&&k&&r.createElement(B,{loading:!0,text:"Loading availability"}),!O&&!k&&r.createElement(K,{name:n,selected:i?a(i):a().startOf("hour"),dateInterval:u,timeInterval:d,dateFormat:v,timeFormat:p,fullDay:x,icalFilter:C})))},te=function(e){var t=e.success;return t?r.createElement("div",{className:"mml-success"},t):null},re=function(e){var t=e.text,n=e.className;return r.createElement("div",{className:("mml-text "+(void 0===n?"":n)).trim()},t)},ne={button:function(e){return r.createElement(T,Object.assign({},e.attributes,{key:e.key,text:e.getText(),name:e.attributes.name,value:e.attributes.value}))},button_list:function(e,t){return r.createElement(x,Object.assign({},e.attributes,{key:e.key}),t)},input:function(e){return r.createElement(P,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,value:e.attributes.value}))},add_to_calendar:function(e){return r.createElement(j,Object.assign({},e.attributes,{key:e.key,title:e.attributes.title,start:e.attributes.start,end:e.attributes.end}))},col:function(e,t){return r.createElement(F,Object.assign({},e.attributes,{key:e.key}),t)},row:function(e,t){return r.createElement(U,Object.assign({},e.attributes,{key:e.key}),t)},icon:function(e){return r.createElement(y,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name}))},image:function(e){return r.createElement(R,Object.assign({},e.attributes,{key:e.key,src:e.attributes.src}))},md:function(e){return r.createElement(Y,Object.assign({},e.attributes,{key:e.key,text:e.getText()}))},text:function(e){return r.createElement(re,Object.assign({},e.attributes,{key:e.key,text:e.getText()}))},scheduler:function(e){return r.createElement(ee,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,dateInterval:parseInt(e.attributes.dateInterval,10)||1,timeInterval:parseInt(e.attributes.timeInterval,10)||30,duration:parseInt(e.attributes.duration,10)||30,selected:e.attributes.selected,fullDay:"true"===e.attributes.fullDay,icalAvailability:e.attributes.icalAvailability}))},carousel:function(e,t){return r.createElement(M,Object.assign({slideWidth:e.attributes.slideWidth},e.attributes,{key:e.key}),t)},item:function(e,t){return r.createElement(D,Object.assign({},e.attributes,{key:e.key}),t)},number:function(e){return r.createElement(z,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,value:e.attributes.value}))}},ae=function(){function e(e,t,r){this.converters=f({},ne,r),this.node=e,this.children=t,this.reactElements=this.toReact(),this.name=e.attributes.name,this.type=e.attributes.type}return e.prototype.toReact=function(e){var t=this;void 0===e&&(e=this);var r=[];return(e.children||[]).forEach((function(e,n){var a=t.converters[e.name];if(!a)throw Error("Converter not found for tag "+e.name+", Available converters are "+Object.keys(t.converters));var i=t.toReact(e);e.key="tag-"+e.name+"-position-"+n,r.push(a(e,i))})),r},e}();function ie(e){var t=e.trim();return t.startsWith("<mml")||(t="<mml>"+e+"</mml>"),t=t.replace(/&(?!amp;|lt;|gt;)/g,"&"),n(t)}function oe(e,t){if(!e||!e.children||!e.children.length)throw new Error("bad input");var r=e.children[0];if("mml"!==r.name)throw new Error("missing mml tag");return new ae(r,function e(t){return t.reduce((function(t,r){var n,a=r;a.children&&(n=e(a.children));var i=a.name;if("text"===r.type){if(!r.text.trim().length)return t;i="text"}return t.push(new p(i,r,n)),t}),[])}(r.children),t)}function le(e,t){return oe(ie(e),t)}exports.AddToCalendar=j,exports.Button=T,exports.ButtonList=x,exports.Card=g,exports.CardBody=E,exports.CardHeader=b,exports.Carousel=M,exports.CarouselItem=D,exports.Col=F,exports.Error=A,exports.Icon=y,exports.Image=R,exports.Input=P,exports.Loading=B,exports.MD=Y,exports.MML=function(e){var n=e.source,a=e.onSubmit,i=e.converters,o=e.theme,l=void 0===o?"":o,c=e.className,s=void 0===c?"":c,u=e.Loading,m=void 0===u?B:u,f=e.Error,v=void 0===f?A:f,p=e.Success,g=void 0===p?te:p,y=t.useState(""),b=y[0],E=y[1],x=t.useState({loading:!1,error:"",success:""}),w=x[0],k=x[1],N=t.useMemo((function(){try{return le(n,i)}catch(e){return console.warn("mml parsing error: ",n,e),E("This chat message has invalid formatting and can't be shown"),null}}),[n,i]),_=t.useCallback(function(){var e=d(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),r={},null!=N&&N.name&&(r.mml_name=N.name),new FormData(t.currentTarget).forEach((function(e,t){r[t]=e})),a){e.next=6;break}return e.abrupt("return",console.warn("Forgot to pass onSubmit prop to <MML/>? payload:",r));case 6:return e.prev=6,k({loading:!0,error:"",success:""}),e.next=10,a(r);case 10:k({loading:!1,error:"",success:"submitted"}),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(6),k({loading:!1,error:"Failed to send the request. Please try again.",success:""});case 16:case"end":return e.stop()}}),e,null,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),[a,N]);return r.createElement("div",{className:"mml-container "+l+" "+s,"data-testid":"mml-container"},b?r.createElement("div",{className:"mml-wrap"},v&&r.createElement(v,{error:b})):r.createElement("form",{onSubmit:_,className:"mml-wrap","data-testid":"mml-form"},null!=N&&N.type?r.createElement("div",{className:"mml-card"},null==N?void 0:N.reactElements):null==N?void 0:N.reactElements,w.loading&&m&&r.createElement(m,{loading:w.loading}),w.success&&g&&r.createElement(g,{success:w.success}),w.error&&v&&r.createElement(v,{error:w.error})))},exports.MMLTag=p,exports.Number=z,exports.Parse=le,exports.Row=U,exports.Scheduler=ee,exports.SourceToXML=ie,exports.Success=te,exports.Text=re,exports.Tree=ae,exports.XMLtoMMLTree=oe,exports.converters=ne,exports.truncate=G; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=e(require("@rgrove/parse-xml")),a=e(require("dayjs")),i=require("@braintree/sanitize-url"),o=e(require("react-markdown")),l=require("linkifyjs"),c=e(require("ical-expander")),s=require("react-virtuoso"),u=e(require("dayjs/plugin/isBetween"));function m(e,t,r,n,a,i,o){try{var l=e[i](o),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}function d(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){m(i,n,a,o,l,"next",e)}function l(e){m(i,n,a,o,l,"throw",e)}o(void 0)}))}}function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var v,h=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof m?t:m).prototype),i=new k(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var l=E(o,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function m(){}function d(){}function f(){}var v={};v[a]=function(){return this};var h=Object.getPrototypeOf,p=h&&h(h(N([])));p&&p!==t&&r.call(p,a)&&(v=p);var g=f.prototype=m.prototype=Object.create(v);function y(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,l){var c=s(e[a],e,i);if("throw"!==c.type){var u=c.arg,m=u.value;return m&&"object"==typeof m&&r.call(m,"__await")?t.resolve(m.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(m).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,l)}))}l(c.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function E(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return d.prototype=g.constructor=f,f.constructor=d,d.displayName=l(f,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(b.prototype),b.prototype[i]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new b(c(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},y(g),l(g,o,"Generator"),g[a]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=N,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;w(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:N(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(v={exports:{}}),v.exports),p=function(){function e(e,t,r){this.name=e,this.node=t,this.attributes=this.node.attributes||{},this.children=r}var t=e.prototype;return t.getText=function(){return"text"===this.node.type?this.node.text:this.node.children&&this.node.children.length?this.node.children[0].text:""},t.initialState=function(){var e,t=this.attributes,r=t.name;return r?((e={})[r]=t.value,e):{}},e}(),g=function(e){var t=e.className;return r.createElement("div",{className:"mml-card "+(void 0===t?"":t)},e.children)},y=function(e){return r.createElement("i",{className:"mml-icon material-icons"},e.name)},b=function(e){var t=e.text,n=e.icon,a=void 0===n?"":n,i=e.className;return r.createElement("div",{className:"mml-card-header "+(void 0===i?"":i)},a&&r.createElement(y,{name:a}),r.createElement("span",{className:"mml-card-header__text"},t))},E=function(e){var t=e.className;return r.createElement("div",{className:"mml-card-body "+(void 0===t?"":t)},e.children)},x=function(e){var t=e.variant;return r.createElement("div",{className:"mml-btnlist "+("floating"===(void 0===t?"":t)?" mml-btnlist--floating":"mml-btnlist--grounded")},e.children)},w=function(e){return r.createElement("i",{className:"mml-icon"},r.createElement("svg",{className:"mml-icon__svg",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},r.createElement("path",{d:e.path})))},k=r.createElement(w,{path:"M21.35 11.1h-9.17v2.73h6.5c-.33 3.8-3.5 5.44-6.5 5.44C8.36 19.27 5 16.25 5 12c0-4.1 3.2-7.27 7.2-7.27 3.1 0 4.9 1.97 4.9 1.97L19 4.72S16.56 2 12.1 2C6.42 2 2.03 6.8 2.03 12c0 5.05 4.13 10 10.22 10 5.35 0 9.25-3.67 9.25-9.1 0-1.15-.15-1.8-.15-1.8h0z"}),N=r.createElement(w,{path:"M3 12V6.75l6-1.32v6.48L3 12m17-9v8.75l-10 .15V5.2L20 3M3 13l6 .1v6.8l-6-1.15V13m17 .25V22l-10-1.9v-7l10 .15z"});function _(){var e="undefined"!=typeof navigator?navigator.userAgent:"";return!!e&&(!!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(e)||"undefined"!=typeof navigator&&navigator.maxTouchPoints>1&&-1!==e.indexOf("Macintosh")&&-1!==e.indexOf("Safari"))}var O="undefined"!=typeof window&&window.navigator.msSaveOrOpenBlob&&window.Blob,L=[{id:"google",label:"Google",Icon:k},{id:"apple",label:"Apple Calendar",Icon:r.createElement(w,{path:"M18.7 19.5c-.83 1.24-1.7 2.45-3.05 2.47-1.34.03-1.77-.8-3.3-.8-1.53 0-2 .77-3.27.82-1.3.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.4c.87-1.52 2.43-2.48 4.12-2.5 1.28-.02 2.5.87 3.3.87.78 0 2.26-1.07 3.8-.9.65.03 2.47.26 3.64 1.98-.1.06-2.17 1.28-2.15 3.8.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.2-.7.85-1.83 1.5-2.95 1.42-.15-1.15.4-2.35 1.05-3.1z"})},{id:"outlook",label:"Outlook",Icon:N},{id:"outlookcom",label:"Outlook.com",Icon:N}];function I(e,t){return a(e).format("outlookcom"===t?"YYYY-MM-DDTHH:mm:ss":"YYYYMMDDTHHmmss")+"Z"}function C(e){return void 0===e&&(e={}),Object.keys(e).reduce((function(t,r){var n=e[r];return n&&(t+="&"+r+"="+encodeURIComponent(n)),t}),"")}function j(e,t){var r=e.end,n=e.title,a=e.location,i=e.description,o=I(e.start,t),l=I(r,t);if("google"===t)return"https://calendar.google.com/calendar/render?action=TEMPLATE&dates="+o+"/"+l+C({location:a,text:n,details:i});if("outlookcom"===t)return"https://outlook.live.com/owa/?rru=addevent"+C({startdt:o,enddt:l,subject:n,location:a,body:i,allday:"false"})+"&path=/calendar/view/Month";var c=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT","URL:"+("undefined"!=typeof window?window.location.href:""),"DTSTART:"+o,"DTEND:"+l,"SUMMARY:"+n,"DESCRIPTION:"+i,"LOCATION:"+a,"END:VEVENT","END:VCALENDAR"].join("\n");return!O&&_()&&(c=encodeURI("data:text/calendar;charset=utf8,"+c)),c}var S=function(e){var t=e.className,n=e.location,a=e.description,i={start:e.start,end:e.end,title:e.title,location:void 0===n?"":n,description:void 0===a?"":a};function o(e){e.preventDefault();var t=e.currentTarget.getAttribute("href");if(_()||!t.startsWith("data")&&!t.startsWith("BEGIN"))window.open(t,"_blank");else{var r=new Blob([t],{type:"text/calendar;charset=utf-8"});if(O)window.navigator.msSaveOrOpenBlob(r,"download.ics");else{var n=document.createElement("a");n.href=window.URL.createObjectURL(r),n.setAttribute("download","download.ics"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}}}return r.createElement(g,{className:"mml-add-to-calendar "+(void 0===t?"":t)},r.createElement(b,{icon:"date_range",text:"Add to My Calendar"}),r.createElement(E,null,r.createElement(x,null,L.map((function(e){var t=e.id,n=e.label,a=e.Icon;return r.createElement("a",{key:t,className:"mml-btn "+(a?"mml-btn--with-icon":""),onClick:o,href:j(i,t),target:"_blank",rel:"nofollow noreferrer noopener"},a," ",n)})))))},T=function(e){var t=e.className,n=void 0===t?"":t,a=e.text,o=e.name,l=e.value,c=e.url,s=void 0===c?"":c,u=e.icon;return n+=u?a?" mml-btn--with-icon":" mml-btn--icon":" mml-btn--text",n+="floating"===e.variant?" mml-btn--floating":" mml-btn--grounded",s?r.createElement("a",{className:"mml-btn "+n,href:i.sanitizeUrl(s),target:"_blank",rel:"nofollow noreferrer noopener"},u&&r.createElement(y,{name:u}),a):r.createElement("button",{className:"mml-btn "+n,type:"submit",name:o,value:l,onClick:function(e){var t,r,n=document.createElement("input");n.type="hidden",n.name=o||"",n.value=l||"",null==(t=e.currentTarget)||null==(r=t.closest("form"))||r.appendChild(n)}},u&&r.createElement(y,{name:u}),a)},M=function(e){var n=e.slideWidth,a=void 0===n?"120px":n,i=e.className;return r.createElement("div",{className:"mml-carousel "+(void 0===i?"":i)},r.createElement("div",{className:"mml-carousel__track"},r.createElement("div",{className:"mml-carousel__slides"},t.Children.map(e.children,(function(e){return t.cloneElement(e,{className:"mml-carousel__slide",slideWidth:a})})))))},D=function(e){var t=e.width,n=e.className,a=(void 0===t?"":t)||e.slideWidth;return r.createElement("div",{className:"mml-carousel-item "+(void 0===n?"":n),style:{flex:"0 0 "+a,minWidth:a}},e.children)},F=function(e){var t=e.width,n=e.offset,a=void 0===n?0:n,i=e.align,o="mml-col-"+(void 0===t?12:t);return a&&(o=o+" mml-offset-"+a),r.createElement("div",{className:o=o+" mml-align-"+(void 0===i?"left":i)},e.children)},A=function(e){var t=e.error,n=void 0===t?"":t;return n?r.createElement("span",{className:"mml-error"},n):null},R=function(e){var t=e.src,n=e.alt,a=void 0===n?"":n,i=e.title,o=void 0===i?"":i,l=e.className;return r.createElement("img",{className:("mml-image "+(void 0===l?"":l)).trim(),src:t,alt:a,title:o})},P=function(e){var n=e.name,a=e.label,i=e.value,o=e.type,l=void 0===o?"text":o,c=e.placeholder,s=void 0===c?"":c,u=t.useState(void 0===i?"":i),m=u[0],d=u[1],f="mml-"+n;return r.createElement(r.Fragment,null,a&&r.createElement("label",{className:"mml-card-header",htmlFor:f},r.createElement("span",{className:"mml-card-header__text"},a)),r.createElement("input",{id:f,className:"mml-input",name:n,value:m,type:l,placeholder:s,onChange:function(e){return d(e.target.value)}}))},V=function(e){var t=e.size,n=e.thickness,a=void 0===n?3.6:n,i=e.color;return a="string"==typeof a?parseFloat(a):a,t="string"==typeof t&&/^\d+$/.test(t)||"number"==typeof t?t+"px":t,r.createElement("span",{className:"mml-progress",role:"progressbar",style:{width:t,height:t,color:i}},r.createElement("svg",{className:"mml-progress__svg",viewBox:"22 22 44 44"},r.createElement("circle",{className:"mml-progress__circle",cx:44,cy:44,r:(44-a)/2,fill:"none",strokeWidth:a})))},B=function(e){var t=e.className,n=e.loading,a=e.text;return void 0!==n&&n?r.createElement("div",{className:"mml-loading "+(void 0===t?"":t)},r.createElement(V,Object.assign({},{size:e.size,thickness:e.thickness,color:e.color})),a&&r.createElement("div",{className:"mml-loading__text"},a)):null},G=function(e,t,r){return void 0===r&&(r="..."),e.length>t?""+e.substring(0,t-r.length)+r:e},W={link:function(e){return e.href&&(e.href.startsWith("http")||e.href.startsWith("mailto:"))?r.createElement("a",{href:e.href,target:"_blank",rel:"nofollow noreferrer noopener"},e.children):e.children}},q=["html","root","text","break","paragraph","emphasis","strong","link","list","listItem","code","inlineCode","blockquote"],Y=function(e){var t=e.text;if(!t)return null;var n,a,i=t,c=(n=i.match(/\[([^[]+)\](\(.*\))/gm),a=/\[([^[]+)\]\((.*)\)/,n?n.map((function(e){var t=a.exec(e);return t&&t[2]})):[]);return l.find(i).forEach((function(e){var t=e.type,r=e.href,n=e.value;if(!((c&&c.filter((function(e){return-1!==(null==e?void 0:e.indexOf(r))}))).length>0)){var a="email"===t?n:G(n.replace(/(http(s?):\/\/)?(www\.)?/,""),20);i=i.replace(n,"["+a+"]("+encodeURI(r)+")")}})),r.createElement("div",{className:"mml-md"},r.createElement(o,{allowedTypes:q,renderers:W,source:i,escapeHtml:!0,unwrapDisallowed:!0,transformLinkUri:function(e){return e.startsWith("app://")?e:o.uriTransformer(e)}}))},z=function(e){var n=e.name,a=t.useState(parseInt(""+e.value,10)||0),i=a[0],o=a[1];return r.createElement("div",{className:"mml-number"},r.createElement("input",{name:n,value:i,type:"hidden"}),r.createElement("span",{className:"mml-btn mml-btn--floating mml-btn--icon mml-number__dec",onClick:function(){return o(i-1)}},r.createElement(y,{name:"remove"})),r.createElement("span",{className:"mml-number__count"},i),r.createElement("span",{className:"mml-btn mml-btn--floating mml-btn--icon mml-number__inc",onClick:function(){return o(i+1)}},r.createElement(y,{name:"add"})))},U=function(e){return r.createElement("div",{className:"mml-row"},e.children)},H=function(e){var n=e.onChange,a=e.icalFilter,i=e.getItemData,o=e.itemClassName,l=e.interval,c=e.format,u=e.value,m=t.useCallback((function(e,t){return Array(e).fill(!0).map((function(e,r){return i({interval:l,format:c,value:u,idx:t+r})})).filter((function(e){return!a||a&&a(e.value)}))}),[l,c,u,a,i]),d=t.useState(m(80,-40)),f=d[0],v=d[1],h=t.useState(1e4),p=h[0],g=h[1],y=t.useRef(40),b=t.useState(null),E=b[0],x=b[1],w=t.useCallback((function(e){n(e.value);var t=y.current||0,r=t-40-40,a=r-e.idx+3;a>=0&&(r-=a,y.current-=t-a,v((function(e){return[].concat(m(a,r),e)}))),x(e.idx)}),[v,m,y,n]),k=t.useCallback((function(e){v((function(t){return[].concat(t,m(40,e))}))}),[v,m]),N=t.useCallback((function(){var e=y.current||0,t=e-40-40;return y&&(y.current-=40),v((function(e){return[].concat(m(40,t),e)})),g(e-40),!1}),[v,m,y]);return t.useEffect((function(){if(u){for(var e=null,t=0;t<f.length;t++)if(f[t].isSelected(u)){e=f[t].idx;break}x(e)}}),[]),r.createElement(s.Virtuoso,{data:f,firstItemIndex:p,itemContent:function(e,t){return r.createElement("div",{className:o+" mml-datepicker__item "+(t.idx===E?"mml-datepicker__item--selected":""),onClick:function(){return w(t)}},t.displayValue)},endReached:k,startReached:N})},X=function(e){var t=e.idx,r=e.interval,n=e.value,i=e.format,o=t>=0?a(n).add(t*(24*r),"hour"):a(n).subtract(t*(24*r)*-1,"hour");return{idx:t,value:o,displayValue:a(o).format(i),isSelected:function(e){return a(o).isSame(1===r?a(e):a(e).add(r,"day"),"date")}}},Z=function(e){return r.createElement("div",{className:"mml-datepicker__select mml-datepicker__date"},r.createElement(H,Object.assign({},e,{itemClassName:"mml-datepicker__item--day",getItemData:X})))};a.extend(u);var $=function(e){var t=e.idx,r=e.interval,n=e.value,i=e.format,o=t>=0?a(n).add(t*r,"minute"):a(n).subtract(-1*t*r,"minute");return{idx:t,value:o,displayValue:a(o).format(i),isSelected:function(e){return a(o).isBetween(e,a(e).add(r-1,"minute"),"minute","[]")}}},J=function(e){return r.createElement("div",{className:"mml-datepicker__select mml-datepicker__time"},r.createElement(H,Object.assign({},e,{itemClassName:"mml-datepicker__item--time",getItemData:$})))},K=function(e){var n=e.name,a=e.dateInterval,i=e.timeInterval,o=e.dateFormat,l=e.timeFormat,c=e.fullDay,s=e.icalFilter,u=t.useState(e.selected),m=u[0],d=u[1];return r.createElement("div",{className:"mml-datepicker mml-datepicker--"+(c?"single":"double")},r.createElement("input",{name:n,value:m.toISOString(),type:"hidden"}),r.createElement(Z,{icalFilter:s,format:o,value:m,onChange:function(e){d((function(t){return t.set("date",e.get("date")).set("month",e.get("month")).set("year",e.get("year"))}))},interval:a}),!c&&r.createElement(J,{icalFilter:s,format:l,value:m,onChange:function(e){d((function(t){return t.set("minute",e.get("minute")).set("hour",e.get("hour"))}))},interval:i}))},Q=function(){var e=d(h.mark((function e(t,r){var n,a,i;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"GET",redirect:"follow",credentials:"same-origin"});case 2:return n=e.sent,e.next=5,n.text();case 5:if(a=e.sent,n.ok){e.next=8;break}throw new Error(a);case 8:return i=new c({ics:a,maxIterations:10}),e.abrupt("return",(function(){return function(e){return!e||!i.between(e.toDate(),e.add(r,"minute").toDate()).events.length}}));case 10:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),ee=function(e){var n=e.name,i=e.selected,o=e.icalAvailability,l=e.duration,c=void 0===l?30:l,s=e.dateInterval,u=void 0===s?1:s,m=e.timeInterval,d=void 0===m?30:m,f=e.dateFormat,v=void 0===f?"ddd MMM DD":f,h=e.timeFormat,p=void 0===h?"hh:mm A":h,y=e.fullDay,x=void 0!==y&&y,w=t.useState(!1),k=w[0],N=w[1],_=t.useState(""),O=_[0],L=_[1],I=t.useState((function(){return function(){return!0}})),C=I[0],j=I[1];return t.useEffect((function(){o&&(N(!0),Q(o,c).then(j).catch((function(e){console.warn("loading ical failed",{icalAvailability:o,err:e}),L("iCal availability could not be loaded")})).finally((function(){return N(!1)})))}),[o,c]),r.createElement(g,{className:"mml-scheduler"},r.createElement(b,{icon:"date_range",text:"Scheduler"}),r.createElement(E,null,O&&!k&&r.createElement(A,{error:"Failed, error: "+O}),!O&&k&&r.createElement(B,{loading:!0,text:"Loading availability"}),!O&&!k&&r.createElement(K,{name:n,selected:i?a(i):a().startOf("hour"),dateInterval:u,timeInterval:d,dateFormat:v,timeFormat:p,fullDay:x,icalFilter:C})))},te=function(e){var t=e.success;return t?r.createElement("div",{className:"mml-success"},t):null},re=function(e){var t=e.text,n=e.className;return r.createElement("div",{className:("mml-text "+(void 0===n?"":n)).trim()},t)},ne={button:function(e){return r.createElement(T,Object.assign({},e.attributes,{key:e.key,text:e.getText(),name:e.attributes.name,value:e.attributes.value}))},button_list:function(e,t){return r.createElement(x,Object.assign({},e.attributes,{key:e.key}),t)},input:function(e){return r.createElement(P,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,value:e.attributes.value}))},add_to_calendar:function(e){return r.createElement(S,Object.assign({},e.attributes,{key:e.key,title:e.attributes.title,start:e.attributes.start,end:e.attributes.end}))},col:function(e,t){return r.createElement(F,Object.assign({},e.attributes,{key:e.key}),t)},row:function(e,t){return r.createElement(U,Object.assign({},e.attributes,{key:e.key}),t)},icon:function(e){return r.createElement(y,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name}))},image:function(e){return r.createElement(R,Object.assign({},e.attributes,{key:e.key,src:e.attributes.src}))},md:function(e){return r.createElement(Y,Object.assign({},e.attributes,{key:e.key,text:e.getText()}))},text:function(e){return r.createElement(re,Object.assign({},e.attributes,{key:e.key,text:e.getText()}))},scheduler:function(e){return r.createElement(ee,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,dateInterval:parseInt(e.attributes.dateInterval,10)||1,timeInterval:parseInt(e.attributes.timeInterval,10)||30,duration:parseInt(e.attributes.duration,10)||30,selected:e.attributes.selected,fullDay:"true"===e.attributes.fullDay,icalAvailability:e.attributes.icalAvailability}))},carousel:function(e,t){return r.createElement(M,Object.assign({slideWidth:e.attributes.slideWidth},e.attributes,{key:e.key}),t)},item:function(e,t){return r.createElement(D,Object.assign({},e.attributes,{key:e.key}),t)},number:function(e){return r.createElement(z,Object.assign({},e.attributes,{key:e.key,name:e.attributes.name,value:e.attributes.value}))}},ae=function(){function e(e,t,r){this.converters=f({},ne,r),this.node=e,this.children=t,this.reactElements=this.toReact(),this.name=e.attributes.name,this.type=e.attributes.type}return e.prototype.toReact=function(e){var t=this;void 0===e&&(e=this);var r=[];return(e.children||[]).forEach((function(e,n){var a=t.converters[e.name];if(!a||!Object.hasOwnProperty.call(t.converters,e.name))throw Error("Converter not found for tag "+e.name+", Available converters are "+Object.keys(t.converters));var i=t.toReact(e);e.key="tag-"+e.name+"-position-"+n,r.push(a(e,i))})),r},e}();function ie(e){var t=e.trim();return t.startsWith("<mml")||(t="<mml>"+e+"</mml>"),t=t.replace(/&(?!amp;|lt;|gt;)/g,"&"),n(t)}function oe(e,t){if(!e||!e.children||!e.children.length)throw new Error("bad input");var r=e.children[0];if("mml"!==r.name)throw new Error("missing mml tag");return new ae(r,function e(t){return t.reduce((function(t,r){var n,a=r;a.children&&(n=e(a.children));var i=a.name;if("text"===r.type){if(!r.text.trim().length)return t;i="text"}return t.push(new p(i,r,n)),t}),[])}(r.children),t)}function le(e,t){return oe(ie(e),t)}exports.AddToCalendar=S,exports.Button=T,exports.ButtonList=x,exports.Card=g,exports.CardBody=E,exports.CardHeader=b,exports.Carousel=M,exports.CarouselItem=D,exports.Col=F,exports.Error=A,exports.Icon=y,exports.Image=R,exports.Input=P,exports.Loading=B,exports.MD=Y,exports.MML=function(e){var n=e.source,a=e.onSubmit,i=e.converters,o=e.theme,l=void 0===o?"":o,c=e.className,s=void 0===c?"":c,u=e.Loading,m=void 0===u?B:u,f=e.Error,v=void 0===f?A:f,p=e.Success,g=void 0===p?te:p,y=t.useState(""),b=y[0],E=y[1],x=t.useState({loading:!1,error:"",success:""}),w=x[0],k=x[1],N=t.useMemo((function(){try{return le(n,i)}catch(e){return console.warn("mml parsing error: ",n,e),E("This chat message has invalid formatting and can't be shown"),null}}),[n,i]),_=t.useCallback(function(){var e=d(h.mark((function e(t){var r;return h.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),r={},null!=N&&N.name&&(r.mml_name=N.name),new FormData(t.currentTarget).forEach((function(e,t){r[t]=e})),a){e.next=6;break}return e.abrupt("return",console.warn("Forgot to pass onSubmit prop to <MML/>? payload:",r));case 6:return e.prev=6,k({loading:!0,error:"",success:""}),e.next=10,a(r);case 10:k({loading:!1,error:"",success:"submitted"}),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(6),k({loading:!1,error:"Failed to send the request. Please try again.",success:""});case 16:case"end":return e.stop()}}),e,null,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),[a,N]);return r.createElement("div",{className:"mml-container "+l+" "+s,"data-testid":"mml-container"},b?r.createElement("div",{className:"mml-wrap"},v&&r.createElement(v,{error:b})):r.createElement("form",{onSubmit:_,className:"mml-wrap","data-testid":"mml-form"},null!=N&&N.type?r.createElement("div",{className:"mml-card"},null==N?void 0:N.reactElements):null==N?void 0:N.reactElements,w.loading&&m&&r.createElement(m,{loading:w.loading}),w.success&&g&&r.createElement(g,{success:w.success}),w.error&&v&&r.createElement(v,{error:w.error})))},exports.MMLTag=p,exports.Number=z,exports.Parse=le,exports.Row=U,exports.Scheduler=ee,exports.SourceToXML=ie,exports.Success=te,exports.Text=re,exports.Tree=ae,exports.XMLtoMMLTree=oe,exports.converters=ne,exports.truncate=G; | ||
//# sourceMappingURL=mml-react.cjs.production.min.js.map |
{ | ||
"name": "mml-react", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "MML (Message Markup Language) for React.", | ||
@@ -5,0 +5,0 @@ "author": "Getstream.io", |
@@ -39,3 +39,3 @@ import { ReactElement } from 'react'; | ||
const converter = this.converters[child.name]; | ||
if (!converter) { | ||
if (!converter || !Object.hasOwnProperty.call(this.converters, child.name)) { | ||
throw Error( | ||
@@ -42,0 +42,0 @@ `Converter not found for tag ${child.name}, Available converters are ${Object.keys(this.converters)}`, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6194
6
1016038
137